Add Latex formatting options to menu
* Format shortcuts in monospace font and increase padding a little bit
This commit is contained in:
parent
12c0a26dc9
commit
82f6e19955
@ -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)
|
||||
|
@ -45,6 +45,10 @@
|
||||
font-size: calc(var(--toolbar-size) / 2.3);
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.monospace {
|
||||
font-family: monospace;
|
||||
}
|
||||
</style>
|
||||
|
||||
<button
|
||||
@ -54,6 +58,6 @@
|
||||
title={tooltip}
|
||||
on:click={onClick}
|
||||
on:mousedown|preventDefault>
|
||||
<span class:me-2={endLabel}>{label}</span>
|
||||
{#if endLabel}<span>{endLabel}</span>{/if}
|
||||
<span class:me-3={endLabel}>{label}</span>
|
||||
{#if endLabel}<span class="monospace">{endLabel}</span>{/if}
|
||||
</button>
|
||||
|
@ -91,28 +91,51 @@ export function getTemplateGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
||||
|
||||
export function getTemplateMenus(): (DynamicSvelteComponent<typeof DropdownMenu> &
|
||||
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];
|
||||
|
Loading…
Reference in New Issue
Block a user