diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/example.js b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/example.js index 1e6f3cbbe6..632c15fa93 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/example.js +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/example.js @@ -5,14 +5,13 @@ const sharedSettings = { height: '400px', plugins: ['tinymceai', 'advlist', 'lists', 'link', 'autolink', 'table', 'wordcount'], toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate | styles | bold italic | bullist numlist | link', - tinymceai_sidebar_type: 'floating', tinymceai_chat_welcome_message: '

Welcome to TinyMCE AI. Pick an action below or type your own prompt.

', tinymceai_chat_welcome_actions: [ { text: 'Here are some actions to get started:' }, { title: 'Summarize the document', command: 'TinyMCEAIQuickActionsSummarize' }, { title: 'Continue writing', command: 'TinyMCEAIQuickActionContinueWriting' }, { title: 'Translate to Spanish', command: 'TinyMCEAIQuickActionTranslate', value: 'spanish' }, - { title: 'Review my document', command: 'ToggleSidebar', value: 'tinymceai-review' } + { title: 'Review my document', command: 'TinyMCEAIToggleApp', value: 'tinymceai-review', icon: 'ai-review' } ], tinymceai_token_provider: async () => { return fetch('/api/tinymceai-token', { credentials: 'include' }) @@ -58,11 +57,12 @@ const sharedSettings = { ] }; -// Group 1: the Introduction and Native integration editors share one AI sidebar. +// Group 1: the Introduction and Native integration editors share AI Chat and AI Review in one panel. tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-introduction', tinymceai_group: 'article-opening', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-opening-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Introduction', tinymceai_document_description: 'The introduction of the article. A title, a short paragraph that sets out the topic, and a figure.' }); @@ -71,15 +71,17 @@ tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-native-integration', tinymceai_group: 'article-opening', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-opening-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Native integration', tinymceai_document_description: 'The section on moving from external AI tools to AI built into the editor, with a bulleted list of benefits.' }); -// Group 2: the Workflow comparison and Adoption challenges editors share a separate AI sidebar and never see the content of group 1. +// Group 2: the Workflow comparison and Adoption challenges editors share a separate panel and never see the content of group 1. tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-workflow-comparison', tinymceai_group: 'article-analysis', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-analysis-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Workflow comparison', tinymceai_document_description: 'The section that compares traditional and AI-enhanced workflows. Keep the comparison table.' }); @@ -88,6 +90,7 @@ tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-adoption-challenges', tinymceai_group: 'article-analysis', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-analysis-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Adoption challenges', tinymceai_document_description: 'The closing section on adoption challenges. Two short paragraphs.' }); diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.html b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.html index a64691acbf..a99124eb07 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.html +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.html @@ -1,7 +1,9 @@ -
+

Group 1: article-opening

-

Introduction (hosts the AI sidebar of group 1)

+

Introduction (first editor of group 1)

+
+
-

Native integration (shares the AI sidebar of group 1)

+

Native integration (second editor of group 1)

+
+
+

Group 2: article-analysis

-

Workflow comparison (hosts the AI sidebar of group 2)

+

Workflow comparison (first editor of group 2)

+
+
-

Adoption challenges (shares the AI sidebar of group 2)

+

Adoption challenges (second editor of group 2)

+
+
+
diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.js b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.js index 5eec82ad4b..a9d525b923 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.js +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor-groups/index.js @@ -54,7 +54,6 @@ const sharedSettings = { 'quickbars', 'tinymceai', 'tinycomments', 'mentions', 'revisionhistory', 'suggestededits', 'uploadcare' ], toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate | styles | bold italic | bullist numlist | link', - tinymceai_sidebar_type: 'floating', quickbars_selection_toolbar: 'tinymceai-quickactions addcomment', tinymceai_chat_welcome_message: '

Welcome to TinyMCE AI. Pick an action below or type your own prompt.

', tinymceai_chat_welcome_actions: [ @@ -62,7 +61,7 @@ const sharedSettings = { { title: 'Summarize the document', command: 'TinyMCEAIQuickActionsSummarize' }, { title: 'Continue writing', command: 'TinyMCEAIQuickActionContinueWriting' }, { title: 'Translate to Spanish', command: 'TinyMCEAIQuickActionTranslate', value: 'spanish' }, - { title: 'Review my document', command: 'ToggleSidebar', value: 'tinymceai-review' } + { title: 'Review my document', command: 'TinyMCEAIToggleApp', value: 'tinymceai-review', icon: 'ai-review' } ], toolbar_mode: 'sliding', visual: false, @@ -126,12 +125,13 @@ const sharedSettings = { ] }; -// Group 1: the Introduction and Native integration editors share one AI sidebar. +// Group 1: the Introduction and Native integration editors share AI Chat and AI Review in one panel. tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-introduction', revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-groups-introduction'), tinymceai_group: 'article-opening', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-opening-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Introduction', tinymceai_document_description: 'The introduction of the article. A title, a short paragraph that sets out the topic, and a figure.' }); @@ -141,16 +141,18 @@ tinymce.init({ selector: 'textarea#tinymceai-multi-editor-groups-native-integration', revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-groups-native-integration'), tinymceai_group: 'article-opening', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-opening-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Native integration', tinymceai_document_description: 'The section on moving from external AI tools to AI built into the editor, with a bulleted list of benefits.' }); -// Group 2: the Workflow comparison and Adoption challenges editors share a separate AI sidebar and never see the content of group 1. +// Group 2: the Workflow comparison and Adoption challenges editors share a separate panel and never see the content of group 1. tinymce.init({ ...sharedSettings, selector: 'textarea#tinymceai-multi-editor-groups-workflow-comparison', revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-groups-workflow-comparison'), tinymceai_group: 'article-analysis', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-analysis-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Workflow comparison', tinymceai_document_description: 'The section that compares traditional and AI-enhanced workflows. Keep the comparison table.' }); @@ -160,6 +162,7 @@ tinymce.init({ selector: 'textarea#tinymceai-multi-editor-groups-adoption-challenges', revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-groups-adoption-challenges'), tinymceai_group: 'article-analysis', + tinymceai_decoupled_container: '#tinymceai-multi-editor-groups-analysis-panel', // Decoupled mode: each group renders AI Chat and AI Review in its own panel. tinymceai_document_name: 'Adoption challenges', tinymceai_document_description: 'The closing section on adoption challenges. Two short paragraphs.' }); diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/example.js b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/example.js index 59f9baea49..ed69220da5 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/example.js +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/example.js @@ -1,18 +1,39 @@ // 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 = { - height: '400px', - plugins: ['tinymceai', 'advlist', 'lists', 'link', 'autolink', 'table', 'wordcount'], - toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate | styles | bold italic | bullist numlist | link', - tinymceai_sidebar_type: 'floating', - tinymceai_chat_welcome_message: '

