@wordpress/block-editor 8.5.4 → 8.5.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,63 +43,63 @@ const BLOCK_PREFIX = 'wp-block';
43
43
  *
44
44
  * Ideally, this hook should be removed in the future and styles should be added
45
45
  * explicitly as editor styles.
46
- *
47
- * @param {Document} doc The document to append cloned stylesheets to.
48
46
  */
49
47
 
50
- function styleSheetsCompat(doc) {
51
- // Search the document for stylesheets targetting the editor canvas.
52
- Array.from(document.styleSheets).forEach(styleSheet => {
53
- try {
54
- // May fail for external styles.
55
- // eslint-disable-next-line no-unused-expressions
56
- styleSheet.cssRules;
57
- } catch (e) {
58
- return;
59
- }
48
+ function useStylesCompatibility() {
49
+ return (0, _compose.useRefEffect)(node => {
50
+ // Search the document for stylesheets targetting the editor canvas.
51
+ Array.from(document.styleSheets).forEach(styleSheet => {
52
+ try {
53
+ // May fail for external styles.
54
+ // eslint-disable-next-line no-unused-expressions
55
+ styleSheet.cssRules;
56
+ } catch (e) {
57
+ return;
58
+ }
60
59
 
61
- const {
62
- ownerNode,
63
- cssRules
64
- } = styleSheet;
60
+ const {
61
+ ownerNode,
62
+ cssRules
63
+ } = styleSheet;
65
64
 
66
- if (!cssRules) {
67
- return;
68
- } // Generally, ignore inline styles. We add inline styles belonging to a
69
- // stylesheet later, which may or may not match the selectors.
65
+ if (!cssRules) {
66
+ return;
67
+ } // Generally, ignore inline styles. We add inline styles belonging to a
68
+ // stylesheet later, which may or may not match the selectors.
70
69
 
71
70
 
72
- if (ownerNode.tagName !== 'LINK') {
73
- return;
74
- } // Don't try to add the reset styles, which were removed as a dependency
75
- // from `edit-blocks` for the iframe since we don't need to reset admin
76
- // styles.
71
+ if (ownerNode.tagName !== 'LINK') {
72
+ return;
73
+ } // Don't try to add the reset styles, which were removed as a dependency
74
+ // from `edit-blocks` for the iframe since we don't need to reset admin
75
+ // styles.
77
76
 
78
77
 
79
- if (ownerNode.id === 'wp-reset-editor-styles-css') {
80
- return;
81
- }
78
+ if (ownerNode.id === 'wp-reset-editor-styles-css') {
79
+ return;
80
+ }
82
81
 
83
- const isMatch = Array.from(cssRules).find(_ref => {
84
- let {
85
- selectorText
86
- } = _ref;
87
- return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
88
- });
82
+ const isMatch = Array.from(cssRules).find(_ref => {
83
+ let {
84
+ selectorText
85
+ } = _ref;
86
+ return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
87
+ });
89
88
 
90
- if (isMatch && !doc.getElementById(ownerNode.id)) {
91
- // Display warning once we have a way to add style dependencies to the editor.
92
- // See: https://github.com/WordPress/gutenberg/pull/37466.
93
- doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
89
+ if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
90
+ // Display warning once we have a way to add style dependencies to the editor.
91
+ // See: https://github.com/WordPress/gutenberg/pull/37466.
92
+ node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
94
93
 
95
- const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
96
- const inlineCssElement = document.getElementById(inlineCssId);
94
+ const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
95
+ const inlineCssElement = document.getElementById(inlineCssId);
97
96
 
98
- if (inlineCssElement) {
99
- doc.head.appendChild(inlineCssElement.cloneNode(true));
97
+ if (inlineCssElement) {
98
+ node.appendChild(inlineCssElement.cloneNode(true));
99
+ }
100
100
  }
101
- }
102
- });
101
+ });
102
+ }, []);
103
103
  }
104
104
  /**
105
105
  * Bubbles some event types (keydown, keypress, and dragover) to parent document
@@ -239,11 +239,7 @@ function Iframe(_ref3, ref) {
239
239
  });
240
240
  }, []);
241
241
  const bodyRef = (0, _compose.useMergeRefs)([contentRef, clearerRef, writingFlowRef]);
242
- (0, _element.useEffect)(() => {
243
- if (iframeDocument) {
244
- styleSheetsCompat(iframeDocument);
245
- }
246
- }, [iframeDocument]);
242
+ const styleCompatibilityRef = useStylesCompatibility();
247
243
  head = (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("style", null, 'body{margin:0}'), styles.map(_ref4 => {
248
244
  let {
249
245
  tagName,
@@ -281,7 +277,12 @@ function Iframe(_ref3, ref) {
281
277
  }, head), (0, _element.createElement)("body", {
282
278
  ref: bodyRef,
283
279
  className: (0, _classnames.default)(BODY_CLASS_NAME, ...bodyClasses)
284
- }, (0, _element.createElement)(_components.__experimentalStyleProvider, {
280
+ }, (0, _element.createElement)("div", {
281
+ style: {
282
+ display: 'none'
283
+ },
284
+ ref: styleCompatibilityRef
285
+ }), (0, _element.createElement)(_components.__experimentalStyleProvider, {
285
286
  document: iframeDocument
286
287
  }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
287
288
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","getElementById","head","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","map","href","rel","media","textContent","TagName","toLowerCase"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAaA;;AACA;;AACA;;AAKA;;AACA;;AAxBA;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,GAA5B,EAAkC;AACjC;AACAC,EAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,QAAI;AACH;AACA;AACAA,MAAAA,UAAU,CAACC,QAAX;AACA,KAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA,SAAF;AAAaF,MAAAA;AAAb,QAA0BD,UAAhC;;AAEA,QAAK,CAAEC,QAAP,EAAkB;AACjB;AACA,KAb4D,CAe7D;AACA;;;AACA,QAAKE,SAAS,CAACC,OAAV,KAAsB,MAA3B,EAAoC;AACnC;AACA,KAnB4D,CAqB7D;AACA;AACA;;;AACA,QAAKD,SAAS,CAACE,EAAV,KAAiB,4BAAtB,EAAqD;AACpD;AACA;;AAED,UAAMC,OAAO,GAAGX,KAAK,CAACC,IAAN,CAAYK,QAAZ,EAAuBM,IAAvB,CACf;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACCA,YAAY,KACVA,YAAY,CAACC,QAAb,CAAwB,IAAIlB,eAAiB,EAA7C,KACDiB,YAAY,CAACC,QAAb,CAAwB,IAAIjB,YAAc,EAA1C,CAFW,CADb;AAAA,KADe,CAAhB;;AAOA,QAAKc,OAAO,IAAI,CAAEZ,GAAG,CAACgB,cAAJ,CAAoBP,SAAS,CAACE,EAA9B,CAAlB,EAAuD;AACtD;AACA;AAEAX,MAAAA,GAAG,CAACiB,IAAJ,CAASC,WAAT,CAA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;;eAEc,yBAAYhB,MAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n *\n * @param {Document} doc The document to append cloned stylesheets to.\n */\nfunction styleSheetsCompat( doc ) {\n\t// Search the document for stylesheets targetting the editor canvas.\n\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\ttry {\n\t\t\t// May fail for external styles.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tstyleSheet.cssRules;\n\t\t} catch ( e ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\tif ( ! cssRules ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t// stylesheet later, which may or may not match the selectors.\n\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t// styles.\n\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t( { selectorText } ) =>\n\t\t\t\tselectorText &&\n\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t);\n\n\t\tif ( isMatch && ! doc.getElementById( ownerNode.id ) ) {\n\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\n\t\t\tdoc.head.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\tconst inlineCssId = ownerNode.id.replace( '-css', '-inline-css' );\n\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\tif ( inlineCssElement ) {\n\t\t\t\tdoc.head.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{ contentRef, children, head, tabIndex = 0, assets, ...props },\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => node.removeEventListener( 'load', setDocumentIfReady );\n\t}, [] );\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\n\tuseEffect( () => {\n\t\tif ( iframeDocument ) {\n\t\t\tstyleSheetsCompat( iframeDocument );\n\t\t}\n\t}, [ iframeDocument ] );\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>{ head }</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["BODY_CLASS_NAME","BLOCK_PREFIX","useStylesCompatibility","node","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","ownerDocument","getElementById","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","head","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","setRef","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","styleCompatibilityRef","map","href","rel","media","textContent","TagName","toLowerCase","display"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAYA;;AACA;;AACA;;AAKA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAYA;AACA;AACA;AAIA,MAAMA,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,sBAAT,GAAkC;AACjC,SAAO,2BAAgBC,IAAF,IAAY;AAChC;AACAC,IAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,UAAI;AACH;AACA;AACAA,QAAAA,UAAU,CAACC,QAAX;AACA,OAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,YAAM;AAAEC,QAAAA,SAAF;AAAaF,QAAAA;AAAb,UAA0BD,UAAhC;;AAEA,UAAK,CAAEC,QAAP,EAAkB;AACjB;AACA,OAb4D,CAe7D;AACA;;;AACA,UAAKE,SAAS,CAACC,OAAV,KAAsB,MAA3B,EAAoC;AACnC;AACA,OAnB4D,CAqB7D;AACA;AACA;;;AACA,UAAKD,SAAS,CAACE,EAAV,KAAiB,4BAAtB,EAAqD;AACpD;AACA;;AAED,YAAMC,OAAO,GAAGX,KAAK,CAACC,IAAN,CAAYK,QAAZ,EAAuBM,IAAvB,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IAAxB,CADD,EAEC;AACC,IAAA,GAAG,EAAG2C,OADP;AAEC,IAAA,SAAS,EAAG,yBACX3G,eADW,EAEX,GAAGkF,WAFQ;AAFb,KAYC;AACC,IAAA,KAAK,EAAG;AAAEkC,MAAAA,OAAO,EAAE;AAAX,KADT;AAEC,IAAA,GAAG,EAAGR;AAFP,IAZD,EAgBC,4BAAC,uCAAD;AAAe,IAAA,QAAQ,EAAG5B;AAA1B,KACGlB,QADH,CAhBD,CAFD,CADD,EAwBCkB,cAAc,CAACc,eAxBhB,CATF,CAFD,EAsCGlB,QAAQ,IAAI,CAAZ,IAAiBa,KAtCpB,CADD;AA0CA;;eAEc,yBAAYhB,MAAZ,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nfunction useStylesCompatibility() {\n\treturn useRefEffect( ( node ) => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\tif ( ! cssRules ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t// styles.\n\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t\t( { selectorText } ) =>\n\t\t\t\t\tselectorText &&\n\t\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\tisMatch &&\n\t\t\t\t! node.ownerDocument.getElementById( ownerNode.id )\n\t\t\t) {\n\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\tnode.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t'-css',\n\t\t\t\t\t'-inline-css'\n\t\t\t\t);\n\t\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\tnode.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}, [] );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{ contentRef, children, head, tabIndex = 0, assets, ...props },\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => node.removeEventListener( 'load', setDocumentIfReady );\n\t}, [] );\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\tconst styleCompatibilityRef = useStylesCompatibility();\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>{ head }</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t\t\t * This is a wrapper for the extra styles and scripts\n\t\t\t\t\t\t\t\t * rendered imperatively by cloning the parent,\n\t\t\t\t\t\t\t\t * it's important that this div's content remains uncontrolled.\n\t\t\t\t\t\t\t\t */ }\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\t\t\t\tref={ styleCompatibilityRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
@@ -32,6 +32,11 @@ function Warning(_ref) {
32
32
  secondaryActions
33
33
  } = _ref;
34
34
  return (0, _element.createElement)("div", {
35
+ style: {
36
+ display: 'contents',
37
+ all: 'initial'
38
+ }
39
+ }, (0, _element.createElement)("div", {
35
40
  className: (0, _classnames.default)(className, 'block-editor-warning')
36
41
  }, (0, _element.createElement)("div", {
37
42
  className: "block-editor-warning__contents"
@@ -54,7 +59,7 @@ function Warning(_ref) {
54
59
  }, () => (0, _element.createElement)(_components.MenuGroup, null, secondaryActions.map((item, pos) => (0, _element.createElement)(_components.MenuItem, {
55
60
  onClick: item.onClick,
56
61
  key: pos
57
- }, item.title)))))));
62
+ }, item.title))))))));
58
63
  }
