Vanessa 2022-10-22 19:56:16 +08:00
parent 23899f762c
commit 9a7ac9e7d8

View file

@ -1,7 +1,7 @@
import {
focusBlock,
focusBlock, focusByOffset,
focusByRange, focusByWbr,
getEditorRange,
getEditorRange, getSelectionOffset,
} from "../util/selection";
import {fetchPost} from "../../util/fetch";
import {replaceFileName, validateName} from "../../editor/rename";
@ -252,7 +252,9 @@ export class Title {
private rename(protyle: IProtyle) {
clearTimeout(this.timeout);
if (!validateName(this.editElement.textContent)) {
const offset = getSelectionOffset(this.editElement)
this.setTitle(this.editElement.textContent.substring(0, Constants.SIZE_TITLE));
focusByOffset(this.editElement, offset.start, offset.end);
return false;
}
this.timeout = window.setTimeout(() => {