Replies: 4 comments 5 replies
-
Create a wrapper component that will render
Follow tiptap useEditor hook documentation |
Beta Was this translation helpful? Give feedback.
-
I managed to do it by implementing the context of use-form and with onUpdate method, I share with you the mantine tutorial on how to implement it, it is very well explained: https://mantine.dev/form/create-form-context/ After you have implemented it, you place the "onUpdate" method where you assign the value through the "setFieldValue", something like this:
|
Beta Was this translation helpful? Give feedback.
-
/* eslint-disable @typescript-eslint/no-unused-vars */
import { RichTextEditor, Link as RTELink } from "@mantine/tiptap";
import { useEditor } from "@tiptap/react";
import { StarterKit } from "@tiptap/starter-kit";
interface CustomInputProps {
value?: string;
defaultValue?: string;
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
error?: string;
}
export const EditorInput = ({
value,
defaultValue,
onChange,
onFocus,
onBlur,
error,
}: CustomInputProps) => {
const editor = useEditor({
extensions: [StarterKit, RTELink],
content: defaultValue,
onUpdate({ editor }) {
const content = editor.getHTML();
onChange && onChange(content as never);
},
});
return (
<RichTextEditor editor={editor}>
<RichTextEditor.Toolbar sticky stickyOffset={60}>
<RichTextEditor.ControlsGroup>
<RichTextEditor.Bold />
<RichTextEditor.Italic />
<RichTextEditor.Underline />
<RichTextEditor.Strikethrough />
</RichTextEditor.ControlsGroup>
<RichTextEditor.ControlsGroup>
<RichTextEditor.BulletList />
<RichTextEditor.OrderedList />
</RichTextEditor.ControlsGroup>
<RichTextEditor.ControlsGroup>
<RichTextEditor.Link />
</RichTextEditor.ControlsGroup>
</RichTextEditor.Toolbar>
<RichTextEditor.Content />
</RichTextEditor>
);
}; Somewhere:
|
Beta Was this translation helpful? Give feedback.
-
Does this solution work? |
Beta Was this translation helpful? Give feedback.
-
How can i use the
@mantine/form
with the Rich Text Editor(TipTap). I wan to apply the features the form provides likeinvalid input
And how can i make tiptap controlled.
Currently, i'm getting the value like this:
What is the built way of getting the value?
Beta Was this translation helpful? Give feedback.
All reactions