You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to implement image placeholders for uploading images using node decorations. After lots of debugging, however, it seems like this line from the documentation:
decorations=decorations.map(tr.mapping,tr.doc)
has some issues, as decorations.find().length is 2 before it and 0 afterwards. This is rather odd as I expect widget decorations to never be deleted (they are not deleted even when doing Ctrl + A → Backspace). However when inserting an image programatically, they are deleted.
As a reproduction, I took dumps of all of the involved variables:
Mapping will absolutely delete decorations that are covered by a deleted or replaced range. But in your example the decorations appear to be at position 9, not inside the deleted range. But given that their from equals their to position, they don't appear to be valid node decorations, which might explain why they get dropped.
I'm trying to implement image placeholders for uploading images using node decorations. After lots of debugging, however, it seems like this line from the documentation:
has some issues, as
decorations.find().length
is 2 before it and 0 afterwards. This is rather odd as I expect widget decorations to never be deleted (they are not deleted even when doingCtrl + A
→Backspace
). However when inserting an image programatically, they are deleted.As a reproduction, I took dumps of all of the involved variables:
Variable dumps
This is the code that adds the image:
And the code that adds the decoration (inside the
apply()
function of the plugin state):Am I doing something wrong? I tried debugging the map function of DecorationSet with no luck, code too complex for me :(
Workaround
If anyone else has the same issue, this is the workaround I'm using right now instead of
decorations = decorations.map(...)
:The text was updated successfully, but these errors were encountered: