Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(ribbon): "Open attribute list" shortcut not focusing (closes #7463)
Elian Doran80c77eeb1871
diff --git a/apps/client/src/widgets/react/CKEditor.tsx b/apps/client/src/widgets/react/CKEditor.tsxindex 8b8839a382..84df2d0599 100644--- a/apps/client/src/widgets/react/CKEditor.tsx+++ b/apps/client/src/widgets/react/CKEditor.tsx@@ -6,9 +6,9 @@ export interface CKEditorApi {focus(): void;/*** Imperatively sets the text in the editor.- *+ ** Prefer setting `currentValue` prop where possible.- *+ ** @param text text to set in the editor*/setText(text: string): void;@@ -27,15 +27,16 @@ interface CKEditorOpts {onClick?: (e: MouseEvent, pos?: ModelPosition | null) => void;onKeyDown?: (e: KeyboardEvent) => void;onBlur?: () => void;+ onInitialized?: (editorInstance: CKTextEditor) => void;}-export default function CKEditor({ apiRef, currentValue, editor, config, disableNewlines, disableSpellcheck, onChange, onClick, ...restProps }: CKEditorOpts) {- const editorContainerRef = useRef<HTMLDivElement>(null);+export default function CKEditor({ apiRef, currentValue, editor, config, disableNewlines, disableSpellcheck, onChange, onClick, onInitialized, ...restProps }: CKEditorOpts) {+ const editorContainerRef = useRef<HTMLDivElement>(null);const textEditorRef = useRef<CKTextEditor>(null);useImperativeHandle(apiRef, () => {return {focus() {- editorContainerRef.current?.focus();+ textEditorRef.current?.editing.view.focus();textEditorRef.current?.model.change((writer) => {const documentRoot = textEditorRef.current?.editing.model.document.getRoot();if (documentRoot) {@@ -83,6 +84,8 @@ export default function CKEditor({ apiRef, currentValue, editor, config, disableif (currentValue) {textEditor.setData(currentValue);}++ onInitialized?.(textEditor);});}, []);@@ -103,4 +106,4 @@ export default function CKEditor({ apiRef, currentValue, editor, config, disable{...restProps}/>)-}\ No newline at end of file+}diff --git a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsxindex 1bdb6c1c0f..ae3d90c072 100644--- a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx+++ b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx@@ -26,4 +26,4 @@ export default function OwnedAttributesTab({ note, hidden, activate, ntxId, ...r)}</div>)-}\ No newline at end of file+}diff --git a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsxindex 380241df8a..bf0aa9428e 100644--- a/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx+++ b/apps/client/src/widgets/ribbon/components/AttributeEditor.tsx@@ -238,11 +238,6 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI}});- // Focus on show.- useEffect(() => {- setTimeout(() => editorRef.current?.focus(), 0);- }, []);-// Interaction with CKEditor.useLegacyImperativeHandlers(useMemo(() => ({loadReferenceLinkTitle: async ($el: JQuery<HTMLElement>, href: string) => {@@ -363,6 +358,7 @@ export default function AttributeEditor({ api, note, componentId, notePath, ntxI}}onKeyDown={() => attributeDetailWidget.hide()}onBlur={() => save()}+ onInitialized={() => editorRef.current?.focus()}disableNewlines disableSpellcheck/>