mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
19940e266b
commit
24709d29ad
7 changed files with 42 additions and 48 deletions
|
|
@ -27,6 +27,14 @@ export const fileTree = {
|
||||||
<span class="fn__space"></span>
|
<span class="fn__space"></span>
|
||||||
<input class="b3-switch fn__flex-center" id="allowCreateDeeper" type="checkbox"${window.siyuan.config.fileTree.allowCreateDeeper ? " checked" : ""}/>
|
<input class="b3-switch fn__flex-center" id="allowCreateDeeper" type="checkbox"${window.siyuan.config.fileTree.allowCreateDeeper ? " checked" : ""}/>
|
||||||
</label>
|
</label>
|
||||||
|
<label class="fn__flex b3-label">
|
||||||
|
<div class="fn__flex-1">
|
||||||
|
${window.siyuan.languages.fileTree3}
|
||||||
|
<div class="b3-label__text">${window.siyuan.languages.fileTree4}</div>
|
||||||
|
</div>
|
||||||
|
<span class="fn__space"></span>
|
||||||
|
<input class="b3-switch fn__flex-center" id="removeDocWithoutConfirm" type="checkbox"${window.siyuan.config.fileTree.removeDocWithoutConfirm ? " checked" : ""}/>
|
||||||
|
</label>
|
||||||
<label class="fn__flex b3-label">
|
<label class="fn__flex b3-label">
|
||||||
<div class="fn__flex-1">
|
<div class="fn__flex-1">
|
||||||
${window.siyuan.languages.fileTree12}
|
${window.siyuan.languages.fileTree12}
|
||||||
|
|
@ -60,6 +68,7 @@ export const fileTree = {
|
||||||
createDocNameTemplate: (fileTree.element.querySelector("#createDocNameTemplate") as HTMLInputElement).value,
|
createDocNameTemplate: (fileTree.element.querySelector("#createDocNameTemplate") as HTMLInputElement).value,
|
||||||
openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,
|
openFilesUseCurrentTab: (fileTree.element.querySelector("#openFilesUseCurrentTab") as HTMLInputElement).checked,
|
||||||
allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,
|
allowCreateDeeper: (fileTree.element.querySelector("#allowCreateDeeper") as HTMLInputElement).checked,
|
||||||
|
removeDocWithoutConfirm: (fileTree.element.querySelector("#removeDocWithoutConfirm") as HTMLInputElement).checked,
|
||||||
maxListCount: parseInt((fileTree.element.querySelector("#maxListCount") as HTMLInputElement).value),
|
maxListCount: parseInt((fileTree.element.querySelector("#maxListCount") as HTMLInputElement).value),
|
||||||
}, response => {
|
}, response => {
|
||||||
fileTree.onSetfiletree(response.data);
|
fileTree.onSetfiletree(response.data);
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ export const initConfigSearch = (element: HTMLElement) => {
|
||||||
]),
|
]),
|
||||||
|
|
||||||
// 文档树
|
// 文档树
|
||||||
getLang(["selectOpen", "fileTree", "fileTree2",
|
getLang(["selectOpen", "fileTree", "fileTree2", "fileTree3", "fileTree4",
|
||||||
"fileTree5", "fileTree6", "fileTree7", "fileTree8", "fileTree12", "fileTree13", "fileTree15", "fileTree16", "fileTree17"]),
|
"fileTree5", "fileTree6", "fileTree7", "fileTree8", "fileTree12", "fileTree13", "fileTree15", "fileTree16", "fileTree17"]),
|
||||||
|
|
||||||
// 图片
|
// 图片
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import {
|
||||||
import {getPreviousHeading} from "../protyle/wysiwyg/getBlock";
|
import {getPreviousHeading} from "../protyle/wysiwyg/getBlock";
|
||||||
import {lockFile, setTitle} from "../dialog/processSystem";
|
import {lockFile, setTitle} from "../dialog/processSystem";
|
||||||
import {zoomOut} from "../menus/protyle";
|
import {zoomOut} from "../menus/protyle";
|
||||||
|
import {confirmDialog} from "../dialog/confirmDialog";
|
||||||
|
|
||||||
export const openOutline = (protyle: IProtyle) => {
|
export const openOutline = (protyle: IProtyle) => {
|
||||||
const outlinePanel = getAllModels().outline.find(item => {
|
const outlinePanel = getAllModels().outline.find(item => {
|
||||||
|
|
@ -539,3 +540,27 @@ export const openBy = (url: string, type: "folder" | "app") => {
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const deleteFile = (notebookId: string, pathString: string, name: string) => {
|
||||||
|
if (window.siyuan.config.fileTree.removeDocWithoutConfirm) {
|
||||||
|
fetchPost("/api/filetree/removeDoc", {
|
||||||
|
notebook: notebookId,
|
||||||
|
path: pathString
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
fetchPost("/api/block/getDocInfo", {
|
||||||
|
id: getDisplayName(pathString, true, true)
|
||||||
|
}, (response) => {
|
||||||
|
let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;
|
||||||
|
if (response.data.subFileCount > 0) {
|
||||||
|
tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
||||||
|
}
|
||||||
|
confirmDialog(window.siyuan.languages.delete, tip, () => {
|
||||||
|
fetchPost("/api/filetree/removeDoc", {
|
||||||
|
notebook: notebookId,
|
||||||
|
path: pathString
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import {setPosition} from "../util/setPosition";
|
||||||
import {updateTransaction} from "../protyle/wysiwyg/transaction";
|
import {updateTransaction} from "../protyle/wysiwyg/transaction";
|
||||||
import {Bookmark} from "../layout/dock/Bookmark";
|
import {Bookmark} from "../layout/dock/Bookmark";
|
||||||
import {rename} from "../editor/rename";
|
import {rename} from "../editor/rename";
|
||||||
import {openAsset, openBy} from "../editor/util";
|
import {deleteFile, openAsset, openBy} from "../editor/util";
|
||||||
import {matchHotKey} from "../protyle/util/hotKey";
|
import {matchHotKey} from "../protyle/util/hotKey";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
import {Constants} from "../constants";
|
import {Constants} from "../constants";
|
||||||
|
|
@ -774,20 +774,7 @@ export const deleteMenu = (notebookId: string, name: string, pathString: string)
|
||||||
label: window.siyuan.languages.delete,
|
label: window.siyuan.languages.delete,
|
||||||
accelerator: "⌦",
|
accelerator: "⌦",
|
||||||
click: () => {
|
click: () => {
|
||||||
fetchPost("/api/block/getDocInfo", {
|
deleteFile(notebookId, pathString, name);
|
||||||
id: getDisplayName(pathString, true, true)
|
|
||||||
}, (response) => {
|
|
||||||
let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;
|
|
||||||
if (response.data.subFileCount > 0) {
|
|
||||||
tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
|
||||||
}
|
|
||||||
confirmDialog(window.siyuan.languages.delete, tip, () => {
|
|
||||||
fetchPost("/api/filetree/removeDoc", {
|
|
||||||
notebook: notebookId,
|
|
||||||
path: pathString
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).element;
|
}).element;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@ import {hasClosestByClassName} from "../util/hasClosest";
|
||||||
import {matchHotKey} from "../util/hotKey";
|
import {matchHotKey} from "../util/hotKey";
|
||||||
import {updateHotkeyTip, writeText} from "../util/compatibility";
|
import {updateHotkeyTip, writeText} from "../util/compatibility";
|
||||||
import {setPanelFocus} from "../../layout/util";
|
import {setPanelFocus} from "../../layout/util";
|
||||||
import {confirmDialog} from "../../dialog/confirmDialog";
|
|
||||||
import {escapeHtml} from "../../util/escape";
|
import {escapeHtml} from "../../util/escape";
|
||||||
import {openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";
|
import {deleteFile, openBacklink, openGraph, openOutline, updatePanelByEditor} from "../../editor/util";
|
||||||
import * as dayjs from "dayjs";
|
import * as dayjs from "dayjs";
|
||||||
import {setTitle} from "../../dialog/processSystem";
|
import {setTitle} from "../../dialog/processSystem";
|
||||||
import {getNoContainerElement} from "../wysiwyg/getBlock";
|
import {getNoContainerElement} from "../wysiwyg/getBlock";
|
||||||
|
|
@ -262,20 +261,7 @@ export class Title {
|
||||||
icon: "iconTrashcan",
|
icon: "iconTrashcan",
|
||||||
label: window.siyuan.languages.delete,
|
label: window.siyuan.languages.delete,
|
||||||
click: () => {
|
click: () => {
|
||||||
fetchPost("/api/block/getDocInfo", {
|
deleteFile(protyle.notebookId, protyle.path, escapeHtml(this.editElement.textContent))
|
||||||
id: protyle.block.rootID
|
|
||||||
}, (response) => {
|
|
||||||
let tip = `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(this.editElement.textContent)}</b>?`;
|
|
||||||
if (response.data.subFileCount > 0) {
|
|
||||||
tip = `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(this.editElement.textContent)}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
|
||||||
}
|
|
||||||
confirmDialog(window.siyuan.languages.delete, tip, () => {
|
|
||||||
fetchPost("/api/filetree/removeDoc", {
|
|
||||||
notebook: protyle.notebookId,
|
|
||||||
path: protyle.path
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}).element);
|
}).element);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1
app/src/types/index.d.ts
vendored
1
app/src/types/index.d.ts
vendored
|
|
@ -226,6 +226,7 @@ declare interface IAppearance {
|
||||||
declare interface IFileTree {
|
declare interface IFileTree {
|
||||||
alwaysSelectOpenedFile: boolean
|
alwaysSelectOpenedFile: boolean
|
||||||
openFilesUseCurrentTab: boolean
|
openFilesUseCurrentTab: boolean
|
||||||
|
removeDocWithoutConfirm: boolean
|
||||||
allowCreateDeeper: boolean
|
allowCreateDeeper: boolean
|
||||||
refCreateSavePath: string
|
refCreateSavePath: string
|
||||||
createDocNameTemplate: string
|
createDocNameTemplate: string
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import {goBack, goForward} from "./backForward";
|
||||||
import {onGet} from "../protyle/util/onGet";
|
import {onGet} from "../protyle/util/onGet";
|
||||||
import {getDisplayName, getNotebookName, movePathTo} from "./pathName";
|
import {getDisplayName, getNotebookName, movePathTo} from "./pathName";
|
||||||
import {confirmDialog} from "../dialog/confirmDialog";
|
import {confirmDialog} from "../dialog/confirmDialog";
|
||||||
import {openFileById} from "../editor/util";
|
import {deleteFile, openFileById} from "../editor/util";
|
||||||
import {getAllDocks, getAllModels, getAllTabs} from "../layout/getAll";
|
import {getAllDocks, getAllModels, getAllTabs} from "../layout/getAll";
|
||||||
import {openGlobalSearch} from "../search/util";
|
import {openGlobalSearch} from "../search/util";
|
||||||
import {getColIndex} from "../protyle/util/table";
|
import {getColIndex} from "../protyle/util/table";
|
||||||
|
|
@ -815,21 +815,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
||||||
}
|
}
|
||||||
if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {
|
if (event.key === "Delete" || (event.key === "Backspace" && isMac())) {
|
||||||
if (isFile) {
|
if (isFile) {
|
||||||
fetchPost("/api/block/getDocInfo", {
|
deleteFile(notebookId, pathString, getDisplayName(liElement.getAttribute("data-name"), false, true));
|
||||||
id: getDisplayName(pathString, true, true)
|
|
||||||
}, (response) => {
|
|
||||||
const name = getDisplayName(liElement.getAttribute("data-name"), false, true);
|
|
||||||
let tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b>?`;
|
|
||||||
if (response.data.subFileCount > 0) {
|
|
||||||
tip = `${window.siyuan.languages.confirmDelete} <b>${name}</b> ${window.siyuan.languages.andSubFile.replace("x", response.data.subFileCount)}?`;
|
|
||||||
}
|
|
||||||
confirmDialog(window.siyuan.languages.delete, tip, () => {
|
|
||||||
fetchPost("/api/filetree/removeDoc", {
|
|
||||||
notebook: notebookId,
|
|
||||||
path: pathString
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
confirmDialog(window.siyuan.languages.delete,
|
confirmDialog(window.siyuan.languages.delete,
|
||||||
`${window.siyuan.languages.confirmDelete} <b>${Lute.EscapeHTMLStr(getNotebookName(notebookId))}</b>?`, () => {
|
`${window.siyuan.languages.confirmDelete} <b>${Lute.EscapeHTMLStr(getNotebookName(notebookId))}</b>?`, () => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue