|
@@ -111,6 +111,7 @@ export const newFile = (optios: {
|
|
/// #endif
|
|
/// #endif
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
|
|
+ // TODO
|
|
fetchPost("/api/filetree/getHPathByPath", {
|
|
fetchPost("/api/filetree/getHPathByPath", {
|
|
notebook: data.data.box,
|
|
notebook: data.data.box,
|
|
path: optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy"
|
|
path: optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy"
|
|
@@ -160,7 +161,7 @@ export const newFile = (optios: {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
-export const getSavePath = (pathString: string, notebookId: string, cb: (p: string) => void) => {
|
|
|
|
|
|
+export const getSavePath = (pathString: string, notebookId: string, cb: (p: string, notebookId: string) => void) => {
|
|
fetchPost("/api/filetree/getRefCreateSavePath", {
|
|
fetchPost("/api/filetree/getRefCreateSavePath", {
|
|
notebook: notebookId
|
|
notebook: notebookId
|
|
}, (data) => {
|
|
}, (data) => {
|
|
@@ -170,13 +171,13 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
|
|
}
|
|
}
|
|
if (data.data.path) {
|
|
if (data.data.path) {
|
|
if (data.data.path.startsWith("/")) {
|
|
if (data.data.path.startsWith("/")) {
|
|
- cb(getDisplayName(data.data.path, false, true));
|
|
|
|
|
|
+ cb(getDisplayName(data.data.path, false, true), data.data.box);
|
|
} else {
|
|
} else {
|
|
fetchPost("/api/filetree/getHPathByPath", {
|
|
fetchPost("/api/filetree/getHPathByPath", {
|
|
notebook: data.data.box,
|
|
notebook: data.data.box,
|
|
path: targetPath
|
|
path: targetPath
|
|
}, (response) => {
|
|
}, (response) => {
|
|
- cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true));
|
|
|
|
|
|
+ cb(getDisplayName(pathPosix().join(response.data, data.data.path), false, true), data.data.box);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
@@ -184,7 +185,7 @@ export const getSavePath = (pathString: string, notebookId: string, cb: (p: stri
|
|
notebook: data.data.box,
|
|
notebook: data.data.box,
|
|
path: targetPath
|
|
path: targetPath
|
|
}, (response) => {
|
|
}, (response) => {
|
|
- cb(getDisplayName(response.data, false, true));
|
|
|
|
|
|
+ cb(getDisplayName(response.data, false, true), data.data.box);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -199,21 +200,21 @@ export const newFileByName = (app: App, value: string) => {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
-export const newFileBySelect = (protyle: IProtyle, selectText: string, nodeElement: HTMLElement, pathDir: string) => {
|
|
|
|
|
|
+export const newFileBySelect = (protyle: IProtyle, selectText: string, nodeElement: HTMLElement, pathDir: string, targetNotebookId: string) => {
|
|
const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML).replace(/\n/g, "")) || window.siyuan.languages.untitled;
|
|
const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML).replace(/\n/g, "")) || window.siyuan.languages.untitled;
|
|
const hPath = pathPosix().join(pathDir, newFileName);
|
|
const hPath = pathPosix().join(pathDir, newFileName);
|
|
fetchPost("/api/filetree/getIDsByHPath", {
|
|
fetchPost("/api/filetree/getIDsByHPath", {
|
|
path: hPath,
|
|
path: hPath,
|
|
- notebook: protyle.notebookId
|
|
|
|
|
|
+ notebook: targetNotebookId
|
|
}, (idResponse) => {
|
|
}, (idResponse) => {
|
|
const refText = escapeHtml(newFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen));
|
|
const refText = escapeHtml(newFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen));
|
|
if (idResponse.data && idResponse.data.length > 0) {
|
|
if (idResponse.data && idResponse.data.length > 0) {
|
|
insertHTML(`<span data-type="block-ref" data-id="${idResponse.data[0]}" data-subtype="d">${refText}</span>`, protyle, false, true);
|
|
insertHTML(`<span data-type="block-ref" data-id="${idResponse.data[0]}" data-subtype="d">${refText}</span>`, protyle, false, true);
|
|
} else {
|
|
} else {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
fetchPost("/api/filetree/createDocWithMd", {
|
|
- notebook: protyle.notebookId,
|
|
|
|
|
|
+ notebook: targetNotebookId,
|
|
path: hPath,
|
|
path: hPath,
|
|
- parentID: protyle.block.rootID,
|
|
|
|
|
|
+ parentID: protyle.notebookId === targetNotebookId ? protyle.block.rootID : "",
|
|
markdown: ""
|
|
markdown: ""
|
|
}, response => {
|
|
}, response => {
|
|
insertHTML(`<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${refText}</span>`, protyle, false, true);
|
|
insertHTML(`<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${refText}</span>`, protyle, false, true);
|