Skip to content

Commit

Permalink
🎨 fix #7146
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Jan 23, 2023
1 parent 559484b commit c5f5290
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
7 changes: 6 additions & 1 deletion app/src/protyle/hint/extend.ts
Expand Up @@ -278,8 +278,11 @@ export const hintTag = (key: string, protyle: IProtyle): IHintData[] => {
if (response.data.k && !hasKey) {
dataList.splice(0, 0, {
value: `#${response.data.k}#`,
html: `<mark>${escapeHtml(response.data.k)}</mark>`,
html: `${window.siyuan.languages.new} <mark>${escapeHtml(response.data.k)}</mark>`,
});
if (dataList.length > 1) {
dataList[1].focus = true;
}
}
protyle.hint.genHTML(dataList, protyle, true);
});
Expand Down Expand Up @@ -342,6 +345,8 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
value: "",
html: window.siyuan.languages.emptyContent,
});
} else if (response.data.newDoc && dataList.length > 1) {
dataList[1].focus = true;
}
protyle.hint.genHTML(dataList, protyle, true, isQuick);
});
Expand Down
11 changes: 2 additions & 9 deletions app/src/protyle/hint/index.ts
Expand Up @@ -191,18 +191,11 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
} else {
this.element.style.display = "";
}
let hasFocus = false;
data.forEach((hintData, i) => {
// 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) {
focusClass = "";
} else {
focusClass = " b3-list-item--focus";
hasFocus = true;
}
} else if (i === 1 && !hasFocus) {
if ((i === 1 && data[i].focus ) ||
(i === 0 && (data.length === 1 || !data[1].focus))) {
focusClass = " b3-list-item--focus";
}
if (hintData.html === "separator") {
Expand Down
1 change: 1 addition & 0 deletions app/src/types/protyle.d.ts
Expand Up @@ -337,6 +337,7 @@ interface IHintData {
html: string;
value: string;
filter?: string[]
focus?: boolean
}

interface IHintExtend {
Expand Down

0 comments on commit c5f5290

Please sign in to comment.