TinyMCE AI Plugin
| This plugin is only available for paid TinyMCE subscriptions. |
The TinyMCE AI plugin integrates AI-assisted authoring with rich-text editing. Users can interact through Actions, Reviews, or Conversations that can use relevant context from multiple sources.
Interactive example
-
TinyMCE
-
HTML
-
JS
-
Edit on CodePen
<textarea id="tinymceai">
<h1 style="font-size: 1.5em; color: black; margin-top: 0; text-align: left;">TinyMCE AI</h1>
<p style="font-size: 1em; color: #333; margin: 15px 0;">TinyMCE AI provides AI-powered features including AI chat, AI review, and quick actions.</p>
</textarea>
tinymce.init({
selector: 'textarea#tinymceai',
height: '800px',
plugins: ["tinymceai", "advlist", "anchor", "autolink", "charmap", "code"],
toolbar: "undo redo | tinymceai | styles | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
});
Basic setup
To setup the TinyMCE AI plugin in the editor:
-
add
tinymceaito thepluginsoption in the editor configuration; -
add
tinymceaito thetoolbaroption in the editor configuration; -
configure the
tinymceai_token_provideroption to provide authentication tokens;
For example:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
plugins: 'tinymceai',
toolbar: 'tinymceai',
tinymceai_token_provider: function() {
// Return a promise that resolves to a JWT token
return fetch('/api/token').then(response => response.text());
}
});
Options
The following configuration options affect the behavior of the TinyMCE AI plugin.
tinymceai_token_provider
Type: Function (() => Promise<string>)
Default value: undefined
Description: A function that returns a Promise resolving to a JWT token string for authenticating with the AI service.
Example: using tinymceai_token_provider
tinymce.init({
selector: 'textarea',
plugins: 'tinymceai',
toolbar: 'showai aiquickactions aireview',
tinymceai_token_provider: () => Promise.resolve('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...')
});
| In production, you should fetch the JWT token from your backend server rather than hardcoding it. For example: |
tinymce.init({
selector: 'textarea',
plugins: 'tinymceai',
tinymceai_token_provider: function() {
return fetch('/api/token').then(response => response.text());
}
});
Toolbar buttons
The TinyMCE AI plugin provides the following toolbar buttons:
| Toolbar button identifier | Description |
|---|---|
|
Main AI plugin button |
|
Conversations feature |
|
Quick Actions feature |
|
Reviews feature |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
These toolbar buttons can be added to the editor using:
-
The
toolbarconfiguration option. -
The
quickbars_insert_toolbarconfiguration option.
| Toolbar button identifier | Description |
|---|---|
|
Main AI plugin button |
|
Conversations feature |
|
Quick Actions feature |
|
Reviews feature |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
|
Quick Actions |
Menu items
The TinyMCE AI plugin provides the following menu items:
| Menu item identifier | Default Menu Location | Description |
|---|
These menu items can be added to the editor using:
-
The
menuconfiguration option. -
The
contextmenuconfiguration option.
| Menu item identifier | Default Menu Location | Description |
|---|
Commands
The TinyMCE AI plugin provides the following TinyMCE commands.
| Command name | Description |
|---|---|
|
Toggle the AI sidebar interface visibility. Accepts an optional object parameter with |
|
Download diagnostic information for troubleshooting purposes. |
// Toggle the AI sidebar
editor.execCommand('tinymceai-toggle-sidebar');
// Open the sidebar with a specific view (e.g., 'chat')
editor.execCommand('tinymceai-toggle-sidebar', false, {
type: 'static',
view: 'chat'
});
// Close the sidebar
editor.execCommand('tinymceai-toggle-sidebar', false, {
type: 'static'
});
Events
The TinyMCE AI plugin provides the following events.
| Event name | Description |
|---|---|
|
Dispatched when the floating AI sidebar should be toggled. This event is used internally to control the visibility of the floating sidebar interface. |
editor.on('tinymceai-toggle-floating-sidebar', function() {
// Handle the toggle floating sidebar event
console.log('Floating sidebar toggle requested');
});
Known issues and caveats
The TinyMCE AI plugin has the following known issues and caveats:
General HTML Support
TinyMCE AI may not work correctly when General HTML Support for block elements is enabled. This issue will be addressed in future updates. In the meantime, we recommend avoiding configurations that may cause problems.
Issues with tables
We are aware of certain glitches that may occur when the AI modifies complex tables or layout tables. To prevent data loss, please ensure that the content around these structures remains intact when using TinyMCE AI tools, while our team investigates the causes and potential solutions to this issue.
Editor context and multiple editor handling
While it’s possible to use TinyMCE AI with multiple editors in an editor context, only the first editor registered in the context will currently be able to interact with AI tools and benefit from the content suggestions made by the AI. As our team works on resolving this issue, we recommend using standalone editor instances with TinyMCE AI.
Inline image processing issues
Inline images may not be processed correctly by commands within AI review. A solution is currently under development.
Quick actions and content markers issues
Applying quick action responses may result in the loss of Comments and Suggested Edits suggestion markers. This issue will be addressed in a future update.
Limited interactivity in Chat history
The interactivity of historical AI chat conversations can become limited over time.
Issues with specific AI models
Some AI models may occasionally return empty responses. If this occurs, we recommend sending a follow-up message asking the Assistant to complete the previous request, or starting a new conversation.
| If you wish to stay informed about updates or discuss TinyMCE AI possibilities, please reach out to us. |