diff --git a/qt/aqt/browser/browser.py b/qt/aqt/browser/browser.py index 2a0606789..e78f1a173 100644 --- a/qt/aqt/browser/browser.py +++ b/qt/aqt/browser/browser.py @@ -399,7 +399,6 @@ $editorToolbar.addButton({{ def add_preview_shortcut(cuts, editor: Editor) -> None: cuts.append(("Ctrl+Shift+P", self.onTogglePreview, True)) - gui_hooks.editor_did_init.append(add_preview_button) gui_hooks.editor_did_init_shortcuts.append(add_preview_shortcut) self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self) diff --git a/ts/editor-toolbar/DropdownItem.svelte b/ts/editor-toolbar/DropdownItem.svelte index 510670dee..d074e6171 100644 --- a/ts/editor-toolbar/DropdownItem.svelte +++ b/ts/editor-toolbar/DropdownItem.svelte @@ -45,6 +45,10 @@ font-size: calc(var(--toolbar-size) / 2.3); color: inherit; } + + .monospace { + font-family: monospace; + } diff --git a/ts/editor-toolbar/template.ts b/ts/editor-toolbar/template.ts index 332a7cd80..96790ec54 100644 --- a/ts/editor-toolbar/template.ts +++ b/ts/editor-toolbar/template.ts @@ -91,28 +91,51 @@ export function getTemplateGroup(): DynamicSvelteComponent & export function getTemplateMenus(): (DynamicSvelteComponent & DropdownMenuProps)[] { + const mathjaxMenuItems = [ + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("\\(", "\\)"), + label: tr.editingMathjaxInline(), + endLabel: "Ctrl+M, M", + }), + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("\\[", "\\]"), + label: tr.editingMathjaxBlock(), + endLabel: "Ctrl+M, E", + }), + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("\\(\\ce{", "}\\)"), + label: tr.editingMathjaxChemistry(), + endLabel: "Ctrl+M, C", + }), + ]; + + const latexMenuItems = [ + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("[latex]", "[/latex]"), + label: tr.editingLatex(), + endLabel: "Ctrl+T, T", + }), + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("[$]", "[/$]"), + label: tr.editingLatexEquation(), + endLabel: "Ctrl+T, E", + }), + dropdownItem({ + // @ts-expect-error + onClick: () => wrap("[$$]", "[/$$]"), + label: tr.editingLatexMathEnv(), + endLabel: "Ctrl+T, M", + }), + ]; + const mathjaxMenu = dropdownMenu({ id: mathjaxMenuId, - menuItems: [ - dropdownItem({ - // @ts-expect-error - onClick: () => wrap("\\(", "\\)"), - endLabel: "Ctrl+M, M", - label: tr.editingMathjaxInline(), - }), - dropdownItem({ - // @ts-expect-error - onClick: () => wrap("\\[", "\\]"), - endLabel: "Ctrl+M, E", - label: tr.editingMathjaxBlock(), - }), - dropdownItem({ - // @ts-expect-error - onClick: () => wrap("\\(\\ce{", "}\\)"), - endLabel: "Ctrl+M, C", - label: tr.editingMathjaxChemistry(), - }), - ], + menuItems: [...mathjaxMenuItems, ...latexMenuItems], }); return [mathjaxMenu];