Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/6854

Vanessa286e87259bb4
diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 1039e49b5f..6b3cae8666 100644
--- a/app/src/protyle/wysiwyg/keydown.ts
+++ b/app/src/protyle/wysiwyg/keydown.ts
@@ -1047,16 +1047,19 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!selectText.trim()) {
selectAll(protyle, nodeElement, range);
}
- const newName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
- const id = Lute.NewNodeID();
- fetchPost("/api/filetree/createDoc", {
+ const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
+ fetchPost("/api/filetree/getHPathByPath", {
notebook: protyle.notebookId,
- path: pathPosix().join(getDisplayName(protyle.path, false, true), id + ".sy"),
- title: newName,
- md: ""
- }, () => {
- insertHTML(`<span data-type="block-ref" data-id="${id}" data-subtype="d">${escapeHtml(newName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`, protyle);
- hideElements(["toolbar"], protyle)
+ path: protyle.path,
+ }, (response) => {
+ fetchPost("/api/filetree/createDocWithMd", {
+ notebook: protyle.notebookId,
+ path: pathPosix().join(response.data, newFileName),
+ markdown: ""
+ }, response => {
+ insertHTML(`<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${escapeHtml(newFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}</span>`, protyle);
+ hideElements(["toolbar"], protyle)
+ });
});
}
event.preventDefault();
@@ -1071,8 +1074,8 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
if (!selectText.trim()) {
selectAll(protyle, nodeElement, range);
}
- const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML));
getSavePath(protyle.path, protyle.notebookId, (pathString) => {
+ const newFileName = replaceFileName(selectText.trim() ? selectText.trim() : protyle.lute.BlockDOM2Content(nodeElement.outerHTML)) || "Untitled";
fetchPost("/api/filetree/createDocWithMd", {
notebook: protyle.notebookId,
path: pathPosix().join(pathString, newFileName),