From a0c5169a1754104730e55e170fed63776f77de49 Mon Sep 17 00:00:00 2001 From: Randall Leeds Date: Fri, 28 Jul 2023 12:10:54 -0600 Subject: [PATCH] Declare the EditorViewContext value to provide the EditorView API --- src/components/EditorView.tsx | 4 +++- src/contexts/EditorViewContext.tsx | 12 ++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/components/EditorView.tsx b/src/components/EditorView.tsx index ca08bd7d..d1d6ecf2 100644 --- a/src/components/EditorView.tsx +++ b/src/components/EditorView.tsx @@ -6,6 +6,7 @@ import { Transaction, } from "prosemirror-state"; import { Decoration, DecorationSet, DirectEditorProps } from "prosemirror-view"; +import type { EditorView as EditorViewT } from "prosemirror-view"; import React, { ComponentType, DetailedHTMLProps, @@ -303,7 +304,8 @@ export function EditorView({ decorations ); - const contextValue = useMemo( + const contextValue = useMemo( + // @ts-expect-error - EditorView API not fully implemented yet () => ({ state, dispatchTransaction, diff --git a/src/contexts/EditorViewContext.tsx b/src/contexts/EditorViewContext.tsx index 46271f25..4286a059 100644 --- a/src/contexts/EditorViewContext.tsx +++ b/src/contexts/EditorViewContext.tsx @@ -1,12 +1,4 @@ -import { EditorState } from "prosemirror-state"; -import { EditorView as EditorViewPM } from "prosemirror-view"; +import type { EditorView as EditorViewT } from "prosemirror-view"; import { createContext } from "react"; -type EditorViewContextValue = { - state: EditorState; - dispatchTransaction: EditorViewPM["dispatch"]; -}; - -export const EditorViewContext = createContext( - null as unknown as EditorViewContextValue -); +export const EditorViewContext = createContext(null as unknown as EditorViewT);