diff --git a/app/src/protyle/wysiwyg/keydown.ts b/app/src/protyle/wysiwyg/keydown.ts
index 1039e49b5..6b3cae866 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(`${escapeHtml(newName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}`, protyle);
- hideElements(["toolbar"], protyle)
+ path: protyle.path,
+ }, (response) => {
+ fetchPost("/api/filetree/createDocWithMd", {
+ notebook: protyle.notebookId,
+ path: pathPosix().join(response.data, newFileName),
+ markdown: ""
+ }, response => {
+ insertHTML(`${escapeHtml(newFileName.substring(0, window.siyuan.config.editor.blockRefDynamicAnchorTextMaxLen))}`, 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),