An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:sparkles: https://github.com/siyuan-note/siyuan/issues/597
Vanessaa4953fa945e6
diff --git a/app/src/assets/scss/_wysiwyg.scss b/app/src/assets/scss/_wysiwyg.scssindex 01df75a47d..f6e3f7889b 100644--- a/app/src/assets/scss/_wysiwyg.scss+++ b/app/src/assets/scss/_wysiwyg.scss@@ -19,7 +19,7 @@box-shadow: 3px 0px 0px -1px var(--b3-protyle-inline-mark-background);}- [spellcheck="false"] {+ [spellcheck] {word-break: break-word;white-space: pre-wrap;@@ -239,7 +239,7 @@padding: 0;}- &.table > [spellcheck="false"] {+ &.table > [spellcheck] {overflow: auto;& > table.select {diff --git a/app/src/block/util.ts b/app/src/block/util.tsindex 02fb860855..f13954724f 100644--- a/app/src/block/util.ts+++ b/app/src/block/util.ts@@ -147,7 +147,7 @@ export const genEmptyBlock = (zwsp = true, wbr = true, string?: string) => {if (string) {html += string;}- return `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="false">${html}</div><div contenteditable="false" class="protyle-attr">${Constants.ZWSP}</div></div>`;+ return `<div data-node-id="${Lute.NewNodeID()}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${html}</div><div contenteditable="false" class="protyle-attr">${Constants.ZWSP}</div></div>`;};export const genEmptyElement = (zwsp = true, wbr = true, id?: string) => {@@ -155,6 +155,6 @@ export const genEmptyElement = (zwsp = true, wbr = true, id?: string) => {element.setAttribute("data-node-id", id || Lute.NewNodeID());element.setAttribute("data-type", "NodeParagraph");element.classList.add("p");- element.innerHTML = `<div contenteditable="true" spellcheck="false">${zwsp ? Constants.ZWSP : ""}${wbr ? "<wbr>" : ""}</div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;+ element.innerHTML = `<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${zwsp ? Constants.ZWSP : ""}${wbr ? "<wbr>" : ""}</div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;return element;};diff --git a/app/src/config/search.ts b/app/src/config/search.tsindex afe836398f..d594cd9fa4 100644--- a/app/src/config/search.ts+++ b/app/src/config/search.ts@@ -16,7 +16,8 @@ export const initConfigSearch = (element: HTMLElement) => {"md39", "md40", "fontSizeTip", "fontSize", "font", "font1", "generateHistory", "generateHistoryInterval","historyRetentionDays", "historyRetentionDaysTip", "clearHistory", "katexMacros", "katexMacrosTip","editReadonly", "editReadonlyTip", "embedBlockBreadcrumb", "embedBlockBreadcrumbTip", "outdentTip",- "outdent", "floatWindowMode", "floatWindowModeTip", "justify", "justifyTip", "rtl", "rtlTip"+ "outdent", "floatWindowMode", "floatWindowModeTip", "justify", "justifyTip", "rtl", "rtlTip", "spellcheck",+ "spellcheckTip"]),// 文档树diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.tsindex 7bfeaa324d..49e9891613 100644--- a/app/src/layout/dock/Outline.ts+++ b/app/src/layout/dock/Outline.ts@@ -193,7 +193,7 @@ export class Outline extends Model {let needReload = false;data.data[0].doOperations.forEach((item: IOperation) => {if ((item.action === "update" || item.action === "insert") &&- (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf('<div contenteditable="true" spellcheck="false"><wbr></div>') > -1)) {+ (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`<div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div>`) > -1)) {needReload = true;} else if (item.action === "delete" || item.action === "move") {needReload = true;diff --git a/app/src/protyle/gutter/index.ts b/app/src/protyle/gutter/index.tsindex 38affbddbb..532f4b1076 100644--- a/app/src/protyle/gutter/index.ts+++ b/app/src/protyle/gutter/index.ts@@ -591,7 +591,7 @@ export class Gutter {click() {let html = "";selectsElement.forEach(item => {- item.querySelectorAll('[spellcheck="false"]').forEach(editItem => {+ item.querySelectorAll('[spellcheck]').forEach(editItem => {const cloneNode = editItem.cloneNode(true) as HTMLElement;cloneNode.querySelectorAll('[data-type="backslash"]').forEach(slashItem => {slashItem.firstElementChild.remove();@@ -980,7 +980,7 @@ export class Gutter {accelerator: window.siyuan.config.keymap.editor.general.copyPlainText.custom,click() {let text = "";- nodeElement.querySelectorAll('[spellcheck="false"]').forEach(item => {+ nodeElement.querySelectorAll('[spellcheck]').forEach(item => {const cloneNode = item.cloneNode(true) as HTMLElement;cloneNode.querySelectorAll('[data-type="backslash"]').forEach(slashItem => {slashItem.firstElementChild.remove();diff --git a/app/src/protyle/header/Title.ts b/app/src/protyle/header/Title.tsindex 2d212c4abe..6707ec376d 100644--- a/app/src/protyle/header/Title.ts+++ b/app/src/protyle/header/Title.ts@@ -45,7 +45,7 @@ export class Title {this.element.classList.add("protyle-wysiwyg--attr");}this.element.innerHTML = `<span aria-label="${window.siyuan.languages.gutterTip2}" class="protyle-title__icon" data-type="a" data-position="right"><svg><use xlink:href="#iconFile"></use></svg></span>-<div contenteditable="true" data-position="center" spellcheck="false" class="protyle-title__input" data-tip="${window.siyuan.languages._kernel[16]}"></div><div class="protyle-attr"></div>`;+<div contenteditable="true" data-position="center" spellcheck="${window.siyuan.config.editor.spellcheck}" class="protyle-title__input" data-tip="${window.siyuan.languages._kernel[16]}"></div><div class="protyle-attr"></div>`;this.editElement = this.element.querySelector(".protyle-title__input");this.editElement.addEventListener("paste", (event: ClipboardEvent) => {event.stopPropagation();diff --git a/app/src/protyle/markdown/highlightRender.ts b/app/src/protyle/markdown/highlightRender.tsindex dfb83e2588..f323c57c7e 100644--- a/app/src/protyle/markdown/highlightRender.ts+++ b/app/src/protyle/markdown/highlightRender.ts@@ -9,7 +9,7 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =let isPreview = false;if (element.classList.contains("code-block")) {// 编辑器内代码块编辑渲染- codeElements = element.querySelectorAll('[spellcheck="false"]');+ codeElements = element.querySelectorAll('[spellcheck]');} else {if (element.classList.contains("item__readme")) {// bazaar reademe@@ -22,7 +22,7 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =codeElements = element.querySelectorAll(".code-block code");isPreview = true;} else {- codeElements = element.querySelectorAll('.code-block [spellcheck="false"]');+ codeElements = element.querySelectorAll('.code-block [spellcheck]');}}if (codeElements.length === 0) {diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.tsindex 11ce56f13a..5ba8f38cd1 100644--- a/app/src/protyle/util/onGet.ts+++ b/app/src/protyle/util/onGet.ts@@ -336,7 +336,7 @@ export const disabledProtyle = (protyle: IProtyle) => {});protyle.wysiwyg.element.style.userSelect = "text";protyle.wysiwyg.element.setAttribute("contenteditable", "false");- protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck="false"]').forEach(item => {+ protyle.wysiwyg.element.querySelectorAll('[contenteditable="true"][spellcheck]').forEach(item => {item.setAttribute("contenteditable", "false");});};@@ -361,7 +361,7 @@ export const enableProtyle = (protyle: IProtyle) => {if (protyle.background) {protyle.background.element.classList.add("protyle-background--enable");}- protyle.wysiwyg.element.querySelectorAll('[contenteditable="false"][spellcheck="false"]').forEach(item => {+ protyle.wysiwyg.element.querySelectorAll('[contenteditable="false"][spellcheck]').forEach(item => {if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) {item.setAttribute("contenteditable", "true");}diff --git a/app/src/protyle/util/paste.ts b/app/src/protyle/util/paste.tsindex fd6685f8c7..a7126d2c3a 100644--- a/app/src/protyle/util/paste.ts+++ b/app/src/protyle/util/paste.ts@@ -237,7 +237,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEvenisBlock = false;}// 从历史中复制后粘贴- tempElement.querySelectorAll('[spellcheck="false"][contenteditable="false"]').forEach((e) => {+ tempElement.querySelectorAll('[contenteditable="false"][spellcheck]').forEach((e) => {e.setAttribute("contenteditable", "true");});const tempInnerHTML = tempElement.innerHTML;diff --git a/app/src/protyle/util/processCode.ts b/app/src/protyle/util/processCode.tsindex 0b79ca2252..40fa74061d 100644--- a/app/src/protyle/util/processCode.ts+++ b/app/src/protyle/util/processCode.ts@@ -36,7 +36,7 @@ export const processPasteCode = (html: string, text: string) => {if (isCode) {const code = text || html;if (/\n/.test(code) || pres.length === 1) {- return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${localStorage.getItem(Constants.LOCAL_CODELANG) || ""}</span><span class="fn__flex-1"></span><span class="protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span class="protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="false">${code.replace(/&/g, "&").replace(/</g, "<")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;+ return `<div data-type="NodeCodeBlock" class="code-block" data-node-id="${Lute.NewNodeID()}"><div class="protyle-action"><span class="protyle-action--first protyle-action__language" contenteditable="false">${localStorage.getItem(Constants.LOCAL_CODELANG) || ""}</span><span class="fn__flex-1"></span><span class="protyle-icon protyle-icon--first protyle-action__copy"><svg><use xlink:href="#iconCopy"></use></svg></span><span class="protyle-icon protyle-icon--last protyle-action__menu"><svg><use xlink:href="#iconMore"></use></svg></span></div><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}">${code.replace(/&/g, "&").replace(/</g, "<")}<wbr></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div></div>`;} else {return code;}diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.tsindex 3b7da3835b..06fafe6121 100644--- a/app/src/protyle/util/reload.ts+++ b/app/src/protyle/util/reload.ts@@ -9,10 +9,16 @@ import {hasClosestByClassName} from "./hasClosest";export const reloadProtyle = (protyle: IProtyle) => {if (window.siyuan.config.editor.displayBookmarkIcon) {protyle.wysiwyg.element.classList.add("protyle-wysiwyg--attr");- protyle.title?.element.classList.add("protyle-wysiwyg--attr");} else {protyle.wysiwyg.element.classList.remove("protyle-wysiwyg--attr");- protyle.title?.element.classList.remove("protyle-wysiwyg--attr");+ }+ if (protyle.title) {+ protyle.title.element.setAttribute("spellcheck", window.siyuan.config.editor.spellcheck.toString());+ if (window.siyuan.config.editor.displayBookmarkIcon) {+ protyle.title.element.classList.add("protyle-wysiwyg--attr");+ } else {+ protyle.title.element.classList.remove("protyle-wysiwyg--attr");+ }}protyle.lute.SetProtyleMarkNetImg(window.siyuan.config.editor.displayNetImgMark);addLoading(protyle);diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.tsindex abf43aefb6..5c3fc63bc3 100644--- a/app/src/protyle/wysiwyg/input.ts+++ b/app/src/protyle/wysiwyg/input.ts@@ -102,13 +102,13 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range:// 仅有一项的列表才可转换if (!blockElement.parentElement.parentElement.classList.contains("protyle-wysiwyg") && // https://ld246.com/article/1659315815506blockElement.parentElement.parentElement.childElementCount === 2) {- html = `<div data-subtype="t" data-node-id="${blockElement.parentElement.parentElement.getAttribute("data-node-id")}" data-type="NodeList" class="list"><div data-marker="*" data-subtype="t" data-node-id="${blockElement.parentElement.getAttribute("data-node-id")}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div><div data-node-id="${id}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="false"><wbr></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;+ html = `<div data-subtype="t" data-node-id="${blockElement.parentElement.parentElement.getAttribute("data-node-id")}" data-type="NodeList" class="list"><div data-marker="*" data-subtype="t" data-node-id="${blockElement.parentElement.getAttribute("data-node-id")}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div><div data-node-id="${id}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;id = blockElement.parentElement.parentElement.getAttribute("data-node-id");blockElement = blockElement.parentElement.parentElement;todoOldHTML = blockElement.outerHTML;}} else {- html = `<div data-subtype="t" data-node-id="${id}" data-type="NodeList" class="list"><div data-marker="*" data-subtype="t" data-node-id="${Lute.NewNodeID()}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div><div data-node-id="${Lute.NewNodeID()}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="false"><wbr></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;+ html = `<div data-subtype="t" data-node-id="${id}" data-type="NodeList" class="list"><div data-marker="*" data-subtype="t" data-node-id="${Lute.NewNodeID()}" data-type="NodeListItem" class="li${isDone ? " protyle-task--done" : ""}"><div class="protyle-action protyle-action--task" draggable="true"><svg><use xlink:href="#icon${isDone ? "C" : "Unc"}heck"></use></svg></div><div data-node-id="${Lute.NewNodeID()}" data-type="NodeParagraph" class="p"><div contenteditable="true" spellcheck="${window.siyuan.config.editor.spellcheck}"><wbr></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div><div class="protyle-attr" contenteditable="false"></div></div>`;todoOldHTML = blockElement.outerHTML;}} else {diff --git a/app/src/protyle/wysiwyg/removeEmbed.ts b/app/src/protyle/wysiwyg/removeEmbed.tsindex a07bb90df9..c07b4fcfb4 100644--- a/app/src/protyle/wysiwyg/removeEmbed.ts+++ b/app/src/protyle/wysiwyg/removeEmbed.ts@@ -17,7 +17,7 @@ export const removeEmbed = (element: Element, type: "outerHTML" | "innerHTML" =export const getEnableHTML = (html: string) => {const tempElement = document.createElement("template");tempElement.innerHTML = html;- tempElement.content.querySelectorAll('[contenteditable="false"][spellcheck="false"]').forEach(item => {+ tempElement.content.querySelectorAll('[contenteditable="false"][spellcheck]').forEach(item => {if (!hasClosestByClassName(item, "protyle-wysiwyg__embed")) {item.setAttribute("contenteditable", "true");}diff --git a/app/src/util/assets.ts b/app/src/util/assets.tsindex 02c3720275..4d489757ee 100644--- a/app/src/util/assets.ts+++ b/app/src/util/assets.ts@@ -174,7 +174,7 @@ export const setInlineStyle = (set = true) => {.protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h1, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h2, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h3, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h4, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h5, .protyle-wysiwyg [data-node-id].li > .protyle-action ~ .h6 {line-height:${height + 8}px;}.protyle-wysiwyg [data-node-id].li > .protyle-action:after {height: ${window.siyuan.config.editor.fontSize}px;width: ${window.siyuan.config.editor.fontSize}px;margin:-${window.siyuan.config.editor.fontSize / 2}px 0 0 -${window.siyuan.config.editor.fontSize / 2}px}.protyle-wysiwyg [data-node-id].li > .protyle-action svg {height: ${Math.max(14, window.siyuan.config.editor.fontSize - 8)}px}-.protyle-wysiwyg [data-node-id] [spellcheck="false"] {min-height:${height}px;}+.protyle-wysiwyg [data-node-id] [spellcheck] {min-height:${height}px;}.protyle-wysiwyg [data-node-id] {${window.siyuan.config.editor.rtl ? " direction: rtl;" : ""}${window.siyuan.config.editor.justify ? " text-align: justify;" : ""}}.protyle-wysiwyg .li {min-height:${height + 8}px}.protyle-gutters button svg {height:${height}px}