chore: migrate to new versions of prosemirror packages (#2854)

* 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
This commit is contained in:
Dominik
2022-06-20 11:45:37 +02:00
committed by GitHub
parent 2fa2c22e6f
commit 1ebc8f8e14
56 changed files with 2440 additions and 6727 deletions

View File

@@ -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
@@ -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)
}
}
@@ -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() {
@@ -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
@@ -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
}
}