Vanessa 2024-05-12 22:47:01 +08:00
parent 9c367dc79e
commit 6bfdaf35e4

View File

@ -5,6 +5,7 @@ import {updateHotkeyTip} from "../util/compatibility";
import {hasClosestByClassName} from "../util/hasClosest"; import {hasClosestByClassName} from "../util/hasClosest";
import {goEnd, goHome} from "../wysiwyg/commonHotkey"; import {goEnd, goHome} from "../wysiwyg/commonHotkey";
import {isMobile} from "../../util/functions"; import {isMobile} from "../../util/functions";
import {showTooltip} from "../../dialog/tooltip";
export class Scroll { export class Scroll {
public element: HTMLElement; public element: HTMLElement;
@ -38,6 +39,7 @@ export class Scroll {
this.inputElement = this.element.firstElementChild as HTMLInputElement; this.inputElement = this.element.firstElementChild as HTMLInputElement;
this.inputElement.addEventListener("input", () => { this.inputElement.addEventListener("input", () => {
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${protyle.block.blockCount}`); this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${protyle.block.blockCount}`);
showTooltip(this.element.getAttribute("aria-label"), this.element);
}); });
/// #if BROWSER /// #if BROWSER
this.inputElement.addEventListener("change", () => { this.inputElement.addEventListener("change", () => {
@ -74,11 +76,14 @@ export class Scroll {
data: getResponse, data: getResponse,
protyle, protyle,
action: [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID], action: [Constants.CB_GET_FOCUSFIRST, Constants.CB_GET_UNCHANGEID],
afterCB: () => {
showTooltip(this.element.getAttribute("aria-label"), this.element);
}
}); });
}); });
} }
public updateIndex(protyle: IProtyle, id: string, cb?:(index: number) => void) { public updateIndex(protyle: IProtyle, id: string, cb?: (index: number) => void) {
fetchPost("/api/block/getBlockIndex", {id}, (response) => { fetchPost("/api/block/getBlockIndex", {id}, (response) => {
if (!response.data) { if (!response.data) {
return; return;