Skip to content

Commit 4186a33

Browse files
authored
Merge pull request #8809 from kavval/fix-tiptap-editorProps
[RFR] Allow `editorProps` attribute in RichTextInput `editorOptions` props
2 parents ccbaf7f + 15328dc commit 4186a33

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

packages/ra-input-rich-text/src/RichTextInput.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { RichTextInputToolbar } from './RichTextInputToolbar';
2525
/**
2626
* A rich text editor for the react-admin that is accessible and supports translations. Based on [Tiptap](https://www.tiptap.dev/).
2727
* @param props The input props. Accept all common react-admin input props.
28-
* @param {EditorOptions} props.editorOptions The options to pass to the Tiptap editor.
28+
* @param {EditorOptions} props.editorOptions The options to pass to the Tiptap editor. See Tiptap settings [here](https://tiptap.dev/api/editor#settings).
2929
* @param {ReactNode} props.toolbar The toolbar containing the editors commands.
3030
*
3131
* @example <caption>Customizing the editors options</caption>
@@ -100,7 +100,9 @@ export const RichTextInput = (props: RichTextInputProps) => {
100100
editable: !disabled && !readOnly,
101101
content: field.value,
102102
editorProps: {
103+
...editorOptions?.editorProps,
103104
attributes: {
105+
...editorOptions?.editorProps?.attributes,
104106
id,
105107
},
106108
},
@@ -126,12 +128,21 @@ export const RichTextInput = (props: RichTextInputProps) => {
126128
editor.setOptions({
127129
editable: !disabled && !readOnly,
128130
editorProps: {
131+
...editorOptions?.editorProps,
129132
attributes: {
133+
...editorOptions?.editorProps?.attributes,
130134
id,
131135
},
132136
},
133137
});
134-
}, [disabled, editor, readOnly, id]);
138+
}, [
139+
disabled,
140+
editor,
141+
readOnly,
142+
id,
143+
editorOptions?.editorProps,
144+
editorOptions?.editorProps?.attributes,
145+
]);
135146

136147
useEffect(() => {
137148
if (!editor) {
@@ -223,7 +234,7 @@ const RichTextInputContent = ({
223234
</Root>
224235
);
225236

226-
export const DefaultEditorOptions = {
237+
export const DefaultEditorOptions: Partial<EditorOptions> = {
227238
extensions: [
228239
StarterKit,
229240
Underline,

0 commit comments

Comments
 (0)