mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -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);
|
||||
</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 {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue