mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
This commit is contained in:
parent
8038877f82
commit
be53f83c59
2 changed files with 37 additions and 1 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue