Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/16051

Vanessabe53f83c59a1
diff --git a/app/src/emoji/index.ts b/app/src/emoji/index.ts
index 873ab323ed..7e26cedf2c 100644
--- a/app/src/emoji/index.ts
+++ b/app/src/emoji/index.ts
@@ -229,7 +229,12 @@ const renderEmojiContent = (previousIndex: string, previousContentElement: Eleme
previousContentElement.removeAttribute("style");
};
-export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition, callback?: (emoji: string) => void, dynamicImgElement?: HTMLElement) => {
+export const openEmojiPanel = (
+ id: string,
+ type: "doc" | "notebook" | "av",
+ position: IPosition,
+ callback?: (emoji: string) => void,
+ dynamicImgElement?: HTMLElement) => {
if (type !== "av") {
window.siyuan.menus.menu.remove();
} else {
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 1f86663a21..51b1072a93 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -3036,6 +3036,37 @@ export class WYSIWYG {
return;
}
+ const calloutIconElement = hasTopClosestByClassName(event.target, "callout-icon");
+ if (!protyle.disabled && !event.shiftKey && !ctrlIsPressed && calloutIconElement) {
+ const nodeElement = hasClosestBlock(calloutIconElement);
+ if (nodeElement) {
+ const emojiRect = calloutIconElement.getBoundingClientRect();
+ openEmojiPanel("", "av", {
+ x: emojiRect.left,
+ y: emojiRect.bottom,
+ h: emojiRect.height,
+ w: emojiRect.width
+ }, (unicode) => {
+ const oldHTML = nodeElement.outerHTML;
+ let emojiHTML;
+ if (unicode.startsWith("api/icon/getDynamicIcon")) {
+ emojiHTML = `<img class="callout-img" src="${unicode}"/>`;
+ } else if (unicode.indexOf(".") > -1) {
+ emojiHTML = `<img class="callout-img" src="/emojis/${unicode}">`;
+ } else {
+ emojiHTML = unicode2Emoji(unicode);
+ }
+ calloutIconElement.innerHTML = emojiHTML;
+ hideElements(["dialog"]);
+ updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
+ focusByWbr(nodeElement, range);
+ }, calloutIconElement.querySelector("img"));
+ }
+ event.preventDefault();
+ event.stopPropagation();
+ return;
+ }
+
const emojiElement = hasTopClosestByClassName(event.target, "emoji");
if (!protyle.disabled && !event.shiftKey && !ctrlIsPressed && emojiElement) {
const nodeElement = hasClosestBlock(emojiElement);