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