mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Generalize accesing anki-mathjax from image in MathjaxHandle
This commit is contained in:
parent
b6bea18b22
commit
c02973a85d
1 changed files with 6 additions and 2 deletions
|
@ -31,8 +31,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
let updateSelection: () => void;
|
let updateSelection: () => void;
|
||||||
let title: string;
|
let title: string;
|
||||||
|
|
||||||
|
function getComponent(image: HTMLImageElement): HTMLElement {
|
||||||
|
return (image.closest("anki-mathjax")! as HTMLElement);
|
||||||
|
}
|
||||||
|
|
||||||
function onUpdate(event: CustomEvent) {
|
function onUpdate(event: CustomEvent) {
|
||||||
activeImage!.parentElement!.dataset.mathjax = event.detail.mathjax;
|
getComponent(activeImage!).dataset.mathjax = event.detail.mathjax;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
updateSelection();
|
updateSelection();
|
||||||
title = activeImage!.title;
|
title = activeImage!.title;
|
||||||
|
@ -63,7 +67,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<MathjaxHandleEditor
|
<MathjaxHandleEditor
|
||||||
initialValue={activeImage.parentElement?.dataset.mathjax ?? ""}
|
initialValue={getComponent(activeImage).dataset.mathjax ?? ""}
|
||||||
on:update={(event) => {
|
on:update={(event) => {
|
||||||
onUpdate(event);
|
onUpdate(event);
|
||||||
setTimeout(dropdownObject.update);
|
setTimeout(dropdownObject.update);
|
||||||
|
|
Loading…
Reference in a new issue