Skip to content

Commit 57673c4

Browse files
committed
DOC-2578: Add Labels and Groups for Context Toolbar Buttons.
1 parent 5a98843 commit 57673c4

File tree

5 files changed

+106
-2
lines changed

5 files changed

+106
-2
lines changed

antora.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ asciidoc:
1010
companyurl: https://www.tiny.cloud
1111
cdnurl: https://cdn.tiny.cloud/1/no-api-key/tinymce/7/tinymce.min.js
1212
tdcdnurl: https://cdn.tiny.cloud/1/_your_api_key_/tinydrive/7/tinydrive.min.js
13-
tinymce_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/7/tinymce.min.js
13+
tinymce_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinymce/7-dev/tinymce.min.js
1414
tinydrive_live_demo_url: https://cdn.tiny.cloud/1/qagffr3pkuv17a8on1afax661irst1hbr4e6tbv888sz91jc/tinydrive/7/tinydrive.min.js
1515
webcomponent_url: https://cdn.jsdelivr.net/npm/@tinymce/tinymce-webcomponent@2/dist/tinymce-webcomponent.min.js
1616
jquery_url: https://cdn.jsdelivr.net/npm/@tinymce/tinymce-jquery@2/dist/tinymce-jquery.min.js
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<textarea id="context-toolbar-labels">
2+
<p>Clicking on the example image below will show the newly configured context toolbar.</p>
3+
4+
{{logofordemoshtml}}
5+
6+
<p>Select a word in this sentence, to see the other newly configured context toolbar.</p>
7+
8+
<p>Clicking on text should not invoke the context toolbar</p>
9+
</textarea>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
tinymce.init({
2+
selector: 'textarea#context-toolbar-labels',
3+
height: 350,
4+
setup: (editor) => {
5+
editor.ui.registry.addContextToolbar('imagealignment', {
6+
predicate: (node) => node.nodeName.toLowerCase() === 'img',
7+
position: 'node',
8+
scope: 'node',
9+
items: [
10+
{
11+
name: 'Formatting',
12+
items: ['alignleft', 'aligncenter', 'alignright']
13+
},
14+
{
15+
label: 'Copy',
16+
items: ['copy', 'paste']
17+
}
18+
],
19+
});
20+
21+
editor.ui.registry.addContextToolbar('textselection', {
22+
predicate: (node) => !editor.selection.isCollapsed(),
23+
position: 'selection',
24+
scope: 'node',
25+
items: [
26+
{
27+
name: 'Format',
28+
items: ['bold', 'italic', 'underline']
29+
},
30+
],
31+
});
32+
},
33+
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
34+
});

modules/ROOT/pages/7.6.0-release-notes.adoc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,33 @@ For information on using Enhanced Skins & Icon Packs, see: xref:enhanced-skins-a
213213
=== <TINY-vwxyz 1 changelog entry>
214214
// #TINY-vwxyz1
215215

216-
== New `+disabled+` option for disabling all user interactions
216+
=== Add Labels and Groups for Context Toolbar Buttons
217+
// #TINY-11095
218+
219+
The release of {productname} {release-version} introduces the ability to organize context toolbar buttons into groups with optional labels or titles. This enhancement, available from {productname} 7.6.0 onward, improves toolbar usability by enabling clearer categorization of buttons.
220+
221+
The `items` object structure now supports defining groups with an optional `name` property for titles or a `label` property for identifying the group. This feature allows developers to create more intuitive and accessible toolbars by visually segmenting functionality.
222+
223+
Example of a context toolbar configuration with groups and labels:
224+
225+
.Example
226+
[source,js]
227+
----
228+
items: [
229+
{
230+
name: 'Formatting', // Optional, used as the group's title
231+
items: [ 'bold', 'italic' ] // Array of registered button names
232+
},
233+
{
234+
label: 'History', // Optional, used as a label for the group
235+
items: [ 'undo', 'redo' ] // Array of registered button names
236+
},
237+
]
238+
----
239+
240+
For more details on configuring context toolbar groups and labels, see: xref:contexttoolbar.adoc#add-labels-and-groups-for-context-toolbar-buttons[Context Toolbar].
241+
242+
=== New `+disabled+` option for disabling all user interactions
217243

218244
A new `+disabled+` option has been introduced to {productname} in version {release-version}. This option allows integrators to disable all user interactions with the editor, including cursor placement, content modifications, and UI components. When set to `+true+`, the editor behaves similarly to the readonly mode changes introduced in {productname} 7.4.0 but ensures complete non-interactivity.
219245

modules/ROOT/pages/contexttoolbar.adoc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,41 @@ This example shows how the quickbars plugin adds the standard selection context
2727

2828
liveDemo::context-toolbar[height="600", tab="js"]
2929

30+
[[add-labels-and-groups-for-context-toolbar-buttons]]
31+
== Add labels and groups for context toolbar buttons
32+
33+
From {productname} 7.6.0 onward, registering a context toolbar allows specifying `items` as an object that supports grouping with optional names and labels. This improvement enhances toolbar usability by organizing buttons into titled or labeled groups.
34+
35+
The object structure takes two optional properties: `name` and `label`.
36+
37+
* `name`: property is used as the group's title for the group that contains the buttons.
38+
* `label`: property is used as a label for each group of buttons.
39+
40+
[NOTE]
41+
If neither `name` nor `label` is specified, the behavior defaults to ungrouped buttons.
42+
43+
The object structure for `items` is as follows:
44+
45+
.Example of a context toolbar configuration with groups and labels
46+
[source,js]
47+
----
48+
items: [
49+
{
50+
name: 'Formatting', // Optional, used as the group's title
51+
items: [ 'bold', 'italic' ] // Array of registered button names
52+
},
53+
{
54+
label: 'History', // Optional, used as a label for the group
55+
items: [ 'undo', 'redo' ] // Array of registered button names
56+
},
57+
{
58+
items: [ 'undo', 'italic' ] // No name or label specified, default behavior applies
59+
}
60+
]
61+
----
62+
63+
liveDemo::context-toolbar-labels[height="600", tab="js"]
64+
3065
== Launching a context toolbar programmatically
3166

3267
There is an `+editor+` event called `+contexttoolbar-show+` that can be fired to show a context toolbar at the current selection. The event takes a parameter `+toolbarKey+` which specifies the name of the registered context form or context toolbar to show.

0 commit comments

Comments
 (0)