Skip to content

Commit

Permalink
fix(react): update the types to reflect true options #5459
Browse files Browse the repository at this point in the history
  • Loading branch information
nperez0111 committed Aug 8, 2024
1 parent 7280e29 commit a4e38e7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/dry-cycles-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tiptap/react": patch
---

Updates the typings to `useEditor` and `EditorProvider` to not conflict with the core Editor type
5 changes: 3 additions & 2 deletions packages/react/src/Context.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Editor } from '@tiptap/core'
import React, { createContext, ReactNode, useContext } from 'react'

import { Editor } from './Editor.js'
import { Editor as ReactEditor } from './Editor.js'
import { EditorContent } from './EditorContent.js'
import { useEditor, UseEditorOptions } from './useEditor.js'

Expand Down Expand Up @@ -44,7 +45,7 @@ export function EditorProvider({
{slotBefore}
<EditorConsumer>
{({ editor: currentEditor }) => (
<EditorContent editor={currentEditor} />
<EditorContent editor={currentEditor as ReactEditor} />
)}
</EditorConsumer>
{children}
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/useEditor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EditorOptions } from '@tiptap/core'
import { type EditorOptions, Editor } from '@tiptap/core'
import {
DependencyList,
MutableRefObject,
Expand All @@ -9,7 +9,6 @@ import {
} from 'react'
import { useSyncExternalStore } from 'use-sync-external-store/shim'

import { Editor } from './Editor.js'
import { useEditorState } from './useEditorState.js'

const isDev = process.env.NODE_ENV !== 'production'
Expand Down
3 changes: 1 addition & 2 deletions packages/react/src/useEditorState.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { Editor } from '@tiptap/core'
import { useDebugValue, useEffect, useState } from 'react'
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'

import type { Editor } from './Editor.js'

export type EditorStateSnapshot<TEditor extends Editor | null = Editor | null> = {
editor: TEditor;
transactionNumber: number;
Expand Down

0 comments on commit a4e38e7

Please sign in to comment.