Skip to content

Commit

Permalink
🎨 撤销后保持原有光标位置 #13027
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 12, 2024
1 parent 99e2628 commit 908c2ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/src/protyle/util/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
7 changes: 7 additions & 0 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ||
Expand Down

0 comments on commit 908c2ea

Please sign in to comment.