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.
To set up the TinyMCE AI plugin in {productname}:
-
add
tinymceaito thepluginsoption in the editor configuration; -
configure the
tinymceai_token_provideroption to provide authentication tokens (must return{ token: string }). During a {cloudname} trial, the demo identity service can supply JWTs so a custom token endpoint is not required; -
when the
toolbaroption is omitted or left at the default, the Silver theme toolbar already includes the AI toolbar buttons once the plugin is enabled:tinymceai-chat,
tinymceai-quickactions, and
tinymceai-review. When a custom
toolbarstring is set, add those button ids to the string explicitly.
The following configuration enables the plugin and token provider and relies on the default toolbar, which includes the AI buttons. If the toolbar option is set to a custom string, add tinymceai-chat, tinymceai-quickactions, and tinymceai-review to that string.
tinymce.init({
selector: 'textarea', // change this value according to the HTML
plugins: 'tinymceai',
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.json());
}
});The following example sets a custom toolbar string. To use the default toolbar instead (which already includes the AI buttons), omit the toolbar option.
tinymce.init({
selector: 'textarea', // change this value according to the HTML
plugins: 'tinymceai',
toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review',
content_id: 'document-123',
// Required for authentication
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.json());
},
tinymceai_default_model: 'agent-1',
tinymceai_allow_model_selection: true,
tinymceai_chat_fetch_sources: async () => [
{
label: 'My Documents',
sources: [
{ id: 'doc-1', label: 'Document 1', type: 'file' },
{ id: 'url-1', label: 'Web Page', type: 'web-resource' }
]
}
],
tinymceai_chat_fetch_source: async (id) => {
const res = await fetch(`/api/documents/\$\{id\}`);
const blob = await res.blob();
const filename = `\$\{id\}.pdf`;
return { type: 'file', file: new File([blob], filename, { type: blob.type }) };
},
tinymceai_quickactions_custom: [
{ title: 'Explain like I am five', prompt: 'Explain the following text in simple terms.', type: 'chat' }
]
});The following configuration options affect the behavior of the TinyMCE AI plugin.
The chat and review interfaces open as sidebars. From the toolbar or menu, clicking tinymceai-chat opens the chat sidebar; clicking again minimizes it (chat history is preserved). Clicking
tinymceai-review opens the review sidebar.
To toggle sidebars programmatically, use the core ToggleSidebar command:
editor.execCommand('ToggleSidebar', false, 'tinymceai-chat');
editor.execCommand('ToggleSidebar', false, 'tinymceai-review');The following keyboard shortcuts are available for the AI sidebars:
| Action | Windows | macOS |
|---|---|---|
Open or Close the AI Chat sidebar |
Ctrl+J |
Cmd+J |
To show the chat sidebar on load:
tinymce.init({
selector: 'textarea', // change this value according to the HTML
plugins: 'tinymceai',
toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review',
sidebar_show: 'tinymceai-chat',
// Required for authentication
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.json());
}
});The TinyMCE AI plugin provides the following {productname} commands.