Can't place block widgets at 0 or doc.length

I’m trying to place a block widget either at the start or end of the document and keep it there for the life of the editor, but both locations cause some weird cursor behavior when navigating the editor. This video shows what happens when I just press the down arrow to navigate to the end of the document.

Here is my state field and decoration widget.

const attributionField = StateField.define<DecorationSet>({
  create(state) {
    return RangeSet.of(decoration().range(state.doc.length))
  },
  update(_attributions, transaction) {
    // keep it at the end of the editor
    return RangeSet.of(decoration().range(transaction.newDoc.length))
  },
  provide(field) {
    return EditorView.decorations.from(field)
  },
})

const decoration = () => Decoration.widget({
  widget: new AttributionWidget(),
  side: 1,
  block: true,
})

That seems to have originated from this bug. @codemirror/view 0.18.14 should fix it.

1 Like

That solved it! Thanks!