@@ -264,6 +264,84 @@ If you have a custom skin, rebuild it using the {productname} {productmajorversi
264264* [ ] Test your custom skin with split buttons in {productname} {productmajorversion}.
265265* [ ] Refer to xref:creating-a-skin.adoc[Creating a Skin] for details.
266266
267+ **Code examples**
268+
269+ .Before: {productname} {productmajorversion}.
270+ [source,js]
271+ ----
272+ tinymce.init({
273+ selector: 'textarea#custom-toolbar-split-button',
274+ toolbar: 'myButton',
275+ menubar: false,
276+ setup: (editor) => {
277+ editor.ui.registry.addSplitButton('myButton', {
278+ text: 'My Button',
279+ icon: 'info',
280+ tooltip: 'This is an example split-button',
281+ onAction: () => editor.insertContent('<p>You clicked the main button</p>'),
282+ onItemAction: (api, value) => editor.insertContent(value),
283+ fetch: (callback) => {
284+ const items = [
285+ {
286+ type: 'choiceitem',
287+ icon: 'notice',
288+ text: 'Menu item 1',
289+ value: ' <em>You clicked menu item 1!</em>'
290+ },
291+ {
292+ type: 'choiceitem',
293+ icon: 'warning',
294+ text: 'Menu item 2',
295+ value: ' <em>You clicked menu item 2!</em>'
296+ }
297+ ];
298+ callback(items);
299+ }
300+ });
301+ },
302+ content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
303+ });
304+ ----
305+
306+ .Migrating to {productname} {productmajorversion}
307+ [source,js]
308+ ----
309+ tinymce.init({
310+ selector: 'textarea',
311+ toolbar: 'myButton',
312+ menubar: false,
313+ setup: (editor) => {
314+ editor.ui.registry.addSplitButton('myButton', {
315+ text: 'My Button',
316+ icon: 'info',
317+ tooltip: 'Execute my action',
318+ chevronTooltip: 'My Button menu options',
319+ onAction: () => editor.insertContent('<p>You clicked the main button</p>'),
320+ onItemAction: (api, value) => editor.insertContent(value),
321+ fetch: (callback) => {
322+ const items = [
323+ {
324+ type: 'choiceitem',
325+ icon: 'notice',
326+ text: 'Menu item 1',
327+ value: ' <em>You clicked menu item 1!</em>'
328+ },
329+ {
330+ type: 'choiceitem',
331+ icon: 'warning',
332+ text: 'Menu item 2',
333+ value: ' <em>You clicked menu item 2!</em>'
334+ }
335+ ];
336+ callback(items);
337+ }
338+ });
339+ },
340+ content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:16px }'
341+ });
342+ ----
343+
344+
267345== Core API Changes
268346
269347[discrete]
0 commit comments