Skip to content

Commit 0f28d9c

Browse files
authored
fix(react): simplify Tiptap component API and separate menu imports (#7494)
* fix(react): simplify Tiptap component API and separate menu imports - Remove isReady from TiptapContextType, editor is now always available - Move BubbleMenu and FloatingMenu to @tiptap/react/menus entrypoint - Add backwards-compatible instance prop (deprecated in favor of editor) - Add helpful error when useTiptap is used outside provider * Validate editor prop and update demo imports Throw an error in TiptapWrapper when neither editor nor instance is provided. Remove the forced cast and expand the deprecation comment to note upcoming removal. Update demo example imports to use .js/.jsx file extensions. * Remove editor prop from BubbleMenu example
1 parent 2d6de06 commit 0f28d9c

5 files changed

Lines changed: 72 additions & 197 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/react': minor
3+
---
4+
5+
Moved BubbleMenu and FloatingMenu to separate `@tiptap/react/menus` entrypoint to keep floating-ui optional
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tiptap/react': minor
3+
---
4+
5+
Simplified Tiptap component API with guaranteed non-null editor instance from useTiptap hook

demos/src/Examples/Default/React/MenuBar.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import { useTiptap, useTiptapState } from '@tiptap/react'
22
import React from 'react'
33

4-
import { menuBarStateSelector } from './menuBarState.ts'
4+
import { menuBarStateSelector } from './menuBarState.js'
55

66
/**
77
* Menu bar component that uses useTiptap and useTiptapState hooks
88
* to access the editor from context.
99
*/
1010
export function MenuBar() {
11-
const { editor, isReady } = useTiptap()
11+
const { editor } = useTiptap()
1212
const editorState = useTiptapState(menuBarStateSelector)
1313

14-
if (!isReady || !editor) {
15-
return null
16-
}
17-
1814
return (
1915
<div className="control-group">
2016
<div className="button-group">

demos/src/Examples/Default/React/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Tiptap, useEditor } from '@tiptap/react'
55
import StarterKit from '@tiptap/starter-kit'
66
import React from 'react'
77

8-
import { MenuBar } from './MenuBar.tsx'
8+
import { MenuBar } from './MenuBar.jsx'
99

1010
const extensions = [TextStyleKit, StarterKit]
1111

@@ -45,7 +45,7 @@ export default () => {
4545
})
4646

4747
return (
48-
<Tiptap instance={editor}>
48+
<Tiptap editor={editor}>
4949
<MenuBar />
5050
<Tiptap.Content />
5151
</Tiptap>

0 commit comments

Comments
 (0)