Track New Content with a Custom Mark in Kendo UI for Vue Editor
Environment
| Product | Kendo UI for Vue Editor |
| Version | 8.0.2 |
Description
I want to track and visually highlight new content that users type in the Kendo UI for Vue 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 Kendo UI for Vue Editor, use a custom ProseMirror mark and plugin:
-
Define a custom
trackedTextmark in the schema via theextendViewevent. 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.
Notes
- The
trackedTextmark is defined withinclusive: trueso that new text typed at the boundary of a tracked span continues to receive the mark. - The
handlePastehandler recursively marks all pasted content fragments, preserving the document structure. - The
handleKeyDownhandler ensures that pressing Enter while tracking is enabled appliessetStoredMarksso the new line continues in tracked mode.