(function () {
    tinymce.create('tinymce.plugins.pmsinsertshortcode', {
        init: function (editor, url) {

            // Add button and functionality
            editor.addButton('pwdms_shrtcd', {
                text: 'PWDMS', // Button text
                selector: "textarea",  // This is unnecessary as TinyMCE buttons are not typically added to textareas directly
                title: 'Insert password table shortcode', // Button tooltip
                icon: false,  // No icon
                id: 'pwdms_shrtcd_btn',

                onclick: function () {
                    // Insert the shortcode at the current cursor position
                    editor.selection.setContent('[pms_pass cat_name=""]');
                }
            });

        }
    });

    // Register the plugin with TinyMCE
    tinymce.PluginManager.add('pmsinsertshortcode', tinymce.plugins.pmsinsertshortcode);
})();
