Hello,
I have some questions related to annotation topic:
1. How can I update a transaction keeping its annotation’s origin value?
2. How can I detect the current transaction’s annotation? Is it like this?
tr.annotation(Transaction.userEvent)
Let me give you some context. I am trying to update a ‘delete.selection’ transaction, reducing the selection area of the content that will be deleted. To do this, I am using
EditorState.transactionFilter.of((tr:Transaction) => {
if(tr.isUserEvent('delete.selection')){
...
}
})
and inside of it, I am using
return tr.startState.update({changes:{from:range.from, to: range.to}}
But I realize that the annotation information is missing when I do this. After reading the docs, and this forum’s topic (https://discuss.codemirror.net/t/using-annotations-to-differentiate-origin-of-transaction/3224) I could achieve the following result:
return tr.startState.update(
{ changes:{
from:range.from, to: range.to
},
annotations: Annotation.define<string>().of('delete.selection')
}
But I realize that when I check if tr.isUserEvent('delete')
to the transaction updated, it returns false. It doesn’t recognize the userEvent. Probably because I am creating a custom userEvent instead of a real ‘delete.selection’.