Welcome to TinyMCE AI. Pick an action below or type your own prompt.

', + 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: '

Hi! I’m your writing assistant.

I can read and write across both sections of this hiring pack — refine the role or generate interview questions.

', + // Every welcome action uses the empty 'no-icon' icon registered in setup, so the buttons show text only. tinymceai_chat_welcome_actions: [ - { text: 'Here are some actions to get started:' }, - { title: 'Summarize the document', command: 'TinyMCEAIQuickActionsSummarize' }, - { title: 'Continue writing', command: 'TinyMCEAIQuickActionContinueWriting' }, - { title: 'Translate to Spanish', command: 'TinyMCEAIQuickActionTranslate', value: 'spanish' }, - { title: 'Review my document', command: 'ToggleSidebar', value: 'tinymceai-review' } + { 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()) @@ -59,16 +80,18 @@ const sharedSettings = { tinymce.init({ ...sharedSettings, - selector: 'textarea#tinymceai-multi-editor-introduction', - tinymceai_group: 'article', - tinymceai_document_name: 'Introduction', - tinymceai_document_description: 'The introduction of the article. A title, a short paragraph that sets out the topic, and a figure.' + 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-body', - tinymceai_group: 'article', - tinymceai_document_name: 'Body', - tinymceai_document_description: 'The main body of the article. Uses h2 and h3 subheadings, short paragraphs, a bulleted list, and a comparison table.' + 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.' }); diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.html b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.html index 6c2a5ef576..d788dbe648 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.html +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.html @@ -1,62 +1,33 @@ -

Introduction (first editor in the group)

- -

Body (shares the AI sidebar with the Introduction)

