From a4e38e744b3863d94c537ed49785540ce888f2e3 Mon Sep 17 00:00:00 2001 From: Nick the Sick Date: Thu, 8 Aug 2024 08:17:19 +0200 Subject: [PATCH] fix(react): update the types to reflect true options #5459 --- .changeset/dry-cycles-sleep.md | 5 +++++ packages/react/src/Context.tsx | 5 +++-- packages/react/src/useEditor.ts | 3 +-- packages/react/src/useEditorState.ts | 3 +-- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/dry-cycles-sleep.md diff --git a/.changeset/dry-cycles-sleep.md b/.changeset/dry-cycles-sleep.md new file mode 100644 index 00000000000..ce8b36b4c20 --- /dev/null +++ b/.changeset/dry-cycles-sleep.md @@ -0,0 +1,5 @@ +--- +"@tiptap/react": patch +--- + +Updates the typings to `useEditor` and `EditorProvider` to not conflict with the core Editor type diff --git a/packages/react/src/Context.tsx b/packages/react/src/Context.tsx index d5b24f5624c..a26fee805d8 100644 --- a/packages/react/src/Context.tsx +++ b/packages/react/src/Context.tsx @@ -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} {({ editor: currentEditor }) => ( - + )} {children} diff --git a/packages/react/src/useEditor.ts b/packages/react/src/useEditor.ts index 2fde5b2ce06..31e0faac68a 100644 --- a/packages/react/src/useEditor.ts +++ b/packages/react/src/useEditor.ts @@ -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' diff --git a/packages/react/src/useEditorState.ts b/packages/react/src/useEditorState.ts index 079605a808a..40b5ce4fae3 100644 --- a/packages/react/src/useEditorState.ts +++ b/packages/react/src/useEditorState.ts @@ -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 = { editor: TEditor; transactionNumber: number;