chore(react/ribbon): add blur & keydown events

This commit is contained in:
Elian Doran
2025-08-23 19:54:02 +03:00
parent 3f3c7cfe88
commit efd713dc61
3 changed files with 6 additions and 41 deletions

View File

@@ -11,9 +11,11 @@ interface CKEditorOpts {
disableSpellcheck?: boolean;
onChange?: (newValue?: string) => void;
onClick?: (e: MouseEvent, pos?: ModelPosition | null) => void;
onKeyDown?: (e: KeyboardEvent) => void;
onBlur?: () => void;
}
export default function CKEditor({ currentValue, className, tabIndex, editor, config, disableNewlines, disableSpellcheck, onChange, onClick }: CKEditorOpts) {
export default function CKEditor({ currentValue, editor, config, disableNewlines, disableSpellcheck, onChange, onClick, ...restProps }: CKEditorOpts) {
const editorContainerRef = useRef<HTMLDivElement>(null);
const textEditorRef = useRef<CKTextEditor>(null);
@@ -62,14 +64,13 @@ export default function CKEditor({ currentValue, className, tabIndex, editor, co
return (
<div
ref={editorContainerRef}
className={className}
tabIndex={tabIndex}
onClick={(e) => {
if (onClick) {
const pos = textEditorRef.current?.model.document.selection.getFirstPosition();
onClick(e, pos);
}
}}
{...restProps}
/>
)
}