mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-12 20:02:28 +08:00
feat(touch_bar): reflect state for bold
This commit is contained in:
parent
ff78ab650a
commit
fff140d141
@ -4,6 +4,10 @@ import appContext from "../components/app_context.js";
|
||||
import NoteContextAwareWidget from "./note_context_aware_widget.js";
|
||||
import type { TouchBarButton, TouchBarGroup, TouchBarSegmentedControl, TouchBarSpacer } from "@electron/remote";
|
||||
|
||||
export function buildSelectedBackgroundColor(isSelected: boolean) {
|
||||
return isSelected ? "#ff0000" : undefined;
|
||||
}
|
||||
|
||||
export default class TouchBarWidget extends NoteContextAwareWidget {
|
||||
|
||||
nativeImage: typeof import("electron").nativeImage;
|
||||
|
@ -16,6 +16,7 @@ import toast from "../../services/toast.js";
|
||||
import { getMermaidConfig } from "../mermaid.js";
|
||||
import { normalizeMimeTypeForCKEditor } from "../../services/mime_type_definitions.js";
|
||||
import { buildConfig, buildToolbarConfig } from "./ckeditor/toolbars.js";
|
||||
import { buildSelectedBackgroundColor } from "../touch_bar.js";
|
||||
|
||||
const ENABLE_INSPECTOR = false;
|
||||
|
||||
@ -250,6 +251,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
CKEditorInspector.attach(editor);
|
||||
}
|
||||
|
||||
// Touch bar integration
|
||||
editor.commands.get("bold").on("change", () => this.triggerCommand("refreshTouchBar"));
|
||||
|
||||
return editor;
|
||||
});
|
||||
|
||||
@ -538,7 +542,8 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
||||
items: [
|
||||
new TouchBarButton({
|
||||
icon: buildIcon("NSTouchBarTextBoldTemplate"),
|
||||
click: () => editor.execute("bold")
|
||||
click: () => editor.execute("bold"),
|
||||
backgroundColor: buildSelectedBackgroundColor(editor.commands.get("bold").value)
|
||||
}),
|
||||
new TouchBarButton({
|
||||
icon: buildIcon("NSTouchBarTextItalicTemplate"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user