mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-08 02:22:20 +08:00
This commit is contained in:
parent
5ecc2a862e
commit
d1a2140cd9
@ -1,4 +1,7 @@
|
||||
{
|
||||
"newSubFile": "New SubFile",
|
||||
"newFileAfter": "New file after",
|
||||
"newFileBefore": "New file before",
|
||||
"adaptiveWidth": "Adaptive Width",
|
||||
"fullWidthTip": "After enabling, the editing area will be displayed as wide as possible",
|
||||
"tabLimit": "Tab Limit",
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"newSubFile": "Nuevo SubArchivo",
|
||||
"newFileAfter": "Nuevo archivo en el mismo nivel después",
|
||||
"newFileBefore": "Nuevo archivo en el mismo nivel anterior",
|
||||
"fullWidth": "Ancho adaptable",
|
||||
"fullWidthTip": "Cuando está habilitado, el área de edición se mostrará lo más amplia posible",
|
||||
"tabLimit": "Límite de la pestaña",
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"newSubFile": "Nouveau sous-fichier",
|
||||
"newFileAfter": "Nouveau fichier au même niveau après",
|
||||
"newFileBefore": "Nouveau fichier au même niveau avant",
|
||||
"fullWidth": "Largeur adaptative",
|
||||
"fullWidthTip": "Lorsqu'il est activé, la zone d'édition sera affichée aussi large que possible",
|
||||
"tabLimit": "Nombre maximum d'onglets ouverts",
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"newSubFile": "新建子文檔",
|
||||
"newFileAfter": "在後新建同級文檔",
|
||||
"newFileBefore": "在前新建同級文檔",
|
||||
"fullWidth": "自適應寬度",
|
||||
"fullWidthTip": "開啟後將盡可能寬地顯示編輯區",
|
||||
"tabLimit": "頁簽打開最大數量",
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"newSubFile": "新建子文档",
|
||||
"newFileAfter": "在后新建同级文档",
|
||||
"newFileBefore": "在前新建同级文档",
|
||||
"fullWidth": "自适应宽度",
|
||||
"fullWidthTip": "开启后将尽可能宽地显示编辑区",
|
||||
"tabLimit": "页签打开最大数量",
|
||||
|
@ -217,7 +217,7 @@ export class Files extends Model {
|
||||
}
|
||||
}
|
||||
if (type === "more-file") {
|
||||
initFileMenu(notebookId, pathString, target.parentElement.getAttribute("data-node-id"), target.parentElement.getAttribute("data-name")).popup({
|
||||
initFileMenu(notebookId, pathString, target.parentElement).popup({
|
||||
x: event.clientX,
|
||||
y: event.clientY
|
||||
});
|
||||
|
@ -793,16 +793,6 @@ export const openMenu = (src: string, onlyMenu = false) => {
|
||||
}).element);
|
||||
};
|
||||
|
||||
export const newFileMenu = (notebookId?: string, path?: string, open?: boolean) => {
|
||||
return new MenuItem({
|
||||
icon: "iconFile",
|
||||
label: window.siyuan.languages.newFile,
|
||||
click: () => {
|
||||
newFile(notebookId, path, open);
|
||||
}
|
||||
}).element;
|
||||
};
|
||||
|
||||
export const deleteMenu = (notebookId: string, name: string, pathString: string) => {
|
||||
return new MenuItem({
|
||||
icon: "iconTrashcan",
|
||||
|
@ -45,7 +45,7 @@ export class Menus {
|
||||
if (dataType === "navigation-file") {
|
||||
this.unselect();
|
||||
// navigation 文件上:删除/重命名/打开文件位置/导出
|
||||
initFileMenu(this.getDir(target), target.getAttribute("data-path"), target.getAttribute("data-node-id"), target.getAttribute("data-name")).popup({
|
||||
initFileMenu(this.getDir(target), target.getAttribute("data-path"), target).popup({
|
||||
x: event.clientX,
|
||||
y: event.clientY
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ import {
|
||||
deleteMenu,
|
||||
exportMd,
|
||||
movePathToMenu,
|
||||
newFileMenu,
|
||||
openFileAttr,
|
||||
renameMenu,
|
||||
} from "./commonMenuItem";
|
||||
@ -23,12 +22,19 @@ import {openFileById} from "../editor/util";
|
||||
/// #endif
|
||||
import {confirmDialog} from "../dialog/confirmDialog";
|
||||
import {Constants} from "../constants";
|
||||
import {newFile} from "../util/newFile";
|
||||
|
||||
export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||
const notebookId = liElement.parentElement.getAttribute("data-url");
|
||||
const name = getNotebookName(notebookId);
|
||||
window.siyuan.menus.menu.remove();
|
||||
window.siyuan.menus.menu.append(newFileMenu(notebookId, "/", true));
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconFile",
|
||||
label: window.siyuan.languages.newFile,
|
||||
click: () => {
|
||||
newFile(notebookId, "/", true);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
if (!window.siyuan.config.readonly) {
|
||||
window.siyuan.menus.menu.append(renameMenu({
|
||||
@ -121,11 +127,53 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
|
||||
return window.siyuan.menus.menu;
|
||||
};
|
||||
|
||||
export const initFileMenu = (notebookId: string, pathString: string, id: string, name: string) => {
|
||||
export const initFileMenu = (notebookId: string, pathString: string, liElement: HTMLElement) => {
|
||||
const id = liElement.getAttribute("data-node-id")
|
||||
let name = liElement.getAttribute("data-name")
|
||||
window.siyuan.menus.menu.remove();
|
||||
name = getDisplayName(name, false, true);
|
||||
if (!window.siyuan.config.readonly) {
|
||||
window.siyuan.menus.menu.append(newFileMenu(notebookId, pathString, true));
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconFile",
|
||||
label: window.siyuan.languages.newSubFile,
|
||||
click: () => {
|
||||
newFile(notebookId, pathString, true);
|
||||
}
|
||||
}).element);
|
||||
if (window.siyuan.config.fileTree.sort === 6) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconBefore",
|
||||
label: window.siyuan.languages.newFileBefore,
|
||||
click: () => {
|
||||
const paths: string[] = [];
|
||||
Array.from(liElement.parentElement.children).forEach((item) => {
|
||||
if (item.tagName === "LI") {
|
||||
if (item.isSameNode(liElement)) {
|
||||
paths.push(undefined)
|
||||
}
|
||||
paths.push(item.getAttribute("data-path"));
|
||||
}
|
||||
});
|
||||
newFile(notebookId, pathPosix().dirname(pathString), true, paths);
|
||||
}
|
||||
}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
icon: "iconAfter",
|
||||
label: window.siyuan.languages.newFileAfter,
|
||||
click: () => {
|
||||
const paths: string[] = [];
|
||||
Array.from(liElement.parentElement.children).forEach((item) => {
|
||||
if (item.tagName === "LI") {
|
||||
paths.push(item.getAttribute("data-path"));
|
||||
if (item.isSameNode(liElement)) {
|
||||
paths.push(undefined);
|
||||
}
|
||||
}
|
||||
});
|
||||
newFile(notebookId, pathPosix().dirname(pathString), true, paths);
|
||||
}
|
||||
}).element);
|
||||
}
|
||||
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.copy,
|
||||
|
@ -182,7 +182,7 @@ export class MobileFiles extends Model {
|
||||
}
|
||||
}
|
||||
if (type === "more-file") {
|
||||
initFileMenu(notebookId, pathString, target.parentElement.getAttribute("data-node-id"), target.parentElement.getAttribute("data-name")).popup({
|
||||
initFileMenu(notebookId, pathString, target.parentElement).popup({
|
||||
x,
|
||||
y
|
||||
});
|
||||
|
@ -812,7 +812,7 @@ const fileTreeKeydown = (event: KeyboardEvent) => {
|
||||
if (matchHotKey("⌘/", event)) {
|
||||
const liRect = liElement.getBoundingClientRect();
|
||||
if (isFile) {
|
||||
initFileMenu(notebookId, pathString, liElement.getAttribute("data-node-id"), liElement.getAttribute("data-name")).popup({
|
||||
initFileMenu(notebookId, pathString, liElement).popup({
|
||||
x: liRect.right - 15,
|
||||
y: liRect.top + 15
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ import {fetchPost} from "./fetch";
|
||||
import {getDisplayName, getOpenNotebookCount, pathPosix} from "./pathName";
|
||||
import {Constants} from "../constants";
|
||||
|
||||
export const newFile = (notebookId?: string, currentPath?: string, open?: boolean) => {
|
||||
export const newFile = (notebookId?: string, currentPath?: string, open?: boolean, paths?: string[]) => {
|
||||
if (getOpenNotebookCount() === 0) {
|
||||
showMessage(window.siyuan.languages.newFileTip);
|
||||
return;
|
||||
@ -54,11 +54,16 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea
|
||||
}
|
||||
fetchPost("/api/filetree/getDocNameTemplate", {notebook: notebookId}, (data) => {
|
||||
const id = Lute.NewNodeID();
|
||||
const newPath = pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy")
|
||||
if (paths) {
|
||||
paths[paths.indexOf(undefined)] = newPath
|
||||
}
|
||||
fetchPost("/api/filetree/createDoc", {
|
||||
notebook: notebookId,
|
||||
path: pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy"),
|
||||
path: newPath,
|
||||
title: data.data.name || "Untitled",
|
||||
md: "",
|
||||
sorts: paths
|
||||
}, () => {
|
||||
/// #if !MOBILE
|
||||
if (open) {
|
||||
|
Loading…
Reference in New Issue
Block a user