The TinyMCE integration renders comment highlights as view-only overlay elements positioned over the commented text. It does not modify your TinyMCE content, schema, undo history, or saved HTML.
Setup
- Add the
Velt Comments component to the root of your app. This component is required to create and render comments in your app.
- Authenticate the user with
authProvider and set the Velt document before users add comments.
- Set the
textMode prop to false to hide the default Velt text comment tool. TinyMCE selections are handled by @veltdev/tinymce-velt-comments.
- Add
VeltCommentsSidebar if you want a Google Docs-style comment sidebar.
React / Next.js
Other Frameworks
Step 2: Install the Velt TinyMCE extension
React / Next.js
Other Frameworks
tinymce is a peer dependency and must be provided by your TinyMCE app. Import the self-hosted TinyMCE assets used by your editor so @tinymce/tinymce-react and the Velt plugin use the same TinyMCE instance.
Add VeltCommentsPlugin to the TinyMCE plugins list and set velt_comments_editor_id in the editor init options. Capture the TinyMCE editor instance from onInit or the init event, then render Velt comment annotations into the editor with renderComments.
React / Next.js
Other Frameworks
The package registers a TinyMCE plugin named veltcomments. You can pass the exported VeltCommentsPlugin constant in plugins, or use the string 'veltcomments' after the package has been imported. It also registers a TinyMCE toolbar button named addveltcomment.
Add a button that users can click to add comments after selecting text in the TinyMCE editor.
Important: Use onMouseDown with preventDefault() so the browser does not move focus away from the editor before addComment reads the current selection. Keep the actual addComment call in onClick.
React / Next.js
Other Frameworks
- Call this method to add a comment to selected text in the TinyMCE editor.
- Params:
AddCommentRequest. It has the following properties:
editor: TinyMCE Editor instance.
editorId: Id of the editor. Use this if you have multiple TinyMCE editors on the same page. (optional)
context: Add custom metadata to the Comment Annotation. Learn more. (optional)
React / Next.js
Other Frameworks
The library automatically writes context.textEditorConfig with the selected text, its 1-based occurrence index in the document, and the editor ID when one is provided. If the editor is inside an element with data-velt-location-id, that value is sent to Velt as the annotation location.
- Get the comment data from Velt SDK and render it in the TinyMCE editor.
- Params:
RenderCommentsRequest. It has the following properties:
editor: TinyMCE Editor instance.
editorId: Id of the editor. Use this if you have multiple TinyMCE editors on the same page. (optional)
commentAnnotations: Array of Comment Annotation objects.
React / Next.js
Other Frameworks
renderComments filters annotations by context.textEditorConfig.editorId. Resolved comments with status.type === 'terminal' are hidden unless they are currently selected in Velt.
- TinyMCE renders comment highlights as view-only overlay elements in the outer document.
- The integration does not write Velt comment marks into your TinyMCE content or undo history.
- Save your TinyMCE content normally. After you recreate the editor or replace content with
editor.setContent(...), call renderComments again.
- You can style the commented text by adding CSS for the
velt-comment-text element.
- TinyMCE highlights are overlay elements in the outer document, not inside the editor iframe, so add this CSS to your page stylesheet instead of
content_style.
Using TinyMCE without React
For a vanilla TinyMCE app, initialize Velt with @veltdev/client, add the Velt comments web component to the page, and subscribe to annotations through the Velt comment element.
Multiple TinyMCE editors
When using multiple editors on the same page, provide a unique editorId to TinyMCE’s velt_comments_editor_id init option, addComment, and renderComments.
TypeScript support
The package includes TypeScript definitions. Key type exports:
Runtime exports:
Complete Example
APIs
The registered TinyMCE plugin name ('veltcomments') that powers Velt comments. Importing the library registers it; add it to the TinyMCE editor’s plugins list.
Init options:
velt_comments_editor_id?: string - Unique identifier for this editor instance.
velt_comments_persist_marks?: boolean - Reserved for API parity; highlights are always rendered as view-only overlays.
React / Next.js
Other Frameworks
Explicitly registers the veltcomments plugin with a TinyMCE instance. Importing the package auto-registers the plugin when a TinyMCE instance is available; use this method when TinyMCE is loaded or provided later.
Parameters:
instance?: TinyMCE - TinyMCE instance to register against.
Returns: void
Creates a Velt comment annotation for the currently selected TinyMCE text.
React / Next.js
Other Frameworks
Resolves Velt comment annotations back to TinyMCE DOM ranges and renders stable <velt-comment-text> overlay elements for the visible comments.
React / Next.js
Other Frameworks