KonnorRogers / rhino-editor

A tiptap integration for Rails compatible with ActionText
https://rhino-editor.vercel.app
MIT License
227 stars 11 forks source link

fix bug in removing attachments #170

Closed KonnorRogers closed 6 months ago

KonnorRogers commented 6 months ago

@lylo this should fix the issues with figures. I forgot the logic was kind of relying on some undocumented behavior of the editor.

This is the "proper" way to remove a node in ProseMirror / TipTap.

Fixes #168

changeset-bot[bot] commented 6 months ago

🦋 Changeset detected

Latest commit: 0d27bea0bef51b4c9e7e438104dcbf92bbf154a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------ | ----- | | rhino-editor | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 6 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
rhino-editor ✅ Ready (Inspect) Visit Preview Apr 23, 2024 9:01pm
lylo commented 6 months ago

Thanks @KonnorRogers! That's fab. I tried to verify but I couldn't figure out how to link my test project with this branch (yarn link didn't work 🤷‍♀️) so I'll wait until the release and confirm then.

KonnorRogers commented 6 months ago

@lylo release should be in a couple mins :)

lylo commented 6 months ago

That does seem to fix the issue, thank you.

I am seeing some other odd behaviour on my app after upgrading though (not on the rhino-test app). I can no longer enter carriage returns. I see this error when hitting return. Nothing has changed in my app other than upgrading to 0.9.3 of Rhino.

application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:68673 Uncaught RangeError: Can not convert <> to a Fragment (looks like multiple versions of prosemirror-model were loaded)
    at _Fragment.from (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:68673:11)
    at _NodeType.create (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:70309:64)
    at split (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:66619:54)
    at Transaction.split (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:67370:5)
    at application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:79629:11
    at Object.splitBlock (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:77454:55)
    at Array.<anonymous> (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:80070:23)
    at application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:78719:18
    at Object.method2 [as first] (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:77384:43)
    at handleEnter (application-f79c2c5d09ed78668c34fbf48d69c19214e9e73b546ebb9757d52ee3da09c9f5.js:80066:52)

I'm also seeing some oddness in the rhino-test app with the placement of images when dragging them into the editor. If I drag to an empty line (so the horizontal line appears before I drop) it seems to work fine, but if I drop at the end of of a line of text, the image appears in the next blank line. I will have to produce a video to demonstrate but that'll have to wait as it's too late right now.

KonnorRogers commented 6 months ago

looks like multiple versions of prosemirror-model were loaded

Let me see if there's some dependencies to dedupe on my end

KonnorRogers commented 6 months ago

@lylo I upgraded the underlying prosemirror + tiptap libraries.

You could try either yarn upgrade prosemirror-model or you may have to add a resolutions key to your package.json that looks like this:

{
  "resolutions": {
     "prosemirror-model": "^1.2.0"
  }
}

and make sure to rm -rf node_modules and then re-run yarn install

if that doesn't fix it' I'd be happy to debug further

lylo commented 6 months ago

@KonnorRogers I ran npm dedupe and this seems to have solved it 👌

$ npm ls prosemirror-model

app@ /Users/olly/dev/teamlight
├─┬ @tiptap/extension-code-block-lowlight@2.2.4
│ └─┬ @tiptap/pm@2.3.0
│   ├─┬ prosemirror-commands@1.5.2
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-gapcursor@1.3.2
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-markdown@1.12.0
│   │ └── prosemirror-model@1.20.0 deduped
│   ├── prosemirror-model@1.20.0
│   ├─┬ prosemirror-schema-basic@1.2.2
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-schema-list@1.3.0
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-state@1.4.3
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-tables@1.3.7
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-trailing-node@2.0.8
│   │ └── prosemirror-model@1.20.0 deduped
│   ├─┬ prosemirror-transform@1.8.0
│   │ └── prosemirror-model@1.20.0 deduped
│   └─┬ prosemirror-view@1.33.5
│     └── prosemirror-model@1.20.0 deduped
└─┬ rhino-editor@0.9.3
  ├─┬ prosemirror-utils@1.2.1-0
  │ └── prosemirror-model@1.20.0 deduped
  └─┬ prosemirror-view@1.28.2
    └── prosemirror-model@1.20.0 deduped