59
64
  /**
60
65
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,SAAS,EAAG,yBAAYH,SAAZ,EAAuB,sBAAvB;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KAA+CE,QAA/C,CADD,EAGG,CAAEE,kBAASC,KAAT,CAAgBJ,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,kBAASC,KAAT,CAAgBJ,OAAhB,IAA4B,CAA5B,IACDG,kBAASE,GAAT,CAAcL,OAAd,EAAuB,CAAEM,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGJ,gBAAgB,IACjB,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGM,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,QAAQ,EAAE,aADI;AAEdV,MAAAA,SAAS,EAAE;AAFG,KAJhB;AAQC,IAAA,OAAO;AARR,KAUG,MACD,4BAAC,qBAAD,QACGG,gBAAgB,CAACG,GAAjB,CACD,CAAEK,IAAF,EAAQC,GAAR,KACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAXF,CAXF,CAJF,CADD,CADD;AAgDA;AAED;AACA;AACA;;;eACef,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t<p className=\"block-editor-warning__message\">{ children }</p>\n\n\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\tclassName: 'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["Warning","className","actions","children","secondaryActions","display","all","Children","count","map","action","i","moreHorizontal","position","item","pos","onClick","title"],"mappings":";;;;;;;;;AAQA;;AALA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;AAMA,SAASA,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,KAAK,EAAG;AAAEC,MAAAA,OAAO,EAAE,UAAX;AAAuBC,MAAAA,GAAG,EAAE;AAA5B;AAAb,KACC;AAAK,IAAA,SAAS,EAAG,yBAAYL,SAAZ,EAAuB,sBAAvB;AAAjB,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACGE,QADH,CADD,EAKG,CAAEI,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGG,kBAASC,KAAT,CAAgBN,OAAhB,IAA4B,CAA5B,IACDK,kBAASE,GAAT,CAAcP,OAAd,EAAuB,CAAEQ,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGN,gBAAgB,IACjB,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGQ,qBAFR;AAGC,IAAA,KAAK,EAAG,cAAI,cAAJ,CAHT;AAIC,IAAA,YAAY,EAAG;AACdC,MAAAA,QAAQ,EAAE,aADI;AAEdZ,MAAAA,SAAS,EACR;AAHa,KAJhB;AASC,IAAA,OAAO;AATR,KAWG,MACD,4BAAC,qBAAD,QACGG,gBAAgB,CAACK,GAAjB,CACD,CAAEK,IAAF,EAAQC,GAAR,KACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAZF,CAXF,CANF,CADD,CADD,CADD;AAqDA;AAED;AACA;AACA;;;eACejB,O","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div style={ { display: 'contents', all: 'initial' } }>\n\t\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t\t<p className=\"block-editor-warning__message\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</p>\n\n\t\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
@@ -9,7 +9,7 @@ import classnames from 'classnames';
9
9
  * WordPress dependencies
10
10
  */
