From 9a7ac9e7d807802cb78411a09c61290a760e5bf7 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Sat, 22 Oct 2022 19:56:16 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/6299 --- app/src/protyle/header/Title.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts index e19420157..30e5dc242 100644 --- a/app/src/protyle/header/Title.ts +++ b/app/src/protyle/header/Title.ts @@ -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(() => {