-
Notifications
You must be signed in to change notification settings - Fork 220
DOC-3468 - Document TinyMCE AI 8.5 custom reviews, commands, and quickbars integration #4070
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/8.5.0/DOC-3355
Are you sure you want to change the base?
Changes from all commits
86bd142
8c99741
62ec64f
01b2946
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| [[tinymceai-toggling-sidebars]] | ||
| .Toggling the AI Chat and AI Review sidebars | ||
| === Toggling the AI Chat and AI Review sidebars | ||
|
|
||
| AI Chat and AI Review use sidebars registered by the plugin. To show or hide them programmatically, use the core `+ToggleSidebar+` command (listed in the xref:editor-command-identifiers.adoc#miscellaneous-core-commands[Miscellaneous Core Commands] table), not a command defined by the TinyMCE AI plugin. Pass the sidebar identifier as the third argument: | ||
| AI Chat and AI Review use sidebars registered by the plugin. To show or hide them programmatically, use the core `+ToggleSidebar+` command (listed in the xref:editor-command-identifiers.adoc#miscellaneous-core-commands[Miscellaneous Core Commands] table), not a command defined by the `+tinymceai+` plugin. Pass the sidebar identifier as the third argument: | ||
|
|
||
| * `+'tinymceai-chat'+` — AI Chat | ||
| * `+'tinymceai-review'+` — AI Review | ||
|
|
@@ -18,3 +18,60 @@ tinymce.activeEditor.execCommand('ToggleSidebar', false, 'tinymceai-chat'); | |
| // Open the AI Review sidebar | ||
| tinymce.activeEditor.execCommand('ToggleSidebar', false, 'tinymceai-review'); | ||
| ---- | ||
|
|
||
| [[tinymceai-floating-sidebar-api]] | ||
| === Floating sidebar and `+ToggleSidebar+` | ||
|
|
||
| When xref:tinymceai.adoc#tinymceai_sidebar_type[`tinymceai_sidebar_type`] is `+'floating'+`, the core `+ToggleSidebar+` command, the `+ToggleSidebar+` event, and `+queryCommandValue('ToggleSidebar')+` work the same as for a static sidebar for `+'tinymceai-chat'+` and `+'tinymceai-review'+`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we even need to include this info I treated it more like a bug that we didn't fully support this API but maybe we could have general notes or some example on how to deal with these events and the query state in general not specifically for floating sidebars? |
||
|
|
||
| [[tinymceai-plugin-commands]] | ||
| === TinyMCE AI plugin commands | ||
|
|
||
| The xref:tinymceai.adoc[`tinymceai`] plugin registers the following editor commands. They mirror the Quick Actions and related UI: each invocation returns immediately while the plugin performs any network and UI work asynchronously. | ||
|
|
||
| [cols="2,2,3",options="header"] | ||
| |=== | ||
| |Command |Third argument |Description | ||
|
|
||
| |`+TinyMCEAIQuickActionImproveWriting+` | |Runs the **Improve writing** quick action. | ||
| |`+TinyMCEAIQuickActionContinueWriting+` | |Runs the **Continue writing** quick action. | ||
| |`+TinyMCEAIQuickActionCheckGrammar+` | |Runs the **Fix grammar** quick action. | ||
| |`+TinyMCEAIQuickActionMakeShorter+` | |Runs **Make shorter**. | ||
| |`+TinyMCEAIQuickActionMakeLonger+` | |Runs **Make longer**. | ||
| |`+TinyMCEAIQuickActionToneCasual+` | |Runs **More casual** tone. | ||
| |`+TinyMCEAIQuickActionToneDirect+` | |Runs **More direct** tone. | ||
| |`+TinyMCEAIQuickActionToneFriendly+` | |Runs **More friendly** tone. | ||
| |`+TinyMCEAIQuickActionToneConfident+` | |Runs **More confident** tone. | ||
| |`+TinyMCEAIQuickActionToneProfessional+` | |Runs **More professional** tone. | ||
| |`+TinyMCEAIQuickActionTranslate+` |`+string+` |Runs **Translate** with the given language label (same string family as xref:tinymceai.adoc#tinymceai_languages[`tinymceai_languages`] `+language+` values). | ||
| |`+TinyMCEAIQuickActionCustom+` |`+{ prompt, model }+` |Runs a custom quick action with the given prompt and model (same behavior as xref:tinymceai.adoc#tinymceai_quickactions_custom[`tinymceai_quickactions_custom`] preview actions). | ||
| |`+TinyMCEAIQuickActionsExplain+` | |Opens Chat with the built-in **Explain** prompt. | ||
| |`+TinyMCEAIQuickActionsSummarize+` | |Opens Chat with the built-in **Summarize** prompt. | ||
| |`+TinyMCEAIQuickActionsHighlightKeyPoints+` | |Opens Chat with the built-in **Highlight key points** prompt. | ||
| |`+TinyMCEAIChatPrompt+` |`+{ prompt, displayedPrompt? }+` |Opens the Chat sidebar if needed, then sends `+prompt+` to the back end. Optional `+displayedPrompt+` controls the label shown in the chat UI when it differs from the text sent to the model. | ||
| |=== | ||
|
|
||
| [NOTE] | ||
| ==== | ||
| Command names use the `+TinyMCEAIQuickActions…+` prefix (with an `+s+`) for **Explain**, **Summarize**, and **Highlight key points** — these map to the xref:tinymceai.adoc#tinymceai_quickactions_chat_prompts[chat prompts] submenu, not to standalone `+TinyMCEAIQuickAction…+` spellings. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, right I wonder if this will be confusing not to have the s suffix but then again executing a command like |
||
| ==== | ||
|
|
||
| .Example: translate and custom quick action | ||
| [source,js] | ||
| ---- | ||
| tinymce.activeEditor.execCommand('TinyMCEAIQuickActionTranslate', false, 'swedish'); | ||
|
|
||
| tinymce.activeEditor.execCommand('TinyMCEAIQuickActionCustom', false, { | ||
| prompt: 'Uppercase text', | ||
| model: 'gpt-4.1' | ||
| }); | ||
| ---- | ||
|
|
||
| .Example: chat prompt with a shorter label in the UI | ||
| [source,js] | ||
| ---- | ||
| tinymce.activeEditor.execCommand('TinyMCEAIChatPrompt', false, { | ||
| prompt: 'Explain the current selection in Klingon', | ||
| displayedPrompt: 'Explain' | ||
| }); | ||
| ---- | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,7 +180,7 @@ These options configure the AI Chat sidebar, where users have interactive conver | |
|
|
||
| Populates the sources menu with submenus of files and web resources. Users can select these sources as additional context for chat conversations. | ||
|
|
||
| Takes a function that returns a Promise resolving to an array of additional context source groups. Each group has `+label+`, optional `+icon+`, and `+sources+` array. Each source has `+id+`, `+label+`, and `+type+` (`+'web-resource'+` or `+'file'+`). A source's `+id+` is used to fetch its content via xref:tinymceai.adoc#tinymceai_chat_fetch_source[`tinymceai_chat_fetch_source`]. | ||
| Takes a function that returns a Promise resolving to an array of additional context source groups. Each group has `+label+`, optional `+icon+`, and `+sources+` array. Each source has `+id+`, `+label+`, and `+type+` (`+'web-resource'+` or `+'file'+`). A source's `+id+` is used to fetch its content through xref:tinymceai.adoc#tinymceai_chat_fetch_source[`tinymceai_chat_fetch_source`]. | ||
|
|
||
| *Type:* `+Function+` (`+() => Promise<Array>+`) | ||
|
|
||
|
|
@@ -255,7 +255,7 @@ tinymce.init({ | |
| [[tinymceai_chat_welcome_message]] | ||
| === `+tinymceai_chat_welcome_message+` | ||
|
|
||
| Customises the welcome message displayed in the Chat sidebar when starting a new conversation. | ||
| Customizes the welcome message displayed in the Chat sidebar when starting a new conversation. | ||
|
|
||
| *Type:* `+String+` | ||
|
|
||
|
|
@@ -440,6 +440,7 @@ Array of custom actions rendered in the Custom submenu within the AI Quick Actio | |
| * `+prompt+`: The prompt sent to the AI | ||
| * `+type+`: `+'action'+` or `+'chat'+` | ||
| * `+model+`: Required for `+action+` type only | ||
| * `+id+` (optional): Stable identifier for the custom action. When set, the same string can be listed in xref:tinymceai.adoc#tinymceai_quickactions_menu[`tinymceai_quickactions_menu`] so the action appears as its own top-level menu item instead of only inside the Custom submenu. The identifier can also be used in xref:quickbars.adoc#quickbars_selection_toolbar[`+quickbars_selection_toolbar+`], the xref:menus-configuration-options.adoc#menu[`+menu+`] option, or any other toolbar or menu configuration that accepts control identifiers. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually only menu items. So the |
||
|
|
||
| *Type:* `+Array+` of `+Object+` | ||
|
|
||
|
|
@@ -474,6 +475,40 @@ tinymce.init({ | |
| }); | ||
| ---- | ||
|
|
||
| .Example: custom actions as top-level Quick Actions menu items using `+id+` | ||
| [source,js] | ||
| ---- | ||
| tinymce.init({ | ||
| selector: 'textarea', | ||
| plugins: 'quickbars tinymceai', | ||
| toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', | ||
| quickbars_selection_toolbar: 'tinymceai-quickactions | bold italic', | ||
| tinymceai_quickactions_menu: [ | ||
| 'ai-quickactions-chat-prompts', | ||
| 'ai-quote', | ||
| 'ai-summarize' | ||
| ], | ||
| tinymceai_quickactions_custom: [ | ||
| { | ||
| id: 'ai-quote', | ||
| title: 'Add a quote from a famous person', | ||
| prompt: 'Add a quote from a known person, which would make sense in the context of the selected text.', | ||
| type: 'action', | ||
| model: 'gemini-2-5-flash' | ||
| }, | ||
| { | ||
| id: 'ai-summarize', | ||
| title: 'Summarize in 5 bullet points', | ||
| prompt: 'Summarize the selected text in 5 bullet points.', | ||
| type: 'chat' | ||
| } | ||
| ], | ||
| tinymceai_token_provider: () => { | ||
| return fetch('/api/token').then(r => r.json()); | ||
| } | ||
| }); | ||
| ---- | ||
|
|
||
| [[options-review]] | ||
| == Options for Review | ||
|
|
||
|
|
@@ -493,6 +528,9 @@ Array of review command IDs that define which review types appear in the Review | |
| * `+'ai-reviews-improve-readability'+`: Adjust sentence structure and word choice | ||
| * `+'ai-reviews-change-length'+`: Shorten or lengthen text | ||
| * `+'ai-reviews-change-tone'+`: Modify tone and style | ||
| * `+'ai-reviews-custom'+`: xref:tinymceai-review.adoc#custom-review-choose-review[Custom review] — accepts a prompt and model, then runs the same streaming preview and apply flow as other reviews | ||
|
|
||
| To hide Custom review from the Review sidebar, omit `+'ai-reviews-custom'+` from the array. | ||
|
|
||
| *Default value:* | ||
| [source,js] | ||
|
|
@@ -502,7 +540,8 @@ Array of review command IDs that define which review types appear in the Review | |
| 'ai-reviews-improve-clarity', | ||
| 'ai-reviews-improve-readability', | ||
| 'ai-reviews-change-length', | ||
| 'ai-reviews-change-tone' | ||
| 'ai-reviews-change-tone', | ||
| 'ai-reviews-custom' | ||
| ] | ||
| ---- | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.