diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..6c7da08 --- /dev/null +++ b/src/index.js @@ -0,0 +1,63 @@ +/* global tinymce */ + +tinymce.PluginManager.add('index', function (editor, url) { + const openDialog = function () { + return editor.windowManager.open({ + title: 'Index', + body: { + type: 'panel', + items: [ + { + type: 'htmlpanel', + html: '

Aggiungendo un index, tutte le intestazioni (H1, H2, H3… H6) verranno inserite automaticamente all’interno di una lista non ordinata. Assicurati che le intestazioni seguano sempre l’ordine corretto.

' + } + ] + }, + buttons: [ + { + type: 'cancel', + text: 'Close' + }, + { + type: 'submit', + text: 'Add Index', + primary: true + } + ], + onSubmit: function (api) { + editor.insertContent('[index]') + api.close() + } + }) + } + + /* Add a button icon */ + editor.ui.registry.addIcon('index', '') + + /* Add a button that opens a window */ + editor.ui.registry.addButton('index', { + icon: 'index', + tooltip: 'Add index', + onAction: function () { + /* Open window */ + openDialog() + } + }) + /* Adds a menu item, which can then be included in any menu via the menu/menubar configuration */ + editor.ui.registry.addMenuItem('index', { + text: 'Index', + onAction: function () { + /* Open window */ + openDialog() + } + }) + /* Return the metadata for the help plugin */ + return { + getMetadata: function () { + return { + name: 'Index Shortcode', + url: 'https://github.com/The-3Labs-Team/tinymce-laravel-shortcode-plus' + } + } + } +}) diff --git a/src/shortcodeList.js b/src/shortcodeList.js index 02521af..17d1dfa 100644 --- a/src/shortcodeList.js +++ b/src/shortcodeList.js @@ -22,6 +22,11 @@ tinymce.PluginManager.add('shortcodeList', function (editor, url) { code: '[button link="https://www.your-link.com" label="Add a label" level="primary|secondary"]', description: 'Insert a button' }, + { + title: 'Index', + code: '[index]', + description: 'Insert an index to the article' + }, { title: 'Widgetbay', code: '[widgetbay id="optional" link="optional"]',