@nish1896/rhf-mui-components
Version:
A suite of 20+ reusable Material UI components for React Hook Form to minimize your time and effort in creating and styling forms
41 lines (40 loc) • 2.01 kB
TypeScript
import type { ReactNode } from 'react';
import { type FieldValues, type Path, type Control, type RegisterOptions } from 'react-hook-form';
import type { EventInfo } from '@ckeditor/ckeditor5-utils';
import type { EditorConfig } from '@ckeditor/ckeditor5-core';
import { ClassicEditor } from 'ckeditor5';
import type { FormLabelProps, FormHelperTextProps } from '../../types';
import { DefaultEditorConfig } from './config';
import 'ckeditor5/ckeditor5.css';
/**
* CK Editor Props ref -
* https://ckeditor.com/docs/ckeditor5/latest/getting-started/legacy/legacy-integrations/react.html#context-feature-properties
*/
type ErrorDetails = {
phase: 'initialization' | 'runtime';
willContextRestart?: boolean;
};
export type RHFRichTextEditorProps<T extends FieldValues> = {
fieldName: Path<T>;
control: Control<T>;
registerOptions?: RegisterOptions<T, Path<T>>;
required?: boolean;
id?: string;
editorConfig?: EditorConfig;
onReady?: (editor: ClassicEditor) => void;
onFocus?: (event: EventInfo<string, unknown>, editor: ClassicEditor) => void;
onBlur?: (event: EventInfo<string, unknown>, editor: ClassicEditor) => void;
onValueChange?: (newValue: string, event: EventInfo, editor: ClassicEditor) => void;
disabled?: boolean;
label?: ReactNode;
showLabelAboveFormField?: boolean;
formLabelProps?: FormLabelProps;
helperText?: ReactNode;
onError?: (error: Error, details: ErrorDetails) => void;
errorMessage?: ReactNode;
hideErrorMessage?: boolean;
formHelperTextProps?: FormHelperTextProps;
};
declare const RHFRichTextEditor: <T extends FieldValues>({ fieldName, control, registerOptions, required, id, editorConfig, onReady, onFocus, onBlur, onValueChange, disabled, label, showLabelAboveFormField, formLabelProps, helperText, onError, errorMessage, hideErrorMessage, formHelperTextProps, }: RHFRichTextEditorProps<T>) => import("react/jsx-runtime").JSX.Element;
export { DefaultEditorConfig };
export default RHFRichTextEditor;