From 079328dee9df9031825713da3e3bddca34ef68d0 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 24 Nov 2023 20:54:08 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20https://github.com/siyuan-note/siyuan/i?= =?UTF-8?q?ssues/9727=20=E8=BD=AC=E4=B9=89=E7=AC=A6dom=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/toolbar/index.ts | 4 ---- app/src/protyle/wysiwyg/input.ts | 9 ++------- app/src/protyle/wysiwyg/keydown.ts | 21 --------------------- 3 files changed, 2 insertions(+), 32 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 516a154be..10a3f2b82 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -561,10 +561,6 @@ export class Toolbar { nextIndex = item.textContent.length; nextElement.innerHTML = item.innerHTML + nextElement.innerHTML; } else if (item.tagName !== "BR" && item.tagName !== "IMG") { - if (item.getAttribute("data-type")?.indexOf("backslash") > -1 && - item.firstChild?.textContent === "\\") { - item.firstChild.remove(); - } item.setAttribute("data-type", types.join(" ")); setFontStyle(item, textObj); newNodes.push(item); diff --git a/app/src/protyle/wysiwyg/input.ts b/app/src/protyle/wysiwyg/input.ts index b172d920f..068f7f2c5 100644 --- a/app/src/protyle/wysiwyg/input.ts +++ b/app/src/protyle/wysiwyg/input.ts @@ -145,13 +145,8 @@ export const input = async (protyle: IProtyle, blockElement: HTMLElement, range: if (blockElement.classList.contains("table")) { scrollLeft = getContenteditableElement(blockElement).scrollLeft; } - if (/\\<\/span>.<\/span>/.test(html)) { - // 转义不需要添加 zwsp - blockElement.outerHTML = html; - } else { - // 使用 md 闭合后继续输入应为普通文本 - blockElement.outerHTML = html.replace("", "" + Constants.ZWSP + ""); - } + // 使用 md 闭合后继续输入应为普通文本 + blockElement.outerHTML = html.replace("", "" + Constants.ZWSP + ""); protyle.wysiwyg.element.querySelectorAll(`[data-node-id="${id}"]`).forEach((item: HTMLElement) => { if (item.getAttribute("data-type") === "NodeBlockQueryEmbed" || !hasClosestByAttribute(item, "data-type", "NodeBlockQueryEmbed")) { diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts index fcbd09e44..aff24df76 100644 --- a/app/src/protyle/wysiwyg/keydown.ts +++ b/app/src/protyle/wysiwyg/keydown.ts @@ -757,27 +757,6 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => { return; } } - // 行首转义符前删除 https://github.com/siyuan-note/siyuan/issues/6092 - if (range.startOffset === 0 && selectText === "" && - previousSibling && previousSibling.parentElement.getAttribute("data-type")?.indexOf("backslash") > -1 && - previousSibling.nodeType !== 3 && (previousSibling as HTMLElement).outerHTML === "\\" && - !hasPreviousSibling(previousSibling.parentElement)) { - range.setStartBefore(previousSibling.parentElement); - removeBlock(protyle, nodeElement, range); - event.stopPropagation(); - event.preventDefault(); - return; - } - // 光标位于转义符前 F5 后,rang 和点击后的不同,也需进行判断 - if (range.startOffset === 1 && range.startContainer.nodeType !== 3 && - range.startContainer.parentElement.getAttribute("data-type")?.indexOf("backslash") > -1 && - !hasPreviousSibling(range.startContainer.parentElement)) { - range.setStartBefore(range.startContainer.parentElement); - removeBlock(protyle, nodeElement, range); - event.stopPropagation(); - event.preventDefault(); - return; - } const imgSelectElement = protyle.wysiwyg.element.querySelector(".img--select"); if (imgSelectElement) { imgSelectElement.classList.remove("img--select");