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/7754

Vanessaca68a787bae5
diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts
index 12a30f08a3..305d8306a7 100644
--- a/app/src/protyle/toolbar/index.ts
+++ b/app/src/protyle/toolbar/index.ts
@@ -1252,16 +1252,17 @@ export class Toolbar {
}
});
inputElement.addEventListener("input", (event) => {
- const mathLanguages: string[] = [];
+ const matchLanguages: string[] = [];
Constants.CODE_LANGUAGES.forEach((item) => {
if (item.indexOf(inputElement.value.toLowerCase()) > -1) {
- mathLanguages.push(item);
+ matchLanguages.push(item);
}
});
let html = "";
// sort
- mathLanguages.sort((a, b) => {
+ let matchInput = false;
+ matchLanguages.sort((a, b) => {
if (a.startsWith(inputElement.value.toLowerCase()) && b.startsWith(inputElement.value.toLowerCase())) {
if (a.length < b.length) {
return -1;
@@ -1278,8 +1279,14 @@ export class Toolbar {
return 0;
}
}).forEach((item) => {
+ if (inputElement.value === item) {
+ matchInput = true
+ }
html += `<div class="b3-list-item">${item.replace(inputElement.value.toLowerCase(), "<b>" + inputElement.value.toLowerCase() + "</b>")}</div>`;
});
+ if (inputElement.value.trim() && !matchInput) {
+ html = `<div class="b3-list-item"><b>${inputElement.value.replace(/`| /g, "_")}</b></div>${html}`;
+ }
this.subElement.firstElementChild.lastElementChild.innerHTML = html;
if (html) {
this.subElement.firstElementChild.lastElementChild.firstElementChild.classList.add("b3-list-item--focus");