mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 09:30:14 +01:00
🚨
This commit is contained in:
parent
aade1e56f3
commit
1679df6209
3 changed files with 11 additions and 11 deletions
|
|
@ -11,7 +11,7 @@ export const cancelSB = (protyle: IProtyle, nodeElement: Element) => {
|
|||
const undoOperations: IOperation[] = [];
|
||||
let previousId = nodeElement.previousElementSibling ? nodeElement.previousElementSibling.getAttribute("data-node-id") : undefined;
|
||||
nodeElement.classList.remove("protyle-wysiwyg--select");
|
||||
const id = nodeElement.getAttribute("data-node-id")
|
||||
const id = nodeElement.getAttribute("data-node-id");
|
||||
const sbElement = genSBElement(nodeElement.getAttribute("data-sb-layout"), id, nodeElement.lastElementChild.outerHTML);
|
||||
undoOperations.push({
|
||||
action: "insert",
|
||||
|
|
@ -47,8 +47,8 @@ export const cancelSB = (protyle: IProtyle, nodeElement: Element) => {
|
|||
|
||||
return {
|
||||
doOperations, undoOperations, previousId
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
export const genSBElement = (layout: string, id?: string, attrHTML?: string) => {
|
||||
const sbElement = document.createElement("div");
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ export const focusSideBlock = (updateElement: Element) => {
|
|||
if (!sideBlockElement) {
|
||||
sideBlockElement = updateElement;
|
||||
}
|
||||
focusBlock(sideBlockElement);
|
||||
focusBlock(sideBlockElement, undefined, collapse);
|
||||
return;
|
||||
}
|
||||
const range = getEditorRange(updateElement);
|
||||
|
|
|
|||
|
|
@ -180,11 +180,11 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
|
|||
let sideElement = selectElements[0].previousElementSibling || selectElements[selectElements.length - 1].nextElementSibling;
|
||||
let listElement: Element;
|
||||
let topElementId: string;
|
||||
let topParentElement: Element
|
||||
let topParentElement: Element;
|
||||
selectElements.find((item: HTMLElement) => {
|
||||
item.classList.remove("protyle-wysiwyg--select");
|
||||
const topElement = getTopAloneElement(item);
|
||||
topParentElement = topElement.parentElement
|
||||
topParentElement = topElement.parentElement;
|
||||
topElementId = topElement.getAttribute("data-node-id");
|
||||
const id = topElement.getAttribute("data-node-id");
|
||||
deletes.push({
|
||||
|
|
@ -378,26 +378,26 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
|
|||
return;
|
||||
}
|
||||
|
||||
const parentElement = blockElement.parentElement
|
||||
const parentElement = blockElement.parentElement;
|
||||
const editableElement = getContenteditableElement(blockElement);
|
||||
const previousLastElement = getLastBlock(previousElement) as HTMLElement;
|
||||
const isSelectNode = previousLastElement && (previousLastElement.classList.contains("table") || previousLastElement.classList.contains("render-node") || previousLastElement.classList.contains("iframe") || previousLastElement.classList.contains("hr") || previousLastElement.classList.contains("code-block"));
|
||||
if (isSelectNode) {
|
||||
if (previousLastElement.classList.contains("code-block")) {
|
||||
if (editableElement.textContent.trim() === "") {
|
||||
const previousId = previousLastElement.getAttribute("data-node-id")
|
||||
const previousId = previousLastElement.getAttribute("data-node-id");
|
||||
const id = blockElement.getAttribute("data-node-id");
|
||||
const doOperations: IOperation[] = [{
|
||||
action: "delete",
|
||||
id,
|
||||
}]
|
||||
}];
|
||||
const undoOperations: IOperation[] = [{
|
||||
action: "insert",
|
||||
data: blockElement.outerHTML,
|
||||
id: id,
|
||||
previousID: blockElement.previousElementSibling?.getAttribute("data-node-id"),
|
||||
parentID: blockElement.parentElement.getAttribute("data-node-id")
|
||||
}]
|
||||
}];
|
||||
blockElement.remove();
|
||||
// 取消超级块
|
||||
if (parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {
|
||||
|
|
@ -470,7 +470,7 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
|
|||
action: "update",
|
||||
data: previousLastElement.outerHTML,
|
||||
id: newId,
|
||||
})
|
||||
});
|
||||
}
|
||||
if (parentElement.getAttribute("data-type") === "NodeSuperBlock" && parentElement.childElementCount === 2) {
|
||||
const sbData = cancelSB(protyle, parentElement);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue