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:
|
def add_preview_shortcut(cuts, editor: Editor) -> None:
|
||||||
cuts.append(("Ctrl+Shift+P", self.onTogglePreview, True))
|
cuts.append(("Ctrl+Shift+P", self.onTogglePreview, True))
|
||||||
|
|
||||||
|
|
||||||
gui_hooks.editor_did_init.append(add_preview_button)
|
gui_hooks.editor_did_init.append(add_preview_button)
|
||||||
gui_hooks.editor_did_init_shortcuts.append(add_preview_shortcut)
|
gui_hooks.editor_did_init_shortcuts.append(add_preview_shortcut)
|
||||||
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
|
self.editor = aqt.editor.Editor(self.mw, self.form.fieldsArea, self)
|
||||||
|
@ -45,6 +45,10 @@
|
|||||||
font-size: calc(var(--toolbar-size) / 2.3);
|
font-size: calc(var(--toolbar-size) / 2.3);
|
||||||
color: inherit;
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.monospace {
|
||||||
|
font-family: monospace;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
@ -54,6 +58,6 @@
|
|||||||
title={tooltip}
|
title={tooltip}
|
||||||
on:click={onClick}
|
on:click={onClick}
|
||||||
on:mousedown|preventDefault>
|
on:mousedown|preventDefault>
|
||||||
<span class:me-2={endLabel}>{label}</span>
|
<span class:me-3={endLabel}>{label}</span>
|
||||||
{#if endLabel}<span>{endLabel}</span>{/if}
|
{#if endLabel}<span class="monospace">{endLabel}</span>{/if}
|
||||||
</button>
|
</button>
|
||||||
|
@ -91,28 +91,51 @@ export function getTemplateGroup(): DynamicSvelteComponent<typeof ButtonGroup> &
|
|||||||
|
|
||||||
export function getTemplateMenus(): (DynamicSvelteComponent<typeof DropdownMenu> &
|
export function getTemplateMenus(): (DynamicSvelteComponent<typeof DropdownMenu> &
|
||||||
DropdownMenuProps)[] {
|
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({
|
const mathjaxMenu = dropdownMenu({
|
||||||
id: mathjaxMenuId,
|
id: mathjaxMenuId,
|
||||||
menuItems: [
|
menuItems: [...mathjaxMenuItems, ...latexMenuItems],
|
||||||
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(),
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return [mathjaxMenu];
|
return [mathjaxMenu];
|
||||||
|
Loading…
Reference in New Issue
Block a user