This commit is contained in:
Vanessa 2022-07-01 22:12:43 +08:00
parent d1a2140cd9
commit 8c639f8a16
3 changed files with 6 additions and 7 deletions

View file

@ -1,7 +1,6 @@
/// #if !BROWSER /// #if !BROWSER
import {shell} from "electron"; import {shell} from "electron";
/// #endif /// #endif
import {newFile} from "../util/newFile";
import {getDockByType} from "../layout/util"; import {getDockByType} from "../layout/util";
import {confirmDialog} from "../dialog/confirmDialog"; import {confirmDialog} from "../dialog/confirmDialog";
import {getSearch, isMobile} from "../util/functions"; import {getSearch, isMobile} from "../util/functions";

View file

@ -127,9 +127,9 @@ export const initNavigationMenu = (liElement: HTMLElement) => {
return window.siyuan.menus.menu; return window.siyuan.menus.menu;
}; };
export const initFileMenu = (notebookId: string, pathString: string, liElement: HTMLElement) => { export const initFileMenu = (notebookId: string, pathString: string, liElement: Element) => {
const id = liElement.getAttribute("data-node-id") const id = liElement.getAttribute("data-node-id");
let name = liElement.getAttribute("data-name") let name = liElement.getAttribute("data-name");
window.siyuan.menus.menu.remove(); window.siyuan.menus.menu.remove();
name = getDisplayName(name, false, true); name = getDisplayName(name, false, true);
if (!window.siyuan.config.readonly) { if (!window.siyuan.config.readonly) {
@ -149,7 +149,7 @@ export const initFileMenu = (notebookId: string, pathString: string, liElement:
Array.from(liElement.parentElement.children).forEach((item) => { Array.from(liElement.parentElement.children).forEach((item) => {
if (item.tagName === "LI") { if (item.tagName === "LI") {
if (item.isSameNode(liElement)) { if (item.isSameNode(liElement)) {
paths.push(undefined) paths.push(undefined);
} }
paths.push(item.getAttribute("data-path")); paths.push(item.getAttribute("data-path"));
} }

View file

@ -54,9 +54,9 @@ export const newFile = (notebookId?: string, currentPath?: string, open?: boolea
} }
fetchPost("/api/filetree/getDocNameTemplate", {notebook: notebookId}, (data) => { fetchPost("/api/filetree/getDocNameTemplate", {notebook: notebookId}, (data) => {
const id = Lute.NewNodeID(); const id = Lute.NewNodeID();
const newPath = pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy") const newPath = pathPosix().join(getDisplayName(currentPath, false, true), id + ".sy");
if (paths) { if (paths) {
paths[paths.indexOf(undefined)] = newPath paths[paths.indexOf(undefined)] = newPath;
} }
fetchPost("/api/filetree/createDoc", { fetchPost("/api/filetree/createDoc", {
notebook: notebookId, notebook: notebookId,