mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
Disallow draggin of mathjax + only ever have one handle active
This commit is contained in:
parent
9ef4bb15c6
commit
7ba85a2fbe
3 changed files with 16 additions and 7 deletions
|
@ -12,7 +12,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
$: encoded = encodeURIComponent(converted);
|
$: encoded = encodeURIComponent(converted);
|
||||||
</script>
|
</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">
|
<style lang="scss">
|
||||||
img {
|
img {
|
||||||
|
|
|
@ -130,7 +130,6 @@ export const Mathjax: DecoratedElementConstructor = class Mathjax
|
||||||
|
|
||||||
connectedCallback(): void {
|
connectedCallback(): void {
|
||||||
this.decorate();
|
this.decorate();
|
||||||
// TODO text is assigned white-space: normal
|
|
||||||
this.disconnect = moveNodesInsertedOutside(this, this.children[0]);
|
this.disconnect = moveNodesInsertedOutside(this, this.children[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,8 +222,8 @@ export class EditingArea extends HTMLDivElement {
|
||||||
this.activeInput.onPaste(event);
|
this.activeInput.onPaste(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetHandles(): void {
|
resetHandles(): Promise<void> {
|
||||||
this.imageHandle.then((imageHandle) =>
|
const promise = this.imageHandle.then((imageHandle) =>
|
||||||
(imageHandle as any).$set({
|
(imageHandle as any).$set({
|
||||||
activeImage: null,
|
activeImage: null,
|
||||||
})
|
})
|
||||||
|
@ -232,12 +232,16 @@ export class EditingArea extends HTMLDivElement {
|
||||||
(this.mathjaxHandle as any).$set({
|
(this.mathjaxHandle as any).$set({
|
||||||
activeImage: null,
|
activeImage: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
showHandles(event: MouseEvent): void {
|
async showHandles(event: MouseEvent): Promise<void> {
|
||||||
if (event.target instanceof HTMLImageElement) {
|
if (event.target instanceof HTMLImageElement) {
|
||||||
|
await this.resetHandles();
|
||||||
|
|
||||||
if (!event.target.dataset.anki) {
|
if (!event.target.dataset.anki) {
|
||||||
this.imageHandle.then((imageHandle) =>
|
await this.imageHandle.then((imageHandle) =>
|
||||||
(imageHandle as any).$set({
|
(imageHandle as any).$set({
|
||||||
activeImage: event.target,
|
activeImage: event.target,
|
||||||
isRtl: this.isRightToLeft(),
|
isRtl: this.isRightToLeft(),
|
||||||
|
@ -250,7 +254,7 @@ export class EditingArea extends HTMLDivElement {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.resetHandles();
|
await this.resetHandles();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue