not sure if I am asking correctly. But I understood that controller is probably what I need. I want to have the functionality of custom plugin number 4 called Dialog – http://suneditor.com/sample/html/customPlugins.html#dialog But I do not want to insert a link but custom element named for example customElement.
I can modify the code provided for the sample plugin to custom HTML element is inserted but then I will loose the context dialog to update, unlink, or remove the element.
I my case I want only the update and remove icons.
Is that possible in Suneditor?
You test with https://jsfiddle.net/radek/qjoevast/12/ the very first line defines what HTML element is going to be inserted.
for var customElement = 'a'
I get the context buttons
for var customElement = 'customElement'
the correct element is inserted but not context buttons
2
Answers
I have specified the places where you can get the context of update,remove with
//$$$$$$$$$$$$$
in js code below,and also the place where you can create the custom element look for it.I have only modified js. The above code is compataible with most type of custom element(like image, a,link,some marquee,etc.), I have demonstrated with
<a>
.The key working is the
active:
andonEditorClick:
methods in above js, which helps to detect and launch the appropriate handles.To create a controller for a custom HTML element that allows for context buttons to update and delete the element, you can follow these steps. This example assumes you are working within a JavaScript environment, likely in conjunction with a web framework or library that supports custom elements.
Step 1: Define the Custom Element
First, you need to define your custom HTML element. This is done using the Web Components API. Here’s an example of how to create a simple custom element:
Step 2: Create the Controller
Next, create a controller that will handle the actions for updating and deleting the custom element. This controller will listen for events and manage the state of your custom elements.
Step 3: Create Context Buttons in HTML
You need to have buttons in your HTML that will serve as the context menu for updating and deleting your custom elements.
Step 4: Putting It All Together
Remember to include everything in your main HTML file:
This method I suggested will help you build a basic structure for managing a custom HTML element with context buttons for updating and deleting it. The CustomElement class defines how your custom elements behave, while CustomElementController manages user interactions with those elements.