Vanessa 2024-10-28 22:04:48 +08:00
parent 1d142c9df1
commit f2a53014fb
16 changed files with 32 additions and 18 deletions

View file

@ -224,6 +224,14 @@
color: var(--b3-theme-primary); color: var(--b3-theme-primary);
} }
&--remove:hover {
color: var(--b3-card-error-color);
& > .b3-menu__icon {
color: var(--b3-card-error-color);
}
}
&--current:not(.b3-menu__item--readonly) { &--current:not(.b3-menu__item--readonly) {
background-color: var(--b3-list-hover); background-color: var(--b3-list-hover);

View file

@ -118,7 +118,7 @@ export const makeCard = (app: App, ids: string[]) => {
}, () => { }, () => {
target.parentElement.remove(); target.parentElement.remove();
}); });
}); }, undefined, true);
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;

View file

@ -68,7 +68,7 @@ export const image = {
assetsListElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`; assetsListElement.innerHTML = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
image.element.querySelector(".config-assets__preview").innerHTML = ""; image.element.querySelector(".config-assets__preview").innerHTML = "";
}); });
}); }, undefined, true);
} else if (target.classList.contains("item") && !target.classList.contains("item--focus")) { } else if (target.classList.contains("item") && !target.classList.contains("item--focus")) {
image.element.querySelector(".layout-tab-bar .item--focus").classList.remove("item--focus"); image.element.querySelector(".layout-tab-bar .item--focus").classList.remove("item--focus");
target.classList.add("item--focus"); target.classList.add("item--focus");
@ -113,7 +113,7 @@ export const image = {
} }
image.element.querySelector(".config-assets__preview").innerHTML = ""; image.element.querySelector(".config-assets__preview").innerHTML = "";
}); });
}); }, undefined, true);
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
break; break;

View file

@ -1,7 +1,10 @@
import {isMobile} from "../util/functions"; import {isMobile} from "../util/functions";
import {Dialog} from "./index"; import {Dialog} from "./index";
export const confirmDialog = (title: string, text: string, confirm?: (dialog?: Dialog) => void, cancel?: (dialog: Dialog) => void) => { export const confirmDialog = (title: string, text: string,
confirm?: (dialog?: Dialog) => void,
cancel?: (dialog: Dialog) => void,
isDelete = false) => {
if (!text && !title) { if (!text && !title) {
confirm(); confirm();
return; return;
@ -13,7 +16,7 @@ export const confirmDialog = (title: string, text: string, confirm?: (dialog?: D
</div> </div>
<div class="b3-dialog__action"> <div class="b3-dialog__action">
<button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div> <button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button><div class="fn__space"></div>
<button class="b3-button b3-button--text" id="confirmDialogConfirmBtn">${window.siyuan.languages.confirm}</button> <button class="b3-button ${isDelete ? "b3-button--remove" : "b3-button--text"}" id="confirmDialogConfirmBtn">${window.siyuan.languages[isDelete ? "delete" : "confirm"]}</button>
</div>`, </div>`,
width: isMobile() ? "92vw" : "520px", width: isMobile() ? "92vw" : "520px",
}); });

View file

@ -31,7 +31,7 @@ export const deleteFile = (notebookId: string, pathString: string) => {
notebook: notebookId, notebook: notebookId,
path: pathString path: pathString
}); });
}); }, undefined, true);
}); });
}; };
@ -51,7 +51,7 @@ export const deleteFiles = (liElements: Element[]) => {
notebook: itemNotebookId, notebook: itemNotebookId,
callback: Constants.CB_MOUNT_REMOVE callback: Constants.CB_MOUNT_REMOVE
}); });
}); }, undefined, true);
} }
} }
} else { } else {
@ -73,6 +73,6 @@ export const deleteFiles = (liElements: Element[]) => {
fetchPost("/api/filetree/removeDocs", { fetchPost("/api/filetree/removeDocs", {
paths paths
}); });
}); }, undefined, true);
} }
}; };

View file

@ -759,7 +759,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
fetchPost("/api/repo/" + type, {tag}, () => { fetchPost("/api/repo/" + type, {tag}, () => {
renderRepo(repoElement, 1); renderRepo(repoElement, 1);
}); });
}); }, undefined, true);
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;

View file

@ -165,7 +165,7 @@ export class Files extends Model {
notebook: target.getAttribute("data-url"), notebook: target.getAttribute("data-url"),
callback: Constants.CB_MOUNT_REMOVE callback: Constants.CB_MOUNT_REMOVE
}); });
}); }, undefined, true);
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();

View file

@ -290,7 +290,7 @@ ${data.shorthandContent}
} else { } else {
this.remove(detailsElement.getAttribute("data-id")); this.remove(detailsElement.getAttribute("data-id"));
} }
}); }, undefined, true);
} }
}).element); }).element);
} }

View file

@ -213,6 +213,9 @@ export class MenuItem {
if (options.type === "readonly") { if (options.type === "readonly") {
this.element.classList.add("b3-menu__item--readonly"); this.element.classList.add("b3-menu__item--readonly");
} }
if (options.icon === "iconTrashcan") {
this.element.classList.add("b3-menu__item--remove");
}
if (options.element) { if (options.element) {
this.element.append(options.element); this.element.append(options.element);

View file

@ -85,7 +85,7 @@ export const openBookmarkMenu = (element: HTMLElement, event: MouseEvent, bookma
} else { } else {
fetchPost("/api/bookmark/removeBookmark", {bookmark: bookmarkText}); fetchPost("/api/bookmark/removeBookmark", {bookmark: bookmarkText});
} }
}); }, undefined, true);
} }
}).element); }).element);
} }

View file

@ -24,7 +24,7 @@ export const openTagMenu = (element: HTMLElement, event: MouseEvent, labelName:
click: () => { click: () => {
confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(labelName)}</b>?`, () => { confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(labelName)}</b>?`, () => {
fetchPost("/api/tag/removeTag", {label: labelName}); fetchPost("/api/tag/removeTag", {label: labelName});
}); }, undefined, true);
} }
}).element); }).element);
window.siyuan.menus.menu.element.setAttribute("data-name", "tagMenu"); window.siyuan.menus.menu.element.setAttribute("data-name", "tagMenu");

View file

@ -301,7 +301,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
fetchPost("/api/system/removeWorkspaceDir", {path: item.path}, () => { fetchPost("/api/system/removeWorkspaceDir", {path: item.path}, () => {
confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.removeWorkspacePhysically.replace("${x}", item.path), () => { confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.removeWorkspacePhysically.replace("${x}", item.path), () => {
fetchPost("/api/system/removeWorkspaceDirPhysically", {path: item.path}); fetchPost("/api/system/removeWorkspaceDirPhysically", {path: item.path});
}); }, undefined, true);
}); });
return; return;
} }

View file

@ -177,7 +177,7 @@ export class MobileFiles extends Model {
notebook: target.getAttribute("data-url"), notebook: target.getAttribute("data-url"),
callback: Constants.CB_MOUNT_REMOVE callback: Constants.CB_MOUNT_REMOVE
}); });
}); }, undefined, true);
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();
break; break;

View file

@ -356,7 +356,7 @@ export const initAbout = () => {
genWorkspace(workspaceDirElement); genWorkspace(workspaceDirElement);
confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.removeWorkspacePhysically.replace("${x}", removePath), () => { confirmDialog(window.siyuan.languages.deleteOpConfirm, window.siyuan.languages.removeWorkspacePhysically.replace("${x}", removePath), () => {
fetchPost("/api/system/removeWorkspaceDirPhysically", {path: removePath}); fetchPost("/api/system/removeWorkspaceDirPhysically", {path: removePath});
}); }, undefined, true);
}); });
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();

View file

@ -289,7 +289,7 @@ export const setColOption = (protyle: IProtyle, data: IAV, target: HTMLElement,
if (selectedElement) { if (selectedElement) {
menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight); menuElement.querySelector(".b3-menu__items").scrollTop = oldScroll + (menuElement.querySelector(".b3-chips").clientHeight - oldChipsHeight);
} }
}); }, undefined, true);
} }
}); });
menu.addSeparator(); menu.addSeparator();

View file

@ -61,7 +61,7 @@ export const bindSyncCloudListEvent = (cloudPanelElement: Element, cb?: () => vo
window.siyuan.config.sync.cloudName = response.data; window.siyuan.config.sync.cloudName = response.data;
getSyncCloudList(cloudPanelElement, true, cb); getSyncCloudList(cloudPanelElement, true, cb);
}); });
}); }, undefined, true);
break; break;
case "selectCloud": case "selectCloud":
cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">'; cloudPanelElement.innerHTML = '<img style="margin: 0 auto;display: block;width: 64px;height: 100%" src="/stage/loading-pure.svg">';