Editing the line that a Block widget is derived from causes newlines to be added

I’m trying to implement a block widget that is derived from a special token in the editor’s text. I have been able to get this to work successfully with a state field, but newlines are inserted before the block widget any time I edit the line. Here’s an example.

If you edit either line that contains the text “SPECIAL_TOKEN”, you will see what I mean. Oddly enough, it doesn’t appear to happen on delete, just on insert.

Thanks in advance!

Oh, indeed, that was a bug in DOM change handling. This patch should help.

1 Like

I tested this out, and it seems to be working as expected! Do you have a release planned for this yet?

I’ve published @codemirror/view 0.19.8 which includes this.

1 Like