michelson / Dante

Just another Medium wysiwyg editor clone
https://dante-editor.dev
2k stars 189 forks source link

Dante 1.0.6 : Cannot read properties of undefined (reading 'target') #214

Closed yohannmartinez closed 2 years ago

yohannmartinez commented 2 years ago

Hello ! I wanted to test the library, I forked a codesandbox example who was working pretty well, but in my environment, i get this error

Capture d’écran 2022-01-25 à 14 22 06

i'm using a empty react 17.0.2 project with no other depedencies instead of prop-types 15.8.1... I used the library this way

Capture d’écran 2022-01-25 à 14 25 43

let me know if u want more details, i also get the same error with other versions of the npm library (1.0.6-alpha.1, 1.0.5, 1.0.4...)

Parker-Bergen commented 2 years ago

I am having this exact same issue. On one server I am not having this issue at all but on another fresh install with the same code I am having this issue. The only thing I can think of is the new server has updated dependencies.

michelson commented 2 years ago

You will need to check your dependencies; I could bet that could be that, and if you can provide an example to reproduce the error will help to figure it out.

Also you should download the repository and run the dev server to see if that works too.

thanks

iuliuh commented 2 years ago

I'm having the same problem. It could be a dependency problem, but I can't figure out a solution/workaround. I can provide an example to reproduce the error, though.

Disclaimer: I am not a web dev, I'm just puzzling some pieces together for a personal project.

I am using npm 8.1.2.

So I am having the same issue that reproduces even with the simplest react app. I tried running dante-editor-3-tester from https://codesandbox.io/s/hzi3l, as well, but I couldn't make it work; will explain what I tried. When I ran npm install for it I got:

npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: react-scripts@4.0.0
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"4.1.3" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"4.0.0" from the root project
npm ERR! 
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"4.0.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /home/iuliu/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/iuliu/.npm/_logs/2022-03-11T11_35_59_796Z-debug.log

Running npm install --force does build it, but it still doesn't work when running npm start. When the app starts I get the following in console:

Uncaught TypeError: Cannot read properties of undefined (reading 'target')
    at Object.addAttributes (link.ts:74:1)
    at getAttributesFromExtensions.ts:85:1
    at Array.forEach (<anonymous>)
    at getAttributesFromExtensions (getAttributesFromExtensions.ts:67:1)
    at getSchemaByResolvedExtensions (getSchemaByResolvedExtensions.ts:23:1)
    at new ExtensionManager (ExtensionManager.ts:34:1)
    at Editor.createExtensionManager (Editor.ts:241:1)
    at new Editor (Editor.ts:81:1)
    at Editor._createSuperInternal (createSuper.js:12:1)
    at new Editor (Editor.ts:6:1)
    at useEditor.ts:16:1
    at invokePassiveEffectCreate (react-dom.development.js:23487:1)
    at HTMLUnknownElement.callCallback (react-dom.development.js:3945:1)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:3994:1)
    at invokeGuardedCallback (react-dom.development.js:4056:1)
    at flushPassiveEffectsImpl (react-dom.development.js:23574:1)
    at unstable_runWithPriority (scheduler.development.js:468:1)
    at runWithPriority$1 (react-dom.development.js:11276:1)
    at flushPassiveEffects (react-dom.development.js:23447:1)
    at react-dom.development.js:23324:1
    at workLoop (scheduler.development.js:417:1)
    at flushWork (scheduler.development.js:390:1)
    at MessagePort.performWorkUntilDeadline (scheduler.development.js:157:1)

I have also tried with a standard npx create-react-app dante3-example-vanilla project to which I just added <Dante content="initial content" />. This is the simplest reproducible example, I believe. I have attached the dante3-example-vanilla project as a zip to this message.

I would very much appreciate any hint or help in getting this working.

dante3-example-vanilla.zip

michelson commented 2 years ago

hi @iuliuh the codesandbox that you send works for me, I tried it from codesandbox directly and it runs ok.

iuliuh commented 2 years ago

Now this is intriguing! What are your node and npm versions? Mine are below.

$ node --version
v16.13.1

$ npm --version
8.1.2

Could it be that I am using Ubuntu 20.04? It can't be that, can it?... Have you also tried dante3-example-vanilla.zip?

ankur700 commented 2 years ago

I am having the same issue, i have node - v16.8.0 & npm 8.1.3

iuliuh commented 2 years ago

@michelson I believe I have managed to isolate the issue and replicate it in codesandbox: https://codesandbox.io/s/determined-dew-vj2iwi

image

What could be that I am unable to create a working example from scratch or on my local machine? Is it possible to point us in the right direction for a better troubleshooting? I can't figure out what is the dependency that is causing the issue.

Thank you very much!

michelson commented 2 years ago

I've released a new version 1.0.8 , try it in your codesandbox, it will work. the tiptap versioning is really a mess.

reopen, or add a new issue if you still have the problem.