11
11
 
12
- import { useState, createPortal, forwardRef, useEffect, useMemo, useReducer } from '@wordpress/element';
12
+ import { useState, createPortal, forwardRef, useMemo, useReducer } from '@wordpress/element';
13
13
  import { __ } from '@wordpress/i18n';
14
14
  import { useMergeRefs, useRefEffect } from '@wordpress/compose';
15
15
  import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
@@ -28,63 +28,63 @@ const BLOCK_PREFIX = 'wp-block';
28
28
  *
29
29
  * Ideally, this hook should be removed in the future and styles should be added
30
30
  * explicitly as editor styles.
31
- *
32
- * @param {Document} doc The document to append cloned stylesheets to.
33
31
  */
34
32
 
35
- function styleSheetsCompat(doc) {
36
- // Search the document for stylesheets targetting the editor canvas.
37
- Array.from(document.styleSheets).forEach(styleSheet => {
38
- try {
39
- // May fail for external styles.
40
- // eslint-disable-next-line no-unused-expressions
41
- styleSheet.cssRules;
42
- } catch (e) {
43
- return;
44
- }
33
+ function useStylesCompatibility() {
34
+ return useRefEffect(node => {
35
+ // Search the document for stylesheets targetting the editor canvas.
36
+ Array.from(document.styleSheets).forEach(styleSheet => {
37
+ try {
38
+ // May fail for external styles.
39
+ // eslint-disable-next-line no-unused-expressions
40
+ styleSheet.cssRules;
41
+ } catch (e) {
42
+ return;
43
+ }
45
44
 
46
- const {
47
- ownerNode,
48
- cssRules
49
- } = styleSheet;
45
+ const {
46
+ ownerNode,
47
+ cssRules
48
+ } = styleSheet;
50
49
 
51
- if (!cssRules) {
52
- return;
53
- } // Generally, ignore inline styles. We add inline styles belonging to a
54
- // stylesheet later, which may or may not match the selectors.
50
+ if (!cssRules) {
51
+ return;
52
+ } // Generally, ignore inline styles. We add inline styles belonging to a
53
+ // stylesheet later, which may or may not match the selectors.
55
54
 
56
55
 
57
- if (ownerNode.tagName !== 'LINK') {
58
- return;
59
- } // Don't try to add the reset styles, which were removed as a dependency
60
- // from `edit-blocks` for the iframe since we don't need to reset admin
61
- // styles.
56
+ if (ownerNode.tagName !== 'LINK') {
57
+ return;
58
+ } // Don't try to add the reset styles, which were removed as a dependency
59
+ // from `edit-blocks` for the iframe since we don't need to reset admin
60
+ // styles.
62
61
 
63
62
 
64
- if (ownerNode.id === 'wp-reset-editor-styles-css') {
65
- return;
66
- }
63
+ if (ownerNode.id === 'wp-reset-editor-styles-css') {
64
+ return;
65
+ }
67
66
 
68
- const isMatch = Array.from(cssRules).find(_ref => {
69
- let {
70
- selectorText
71
- } = _ref;
72
- return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
73
- });
67
+ const isMatch = Array.from(cssRules).find(_ref => {
68
+ let {
69
+ selectorText
70
+ } = _ref;
71
+ return selectorText && (selectorText.includes(`.${BODY_CLASS_NAME}`) || selectorText.includes(`.${BLOCK_PREFIX}`));
72
+ });
74
73
 
75
- if (isMatch && !doc.getElementById(ownerNode.id)) {
76
- // Display warning once we have a way to add style dependencies to the editor.
77
- // See: https://github.com/WordPress/gutenberg/pull/37466.
78
- doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
74
+ if (isMatch && !node.ownerDocument.getElementById(ownerNode.id)) {
75
+ // Display warning once we have a way to add style dependencies to the editor.
76
+ // See: https://github.com/WordPress/gutenberg/pull/37466.
77
+ node.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
79
78
 
80
- const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
81
- const inlineCssElement = document.getElementById(inlineCssId);
79
+ const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
80
+ const inlineCssElement = document.getElementById(inlineCssId);
82
81
 
83
- if (inlineCssElement) {
84
- doc.head.appendChild(inlineCssElement.cloneNode(true));
82
+ if (inlineCssElement) {
83
+ node.appendChild(inlineCssElement.cloneNode(true));
84
+ }
85
85
  }
86
- }
87
- });
86
+ });
87
+ }, []);
88
88
  }
89
89
  /**
90
90
  * Bubbles some event types (keydown, keypress, and dragover) to parent document
@@ -224,11 +224,7 @@ function Iframe(_ref3, ref) {
224
224
  });
225
225
  }, []);
226
226
  const bodyRef = useMergeRefs([contentRef, clearerRef, writingFlowRef]);
227
- useEffect(() => {
228
- if (iframeDocument) {
229
- styleSheetsCompat(iframeDocument);
230
- }
231
- }, [iframeDocument]);
227
+ const styleCompatibilityRef = useStylesCompatibility();
232
228
  head = createElement(Fragment, null, createElement("style", null, 'body{margin:0}'), styles.map(_ref4 => {
233
229
  let {
234
230
  tagName,
@@ -266,7 +262,12 @@ function Iframe(_ref3, ref) {
266
262
  }, head), createElement("body", {
267
263
  ref: bodyRef,
268
264
  className: classnames(BODY_CLASS_NAME, ...bodyClasses)
269
- }, createElement(StyleProvider, {
265
+ }, createElement("div", {
266
+ style: {
267
+ display: 'none'
268
+ },
269
+ ref: styleCompatibilityRef
270
+ }), createElement(StyleProvider, {
270
271
  document: iframeDocument
271
272
  }, children))), iframeDocument.documentElement)), tabIndex >= 0 && after);
272
273
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useEffect","useMemo","useReducer","__","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","useWritingFlow","BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","getElementById","head","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","map","href","rel","media","textContent","TagName","toLowerCase"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,SAJD,EAKCC,OALD,EAMCC,UAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,EAAuBC,YAAvB,QAA2C,oBAA3C;AACA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AAEA,MAAMC,eAAe,GAAG,uBAAxB;AACA,MAAMC,YAAY,GAAG,UAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,CAA4BC,GAA5B,EAAkC;AACjC;AACAC,EAAAA,KAAK,CAACC,IAAN,CAAYC,QAAQ,CAACC,WAArB,EAAmCC,OAAnC,CAA8CC,UAAF,IAAkB;AAC7D,QAAI;AACH;AACA;AACAA,MAAAA,UAAU,CAACC,QAAX;AACA,KAJD,CAIE,OAAQC,CAAR,EAAY;AACb;AACA;;AAED,UAAM;AAAEC,MAAAA,SAAF;AAAaF,MAAAA;AAAb,QAA0BD,UAAhC;;AAEA,QAAK,CAAEC,QAAP,EAAkB;AACjB;AACA,KAb4D,CAe7D;AACA;;;AACA,QAAKE,SAAS,CAACC,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,GAfA,CAFH,EAmBGM,IAnBH,CADD;AAwBA,SACC,8BACGuD,QAAQ,IAAI,CAAZ,IAAiBW,MADpB,EAEC,qCACMT,KADN;AAEC,IAAA,GAAG,EAAGnF,YAAY,CAAE,CAAE+E,GAAF,EAAOgB,MAAP,CAAF,CAFnB;AAGC,IAAA,QAAQ,EAAGd,QAHZ,CAIC;AAJD;AAKC,IAAA,MAAM,EAAC,iBALR;AAMC,IAAA,KAAK,EAAGlF,EAAE,CAAE,eAAF;AANX,MAQGsF,cAAc,IACf3F,YAAY,CACX,8BACC;AAAM,IAAA,GAAG,EAAGiH;AAAZ,KAAwBjF,IAAxB,CADD,EAEC;AACC,IAAA,GAAG,EAAGuF,OADP;AAEC,IAAA,SAAS,EAAGzH,UAAU,CACrBc,eADqB,EAErB,GAAGiF,WAFkB;AAFvB,KAOC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGF;AAA1B,KACGlB,QADH,CAPD,CAFD,CADW,EAeXkB,cAAc,CAACe,eAfJ,CATd,CAFD,EA6BGnB,QAAQ,IAAI,CAAZ,IAAiBa,KA7BpB,CADD;AAiCA;;AAED,eAAenG,UAAU,CAAEmF,MAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n *\n * @param {Document} doc The document to append cloned stylesheets to.\n */\nfunction styleSheetsCompat( doc ) {\n\t// Search the document for stylesheets targetting the editor canvas.\n\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\ttry {\n\t\t\t// May fail for external styles.\n\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\tstyleSheet.cssRules;\n\t\t} catch ( e ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\tif ( ! cssRules ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t// stylesheet later, which may or may not match the selectors.\n\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t// styles.\n\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t( { selectorText } ) =>\n\t\t\t\tselectorText &&\n\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t);\n\n\t\tif ( isMatch && ! doc.getElementById( ownerNode.id ) ) {\n\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\n\t\t\tdoc.head.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\tconst inlineCssId = ownerNode.id.replace( '-css', '-inline-css' );\n\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\tif ( inlineCssElement ) {\n\t\t\t\tdoc.head.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t}\n\t\t}\n\t} );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{ contentRef, children, head, tabIndex = 0, assets, ...props },\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => node.removeEventListener( 'load', setDocumentIfReady );\n\t}, [] );\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\n\tuseEffect( () => {\n\t\tif ( iframeDocument ) {\n\t\t\tstyleSheetsCompat( iframeDocument );\n\t\t}\n\t}, [ iframeDocument ] );\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>{ head }</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","__","useMergeRefs","useRefEffect","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","useWritingFlow","BODY_CLASS_NAME","BLOCK_PREFIX","useStylesCompatibility","node","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","ownerDocument","getElementById","appendChild","cloneNode","inlineCssId","replace","inlineCssElement","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","implementation","createHTMLDocument","body","innerHTML","children","loadScript","head","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","ref","contentRef","tabIndex","assets","props","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","styles","scripts","clearerRef","before","writingFlowRef","after","setRef","setDocumentIfReady","contentDocument","readyState","documentElement","classList","filter","startsWith","dir","removeChild","removeEventListener","headRef","element","reduce","promise","then","finally","bodyRef","styleCompatibilityRef","map","href","rel","media","textContent","TagName","toLowerCase","display"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAO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AAS,EAAGxH,UAAU,CACrBa,eADqB,EAErB,GAAGkF,WAFkB;AAFvB,KAYC;AACC,IAAA,KAAK,EAAG;AAAEkC,MAAAA,OAAO,EAAE;AAAX,KADT;AAEC,IAAA,GAAG,EAAGR;AAFP,IAZD,EAgBC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAG5B;AAA1B,KACGlB,QADH,CAhBD,CAFD,CADW,EAwBXkB,cAAc,CAACc,eAxBJ,CATd,CAFD,EAsCGlB,QAAQ,IAAI,CAAZ,IAAiBa,KAtCpB,CADD;AA0CA;;AAED,eAAenG,UAAU,CAAEmF,MAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs, useRefEffect } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\n\nconst BODY_CLASS_NAME = 'editor-styles-wrapper';\nconst BLOCK_PREFIX = 'wp-block';\n\n/**\n * Clones stylesheets targetting the editor canvas to the given document. A\n * stylesheet is considered targetting the editor a canvas if it contains the\n * `editor-styles-wrapper`, `wp-block`, or `wp-block-*` class selectors.\n *\n * Ideally, this hook should be removed in the future and styles should be added\n * explicitly as editor styles.\n */\nfunction useStylesCompatibility() {\n\treturn useRefEffect( ( node ) => {\n\t\t// Search the document for stylesheets targetting the editor canvas.\n\t\tArray.from( document.styleSheets ).forEach( ( styleSheet ) => {\n\t\t\ttry {\n\t\t\t\t// May fail for external styles.\n\t\t\t\t// eslint-disable-next-line no-unused-expressions\n\t\t\t\tstyleSheet.cssRules;\n\t\t\t} catch ( e ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { ownerNode, cssRules } = styleSheet;\n\n\t\t\tif ( ! cssRules ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Generally, ignore inline styles. We add inline styles belonging to a\n\t\t\t// stylesheet later, which may or may not match the selectors.\n\t\t\tif ( ownerNode.tagName !== 'LINK' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Don't try to add the reset styles, which were removed as a dependency\n\t\t\t// from `edit-blocks` for the iframe since we don't need to reset admin\n\t\t\t// styles.\n\t\t\tif ( ownerNode.id === 'wp-reset-editor-styles-css' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isMatch = Array.from( cssRules ).find(\n\t\t\t\t( { selectorText } ) =>\n\t\t\t\t\tselectorText &&\n\t\t\t\t\t( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||\n\t\t\t\t\t\tselectorText.includes( `.${ BLOCK_PREFIX }` ) )\n\t\t\t);\n\n\t\t\tif (\n\t\t\t\tisMatch &&\n\t\t\t\t! node.ownerDocument.getElementById( ownerNode.id )\n\t\t\t) {\n\t\t\t\t// Display warning once we have a way to add style dependencies to the editor.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/37466.\n\t\t\t\tnode.appendChild( ownerNode.cloneNode( true ) );\n\n\t\t\t\t// Add inline styles belonging to the stylesheet.\n\t\t\t\tconst inlineCssId = ownerNode.id.replace(\n\t\t\t\t\t'-css',\n\t\t\t\t\t'-inline-css'\n\t\t\t\t);\n\t\t\t\tconst inlineCssElement = document.getElementById( inlineCssId );\n\n\t\t\t\tif ( inlineCssElement ) {\n\t\t\t\t\tnode.appendChild( inlineCssElement.cloneNode( true ) );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}, [] );\n}\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe(\n\t{ contentRef, children, head, tabIndex = 0, assets, ...props },\n\tref\n) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst styles = useParsedAssets( assets?.styles );\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { readyState, documentElement } = contentDocument;\n\n\t\t\tif ( readyState !== 'interactive' && readyState !== 'complete' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.head );\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\treturn true;\n\t\t}\n\n\t\t// Document set with srcDoc is not immediately ready.\n\t\tnode.addEventListener( 'load', setDocumentIfReady );\n\n\t\treturn () => node.removeEventListener( 'load', setDocumentIfReady );\n\t}, [] );\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );\n\tconst styleCompatibilityRef = useStylesCompatibility();\n\n\thead = (\n\t\t<>\n\t\t\t<style>{ 'body{margin:0}' }</style>\n\t\t\t{ styles.map(\n\t\t\t\t( { tagName, href, id, rel, media, textContent } ) => {\n\t\t\t\t\tconst TagName = tagName.toLowerCase();\n\n\t\t\t\t\tif ( TagName === 'style' ) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<TagName { ...{ id } } key={ id }>\n\t\t\t\t\t\t\t\t{ textContent }\n\t\t\t\t\t\t\t</TagName>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ id } />\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t) }\n\t\t\t{ head }\n\t\t</>\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards mode\n\t\t\t\tsrcDoc=\"<!doctype html>\"\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<head ref={ headRef }>{ head }</head>\n\t\t\t\t\t\t\t<body\n\t\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\tBODY_CLASS_NAME,\n\t\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ /*\n\t\t\t\t\t\t\t\t * This is a wrapper for the extra styles and scripts\n\t\t\t\t\t\t\t\t * rendered imperatively by cloning the parent,\n\t\t\t\t\t\t\t\t * it's important that this div's content remains uncontrolled.\n\t\t\t\t\t\t\t\t */ }\n\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\t\t\t\tref={ styleCompatibilityRef }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t\t</body>\n\t\t\t\t\t\t</>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
@@ -21,6 +21,11 @@ function Warning(_ref) {
21
21
  secondaryActions
22
22
  } = _ref;
23
23
  return createElement("div", {
24
+ style: {
25
+ display: 'contents',
26
+ all: 'initial'
27
+ }
28
+ }, createElement("div", {
24
29
  className: classnames(className, 'block-editor-warning')
25
30
  }, createElement("div", {
26
31
  className: "block-editor-warning__contents"
@@ -43,7 +48,7 @@ function Warning(_ref) {
43
48
  }, () => createElement(MenuGroup, null, secondaryActions.map((item, pos) => createElement(MenuItem, {
44
49
  onClick: item.onClick,
45
50
  key: pos
46
- }, item.title)))))));
51
+ }, item.title))))))));
47
52
  }
