Disallow draggin of mathjax + only ever have one handle active

This commit is contained in:
Henrik Giesel 2021-08-07 04:04:42 +02:00
parent 9ef4bb15c6
commit 7ba85a2fbe
3 changed files with 16 additions and 7 deletions

View file

@ -12,7 +12,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
$: encoded = encodeURIComponent(converted);
</script>
<img src="data:image/svg+xml,{encoded}" class:block alt="Mathjax" data-anki="mathjax" />
<img
src="data:image/svg+xml,{encoded}"
class:block
alt="Mathjax"
data-anki="mathjax"
on:dragstart|preventDefault
/>
<style lang="scss">
img {

View file

@ -130,7 +130,6 @@ export const Mathjax: DecoratedElementConstructor = class Mathjax
connectedCallback(): void {
this.decorate();
// TODO text is assigned white-space: normal
this.disconnect = moveNodesInsertedOutside(this, this.children[0]);
}

View file

@ -222,8 +222,8 @@ export class EditingArea extends HTMLDivElement {
this.activeInput.onPaste(event);
}
resetHandles(): void {
this.imageHandle.then((imageHandle) =>
resetHandles(): Promise<void> {
const promise = this.imageHandle.then((imageHandle) =>
(imageHandle as any).$set({
activeImage: null,
})
@ -232,12 +232,16 @@ export class EditingArea extends HTMLDivElement {
(this.mathjaxHandle as any).$set({
activeImage: null,
});
return promise;
}
showHandles(event: MouseEvent): void {
async showHandles(event: MouseEvent): Promise<void> {
if (event.target instanceof HTMLImageElement) {
await this.resetHandles();
if (!event.target.dataset.anki) {
this.imageHandle.then((imageHandle) =>
await this.imageHandle.then((imageHandle) =>
(imageHandle as any).$set({
activeImage: event.target,
isRtl: this.isRightToLeft(),
@ -250,7 +254,7 @@ export class EditingArea extends HTMLDivElement {
});
}
} else {
this.resetHandles();
await this.resetHandles();
}
}