mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-14 04:52:28 +08:00
feat(touch_bar): reflect state for underline, italic
This commit is contained in:
parent
fff140d141
commit
e71a18f4e4
@ -252,7 +252,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Touch bar integration
|
// Touch bar integration
|
||||||
editor.commands.get("bold").on("change", () => this.triggerCommand("refreshTouchBar"));
|
for (const event of [ "bold", "italic", "underline" ]) {
|
||||||
|
editor.commands.get(event).on("change", () => this.triggerCommand("refreshTouchBar"));
|
||||||
|
}
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
});
|
});
|
||||||
@ -516,6 +518,12 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
const { TouchBarSegmentedControl, TouchBarGroup, TouchBarButton } = TouchBar;
|
const { TouchBarSegmentedControl, TouchBarGroup, TouchBarButton } = TouchBar;
|
||||||
const { editor } = this.watchdog;
|
const { editor } = this.watchdog;
|
||||||
|
|
||||||
|
const commandButton = (icon, command) => new TouchBarButton({
|
||||||
|
icon: buildIcon(icon),
|
||||||
|
click: () => editor.execute(command),
|
||||||
|
backgroundColor: buildSelectedBackgroundColor(editor.commands.get(command).value)
|
||||||
|
});
|
||||||
|
|
||||||
return [
|
return [
|
||||||
new TouchBarSegmentedControl({
|
new TouchBarSegmentedControl({
|
||||||
segments: [
|
segments: [
|
||||||
@ -540,19 +548,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
new TouchBarGroup({
|
new TouchBarGroup({
|
||||||
items: new TouchBar({
|
items: new TouchBar({
|
||||||
items: [
|
items: [
|
||||||
new TouchBarButton({
|
commandButton("NSTouchBarTextBoldTemplate", "bold"),
|
||||||
icon: buildIcon("NSTouchBarTextBoldTemplate"),
|
commandButton("NSTouchBarTextItalicTemplate", "italic"),
|
||||||
click: () => editor.execute("bold"),
|
commandButton("NSTouchBarTextUnderlineTemplate", "underline")
|
||||||
backgroundColor: buildSelectedBackgroundColor(editor.commands.get("bold").value)
|
|
||||||
}),
|
|
||||||
new TouchBarButton({
|
|
||||||
icon: buildIcon("NSTouchBarTextItalicTemplate"),
|
|
||||||
click: () => editor.execute("italic")
|
|
||||||
}),
|
|
||||||
new TouchBarButton({
|
|
||||||
icon: buildIcon("NSTouchBarTextUnderlineTemplate"),
|
|
||||||
click: () => editor.execute("underline")
|
|
||||||
})
|
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user