- +
+
+ diff --git a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.js b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.js index 600056c785..63f55f899e 100644 --- a/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.js +++ b/modules/ROOT/examples/live-demos/tinymceai-multi-editor/index.js @@ -48,22 +48,43 @@ const createRevisionHistoryFetch = (selector) => () => { // Share one TinyMCE AI configuration between every editor in the group. const sharedSettings = { - height: '400px', plugins: [ - 'autolink', 'link', 'emoticons', 'lists', 'table', 'advlist', 'searchreplace', 'wordcount', 'autocorrect', 'tinymcespellchecker', 'charmap', 'fullscreen', 'advcode', 'accordion', 'anchor', 'footnotes', 'powerpaste', 'importword', 'exportpdf', 'exportword', 'markdown', 'a11ychecker', 'typography', 'casechange', 'checklist', 'advtable', 'formatpainter', 'permanentpen', 'tableofcontents', 'help', 'math', 'linkchecker', 'media', 'mediaembed', + 'autolink', 'link', 'emoticons', 'lists', 'table', 'advlist', 'searchreplace', 'autocorrect', 'tinymcespellchecker', 'charmap', 'fullscreen', 'advcode', 'accordion', 'anchor', 'footnotes', 'powerpaste', 'importword', 'exportpdf', 'exportword', 'markdown', 'a11ychecker', 'typography', 'casechange', 'checklist', 'advtable', 'formatpainter', 'permanentpen', 'tableofcontents', 'help', 'math', 'linkchecker', 'media', 'mediaembed', 'quickbars', 'tinymceai', 'tinycomments', 'mentions', 'revisionhistory', 'suggestededits', 'uploadcare' ], - toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate | styles | bold italic | bullist numlist | link', - tinymceai_sidebar_type: 'floating', + toolbar: 'undo redo | tinymceai-chat tinymceai-review ai-quickactions-translate spellchecker | styles | bold italic underline forecolor backcolor casechange | link uploadcare table addcomment | align bullist numlist checklist removeformat | code fullscreen help', + 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', quickbars_selection_toolbar: 'tinymceai-quickactions addcomment', - tinymceai_chat_welcome_message: '

Welcome to TinyMCE AI. Pick an action below or type your own prompt.

', + tinymceai_chat_welcome_message: '

Hi! I’m your writing assistant.

I can read and write across both sections of this hiring pack — refine the role or generate interview questions.

', + // Every welcome action uses the empty 'no-icon' icon registered in setup, so the buttons show text only. tinymceai_chat_welcome_actions: [ - { text: 'Here are some actions to get started:' }, - { title: 'Summarize the document', command: 'TinyMCEAIQuickActionsSummarize' }, - { title: 'Continue writing', command: 'TinyMCEAIQuickActionContinueWriting' }, - { title: 'Translate to Spanish', command: 'TinyMCEAIQuickActionTranslate', value: 'spanish' }, - { title: 'Review my document', command: 'ToggleSidebar', value: 'tinymceai-review' } + { 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', ''); + }, toolbar_mode: 'sliding', visual: false, images_file_types: 'jpeg,jpg,jpe,jfi,jif,jfif,png,gif,bmp,webp,svg', @@ -128,18 +149,20 @@ const sharedSettings = { tinymce.init({ ...sharedSettings, - selector: 'textarea#tinymceai-multi-editor-introduction', - revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-introduction'), - tinymceai_group: 'article', - tinymceai_document_name: 'Introduction', - tinymceai_document_description: 'The introduction of the article. A title, a short paragraph that sets out the topic, and a figure.' + selector: 'textarea#tinymceai-multi-editor-role-description', + height: '270px', + revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-role-description'), + 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-body', - revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-body'), - tinymceai_group: 'article', - tinymceai_document_name: 'Body', - tinymceai_document_description: 'The main body of the article. Uses h2 and h3 subheadings, short paragraphs, a bulleted list, and a comparison table.' + selector: 'textarea#tinymceai-multi-editor-interview-questions', + height: '340px', + revisionhistory_fetch: createRevisionHistoryFetch('textarea#tinymceai-multi-editor-interview-questions'), + 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.' }); diff --git a/modules/ROOT/pages/8.11.0-release-notes.adoc b/modules/ROOT/pages/8.11.0-release-notes.adoc index bb95b7eef7..a87edfcb36 100644 --- a/modules/ROOT/pages/8.11.0-release-notes.adoc +++ b/modules/ROOT/pages/8.11.0-release-notes.adoc @@ -128,7 +128,26 @@ For information on the **Image Editing** plugin, see: xref:editimage.adoc[Image The {productname} {release-version} release includes an accompanying release of the **TinyMCE AI** premium plugin. -**TinyMCE AI** includes the following fixes and additions and improvements. +**TinyMCE AI** includes the following fixe and additions and improvements. + +==== Added new `+tinymceai_decoupled_container+` option to render AI Chat and AI Review in an element provided by a CSS selector +// #TINYMCE-15031 + +Previously, the **TinyMCE AI** plugin always rendered AI Chat and AI Review in an editor sidebar, either static or floating. Applications that have their own panel or layout for the AI interface could not render AI Chat and AI Review there. + +In {productname} {release-version}, the new xref:tinymceai.adoc#tinymceai_decoupled_container[`+tinymceai_decoupled_container+`] option turns on xref:tinymceai.adoc#decoupled-mode[decoupled mode]. The option takes a CSS selector, and the plugin renders AI Chat and AI Review inside the matching element instead of in a sidebar. The new xref:tinymceai.adoc#tinymceai-toggling-apps-decoupled[`+TinyMCEAIToggleApp+`] command opens and closes AI Chat and AI Review in that element, and the matching `+TinyMCEAIToggleApp+` event reports each change. Decoupled mode also works with xref:tinymceai-multi-editor.adoc#decoupled-mode-group[multi-editor groups]. + +==== Added `+tinymceai_decoupled_show+` option to set the initial view +// #TINYMCE-15032 + +In {productname} {release-version}, the new xref:tinymceai.adoc#tinymceai_decoupled_show[`+tinymceai_decoupled_show+`] option opens AI Chat or AI Review in the element set by `+tinymceai_decoupled_container+` when the editor initializes. In decoupled mode, use this option in place of the core xref:customsidebar.adoc#sidebar_show[`+sidebar_show+`] option. + +==== New `+TinyMCEAIPreview+` query command state to check whether an editor has a preview of AI suggestions open +// #TINYMCE-15033 + +Previously, integrations had no public way to check whether an editor showed a preview of AI suggestions that the user had not yet resolved. + +In {productname} {release-version}, `+queryCommandState('TinyMCEAIPreview')+` returns `+true+` while the editor shows a preview of AI suggestions to resolve. For details, see xref:tinymceai.adoc#tinymceai-preview-state[Checking for an open preview]. ==== Adding a corrupt file as a context source now shows a message saying the file could not be processed, instead of the generic upload error // #TINYMCE-14815 diff --git a/modules/ROOT/pages/editor-command-identifiers.adoc b/modules/ROOT/pages/editor-command-identifiers.adoc index bb046e2e29..01a0b7481e 100644 --- a/modules/ROOT/pages/editor-command-identifiers.adoc +++ b/modules/ROOT/pages/editor-command-identifiers.adoc @@ -530,7 +530,7 @@ include::partial$commands/tableofcontents-cmds.adoc[leveloffset=+3] [[tinymceai]] ==== TinyMCE AI -The xref:tinymceai.adoc[TinyMCE AI (`+tinymceai+`)] plugin registers AI Chat and AI Review sidebars, Quick Actions-related editor commands, and uses the core `+ToggleSidebar+` command for sidebar visibility. The following partial covers `+ToggleSidebar+`, floating-sidebar behavior, and plugin command names. +The xref:tinymceai.adoc[TinyMCE AI (`+tinymceai+`)] plugin registers AI Chat and AI Review sidebars, Quick Actions-related editor commands, and uses the core `+ToggleSidebar+` command for sidebar visibility. The following partial covers `+ToggleSidebar+`, floating-sidebar behavior, the `+TinyMCEAIToggleApp+` command for decoupled mode, and plugin command names. include::partial$commands/tinymceai-cmds.adoc[leveloffset=+3] diff --git a/modules/ROOT/pages/tinymceai-multi-editor.adoc b/modules/ROOT/pages/tinymceai-multi-editor.adoc index 417a9fd0fd..50ed50505d 100644 --- a/modules/ROOT/pages/tinymceai-multi-editor.adoc +++ b/modules/ROOT/pages/tinymceai-multi-editor.adoc @@ -8,14 +8,12 @@ include::partial$misc/admon-requires-8.10v.adoc[] -Multi-editor mode groups several {productname} editors on the same page so that they share one Chat sidebar and one Review sidebar. Use multi-editor mode when a page splits related content across several editors, for example a form with separate editors for a summary and a body, or a page that edits several related articles side by side. - -In a group, Chat, Review, and Quick Actions work across the content of every editor. The {pluginname} plugin identifies the content of each editor by name, and previews and applies each change in the editor it belongs to. +Multi-editor mode groups several {productname} 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]] == Demo -The demo below splits an article across an Introduction editor and a Body editor in one group. Select the image:icons-premium/ai-assistant.svg[Chat icon,24px] Chat toolbar button in either editor to open the shared Chat sidebar, which the first editor hosts. Then ask the AI to change both parts of the article, or run a review over both editors. +The demo below groups the two sections of a hiring pack. The group uses xref:tinymceai.adoc#decoupled-mode[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. liveDemo::tinymceai-multi-editor[] @@ -29,6 +27,8 @@ include::partial$misc/admon-inline-not-supported.adoc[] 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 xref:tinymceai.adoc#decoupled-mode[decoupled mode], the first editor of the group hosts AI Chat and AI Review in the element set by its xref:tinymceai.adoc#tinymceai_decoupled_container[`+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]] === Chat @@ -71,16 +71,18 @@ While the {pluginname} plugin previews changes from Chat or Quick Actions, each [[discarding-suggestions]] === Discarding pending suggestions -When any editor in the group has pending suggestions, the {pluginname} 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. +With the floating sidebar, when any editor in the group has pending suggestions, the {pluginname} 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. -If the user confirms, the plugin discards the pending suggestions in every editor of the group and returns each editor to normal editing. If the user cancels, the plugin keeps every preview and pending suggestion. +In xref:tinymceai.adoc#decoupled-mode[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]] == Integration To group editors, load the `+tinymceai+` plugin in each editor and set the same xref:tinymceai.adoc#tinymceai_group[`+tinymceai_group+`] value on each editor in the group. Give each editor a unique xref:tinymceai.adoc#tinymceai_document_name[`+tinymceai_document_name+`] value, and optionally a xref:tinymceai.adoc#tinymceai_document_description[`+tinymceai_document_description+`] value that describes the content to the AI. -Multi-editor mode is supported with the floating sidebar. Set xref:tinymceai.adoc#tinymceai_sidebar_type[`+tinymceai_sidebar_type+`] to `+'floating'+` for every editor in the group. +The floating sidebar and xref:tinymceai.adoc#decoupled-mode[decoupled mode] both support multi-editor mode. For the floating sidebar, set xref:tinymceai.adoc#tinymceai_sidebar_type[`+tinymceai_sidebar_type+`] to `+'floating'+` for every editor in the group. For decoupled mode, see xref:#decoupled-mode-group[Grouped editors in decoupled mode]. Use the same {pluginname} configuration for every editor in a group, for example by sharing a settings object between the `+tinymce.init+` calls: @@ -116,10 +118,57 @@ Grouped editors must be on the same page and use the same `+tinymce+` instance. For information about installing the plugin and enabling AI features, see xref:tinymceai.adoc[Plugin Reference]. +[[decoupled-mode-group]] +=== Grouped editors in decoupled mode + +include::partial$misc/admon-requires-8.11v.adoc[] + +To use xref:tinymceai.adoc#decoupled-mode[decoupled mode] with a group, add one element for the group to the page and set xref:tinymceai.adoc#tinymceai_decoupled_container[`+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 xref:tinymceai.adoc#tinymceai_decoupled_show[`+tinymceai_decoupled_show+`]. + +[source,html] +---- +
+
+ + +
+
+
+---- + +[source,js] +---- +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 xref:tinymceai.adoc#tinymceai-toggling-apps-decoupled[`+TinyMCEAIToggleApp+`]. + [[multiple-groups]] === Multiple groups on one page -A page can contain several independent groups, each with a different xref:tinymceai.adoc#tinymceai_group[`+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. For a configuration with two groups, see the xref:tinymceai.adoc#tinymceai_group[two-group example]. +A page can contain several independent groups, each with a different xref:tinymceai.adoc#tinymceai_group[`+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 xref:tinymceai.adoc#tinymceai_decoupled_container[`+tinymceai_decoupled_container+`] value for each group. For a configuration with two groups, see the xref:tinymceai.adoc#tinymceai_group[two-group example]. [[configuration]] == Configuration diff --git a/modules/ROOT/pages/tinymceai.adoc b/modules/ROOT/pages/tinymceai.adoc index e32c5937d1..8c4c929993 100644 --- a/modules/ROOT/pages/tinymceai.adoc +++ b/modules/ROOT/pages/tinymceai.adoc @@ -155,6 +155,52 @@ tinymce.init({ }); ---- +[[decoupled-mode]] +== Decoupled mode + +include::partial$misc/admon-requires-8.11v.adoc[] + +By default, AI Chat and AI Review open in an editor sidebar. In decoupled mode, the two apps, AI Chat and AI Review, render inside an element on the page instead, outside the editor. Use decoupled mode to place the AI interface in a panel or layout that the application provides. + +To turn on decoupled mode, set xref:#tinymceai_decoupled_container[`+tinymceai_decoupled_container+`] to a CSS selector that matches one element on the page, and give that element a width and a height. The plugin does not add a border around AI Chat and AI Review in decoupled mode. To separate the apps from the rest of the page, add a border to the element. To open AI Chat or AI Review when the editor initializes, set xref:#tinymceai_decoupled_show[`+tinymceai_decoupled_show+`]. + +[source,html] +---- +
+
+ +
+
+
+---- + +[source,js] +---- +tinymce.init({ + selector: 'textarea#editor', // change this value according to the HTML + plugins: 'tinymceai', + toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', + 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.json()); + } +}); +---- + +In decoupled mode: + +* The `+tinymceai-chat+` and `+tinymceai-review+` toolbar buttons and menu items open and close AI Chat and AI Review in the element. +* The xref:#keyboard-shortcuts[keyboard shortcuts], pressed in the editor, open the matching app or move focus to it when it is already open. Pressed inside an open app, the shortcut for that app closes it and returns focus to the editor. +* The element shows one app at a time. When one app opens, the plugin hides the other. +* The plugin keeps the state of a closed app, so reopening AI Chat shows the same conversation. +* When the user switches from one app to the other, the plugin stops any request in progress in the hidden app and discards any pending AI suggestions. +* Chat and review commands, such as `+TinyMCEAIChatPrompt+` and `+TinyMCEAIReviewProofread+`, open the matching app in the element. +* Use the xref:#tinymceai-toggling-apps-decoupled[`+TinyMCEAIToggleApp+`] command and the xref:#tinymceai_decoupled_show[`+tinymceai_decoupled_show+`] option in place of the core `+ToggleSidebar+` command and the xref:customsidebar.adoc#sidebar_show[`+sidebar_show+`] option. + +For a xref:tinymceai-multi-editor.adoc[multi-editor group] in decoupled mode, see xref:tinymceai-multi-editor.adoc#decoupled-mode-group[Grouped editors in decoupled mode]. + [[commands]] == Commands diff --git a/modules/ROOT/partials/commands/tinymceai-cmds.adoc b/modules/ROOT/partials/commands/tinymceai-cmds.adoc index eb52df3e80..d8bfcfa03f 100644 --- a/modules/ROOT/partials/commands/tinymceai-cmds.adoc +++ b/modules/ROOT/partials/commands/tinymceai-cmds.adoc @@ -19,7 +19,59 @@ tinymce.activeEditor.execCommand('ToggleSidebar', false, 'tinymceai-chat'); tinymce.activeEditor.execCommand('ToggleSidebar', false, 'tinymceai-review'); ---- -NOTE: These commands work regardless of xref:tinymceai.adoc#tinymceai_sidebar_type[`tinymceai_sidebar_type`] (`+'static'+` or `+'floating'+`). The `+ToggleSidebar+` event and `+queryCommandValue('ToggleSidebar')+` also behave the same for both sidebar types. +NOTE: These commands work regardless of xref:tinymceai.adoc#tinymceai_sidebar_type[`tinymceai_sidebar_type`] (`+'static'+` or `+'floating'+`). The `+ToggleSidebar+` event and `+queryCommandValue('ToggleSidebar')+` also behave the same for both sidebar types. In xref:tinymceai.adoc#decoupled-mode[decoupled mode], use the <> command instead. + +[[tinymceai-toggling-apps-decoupled]] +== Toggling AI Chat and AI Review in decoupled mode + +include::partial$misc/admon-requires-8.11v.adoc[] + +In xref:tinymceai.adoc#decoupled-mode[decoupled mode], the `+TinyMCEAIToggleApp+` command opens or closes AI Chat or AI Review in the element set by xref:tinymceai.adoc#tinymceai_decoupled_container[`+tinymceai_decoupled_container+`]. The plugin registers this command only in decoupled mode. Pass the app identifier as the third argument: + +[cols="1,3",options="header"] +|=== +|Value |Effect +|`+'tinymceai-chat'+` |Opens AI Chat, or closes it when it is already open. +|`+'tinymceai-review'+` |Opens AI Review, or closes it when it is already open. +|Any other value |Does nothing. The value is case sensitive, so a missing value, an empty string, an unknown identifier, or different capitalization has no effect. +|=== + +`+queryCommandValue('TinyMCEAIToggleApp')+` returns the identifier of the open app, or an empty string when neither app is open. It is the decoupled mode equivalent of `+queryCommandValue('ToggleSidebar')+`. + +Each time `+TinyMCEAIToggleApp+` runs with a valid value, the editor fires a `+TinyMCEAIToggleApp+` event, whether the command opens, closes, or switches an app. The event has no data. To read the new state, call `+queryCommandValue('TinyMCEAIToggleApp')+` in the event handler. The editor does not fire the event for the app opened by xref:tinymceai.adoc#tinymceai_decoupled_show[`+tinymceai_decoupled_show+`]. + +In a xref:tinymceai-multi-editor.adoc[multi-editor group], the plugin registers the command and fires the event on the first editor created in the group. Run the command, query the value, and listen for the event on that editor. + +.Examples +[source,js] +---- +// Open AI Review, or close it if it is already open +tinymce.activeEditor.execCommand('TinyMCEAIToggleApp', false, 'tinymceai-review'); + +// Returns 'tinymceai-chat', 'tinymceai-review', or '' when neither app is open +tinymce.activeEditor.queryCommandValue('TinyMCEAIToggleApp'); +---- + +.Example: showing an application panel only while an app is open +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to the HTML + plugins: 'tinymceai', + toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', + tinymceai_decoupled_container: '#ai-panel', // change this value according to the HTML + // Required for authentication + tinymceai_token_provider: () => { + return fetch('/api/token').then(r => r.json()); + }, + setup: (editor) => { + editor.on('TinyMCEAIToggleApp', () => { + const openApp = editor.queryCommandValue('TinyMCEAIToggleApp'); + document.querySelector('#ai-panel').classList.toggle('is-open', openApp !== ''); + }); + } +}); +---- [[tinymceai-plugin-commands]] == TinyMCE AI plugin commands @@ -95,6 +147,22 @@ tinymce.activeEditor.execCommand('TinyMCEAIReviewProofread'); tinymce.activeEditor.execCommand('TinyMCEAIReviewToneProfessional'); ---- +[[tinymceai-preview-state]] +=== Checking for an open preview + +include::partial$misc/admon-requires-8.11v.adoc[] + +`+queryCommandState('TinyMCEAIPreview')+` returns `+true+` when the editor shows a preview of AI suggestions that the user has not yet resolved, and `+false+` otherwise. A preview that is still loading does not count, and the state returns to `+false+` after the user applies or discards the suggestions. + +In a xref:tinymceai-multi-editor.adoc[multi-editor group], each editor reports only its own preview. To check whether any editor in a group shows a preview, query each editor in the group. + +[source,js] +---- +if (tinymce.activeEditor.queryCommandState('TinyMCEAIPreview')) { + console.log('The editor has AI suggestions to resolve.'); +} +---- + [[tinymceai-review-custom-values]] === Values for `+TinyMCEAIReviewCustom+` diff --git a/modules/ROOT/partials/configuration/tinymceai_options.adoc b/modules/ROOT/partials/configuration/tinymceai_options.adoc index de47fe6964..56375d93af 100644 --- a/modules/ROOT/partials/configuration/tinymceai_options.adoc +++ b/modules/ROOT/partials/configuration/tinymceai_options.adoc @@ -152,6 +152,74 @@ tinymce.init({ Changing this property dynamically (after the editor has been initialized) is not supported and can result in unpredictable behavior. ==== +[[tinymceai_decoupled_container]] +=== `+tinymceai_decoupled_container+` + +include::partial$misc/admon-requires-8.11v.adoc[] + +Turns on xref:tinymceai.adoc#decoupled-mode[decoupled mode]. The value is a CSS selector that must match exactly one element on the page. AI Chat and AI Review render inside that element instead of in an editor sidebar. + +When this option is set, the plugin registers no AI sidebars and ignores the xref:tinymceai.adoc#tinymceai_sidebar_type[`+tinymceai_sidebar_type+`] option. When the selector matches no element, matches more than one element, or is not a valid CSS selector, {productname} logs a warning to the browser console and the plugin does not render AI Chat or AI Review. + +The element must be on the page when the editor initializes. When the editor is removed, the plugin removes AI Chat and AI Review from the element, and the element stays on the page. + +For grouped editors, see xref:tinymceai-multi-editor.adoc#decoupled-mode-group[Grouped editors in decoupled mode]. + +*Type:* `+String+` + +*Default value:* `+undefined+` + +.Example +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to the HTML + plugins: 'tinymceai', + toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', + tinymceai_decoupled_container: '#ai-panel', // change this value according to the HTML + // Required for authentication + tinymceai_token_provider: () => { + return fetch('/api/token').then(r => r.json()); + } +}); +---- + +[NOTE] +==== +Set this option in the initial configuration of the editor. Changing this option after the editor initializes is not supported. +==== + +[[tinymceai_decoupled_show]] +=== `+tinymceai_decoupled_show+` + +include::partial$misc/admon-requires-8.11v.adoc[] + +Opens AI Chat or AI Review in the element set by xref:tinymceai.adoc#tinymceai_decoupled_container[`+tinymceai_decoupled_container+`] when the editor initializes. This option is the decoupled mode equivalent of the core xref:customsidebar.adoc#sidebar_show[`+sidebar_show+`] option. + +The value is case insensitive. When the value is not valid, {productname} logs a warning to the browser console and the plugin opens neither app. The plugin ignores this option when `+tinymceai_decoupled_container+` is not set. + +*Type:* `+String+` + +*Possible values:* `+'tinymceai-chat'+`, `+'tinymceai-review'+` + +*Default value:* `+undefined+` + +.Example +[source,js] +---- +tinymce.init({ + selector: 'textarea', // change this value according to the HTML + plugins: 'tinymceai', + toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', + 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.json()); + } +}); +---- + [[tinymceai_default_model]] === `+tinymceai_default_model+` @@ -370,9 +438,9 @@ Each item in the array is one of the following: * A `+String+`, or an object with a `+text+` property (`+{ text: 'string' }+`), shown as descriptive text. * An action object, shown as a clickable button, with the following properties: ** `+title+` (`+String+`): The label shown on the button. -** `+command+` (`+String+`): The editor command run when the button is selected. The command runs without moving focus into the editor, so the editor scroll position is preserved. This can be a Quick Action or Chat command, the core `+ToggleSidebar+` command, or any other registered editor command, such as `+Bold+`. For the AI command names, see xref:editor-command-identifiers.adoc#tinymceai[TinyMCE AI]. -** `+value+` (optional): The argument passed to the command. The accepted value matches the command, for example a language label for `+TinyMCEAIQuickActionTranslate+`, a `+{ prompt, displayedPrompt }+` object for `+TinyMCEAIChatPrompt+`, or a sidebar name such as `+'tinymceai-review'+` for `+ToggleSidebar+`. -** `+icon+` (optional `+String+`): The name of the icon shown on the button, using any editor icon identifier. When omitted, an icon is selected automatically based on the command. +** `+command+` (`+String+`): The editor command run when the button is selected. The command runs without moving focus into the editor, so the editor scroll position is preserved. This can be a Quick Action or Chat command, the core `+ToggleSidebar+` command (or `+TinyMCEAIToggleApp+` in xref:tinymceai.adoc#decoupled-mode[decoupled mode]), or any other registered editor command, such as `+Bold+`. For the AI command names, see xref:editor-command-identifiers.adoc#tinymceai[TinyMCE AI]. +** `+value+` (optional): The argument passed to the command. The accepted value matches the command, for example a language label for `+TinyMCEAIQuickActionTranslate+`, a `+{ prompt, displayedPrompt }+` object for `+TinyMCEAIChatPrompt+`, or an identifier such as `+'tinymceai-review'+` for `+ToggleSidebar+` or `+TinyMCEAIToggleApp+`. +** `+icon+` (optional `+String+`): The name of the icon shown on the button, using any editor icon identifier. When omitted, an icon is selected automatically based on the command. For a `+ToggleSidebar+` action, the automatic icon matches the sidebar. For a `+TinyMCEAIToggleApp+` action, set `+icon+`, for example to `+'ai-review'+`, because the automatic icon does not match the app. Text items and action buttons can be interleaved to group related actions under short headings. @@ -902,7 +970,7 @@ include::partial$misc/admon-requires-8.10v.adoc[] [[tinymceai_group]] === `+tinymceai_group+` -Adds the editor to a named group. Editors on the same page with the same `+tinymceai_group+` value share one Chat sidebar and one Review sidebar. In a group, Chat, Review, and Quick Actions work across the content of every editor. The editor created first in the group hosts the shared sidebars. +Adds the editor to a named group. Editors on the same page with the same `+tinymceai_group+` value share one Chat sidebar and one Review sidebar. In a group, Chat, Review, and Quick Actions work across the content of every editor. The editor created first in the group hosts the shared sidebars, or the shared AI Chat and AI Review in xref:tinymceai.adoc#decoupled-mode[decoupled mode]. The plugin uses the group name only to match editors, and never shows the name to users or sends it to the AI service. A page can contain several independent groups, each with a different name. Editors in one group never receive content from another group.