TinyMCE AI multi-editor mode
| This feature is only available for TinyMCE 8.10 and later. |
Multi-editor mode groups several TinyMCE editors on one page, such as the sections of a form, so that they share one Chat sidebar and one Review sidebar. Chat, Review, and Quick Actions work across the content of every editor in the group.
Demo
The demo below groups the two sections of a hiring pack. The group uses decoupled mode, so AI Chat and AI Review open in a panel next to the editors, and AI Chat opens when the demo loads. Select a suggested action, or run a review across both editors.
-
TinyMCE
-
HTML
-
JS
Role description
Interview questions
<style>
/* Hide the empty icon slot so the welcome action buttons show text only. */
.tox .tox-ai .tox-ai-chat-action-button .tox-icon:empty { display: none; }
/* Keep the AI panel next to the editors. Stack it below them only on narrow screens. */
.tinymceai-multi-editor-layout { display: flex; gap: 16px; align-items: flex-start; }
.tinymceai-multi-editor-editors { flex: 1 1 auto; min-width: 0; }
#tinymceai-multi-editor-panel { flex: 0 0 300px; height: 654px; box-sizing: border-box; border: 2px solid #eee; border-radius: 10px; overflow: hidden; }
@media (max-width: 600px) {
.tinymceai-multi-editor-layout { flex-direction: column; align-items: stretch; }
#tinymceai-multi-editor-panel { flex-basis: auto; }
}
</style>
<h3>Role description</h3>
<div class="tinymceai-multi-editor-layout">
<div class="tinymceai-multi-editor-editors">
<textarea id="tinymceai-multi-editor-role-description">
<h2>Senior product designer, Berlin</h2>
<p>We’re looking for a strong designer to join our young and fast-moving team shaping the editing experience end to end. You’ll own flows from first sketch to shipped release, working next to engineers and researchers.</p>
<p>Must have 5+ years in product design and be comfortable owning ambiguous problems. Native-level English required.</p>
</textarea>
<h3>Interview questions</h3>
<textarea id="tinymceai-multi-editor-interview-questions">
<h2>Interview guide</h2>
<ol>
<li>Walk me through a project where you owned the problem definition, not just the visuals.</li>
<li>How do you work with engineering when a constraint appears mid-build?</li>
</ol>
</textarea>
</div>
<div id="tinymceai-multi-editor-panel"></div>
</div>
// Open-source plugins below are only for editing the demo HTML (lists, links, tables). TinyMCE AI options are the focus.
// Share one TinyMCE AI configuration between every editor in the group.
const sharedSettings = {
plugins: ['tinymceai', 'advlist', 'lists', 'link', 'autolink', 'table'],
toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate | styles | bold italic underline | bullist numlist | link table',
menubar: false,
help_accessibility: false,
// Decoupled mode: AI Chat and AI Review render in the panel next to the editors instead of in a sidebar.
tinymceai_decoupled_container: '#tinymceai-multi-editor-panel',
tinymceai_decoupled_show: 'tinymceai-chat',
tinymceai_chat_welcome_message: '<p>Hi! I’m your writing assistant.</p><p>I can read and write across both sections of this hiring pack — refine the role or generate interview questions.</p>',
// Every welcome action uses the empty 'no-icon' icon registered in setup, so the buttons show text only.
tinymceai_chat_welcome_actions: [
{ text: '**Try one of these:**' },
{
title: 'Suggest more interview questions',
command: 'TinyMCEAIChatPrompt',
value: {
prompt: 'Based on the Role description, suggest three or four more interview questions and add them to the end of the numbered list in the Interview questions section. Match the style of the existing questions.',
displayedPrompt: 'Suggest more interview questions'
},
icon: 'no-icon'
},
{
title: 'Flag any unclear or biased wording',
command: 'TinyMCEAIChatPrompt',
value: {
prompt: 'Check both sections of this hiring pack for unclear or biased wording. For each phrase, explain the problem and suggest clearer, more inclusive wording.',
displayedPrompt: 'Flag any unclear or biased wording'
},
icon: 'no-icon'
}
],
setup: (editor) => {
editor.ui.registry.addIcon('no-icon', '');
},
tinymceai_token_provider: async () => {
return fetch('/api/token', { credentials: 'include' })
.then(resp => resp.text())
.then(token => ({ token }));
},
tinymceai_chat_fetch_sources: () => Promise.resolve([{
label: 'TinyMCE resources',
sources: [
{ id: 'docs', label: 'TinyMCE Documentation', type: 'web-resource' },
{ id: 'blog', label: 'Tiny Blog', type: 'web-resource' },
{ id: 'survey-2023', label: 'State of rich text editing 2023', type: 'web-resource' },
]
}]),
tinymceai_chat_fetch_source: (id) => {
const urls = {
'docs': 'https://www.tiny.cloud/docs/tinymce/latest/',
'blog': 'https://www.tiny.cloud/blog/',
'survey-2023': 'https://www.tiny.cloud/developer-survey-results-2023/',
};
return Promise.resolve({ type: 'web-resource', url: urls[id] });
},
tinymceai_quickactions_custom: [
{
type: 'chat',
title: 'Challenge',
prompt: 'Challenge statements, verify facts and identify assumptions'
}
],
tinymceai_languages: [
{ title: 'English', language: 'english' },
{ title: 'Chinese (Simplified)', language: 'chinese' },
{ title: 'Spanish', language: 'spanish' },
{ title: 'German', language: 'german' },
{ title: 'Japanese', language: 'japanese' },
{ title: 'Portuguese', language: 'portuguese' },
{ title: 'Swedish', language: 'swedish' },
{ title: 'Korean', language: 'korean' },
{ title: 'Hindi (Devanagari)', language: 'hindi devanagari' },
{ title: 'Italian', language: 'italian' },
{ title: 'Klingon', language: 'klingon' },
{ title: 'Dothraki', language: 'dothraki' },
]
};
tinymce.init({
...sharedSettings,
selector: 'textarea#tinymceai-multi-editor-role-description',
height: '270px',
tinymceai_group: 'hiring-pack',
tinymceai_document_name: 'Role description',
tinymceai_document_description: 'The job advert for the role: the job title and location, what the role involves, and the requirements for candidates.'
});
tinymce.init({
...sharedSettings,
selector: 'textarea#tinymceai-multi-editor-interview-questions',
height: '340px',
tinymceai_group: 'hiring-pack',
tinymceai_document_name: 'Interview questions',
tinymceai_document_description: 'The interview guide for the role: a heading followed by a numbered list of interview questions.'
});
| This feature is not supported when TinyMCE is run in inline mode. It is only supported in classic mode. For more information on the differences between the editing modes, see Inline editing mode. |
How grouped editors work
Shared sidebar
The first editor of the group to be created hosts the shared Chat sidebar and Review sidebar. The Chat and Review toolbar buttons and menu items in every other editor of the group open, close, and focus that shared sidebar.
In decoupled mode, the first editor of the group hosts AI Chat and AI Review in the element set by its tinymceai_decoupled_container value. The Chat and Review toolbar buttons and menu items in every editor of the group open and close AI Chat and AI Review in that element, and the keyboard shortcuts in every editor open them.
Chat
By default, each chat prompt includes the content of every editor in the group. Each editor appears above the prompt as a context tag labeled with its tinymceai_document_name value, for example
for an editor named Body.
Users can change which editors the AI works with:
-
Removing a context tag leaves the content of that editor out of the prompt, and the AI does not change that editor.
-
The Add context source menu lists every editor in the group and adds a removed editor back.
After a message is sent, the editors included in that message stay in the conversation and their context tags cannot be removed until the user starts a new conversation. Editors that were left out can still be added from the Add context source menu at any point in the conversation.
The AI can change the content of any editor in the conversation, and the plugin previews and applies each change in the editor it belongs to. To direct a request at the content of one editor, name that content in the prompt, for example "Shorten the Introduction". For more information about chat, see Chat.
Review
A review analyzes the content of every editor in the group. The Review sidebar groups suggestions under the name of the editor they belong to and shows the number of pending suggestions in each group. A review always covers the whole group. For more information about reviews, see Review.
Quick Actions
Users can run a Quick Action from any editor in the group. What the Quick Action changes depends on whether text is selected in that editor:
-
With text selected, the Quick Action changes only the selected text in that editor.
-
With no text selected, the Quick Action changes the whole content of every editor in the group and ignores any text selected in the other editors. For example, running Translate with no text selected translates every editor in the group.
Chat actions, such as Explain, Summarize, and Highlight key points, open the shared Chat sidebar and start a conversation that includes every editor in the group, as described in Chat. For more information about Quick Actions, see Quick Actions.
Previewing and applying changes
While the TinyMCE AI plugin previews changes from Chat or Quick Actions, each affected editor shows its own preview and is read-only. The whole group shares one change toolbar:
-
The change counter covers the changes in every editor of the group.
-
The next and previous buttons move between changes across editors.
-
Selecting a change in any editor moves the change toolbar to that change.
-
Accepting or rejecting a change applies it to the editor that holds the change.
Discarding pending suggestions
With the floating sidebar, when any editor in the group has pending suggestions, the TinyMCE AI plugin asks for confirmation before it discards them and starts a different AI task. For example, the confirmation dialog appears when the user switches between the Chat sidebar and the Review sidebar, or runs a Quick Action while a review has pending suggestions.
If the user confirms, the plugin discards the suggestions in every editor of the group, resets the changes already applied, and returns each editor to normal editing. If the user cancels, the plugin keeps every preview and pending suggestion.
In decoupled mode, the confirmation dialog does not appear. When the user switches between AI Chat and AI Review, the plugin discards the pending suggestions without asking.
Integration
To group editors, load the tinymceai plugin in each editor and set the same tinymceai_group value on each editor in the group. Give each editor a unique tinymceai_document_name value, and optionally a tinymceai_document_description value that describes the content to the AI.
The floating sidebar and decoupled mode both support multi-editor mode. For the floating sidebar, set tinymceai_sidebar_type to 'floating' for every editor in the group. For decoupled mode, see Grouped editors in decoupled mode.
Use the same TinyMCE AI configuration for every editor in a group, for example by sharing a settings object between the tinymce.init calls:
const sharedSettings = {
plugins: 'tinymceai',
toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review',
tinymceai_sidebar_type: 'floating',
tinymceai_group: 'article',
// Required for authentication
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.text()).then(token => ({ token }));
}
};
tinymce.init({
...sharedSettings,
selector: 'textarea#introduction', // change this value according to the HTML
tinymceai_document_name: 'Introduction',
tinymceai_document_description: 'The introduction of the article. A short paragraph that sets out the topic and hooks the reader.'
});
tinymce.init({
...sharedSettings,
selector: 'textarea#body', // change this value according to the HTML
tinymceai_document_name: 'Body',
tinymceai_document_description: 'The main body of the article. Uses h2 subheadings and short paragraphs.'
});
Grouped editors must be on the same page and use the same tinymce instance. Set tinymceai_group in the initial configuration of each editor.
For information about installing the plugin and enabling AI features, see Plugin Reference.
Grouped editors in decoupled mode
| This feature is only available for TinyMCE 8.11 and later. |
To use decoupled mode with a group, add one element for the group to the page and set tinymceai_decoupled_container to a CSS selector that matches it. The plugin uses the value set on the first editor created in the group, so the option can go in the shared settings object. To open AI Chat or AI Review when the page loads, set tinymceai_decoupled_show.
<div style="display: flex; gap: 16px;">
<div style="flex: 1;">
<textarea id="introduction"></textarea>
<textarea id="body"></textarea>
</div>
<div id="ai-panel" style="width: 400px; height: 800px; box-sizing: border-box; border: 2px solid #eee; border-radius: 10px; overflow: hidden;"></div>
</div>
const sharedSettings = {
plugins: 'tinymceai',
toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review',
tinymceai_group: 'article',
tinymceai_decoupled_container: '#ai-panel', // change this value according to the HTML
tinymceai_decoupled_show: 'tinymceai-chat',
// Required for authentication
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.text()).then(token => ({ token }));
}
};
tinymce.init({
...sharedSettings,
selector: 'textarea#introduction', // change this value according to the HTML
tinymceai_document_name: 'Introduction'
});
tinymce.init({
...sharedSettings,
selector: 'textarea#body', // change this value according to the HTML
tinymceai_document_name: 'Body'
});
To open or close AI Chat and AI Review programmatically, see TinyMCEAIToggleApp.
Multiple groups on one page
A page can contain several independent groups, each with a different tinymceai_group value. Each group has its own shared sidebar, and an editor in one group never receives the content of an editor in another group. In decoupled mode, give each group its own element and set a different tinymceai_decoupled_container value for each group. For a configuration with two groups, see the two-group example.
Configuration
For the options that configure multi-editor mode, see Options for multi-editor mode.
Related features
-
AI Chat: For interactive discussions with document analysis and context.
-
AI Review: For content quality analysis and improvement suggestions.
-
Quick Actions: For fast, stateless content transformations.