Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/11345

Vanessa84819beaf7f5
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 75e51a55c1..e7ebffa3ce 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -621,6 +621,9 @@ ${genHintItemHTML(item)}
notebookId: protyle.notebookId,
useSavePath: true,
currentPath: protyle.path,
+ afterCB: (createDocId, createDocTitle) => {
+ insertHTML(`<span data-type="block-ref" data-id="${createDocId}" data-subtype="d">${createDocTitle}</span>`, protyle);
+ }
});
return;
} else if (value === Constants.ZWSP + 6) {
@@ -632,7 +635,7 @@ ${genHintItemHTML(item)}
title: window.siyuan.languages.untitled,
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
openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #else
diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts
index 9b3542d3f0..91b1957d02 100644
--- a/app/src/util/newFile.ts
+++ b/app/src/util/newFile.ts
@@ -80,7 +80,8 @@ export const newFile = (optios: {
currentPath?: string,
paths?: string[],
useSavePath: boolean,
- name?: string
+ name?: string,
+ afterCB?: (id: string, title: string) => void
}) => {
if (getOpenNotebookCount() === 0) {
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.startsWith("/") || optios.currentPath === "/") {
+ const createPath = pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : ""))
fetchPost("/api/filetree/createDocWithMd", {
notebook: data.data.box,
- path: pathPosix().join(data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
+ path: createPath,
// 根目录时无法确定 parentID
markdown: ""
}, response => {
+ if (optios.afterCB) {
+ optios.afterCB(response.data, pathPosix().basename(createPath));
+ }
/// #if !MOBILE
openFileById({
app: optios.app,
@@ -118,12 +123,16 @@ export const newFile = (optios: {
notebook: data.data.box,
path: optios.notebookId === data.data.box ? (optios.currentPath.endsWith(".sy") ? optios.currentPath : optios.currentPath + ".sy") : (data.data.path || "/")
}, (responseHPath) => {
+ const createPath = pathPosix().join(responseHPath.data, data.data.path, optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : ""))
fetchPost("/api/filetree/createDocWithMd", {
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),
markdown: ""
}, response => {
+ if (optios.afterCB) {
+ optios.afterCB(response.data, pathPosix().basename(createPath));
+ }
/// #if !MOBILE
openFileById({
app: optios.app,
@@ -142,11 +151,15 @@ export const newFile = (optios: {
return;
}
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", {
notebook: data.data.box,
- path: pathPosix().join(data.data.path || "/", optios.name || (data.data.path.endsWith("/") ? window.siyuan.languages.untitled : "")),
+ path: createPath,
markdown: ""
}, response => {
+ if (optios.afterCB) {
+ optios.afterCB(response.data, pathPosix().basename(createPath));
+ }
/// #if !MOBILE
openFileById({
app: optios.app,
@@ -172,6 +185,9 @@ export const newFile = (optios: {
md: "",
sorts: optios.paths
}, () => {
+ if (optios.afterCB) {
+ optios.afterCB(id, title);
+ }
/// #if !MOBILE
openFileById({app: optios.app, id, action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]});
/// #else