Track New Content with a Custom Mark in KendoReact Editor
Environment
| Product Version | 14.2.1 |
| Product | Progress® KendoReact Editor |
Description
I want to track and visually highlight new content that users type in the KendoReact Editor. For example, when tracking is enabled, all newly entered text should appear in a different color so that it is easy to distinguish from the original content.
Solution
To track new content in the KendoReact Editor, use a custom ProseMirror mark and plugin:
-
Define a custom
trackedTextmark in the schema via theonMountevent. This mark wraps new content in a<span>with a distinct style (for example, blue text). -
Create a ProseMirror plugin that intercepts
handleTextInput,handlePaste, andhandleKeyDown. When tracking is enabled, the plugin applies thetrackedTextmark to all newly inserted content and preserves the tracking format when pressing Enter to create new lines. -
Add a toolbar button that toggles the tracking mode on and off.