I try to get the position(line
, ch
) from the state.selection
(like the position codemirror provides) using the API or property, because i need the line
and ch
position to change our other internal model(not prosemirror model) with this position whenever prosemirror document is changed. So I implement this using selection
and transation
in dispatchTransaction
.
dispatchTransaction(transaction) {
const { $from, $to, ranges } = this.state.selection;
const { state, transactions } = this.state.applyTransaction(transaction);
transactions.forEach(tr => {
if (tr.docChanged) {
// ...
}
});
}
But I’ve spent the last three hours playing with all the prosemirror-model APIs I could find, but no luck extracting those positions… I feel like I must be missing something important.
Is there any obvious way to get the line and ch position of the state.selection
based on view?
Thank you in advance!