Skip to content

Commit

Permalink
Declare the EditorViewContext value to provide the EditorView API
Browse files Browse the repository at this point in the history
  • Loading branch information
tilgovi committed Jul 28, 2023
1 parent 118b5a5 commit a0c5169
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/components/EditorView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -303,7 +304,8 @@ export function EditorView({
decorations
);

const contextValue = useMemo(
const contextValue = useMemo<EditorViewT>(
// @ts-expect-error - EditorView API not fully implemented yet
() => ({
state,
dispatchTransaction,
Expand Down
12 changes: 2 additions & 10 deletions src/contexts/EditorViewContext.tsx
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit a0c5169

Please sign in to comment.