From 94755c59f359b4387a093427323fd99617c0b476 Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Tue, 11 Aug 2026 12:16:42 +1000 Subject: [PATCH 1/2] TINYDOC-3570 - Add the tinymceai_chat_default_sources option and its 8.9.0 release note Documents the new TinyMCE AI chat option and adds the accompanying release note entry for the 8.9.0 release. Covers TINYDOC-3561 (option reference section) and TINYMCE-14703. --- modules/ROOT/pages/8.9.0-release-notes.adoc | 17 +++++++ modules/ROOT/pages/tinymceai-chat.adoc | 2 + modules/ROOT/pages/tinymceai.adoc | 1 + .../configuration/tinymceai_options.adoc | 44 +++++++++++++++++++ 4 files changed, 64 insertions(+) diff --git a/modules/ROOT/pages/8.9.0-release-notes.adoc b/modules/ROOT/pages/8.9.0-release-notes.adoc index 30243b6272..ff106eb7af 100644 --- a/modules/ROOT/pages/8.9.0-release-notes.adoc +++ b/modules/ROOT/pages/8.9.0-release-notes.adoc @@ -71,6 +71,23 @@ The {productname} {release-version} release includes an accompanying release of For information on the **** plugin, see: xref:.adoc[]. +=== TinyMCE AI + +The {productname} {release-version} release includes an accompanying release of the **TinyMCE AI** premium plugin. + +**TinyMCE AI** includes the following addition. + +==== New option `tinymceai_chat_default_sources` to allow specifying predefined sources as chat default context. +// #TINYMCE-14703 + +Previously, the **TinyMCE AI** plugin applied only the current document to the context of a new AI Chat conversation. Users had to add every other context source, such as a style guide or a reference document, to each new conversation by hand. + +In {productname} {release-version}, the **TinyMCE AI** plugin supports the xref:tinymceai.adoc#tinymceai_chat_default_sources[`+tinymceai_chat_default_sources+`] option. The option accepts an array of source identifiers taken from the list supplied by xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`+tinymceai_chat_fetch_sources+`], and the plugin applies those sources to the context of every new conversation. Users can remove a default source from a conversation and add it again from the sources menu. + +For details on configuring conversation context, see xref:tinymceai-chat.adoc#context-configuration[Adding custom context sources]. + +For information on the **TinyMCE AI** plugin, see: xref:tinymceai.adoc[TinyMCE AI]. + [[accompanying-premium-plugin-end-of-life-announcement]] == Accompanying Premium plugin end-of-life announcement diff --git a/modules/ROOT/pages/tinymceai-chat.adoc b/modules/ROOT/pages/tinymceai-chat.adoc index efdf9b5e29..08b8202db6 100644 --- a/modules/ROOT/pages/tinymceai-chat.adoc +++ b/modules/ROOT/pages/tinymceai-chat.adoc @@ -160,6 +160,8 @@ To add custom external sources for users to select from, configure: Full schemas, return types, and examples are documented under xref:tinymceai.adoc#tinymceai_chat_fetch_sources[Chat configuration options]. +To apply a custom source to every new conversation without requiring users to select it, list its ID in xref:tinymceai.adoc#tinymceai_chat_default_sources[`tinymceai_chat_default_sources`]. + [source,js] ---- tinymce.init({ diff --git a/modules/ROOT/pages/tinymceai.adoc b/modules/ROOT/pages/tinymceai.adoc index b32c601b9b..06f1e5e67b 100644 --- a/modules/ROOT/pages/tinymceai.adoc +++ b/modules/ROOT/pages/tinymceai.adoc @@ -98,6 +98,7 @@ tinymce.init({ const filename = `\$\{id\}.pdf`; return { type: 'file', file: new File([blob], filename, { type: blob.type }) }; }, + tinymceai_chat_default_sources: [ 'doc-1' ], tinymceai_quickactions_custom: [ { title: 'Explain like I am five', prompt: 'Explain the following text in simple terms.', type: 'chat' } ] diff --git a/modules/ROOT/partials/configuration/tinymceai_options.adoc b/modules/ROOT/partials/configuration/tinymceai_options.adoc index 49d736a774..4b744b692e 100644 --- a/modules/ROOT/partials/configuration/tinymceai_options.adoc +++ b/modules/ROOT/partials/configuration/tinymceai_options.adoc @@ -252,6 +252,50 @@ tinymce.init({ }); ---- +[[tinymceai_chat_default_sources]] +=== `+tinymceai_chat_default_sources+` + +Adds one or more sources to the context of every new chat conversation, alongside the current document. Without this option, users add each source to a conversation themselves. + +Takes an array of source identifiers. Each identifier is the `+id+` of a source supplied by xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`tinymceai_chat_fetch_sources`], and the content of each source is loaded through xref:tinymceai.adoc#tinymceai_chat_fetch_source[`tinymceai_chat_fetch_source`]. Identifiers that do not match a supplied source are ignored. + +Users can remove a default source from a conversation and add it again from the sources menu. + +*Type:* `+Array+` (`+string[]+`) + +*Default value:* `+[]+` + +.Example +[source,js] +---- +tinymce.init({ + selector: 'textarea', + plugins: 'tinymceai', + toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', + tinymceai_chat_fetch_sources: async () => [ + { + label: 'My Documents', + icon: 'folder', + sources: [ + { id: 'doc-1', label: 'Style guide', type: 'file' }, + { id: 'doc-2', label: 'Document 2', type: 'file' } + ] + } + ], + 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_chat_default_sources: [ 'doc-1' ], + // Required for authentication + tinymceai_token_provider: () => { + return fetch('/api/token').then(r => r.json()); + } +}); +---- + [[tinymceai_chat_welcome_message]] === `+tinymceai_chat_welcome_message+` From 3248b71c97086414567ee6e1bd71cf54b34f48b5 Mon Sep 17 00:00:00 2001 From: Karl Kemister-Sheppard Date: Thu, 20 Aug 2026 15:39:00 +1000 Subject: [PATCH 2/2] TINYDOC-3570: The tinymceai_chat_fetch_sources option can now nominate default sources for chat conversations. --- modules/ROOT/pages/8.9.0-release-notes.adoc | 10 ++- modules/ROOT/pages/tinymceai-chat.adoc | 2 +- modules/ROOT/pages/tinymceai.adoc | 1 - .../configuration/tinymceai_options.adoc | 74 ++++++++++--------- 4 files changed, 46 insertions(+), 41 deletions(-) diff --git a/modules/ROOT/pages/8.9.0-release-notes.adoc b/modules/ROOT/pages/8.9.0-release-notes.adoc index ff106eb7af..3dd02b98f2 100644 --- a/modules/ROOT/pages/8.9.0-release-notes.adoc +++ b/modules/ROOT/pages/8.9.0-release-notes.adoc @@ -77,12 +77,16 @@ The {productname} {release-version} release includes an accompanying release of **TinyMCE AI** includes the following addition. -==== New option `tinymceai_chat_default_sources` to allow specifying predefined sources as chat default context. -// #TINYMCE-14703 +==== The `tinymceai_chat_fetch_sources` option can now nominate default sources for chat conversations. +// #TINYMCE-14777 Previously, the **TinyMCE AI** plugin applied only the current document to the context of a new AI Chat conversation. Users had to add every other context source, such as a style guide or a reference document, to each new conversation by hand. -In {productname} {release-version}, the **TinyMCE AI** plugin supports the xref:tinymceai.adoc#tinymceai_chat_default_sources[`+tinymceai_chat_default_sources+`] option. The option accepts an array of source identifiers taken from the list supplied by xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`+tinymceai_chat_fetch_sources+`], and the plugin applies those sources to the context of every new conversation. Users can remove a default source from a conversation and add it again from the sources menu. +In {productname} {release-version}, the function supplied to xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`+tinymceai_chat_fetch_sources+`] can resolve to an object with a `+menu+` property, holding the source groups shown in the sources menu, and a `+defaults+` property, holding an array of source identifiers. The plugin adds each source listed in `+defaults+` to the context of every new conversation, and shows it as selected in the sources menu. Users can remove a default source from a conversation and add it again from the sources menu. + +Identifiers listed in `+defaults+` without a matching source in `+menu.sources+` are not added to the context, and the plugin reports them as an error in the browser console. + +The option continues to accept a function that resolves to an array of source groups, so existing configurations are unaffected. For details on configuring conversation context, see xref:tinymceai-chat.adoc#context-configuration[Adding custom context sources]. diff --git a/modules/ROOT/pages/tinymceai-chat.adoc b/modules/ROOT/pages/tinymceai-chat.adoc index 08b8202db6..50558d1a41 100644 --- a/modules/ROOT/pages/tinymceai-chat.adoc +++ b/modules/ROOT/pages/tinymceai-chat.adoc @@ -160,7 +160,7 @@ To add custom external sources for users to select from, configure: Full schemas, return types, and examples are documented under xref:tinymceai.adoc#tinymceai_chat_fetch_sources[Chat configuration options]. -To apply a custom source to every new conversation without requiring users to select it, list its ID in xref:tinymceai.adoc#tinymceai_chat_default_sources[`tinymceai_chat_default_sources`]. +To apply a custom source to every new conversation without requiring users to select it, return an object from xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`+tinymceai_chat_fetch_sources+`] and list the source ID in its `+defaults+` property. [source,js] ---- diff --git a/modules/ROOT/pages/tinymceai.adoc b/modules/ROOT/pages/tinymceai.adoc index 06f1e5e67b..b32c601b9b 100644 --- a/modules/ROOT/pages/tinymceai.adoc +++ b/modules/ROOT/pages/tinymceai.adoc @@ -98,7 +98,6 @@ tinymce.init({ const filename = `\$\{id\}.pdf`; return { type: 'file', file: new File([blob], filename, { type: blob.type }) }; }, - tinymceai_chat_default_sources: [ 'doc-1' ], tinymceai_quickactions_custom: [ { title: 'Explain like I am five', prompt: 'Explain the following text in simple terms.', type: 'chat' } ] diff --git a/modules/ROOT/partials/configuration/tinymceai_options.adoc b/modules/ROOT/partials/configuration/tinymceai_options.adoc index 4b744b692e..cf0dbb176e 100644 --- a/modules/ROOT/partials/configuration/tinymceai_options.adoc +++ b/modules/ROOT/partials/configuration/tinymceai_options.adoc @@ -178,17 +178,28 @@ These options configure the AI Chat sidebar, where users have interactive conver [[tinymceai_chat_fetch_sources]] === `+tinymceai_chat_fetch_sources+` -Populates the sources menu with submenus of files and web resources. Users can select these sources as additional context for chat conversations. +Populates the sources menu with submenus of files and web resources. Users can select these sources as additional context for chat conversations. The option can also nominate default sources, which the {pluginname} plugin adds to the context of every new conversation. -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`]. +Takes a function that returns a Promise resolving to either of the following: -*Type:* `+Function+` (`+() => Promise+`) +* An array of source groups. +* An object with a `+menu+` property, holding the array of source groups as `+menu.sources+`, and a `+defaults+` property, holding an array of source identifiers. + +Each source 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`]. + +Both shapes are supported. Returning an array populates the sources menu without nominating any default sources. + +Each identifier listed in `+defaults+` must match the `+id+` of a source listed in `+menu.sources+`. The plugin adds each matching source to the context of every new conversation, and shows it as selected in the sources menu. Identifiers without a matching source are not added to the context, and the plugin reports them as an error in the browser console. Users can remove a default source from a conversation and add it again from the sources menu. + +If `+menu.sources+` is missing or empty, the plugin reports an error in the browser console and populates no sources. + +*Type:* `+Function+` (`+() => Promise+`) *Possible Values:* For source `+type+` property: `+'web-resource'+`, `+'file'+` *Default value:* `+() => Promise.resolve([])+` -.Example +.Example: populating the sources menu [source,js] ---- tinymce.init({ @@ -218,27 +229,28 @@ tinymce.init({ }); ---- -[[tinymceai_chat_fetch_source]] -=== `+tinymceai_chat_fetch_source+` - -A function that fetches the content for an additional source by ID. Receives the source `+id+` and returns a Promise resolving to the source content (either `+{ type: 'file', file: File }+` or `+{ type: 'web-resource', url: string }+`). The content is passed to the AI agent as additional context for the chat conversation. - -*Type:* `+Function+` (`+(id: string) => Promise+`) - -*Possible Values:* For return object `+type+` property: `+'file'+`, `+'web-resource'+` - -*Default value:* `+(id) => Promise.resolve(\`Should fetch additional source with given \$\{id\}\`)+` - -.Example +.Example: nominating default sources [source,js] ---- tinymce.init({ selector: 'textarea', plugins: 'tinymceai', toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', - tinymceai_chat_fetch_sources: async () => [ - { label: 'Docs', sources: [{ id: 'doc-1', label: 'Document 1', type: 'file' }] } - ], + tinymceai_chat_fetch_sources: async () => ({ + defaults: [ 'doc-1' ], + menu: { + sources: [ + { + label: 'My Documents', + icon: 'folder', + sources: [ + { id: 'doc-1', label: 'Style guide', 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(); @@ -252,18 +264,16 @@ tinymce.init({ }); ---- -[[tinymceai_chat_default_sources]] -=== `+tinymceai_chat_default_sources+` - -Adds one or more sources to the context of every new chat conversation, alongside the current document. Without this option, users add each source to a conversation themselves. +[[tinymceai_chat_fetch_source]] +=== `+tinymceai_chat_fetch_source+` -Takes an array of source identifiers. Each identifier is the `+id+` of a source supplied by xref:tinymceai.adoc#tinymceai_chat_fetch_sources[`tinymceai_chat_fetch_sources`], and the content of each source is loaded through xref:tinymceai.adoc#tinymceai_chat_fetch_source[`tinymceai_chat_fetch_source`]. Identifiers that do not match a supplied source are ignored. +A function that fetches the content for an additional source by ID. Receives the source `+id+` and returns a Promise resolving to the source content (either `+{ type: 'file', file: File }+` or `+{ type: 'web-resource', url: string }+`). The content is passed to the AI agent as additional context for the chat conversation. -Users can remove a default source from a conversation and add it again from the sources menu. +*Type:* `+Function+` (`+(id: string) => Promise+`) -*Type:* `+Array+` (`+string[]+`) +*Possible Values:* For return object `+type+` property: `+'file'+`, `+'web-resource'+` -*Default value:* `+[]+` +*Default value:* `+(id) => Promise.resolve(\`Should fetch additional source with given \$\{id\}\`)+` .Example [source,js] @@ -273,14 +283,7 @@ tinymce.init({ plugins: 'tinymceai', toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review', tinymceai_chat_fetch_sources: async () => [ - { - label: 'My Documents', - icon: 'folder', - sources: [ - { id: 'doc-1', label: 'Style guide', type: 'file' }, - { id: 'doc-2', label: 'Document 2', type: 'file' } - ] - } + { label: 'Docs', sources: [{ id: 'doc-1', label: 'Document 1', type: 'file' }] } ], tinymceai_chat_fetch_source: async (id) => { const res = await fetch(`/api/documents/\$\{id\}`); @@ -288,7 +291,6 @@ tinymce.init({ const filename = `\$\{id\}.pdf`; return { type: 'file', file: new File([blob], filename, { type: blob.type }) }; }, - tinymceai_chat_default_sources: [ 'doc-1' ], // Required for authentication tinymceai_token_provider: () => { return fetch('/api/token').then(r => r.json());