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

Vanessa8b7be233d943
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index e74ea9bf3a..d87564859b 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -89,6 +89,7 @@ import {
getTypeByCellElement,
updateCellsValue
} from "../render/av/cell";
+import {openEmojiPanel, unicode2Emoji} from "../../emoji";
export class WYSIWYG {
public lastHTMLs: { [key: string]: string } = {};
@@ -2300,6 +2301,35 @@ export class WYSIWYG {
return;
}
+ const emojiElement = hasTopClosestByClassName(event.target, "emoji");
+ if (!event.shiftKey && !ctrlIsPressed && emojiElement) {
+ const nodeElement = hasClosestBlock(emojiElement);
+ if (nodeElement) {
+ const emojiRect = emojiElement.getBoundingClientRect()
+ openEmojiPanel("", "av", {
+ x: emojiRect.left,
+ y: emojiRect.bottom,
+ h: emojiRect.height,
+ w: emojiRect.width
+ }, (unicode) => {
+ emojiElement.insertAdjacentHTML("afterend", "<wbr>")
+ const oldHTML = nodeElement.outerHTML;
+ let emojiHTML;
+ if (unicode.indexOf(".") > -1) {
+ const emojiList = unicode.split(".");
+ emojiHTML = `<img alt="${emojiList[0]}" class="emoji" src="/emojis/${unicode}" title="${emojiList[0]}">`;
+ } else {
+ emojiHTML = unicode2Emoji(unicode);
+ }
+ emojiElement.outerHTML = emojiHTML;
+ hideElements(["dialog"]);
+ updateTransaction(protyle, nodeElement.getAttribute("data-node-id"), nodeElement.outerHTML, oldHTML);
+ focusByWbr(nodeElement, range);
+ });
+ }
+ return;
+ }
+
if (avClick(protyle, event)) {
return;
}