remirror icon indicating copy to clipboard operation
remirror copied to clipboard

Migrate from 2 to 3 throws ts error in prosemirrorNodeToHtml

Open apdrsn opened this issue 1 year ago • 1 comments

Summary

When updating from 2 to 3 I get this typescript error. I suspect that it is some internal dependecies that are not correct. It is complaining about Property 'linebreakReplacement' is missing in type when passing state.doc into prosemirrorNodeToHtml.

It seems that something is colliding between prosemirror/model and prosemirror/view

Steps to reproduce

  1. Use prosemirrorNodeToHtml in version 2 passing in state.doc
  2. Do the same thing after updating to newest remirror @remirror/pm and @remirror/react
"@remirror/pm": "^3.0.0",
"@remirror/react": "^3.0.1",
"remirror": "^3.0.1",

Expected results

prosemirrorNodeToHtml should accept state.doc

Actual results

prosemirrorNodeToHtml throws an error (see image)

Possible Solution

Screenshot(s)

image

apdrsn avatar Aug 13 '24 14:08 apdrsn

@apdrsn - Are you still able to reproduce this? I'm not. Here's what I tried:

  1. Setup a minimal app: npx create-react-app my-app --template typescript
  2. Install remirror dependencies: npm install --save remirror @remirror/react @remirror/pm
     "@remirror/pm": "^3.0.0",
     "@remirror/react": "^3.0.1",
     "remirror": "^3.0.1",
    
  3. Update App.tsx
    import React from "react";
    import { htmlToProsemirrorNode, prosemirrorNodeToHtml } from "remirror";
    import { CodeExtension } from "remirror/extensions";
    import { Remirror, ThemeProvider, useRemirror } from "@remirror/react";
    import "remirror/styles/all.css";
    import "./App.css";
    
    const extensions = () => [new CodeExtension()];
    
    function App() {
      const { manager, state, onChange } = useRemirror({
        extensions: extensions,
        content: "<p>Text as <code>code</code></p>",
        stringHandler: htmlToProsemirrorNode,
      });
    
      const html = prosemirrorNodeToHtml(state.doc);
    
      return (
        <div className="App">
          <ThemeProvider>
            <Remirror
              manager={manager}
              onChange={onChange}
              initialContent={state}
              autoRender="end"
            ></Remirror>
          </ThemeProvider>
          HTML:
          <textarea>{html}</textarea>
        </div>
      );
    }
    
    export default App;
    
  4. Build the app: npm run build

I didn't see any type errors in the editor (VSCode) nor during build.

mdmower avatar Sep 20 '24 22:09 mdmower