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

View File

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

View File

@ -183,7 +183,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false) =>
} else { } else {
if (item.classList.contains("li") && !blockElement.parentElement.classList.contains("list")) { if (item.classList.contains("li") && !blockElement.parentElement.classList.contains("list")) {
// https://github.com/siyuan-note/siyuan/issues/6534 // https://github.com/siyuan-note/siyuan/issues/6534
addId = Lute.NewNodeID() addId = Lute.NewNodeID();
const liElement = document.createElement("div"); const liElement = document.createElement("div");
liElement.setAttribute("data-subtype", item.getAttribute("data-subtype")); liElement.setAttribute("data-subtype", item.getAttribute("data-subtype"));
liElement.setAttribute("data-node-id", addId); 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) => { export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
let focusElement let focusElement;
const doOperations: IOperation[] = [] const doOperations: IOperation[] = [];
const undoOperations: IOperation[] = [] const undoOperations: IOperation[] = [];
nodeElements.forEach((item, index) => { nodeElements.forEach((item, index) => {
const tempElement = item.cloneNode(true) as HTMLElement; const tempElement = item.cloneNode(true) as HTMLElement;
if (index === nodeElements.length - 1) { if (index === nodeElements.length - 1) {
focusElement = tempElement focusElement = tempElement;
} }
const newId = Lute.NewNodeID(); const newId = Lute.NewNodeID();
tempElement.setAttribute("data-node-id", newId); tempElement.setAttribute("data-node-id", newId);
@ -205,13 +205,13 @@ export const duplicateBlock = (nodeElements: Element[], protyle: IProtyle) => {
data: tempElement.outerHTML, data: tempElement.outerHTML,
id: newId, id: newId,
previousID: item.getAttribute("data-node-id"), previousID: item.getAttribute("data-node-id"),
}) });
undoOperations.push({ undoOperations.push({
action: "delete", action: "delete",
id: newId, id: newId,
}) });
}) });
transaction(protyle, doOperations, undoOperations); transaction(protyle, doOperations, undoOperations);
focusBlock(focusElement); focusBlock(focusElement);
scrollCenter(protyle); scrollCenter(protyle);
} };