Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@openwebwork/mathquill",
"description": "Easily type math in your webapp",
"version": "0.11.3",
"version": "0.11.4",
"license": "MPL-2.0",
"repository": {
"type": "git",
Expand Down
11 changes: 8 additions & 3 deletions src/toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { EditableField } from 'src/abstractFields';
import { StaticMath } from 'commands/math';

export class MathQuillToolbar {
private enabled: boolean;
private element?: HTMLDivElement;
private tooltips: Tooltip[] = [];
private contextMenuElement?: HTMLDivElement;
Expand All @@ -14,12 +13,19 @@ export class MathQuillToolbar {
private controller: Controller,
private textarea: HTMLTextAreaElement
) {
this.enabled = (localStorage.getItem('MQEditorToolbarEnabled') ?? 'true') === 'true';
textarea.addEventListener('focusin', this.insert);
textarea.addEventListener('focusout', this.removeUnlessFocused);
this.controller.container.addEventListener('contextmenu', this.contextMenu);
}

get enabled() {
return (localStorage.getItem('MQEditorToolbarEnabled') ?? 'true') === 'true';
}

set enabled(enable: boolean) {
localStorage.setItem('MQEditorToolbarEnabled', enable ? 'true' : 'false');
}

unbind() {
this.textarea.removeEventListener('focusin', this.insert);
this.textarea.removeEventListener('focusout', this.removeUnlessFocused);
Expand Down Expand Up @@ -307,7 +313,6 @@ export class MathQuillToolbar {
(e) => {
e.preventDefault();
this.enabled = !this.enabled;
localStorage.setItem('MQEditorToolbarEnabled', this.enabled ? 'true' : 'false');
if (!this.enabled && this.element) this.remove();
// Bootstrap tries to focus the triggering element after hiding the menu. However, the menu gets
// disposed of and the hidden link which is the triggering element removed too quickly in the
Expand Down
Loading