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 ||