renderAnnotation is not called when applying add_annotation operation
See original GitHub issueDo you want to request a feature or report a bug?
Report a bug.
What’s the current behavior?
If you get add_annotation
operation from another editor (lets call it remote editor) and you want to apply it to your editor instance (lets call it local editor), it is applied correctly to the value (value.annotations is properly updated) however, renderAnnotation
is not called on local editor.
Also if you change the text within the range of the annotation in remote editor, the annotation range and offset is not updated. In local editor (the one that created the annotation), range is updated properly.
So there is some difference between calling:
editor.addAnnotation(annotation)
and calling
editor.applyOperation(operationContainingAnnotation)
What’s the expected behavior?
renderAnnotation
should be called if anything in value.annotations
has changes.
Also annotations should be updated whenever document.value has changed.
Without it annotations cannot be used in collaborative editing (we use operational transform).
Minimal reproducible example
I updated Syncing operations
example to include this case. It shows this behavior with minimal changes.
Here is my commit, if you checkout this, you will be able to reproduce it:
https://github.com/kierson/slate/commit/21ef412649373fd53d39106db1886ee4e2d75d25
I added new Comment icon. So you have to just select some text in one of editors and click comment button. It will add new annotation and render orange text in one of the editors. But it should render it on both editors.
I would be happy to fix it myself and open a PR if someone can point me out where to look for solution.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:6 (3 by maintainers)
Top GitHub Comments
In my case, using
addAnnotation
won’t callrenderAnnotation
I believe that this may be fixed by https://github.com/ianstormtaylor/slate/pull/3093, which has changed a lot of the logic in Slate and
slate-react
especially. I’m going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.