mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-08 05:32:33 +01:00
This commit is contained in:
parent
d03ebdec82
commit
48bde74170
2 changed files with 22 additions and 10 deletions
|
|
@ -87,7 +87,7 @@ export const lazyLoadEmojiImg = (element: Element) => {
|
|||
});
|
||||
};
|
||||
|
||||
export const filterEmoji = (key = "", max?: number) => {
|
||||
export const filterEmoji = (key = "", max?: number, hideCustom = false) => {
|
||||
let html = "";
|
||||
const recentEmojis: IEmojiItem[] = [];
|
||||
if (key) {
|
||||
|
|
@ -97,6 +97,9 @@ export const filterEmoji = (key = "", max?: number) => {
|
|||
let keyHTML = "";
|
||||
const customStore: IEmojiItem[] = [];
|
||||
window.siyuan.emojis.forEach((category, index) => {
|
||||
if (hideCustom && category.id === "custom") {
|
||||
return;
|
||||
}
|
||||
if (!key) {
|
||||
html += `<div class="emojis__title" data-type="${index + 1}">${getEmojiTitle(index)}</div><div style="min-height:${index === 0 ? "30px" : "300px"}" class="emojis__content"${index > 1 ? ' data-index="' + index + '"' : ""}>`;
|
||||
}
|
||||
|
|
@ -236,7 +239,11 @@ export const openEmojiPanel = (
|
|||
type: "doc" | "notebook" | "av",
|
||||
position: IPosition,
|
||||
callback?: (emoji: string) => void,
|
||||
dynamicImgElement?: HTMLElement) => {
|
||||
dynamicImgElement?: HTMLElement,
|
||||
hide?: {
|
||||
dynamic: boolean,
|
||||
custom: boolean
|
||||
}) => {
|
||||
if (type !== "av") {
|
||||
window.siyuan.menus.menu.remove();
|
||||
} else {
|
||||
|
|
@ -275,7 +282,7 @@ export const openEmojiPanel = (
|
|||
<div class="emojis__tabheader">
|
||||
<div data-type="tab-emoji" class="ariaLabel block__icon block__icon--show" aria-label="${window.siyuan.languages.emoji}"><svg><use xlink:href="#iconEmoji"></use></svg></div>
|
||||
<div class="fn__space"></div>
|
||||
<div data-type="tab-dynamic" class="ariaLabel block__icon block__icon--show" aria-label="${window.siyuan.languages.dynamicIcon}"><svg><use xlink:href="#iconCalendar"></use></svg></div>
|
||||
<div data-type="tab-dynamic" class="ariaLabel block__icon block__icon--show${hide?.dynamic ? " fn__none" : ""}" aria-label="${window.siyuan.languages.dynamicIcon}"><svg><use xlink:href="#iconCalendar"></use></svg></div>
|
||||
<div class="fn__flex-1"></div>
|
||||
<span class="block__icon block__icon--show fn__flex-center ariaLabel" data-action="remove" aria-label="${window.siyuan.languages.remove}"><svg><use xlink:href="#iconTrashcan"></use></svg></span>
|
||||
</div>
|
||||
|
|
@ -292,7 +299,7 @@ export const openEmojiPanel = (
|
|||
<span class="block__icon block__icon--show fn__flex-center ariaLabel" data-action="random" aria-label="${window.siyuan.languages.random}"><svg><use xlink:href="#iconRefresh"></use></svg></span>
|
||||
<span class="fn__space"></span>
|
||||
</div>
|
||||
<div class="emojis__panel">${filterEmoji()}</div>
|
||||
<div class="emojis__panel">${filterEmoji("", null, hide?.custom)}</div>
|
||||
<div class="fn__flex">
|
||||
${[
|
||||
["2b50", window.siyuan.languages.recentEmoji],
|
||||
|
|
@ -305,9 +312,12 @@ export const openEmojiPanel = (
|
|||
["1f52e", getEmojiTitle(6)],
|
||||
["267e-fe0f", getEmojiTitle(7)],
|
||||
["1f6a9", getEmojiTitle(8)],
|
||||
].map(([unicode, title], index) =>
|
||||
`<div data-type="${index}" class="emojis__type ariaLabel" aria-label="${title}">${unicode2Emoji(unicode)}</div>`
|
||||
).join("")}
|
||||
].map(([unicode, title], index) => {
|
||||
if (hide?.custom && index === 1) {
|
||||
return "";
|
||||
}
|
||||
return `<div data-type="${index}" class="emojis__type ariaLabel" aria-label="${title}">${unicode2Emoji(unicode)}</div>`;
|
||||
}).join("")}
|
||||
</div>
|
||||
</div>
|
||||
<div class="fn__none" data-type="tab-dynamic">
|
||||
|
|
@ -392,7 +402,7 @@ export const openEmojiPanel = (
|
|||
const emojiSearchInputElement = dialog.element.querySelector('[data-type="tab-emoji"] .b3-text-field') as HTMLInputElement;
|
||||
const emojisContentElement = dialog.element.querySelector(".emojis__panel");
|
||||
emojiSearchInputElement.addEventListener("compositionend", () => {
|
||||
emojisContentElement.innerHTML = filterEmoji(emojiSearchInputElement.value);
|
||||
emojisContentElement.innerHTML = filterEmoji(emojiSearchInputElement.value, null, hide?.custom);
|
||||
if (emojiSearchInputElement.value) {
|
||||
emojisContentElement.nextElementSibling.classList.add("fn__none");
|
||||
} else {
|
||||
|
|
@ -409,7 +419,7 @@ export const openEmojiPanel = (
|
|||
if (event.isComposing) {
|
||||
return;
|
||||
}
|
||||
emojisContentElement.innerHTML = filterEmoji(emojiSearchInputElement.value);
|
||||
emojisContentElement.innerHTML = filterEmoji(emojiSearchInputElement.value, null, hide?.custom);
|
||||
if (emojiSearchInputElement.value) {
|
||||
emojisContentElement.nextElementSibling.classList.add("fn__none");
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -310,13 +310,15 @@ const openEmoji = (options: {
|
|||
position: IPosition,
|
||||
selectedCB?: (emoji: string) => void,
|
||||
dynamicIconURL?: string
|
||||
hideDynamicIcon?: boolean
|
||||
hideCustomIcon?: boolean
|
||||
}) => {
|
||||
let dynamicImgElement: HTMLImageElement;
|
||||
if (options.dynamicIconURL) {
|
||||
dynamicImgElement = document.createElement("img");
|
||||
dynamicImgElement.src = options.dynamicIconURL;
|
||||
}
|
||||
openEmojiPanel("", "av", options.position, options.selectedCB, dynamicImgElement);
|
||||
openEmojiPanel("", "av", options.position, options.selectedCB, dynamicImgElement, {dynamic: options.hideDynamicIcon, custom: options.hideCustomIcon});
|
||||
};
|
||||
|
||||
export const API = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue