diff --git a/classes/class-gutenberg.php b/classes/class-gutenberg.php
index 81b0a23f..0814203f 100644
--- a/classes/class-gutenberg.php
+++ b/classes/class-gutenberg.php
@@ -212,7 +212,8 @@ public function enqueue_block_editor_assets() {
// Block.
Visual_Portfolio_Assets::enqueue_script(
'visual-portfolio-gutenberg',
- 'build/gutenberg/index'
+ 'build/gutenberg/index',
+ array( 'masonry' )
);
Visual_Portfolio_Assets::enqueue_style(
'visual-portfolio-gutenberg',
diff --git a/gutenberg/components/masonry-wrapper/index.js b/gutenberg/components/masonry-wrapper/index.js
new file mode 100644
index 00000000..cb06e378
--- /dev/null
+++ b/gutenberg/components/masonry-wrapper/index.js
@@ -0,0 +1,24 @@
+import { useEffect, useRef } from '@wordpress/element';
+
+const { Masonry } = window;
+
+export default function MasonryWrapper(props) {
+ const { options, children, ...restProps } = props;
+
+ const ref = useRef();
+
+ // Init.
+ useEffect(() => {
+ const instance = new Masonry(ref.current, options);
+
+ return () => {
+ instance.destroy();
+ };
+ }, [ref, options, children]);
+
+ return (
+
+ {children}
+
+ );
+}
diff --git a/gutenberg/components/tiles-selector/index.js b/gutenberg/components/tiles-selector/index.js
index eb05c2bb..9af37257 100644
--- a/gutenberg/components/tiles-selector/index.js
+++ b/gutenberg/components/tiles-selector/index.js
@@ -1,12 +1,12 @@
import './style.scss';
import classnames from 'classnames/dedupe';
-import Masonry from 'react-masonry-component';
import { Button } from '@wordpress/components';
import { Component } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
+import MasonryWrapper from '../masonry-wrapper';
import StylesRender from '../styles-render';
import ToggleModal from '../toggle-modal';
@@ -69,8 +69,8 @@ export default class TilesSelector extends Component {
return (
<>
- {styles}
+
))}
-
- {styles}
+
>
);
}
diff --git a/package-lock.json b/package-lock.json
index 1caaf5dc..bfa2e0d6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27,7 +27,6 @@
"photoswipe": "^4.1.3",
"raf-schd": "^4.0.3",
"react-ace": "^9.5.0",
- "react-masonry-component": "^6.3.0",
"react-select": "^5.7.3",
"react-sortable-hoc": "^2.0.0",
"shorthash": "0.0.2",
@@ -7040,11 +7039,6 @@
"integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==",
"dev": true
},
- "node_modules/batch-processor": {
- "version": "1.0.0",
- "resolved": "https://registry.npmjs.org/batch-processor/-/batch-processor-1.0.0.tgz",
- "integrity": "sha512-xoLQD8gmmR32MeuBHgH0Tzd5PuSZx71ZsbhVxOCRbgktZEPe4SQy7s9Z50uPp0F/f7iw2XmkHN2xkgbMfckMDA=="
- },
"node_modules/big-integer": {
"version": "1.6.51",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
@@ -8864,23 +8858,6 @@
"node": ">= 6"
}
},
- "node_modules/create-react-class": {
- "version": "15.7.0",
- "resolved": "https://registry.npmjs.org/create-react-class/-/create-react-class-15.7.0.tgz",
- "integrity": "sha512-QZv4sFWG9S5RUvkTYWbflxeZX+JG7Cz0Tn33rQBJ+WFQTqTfUTjMjiv9tnfXazjsO5r0KhPs+AqCjyrQX6h2ng==",
- "dependencies": {
- "loose-envify": "^1.3.1",
- "object-assign": "^4.1.1"
- }
- },
- "node_modules/create-react-class/node_modules/object-assign": {
- "version": "4.1.1",
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
- "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
- "engines": {
- "node": ">=0.10.0"
- }
- },
"node_modules/cross-env": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz",
@@ -10093,14 +10070,6 @@
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.527.tgz",
"integrity": "sha512-EafxEiEDzk2aLrdbtVczylHflHdHkNrpGNHIgDyA63sUQLQVS2ayj2hPw3RsVB42qkwURH+T2OxV7kGPUuYszA=="
},
- "node_modules/element-resize-detector": {
- "version": "1.2.4",
- "resolved": "https://registry.npmjs.org/element-resize-detector/-/element-resize-detector-1.2.4.tgz",
- "integrity": "sha512-Fl5Ftk6WwXE0wqCgNoseKWndjzZlDCwuPTcoVZfCP9R3EHQF8qUtr3YUPNETegRBOKqQKPW3n4kiIWngGi8tKg==",
- "dependencies": {
- "batch-processor": "1.0.0"
- }
- },
"node_modules/emittery": {
"version": "0.8.1",
"resolved": "https://registry.npmjs.org/emittery/-/emittery-0.8.1.tgz",
@@ -14266,14 +14235,6 @@
"node": ">=10"
}
},
- "node_modules/imagesloaded": {
- "version": "4.1.4",
- "resolved": "https://registry.npmjs.org/imagesloaded/-/imagesloaded-4.1.4.tgz",
- "integrity": "sha512-ltiBVcYpc/TYTF5nolkMNsnREHW+ICvfQ3Yla2Sgr71YFwQ86bDwV9hgpFhFtrGPuwEx5+LqOHIrdXBdoWwwsA==",
- "dependencies": {
- "ev-emitter": "^1.0.0"
- }
- },
"node_modules/immutable": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/immutable/-/immutable-4.3.4.tgz",
@@ -18027,7 +17988,8 @@
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
- "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
+ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
+ "dev": true
},
"node_modules/lodash.debounce": {
"version": "4.0.8",
@@ -22290,22 +22252,6 @@
"integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==",
"dev": true
},
- "node_modules/react-masonry-component": {
- "version": "6.3.0",
- "resolved": "https://registry.npmjs.org/react-masonry-component/-/react-masonry-component-6.3.0.tgz",
- "integrity": "sha512-4ZI78nxMfCpU5yQiS6Rup07Ju++YzcOGAyvbMcl2GfpZTw8GRwT548lkKr0PJarNicRV1qE2D/NiT26UPg1T7A==",
- "dependencies": {
- "create-react-class": "^15.6.2",
- "element-resize-detector": "^1.1.9",
- "imagesloaded": "^4.0.0",
- "lodash": "^4.17.4",
- "masonry-layout": "^4.2.0",
- "prop-types": "^15.5.8"
- },
- "peerDependencies": {
- "react": "^0.14.0 || ^15.0.0-0 || ^16.0.0-0 || ^17.0.0"
- }
- },
"node_modules/react-refresh": {
"version": "0.10.0",
"resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.10.0.tgz",
diff --git a/package.json b/package.json
index 4a0443fd..1318668c 100644
--- a/package.json
+++ b/package.json
@@ -87,7 +87,6 @@
"photoswipe": "^4.1.3",
"raf-schd": "^4.0.3",
"react-ace": "^9.5.0",
- "react-masonry-component": "^6.3.0",
"react-select": "^5.7.3",
"react-sortable-hoc": "^2.0.0",
"shorthash": "0.0.2",