48
53
  /**
49
54
  * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["classnames","Children","DropdownMenu","MenuGroup","MenuItem","__","moreHorizontal","Warning","className","actions","children","secondaryActions","count","map","action","i","position","item","pos","onClick","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EA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**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t<p className=\"block-editor-warning__message\">{ children }</p>\n\n\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\tclassName: 'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/warning/index.js"],"names":["classnames","Children","DropdownMenu","MenuGroup","MenuItem","__","moreHorizontal","Warning","className","actions","children","secondaryActions","display","all","count","map","action","i","position","item","pos","onClick","title"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,QAAlC,QAAkD,uBAAlD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,cAAT,QAA+B,kBAA/B;;AAEA,SAASC,OAAT,OAAuE;AAAA,MAArD;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA,QAAtB;AAAgCC,IAAAA;AAAhC,GAAqD;AACtE,SACC;AAAK,IAAA,KAAK,EAAG;AAAEC,MAAAA,OAAO,EAAE,UAAX;AAAuBC,MAAAA,GAAG,EAAE;AAA5B;AAAb,KACC;AAAK,IAAA,SAAS,EAAGb,UAAU,CAAEQ,SAAF,EAAa,sBAAb;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAG,IAAA,SAAS,EAAC;AAAb,KACGE,QADH,CADD,EAKG,CAAET,QAAQ,CAACa,KAAT,CAAgBL,OAAhB,IAA4B,CAA5B,IAAiCE,gBAAnC,KACD;AAAK,IAAA,SAAS,EAAC;AAAf,KACGV,QAAQ,CAACa,KAAT,CAAgBL,OAAhB,IAA4B,CAA5B,IACDR,QAAQ,CAACc,GAAT,CAAcN,OAAd,EAAuB,CAAEO,MAAF,EAAUC,CAAV,KACtB;AACC,IAAA,GAAG,EAAGA,CADP;AAEC,IAAA,SAAS,EAAC;AAFX,KAIGD,MAJH,CADD,CAFF,EAUGL,gBAAgB,IACjB,cAAC,YAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,IAAI,EAAGL,cAFR;AAGC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAHX;AAIC,IAAA,YAAY,EAAG;AACda,MAAAA,QAAQ,EAAE,aADI;AAEdV,MAAAA,SAAS,EACR;AAHa,KAJhB;AASC,IAAA,OAAO;AATR,KAWG,MACD,cAAC,SAAD,QACGG,gBAAgB,CAACI,GAAjB,CACD,CAAEI,IAAF,EAAQC,GAAR,KACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAGD,IAAI,CAACE,OADhB;AAEC,IAAA,GAAG,EAAGD;AAFP,KAIGD,IAAI,CAACG,KAJR,CAFA,CADH,CAZF,CAXF,CANF,CADD,CADD,CADD;AAqDA;AAED;AACA;AACA;;;AACA,eAAef,OAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Children } from '@wordpress/element';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { moreHorizontal } from '@wordpress/icons';\n\nfunction Warning( { className, actions, children, secondaryActions } ) {\n\treturn (\n\t\t<div style={ { display: 'contents', all: 'initial' } }>\n\t\t\t<div className={ classnames( className, 'block-editor-warning' ) }>\n\t\t\t\t<div className=\"block-editor-warning__contents\">\n\t\t\t\t\t<p className=\"block-editor-warning__message\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</p>\n\n\t\t\t\t\t{ ( Children.count( actions ) > 0 || secondaryActions ) && (\n\t\t\t\t\t\t<div className=\"block-editor-warning__actions\">\n\t\t\t\t\t\t\t{ Children.count( actions ) > 0 &&\n\t\t\t\t\t\t\t\tChildren.map( actions, ( action, i ) => (\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tkey={ i }\n\t\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__action\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ action }\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t) ) }\n\t\t\t\t\t\t\t{ secondaryActions && (\n\t\t\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-warning__secondary\"\n\t\t\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'More options' ) }\n\t\t\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t\t\tposition: 'bottom left',\n\t\t\t\t\t\t\t\t\t\tclassName:\n\t\t\t\t\t\t\t\t\t\t\t'block-editor-warning__dropdown',\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tnoIcons\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t\t\t{ secondaryActions.map(\n\t\t\t\t\t\t\t\t\t\t\t\t( item, pos ) => (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tonClick={ item.onClick }\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tkey={ pos }\n\t\t\t\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ item.title }\n\t\t\t\t\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/warning/README.md\n */\nexport default Warning;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "8.5.4",
