diff --git a/apps/client/src/services/shortcuts.spec.ts b/apps/client/src/services/shortcuts.spec.ts index 405c71359..87f8ae489 100644 --- a/apps/client/src/services/shortcuts.spec.ts +++ b/apps/client/src/services/shortcuts.spec.ts @@ -148,13 +148,21 @@ describe("shortcuts", () => { expect(matchesShortcut(event, "a")).toBe(false); }); - it("should match function keys even with no modifiers", () => { + it("should match some keys even with no modifiers", () => { + // Bare function keys let event = createKeyboardEvent({ key: "F1", code: "F1" }); expect(matchesShortcut(event, "F1")).toBeTruthy(); expect(matchesShortcut(event, "f1")).toBeTruthy(); + // Function keys with shift event = createKeyboardEvent({ key: "F1", code: "F1", shiftKey: true }); expect(matchesShortcut(event, "Shift+F1")).toBeTruthy(); + + // Special keys + for (const keyCode of [ "Delete", "Enter" ]) { + event = createKeyboardEvent({ key: keyCode, code: keyCode }); + expect(matchesShortcut(event, keyCode), `Key ${keyCode}`).toBeTruthy(); + } }); it("should handle alternative modifier names", () => { diff --git a/apps/client/src/services/shortcuts.ts b/apps/client/src/services/shortcuts.ts index 92bb02d66..94dd8893c 100644 --- a/apps/client/src/services/shortcuts.ts +++ b/apps/client/src/services/shortcuts.ts @@ -36,10 +36,19 @@ const keyMap: { [key: string]: string[] } = { }; // Function keys +const functionKeyCodes: string[] = []; for (let i = 1; i <= 19; i++) { - keyMap[`f${i}`] = [`F${i}`]; + const keyCode = `F${i}`; + functionKeyCodes.push(keyCode); + keyMap[`f${i}`] = [ keyCode ]; } +const KEYCODES_WITH_NO_MODIFIER = new Set([ + "Delete", + "Enter", + ...functionKeyCodes +]); + /** * Check if IME (Input Method Editor) is composing * This is used to prevent keyboard shortcuts from firing during IME composition @@ -163,8 +172,8 @@ export function matchesShortcut(e: KeyboardEvent, shortcut: string): boolean { const expectedMeta = modifiers.includes('meta') || modifiers.includes('cmd') || modifiers.includes('command'); // Refuse key combinations that don't include modifiers because they interfere with the normal usage of the application. - // Function keys are an exception. - if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta) && !/f\d+/.test(key)) { + // Some keys such as function keys are an exception. + if (!(expectedCtrl || expectedAlt || expectedShift || expectedMeta) && !KEYCODES_WITH_NO_MODIFIER.has(e.code)) { return false; } diff --git a/apps/client/src/stylesheets/print.css b/apps/client/src/stylesheets/print.css index f537911e5..114a52559 100644 --- a/apps/client/src/stylesheets/print.css +++ b/apps/client/src/stylesheets/print.css @@ -31,7 +31,7 @@ #center-pane > *:not(.split-note-container-widget), #right-pane, .title-row .note-icon-widget, -.title-row .button-widget, +.title-row .icon-action, .ribbon-container, .promoted-attributes-widget, .scroll-padding-widget, diff --git a/apps/client/src/widgets/ribbon/Ribbon.tsx b/apps/client/src/widgets/ribbon/Ribbon.tsx index ff908f00f..e47a78aee 100644 --- a/apps/client/src/widgets/ribbon/Ribbon.tsx +++ b/apps/client/src/widgets/ribbon/Ribbon.tsx @@ -51,6 +51,7 @@ const TAB_CONFIGURATION = numberObjectsInPlace([ show: ({ note }) => note?.type === "text" && options.get("textNoteEditorType") === "ckeditor-classic", toggleCommand: "toggleRibbonTabClassicEditor", content: FormattingToolbar, + activate: true, stayInDom: true }, { diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx index e3ba25440..233186ffe 100644 --- a/apps/client/src/widgets/type_widgets/options/appearance.tsx +++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx @@ -90,6 +90,7 @@ export default function AppearanceSettings() { {isElectron() && } + ) } + +function RibbonOptions() { + const [ editedNotesOpenInRibbon, setEditedNotesOpenInRibbon ] = useTriliumOptionBool("editedNotesOpenInRibbon"); + + return ( + + + + ) +} diff --git a/apps/client/src/widgets/type_widgets/read_only_code.ts b/apps/client/src/widgets/type_widgets/read_only_code.ts index cdae4565e..78d84950a 100644 --- a/apps/client/src/widgets/type_widgets/read_only_code.ts +++ b/apps/client/src/widgets/type_widgets/read_only_code.ts @@ -45,14 +45,4 @@ export default class ReadOnlyCodeTypeWidget extends AbstractCodeTypeWidget { readOnly: true }; } - - async executeWithContentElementEvent({ resolve, ntxId }: EventData<"executeWithContentElement">) { - if (!this.isNoteContext(ntxId)) { - return; - } - - await this.initialized; - - resolve(this.$editor); - } }