joelewis / prosemirror-mentions

ProseMirror plugin to enable @mentions and #hashtags
MIT License
114 stars 32 forks source link

document state is not updated when the mention is selected #30

Closed ravi7mech closed 2 years ago

ravi7mech commented 2 years ago

Co-Authored-By: gdelory 9974707+gdelory@users.noreply.github.com

joelewis commented 2 years ago

Hi, thanks for the patch! Can you quickly explain more about the issue. I tried in the demo editor running @ https://star-drug.glitch.me/ and the state does seems like it's updated when a mention is selected.

gdelory commented 2 years ago

Hi, I tried to simplified my sample in a codebox so you can see, and I also recorder my screen. This is ugly, I have no css whatsoever, but it should be enough for you to reproduce, it was for me.

Issue is that because the event is not properly dispatched, it doesn't correctly call dispatchTransaction, which react prosemirror relies on to trigger the change event (which we rely on to update our state and do stuff).

As you can see on the gifs, every time I type, the handleChange is triggered, but not when I select a mention. As soon as I enter anything else, it does fix it, but issue is that our users usually put a mention at the end and save, and therefor we don't actually save the mention, just what they types so far

Here is the recording: prosemirror-mention-issue-29

Here is the sandbox: https://codesandbox.io/s/holy-sun-k3vp2?file=/src/App.js:1369-1381

joelewis commented 2 years ago

Got it @gdelory Thanks for the live demo. Looks good to go :)

gdelory commented 2 years ago

awesome, thanks a lot for merging that fast 😃 Any idea when this will be released to npmjs.com? Or you're not planning to and we should install from git directly?

gdelory commented 2 years ago

@joelewis in case you didn't get a notification, if you had sorry for the spam 😉

joelewis commented 2 years ago

Hi @gdelory I'll pull together some time to publish it in npm this weekend. Will update here once once it's done?

gdelory commented 2 years ago

Awesome thanks a lot

joelewis commented 2 years ago

The latest version is published to npm now.

gdelory commented 2 years ago

Hi, unfortunately it seems like the change didn't make it to the compiled version in dist/index.js and dist/index.es.js, only in the source file. Not sure why though

See https://registry.npmjs.org/prosemirror-mentions/-/prosemirror-mentions-1.0.1.tgz

You might have forgotten to run the build script?

npm run-script build rollup.config.js
npm pack

Although I had to update the config to switch from esm to es or I had:

[!] Error: Invalid format: esm - valid options are amd, cjs, es, iife, umd

I've never used rollup so not used if they changed this lately.

@joelewis

joelewis commented 2 years ago

Published with compiled versions in npm. Thanks for the heads up @gdelory I did forget to run the build script. I've fixed the rollup config as well.

gdelory commented 2 years ago

@joelewis Thank you so much for your reactivity! I know this is volunteer work so I'm really grateful for you answering and fixing things so quickly.

New version installed and deployed, original issue fixed, everything works like a charm 🎉

Thank you!