Quellcode durchsuchen

:art: fix https://github.com/siyuan-note/siyuan/issues/7969

Vanessa vor 2 Jahren
Ursprung
Commit
a84de71dae

+ 6 - 4
app/src/editor/deleteFile.ts

@@ -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>?`, () => {

+ 8 - 0
app/src/protyle/breadcrumb/index.ts

@@ -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",

+ 1 - 1
app/src/protyle/header/Title.ts

@@ -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);