Create a new TinyMCE plugin template that incorporates a category dropdown list feature

Currently, I am in the process of developing an external template manager using ASP.net for my company.

This template manager allows users to perform all CRUD actions, including create, read, update, and delete.

Various departments within the organization utilize these templates, so I have incorporated a category field in the template manager to facilitate filtering.

My goal is to enhance the template plugin by modifying the plugin.js file to include a dynamic listbox category feature.

This way, when a user attempts to add a template in the editor, they can select their department [category], and only relevant templates will be displayed in the listbox [template].

All template definitions [title, content, description, category] are retrieved from an MS SQL DB using an ASP repeater Control.

The result generated by the repeater provides the necessary template plugin definition:

templates:
[
{"title": "Some title 1", "description": "Some desc 1", "content": "My 
content", "category": "support"},
]

I made an attempt (though not proficient in JS and Object-oriented programming) :


win = editor.windowManager.open({
    title: 'Insert template',
    layout: 'flex',
    direction: 'column',
    align: 'stretch',
    padding: 15,
    spacing: 10,
    items: [
        {
            type: 'form', flex: 0, padding: 0, items: [
                {
                    type: 'container', label: 'Templates', items: {
                        type: 'listbox', label: 'Templates', name: 'template', 
values: values, onselect: onSelectTemplate
                    },
                    //Added BY ME
                    type: 'container', label: 'Category', items: {
                        type: 'listbox', label: 'Category', name: 'category', 
values: valuesCategory, onselect: onSelectCategory
                    }
                }
            ]
        },
        { type: 'label', name: 'description', label: 'Description', text: 
'\u00a0' },
        { type: 'iframe', flex: 1, border: 1 }
    ],

    onsubmit: function () {
        insertTemplate(false, templateHtml);
    },

    minWidth: Math.min(DOMUtils.DOM.getViewPort().w, 
editor.getParam('template_popup_width', 600)),
    minHeight: Math.min(DOMUtils.DOM.getViewPort().h, 
editor.getParam('template_popup_height', 500))
});

win.find('listbox')[0].fire('select');
win.find('listbox')[0].fire('select');

I have defined valuesCategory & onSelectCategory elsewhere in the code.

However, the list box does not appear in the dialog. I have searched online for similar solutions with TinyMCE but have not found anything relevant. Can someone assist me in implementing this functionality?

Thank you for your input!

Wishing you a great day ahead!

Answer №1

Have you considered calculating the appropriate plugins on the server side and adding only relevant templates to the editor configuration instead of making changes directly to the source code?

This approach prevents the necessity of altering the editor's source code and ensures that users are only able to access templates specific to their department.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I'm stuck on finding the solution for PROJECT EULER P4

Challenge 4 Palindrome numbers read the same forwards and backwards. The largest palindrome that can be formed by multiplying two 3-digit numbers is 9009 = 91 × 99. Your task is to find the largest palindrome made from the product of two 3-digit numbers. ...

The npm module parsing has encountered an error... It appears that a suitable loader is required to process this file format

Recently, I made changes to an open-source code that was working perfectly until yesterday. I can't seem to figure out what went wrong as I didn't make any significant changes. Despite searching on Stack Overflow for a similar issue, my lack of k ...

ShaderMaterial does not support textures when replicating MeshLambertMaterial

It came to my attention that THREE.js utilizes shaders internally for creating core material like "e.g. MeshLambertMaterial". Intrigued by this, I decided to replicate the lambert shader from Three.js code into a new shader and expand upon it. Below is th ...

Double-tap bug with Image Picker in Typescript React Native (non-expo)

Well, here’s the situation - some good news and some bad news. First, the good news is that the code below is functioning smoothly. Now, the not-so-good news is that I find myself having to select the image twice before it actually shows up on the clie ...

Inspect all checkboxes created by JavaScript

I'm attempting to develop a checkall checkbox that will automatically select all the checkboxes I've created using JavaScript. Firstly, I gather the number of rows and columns from the user and then use JavaScript to generate a table and insert ...

The feature for automatically hiding other dropdowns when one is open is not functioning properly

Trying to finalize a mega menu that almost works. I need help with closing all other open mega menus when a user clicks on one. Check out the JavaScript code snippet I've written below. The mega menu currently toggles correctly, but it doesn't h ...

Tips for Managing the Hardware Back Button in Ionic 3

Can someone help me enable the hardware back button in Ionic 3? I want it to redirect to specific pages and display designated content. Being new to Ionic 3, I need guidance on how to set up the hardware device buttons for redirection. ...

Information bubble from HERE Maps -

Currently, I am integrating HereMap into my Vue.js application. You can find the code for implementing HereMap in Vue.js here. Next, I need to add an InfoBubble to this map using the code available here. However, I encounter a problem where the InfoBubbl ...

Finding the location of PIE.htc in the Firebug tool

After encountering issues with CSS3 properties not working on IE 7 and IE 8, I decided to include PIE.HTC. Visit this link for more information Upon viewing the page in IE, I realized that the CSS3 properties were not being applied as expected. I attempt ...

What is the method for transforming the date format (Friday June 22 2018 14:37:47 GMT+0530 (India Standard Time)) to DD-MM-YYYY?

When using the material-ui/DatePicker, the date is displayed in full format, but I only need the DD-MM-YYYY format. import DatePicker from 'material-ui/DatePicker'; This is the datepicker component: <DatePicker hintText="" formatDate= ...

Guide to utilizing Vue.js method functions to add a thousand separator in the passed props

As a beginner in Vue.js, I am trying to add a thousand separator to the price passed as a prop using a method called 'thousandSeparator'. However, I am having trouble figuring out how to implement this. I have managed to parse the props price, b ...

Tips for delaying code execution until environment variables are fully loaded in Node.js/TypeScript/JavaScript

Purpose: ensure slack credentials are loaded into env vars prior to server launch. Here's my env.ts: import dotenv from "dotenv"; import path from "path"; import { loadAwsSecretToEnv } from "./awsSecretLoader"; const st ...

Conflict in the naming and scoping of IE7 and IE8

While reviewing some code, I encountered a problem in Internet Explorer 7 and 8. Despite the constructor executing properly when stepped through, upon returning I received an error stating "Object does not support this property or method." How frustrating! ...

Automatically redirect users on page refresh using jQuery

I am attempting to use jQuery to detect when the user refreshes the page in order to redirect, but I can't seem to get it working. Can someone help me figure out what is wrong with this code? <?php include 'instagram.php'; ?> <! ...

Is there a way to incorporate an 'ended' feature into the .animate() function?

I'm currently working on a jQuery statement where I want to activate pointer events once the button animation is finished. However, I'm unsure how to incorporate an ended or complete function. Any suggestions on how to approach this? $('#ce ...

Techniques for transferring JavaScript variables within a URL using AJAX

Is there a correct way to pass the values of accesstoken and pageid inside the URL I am using? Any ideas on how to do it properly? <script type="text/javascript"> function makeUrl() { var accesstoken = "12345679|bababashahahhahauauuaua"; ...

Adding a dynamic form to each row in a table: A step-by-step guide

https://i.sstatic.net/HctnU.jpg Hey there! I'm facing a challenge with dynamically generated rows in a form. I want to send only the inputs from the selected row when a checkbox is clicked. Can you help me figure this out? I tried using let rowForm ...

Encountering an error with dynamic routing in Angular 4 when using dynamic components

Upon receiving routing configuration from a server and loading it before the application bootstrap, the config.json file contains the following setup: [{ "path": "dashboard", "component": "SingleComponent", "data": {...} }, { "path": "payment", ...

The predicament encountered with user registration in the realm of Node.js

I am encountering a problem with the sign-up route in node.js and MongoDB. Whenever I attempt to post data using Insomnia, it displays an error message. You can find the screenshot of the error [here](https://i.stack.imgur.com/qnGAv.png). Here is the code ...

Unable to get onChange function to work with multiple input fields in React

I am attempting to implement a feature where an additional input field is added when the user clicks on the "Add input" button, and then store those input values in an object: const {useState } = React; const InviteUser = () => { const [userDetail ...