mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 07:48:49 +01:00
This commit is contained in:
parent
8075902681
commit
a84de71dae
3 changed files with 15 additions and 5 deletions
|
|
@ -4,8 +4,9 @@ import {confirmDialog} from "../dialog/confirmDialog";
|
|||
import {hasTopClosestByTag} from "../protyle/util/hasClosest";
|
||||
import {Constants} from "../constants";
|
||||
import {showMessage} from "../dialog/message";
|
||||
import {escapeHtml} from "../util/escape";
|
||||
|
||||
export const deleteFile = (notebookId: string, pathString: string, name: string) => {
|
||||
export const deleteFile = (notebookId: string, pathString: string) => {
|
||||
if (window.siyuan.config.fileTree.removeDocWithoutConfirm) {
|
||||
fetchPost("/api/filetree/removeDoc", {
|
||||
notebook: notebookId,
|
||||
|
|
@ -16,9 +17,10 @@ export const deleteFile = (notebookId: string, pathString: string, name: string)
|
|||
fetchPost("/api/block/getDocInfo", {
|
||||
id: getDisplayName(pathString, true, true)
|
||||
}, (response) => {
|
||||
let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;
|
||||
const fileName = escapeHtml(response.data.name);
|
||||
let tip = `${window.siyuan.languages.confirmDelete} <b>${fileName}</b>?`;
|
||||
if (response.data.subFileCount > 0) {
|
||||
tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
||||
tip = `${window.siyuan.languages.confirmDelete} <b>${fileName}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
||||
}
|
||||
confirmDialog(window.siyuan.languages.deleteOpConfirm, tip, () => {
|
||||
fetchPost("/api/filetree/removeDoc", {
|
||||
|
|
@ -35,7 +37,7 @@ export const deleteFiles = (liElements: Element[]) => {
|
|||
if (itemTopULElement) {
|
||||
const itemNotebookId = itemTopULElement.getAttribute("data-url");
|
||||
if (liElements[0].getAttribute("data-type") === "navigation-file") {
|
||||
deleteFile(itemNotebookId, liElements[0].getAttribute("data-path"), getDisplayName(liElements[0].getAttribute("data-name"), false, true));
|
||||
deleteFile(itemNotebookId, liElements[0].getAttribute("data-path"));
|
||||
} else {
|
||||
confirmDialog(window.siyuan.languages.deleteOpConfirm,
|
||||
`${window.siyuan.languages.confirmDelete} <b>${Lute.EscapeHTMLStr(getNotebookName(itemNotebookId))}</b>?`, () => {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ import {saveScroll} from "../scroll/saveScroll";
|
|||
import {hideElements} from "../ui/hideElements";
|
||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
||||
import {reloadProtyle} from "../util/reload";
|
||||
import {deleteFile} from "../../editor/deleteFile";
|
||||
|
||||
export class Breadcrumb {
|
||||
public element: HTMLElement;
|
||||
|
|
@ -318,6 +319,13 @@ export class Breadcrumb {
|
|||
reloadProtyle(protyle);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click: () => {
|
||||
deleteFile(protyle.notebookId, protyle.path);
|
||||
}
|
||||
}).element);
|
||||
if (!isMobile()) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: protyle.element.className.includes("fullscreen") ? "iconFullscreenExit" : "iconFullscreen",
|
||||
|
|
|
|||
|
|
@ -289,7 +289,7 @@ export class Title {
|
|||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.delete,
|
||||
click: () => {
|
||||
deleteFile(protyle.notebookId, protyle.path, escapeHtml(this.editElement.textContent));
|
||||
deleteFile(protyle.notebookId, protyle.path);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue