Saul-Mirone / prosemirror-adapter

Universal adapter to create prosemirror nodeview from modern UI frameworks.
MIT License
97 stars 7 forks source link

Version incompatibility in @prosemirror-adapter/svelte vs SvelteKit #28

Open radio-miskovice opened 1 year ago

radio-miskovice commented 1 year ago

When using the code in examples/svelte I get error in this code (Editor.svelte, lines 32, 27, etc.):

 // line 29:
  function editor(element: HTMLElement) {
    editorView = createEditorView(element, {
      paragraph: nodeViewFactory({
        component: Paragraph,
        as: 'div',
        contentAs: 'p'
      }),
      heading: nodeViewFactory({
        component: Heading
      })
    }, [
      new Plugin({
        view: pluginViewFactory({
          component: Size
        })
      }),
...

The error reads:

Type 'typeof Paragraph_SvelteComponent' is not assignable to type 'SvelteNodeViewComponent'. Types of parameters 'options' and 'options' are incompatible. Type 'ComponentConstructorOptions' is not assignable to type 'ComponentConstructorOptions<Record<string, never>>'. Type 'EmptyProps' is not assignable to type 'Record<string, never>'. Index signature for type 'string' is missing in type 'EmptyProps'.ts(2322)

Not sure how exactly approach a fix... My guess is that changing type in the adapter code should suffice, but did not have the courage to look inside, yet.

"@sveltejs/kit": "^1.5.0", "@sveltejs/adapter-auto": "^2.0.0", "svelte": "^3.54.0", "svelte-check": "^3.0.1", "@prosemirror-adapter/svelte": "^0.2.4",

Saul-Mirone commented 1 year ago

Does it help if you update svelte to 3.57.0?

radio-miskovice commented 1 year ago

Unfortunately it doesn't.

export const createEditorView = (element: HTMLElement, nodeViews: Record<string, NodeViewConstructor>, plugins: Plugin[]) => {
...

It seems that nodeViews' type should be different, but so far I have little idea 1. what exactly should be the change, 2. if there are any potential adverse effects of such a change.

Saul-Mirone commented 1 year ago

Can you provide a stackblitz or codesandbox link? I still cannot reproduce.

radio-miskovice commented 1 year ago

I will check what is definition of ComponentConstructorOptions. If it is based on Record<> then it could be some option in typescript config. Stackblitz or Codesandbox later.

Rimantovas commented 1 year ago

Have you managed to solve it? @radio-miskovice