3
+ "version": "8.5.7",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,7 +37,7 @@
37
37
  "@wordpress/api-fetch": "^6.3.1",
38
38
  "@wordpress/blob": "^3.6.1",
39
39
  "@wordpress/blocks": "^11.5.3",
40
- "@wordpress/components": "^19.8.3",
40
+ "@wordpress/components": "^19.8.4",
41
41
  "@wordpress/compose": "^5.4.1",
42
42
  "@wordpress/data": "^6.6.1",
43
43
  "@wordpress/date": "^4.6.1",
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "gitHead": "1fdd4758150247d6b690051aed18fa27c15f3a32"
80
+ "gitHead": "d9042594d77ee2d9e28326266de078a505fdf645"
81
81
  }
@@ -10,7 +10,6 @@ import {
10
10
  useState,
11
11
  createPortal,
12
12
  forwardRef,
13
- useEffect,
14
13
  useMemo,
15
14
  useReducer,
16
15
  } from '@wordpress/element';
@@ -34,61 +33,66 @@ const BLOCK_PREFIX = 'wp-block';
34
33
  *
35
34
  * Ideally, this hook should be removed in the future and styles should be added
36
35
  * explicitly as editor styles.
37
- *
38
- * @param {Document} doc The document to append cloned stylesheets to.
39
36
  */
