This commit is contained in:
Vanessa 2022-11-10 15:46:22 +08:00
parent 34b49fe7de
commit 9b3c6e8449
4 changed files with 15 additions and 15 deletions

View file

@ -27,9 +27,9 @@ import {deleteFiles} from "../editor/deleteFile";
const initMultiMenu = (selectItemElements: NodeListOf<Element>) => {
const fileItemElement = Array.from(selectItemElements).find(item => {
if (item.getAttribute("data-type") === "navigation-file") {
return true
return true;
}
})
});
if (!fileItemElement) {
return window.siyuan.menus.menu;
}
@ -45,7 +45,7 @@ const initMultiMenu = (selectItemElements: NodeListOf<Element>) => {
}
}).element);
return window.siyuan.menus.menu;
}
};
export const initNavigationMenu = (liElement: HTMLElement) => {
window.siyuan.menus.menu.remove();
@ -61,7 +61,7 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
});
liElement.classList.add("b3-list-item--focus");
}
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus")
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements);
}
@ -182,7 +182,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
});
liElement.classList.add("b3-list-item--focus");
}
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus")
const selectItemElements = fileElement.querySelectorAll(".b3-list-item--focus");
if (selectItemElements.length > 1) {
return initMultiMenu(selectItemElements);
}

View file

@ -117,7 +117,7 @@ export const fontMenu = (protyle: IProtyle) => {
element.addEventListener(getEventName(), function (event: Event) {
let target = event.target as HTMLElement;
while (target && !target.isEqualNode(element)) {
const dataType = target.getAttribute("data-type")
const dataType = target.getAttribute("data-type");
if (target.tagName === "BUTTON") {
if (dataType === "clear") {
protyle.toolbar.setInlineMark(protyle, "clear", "range", {type:"text"});

View file

@ -183,7 +183,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
} else {
if (item.classList.contains("li") && !blockElement.parentElement.classList.contains("list")) {
// https://github.com/siyuan-note/siyuan/issues/6534
addId = Lute.NewNodeID()
addId = Lute.NewNodeID();
const liElement = document.createElement("div");
liElement.setAttribute("data-subtype", item.getAttribute("data-subtype"));
liElement.setAttribute("data-node-id", addId);

View file

@ -185,13 +185,13 @@ export const getStartEndElement = (selectElements: NodeListOf<Element> | Element
};
export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
let focusElement
const doOperations: IOperation[] = []
const undoOperations: IOperation[] = []
let focusElement;
const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [];
nodeElements.forEach((item, index) => {
const tempElement = item.cloneNode(true) as HTMLElement;
if (index === nodeElements.length - 1) {
focusElement = tempElement
focusElement = tempElement;
}
const newId = Lute.NewNodeID();
tempElement.setAttribute("data-node-id", newId);
@ -205,13 +205,13 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
data: tempElement.outerHTML,
id: newId,
previousID: item.getAttribute("data-node-id"),
})
});
undoOperations.push({
action: "delete",
id: newId,
})
})
});
});
transaction(protyle, doOperations, undoOperations);
focusBlock(focusElement);
scrollCenter(protyle);
}
};