diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts index 34a9e94f7..8dca51229 100644 --- a/app/src/protyle/hint/extend.ts +++ b/app/src/protyle/hint/extend.ts @@ -298,7 +298,7 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD if (response.data.newDoc) { const newFileName = Lute.UnEscapeHTMLStr(replaceFileName(response.data.k)); dataList.push({ - value: `((newFile "${newFileName}${Lute.Caret}"))`, + value: isQuick ? `((newFile "${newFileName}"${Constants.ZWSP}'${newFileName}${Lute.Caret}'))` : `((newFile '${newFileName}${Lute.Caret}'))`, html: `
${window.siyuan.languages.newFile} ${response.data.k}
`, }); diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts index 647ea0848..994bfc7a7 100644 --- a/app/src/protyle/hint/index.ts +++ b/app/src/protyle/hint/index.ts @@ -197,7 +197,7 @@ ${unicode2Emoji(emoji.unicode, true)}`; // https://github.com/siyuan-note/siyuan/issues/1229 提示时,新建文件不应默认选中 let focusClass = ""; if (i === 0) { - if (hintData.value.startsWith("((newFile ") && hintData.value.endsWith(`${Lute.Caret}"))`) && data.length > 1) { + if (hintData.value.startsWith("((newFile ") && hintData.value.endsWith(`${Lute.Caret}'))`) && data.length > 1) { focusClass = ""; } else { focusClass = " b3-list-item--focus"; @@ -280,7 +280,7 @@ ${unicode2Emoji(emoji.unicode, true)}`; } private genSearchHTML(protyle: IProtyle, searchElement: HTMLInputElement, nodeElement: false | HTMLElement, oldValue: string) { - this.element.lastElementChild.innerHTML = "
"; + this.element.lastElementChild.innerHTML = '
'; fetchPost("/api/search/searchRefBlock", { k: searchElement.value, id: nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.parentID, @@ -289,7 +289,8 @@ ${unicode2Emoji(emoji.unicode, true)}`; }, (response) => { let searchHTML = ""; if (response.data.newDoc) { - searchHTML += ``; } response.data.blocks.forEach((item: IBlock, index: number) => { @@ -307,7 +308,8 @@ ${unicode2Emoji(emoji.unicode, true)}`; if (attrHTML) { attrHTML = `
${attrHTML}
`; } - searchHTML += ``; } range.deleteContents(); // 新建文件 - if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar) && value.startsWith("((newFile ") && value.endsWith(`${Lute.Caret}"))`)) { + if (Constants.BLOCK_HINT_KEYS.includes(this.splitChar) && value.startsWith("((newFile ") && value.endsWith(`${Lute.Caret}'))`)) { focusByRange(range); - const fileName = value.substring(11, value.length - 4); + const fileNames = value.substring(11, value.length - 4).split(`"${Constants.ZWSP}'`) + const realFileName = fileNames.length === 1 ? fileNames[0] : fileNames[1]; getSavePath(protyle.path, protyle.notebookId, (pathString) => { fetchPost("/api/filetree/createDocWithMd", { notebook: protyle.notebookId, - path: pathPosix().join(pathString, fileName), + path: pathPosix().join(pathString, realFileName), markdown: "" }, response => { - insertHTML(genEmptyBlock(false, false, `${escapeHtml(fileName)}`), protyle); + let blockRefHTML = `${escapeHtml(realFileName)}` + if (fileNames.length === 2) { + blockRefHTML = `${escapeHtml(fileNames[0])}` + } + insertHTML(genEmptyBlock(false, false, blockRefHTML), protyle); }); }); return;