diff --git a/src/block-components/icon/edit.js b/src/block-components/icon/edit.js
index 6584c0599d..b4c21a0ed5 100644
--- a/src/block-components/icon/edit.js
+++ b/src/block-components/icon/edit.js
@@ -31,6 +31,7 @@ import {
import { __ } from '@wordpress/i18n'
import { Fragment, useMemo } from '@wordpress/element'
import { applyFilters } from '@wordpress/hooks'
+import { dispatch } from '@wordpress/data'
export const Edit = props => {
const {
@@ -92,6 +93,8 @@ export const Edit = props => {
value={ attributes.icon }
defaultValue={ defaultValue }
onChange={ icon => {
+ dispatch( 'stackable/page-icons' ).removePageIcon( attributes.icon )
+
if ( onChangeIcon ) {
onChangeIcon( icon )
} else {
diff --git a/src/block-components/icon/index.js b/src/block-components/icon/index.js
index 8ff86ef799..a0ec5323f9 100644
--- a/src/block-components/icon/index.js
+++ b/src/block-components/icon/index.js
@@ -20,6 +20,7 @@ import { addStyles } from './style'
* WordPress dependencies
*/
import { useBlockEditContext } from '@wordpress/block-editor'
+import { dispatch, select } from '@wordpress/data'
import {
useMemo, useState, useRef, useEffect, renderToString,
} from '@wordpress/element'
@@ -57,6 +58,67 @@ const LinearGradient = ( {
const NOOP = () => {}
+const getSvgDef = ( href, viewBox = '0 0 24 24' ) => {
+ return ``
+}
+
+const generateIconId = () => {
+ return Math.floor( Math.random() * new Date().getTime() ) % 100000
+}
+
+/**
+ * Extract viewBox, width, and height from SVG string without DOM manipulation
+ * Only checks for the specific attributes we need (case-insensitive)
+ *
+ * @param {string} svgString The SVG string to parse
+ * @return {Object} Object with viewBox, width, and height
+ */
+const extractSVGDimensions = svgString => {
+ if ( ! svgString || typeof svgString !== 'string' ) {
+ return {
+ viewBox: null,
+ width: null,
+ height: null,
+ }
+ }
+
+ // Find the opening