mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
6bfdaf35e4
commit
84819beaf7
2 changed files with 24 additions and 5 deletions
|
|
@ -621,6 +621,9 @@ ${genHintItemHTML(item)}
|
||||||
notebookId: protyle.notebookId,
|
notebookId: protyle.notebookId,
|
||||||
useSavePath: true,
|
useSavePath: true,
|
||||||
currentPath: protyle.path,
|
currentPath: protyle.path,
|
||||||
|
afterCB: (createDocId, createDocTitle) => {
|
||||||
|
insertHTML(`<span data-type="block-ref" data-id="${createDocId}" data-subtype="d">${createDocTitle}</span>`, protyle);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
} else if (value === Constants.ZWSP + 6) {
|
} else if (value === Constants.ZWSP + 6) {
|
||||||
|
|
@ -632,7 +635,7 @@ ${genHintItemHTML(item)}
|
||||||
title: window.siyuan.languages.untitled,
|
title: window.siyuan.languages.untitled,
|
||||||
md: ""
|
md: ""
|
||||||
}, () => {
|
}, () => {
|
||||||
insertHTML(`<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`, protyle);
|
insertHTML(`<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">${window.siyuan.languages.untitled}</span>`, protyle);
|
||||||
/// #if MOBILE
|
/// #if MOBILE
|
||||||
openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
|
openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
|
||||||
/// #else
|
/// #else
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@ export const newFile = (optios: {
|
||||||
currentPath?: string,
|
currentPath?: string,
|
||||||
paths?: string[],
|
paths?: string[],
|
||||||
useSavePath: boolean,
|
useSavePath: boolean,
|
||||||
name?: string
|
name?: string,
|
||||||
|
afterCB?: (id: string, title: string) => void
|
||||||
}) => {
|
}) => {
|
||||||
if (getOpenNotebookCount() === 0) {
|
if (getOpenNotebookCount() === 0) {
|
||||||
showMessage(window.siyuan.languages.newFileTip);
|
showMessage(window.siyuan.languages.newFileTip);
|
||||||
|
|
@ -97,12 +98,16 @@ export const newFile = (optios: {
|
||||||
}
|
}
|
||||||
if ((data.data.path.indexOf("/") > -1 && optios.useSavePath) || optios.name) {
|
if ((data.data.path.indexOf("/") > -1 && optios.useSavePath) || optios.name) {
|
||||||
if (data.data.path.startsWith("/") || optios.currentPath === "/") {
|
if (data.data.path.startsWith("/") || optios.currentPath === "/") {
|
||||||
|
const createPath = pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : ""))
|
||||||
fetchPost("/api/filetree/createDocWithMd", {
|
fetchPost("/api/filetree/createDocWithMd", {
|
||||||
notebook: data.data.box,
|
notebook: data.data.box,
|
||||||
path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
|
path: createPath,
|
||||||
// 根目录时无法确定 parentID
|
// 根目录时无法确定 parentID
|
||||||
markdown: ""
|
markdown: ""
|
||||||
}, response => {
|
}, response => {
|
||||||
|
if (optios.afterCB) {
|
||||||
|
optios.afterCB(response.data, pathPosix().basename(createPath));
|
||||||
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
openFileById({
|
openFileById({
|
||||||
app: optios.app,
|
app: optios.app,
|
||||||
|
|
@ -118,12 +123,16 @@ export const newFile = (optios: {
|
||||||
notebook: data.data.box,
|
notebook: data.data.box,
|
||||||
path: optios.notebookId === data.data.box ? (optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy") : (data.data.path || "/")
|
path: optios.notebookId === data.data.box ? (optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy") : (data.data.path || "/")
|
||||||
}, (responseHPath) => {
|
}, (responseHPath) => {
|
||||||
|
const createPath = pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : ""))
|
||||||
fetchPost("/api/filetree/createDocWithMd", {
|
fetchPost("/api/filetree/createDocWithMd", {
|
||||||
notebook: data.data.box,
|
notebook: data.data.box,
|
||||||
path: pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
|
path: createPath,
|
||||||
parentID: getDisplayName(optios.currentPath, true, true),
|
parentID: getDisplayName(optios.currentPath, true, true),
|
||||||
markdown: ""
|
markdown: ""
|
||||||
}, response => {
|
}, response => {
|
||||||
|
if (optios.afterCB) {
|
||||||
|
optios.afterCB(response.data, pathPosix().basename(createPath));
|
||||||
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
openFileById({
|
openFileById({
|
||||||
app: optios.app,
|
app: optios.app,
|
||||||
|
|
@ -142,11 +151,15 @@ export const newFile = (optios: {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (optios.notebookId !== data.data.box) {
|
if (optios.notebookId !== data.data.box) {
|
||||||
|
const createPath = pathPosix().join(data.data.path || "/", optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : ""))
|
||||||
fetchPost("/api/filetree/createDocWithMd", {
|
fetchPost("/api/filetree/createDocWithMd", {
|
||||||
notebook: data.data.box,
|
notebook: data.data.box,
|
||||||
path: pathPosix().join(data.data.path || "/", optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
|
path: createPath,
|
||||||
markdown: ""
|
markdown: ""
|
||||||
}, response => {
|
}, response => {
|
||||||
|
if (optios.afterCB) {
|
||||||
|
optios.afterCB(response.data, pathPosix().basename(createPath));
|
||||||
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
openFileById({
|
openFileById({
|
||||||
app: optios.app,
|
app: optios.app,
|
||||||
|
|
@ -172,6 +185,9 @@ export const newFile = (optios: {
|
||||||
md: "",
|
md: "",
|
||||||
sorts: optios.paths
|
sorts: optios.paths
|
||||||
}, () => {
|
}, () => {
|
||||||
|
if (optios.afterCB) {
|
||||||
|
optios.afterCB(id, title);
|
||||||
|
}
|
||||||
/// #if !MOBILE
|
/// #if !MOBILE
|
||||||
openFileById({app: optios.app, id, action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]});
|
openFileById({app: optios.app, id, action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]});
|
||||||
/// #else
|
/// #else
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue