Should I expect the doc to update in this example? I’m trying to test a state extension’s result. Do I have to dispatch the changes through the view to trigger the update?
let state = EditorState.create({
doc: "test",
extensions: [
contextualKeywordsState,
],
});
state.update({ changes: { from: 0, insert: "changes" } });
console.log(state.doc); // TextLeaf { text: [ 'test' ], length: 4 }
let result = state.field(contextualKeywordsState);
return result
It will return the value the field has after the transaction. Running transactions like this is a perfectly reasonable way to test state fields. Maybe you have an issue in the field implementation or the test transaction code?