From 8b7be233d9435d0516d124bb7f5fdb4ba0be9ec4 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 2 Feb 2024 21:57:47 +0800 Subject: [PATCH] :art: fix https://github.com/siyuan-note/siyuan/issues/9164 --- app/src/protyle/wysiwyg/index.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index e74ea9bf3..d87564859 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", "") + const oldHTML = nodeElement.outerHTML; + let emojiHTML; + if (unicode.indexOf(".") > -1) { + const emojiList = unicode.split("."); + emojiHTML = `${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; }