mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
This commit is contained in:
parent
3c5a4043de
commit
7881d97e84
2 changed files with 16 additions and 9 deletions
|
|
@ -298,7 +298,7 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
|
||||||
if (response.data.newDoc) {
|
if (response.data.newDoc) {
|
||||||
const newFileName = Lute.UnEscapeHTMLStr(replaceFileName(response.data.k));
|
const newFileName = Lute.UnEscapeHTMLStr(replaceFileName(response.data.k));
|
||||||
dataList.push({
|
dataList.push({
|
||||||
value: `((newFile "${newFileName}${Lute.Caret}"))`,
|
value: isQuick ? `((newFile "${newFileName}"${Constants.ZWSP}'${newFileName}${Lute.Caret}'))` : `((newFile '${newFileName}${Lute.Caret}'))`,
|
||||||
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
||||||
<span class="b3-list-item__text">${window.siyuan.languages.newFile} <mark>${response.data.k}</mark></span></div>`,
|
<span class="b3-list-item__text">${window.siyuan.languages.newFile} <mark>${response.data.k}</mark></span></div>`,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
// https://github.com/siyuan-note/siyuan/issues/1229 提示时,新建文件不应默认选中
|
// https://github.com/siyuan-note/siyuan/issues/1229 提示时,新建文件不应默认选中
|
||||||
let focusClass = "";
|
let focusClass = "";
|
||||||
if (i === 0) {
|
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 = "";
|
focusClass = "";
|
||||||
} else {
|
} else {
|
||||||
focusClass = " b3-list-item--focus";
|
focusClass = " b3-list-item--focus";
|
||||||
|
|
@ -280,7 +280,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private genSearchHTML(protyle: IProtyle, searchElement: HTMLInputElement, nodeElement: false | HTMLElement, oldValue: string) {
|
private genSearchHTML(protyle: IProtyle, searchElement: HTMLInputElement, nodeElement: false | HTMLElement, oldValue: string) {
|
||||||
this.element.lastElementChild.innerHTML = "<div class=\"ft__center\"><img style=\"height:32px;width:32px;\" src=\"/stage/loading-pure.svg\"></div>";
|
this.element.lastElementChild.innerHTML = '<div class="ft__center"><img style="height:32px;width:32px;" src="/stage/loading-pure.svg"></div>';
|
||||||
fetchPost("/api/search/searchRefBlock", {
|
fetchPost("/api/search/searchRefBlock", {
|
||||||
k: searchElement.value,
|
k: searchElement.value,
|
||||||
id: nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.parentID,
|
id: nodeElement ? nodeElement.getAttribute("data-node-id") : protyle.block.parentID,
|
||||||
|
|
@ -289,7 +289,8 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
}, (response) => {
|
}, (response) => {
|
||||||
let searchHTML = "";
|
let searchHTML = "";
|
||||||
if (response.data.newDoc) {
|
if (response.data.newDoc) {
|
||||||
searchHTML += `<button class="b3-list-item b3-list-item--two fn__block${response.data.blocks.length === 0 ? " b3-list-item--focus" : ""}" data-value="${encodeURIComponent('((newFile "' + oldValue + Lute.Caret + '"))')}"><div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
const blockRefText = `((newFile "${oldValue}"${Constants.ZWSP}'${response.data.k}${Lute.Caret}'))`
|
||||||
|
searchHTML += `<button class="b3-list-item b3-list-item--two fn__block${response.data.blocks.length === 0 ? " b3-list-item--focus" : ""}" data-value="${encodeURIComponent(blockRefText)}"><div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg>
|
||||||
<span class="b3-list-item__text">${window.siyuan.languages.newFile} <mark>${response.data.k}</mark></span></div></button>`;
|
<span class="b3-list-item__text">${window.siyuan.languages.newFile} <mark>${response.data.k}</mark></span></div></button>`;
|
||||||
}
|
}
|
||||||
response.data.blocks.forEach((item: IBlock, index: number) => {
|
response.data.blocks.forEach((item: IBlock, index: number) => {
|
||||||
|
|
@ -307,7 +308,8 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
if (attrHTML) {
|
if (attrHTML) {
|
||||||
attrHTML = `<div class="fn__flex b3-list-item__meta" style="line-height: 1">${attrHTML}</div>`;
|
attrHTML = `<div class="fn__flex b3-list-item__meta" style="line-height: 1">${attrHTML}</div>`;
|
||||||
}
|
}
|
||||||
searchHTML += `<button class="b3-list-item b3-list-item--two fn__block${index === 0 ? " b3-list-item--focus" : ""}" data-value="${encodeURIComponent('<span data-type="block-ref" data-id="' + item.id + '" data-subtype="s">' + oldValue + "</span>")}">${attrHTML}<div class="b3-list-item__first">
|
const blockRefHTML = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${oldValue}</span>`
|
||||||
|
searchHTML += `<button class="b3-list-item b3-list-item--two fn__block${index === 0 ? " b3-list-item--focus" : ""}" data-value="${encodeURIComponent(blockRefHTML)}">${attrHTML}<div class="b3-list-item__first">
|
||||||
<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${iconName}"></use></svg>
|
<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${iconName}"></use></svg>
|
||||||
<span class="b3-list-item__text">${item.content}</span>
|
<span class="b3-list-item__text">${item.content}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -409,16 +411,21 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
|
||||||
}
|
}
|
||||||
range.deleteContents();
|
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);
|
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) => {
|
getSavePath(protyle.path, protyle.notebookId, (pathString) => {
|
||||||
fetchPost("/api/filetree/createDocWithMd", {
|
fetchPost("/api/filetree/createDocWithMd", {
|
||||||
notebook: protyle.notebookId,
|
notebook: protyle.notebookId,
|
||||||
path: pathPosix().join(pathString, fileName),
|
path: pathPosix().join(pathString, realFileName),
|
||||||
markdown: ""
|
markdown: ""
|
||||||
}, response => {
|
}, response => {
|
||||||
insertHTML(genEmptyBlock(false, false, `<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${escapeHtml(fileName)}</span>`), protyle);
|
let blockRefHTML = `<span data-type="block-ref" data-id="${response.data}" data-subtype="d">${escapeHtml(realFileName)}</span>`
|
||||||
|
if (fileNames.length === 2) {
|
||||||
|
blockRefHTML = `<span data-type="block-ref" data-id="${response.data}" data-subtype="s">${escapeHtml(fileNames[0])}</span>`
|
||||||
|
}
|
||||||
|
insertHTML(genEmptyBlock(false, false, blockRefHTML), protyle);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue