fix(react): update the types to reflect true options #5459 (#5460)

This commit is contained in:
Nick Perez 2024-08-08 08:27:10 +02:00 committed by GitHub
parent 7280e2931e
commit c7fd0f80af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 6 deletions

View File

@ -0,0 +1,5 @@
---
"@tiptap/react": patch
---
Updates the typings to `useEditor` and `EditorProvider` to not conflict with the core Editor type

View File

@ -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'
@ -44,7 +45,7 @@ export function EditorProvider({
{slotBefore}
<EditorConsumer>
{({ editor: currentEditor }) => (
<EditorContent editor={currentEditor} />
<EditorContent editor={currentEditor as ReactEditor} />
)}
</EditorConsumer>
{children}

View File

@ -1,4 +1,4 @@
import { EditorOptions } from '@tiptap/core'
import { type EditorOptions, Editor } from '@tiptap/core'
import {
DependencyList,
MutableRefObject,
@ -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'

View File

@ -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;