Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 撤销后保持原有光标位置 https://github.com/siyuan-note/siyuan/issues/13027

Vanessa908c2eae5633
diff --git a/app/src/protyle/util/table.ts b/app/src/protyle/util/table.ts
index 57413373a9..815f9cf7eb 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 a604c5f83a..02212fde29 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 ||