Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/6299

Vanessa9a7ac9e7d807
diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.ts
index e19420157e..30e5dc242a 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(() => {