The following code produces an error:
const tr = state.tr;
const hr = state.schema.nodes.hr.create();
tr.replaceSelectionWith(hr);
if (tr.selection instanceof NodeSelection) {
const near = GapCursor.near(tr.selection.$to, 1);
tr.setSelection(near);
}
dispatch(tr);
I’ve had to resort to doing this instead:
const near = TextSelection.near(tr.selection.$to, 1);
tr.setSelection(
new GapCursor(near.$to, near.$to)
);
The error strikes me as a bit strange, so I figured I’d ask if it could be a bug before I dive too deep into figuring out what I’m doing wrong. It happens with GapCursor.findFrom
as well.