An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/5202
Vanessac4360840c267
diff --git a/app/src/assets/scss/_protyle.scss b/app/src/assets/scss/_protyle.scssindex 20bc4d6e33..0774f150d3 100644--- a/app/src/assets/scss/_protyle.scss+++ b/app/src/assets/scss/_protyle.scss@@ -394,10 +394,6 @@&:focus {outline: none;}-- &--untitled {- color: var(--b3-theme-on-surface);- }}}diff --git a/app/src/editor/rename.ts b/app/src/editor/rename.tsindex bc1ff5bcb0..d0b4cf9e36 100644--- a/app/src/editor/rename.ts+++ b/app/src/editor/rename.ts@@ -19,7 +19,7 @@ export const validateName = (name: string) => {};export const replaceFileName = (name: string) => {- return name.replace(/\r\n|\r|\n|\u2028|\u2029|\t|\//g, "").trim();+ return name.replace(/\r\n|\r|\n|\u2028|\u2029|\t|\//g, "");};export const rename = (options: {@@ -130,7 +130,7 @@ export const newFileBySelect = (fileName: string, protyle: IProtyle) => {const id = Lute.NewNodeID();fetchPost("/api/filetree/createDoc", {notebook: protyle.notebookId,- path: pathPosix().join(getDisplayName(protyle.path, false, true), id+ ".sy"),+ path: pathPosix().join(getDisplayName(protyle.path, false, true), id + ".sy"),title: fileName,md: ""}, () => {diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 2e4e187c4a..9e7863879c 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -25,6 +25,7 @@ import {setTitle} from "../../dialog/processSystem";import {getNoContainerElement} from "../wysiwyg/getBlock";import {commonHotkey} from "../wysiwyg/commonHotkey";import {setPosition} from "../../util/setPosition";+import {code160to32} from "../util/code160to32";export class Title {public element: HTMLElement;@@ -228,22 +229,15 @@ export class Title {private rename(protyle: IProtyle) {if (!validateName(this.editElement.textContent)) {- this.editElement.textContent = replaceFileName(this.editElement.textContent);return false;}- if (this.editElement.textContent.trim() === "" || this.editElement.textContent.trim() === window.siyuan.languages.untitled) {- this.editElement.textContent = window.siyuan.languages.untitled;- this.editElement.classList.add("protyle-title__input--untitled");- } else {- this.editElement.classList.remove("protyle-title__input--untitled");- }const fileName = replaceFileName(this.editElement.textContent);fetchPost("/api/filetree/renameDoc", {notebook: protyle.notebookId,path: protyle.path,title: fileName,});- this.editElement.textContent = fileName;+ this.setTitle(fileName)}private renderMenu(protyle: IProtyle, iconElement: Element, position: { x: number, y: number }) {@@ -333,6 +327,12 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))});}+ public setTitle(title: string) {+ if (code160to32(title) !== code160to32(this.editElement.textContent)) {+ this.editElement.textContent = title === "Untitled" ? "" : title;+ }+ }+public render(protyle: IProtyle, refresh = false) {if (this.editElement.getAttribute("data-render") === "true" && !refresh) {return;@@ -344,12 +344,7 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))protyle.background.render(response.data.ial, protyle.block.rootID);protyle.wysiwyg.renderCustom(response.data.ial);this.editElement.setAttribute("data-render", "true");- this.editElement.textContent = response.data.ial.title;- if (response.data.ial.title === window.siyuan.languages.untitled) {- this.editElement.classList.add("protyle-title__input--untitled");- } else {- this.editElement.classList.remove("protyle-title__input--untitled");- }+ this.setTitle(response.data.ial.title);let nodeAttrHTML = "";if (response.data.ial.bookmark) {nodeAttrHTML += `<div class="protyle-attr--bookmark">${Lute.EscapeHTMLStr(response.data.ial.bookmark)}</div>`;@@ -367,7 +362,7 @@ ${window.siyuan.languages.createdAt} ${dayjs(response.data.ial.id.substr(0, 14))if (response.data.refCount !== 0) {this.element.querySelector(".protyle-attr").insertAdjacentHTML("beforeend", `<div class="protyle-attr--refcount popover__block" data-defids='${JSON.stringify([protyle.block.rootID])}' data-id='${JSON.stringify(response.data.refIDs)}'>${response.data.refCount}</div>`);}- // 存在设置新建文档名模板,不能使用 window.siyuan.languages.untitled 进行判断,https://ld246.com/article/1649301009888+ // 存在设置新建文档名模板,不能使用 Untitled 进行判断,https://ld246.com/article/1649301009888if (new Date().getTime() - dayjs(response.data.id.split("-")[0]).toDate().getTime() < 2000) {const range = this.editElement.ownerDocument.createRange();range.selectNodeContents(this.editElement);diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.tsindex 8e8a6337f1..1855c52484 100644--- a/app/src/protyle/hint/index.ts+++ b/app/src/protyle/hint/index.ts@@ -493,10 +493,10 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;fetchPost("/api/filetree/createDoc", {notebook: protyle.notebookId,path: pathPosix().join(getDisplayName(protyle.path, false, true), newSubDocId + ".sy"),- title: window.siyuan.languages.untitled,+ title: "Untitled",md: ""}, () => {- insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">${escapeHtml(window.siyuan.languages.untitled)}</span>`), protyle);+ insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`), protyle);if (isMobile()) {openMobileFileById(newSubDocId, true);} else {diff --git a/app/src/protyle/index.ts b/app/src/protyle/index.tsindex 42ca405ded..a50c056f31 100644--- a/app/src/protyle/index.ts+++ b/app/src/protyle/index.ts@@ -108,7 +108,7 @@ class Protyle {this.protyle.model.parent.updateTitle(data.data.title);}if (this.protyle.options.render.title && this.protyle.block.parentID === data.data.id) {- this.protyle.title.editElement.textContent = data.data.title;+ this.protyle.title.setTitle(data.data.title);}// update refthis.protyle.wysiwyg.element.querySelectorAll(`[data-type="block-ref"][data-id="${data.data.id}"]`).forEach(item => {diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.tsindex 633404b06a..d901132149 100644--- a/app/src/util/newFile.ts+++ b/app/src/util/newFile.ts@@ -54,7 +54,7 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: booleafetchPost("/api/filetree/createDoc", {notebook: notebookId,path: pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy"),- title: data.data.name || window.siyuan.languages.untitled,+ title: data.data.name || "Untitled",md: "",}, () => {if (open && !isMobile()) {