mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-24 07:54:07 +01:00
This commit is contained in:
parent
91c1b00305
commit
86878ffcc4
3 changed files with 18 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
|||
import {focusByWbr, getEditorRange} from "../protyle/util/selection";
|
||||
import {hasClosestBlock} from "../protyle/util/hasClosest";
|
||||
import {getTopAloneElement} from "../protyle/wysiwyg/getBlock";
|
||||
import {getContenteditableElement, getTopAloneElement} from "../protyle/wysiwyg/getBlock";
|
||||
import {genListItemElement, updateListOrder} from "../protyle/wysiwyg/list";
|
||||
import {transaction, turnsIntoOneTransaction, updateTransaction} from "../protyle/wysiwyg/transaction";
|
||||
import {scrollCenter} from "../util/highlightById";
|
||||
|
|
@ -11,7 +11,7 @@ import {fetchPost, fetchSyncPost} from "../util/fetch";
|
|||
import {openFileById} from "../editor/util";
|
||||
import {openMobileFileById} from "../mobile/editor";
|
||||
|
||||
export const cancelSB = async (protyle: IProtyle, nodeElement: Element) => {
|
||||
export const cancelSB = async (protyle: IProtyle, nodeElement: Element, range?: Range) => {
|
||||
const doOperations: IOperation[] = [];
|
||||
const undoOperations: IOperation[] = [];
|
||||
let previousId = nodeElement.previousElementSibling ? nodeElement.previousElementSibling.getAttribute("data-node-id") : undefined;
|
||||
|
|
@ -45,12 +45,18 @@ export const cancelSB = async (protyle: IProtyle, nodeElement: Element) => {
|
|||
action: "delete",
|
||||
id,
|
||||
});
|
||||
if (range) {
|
||||
getContenteditableElement(nodeElement).insertAdjacentHTML("afterbegin", "<wbr>")
|
||||
}
|
||||
nodeElement.lastElementChild.remove();
|
||||
// 超级块中的 html 块需要反转义再赋值 https://github.com/siyuan-note/siyuan/issues/13155
|
||||
nodeElement.querySelectorAll("protyle-html").forEach(item => {
|
||||
item.setAttribute("data-content", item.getAttribute("data-content").replace(/</g, "<").replace(/>/g, ">"));
|
||||
});
|
||||
nodeElement.outerHTML = nodeElement.innerHTML;
|
||||
if (range) {
|
||||
focusByWbr(protyle.wysiwyg.element, range);
|
||||
}
|
||||
return;
|
||||
}
|
||||
doOperations.push({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue