In my blocks.js , located in wp-includes/js/dist/ I find the RemoveInvalidHTML
function, which seems to responsible for removing styles from pasted HTML.
/**
* Given a schema, unwraps or removes nodes, attributes and classes on HTML.
*
* @param {string} HTML The HTML to clean up.
* @param {Object} schema Schema for the HTML.
* @param {Object} inline Whether to clean for inline mode.
*
* @return {string} The cleaned up HTML.
*/
function removeInvalidHTML(HTML, schema, inline) {
var doc = document.implementation.createHTMLDocument('');
doc.body.innerHTML = HTML;
cleanNodeList(doc.body.childNodes, doc, schema, inline);
return doc.body.innerHTML;
}
As you can see, this returns only the innerHTML . Modifying (creating a customized version of) this function would likely solve your problem.
Related Posts:
- Gutenberg: Is there a way to know if current block is inside InnerBlocks?
- How to add a custom CSS class to core blocks in Gutenberg editor?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- Changing text within the Block Editor
- Remove left alignment option in core/image block
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- Filter Gutenberg Blocks Content
- How do I replace a render_callback function for a block?
- How can I filter block registration based on post-type? (Block alignment settings)
- Gutenberg disable the “block” tab in right sidebar
- How to change the order of HTML output of a core block?
- Gutenberg – Add align controls to a custom block
- Can the wordpress color palettes by changed through Javascript?
- Inline Styles on all native blocks
- How to link the whole list item in Gutenberg’s latest posts block?
- add_filter(allowed_block_types) -> adding core/paragraph bugs Gutenberg editor
- Set default terms for new posts / CPTs
- Detect when gutenberg editor title is available in Dom after editor load
- Gutenberg Block – Post Featured Image Filter Hook
- Set default value for “Additional CSS class(es)” for specific block types
- How to hide/remove GhostKit component panel in gutenberg block inspector
- Filter for author list in gutenberg core editor
- How to optionally append components to the output of a gutenberg block?
- Problem width wp_insert_post_data and Gutenberg block editor
- WordPress Gutenberg core/heading block (wp-block-heading)
- Changing the category for existing Gutenberg blocks
- How do I check if I can use the allowed_block_types filter?
- How to add lazy field in content endpoint using Gutenberg blocks
- How to add custom HTML attribute to reusable block div in WordPress admin
- How to change this WP logo and posts url in block editor?
- How to get shortcode’s input values inside a filter?
- How to bulk delete all users with no posts?
- WordPress 3.9 – Trouble Editing TinyMCE 4.0
- How to use update_{$meta_type}_metadata filter to modify meta value
- How to wrap an element around an iframe or embed in content automatically?
- Earliest hook to reliably get $post/$posts
- Modify links when inserted by WYSIWYG editor
- How to check if a hook is hooked or not?
- Completely strip any hidden formatting when pasting into TinyMCE
- How to add filter to __() and _e()?
- Where is the proper place to add a filter for pre_get_table_charset?
- WordPress Rest filter for custom taxonomy gets applied to the admin area
- add class to internal links in content
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- Help debugging PHP filter for wordpress [closed]
- About Hooks and Filters
- How to always display a specific post from the search result first
- filter title from shortcode
- Add a Span Around a Product Title in WooCommerce [closed]
- get_query stops working after post filter
- How to filter into post meta data before saving
- Adding custom column to comments admin panel?
- Filter out some plugin action in wp head / wp_footer
- How to make a widget expand wider than the column width when editing its settings in the admin
- Is there a wildcard/catchall filter hook?
- Apply the_content filter, but prevent other hooked actions
- Can the wp_filter object hold multiple values with the same key
- apply_filters/do_action tag characters limit
- Add Defer Attributes to WordPress Scripts with consistent versioning
- How to stop wrapping comments in P tag
- String regex match replace for role ‘contributor’ only
- Can plugins that filter post contents work on posts from Word 2007?
- html tags in gettext hook get escaped
- Better extend a class or use add filter/action hooks?
- Adding a Clone link to product attributes – post_row_actions() filter, or how to override a Class question
- wp_upload_bits Upload Specific Sizes Only
- Woocommerce “added to cart” message on main(home) page
- Why does adding a filter to ‘the_title’ break the server?
- Add filter for specific post type only
- Avoid user registrations with specific email provider
- Should I remove_filter in order to replace a filter?
- Change custom post type GUID in RSS
- filter hook to load a different post/page on current post/page
- How would I be able to use a font awesome icon as a user’s avatar?
- Add something after a filter
- add_filter the_content doesn’t work
- Redirect to woocommerce checkout after adding to cart – item already in cart
- `authenticate` filter never gets called
- How to disable a wp filter in a certain admin panel page
- Is there a filter to programmatically change the HTML tab switching output of the page editor?
- post_orderby filter breaks function
- Disable Remember Me in Login Form
- How do I add a line break to a string that is output by PHP?
- Counting a WP_Post Object value in an arary, using a filter?
- List all categories that have results in a query
- Distinguish between page and post in function
- Display posts from today and future in Elementor ‘posts widget’
- Right filter for rewriting page statuscode
- How to filter page title for certain page?
- Displaying posts on a page that have been assigned a value in a database
- Replace Text with hyperlinks
- adding an action inside if condition not working
- Adding filter to an specific page/site direction
- How to check which submission button was clicked?
- check, if any “add_action” function contains string XXXXXXXXX
- Joining tables not working in the post editor page
- Auto append text after the title?
- Filter and manipulate the get_current_user() function
- add_filter(‘the_content’, ‘method’) does not trigger my custom method
- Why isn’t this add_filter function working as expected?