Skip to content

Commit c0ce0de

Browse files
committed
DOC-1820: Updated headings and explanation of new content
1 parent f85a78b commit c0ce0de

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

modules/ROOT/examples/live-demos/custom-toolbar-menu-button-search/index.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ tinymce.init({
1313
const allItems = [
1414
{ type: 'menuitem', text: 'Apple', onAction: () => editor.insertContent('Apple') },
1515
{ type: 'menuitem', text: 'Banana', onAction: () => editor.insertContent('Banana') },
16-
{ type: 'togglemenuitem', text: 'Cherry', onAction: () => {
17-
toggleState = !toggleState;
18-
editor.insertContent('Cherry')
19-
20-
},
21-
onSetup: (api) => {
22-
api.setActive(toggleState);
23-
return () => {};
24-
}
25-
}
16+
{ type: 'togglemenuitem', text: 'ToggleableMenu', onAction: () => {
17+
toggleState = !toggleState;
18+
editor.insertContent('ToggleableMenu');
19+
},
20+
onSetup: (api) => {
21+
api.setActive(toggleState);
22+
return () => {};
23+
},
24+
},
2625
];
2726

2827
// Use the `pattern` to filter items

modules/ROOT/pages/custom-menu-toolbar-button.adoc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ include::partial$misc/admon-requires-6.4v.adoc[]
3737
|setIcon |`+(icon: string) => void+` |Sets the icon of the button.
3838
|===
3939

40-
== Menu button example and explanation without search
40+
== Menu button example and explanation without search enabled
4141

4242
The following is a simple toolbar menu button example:
4343

@@ -48,7 +48,7 @@ This example configures a toolbar menu button labeled `+My Button+` that opens a
4848
The `+fetch+` function retrieves an array of menu items and passes it to the callback, which renders them in the dropdown menu. This enables asynchronous menu generation.
4949

5050
[[searchable-menu-buttons]]
51-
== Searchable menu buttons
51+
== Fetch with Searchable menu buttons
5252

5353
include::partial$misc/admon-requires-6.2v.adoc[]
5454

@@ -69,8 +69,8 @@ The following is a simple toolbar menu button example, where searching has been
6969

7070
liveDemo::custom-toolbar-menu-button-search[tab="js"]
7171

72-
This example configures a toolbar menu button with the label `+My searchable button+` that opens the specified menu when clicked. The menu will contain a search input field because `+search+` is not `+false+`. The input field's https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder[placeholder attribute] will be `+Type...+`.
72+
This example configures a toolbar menu button with the label `+Searchable Menu+` that opens the specified menu when clicked. The menu will contain a search input field because `+search+` is not `+false+`. The `+fetch+` function is called with a `+pattern+` being "Search items...". The `+fetchContext+` is set to the `+pattern+` and as `+pattern+` is updated the menu will update. When searching the `+pattern+` is filtered and when the pattern doesn't meet the menuitems the search closes.
7373

74-
Initially, when the menu opens, the search input field will be empty, and the `+fetch+` function is called with an empty `+pattern+` for its `+fetchContext+`. In that situation, `+fetch+` passes back an array of two items to be rendered in the drop-down menu. When the user types in the input field, `+fetch+` will be called again, except this time, the `+pattern+` property in `+fetchContext+` will reflect the value typed in the input field. For illustration purposes, this example then passes back an item that contains this pattern inside the item's text. In a more real-life example, the `+pattern+` could be used to filter which of the items are passed to the callback.
74+
The input field's https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#placeholder[placeholder attribute] will be `+Type...+`.
7575

7676
include::partial$misc/onSetup.adoc[]

0 commit comments

Comments
 (0)