: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
window.parent.postMessage({
width: clientBoundingRect.width,
height: clientBoundingRect.height
const observer = new MutationObserver(sendResize);
observer.observe(document.body, {
attributeOldValue: false,
characterDataOldValue: false,
window.addEventListener('load', sendResize, true);
// Hack: Remove viewport unit styles, as these are relative
// the iframe root and interfere with our mechanism for
// determining the unconstrained page bounds.
function removeViewportStyles(ruleOrNode) {
['width', 'height', 'minHeight', 'maxHeight'].forEach(function (style) {
if (/^\\d+(vw|vh|svw|lvw|dvw|svh|lvh|dvh|vi|svi|lvi|dvi|vb|svb|lvb|dvb|vmin|svmin|lvmin|dvmin|vmax|svmax|lvmax|dvmax)$/.test(ruleOrNode.style[style])) {
ruleOrNode.style[style] = '';
Array.prototype.forEach.call(document.querySelectorAll('[style]'), removeViewportStyles);
Array.prototype.forEach.call(document.styleSheets, function (stylesheet) {
Array.prototype.forEach.call(stylesheet.cssRules || stylesheet.rules, removeViewportStyles);
document.body.style.position = 'absolute';
document.body.style.width = '100%';
document.body.setAttribute('data-resizable-iframe-connected', '');
// Resize events can change the width of elements with 100% width, but we don't
// get an DOM mutations for that, so do the resize when the window is resized, too.
window.addEventListener('resize', sendResize, true);
// TODO: These styles shouldn't be coupled with WordPress.
html.wp-has-aspect-ratio,
body.wp-has-aspect-ratio,
body.wp-has-aspect-ratio > div,
body.wp-has-aspect-ratio > div iframe {
overflow: hidden; /* If it has an aspect ratio, it shouldn't scroll. */
margin-top: 0 !important; /* Has to have !important to override inline styles. */
margin-bottom: 0 !important;
* This component provides an isolated environment for arbitrary HTML via iframes.
* import { SandBox } from '@wordpress/components';
* const MySandBox = () => (
* <SandBox html="<p>Content</p>" title="SandBox" type="embed" />
const ref = (0,external_wp_element_namespaceObject.useRef)();
const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)(0);
const [height, setHeight] = (0,external_wp_element_namespaceObject.useState)(0);
function isFrameAccessible() {
return !!ref.current?.contentDocument?.body;
function trySandBox(forceRerender = false) {
if (!isFrameAccessible()) {
if (!forceRerender && null !== contentDocument?.body.getAttribute('data-resizable-iframe-connected')) {
// Put the html snippet into a html document, and then write it to the iframe's document
// we can use this in the future to inject custom styles or scripts.
// Scripts go into the body rather than the head, to support embedded content such as Instagram
// that expect the scripts to be part of the body.
const htmlDoc = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("html", {
lang: ownerDocument.documentElement.lang,
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("head", {
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("title", {
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("style", {
dangerouslySetInnerHTML: {
}), styles.map((rules, i) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("style", {
dangerouslySetInnerHTML: {
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("body", {
"data-resizable-iframe-connected": "data-resizable-iframe-connected",
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
dangerouslySetInnerHTML: {
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("script", {
dangerouslySetInnerHTML: {
__html: `(${observeAndResizeJS.toString()})();`
}), scripts.map(src => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("script", {
// Writing the document like this makes it act in the same way as if it was
// loaded over the network, so DOM creation and mutation, script execution, etc.
contentDocument.write('<!DOCTYPE html>' + (0,external_wp_element_namespaceObject.renderToString)(htmlDoc));
(0,external_wp_element_namespaceObject.useEffect)(() => {
function tryNoForceSandBox() {
function checkMessageForResize(event) {
const iframe = ref.current;
// Verify that the mounted element is the source of the message.
if (!iframe || iframe.contentWindow !== event.source) {
// Attempt to parse the message data as JSON if passed as string.
let data = event.data || {};
if ('string' === typeof data) {
// Update the state only if the message is formatted as we expect,
// i.e. as an object with a 'resize' action.
if ('resize' !== data.action) {
const iframe = ref.current;
const defaultView = iframe?.ownerDocument?.defaultView;
// This used to be registered using <iframe onLoad={} />, but it made the iframe blank
// after reordering the containing block. See these two issues for more details:
// https://github.com/WordPress/gutenberg/issues/6146
// https://github.com/facebook/react/issues/18752
iframe?.addEventListener('load', tryNoForceSandBox, false);
defaultView?.addEventListener('message', checkMessageForResize);
iframe?.removeEventListener('load', tryNoForceSandBox, false);
defaultView?.removeEventListener('message', checkMessageForResize);
// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
// See https://github.com/WordPress/gutenberg/pull/44378
// eslint-disable-next-line react-hooks/exhaustive-deps
(0,external_wp_element_namespaceObject.useEffect)(() => {
// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
// See https://github.com/WordPress/gutenberg/pull/44378
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [title, styles, scripts]);
(0,external_wp_element_namespaceObject.useEffect)(() => {
// Ignore reason: passing `exhaustive-deps` will likely involve a more detailed refactor.
// See https://github.com/WordPress/gutenberg/pull/44378
// eslint-disable-next-line react-hooks/exhaustive-deps
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("iframe", {
ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, (0,external_wp_compose_namespaceObject.useFocusableIframe)()]),
className: "components-sandbox",
sandbox: "allow-scripts allow-same-origin allow-presentation",
height: Math.ceil(height)
/* harmony default export */ const sandbox = (SandBox);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/snackbar/index.js
const NOTICE_TIMEOUT = 10000;
* Custom hook which announces the message with the given politeness, if a
* valid message is provided.
* @param message Message to announce.
* @param politeness Politeness to announce.
function snackbar_useSpokenMessage(message, politeness) {
const spokenMessage = typeof message === 'string' ? message : (0,external_wp_element_namespaceObject.renderToString)(message);
(0,external_wp_element_namespaceObject.useEffect)(() => {
(0,external_wp_a11y_namespaceObject.speak)(spokenMessage, politeness);
}, [spokenMessage, politeness]);
function UnforwardedSnackbar({
spokenMessage = children,
// onDismiss is a callback executed when the snackbar is dismissed.
// It is distinct from onRemove, which _looks_ like a callback but is
// actually the function to call to remove the snackbar from the UI.
function dismissMe(event) {
if (event && event.preventDefault) {
// Prevent focus loss by moving it to the list element.
listRef?.current?.focus();
function onActionClick(event, onClick) {
snackbar_useSpokenMessage(spokenMessage, politeness);
// The `onDismiss/onRemove` can have unstable references,
// trigger side-effect cleanup, and reset timers.
const callbackRefs = (0,external_wp_element_namespaceObject.useRef)({
(0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
(0,external_wp_element_namespaceObject.useEffect)(() => {
// Only set up the timeout dismiss if we're not explicitly dismissing.
const timeoutHandle = setTimeout(() => {
callbackRefs.current.onDismiss?.();
callbackRefs.current.onRemove?.();
return () => clearTimeout(timeoutHandle);
const classes = dist_clsx(className, 'components-snackbar', {
'components-snackbar-explicit-dismiss': !!explicitDismiss
if (actions && actions.length > 1) {
// We need to inform developers that snackbar only accepts 1 action.
true ? external_wp_warning_default()('Snackbar can only have one action. Use Notice if your message requires many actions.') : 0;
// return first element only while keeping it inside an array
const snackbarContentClassnames = dist_clsx('components-snackbar__content', {
'components-snackbar__content-with-icon': !!icon
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
onClick: !explicitDismiss ? dismissMe : undefined,
role: !explicitDismiss ? 'button' : undefined,
onKeyPress: !explicitDismiss ? dismissMe : undefined,
"aria-label": !explicitDismiss ? (0,external_wp_i18n_namespaceObject.__)('Dismiss this notice') : undefined,
"data-testid": "snackbar",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
className: snackbarContentClassnames,
children: [icon && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "components-snackbar__icon",
}), children, actions.map(({
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(build_module_button, {
onClick: event => onActionClick(event, onClick),
className: "components-snackbar__action",
}), explicitDismiss && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
"aria-label": (0,external_wp_i18n_namespaceObject.__)('Dismiss this notice'),
className: "components-snackbar__dismiss-button",
* A Snackbar displays a succinct message that is cleared out after a small delay.
* It can also offer the user options, like viewing a published post.
* But these options should also be available elsewhere in the UI.
* const MySnackbarNotice = () => (
* <Snackbar>Post published successfully.</Snackbar>
const Snackbar = (0,external_wp_element_namespaceObject.forwardRef)(UnforwardedSnackbar);
/* harmony default export */ const snackbar = (Snackbar);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/snackbar/list.js
const SNACKBAR_VARIANTS = {
* Renders a list of notices.
* const MySnackbarListNotice = () => (
* onRemove={ removeNotice }
const listRef = (0,external_wp_element_namespaceObject.useRef)(null);
const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
className = dist_clsx('components-snackbar-list', className);
const removeNotice = notice => () => onRemove?.(notice.id);
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
"data-testid": "snackbar-list",
children: [children, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AnimatePresence, {
children: notices.map(notice => {
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(motion.div, {
layout: !isReducedMotion // See https://www.framer.com/docs/animation/#layout-animations
variants: isReducedMotion ? undefined : SNACKBAR_VARIANTS,
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
className: "components-snackbar-list__notice-container",
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(snackbar, {
onRemove: removeNotice(notice),
/* harmony default export */ const snackbar_list = (SnackbarList);
;// CONCATENATED MODULE: ./node_modules/@wordpress/components/build-module/spinner/styles.js
function spinner_styles_EMOTION_STRINGIFIED_CSS_ERROR_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }