Skip to content

Commit

Permalink
feat: add editorContainerProps to EditorProvider (#5661)
Browse files Browse the repository at this point in the history
  • Loading branch information
kart-c authored Sep 26, 2024
1 parent e8e4df3 commit 26056aa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-apples-reflect.md
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions packages/react/src/Context.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -23,6 +25,7 @@ export type EditorProviderProps = {
children?: ReactNode;
slotBefore?: ReactNode;
slotAfter?: ReactNode;
editorContainerProps?: HTMLAttributes<HTMLDivElement>;
} & UseEditorOptions

/**
Expand All @@ -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)

Expand All @@ -44,7 +47,7 @@ export function EditorProvider({
{slotBefore}
<EditorConsumer>
{({ editor: currentEditor }) => (
<EditorContent editor={currentEditor} />
<EditorContent editor={currentEditor} {...editorContainerProps} />
)}
</EditorConsumer>
{children}
Expand Down

0 comments on commit 26056aa

Please sign in to comment.