Appending HTML content using custom plugin
See original GitHub issueHello. I have successfully created a custom plugin, everything works fine if I’m only typing text. I however have a scenario where I declare a title variable, then concatenate the contents of the input field in the custom editor.
This appends even HTML tags into the editor, not the clean, formatted text. Here is my onClick
property of the plugin:
onClick: function () {
this.history.push(true);
const initialEditorContent = this.getContents();
const title = initialEditorContent.search('Resolutions') === -1 ? '<h4><u>Resolutions</u></h4>' : '';
if(this.context.custom.textElement.value.length > 0) {
// Get Input value
const value = this.util.createTextNode(title.concat('<br />', this.context.custom.textElement.value));
// insert
this.insertNode(value);
// set range
this.setRange(value, value.length, value, value.length);
// clear content
this.context.custom.textElement.value = null;
}
// submenu off
this.submenuOff();
// focus
this.focus();
}
Here is the text I’m typing:
When I click Done, here is what is added to the editor:
@JiHong88 , how do I insert that text, well edited without the HTML tags?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
WP Coder – add custom html, css and js code
WP Coder – plugin for adding custom code to the site. You can easily add HTML CSS JS code to the page of...
Read more >Working with custom HTML - BEE Plugin
The Custom HTML content block allows you to easily add your own HTML code to an email message that you are designing with...
Read more >how to make the content script append html to the original ...
I am using google chrome extension v3 to write a plugin. Now I want to append the html content that contains a popup...
Read more >How to insert formatted HTML into editor from custom plugin?
I have created a custom plugin which with the onOk function includes the following: var dialog = this; var srcURL = dialog.
Read more >Use action, filter, or hook to append HTML to WordPress ...
The paragraph with the class of "appended-text" is what should be appended to the HTML using an action, filter, or hook. Plugin's function:...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi sorry for the late reply. The
util.createTextNode
method only creates text nodes. You must create a tag with theutil.createElement
method.In the current version, lines may overlap, but It will be fine in the next version.
Hi @aderaHenry, Could you please share us your code about list hierarchy.
Best regardss