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

Vanessaec316d114b84
diff --git a/app/src/protyle/hint/extend.ts b/app/src/protyle/hint/extend.ts
index 4c4f1c2439..366a56d3c0 100644
--- a/app/src/protyle/hint/extend.ts
+++ b/app/src/protyle/hint/extend.ts
@@ -18,6 +18,7 @@ import {escapeHtml} from "../../util/escape";
import {zoomOut} from "../../menus/protyle";
import {hideElements} from "../ui/hideElements";
import {genAssetHTML} from "../../asset/renderAssets";
+import {unicode2Emoji} from "../../emoji";
export const hintSlash = (key: string, protyle: IProtyle) => {
const allList: IHintData[] = [{
@@ -319,7 +320,13 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
});
}
response.data.blocks.forEach((item: IBlock) => {
- const iconName = getIconByType(item.type);
+ let iconHTML;
+ if (item.type === "NodeDocument" && item.ial.icon){
+ iconHTML = unicode2Emoji(item.ial.icon, false, "b3-list-item__graphic popover__block", true);
+ iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`)
+ } else {
+ iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
+ }
let attrHTML = "";
if (item.name) {
attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg><span>${item.name}</span></span><span class="fn__space"></span>`;
@@ -340,7 +347,7 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
dataList.push({
value,
html: `${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>
+ ${iconHTML}
<span class="b3-list-item__text">${item.content}</span>
</div>
<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div>`,
@@ -377,7 +384,13 @@ export const hintEmbed = (key: string, protyle: IProtyle): IHintData[] => {
}, (response) => {
const dataList: IHintData[] = [];
response.data.blocks.forEach((item: IBlock) => {
- const iconName = getIconByType(item.type);
+ let iconHTML;
+ if (item.type === "NodeDocument" && item.ial.icon){
+ iconHTML = unicode2Emoji(item.ial.icon, false, "b3-list-item__graphic popover__block", true);
+ iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`)
+ } else {
+ iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
+ }
let attrHTML = "";
if (item.name) {
attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg>${item.name}</span><span class="fn__space"></span>`;
@@ -394,7 +407,7 @@ export const hintEmbed = (key: string, protyle: IProtyle): IHintData[] => {
dataList.push({
value: `{{select * from blocks where id='${item.id}'}}`,
html: `${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>
+ ${iconHTML}
<span class="b3-list-item__text">${item.content}</span>
</div>
<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div>`,
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index 0a76356767..e8efff8e78 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -288,7 +288,10 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
searchElement.value = oldValue;
searchElement.select();
searchElement.addEventListener("keydown", (event: KeyboardEvent) => {
- event.stopPropagation();
+ if (event.key !== "Meta" && event.key !== "Control") {
+ // 需要冒泡以满足光标在块标位置时 ctrl 弹出悬浮层
+ event.stopPropagation();
+ }
if (event.isComposing) {
return;
}
@@ -334,7 +337,13 @@ ${unicode2Emoji(emoji.unicode, true)}</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) => {
- const iconName = getIconByType(item.type);
+ let iconHTML;
+ if (item.type === "NodeDocument" && item.ial.icon) {
+ iconHTML = unicode2Emoji(item.ial.icon, false, "b3-list-item__graphic popover__block", true);
+ iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`)
+ } else {
+ iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
+ }
let attrHTML = "";
if (item.name) {
attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg><span>${item.name}</span></span><span class="fn__space"></span>`;
@@ -350,7 +359,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
}
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>
+ ${iconHTML}
<span class="b3-list-item__text">${item.content}</span>
</div>
<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div></button>`;