40
- function styleSheetsCompat( doc ) {
41
- // Search the document for stylesheets targetting the editor canvas.
42
- Array.from( document.styleSheets ).forEach( ( styleSheet ) => {
43
- try {
44
- // May fail for external styles.
45
- // eslint-disable-next-line no-unused-expressions
46
- styleSheet.cssRules;
47
- } catch ( e ) {
48
- return;
49
- }
50
-
51
- const { ownerNode, cssRules } = styleSheet;
52
-
53
- if ( ! cssRules ) {
54
- return;
55
- }
37
+ function useStylesCompatibility() {
38
+ return useRefEffect( ( node ) => {
39
+ // Search the document for stylesheets targetting the editor canvas.
40
+ Array.from( document.styleSheets ).forEach( ( styleSheet ) => {
41
+ try {
42
+ // May fail for external styles.
43
+ // eslint-disable-next-line no-unused-expressions
44
+ styleSheet.cssRules;
45
+ } catch ( e ) {
46
+ return;
47
+ }
56
48
 
57
- // Generally, ignore inline styles. We add inline styles belonging to a
58
- // stylesheet later, which may or may not match the selectors.
59
- if ( ownerNode.tagName !== 'LINK' ) {
60
- return;
61
- }
49
+ const { ownerNode, cssRules } = styleSheet;
62
50
 
63
- // Don't try to add the reset styles, which were removed as a dependency
64
- // from `edit-blocks` for the iframe since we don't need to reset admin
65
- // styles.
66
- if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
67
- return;
68
- }
69
-
70
- const isMatch = Array.from( cssRules ).find(
71
- ( { selectorText } ) =>
72
- selectorText &&
73
- ( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
74
- selectorText.includes( `.${ BLOCK_PREFIX }` ) )
75
- );
51
+ if ( ! cssRules ) {
52
+ return;
53
+ }
76
54
 
77
- if ( isMatch && ! doc.getElementById( ownerNode.id ) ) {
78
- // Display warning once we have a way to add style dependencies to the editor.
79
- // See: https://github.com/WordPress/gutenberg/pull/37466.
55
+ // Generally, ignore inline styles. We add inline styles belonging to a
56
+ // stylesheet later, which may or may not match the selectors.
57
+ if ( ownerNode.tagName !== 'LINK' ) {
58
+ return;
59
+ }
80
60
 
81
- doc.head.appendChild( ownerNode.cloneNode( true ) );
61
+ // Don't try to add the reset styles, which were removed as a dependency
62
+ // from `edit-blocks` for the iframe since we don't need to reset admin
63
+ // styles.
64
+ if ( ownerNode.id === 'wp-reset-editor-styles-css' ) {
65
+ return;
66
+ }
82
67
 
83
- // Add inline styles belonging to the stylesheet.
84
- const inlineCssId = ownerNode.id.replace( '-css', '-inline-css' );
85
- const inlineCssElement = document.getElementById( inlineCssId );
68
+ const isMatch = Array.from( cssRules ).find(
69
+ ( { selectorText } ) =>
70
+ selectorText &&
71
+ ( selectorText.includes( `.${ BODY_CLASS_NAME }` ) ||
72
+ selectorText.includes( `.${ BLOCK_PREFIX }` ) )
73
+ );
86
74
 
87
- if ( inlineCssElement ) {
88
- doc.head.appendChild( inlineCssElement.cloneNode( true ) );
75
+ if (
76
+ isMatch &&
77
+ ! node.ownerDocument.getElementById( ownerNode.id )
78
+ ) {
79
+ // Display warning once we have a way to add style dependencies to the editor.
80
+ // See: https://github.com/WordPress/gutenberg/pull/37466.
81
+ node.appendChild( ownerNode.cloneNode( true ) );
82
+
83
+ // Add inline styles belonging to the stylesheet.
84
+ const inlineCssId = ownerNode.id.replace(
85
+ '-css',
86
+ '-inline-css'
87
+ );
88
+ const inlineCssElement = document.getElementById( inlineCssId );
89
+
90
+ if ( inlineCssElement ) {
91
+ node.appendChild( inlineCssElement.cloneNode( true ) );
92
+ }
89
93
  }
90
- }
91
- } );
94
+ } );
95
+ }, [] );
92
96
  }
93
97
 
94
98
  /**
@@ -222,12 +226,7 @@ function Iframe(
222
226
  } );
223
227
  }, [] );
224
228
  const bodyRef = useMergeRefs( [ contentRef, clearerRef, writingFlowRef ] );
225
-
226
- useEffect( () => {
227
- if ( iframeDocument ) {
228
- styleSheetsCompat( iframeDocument );
229
- }
230
- }, [ iframeDocument ] );
229
+ const styleCompatibilityRef = useStylesCompatibility();
231
230
 
232
231
  head = (
233
232
  <>
@@ -275,6 +274,15 @@ function Iframe(
275
274
  ...bodyClasses
276
275
  ) }
277
276
  >
277
+ { /*
278
+ * This is a wrapper for the extra styles and scripts
279
+ * rendered imperatively by cloning the parent,
280
+ * it's important that this div's content remains uncontrolled.
281
+ */ }
282
+ <div
283
+ style={ { display: 'none' } }
284
+ ref={ styleCompatibilityRef }
285
+ />
278
286
  <StyleProvider document={ iframeDocument }>
