mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-20 08:30:12 +01:00
This commit is contained in:
parent
5ecc2a862e
commit
d1a2140cd9
12 changed files with 78 additions and 20 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue