mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-17 16:31:44 +08:00
feat(touch_bar): paragraph and heading buttons
This commit is contained in:
parent
2676596384
commit
60859954b9
@ -38,14 +38,14 @@ export default class TouchBarWidget extends Component {
|
|||||||
return newImage;
|
return newImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
async #triggerTextEditorCommand(command: string) {
|
async #triggerTextEditorCommand(command: string, args?: object) {
|
||||||
const editor = await appContext.tabManager.getActiveContext().getTextEditor();
|
const editor = await appContext.tabManager.getActiveContext().getTextEditor();
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix type of editor.
|
// TODO: Fix type of editor.
|
||||||
(editor as any).execute(command);
|
(editor as any).execute(command, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
#buildTouchBar() {
|
#buildTouchBar() {
|
||||||
@ -61,6 +61,18 @@ export default class TouchBarWidget extends Component {
|
|||||||
new TouchBarGroup({
|
new TouchBarGroup({
|
||||||
items: new TouchBar({
|
items: new TouchBar({
|
||||||
items: [
|
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({
|
new TouchBarButton({
|
||||||
icon: this.#buildIcon("NSTouchBarTextBoldTemplate"),
|
icon: this.#buildIcon("NSTouchBarTextBoldTemplate"),
|
||||||
click: () => this.#triggerTextEditorCommand("bold")
|
click: () => this.#triggerTextEditorCommand("bold")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user