diff --git a/apps/client/src/services/keyboard_actions.ts b/apps/client/src/services/keyboard_actions.ts index 9fce5ad35..1ada409ec 100644 --- a/apps/client/src/services/keyboard_actions.ts +++ b/apps/client/src/services/keyboard_actions.ts @@ -29,6 +29,8 @@ async function getActionsForScope(scope: string) { } async function setupActionsForElement(scope: string, $el: JQuery, component: Component) { + if (!$el[0]) return; + const actions = await getActionsForScope(scope); const bindings: ShortcutBinding[] = []; diff --git a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx index eaf85a08f..b7346dd9a 100644 --- a/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx +++ b/apps/client/src/widgets/type_widgets/text/CKEditorWithWatchdog.tsx @@ -1,7 +1,7 @@ import { HTMLProps, RefObject, useEffect, useImperativeHandle, useRef, useState } from "preact/compat"; import { PopupEditor, ClassicEditor, EditorWatchdog, type WatchdogConfig, CKTextEditor, TemplateDefinition } from "@triliumnext/ckeditor5"; import { buildConfig, BuildEditorOptions } from "./config"; -import { useLegacyImperativeHandlers, useSyncedRef } from "../../react/hooks"; +import { useKeyboardShortcuts, useLegacyImperativeHandlers, useNoteContext, useSyncedRef } from "../../react/hooks"; import link from "../../../services/link"; import froca from "../../../services/froca"; @@ -38,6 +38,9 @@ export default function CKEditorWithWatchdog({ containerRef: externalContainerRe const containerRef = useSyncedRef(externalContainerRef, null); const watchdogRef = useRef(null); const [ editor, setEditor ] = useState(); + const { parentComponent } = useNoteContext(); + + useKeyboardShortcuts("text-detail", containerRef, parentComponent); useImperativeHandle(editorApi, () => ({ hasSelection() { diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsx index f39ea3992..aa6e0b589 100644 --- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx +++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx @@ -196,7 +196,6 @@ export default function EditableText({ note, parentComponent, ntxId, noteContext }); } - useKeyboardShortcuts("text-detail", containerRef, parentComponent); useTriliumEvent("insertDateTimeToText", ({ ntxId: eventNtxId }) => { if (eventNtxId !== ntxId) return; const date = new Date();