Jeffrey Chen 2025-01-06 17:38:24 +08:00 committed by GitHub
parent 7b9a74ea52
commit 1b05bb9afe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -524,15 +524,28 @@ export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", posi
if (target.classList.contains("emojis__type")) { if (target.classList.contains("emojis__type")) {
const titleElement = emojisContentElement.querySelector(`[data-type="${target.getAttribute("data-type")}"]`) as HTMLElement; const titleElement = emojisContentElement.querySelector(`[data-type="${target.getAttribute("data-type")}"]`) as HTMLElement;
if (titleElement) { if (titleElement) {
const index = titleElement.nextElementSibling.getAttribute("data-index"); const previousElement = titleElement.previousElementSibling as HTMLElement;
const previousIndex = previousElement?.getAttribute("data-index");
const nextElement = titleElement.nextElementSibling as HTMLElement;
const index = nextElement?.getAttribute("data-index");
if (previousIndex) {
let html = "";
window.siyuan.emojis[parseInt(previousIndex)].items.forEach(emoji => {
html += `<button data-unicode="${emoji.unicode}" class="emojis__item ariaLabel" aria-label="${getEmojiDesc(emoji)}">${unicode2Emoji(emoji.unicode)}</button>`;
});
previousElement.innerHTML = html;
previousElement.removeAttribute("data-index");
previousElement.style.minHeight = "";
}
if (index) { if (index) {
let html = ""; let html = "";
window.siyuan.emojis[parseInt(index)].items.forEach(emoji => { window.siyuan.emojis[parseInt(index)].items.forEach(emoji => {
html += `<button data-unicode="${emoji.unicode}" class="emojis__item ariaLabel" aria-label="${getEmojiDesc(emoji)}"> html += `<button data-unicode="${emoji.unicode}" class="emojis__item ariaLabel" aria-label="${getEmojiDesc(emoji)}">${unicode2Emoji(emoji.unicode)}</button>`;
${unicode2Emoji(emoji.unicode)}</button>`;
}); });
titleElement.nextElementSibling.innerHTML = html; nextElement.innerHTML = html;
titleElement.nextElementSibling.removeAttribute("data-index"); nextElement.removeAttribute("data-index");
nextElement.style.minHeight = "";
} }
emojisContentElement.scrollTo({ emojisContentElement.scrollTo({