diff --git a/app/src/assets/scss/_wysiwyg.scss b/app/src/assets/scss/_wysiwyg.scss index 01df75a47..f6e3f7889 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.ts index 02fb86085..f13954724 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 `
${html}
${Constants.ZWSP}
`; + return `
${html}
${Constants.ZWSP}
`; }; 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 = `
${zwsp ? Constants.ZWSP : ""}${wbr ? "" : ""}
${Constants.ZWSP}
`; + element.innerHTML = `
${zwsp ? Constants.ZWSP : ""}${wbr ? "" : ""}
${Constants.ZWSP}
`; return element; }; diff --git a/app/src/config/search.ts b/app/src/config/search.ts index afe836398..d594cd9fa 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.ts index 7bfeaa324..49e989161 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('
') > -1)) { + (item.data.indexOf('data-type="NodeHeading"') > -1 || item.data.indexOf(`
`) > -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.ts index 38affbddb..532f4b107 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.ts index 2d212c4ab..6707ec376 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 = ` -
`; +
`; 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.ts index dfb83e258..f323c57c7 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.ts index 11ce56f13..5ba8f38cd 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.ts index fd6685f8c..a7126d2c3 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 | DragEven isBlock = 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.ts index 0b79ca225..40fa74061 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 `
${localStorage.getItem(Constants.LOCAL_CODELANG) || ""}
${code.replace(/&/g, "&").replace(/
${Constants.ZWSP}
`; + return `
${localStorage.getItem(Constants.LOCAL_CODELANG) || ""}
${code.replace(/&/g, "&").replace(/
${Constants.ZWSP}
`; } else { return code; } diff --git a/app/src/protyle/util/reload.ts b/app/src/protyle/util/reload.ts index 3b7da3835..06fafe612 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.ts index abf43aefb..5c3fc63bc 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/1659315815506 blockElement.parentElement.parentElement.childElementCount === 2) { - html = `
`; + html = `
`; id = blockElement.parentElement.parentElement.getAttribute("data-node-id"); blockElement = blockElement.parentElement.parentElement; todoOldHTML = blockElement.outerHTML; } } else { - html = `
`; + html = `
`; todoOldHTML = blockElement.outerHTML; } } else { diff --git a/app/src/protyle/wysiwyg/removeEmbed.ts b/app/src/protyle/wysiwyg/removeEmbed.ts index a07bb90df..c07b4fcfb 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.ts index 02c372027..4d489757e 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}