From 60859954b96dfdcd4c1d0d1a5b2bbdeeed8c98ca Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 8 Mar 2025 13:22:24 +0200 Subject: [PATCH] feat(touch_bar): paragraph and heading buttons --- src/public/app/widgets/touch_bar.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/public/app/widgets/touch_bar.ts b/src/public/app/widgets/touch_bar.ts index be73ab85b..2ef520426 100644 --- a/src/public/app/widgets/touch_bar.ts +++ b/src/public/app/widgets/touch_bar.ts @@ -38,14 +38,14 @@ export default class TouchBarWidget extends Component { return newImage; } - async #triggerTextEditorCommand(command: string) { + async #triggerTextEditorCommand(command: string, args?: object) { const editor = await appContext.tabManager.getActiveContext().getTextEditor(); if (!editor) { return; } // TODO: Fix type of editor. - (editor as any).execute(command); + (editor as any).execute(command, args); } #buildTouchBar() { @@ -61,6 +61,18 @@ export default class TouchBarWidget extends Component { new TouchBarGroup({ items: new TouchBar({ items: [ + new TouchBarButton({ + label: "P", + click: () => this.#triggerTextEditorCommand("paragraph") + }), + new TouchBarButton({ + label: "H2", + click: () => this.#triggerTextEditorCommand("heading", { value: "heading2" }) + }), + new TouchBarButton({ + label: "H3", + click: () => this.#triggerTextEditorCommand("heading", { value: "heading3" }) + }), new TouchBarButton({ icon: this.#buildIcon("NSTouchBarTextBoldTemplate"), click: () => this.#triggerTextEditorCommand("bold")