Skip to content

Commit

Permalink
Improved prop types
Browse files Browse the repository at this point in the history
  • Loading branch information
dminkovsky committed Aug 30, 2020
1 parent 76877f8 commit c48da2a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "use-prosemirror",
"version": "1.1.4",
"version": "1.1.5",
"description": "ProseMirror for React",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
17 changes: 11 additions & 6 deletions src/ProseMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,27 @@ import React, {
forwardRef,
CSSProperties,
} from 'react';
import {EditorView, DirectEditorProps} from 'prosemirror-view';
import {
EditorView,
EditorProps,
DirectEditorProps,
} from 'prosemirror-view';
import {EditorState} from 'prosemirror-state';
import {Schema} from 'prosemirror-model';

export interface Handle {
view: EditorView;
}

interface Props<S extends Schema = any>
extends Partial<DirectEditorProps<S>> {
interface Props<S extends Schema = any> extends EditorProps<S> {
state: EditorState<S>;
onChange: (state: EditorState) => void;
style?: CSSProperties;
className?: string;
}

export default forwardRef<Handle, Props>(function ProseMirror(
// eslint-disable-next-line @typescript-eslint/no-unused-vars
{dispatchTransaction, onChange, style, className, ...props},
{onChange, style, className, ...props},
ref,
): JSX.Element {
const root = useRef<HTMLDivElement>(null!);
Expand All @@ -48,7 +50,10 @@ export default forwardRef<Handle, Props>(function ProseMirror(
},
}));
return <div ref={root} style={style} className={className} />;
function buildProps(props: DirectEditorProps): DirectEditorProps {

function buildProps(
props: Omit<DirectEditorProps, 'dispatchTransaction'>,
): DirectEditorProps {
return {
...props,
dispatchTransaction: transaction => {
Expand Down

0 comments on commit c48da2a

Please sign in to comment.