Skip to content

Commit 6217680

Browse files
authored
DOC-2217: Update ai_shortcut documentation with selection property and changes to default value. (#2997)
* DOC-2217: Update shortcut docs * DOC-2217: Additional docs fixes * DOC-2217: Fix broken include
1 parent 674ae32 commit 6217680

File tree

3 files changed

+58
-28
lines changed

3 files changed

+58
-28
lines changed

modules/ROOT/pages/dialog-footer-buttons.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ NOTE: Dialog footer buttons are different to xref:dialog-components.adoc#button[
1616
|text |string |required |Text to display in the button if `+icon+` is not specified. Also used for the button's `+title+` attribute.
1717
|name |string |optional |An identifier for the button. If not specified, the button will be assigned a randomly generated `+name+`.
1818
|icon |string |optional |
19-
include::partial$misc/admon-predefined-icons-only.adoc[] *When configured, the button will display the icon instead of text.*
19+
include::partial$misc/admon-predefined-icons-only.adoc[]
20+
*When configured, the button will display the icon instead of text.*
2021
|buttonType |`+'primary'+`, or `+'secondary'+` |optional |default: `+'secondary'+` - Whether to style the button as a primary, or secondary button.
2122
|enabled |boolean |optional |default: `+true+` - When `+false+`, the button will be disabled when the dialog loads.
2223
|align |`+'end'+` or `+'start'+` |optional |default: `+'end'+` - When set to `+'end'+` the button will display on the right-hand side of the dialog. When set to `+'start'+` the button will display on the left-hand side.

modules/ROOT/partials/configuration/ai_request.adoc

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ tinymce.init({
4040
return [];
4141
}
4242
});
43+
44+
// System messages provided by the plugin to format the output as HTML content.
45+
const pluginSystemMessages = request.system.map((content) => ({
46+
role: 'system',
47+
content
48+
}));
49+
50+
const systemMessages = [
51+
...pluginSystemMessages,
52+
// Additional system messages to control the output of the AI
53+
{ role: 'system', content: 'Remove lines with ``` from the response start and response end.' }
54+
]
4355
4456
// Forms the new query sent to the API
4557
const content = request.context.length === 0 || conversation.length > 0
@@ -48,7 +60,7 @@ tinymce.init({
4860
4961
const messages = [
5062
...conversation,
51-
{ role: 'system', content: request.system.join('\n') },
63+
...systemMessages,
5264
{ role: 'user', content }
5365
];
5466
@@ -116,7 +128,7 @@ tinymce.init({
116128
onerror
117129
})
118130
)
119-
.then((response) => {
131+
.then(async (response) => {
120132
if (response && !response.ok) {
121133
const data = await response.json();
122134
if (data.error) {

modules/ROOT/partials/configuration/ai_shortcuts.adoc

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ When configured with an instance-specific object array, the {pluginname} shortcu
1919
[source, js]
2020
----
2121
[
22-
{ title: 'Summarize content', prompt: 'Provide the key points and concepts in this content in a succinct summary.' },
23-
{ title: 'Improve writing', prompt: 'Rewrite this content with no spelling mistakes, proper grammar, and with more descriptive language, using best writing practices without losing the original meaning.' },
24-
{ title: 'Simplify language', prompt: 'Rewrite this content with simplified language and reduce the complexity of the writing, so that the content is easier to understand.' },
25-
{ title: 'Expand upon', prompt: 'Expand upon this content with descriptive language and more detailed explanations, to make the writing easier to understand and increase the length of the content.' },
26-
{ title: 'Trim content', prompt: 'Remove any repetitive, redundant, or non-essential writing in this content without changing the meaning or losing any key information.' },
22+
{ title: 'Summarize content', prompt: 'Provide the key points and concepts in this content in a succinct summary.', selection: true },
23+
{ title: 'Improve writing', prompt: 'Rewrite this content with no spelling mistakes, proper grammar, and with more descriptive language, using best writing practices without losing the original meaning.', selection: true },
24+
{ title: 'Simplify language', prompt: 'Rewrite this content with simplified language and reduce the complexity of the writing, so that the content is easier to understand.', selection: true },
25+
{ title: 'Expand upon', prompt: 'Expand upon this content with descriptive language and more detailed explanations, to make the writing easier to understand and increase the length of the content.', selection: true },
26+
{ title: 'Trim content', prompt: 'Remove any repetitive, redundant, or non-essential writing in this content without changing the meaning or losing any key information.', selection: true },
2727
{ title: 'Change tone', subprompts: [
28-
{ title: 'Professional', prompt: 'Rewrite this content using polished, formal, and respectful language to convey professional expertise and competence.' },
29-
{ title: 'Casual', prompt: 'Rewrite this content with casual, informal language to convey a casual conversation with a real person.' },
30-
{ title: 'Direct', prompt: 'Rewrite this content with direct language using only the essential information.' },
31-
{ title: 'Confident', prompt: 'Rewrite this content using compelling, optimistic language to convey confidence in the writing.' },
32-
{ title: 'Friendly', prompt: 'Rewrite this content using friendly, comforting language, to convey understanding and empathy.' },
28+
{ title: 'Professional', prompt: 'Rewrite this content using polished, formal, and respectful language to convey professional expertise and competence.', selection: true },
29+
{ title: 'Casual', prompt: 'Rewrite this content with casual, informal language to convey a casual conversation with a real person.', selection: true },
30+
{ title: 'Direct', prompt: 'Rewrite this content with direct language using only the essential information.', selection: true },
31+
{ title: 'Confident', prompt: 'Rewrite this content using compelling, optimistic language to convey confidence in the writing.', selection: true },
32+
{ title: 'Friendly', prompt: 'Rewrite this content using friendly, comforting language, to convey understanding and empathy.', selection: true },
3333
] },
3434
{ title: 'Change style', subprompts: [
35-
{ title: 'Business', prompt: 'Rewrite this content as a business professional with formal language.' },
36-
{ title: 'Legal', prompt: 'Rewrite this content as a legal professional using valid legal terminology.' },
37-
{ title: 'Journalism', prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.' },
38-
{ title: 'Medical', prompt: 'Rewrite this content as a medical professional using valid medical terminology.' },
39-
{ title: 'Poetic', prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.' },
40-
] },
35+
{ title: 'Business', prompt: 'Rewrite this content as a business professional with formal language.', selection: true },
36+
{ title: 'Legal', prompt: 'Rewrite this content as a legal professional using valid legal terminology.', selection: true },
37+
{ title: 'Journalism', prompt: 'Rewrite this content as a journalist using engaging language to convey the importance of the information.', selection: true },
38+
{ title: 'Medical', prompt: 'Rewrite this content as a medical professional using valid medical terminology.', selection: true },
39+
{ title: 'Poetic', prompt: 'Rewrite this content as a poem using poetic techniques without losing the original meaning.', selection: true },
40+
] }
4141
]
4242
----
4343

@@ -59,18 +59,18 @@ tinymce.init({
5959
toolbar: 'aidialog aishortcuts',
6060
ai_request: (request, respondWith) => respondWith.string(() => Promise.reject("See docs to implement AI Assistant")),
6161
ai_shortcuts: [
62-
{ title: 'Screenplay', prompt: 'Convert this to screenplay format.' },
63-
{ title: 'Stage play', prompt: 'Convert this to stage play format.' },
62+
{ title: 'Screenplay', prompt: 'Convert this to screenplay format.', selection: true },
63+
{ title: 'Stage play', prompt: 'Convert this to stage play format.', selection: true },
6464
{ title: 'Classical', subprompts:
6565
[
66-
{ title: 'Dialogue', prompt: 'Convert this to a Socratic dialogue.' },
67-
{ title: 'Homeric', prompt: 'Convert this to a Classical Epic.' }
66+
{ title: 'Dialogue', prompt: 'Convert this to a Socratic dialogue.', selection: true },
67+
{ title: 'Homeric', prompt: 'Convert this to a Classical Epic.', selection: true }
6868
]
6969
},
7070
{ title: 'Celtic', subprompts:
7171
[
72-
{ title: 'Bardic', prompt: 'Convert this to Bardic verse.' },
73-
{ title: 'Filí', prompt: 'Convert this to Filí-an verse.' }
72+
{ title: 'Bardic', prompt: 'Convert this to Bardic verse.', selection: true },
73+
{ title: 'Filí', prompt: 'Convert this to Filí-an verse.', selection: true }
7474
]
7575
},
7676
]
@@ -99,14 +99,31 @@ tinymce.init({
9999

100100
=== Valid Shortcuts
101101

102-
Valid shortcut objects contain the following fields.
102+
Valid shortcut objects contain the following properties.
103103

104104
`+title+`:: A string which is displayed in the `+aishortcuts+` toolbar button and menu item. This will indicate which shortcut is used, or which category of shortcuts are in this menu.
105105

106106
And either
107107

108-
`+prompt+`:: A string containing the query which is given to the `+ai_request+` function when the shortcut is used.
108+
`+subprompts+`:: An array containing more valid shortcut objects. This allows shortcuts to be grouped into categories within the {pluginname} shortcuts toolbar button and menu item.
109109

110110
or
111111

112-
`+subprompts+`:: An array containing more valid shortcut objects. This allows shortcuts to be grouped into categories within the {pluginname} shortcuts toolbar button and menu item.
112+
`+prompt+`:: A string containing the query which is given to the `+ai_request+` function when the shortcut is used.
113+
114+
115+
==== The `+selection+` property
116+
117+
include::partial$misc/admon-requires-6.8v.adoc[]
118+
119+
Shortcut objects with the `+prompt+` property may also contain the following optional property.
120+
121+
`+selection+`:: A boolean value which will match to the current selection and set the enabled state of the shortcut. When `+selection+` is:
122+
123+
* `+true+`: The shortcut will _only_ be enabled when the user _has_ made a selection in the editor.
124+
125+
* `+false+`: The shortcut will _only_ be enabled when the user _has not_ made a selection in the editor.
126+
127+
* `+undefined+`, or _not set_: The shortcut will always be enabled.
128+
129+
This property allows the definition of shortcuts which should only operate when the user has selected content, requiring the selection as context to the AI when the property is `+true+`. Additionally, shortcuts which are intended to generate specific content will not be enabled with any selection when the property if `+false+`.

0 commit comments

Comments
 (0)