mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 03:39:01 +08:00
feat: add editorContainerProps
to EditorProvider
(#5661)
This commit is contained in:
parent
e8e4df38d5
commit
26056aa0c2
5
.changeset/bright-apples-reflect.md
Normal file
5
.changeset/bright-apples-reflect.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tiptap/react": patch
|
||||
---
|
||||
|
||||
Add editorContainerProps to EditorProvider. This allows for any HTML attributes to be added to the EditorContent when using EditorProvider
|
@ -1,5 +1,7 @@
|
||||
import { Editor } from '@tiptap/core'
|
||||
import React, { createContext, ReactNode, useContext } from 'react'
|
||||
import React, {
|
||||
createContext, HTMLAttributes, ReactNode, useContext,
|
||||
} from 'react'
|
||||
|
||||
import { EditorContent } from './EditorContent.js'
|
||||
import { useEditor, UseEditorOptions } from './useEditor.js'
|
||||
@ -23,6 +25,7 @@ export type EditorProviderProps = {
|
||||
children?: ReactNode;
|
||||
slotBefore?: ReactNode;
|
||||
slotAfter?: ReactNode;
|
||||
editorContainerProps?: HTMLAttributes<HTMLDivElement>;
|
||||
} & UseEditorOptions
|
||||
|
||||
/**
|
||||
@ -31,7 +34,7 @@ export type EditorProviderProps = {
|
||||
* with `useCurrentEditor`.
|
||||
*/
|
||||
export function EditorProvider({
|
||||
children, slotAfter, slotBefore, ...editorOptions
|
||||
children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions
|
||||
}: EditorProviderProps) {
|
||||
const editor = useEditor(editorOptions)
|
||||
|
||||
@ -44,7 +47,7 @@ export function EditorProvider({
|
||||
{slotBefore}
|
||||
<EditorConsumer>
|
||||
{({ editor: currentEditor }) => (
|
||||
<EditorContent editor={currentEditor} />
|
||||
<EditorContent editor={currentEditor} {...editorContainerProps} />
|
||||
)}
|
||||
</EditorConsumer>
|
||||
{children}
|
||||
|
Loading…
Reference in New Issue
Block a user