From 908c2eae563380c118a29f9489e76db3bd9513b8 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Thu, 12 Dec 2024 10:48:57 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=92=A4=E9=94=80=E5=90=8E=E4=BF=9D?= =?UTF-8?q?=E6=8C=81=E5=8E=9F=E6=9C=89=E5=85=89=E6=A0=87=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=20https://github.com/siyuan-note/siyuan/issues/13027?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/protyle/util/table.ts | 7 +++++++ app/src/protyle/wysiwyg/index.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts index 57413373a..815f9cf7e 100644 --- a/app/src/protyle/util/table.ts +++ b/app/src/protyle/util/table.ts @@ -737,7 +737,14 @@ export const clearTableCell = (protyle: IProtyle, tableBlockElement: HTMLElement } }); tableSelectElement.removeAttribute("style"); + if (getSelection().rangeCount>0) { + const range = getSelection().getRangeAt(0) + if (tableBlockElement.contains(range.startContainer)) { + range.insertNode(document.createElement("wbr")) + } + } const oldHTML = tableBlockElement.outerHTML; + tableBlockElement.querySelector("wbr")?.remove(); tableBlockElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); selectCellElements.forEach(item => { item.innerHTML = ""; diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index a604c5f83..02212fde2 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1482,7 +1482,14 @@ export class WYSIWYG { } }); tableSelectElement.removeAttribute("style"); + if (getSelection().rangeCount>0) { + const range = getSelection().getRangeAt(0) + if (nodeElement.contains(range.startContainer)) { + range.insertNode(document.createElement("wbr")) + } + } const oldHTML = nodeElement.outerHTML; + nodeElement.querySelector("wbr")?.remove(); nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); selectCellElements.forEach((item, index) => { if (index === 0 || !item.previousElementSibling ||