Skip to content

Commit

Permalink
editor content cleanup for advanced heading block
Browse files Browse the repository at this point in the history
  • Loading branch information
erdembircan committed Mar 29, 2024
1 parent ab2169a commit 3afc71c
Show file tree
Hide file tree
Showing 4 changed files with 134,011 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/blocks.build.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => 'c1d3fb06c4830033ad1c');
<?php return array('dependencies' => array('lodash', 'moment', 'react', 'react-dom', 'wp-api', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-keycodes', 'wp-notices', 'wp-primitives', 'wp-url'), 'version' => '35d430ac3891ade2ba35');
133,999 changes: 133,998 additions & 1 deletion dist/blocks.build.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/blocks.build.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/blocks/advanced-heading/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ const AdvancedHeadingEdit = ({
setAttributes({ blockID: block.clientId });
}, [block?.clientId]);

// Clean up the content from img and script tags.
useEffect(() => {
const imgTagRegex = /<img[^>]+>/i;
const imgTagCleaned = content.replace(imgTagRegex, '');

const scriptTagRegex = /<script[^>]*?>.*?<\/script>/is;
const allCleaned = imgTagCleaned.replace(scriptTagRegex, '');

setAttributes({ content: allCleaned });
}, []);

const headingIcons = [h1Icon, h2Icon, h3Icon, h4Icon, h5Icon, h6Icon];
const styles = getStyles(attributes);
return (
Expand Down

0 comments on commit 3afc71c

Please sign in to comment.