Skip to content

Commit

Permalink
chore: migrate to new versions of prosemirror packages (ueberdosis#2854)
Browse files Browse the repository at this point in the history
* refactor: upgrade prosemirror packages to new typescript versions

* refactor: migrate to new typings from prosemirror

* style: fix linting issues

* style: fix linting issues

* style: fix linting issues

* fix(ci): fix build process by reimplement filterTransaction

* fix(extension-test): fix broken build because of wrong output file names

* fix: fix prosemirror-tables not being bundled correctly for ES6

* fix: move to prosemirror-tables-contently until es6 build is working

* fix: fix tests for youtube

* fix: fix youtube test

* fix(demos): fix demos build
  • Loading branch information
bdbch authored Jun 20, 2022
1 parent 6dbec6f commit 7d43fb2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"dependencies": {
"@tiptap/extension-bubble-menu": "^2.0.0-beta.59",
"@tiptap/extension-floating-menu": "^2.0.0-beta.54",
"prosemirror-view": "^1.23.6"
"prosemirror-view": "^1.25.0"
},
"repository": {
"type": "git",
Expand Down
42 changes: 23 additions & 19 deletions src/ReactNodeViewRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ import { ReactRenderer } from './ReactRenderer'
import { ReactNodeViewContext, ReactNodeViewContextProps } from './useReactNodeView'

export interface ReactNodeViewRendererOptions extends NodeViewRendererOptions {
update: ((props: {
oldNode: ProseMirrorNode,
oldDecorations: Decoration[],
newNode: ProseMirrorNode,
newDecorations: Decoration[],
updateProps: () => void,
}) => boolean) | null,
as?: string,
className?: string,
update:
| ((props: {
oldNode: ProseMirrorNode;
oldDecorations: Decoration[];
newNode: ProseMirrorNode;
newDecorations: Decoration[];
updateProps: () => void;
}) => boolean)
| null;
as?: string;
className?: string;
}

class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeViewRendererOptions> {

class ReactNodeView extends NodeView<
React.FunctionComponent,
Editor,
ReactNodeViewRendererOptions
> {
renderer!: ReactRenderer

contentDOMElement!: HTMLElement | null
Expand Down Expand Up @@ -55,11 +60,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
const Component = this.component
const onDragStart = this.onDragStart.bind(this)
const nodeViewContentRef: ReactNodeViewContextProps['nodeViewContentRef'] = element => {
if (
element
&& this.contentDOMElement
&& element.firstChild !== this.contentDOMElement
) {
if (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {
element.appendChild(this.contentDOMElement)
}
}
Expand Down Expand Up @@ -108,7 +109,7 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
throw Error('Please use the NodeViewWrapper component for your node view.')
}

return this.renderer.element
return this.renderer.element as HTMLElement
}

get contentDOM() {
Expand Down Expand Up @@ -174,7 +175,10 @@ class ReactNodeView extends NodeView<React.FunctionComponent, Editor, ReactNodeV
}
}

export function ReactNodeViewRenderer(component: any, options?: Partial<ReactNodeViewRendererOptions>): NodeViewRenderer {
export function ReactNodeViewRenderer(
component: any,
options?: Partial<ReactNodeViewRendererOptions>,
): NodeViewRenderer {
return (props: NodeViewRendererProps) => {
// try to get the parent component
// this is important for vue devtools to show the component hierarchy correctly
Expand All @@ -183,6 +187,6 @@ export function ReactNodeViewRenderer(component: any, options?: Partial<ReactNod
return {}
}

return new ReactNodeView(component, props, options) as ProseMirrorNodeView
return new ReactNodeView(component, props, options) as unknown as ProseMirrorNodeView
}
}

0 comments on commit 7d43fb2

Please sign in to comment.