Skip to content

Commit

Permalink
Merge pull request #8809 from kavval/fix-tiptap-editorProps
Browse files Browse the repository at this point in the history
[RFR] Allow `editorProps` attribute in RichTextInput `editorOptions` props
  • Loading branch information
djhi authored Apr 11, 2023
2 parents ccbaf7f + 15328dc commit 4186a33
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions packages/ra-input-rich-text/src/RichTextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { RichTextInputToolbar } from './RichTextInputToolbar';
/**
* A rich text editor for the react-admin that is accessible and supports translations. Based on [Tiptap](https://www.tiptap.dev/).
* @param props The input props. Accept all common react-admin input props.
* @param {EditorOptions} props.editorOptions The options to pass to the Tiptap editor.
* @param {EditorOptions} props.editorOptions The options to pass to the Tiptap editor. See Tiptap settings [here](https://tiptap.dev/api/editor#settings).
* @param {ReactNode} props.toolbar The toolbar containing the editors commands.
*
* @example <caption>Customizing the editors options</caption>
Expand Down Expand Up @@ -100,7 +100,9 @@ export const RichTextInput = (props: RichTextInputProps) => {
editable: !disabled && !readOnly,
content: field.value,
editorProps: {
...editorOptions?.editorProps,
attributes: {
...editorOptions?.editorProps?.attributes,
id,
},
},
Expand All @@ -126,12 +128,21 @@ export const RichTextInput = (props: RichTextInputProps) => {
editor.setOptions({
editable: !disabled && !readOnly,
editorProps: {
...editorOptions?.editorProps,
attributes: {
...editorOptions?.editorProps?.attributes,
id,
},
},
});
}, [disabled, editor, readOnly, id]);
}, [
disabled,
editor,
readOnly,
id,
editorOptions?.editorProps,
editorOptions?.editorProps?.attributes,
]);

useEffect(() => {
if (!editor) {
Expand Down Expand Up @@ -223,7 +234,7 @@ const RichTextInputContent = ({
</Root>
);

export const DefaultEditorOptions = {
export const DefaultEditorOptions: Partial<EditorOptions> = {
extensions: [
StarterKit,
Underline,
Expand Down

0 comments on commit 4186a33

Please sign in to comment.