279
287
  { children }
280
288
  </StyleProvider>
@@ -13,50 +13,55 @@ import { moreHorizontal } from '@wordpress/icons';
13
13
 
14
14
  function Warning( { className, actions, children, secondaryActions } ) {
15
15
  return (
16
- <div className={ classnames( className, 'block-editor-warning' ) }>
17
- <div className="block-editor-warning__contents">
18
- <p className="block-editor-warning__message">{ children }</p>
16
+ <div style={ { display: 'contents', all: 'initial' } }>
17
+ <div className={ classnames( className, 'block-editor-warning' ) }>
18
+ <div className="block-editor-warning__contents">
19
+ <p className="block-editor-warning__message">
20
+ { children }
21
+ </p>
19
22
 
20
- { ( Children.count( actions ) > 0 || secondaryActions ) && (
21
- <div className="block-editor-warning__actions">
22
- { Children.count( actions ) > 0 &&
23
- Children.map( actions, ( action, i ) => (
24
- <span
25
- key={ i }
26
- className="block-editor-warning__action"
23
+ { ( Children.count( actions ) > 0 || secondaryActions ) && (
24
+ <div className="block-editor-warning__actions">
25
+ { Children.count( actions ) > 0 &&
26
+ Children.map( actions, ( action, i ) => (
27
+ <span
28
+ key={ i }
29
+ className="block-editor-warning__action"
30
+ >
31
+ { action }
32
+ </span>
33
+ ) ) }
34
+ { secondaryActions && (
35
+ <DropdownMenu
36
+ className="block-editor-warning__secondary"
37
+ icon={ moreHorizontal }
38
+ label={ __( 'More options' ) }
39
+ popoverProps={ {
40
+ position: 'bottom left',
41
+ className:
42
+ 'block-editor-warning__dropdown',
43
+ } }
44
+ noIcons
27
45
  >
28
- { action }
29
- </span>
30
- ) ) }
31
- { secondaryActions && (
32
- <DropdownMenu
33
- className="block-editor-warning__secondary"
34
- icon={ moreHorizontal }
35
- label={ __( 'More options' ) }
36
- popoverProps={ {
37
- position: 'bottom left',
38
- className: 'block-editor-warning__dropdown',
39
- } }
40
- noIcons
41
- >
42
- { () => (
43
- <MenuGroup>
44
- { secondaryActions.map(
45
- ( item, pos ) => (
46
- <MenuItem
47
- onClick={ item.onClick }
48
- key={ pos }
49
- >
50
- { item.title }
51
- </MenuItem>
52
- )
53
- ) }
54
- </MenuGroup>
55
- ) }
56
- </DropdownMenu>
57
- ) }
58
- </div>
59
- ) }
46
+ { () => (
47
+ <MenuGroup>
48
+ { secondaryActions.map(
49
+ ( item, pos ) => (
50
+ <MenuItem
51
+ onClick={ item.onClick }
52
+ key={ pos }
53
+ >
54
+ { item.title }
55
+ </MenuItem>
56
+ )
57
+ ) }
58
+ </MenuGroup>
59
+ ) }
60
+ </DropdownMenu>
61
+ ) }
62
+ </div>
63
+ ) }
64
+ </div>
60
65
  </div>
61
66
  </div>
62
67
  );
@@ -2,16 +2,25 @@
2
2
 
3
3
  exports[`Warning should match snapshot 1`] = `
4
4
  <div
5
- className="block-editor-warning"
5
+ style={
6
+ Object {
7
+ "all": "initial",
8
+ "display": "contents",
9
+ }
10
+ }
6
11
  >
7
12
  <div
8
- className="block-editor-warning__contents"
13
+ className="block-editor-warning"
9
14
  >
10
- <p
11
- className="block-editor-warning__message"
15
+ <div
16
+ className="block-editor-warning__contents"
12
17
  >
13
- error
14
- </p>
18
+ <p
19
+ className="block-editor-warning__message"
20
+ >
21
+ error
22
+ </p>
23
+ </div>
15
24
  </div>
16
25
  </div>
17
26
  `;
@@ -18,7 +18,7 @@ describe( 'Warning', () => {
18
18
  it( 'should have valid class', () => {
19
19
  const wrapper = shallow( <Warning /> );
20
20
 
21
- expect( wrapper.hasClass( 'block-editor-warning' ) ).toBe( true );
21
+ expect( wrapper.find( '.block-editor-warning' ) ).toHaveLength( 1 );
22
22
  expect( wrapper.find( '.block-editor-warning__actions' ) ).toHaveLength(
23
23
  0
24
24
  );