Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modules/ROOT/pages/8.9.0-release-notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,27 @@ The {productname} {release-version} release includes an accompanying release of

For information on the **<Premium plugin name 1>** plugin, see: xref:<plugincode>.adoc[<Premium plugin name 1>].

=== TinyMCE AI

The {productname} {release-version} release includes an accompanying release of the **TinyMCE AI** premium plugin.

**TinyMCE AI** includes the following addition.

==== 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 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].

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
Expand Down
2 changes: 2 additions & 0 deletions modules/ROOT/pages/tinymceai-chat.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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, 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]
----
tinymce.init({
Expand Down
54 changes: 50 additions & 4 deletions modules/ROOT/partials/configuration/tinymceai_options.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Array>+`)
* 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<Array | Object>+`)

*Possible Values:* For source `+type+` property: `+'web-resource'+`, `+'file'+`

*Default value:* `+() => Promise.resolve([])+`

.Example
.Example: populating the sources menu
[source,js]
----
tinymce.init({
Expand Down Expand Up @@ -218,6 +229,41 @@ tinymce.init({
});
----

.Example: nominating default sources
[source,js]
----
tinymce.init({
selector: 'textarea',
plugins: 'tinymceai',
toolbar: 'tinymceai-chat tinymceai-quickactions tinymceai-review',
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();
const filename = `\$\{id\}.pdf`;
return { type: 'file', file: new File([blob], filename, { type: blob.type }) };
},
// Required for authentication
tinymceai_token_provider: () => {
return fetch('/api/token').then(r => r.json());
}
});
----

[[tinymceai_chat_fetch_source]]
=== `+tinymceai_chat_fetch_source+`

Expand Down
Loading