Pasting HTML in editor
-
-
Juha PenttiläParticipant# 1 year, 3 months ago
Hi,
8.1.6 (2022/02/21) =
- New: Copying/pasting HTML to the editor is now allowed but tags are all filtered out by default (allowed tags are customizable through filter ‘cuar/core/js-richEditor’)
How to excatly do this? What file should be edited? Goal is to allow pasting of html links into the editor.
-
ThomasKeymaster# 1 year, 3 months ago
Hello,
You could use this kind of code snippet:
/** * Edit Summernote editor options * * @param $options array Summernote options * * @return array */ function wpca_richeditor_options($options) { // Configure the list of allowed HTML tags while pasting to the editor // Method 1: just add your own tags // $options["options"]["cleaner"]["keepOnlyTags"][] = 'a'; // $options["options"]["cleaner"]["keepOnlyTags"][] = 'table'; // Method 2: override the full list and make your own: $options["options"]["cleaner"]["keepOnlyTags"] = [ 'a', 'abbr', 'acronym', 'b', 'bdo', 'big', 'blockquote', 'br', 'button', 'caption', 'cite', 'code', 'del', 'dd', 'dfn', 'details', 'div', 'dl', 'dt', 'em', 'fieldset', 'figure', 'figcaption', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'label', 'li', 'mark', 'menu', 'nav', 'p', 'pre', 'q', 'rb', 'rp', 'rt', 'rtc', 'ruby', 's', 'samp', 'span', 'section', 'small', 'strike', 'strong', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'tt', 'u', 'ul', 'ol', ]; return $options; } add_action('cuar/core/js-richEditor', 'wpca_richeditor_options');
See our code snippets documentation to know exactly where to paste this.
This hook will maybe be modified in next WPCA version (in this case, will be documented in the readme), but will include this list as default options.
Regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂 -
ThomasKeymaster# 1 year, 3 months ago
Additional note: if you ONLY want to add ability to paste pasted HTML links, but nothing else, just configure it like so:
/** * Edit Summernote editor options * * @param $options array Summernote options * * @return array */ function wpca_richeditor_options($options) { // Configure the list of allowed HTML tags while pasting to the editor $options["options"]["cleaner"]["keepOnlyTags"][] = 'a'; return $options; } add_action('cuar/core/js-richEditor', 'wpca_richeditor_options');
Regards.
Want to help WP Customer Area? It only takes few seconds!
Rate & review the plugin on WordPress.org 🙂
-
The topic ‘Pasting HTML in editor’ is closed to new replies.