@wordpress/block-editor 6.1.12 → 6.1.15

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.
Files changed (55) hide show
  1. package/README.md +100 -98
  2. package/build/components/block-list/head.js +27 -0
  3. package/build/components/block-list/head.js.map +1 -0
  4. package/build/components/block-list/index.js +4 -2
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/iframe/index.js +34 -5
  7. package/build/components/iframe/index.js.map +1 -1
  8. package/build/components/rich-text/use-input-rules.js +5 -2
  9. package/build/components/rich-text/use-input-rules.js.map +1 -1
  10. package/build/components/use-setting/index.js +1 -1
  11. package/build/components/use-setting/index.js.map +1 -1
  12. package/build/components/writing-flow/index.js +27 -14
  13. package/build/components/writing-flow/index.js.map +1 -1
  14. package/build/components/writing-flow/use-select-all.js +36 -34
  15. package/build/components/writing-flow/use-select-all.js.map +1 -1
  16. package/build/components/writing-flow/use-tab-nav.js +8 -0
  17. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  18. package/build/hooks/duotone.js +5 -2
  19. package/build/hooks/duotone.js.map +1 -1
  20. package/build/hooks/layout.js +5 -2
  21. package/build/hooks/layout.js.map +1 -1
  22. package/build-module/components/block-list/head.js +19 -0
  23. package/build-module/components/block-list/head.js.map +1 -0
  24. package/build-module/components/block-list/index.js +3 -2
  25. package/build-module/components/block-list/index.js.map +1 -1
  26. package/build-module/components/iframe/index.js +34 -5
  27. package/build-module/components/iframe/index.js.map +1 -1
  28. package/build-module/components/rich-text/use-input-rules.js +5 -2
  29. package/build-module/components/rich-text/use-input-rules.js.map +1 -1
  30. package/build-module/components/use-setting/index.js +1 -1
  31. package/build-module/components/use-setting/index.js.map +1 -1
  32. package/build-module/components/writing-flow/index.js +23 -12
  33. package/build-module/components/writing-flow/index.js.map +1 -1
  34. package/build-module/components/writing-flow/use-select-all.js +30 -28
  35. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  36. package/build-module/components/writing-flow/use-tab-nav.js +8 -0
  37. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  38. package/build-module/hooks/duotone.js +5 -2
  39. package/build-module/hooks/duotone.js.map +1 -1
  40. package/build-module/hooks/layout.js +5 -2
  41. package/build-module/hooks/layout.js.map +1 -1
  42. package/build-style/style-rtl.css +1 -1
  43. package/build-style/style.css +1 -1
  44. package/package.json +23 -23
  45. package/src/components/block-list/head.js +18 -0
  46. package/src/components/block-list/index.js +21 -18
  47. package/src/components/block-list-appender/style.scss +3 -4
  48. package/src/components/iframe/index.js +39 -7
  49. package/src/components/rich-text/use-input-rules.js +4 -2
  50. package/src/components/use-setting/index.js +1 -1
  51. package/src/components/writing-flow/index.js +23 -10
  52. package/src/components/writing-flow/use-select-all.js +33 -35
  53. package/src/components/writing-flow/use-tab-nav.js +8 -0
  54. package/src/hooks/duotone.js +13 -5
  55. package/src/hooks/layout.js +12 -4
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["isFormElement","element","tagName","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","keyCode","ESCAPE","stopPropagation","TAB","isShift","shiftKey","direction","next","preventScroll","onFocusOut","preventScrollOnTab","getAttribute","preventDefault","ownerDocument","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;AACjC,QAAM;AAAEC,IAAAA;AAAF,MAAcD,OAApB;AACA,SACCC,OAAO,KAAK,OAAZ,IACAA,OAAO,KAAK,QADZ,IAEAA,O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e,aAAL,CAAmBC,WAAnB,CAA+BE,mBAA/B,CACC,SADD,EAECN,kBAFD;AAIAZ,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,SAA1B,EAAqCjB,SAArC;AACAD,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,UAA1B,EAAsCP,UAAtC;AACA,KAPD;AAQA,GAtGW,EAsGT,EAtGS,CAAZ;AAwGA,QAAMQ,UAAU,GAAG,2BAAc,CAAE7C,SAAF,EAAayB,GAAb,CAAd,CAAnB;AAEA,SAAO,CAAEF,MAAF,EAAUsB,UAAV,EAAsBrB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction isFormElement( element ) {\n\tconst { tagName } = element;\n\treturn (\n\t\ttagName === 'INPUT' ||\n\t\ttagName === 'BUTTON' ||\n\t\ttagName === 'SELECT' ||\n\t\ttagName === 'TEXTAREA'\n\t);\n}\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst { hasMultiSelection, getSelectedBlockClientId } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( event.target ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.defaultView.addEventListener(\n\t\t\t'keydown',\n\t\t\tpreventScrollOnTab\n\t\t);\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tnode.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'keydown',\n\t\t\t\tpreventScrollOnTab\n\t\t\t);\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"names":["isFormElement","element","tagName","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","lastFocus","hasMultiSelection","getSelectedBlockClientId","blockEditorStore","setNavigationMode","isNavigationMode","select","focusCaptureTabIndex","undefined","noCapture","onFocusCapture","event","current","focus","isBefore","target","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","action","tabbable","before","after","ref","node","onKeyDown","keyCode","ESCAPE","stopPropagation","preventDefault","TAB","isShift","shiftKey","direction","next","preventScroll","onFocusOut","preventScrollOnTab","getAttribute","ownerDocument","defaultView","addEventListener","removeEventListener","mergedRefs"],"mappings":";;;;;;;AAOA;;AAJA;;AACA;;AACA;;AACA;;AAMA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGA,SAASA,aAAT,CAAwBC,OAAxB,EAAkC;A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AAEDX,IAAAA,IAAI,CAACe,aAAL,CAAmBC,WAAnB,CAA+BC,gBAA/B,CACC,SADD,EAECJ,kBAFD;AAIAb,IAAAA,IAAI,CAACiB,gBAAL,CAAuB,SAAvB,EAAkChB,SAAlC;AACAD,IAAAA,IAAI,CAACiB,gBAAL,CAAuB,UAAvB,EAAmCL,UAAnC;AACA,WAAO,MAAM;AACZZ,MAAAA,IAAI,CAACe,aAAL,CAAmBC,WAAnB,CAA+BE,mBAA/B,CACC,SADD,EAECL,kBAFD;AAIAb,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,SAA1B,EAAqCjB,SAArC;AACAD,MAAAA,IAAI,CAACkB,mBAAL,CAA0B,UAA1B,EAAsCN,UAAtC;AACA,KAPD;AAQA,GA9GW,EA8GT,EA9GS,CAAZ;AAgHA,QAAMO,UAAU,GAAG,2BAAc,CAAE7C,SAAF,EAAayB,GAAb,CAAd,CAAnB;AAEA,SAAO,CAAEF,MAAF,EAAUsB,UAAV,EAAsBrB,KAAtB,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus } from '@wordpress/dom';\nimport { TAB, ESCAPE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nfunction isFormElement( element ) {\n\tconst { tagName } = element;\n\treturn (\n\t\ttagName === 'INPUT' ||\n\t\ttagName === 'BUTTON' ||\n\t\ttagName === 'SELECT' ||\n\t\ttagName === 'TEXTAREA'\n\t);\n}\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\tconst lastFocus = useRef();\n\tconst { hasMultiSelection, getSelectedBlockClientId } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst { setNavigationMode } = useDispatch( blockEditorStore );\n\tconst isNavigationMode = useSelect(\n\t\t( select ) => select( blockEditorStore ).isNavigationMode(),\n\t\t[]\n\t);\n\n\t// Don't allow tabbing to this element in Navigation mode.\n\tconst focusCaptureTabIndex = ! isNavigationMode ? '0' : undefined;\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCapture = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCapture.current ) {\n\t\t\tnoCapture.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tlastFocus.current.focus();\n\t\t} else {\n\t\t\tsetNavigationMode( true );\n\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( container.current ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst action = isBefore ? 'findNext' : 'findPrevious';\n\n\t\t\tfocus.tabbable[ action ]( event.target ).focus();\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex={ focusCaptureTabIndex }\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.keyCode === ESCAPE && ! hasMultiSelection() ) {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\t// Preserve the behaviour of entering navigation mode when\n\t\t\t\t// tabbing into the content without a block selection.\n\t\t\t\t// `onFocusCapture` already did this previously, but we need to\n\t\t\t\t// do it again here because after clearing block selection,\n\t\t\t\t// focus land on the writing flow container and pressing Tab\n\t\t\t\t// will no longer send focus through the focus capture element.\n\t\t\t\tif ( event.target === node ) setNavigationMode( true );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Allow tabbing between form elements rendered in a block,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( event.target ) &&\n\t\t\t\tisFormElement( focus.tabbable[ direction ]( event.target ) )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCapture.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tlastFocus.current = event.target;\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tnode.ownerDocument.defaultView.addEventListener(\n\t\t\t'keydown',\n\t\t\tpreventScrollOnTab\n\t\t);\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tnode.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'keydown',\n\t\t\t\tpreventScrollOnTab\n\t\t\t);\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"]}
@@ -25,6 +25,8 @@ var _hooks = require("@wordpress/hooks");
25
25
 
26
26
  var _components2 = require("../components");
27
27
 
28
+ var _head = require("../components/block-list/head");
29
+
28
30
  /**
29
31
  * External dependencies
30
32
  */
@@ -227,11 +229,12 @@ const withDuotoneStyles = (0, _compose.createHigherOrderComponent)(BlockListBloc
227
229
  const selectorsScoped = selectors.map(selector => `.${id} ${selector.trim()}`);
228
230
  const selectorsGroup = selectorsScoped.join(', ');
229
231
  const className = (0, _classnames.default)(props === null || props === void 0 ? void 0 : props.className, id);
230
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(DuotoneFilter, {
232
+ const element = (0, _element.useContext)(_head.Head.context);
233
+ return (0, _element.createElement)(_element.Fragment, null, element && (0, _element.createPortal)((0, _element.createElement)(DuotoneFilter, {
231
234
  selector: selectorsGroup,
232
235
  id: id,
233
236
  values: getValuesFromColors(values)
234
- }), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
237
+ }), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
235
238
  className: className
236
239
  })));
237
240
  }, 'withDuotoneStyles');
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","forEach","color","tcolor","push","_r","_g","_b","DuotoneFilter","selector","id","stylesheet","visibility","position","left","overflow","join","__html","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","withDuotoneStyles","BlockListBlock","duotoneSupport","selectors","split","selectorsScoped","map","trim","selectorsGroup","className"],"mappings":";;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAKA;;AAjBA;AACA;AACA;;AAIA;AACA;AACA;;AAMA;AACA;AACA;AAOA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;A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C,KAArB;AAA6B,IAAA,SAAS,EAAGY;AAAzC,KAND,CADD;AAUA,CAhCwB,EAiCzB,mBAjCyB,CAA1B;AAoCA,sBACC,0BADD,EAEC,oCAFD,EAGCnB,oBAHD;AAKA,sBACC,kBADD,EAEC,0CAFD,EAGCK,mBAHD;AAKA,sBACC,uBADD,EAEC,iCAFD,EAGCK,iBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport tinycolor from 'tinycolor2';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\t// Access values directly to skip extra rounding that tinycolor.toRgb() does.\n\t\tconst tcolor = tinycolor( color );\n\t\tvalues.r.push( tcolor._r / 255 );\n\t\tvalues.g.push( tcolor._g / 255 );\n\t\tvalues.b.push( tcolor._b / 255 );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n */\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, and B values to filter with.\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { selector, id, values } ) {\n\tconst stylesheet = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\n\treturn (\n\t\t<>\n\t\t\t<SVG\n\t\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<defs>\n\t\t\t\t\t<filter id={ id }>\n\t\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\t// prettier-ignore\n\t\t\t\t\t\t\tvalues=\".299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t 0 0 0 1 0\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t</filter>\n\t\t\t\t</defs>\n\t\t\t</SVG>\n\t\t\t<style dangerouslySetInnerHTML={ { __html: stylesheet } } />\n\t\t</>\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY;\n\tconst colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\">\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-filter-${ useInstanceId( BlockListBlock ) }`;\n\n\t\tconst selectors = duotoneSupport.split( ',' );\n\t\tconst selectorsScoped = selectors.map(\n\t\t\t( selector ) => `.${ id } ${ selector.trim() }`\n\t\t);\n\t\tconst selectorsGroup = selectorsScoped.join( ', ' );\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<DuotoneFilter\n\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\tid={ id }\n\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t/>\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/duotone.js"],"names":["EMPTY_ARRAY","getValuesFromColors","colors","values","r","g","b","forEach","color","tcolor","push","_r","_g","_b","DuotoneFilter","selector","id","stylesheet","visibility","position","left","overflow","join","__html","DuotonePanel","attributes","setAttributes","style","duotone","duotonePalette","colorPalette","disableCustomColors","disableCustomDuotone","length","newDuotone","newStyle","addDuotoneAttributes","settings","Object","assign","type","withDuotoneControls","BlockEdit","props","hasDuotoneSupport","name","withDuotoneStyles","BlockListBlock","duotoneSupport","selectors","split","selectorsScoped","map","trim","selectorsGroup","className","element","Head","context"],"mappings":";;;;;;;;;AAaA;;;;AAVA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AAKA;;AAvBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAQA,MAAMA,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,mBAAT,CAA8BC,MAAM,GAAG,EAAvC,EAA4C;AAClD,QAAMC,MAAM,GAAG;AAAEC,IAAAA,CAAC,EAAE,EAAL;AAASC,IAAAA,CAAC,EAAE,EAAZ;AAAgBC,IAAAA,CAAC,EAAE;AAAnB,GAAf;AAEAJ,EAAAA,MAAM,CAACK,OAAP,CAAkBC,KAAF,IAAa;AAC5B;AACA,UAAMC,MAAM,GAAG,wBAAWD,KAAX,CAAf;AACAL,IAAAA,MAAM,CAACC,CAAP,CAASM,IAAT,CAAeD,MAAM,CAACE,EAAP,GAAY,GAA3B;AACAR,IAAAA,MAAM,CAACE,C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n * WordPress dependencies\n */\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { SVG } from '@wordpress/components';\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tBlockControls,\n\t__experimentalDuotoneControl as DuotoneControl,\n\tuseSetting,\n} from '../components';\nimport { Head } from '../components/block-list/head';\n\nconst EMPTY_ARRAY = [];\n\n/**\n * Convert a list of colors to an object of R, G, and B values.\n *\n * @param {string[]} colors Array of RBG color strings.\n *\n * @return {Object} R, G, and B values.\n */\nexport function getValuesFromColors( colors = [] ) {\n\tconst values = { r: [], g: [], b: [] };\n\n\tcolors.forEach( ( color ) => {\n\t\t// Access values directly to skip extra rounding that tinycolor.toRgb() does.\n\t\tconst tcolor = tinycolor( color );\n\t\tvalues.r.push( tcolor._r / 255 );\n\t\tvalues.g.push( tcolor._g / 255 );\n\t\tvalues.b.push( tcolor._b / 255 );\n\t} );\n\n\treturn values;\n}\n\n/**\n * Values for the SVG `feComponentTransfer`.\n *\n * @typedef Values {Object}\n * @property {number[]} r Red values.\n * @property {number[]} g Green values.\n * @property {number[]} b Blue values.\n */\n\n/**\n * SVG and stylesheet needed for rendering the duotone filter.\n *\n * @param {Object} props Duotone props.\n * @param {string} props.selector Selector to apply the filter to.\n * @param {string} props.id Unique id for this duotone filter.\n * @param {Values} props.values R, G, and B values to filter with.\n * @return {WPElement} Duotone element.\n */\nfunction DuotoneFilter( { selector, id, values } ) {\n\tconst stylesheet = `\n${ selector } {\n\tfilter: url( #${ id } );\n}\n`;\n\n\treturn (\n\t\t<>\n\t\t\t<SVG\n\t\t\t\txmlnsXlink=\"http://www.w3.org/1999/xlink\"\n\t\t\t\tviewBox=\"0 0 0 0\"\n\t\t\t\twidth=\"0\"\n\t\t\t\theight=\"0\"\n\t\t\t\tfocusable=\"false\"\n\t\t\t\trole=\"none\"\n\t\t\t\tstyle={ {\n\t\t\t\t\tvisibility: 'hidden',\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\tleft: '-9999px',\n\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<defs>\n\t\t\t\t\t<filter id={ id }>\n\t\t\t\t\t\t<feColorMatrix\n\t\t\t\t\t\t\ttype=\"matrix\"\n\t\t\t\t\t\t\t// Use perceptual brightness to convert to grayscale.\n\t\t\t\t\t\t\t// prettier-ignore\n\t\t\t\t\t\t\tvalues=\".299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t .299 .587 .114 0 0\n\t\t\t\t\t\t\t 0 0 0 1 0\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<feComponentTransfer\n\t\t\t\t\t\t\t// Use sRGB instead of linearRGB to be consistent with how CSS gradients work.\n\t\t\t\t\t\t\tcolorInterpolationFilters=\"sRGB\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<feFuncR\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.r.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncG\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.g.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<feFuncB\n\t\t\t\t\t\t\t\ttype=\"table\"\n\t\t\t\t\t\t\t\ttableValues={ values.b.join( ' ' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</feComponentTransfer>\n\t\t\t\t\t</filter>\n\t\t\t\t</defs>\n\t\t\t</SVG>\n\t\t\t<style dangerouslySetInnerHTML={ { __html: stylesheet } } />\n\t\t</>\n\t);\n}\n\nfunction DuotonePanel( { attributes, setAttributes } ) {\n\tconst style = attributes?.style;\n\tconst duotone = style?.color?.duotone;\n\n\tconst duotonePalette = useSetting( 'color.duotone' ) || EMPTY_ARRAY;\n\tconst colorPalette = useSetting( 'color.palette' ) || EMPTY_ARRAY;\n\tconst disableCustomColors = ! useSetting( 'color.custom' );\n\tconst disableCustomDuotone =\n\t\t! useSetting( 'color.customDuotone' ) ||\n\t\t( colorPalette?.length === 0 && disableCustomColors );\n\n\tif ( duotonePalette?.length === 0 && disableCustomDuotone ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockControls group=\"block\">\n\t\t\t<DuotoneControl\n\t\t\t\tduotonePalette={ duotonePalette }\n\t\t\t\tcolorPalette={ colorPalette }\n\t\t\t\tdisableCustomDuotone={ disableCustomDuotone }\n\t\t\t\tdisableCustomColors={ disableCustomColors }\n\t\t\t\tvalue={ duotone }\n\t\t\t\tonChange={ ( newDuotone ) => {\n\t\t\t\t\tconst newStyle = {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t...style?.color,\n\t\t\t\t\t\t\tduotone: newDuotone,\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tsetAttributes( { style: newStyle } );\n\t\t\t\t} }\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include\n * the `duotone` attribute.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nfunction addDuotoneAttributes( settings ) {\n\tif ( ! hasBlockSupport( settings, 'color.__experimentalDuotone' ) ) {\n\t\treturn settings;\n\t}\n\n\t// Allow blocks to specify their own attribute definition with default\n\t// values if needed.\n\tif ( ! settings.attributes.style ) {\n\t\tObject.assign( settings.attributes, {\n\t\t\tstyle: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include toolbar controls for duotone if the\n * block supports duotone.\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nconst withDuotoneControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst hasDuotoneSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ hasDuotoneSupport && <DuotonePanel { ...props } /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneControls'\n);\n\n/**\n * Override the default block element to include duotone styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nconst withDuotoneStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst duotoneSupport = getBlockSupport(\n\t\t\tprops.name,\n\t\t\t'color.__experimentalDuotone'\n\t\t);\n\t\tconst values = props?.attributes?.style?.color?.duotone;\n\n\t\tif ( ! duotoneSupport || ! values ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\n\t\tconst id = `wp-duotone-filter-${ useInstanceId( BlockListBlock ) }`;\n\n\t\tconst selectors = duotoneSupport.split( ',' );\n\t\tconst selectorsScoped = selectors.map(\n\t\t\t( selector ) => `.${ id } ${ selector.trim() }`\n\t\t);\n\t\tconst selectorsGroup = selectorsScoped.join( ', ' );\n\n\t\tconst className = classnames( props?.className, id );\n\n\t\tconst element = useContext( Head.context );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<DuotoneFilter\n\t\t\t\t\t\t\tselector={ selectorsGroup }\n\t\t\t\t\t\t\tid={ id }\n\t\t\t\t\t\t\tvalues={ getValuesFromColors( values ) }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t},\n\t'withDuotoneStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/editor/duotone/add-attributes',\n\taddDuotoneAttributes\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/duotone/with-editor-controls',\n\twithDuotoneControls\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/duotone/with-styles',\n\twithDuotoneStyles\n);\n"]}
@@ -38,6 +38,8 @@ var _useSetting = _interopRequireDefault(require("../components/use-setting"));
38
38
 
39
39
  var _layout = require("../components/block-list/layout");
40
40
 
41
+ var _head = require("../components/block-list/head");
42
+
41
43
  /**
42
44
  * External dependencies
43
45
  */
@@ -209,10 +211,11 @@ const withLayoutStyles = (0, _compose.createHigherOrderComponent)(BlockListBlock
209
211
  } = attributes;
210
212
  const usedLayout = !!layout && layout.inherit ? defaultLayout : layout;
211
213
  const className = (0, _classnames.default)(props === null || props === void 0 ? void 0 : props.className, `wp-container-${id}`);
212
- return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_layout.LayoutStyle, {
214
+ const element = (0, _element.useContext)(_head.Head.context);
215
+ return (0, _element.createElement)(_element.Fragment, null, element && (0, _element.createPortal)((0, _element.createElement)(_layout.LayoutStyle, {
213
216
  selector: `.wp-container-${id}`,
214
217
  layout: usedLayout
215
- }), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
218
+ }), element), (0, _element.createElement)(BlockListBlock, (0, _extends2.default)({}, props, {
216
219
  className: className
217
220
  })));
218
221
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["LayoutPanel","setAttributes","attributes","layout","wideSize","contentSize","inherit","defaultLayout","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","units","availableUnits","nextWidth","parseFloat","positionCenter","stretchWide","undefined","addAttribute","settings","type","withInspectorControls","BlockEdit","props","name","blockName","supportLayout","withLayoutStyles","BlockListBlock","id","usedLayout","className"],"mappings":";;;;;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAIA;AACA;AACA;;A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ClC,QAAM;AAAEC,IAAAA,IAAF;AAAQxB,IAAAA;AAAR,MAAuBuB,KAA7B;AACA,QAAMG,aAAa,GAAG,6BAAiBF,IAAjB,EAAuB,sBAAvB,CAAtB;AACA,QAAMK,EAAE,GAAG,4BAAeD,cAAf,CAAX;AACA,QAAMvB,aAAa,GAAG,yBAAY,QAAZ,KAA0B,EAAhD;;AACA,MAAK,CAAEqB,aAAP,EAAuB;AACtB,WAAO,4BAAC,cAAD,EAAqBH,KAArB,CAAP;AACA;;AACD,QAAM;AAAEtB,IAAAA,MAAM,GAAG;AAAX,MAAkBD,UAAxB;AACA,QAAM8B,UAAU,GAAG,CAAC,CAAE7B,MAAH,IAAaA,MAAM,CAACG,OAApB,GAA8BC,aAA9B,GAA8CJ,MAAjE;AACA,QAAM8B,SAAS,GAAG,yBACjBR,KADiB,aACjBA,KADiB,uBACjBA,KAAK,CAAEQ,SADU,EAEhB,gBAAgBF,EAAI,EAFJ,CAAlB;AAKA,SACC,qDACC,4BAAC,mBAAD;AACC,IAAA,QAAQ,EAAI,iBAAiBA,EAAI,EADlC;AAEC,IAAA,MAAM,EAAGC;AAFV,IADD,EAKC,4BAAC,cAAD,6BAAqBP,KAArB;AAA6B,IAAA,SAAS,EAAGQ;AAAzC,KALD,CADD;AASA,CAzB8B,CAAzB;;AA4BP,sBACC,0BADD,EAEC,0BAFD,EAGCb,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCS,gBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCN,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tToggleControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, positionCenter, stretchWide } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\n\nfunction LayoutPanel( { setAttributes, attributes } ) {\n\tconst { layout = {} } = attributes;\n\tconst { wideSize, contentSize, inherit = false } = layout;\n\tconst defaultLayout = useSetting( 'layout' );\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().supportsLayout;\n\t}, [] );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tif ( ! themeSupportsLayout ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t{ !! defaultLayout && (\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Inherit default layout' ) }\n\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { layout: { inherit: ! inherit } } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\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} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\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} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-reset\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tisSecondary\n\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\tdisabled={ ! contentSize && ! wideSize }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: undefined,\n\t\t\t\t\t\t\t\t\t\t\twideSize: undefined,\n\t\t\t\t\t\t\t\t\t\t\tinherit: false,\n\t\t\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}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nexport function addAttribute( settings ) {\n\tif ( has( settings.attributes, [ 'layout', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, '__experimentalLayout' ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\t'__experimentalLayout'\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst supportLayout = hasBlockSupport( name, '__experimentalLayout' );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultLayout = useSetting( 'layout' ) || {};\n\t\tif ( ! supportLayout ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst { layout = {} } = attributes;\n\t\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\t\tconst className = classnames(\n\t\t\tprops?.className,\n\t\t\t`wp-container-${ id }`\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<LayoutStyle\n\t\t\t\t\tselector={ `.wp-container-${ id }` }\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t/>\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/layout.js"],"names":["LayoutPanel","setAttributes","attributes","layout","wideSize","contentSize","inherit","defaultLayout","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","units","availableUnits","nextWidth","parseFloat","positionCenter","stretchWide","undefined","addAttribute","settings","type","withInspectorControls","BlockEdit","props","name","blockName","supportLayout","withLayoutStyles","BlockListBlock","id","usedLayout","className","element","Head","context"],"mappings":";;;;;;;;;;AAsBA;;;;AAnBA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AA/BA;AACA;AACA;;AAIA;AACA;AACA;;AAgBA;AACA;AACA;AAOA,SAASA,WAAT,CAAsB;AAAEC,EAAAA,aAAF;AAAiBC,EAAAA;AAAjB,CAAtB,EAAsD;AACrD,QAAM;AAAEC,IAAAA,MAAM,GAAG;AAAX,MAAkBD,UAAxB;AACA,QAAM;AAAEE,IAAAA,QAAF;AAAYC,IAAAA,WAAZ;AAAyBC,IAAAA,OAAO,GAAG;AAAnC,MAA6CH,MAAnD;AACA,QAAMI,aAAa,GAAG,yBAAY,QAAZ,CAAtB;AACA,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,YAAF,CAA9B;AACA,WAAOD,WAAW,GAAGE,cAArB;AACA,GAH2B,EAGzB,EAHyB,CAA5B;AAKA,QAAMC,KAAK,GAAG,8CAAgB;AAC7BC,IAAAA,cAAc,EAAE,yBAAY,eAAZ,KAAiC,CAChD,GADgD,EAEhD,IAFgD,EAGhD,IAHgD,EAIhD,KAJgD,EAKhD,IALgD;AADpB,GAAhB,CAAd;;AAUA,MAAK,CAAEN,mBAAP,EAA6B;AAC5B,WAAO,IAAP;AACA;;AACD,SACC,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAA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CE,OALD,CAFF,EASC,4BAAC,cAAD,6BAAqBT,KAArB;AAA6B,IAAA,SAAS,EAAGQ;AAAzC,KATD,CADD;AAaA,CA/B8B,CAAzB;;AAkCP,sBACC,0BADD,EAEC,0BAFD,EAGCb,YAHD;AAKA,sBACC,uBADD,EAEC,uCAFD,EAGCS,gBAHD;AAKA,sBACC,kBADD,EAEC,4CAFD,EAGCN,qBAHD","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { has } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tToggleControl,\n\tPanelBody,\n\t__experimentalUseCustomUnits as useCustomUnits,\n\t__experimentalUnitControl as UnitControl,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, positionCenter, stretchWide } from '@wordpress/icons';\nimport { useContext, createPortal } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport useSetting from '../components/use-setting';\nimport { LayoutStyle } from '../components/block-list/layout';\nimport { Head } from '../components/block-list/head';\n\nfunction LayoutPanel( { setAttributes, attributes } ) {\n\tconst { layout = {} } = attributes;\n\tconst { wideSize, contentSize, inherit = false } = layout;\n\tconst defaultLayout = useSetting( 'layout' );\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().supportsLayout;\n\t}, [] );\n\n\tconst units = useCustomUnits( {\n\t\tavailableUnits: useSetting( 'spacing.units' ) || [\n\t\t\t'%',\n\t\t\t'px',\n\t\t\t'em',\n\t\t\t'rem',\n\t\t\t'vw',\n\t\t],\n\t} );\n\n\tif ( ! themeSupportsLayout ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t{ !! defaultLayout && (\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Inherit default layout' ) }\n\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\tonChange={ () =>\n\t\t\t\t\t\t\tsetAttributes( { layout: { inherit: ! inherit } } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls\">\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Content' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ contentSize || wideSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\t\tcontentSize: nextWidth,\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} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ positionCenter } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-unit\">\n\t\t\t\t\t\t\t\t<UnitControl\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Wide' ) }\n\t\t\t\t\t\t\t\t\tlabelPosition=\"top\"\n\t\t\t\t\t\t\t\t\t__unstableInputWidth=\"80px\"\n\t\t\t\t\t\t\t\t\tvalue={ wideSize || contentSize || '' }\n\t\t\t\t\t\t\t\t\tonChange={ ( nextWidth ) => {\n\t\t\t\t\t\t\t\t\t\tnextWidth =\n\t\t\t\t\t\t\t\t\t\t\t0 > parseFloat( nextWidth )\n\t\t\t\t\t\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t\t\t\t\t\t: nextWidth;\n\t\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\t\t...layout,\n\t\t\t\t\t\t\t\t\t\t\t\twideSize: nextWidth,\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} }\n\t\t\t\t\t\t\t\t\tunits={ units }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<Icon icon={ stretchWide } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-editor-hooks__layout-controls-reset\">\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tisSecondary\n\t\t\t\t\t\t\t\tisSmall\n\t\t\t\t\t\t\t\tdisabled={ ! contentSize && ! wideSize }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\t\t\t\t\tcontentSize: undefined,\n\t\t\t\t\t\t\t\t\t\t\twideSize: undefined,\n\t\t\t\t\t\t\t\t\t\t\tinherit: false,\n\t\t\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}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<p className=\"block-editor-hooks__layout-controls-helptext\">\n\t\t\t\t\t{ __(\n\t\t\t\t\t\t'Customize the width for all elements that are assigned to the center or wide columns.'\n\t\t\t\t\t) }\n\t\t\t\t</p>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings\n * @return {Object} Filtered block settings\n */\nexport function addAttribute( settings ) {\n\tif ( has( settings.attributes, [ 'layout', 'type' ] ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasBlockSupport( settings, '__experimentalLayout' ) ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n}\n\n/**\n * Override the default edit UI to include layout controls\n *\n * @param {Function} BlockEdit Original component\n * @return {Function} Wrapped component\n */\nexport const withInspectorControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst { name: blockName } = props;\n\t\tconst supportLayout = hasBlockSupport(\n\t\t\tblockName,\n\t\t\t'__experimentalLayout'\n\t\t);\n\n\t\treturn [\n\t\t\tsupportLayout && <LayoutPanel key=\"layout\" { ...props } />,\n\t\t\t<BlockEdit key=\"edit\" { ...props } />,\n\t\t];\n\t},\n\t'withInspectorControls'\n);\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component\n * @return {Function} Wrapped component\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { name, attributes } = props;\n\t\tconst supportLayout = hasBlockSupport( name, '__experimentalLayout' );\n\t\tconst id = useInstanceId( BlockListBlock );\n\t\tconst defaultLayout = useSetting( 'layout' ) || {};\n\t\tif ( ! supportLayout ) {\n\t\t\treturn <BlockListBlock { ...props } />;\n\t\t}\n\t\tconst { layout = {} } = attributes;\n\t\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\t\tconst className = classnames(\n\t\t\tprops?.className,\n\t\t\t`wp-container-${ id }`\n\t\t);\n\n\t\tconst element = useContext( Head.context );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ element &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\tselector={ `.wp-container-${ id }` }\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t/>,\n\t\t\t\t\t\telement\n\t\t\t\t\t) }\n\t\t\t\t<BlockListBlock { ...props } className={ className } />\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n\taddAttribute\n);\naddFilter(\n\t'editor.BlockListBlock',\n\t'core/editor/layout/with-layout-styles',\n\twithLayoutStyles\n);\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/layout/with-inspector-controls',\n\twithInspectorControls\n);\n"]}
@@ -0,0 +1,19 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { createContext, useState } from '@wordpress/element';
7
+ const context = createContext();
8
+ export function Head({
9
+ children
10
+ }) {
11
+ const [element, setElement] = useState();
12
+ return createElement(context.Provider, {
13
+ value: element
14
+ }, createElement("div", {
15
+ ref: setElement
16
+ }), children);
17
+ }
18
+ Head.context = context;
19
+ //# sourceMappingURL=head.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/head.js"],"names":["createContext","useState","context","Head","children","element","setElement"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,QAAxB,QAAwC,oBAAxC;AAEA,MAAMC,OAAO,GAAGF,aAAa,EAA7B;AAEA,OAAO,SAASG,IAAT,CAAe;AAAEC,EAAAA;AAAF,CAAf,EAA8B;AACpC,QAAM,CAAEC,OAAF,EAAWC,UAAX,IAA0BL,QAAQ,EAAxC;AACA,SACC,cAAC,OAAD,CAAS,QAAT;AAAkB,IAAA,KAAK,EAAGI;AAA1B,KACC;AAAK,IAAA,GAAG,EAAGC;AAAX,IADD,EAEGF,QAFH,CADD;AAMA;AAEDD,IAAI,CAACD,OAAL,GAAeA,OAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createContext, useState } from '@wordpress/element';\n\nconst context = createContext();\n\nexport function Head( { children } ) {\n\tconst [ element, setElement ] = useState();\n\treturn (\n\t\t<context.Provider value={ element }>\n\t\t\t<div ref={ setElement } />\n\t\t\t{ children }\n\t\t</context.Provider>\n\t);\n}\n\nHead.context = context;\n"]}
@@ -24,6 +24,7 @@ import { usePreParsePatterns } from '../../utils/pre-parse-patterns';
24
24
  import { LayoutProvider, defaultLayout } from './layout';
25
25
  import BlockToolsBackCompat from '../block-tools/back-compat';
26
26
  import { useBlockSelectionClearer } from '../block-selection-clearer';
27
+ import { Head } from './head';
27
28
  export const IntersectionObserver = createContext();
28
29
 
29
30
  function Root({
@@ -50,14 +51,14 @@ function Root({
50
51
  isNavigationMode: _isNavigationMode()
51
52
  };
52
53
  }, []);
53
- return createElement("div", {
54
+ return createElement(Head, null, createElement("div", {
54
55
  ref: useMergeRefs([useBlockSelectionClearer(), useBlockDropZone(), useInBetweenInserter()]),
55
56
  className: classnames('block-editor-block-list__layout is-root-container', className, {
56
57
  'is-outline-mode': isOutlineMode,
57
58
  'is-focus-mode': isFocusMode && isLargeViewport,
58
59
  'is-navigate-mode': isNavigationMode
59
60
  })
60
- }, children);
61
+ }, children));
61
62
  }
62
63
 
63
64
  export default function BlockList({
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"names":["classnames","AsyncModeProvider","useSelect","useViewportMatch","useMergeRefs","createContext","useState","useMemo","BlockListBlock","BlockListAppender","useBlockDropZone","useInBetweenInserter","store","blockEditorStore","usePreParsePatterns","LayoutProvider","defaultLayout","BlockToolsBackCompat","useBlockSelectionClearer","IntersectionObserver","Root","className","children","isLargeViewport","isOutlineMode","isFocusMode","isNavigationMode","select","getSettings","_isNavigationMode","outlineMode","focusMode","BlockList","props","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","__experimentalLayout","layout","intersectingBlocks","setIntersectingBlocks","Set","intersectionObserver","Observer","window","entries","oldIntersectingBlocks","newIntersectingBlocks","entry","clientId","target","getAttribute","action","isIntersecting","order","selectedBlocks","getBlockOrder","getSelectedBlockClientIds","map","has","includes","length","BlockListItems"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,OAAlC,QAAiD,oBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,SAA3B;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,SAASC,oBAAT,QAAqC,2BAArC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASC,cAAT,EAAyBC,aAAzB,QAA8C,UAA9C;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AAEA,OAAO,MAAMC,oBAAoB,GAAGd,aAAa,EAA1C;;AAEP,SAASe,IAAT,CAAe;AAAEC,EAAAA,SAAF;AAAaC,EAAAA;AAAb,CAAf,EAAyC;AACxC,QAAMC,eAAe,GAAGpB,gBAAgB,CAAE,QAAF,CAAxC;AACA,QAAM;AAAEqB,IAAAA,aAAF;AAAiBC,IAAA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ADP;AAEC,IAAA,KAAK,EACJ;AACA;AACA,KAAEV,kBAAkB,CAACoB,GAAnB,CAAwBV,QAAxB,CAAF,IACA,CAAEM,cAAc,CAACK,QAAf,CAAyBX,QAAzB;AANJ,KASC,cAAC,cAAD;AACC,IAAA,YAAY,EAAGf,YADhB;AAEC,IAAA,QAAQ,EAAGe;AAFZ,IATD,CADC,CADH,CADD,EAmBGK,KAAK,CAACO,MAAN,GAAe,CAAf,IAAoB5B,WAnBvB,EAoBC,cAAC,iBAAD;AACC,IAAA,OAAO,EAAGG,6BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,cAAc,EAAGC;AAHlB,IApBD,CADD;AA4BA;;AAED,OAAO,SAAS2B,cAAT,CAAyB/B,KAAzB,EAAiC;AACvC;AACA;AACA,SACC,cAAC,iBAAD;AAAmB,IAAA,KAAK,EAAG;AAA3B,KACC,cAAC,KAAD,EAAYA,KAAZ,CADD,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { createContext, useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { usePreParsePatterns } from '../../utils/pre-parse-patterns';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport BlockToolsBackCompat from '../block-tools/back-compat';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\n\nexport const IntersectionObserver = createContext();\n\nfunction Root( { className, children } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, isNavigationMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, isNavigationMode: _isNavigationMode } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\tisNavigationMode: _isNavigationMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\treturn (\n\t\t<div\n\t\t\tref={ useMergeRefs( [\n\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\tuseBlockDropZone(),\n\t\t\t\tuseInBetweenInserter(),\n\t\t\t] ) }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-list__layout is-root-container',\n\t\t\t\tclassName,\n\t\t\t\t{\n\t\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t\t'is-navigate-mode': isNavigationMode,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t{ children }\n\t\t</div>\n\t);\n}\n\nexport default function BlockList( { className, ...props } ) {\n\tusePreParsePatterns();\n\treturn (\n\t\t<BlockToolsBackCompat>\n\t\t\t<Root className={ className }>\n\t\t\t\t<BlockListItems { ...props } />\n\t\t\t</Root>\n\t\t</BlockToolsBackCompat>\n\t);\n}\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\t__experimentalLayout: layout = defaultLayout,\n} ) {\n\tconst [ intersectingBlocks, setIntersectingBlocks ] = useState( new Set() );\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tsetIntersectingBlocks( ( oldIntersectingBlocks ) => {\n\t\t\t\tconst newIntersectingBlocks = new Set( oldIntersectingBlocks );\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\t\tconst action = entry.isIntersecting ? 'add' : 'delete';\n\t\t\t\t\tnewIntersectingBlocks[ action ]( clientId );\n\t\t\t\t}\n\t\t\t\treturn newIntersectingBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ setIntersectingBlocks ] );\n\tconst { order, selectedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockOrder, getSelectedBlockClientIds } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t\t<AsyncModeProvider\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t\t! intersectingBlocks.has( clientId ) &&\n\t\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t) ) }\n\t\t\t</IntersectionObserver.Provider>\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t/>\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-list/index.js"],"names":["classnames","AsyncModeProvider","useSelect","useViewportMatch","useMergeRefs","createContext","useState","useMemo","BlockListBlock","BlockListAppender","useBlockDropZone","useInBetweenInserter","store","blockEditorStore","usePreParsePatterns","LayoutProvider","defaultLayout","BlockToolsBackCompat","useBlockSelectionClearer","Head","IntersectionObserver","Root","className","children","isLargeViewport","isOutlineMode","isFocusMode","isNavigationMode","select","getSettings","_isNavigationMode","outlineMode","focusMode","BlockList","props","Items","placeholder","rootClientId","renderAppender","__experimentalAppenderTagName","__experimentalLayout","layout","intersectingBlocks","setIntersectingBlocks","Set","intersectionObserver","Observer","window","entries","oldIntersectingBlocks","newIntersectingBlocks","entry","clientId","target","getAttribute","action","isIntersecting","order","selectedBlocks","getBlockOrder","getSelectedBlockClientIds","map","has","includes","length","BlockListItems"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,iBAAT,EAA4BC,SAA5B,QAA6C,iBAA7C;AACA,SAASC,gBAAT,EAA2BC,YAA3B,QAA+C,oBAA/C;AACA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,OAAlC,QAAiD,oBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,SAA3B;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,gBAAP,MAA6B,wBAA7B;AACA,SAASC,oBAAT,QAAqC,2BAArC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,mBAAT,QAAoC,gCAApC;AACA,SAASC,cAAT,EAAyBC,aAAzB,QAA8C,UAA9C;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,IAAT,QAAqB,QAArB;AAEA,OAAO,MAAMC,oBAAo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,YAAF,CAV0C,CAA3C;AAaA,SACC,cAAC,cAAD;AAAgB,IAAA,KAAK,EAAGI;AAAxB,KACC,cAAC,oBAAD,CAAsB,QAAtB;AAA+B,IAAA,KAAK,EAAGI;AAAvC,KACGY,KAAK,CAACI,GAAN,CAAaT,QAAF,IACZ,cAAC,iBAAD;AACC,IAAA,GAAG,EAAGA,QADP;AAEC,IAAA,KAAK,EACJ;AACA;AACA,KAAEV,kBAAkB,CAACoB,GAAnB,CAAwBV,QAAxB,CAAF,IACA,CAAEM,cAAc,CAACK,QAAf,CAAyBX,QAAzB;AANJ,KASC,cAAC,cAAD;AACC,IAAA,YAAY,EAAGf,YADhB;AAEC,IAAA,QAAQ,EAAGe;AAFZ,IATD,CADC,CADH,CADD,EAmBGK,KAAK,CAACO,MAAN,GAAe,CAAf,IAAoB5B,WAnBvB,EAoBC,cAAC,iBAAD;AACC,IAAA,OAAO,EAAGG,6BADX;AAEC,IAAA,YAAY,EAAGF,YAFhB;AAGC,IAAA,cAAc,EAAGC;AAHlB,IApBD,CADD;AA4BA;;AAED,OAAO,SAAS2B,cAAT,CAAyB/B,KAAzB,EAAiC;AACvC;AACA;AACA,SACC,cAAC,iBAAD;AAAmB,IAAA,KAAK,EAAG;AAA3B,KACC,cAAC,KAAD,EAAYA,KAAZ,CADD,CADD;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport { useViewportMatch, useMergeRefs } from '@wordpress/compose';\nimport { createContext, useState, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockListBlock from './block';\nimport BlockListAppender from '../block-list-appender';\nimport useBlockDropZone from '../use-block-drop-zone';\nimport { useInBetweenInserter } from './use-in-between-inserter';\nimport { store as blockEditorStore } from '../../store';\nimport { usePreParsePatterns } from '../../utils/pre-parse-patterns';\nimport { LayoutProvider, defaultLayout } from './layout';\nimport BlockToolsBackCompat from '../block-tools/back-compat';\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { Head } from './head';\n\nexport const IntersectionObserver = createContext();\n\nfunction Root( { className, children } ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { isOutlineMode, isFocusMode, isNavigationMode } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings, isNavigationMode: _isNavigationMode } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\tconst { outlineMode, focusMode } = getSettings();\n\t\t\treturn {\n\t\t\t\tisOutlineMode: outlineMode,\n\t\t\t\tisFocusMode: focusMode,\n\t\t\t\tisNavigationMode: _isNavigationMode(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\treturn (\n\t\t<Head>\n\t\t\t<div\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tuseBlockSelectionClearer(),\n\t\t\t\t\tuseBlockDropZone(),\n\t\t\t\t\tuseInBetweenInserter(),\n\t\t\t\t] ) }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-block-list__layout is-root-container',\n\t\t\t\t\tclassName,\n\t\t\t\t\t{\n\t\t\t\t\t\t'is-outline-mode': isOutlineMode,\n\t\t\t\t\t\t'is-focus-mode': isFocusMode && isLargeViewport,\n\t\t\t\t\t\t'is-navigate-mode': isNavigationMode,\n\t\t\t\t\t}\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Head>\n\t);\n}\n\nexport default function BlockList( { className, ...props } ) {\n\tusePreParsePatterns();\n\treturn (\n\t\t<BlockToolsBackCompat>\n\t\t\t<Root className={ className }>\n\t\t\t\t<BlockListItems { ...props } />\n\t\t\t</Root>\n\t\t</BlockToolsBackCompat>\n\t);\n}\n\nfunction Items( {\n\tplaceholder,\n\trootClientId,\n\trenderAppender,\n\t__experimentalAppenderTagName,\n\t__experimentalLayout: layout = defaultLayout,\n} ) {\n\tconst [ intersectingBlocks, setIntersectingBlocks ] = useState( new Set() );\n\tconst intersectionObserver = useMemo( () => {\n\t\tconst { IntersectionObserver: Observer } = window;\n\n\t\tif ( ! Observer ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn new Observer( ( entries ) => {\n\t\t\tsetIntersectingBlocks( ( oldIntersectingBlocks ) => {\n\t\t\t\tconst newIntersectingBlocks = new Set( oldIntersectingBlocks );\n\t\t\t\tfor ( const entry of entries ) {\n\t\t\t\t\tconst clientId = entry.target.getAttribute( 'data-block' );\n\t\t\t\t\tconst action = entry.isIntersecting ? 'add' : 'delete';\n\t\t\t\t\tnewIntersectingBlocks[ action ]( clientId );\n\t\t\t\t}\n\t\t\t\treturn newIntersectingBlocks;\n\t\t\t} );\n\t\t} );\n\t}, [ setIntersectingBlocks ] );\n\tconst { order, selectedBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockOrder, getSelectedBlockClientIds } = select(\n\t\t\t\tblockEditorStore\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torder: getBlockOrder( rootClientId ),\n\t\t\t\tselectedBlocks: getSelectedBlockClientIds(),\n\t\t\t};\n\t\t},\n\t\t[ rootClientId ]\n\t);\n\n\treturn (\n\t\t<LayoutProvider value={ layout }>\n\t\t\t<IntersectionObserver.Provider value={ intersectionObserver }>\n\t\t\t\t{ order.map( ( clientId ) => (\n\t\t\t\t\t<AsyncModeProvider\n\t\t\t\t\t\tkey={ clientId }\n\t\t\t\t\t\tvalue={\n\t\t\t\t\t\t\t// Only provide data asynchronously if the block is\n\t\t\t\t\t\t\t// not visible and not selected.\n\t\t\t\t\t\t\t! intersectingBlocks.has( clientId ) &&\n\t\t\t\t\t\t\t! selectedBlocks.includes( clientId )\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockListBlock\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</AsyncModeProvider>\n\t\t\t\t) ) }\n\t\t\t</IntersectionObserver.Provider>\n\t\t\t{ order.length < 1 && placeholder }\n\t\t\t<BlockListAppender\n\t\t\t\ttagName={ __experimentalAppenderTagName }\n\t\t\t\trootClientId={ rootClientId }\n\t\t\t\trenderAppender={ renderAppender }\n\t\t\t/>\n\t\t</LayoutProvider>\n\t);\n}\n\nexport function BlockListItems( props ) {\n\t// This component needs to always be synchronous as it's the one changing\n\t// the async mode depending on the block selection.\n\treturn (\n\t\t<AsyncModeProvider value={ false }>\n\t\t\t<Items { ...props } />\n\t\t</AsyncModeProvider>\n\t);\n}\n"]}
@@ -44,6 +44,19 @@ function styleSheetsCompat(doc) {
44
44
 
45
45
  if (!cssRules) {
46
46
  return;
47
+ } // Generally, ignore inline styles. We add inline styles belonging to a
48
+ // stylesheet later, which may or may not match the selectors.
49
+
50
+
51
+ if (ownerNode.tagName !== 'LINK') {
52
+ return;
53
+ } // Don't try to add the reset styles, which were removed as a dependency
54
+ // from `edit-blocks` for the iframe since we don't need to reset admin
55
+ // styles.
56
+
57
+
58
+ if (ownerNode.id === 'wp-reset-editor-styles-css') {
59
+ return;
47
60
  }
48
61
 
49
62
  const isMatch = Array.from(cssRules).find(({
@@ -54,8 +67,15 @@ function styleSheetsCompat(doc) {
54
67
  // eslint-disable-next-line no-console
55
68
  console.error(`Stylesheet ${ownerNode.id} was not properly added.
56
69
  For blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).
57
- For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode);
58
- doc.head.appendChild(ownerNode.cloneNode(true));
70
+ For themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`, ownerNode.outerHTML);
71
+ doc.head.appendChild(ownerNode.cloneNode(true)); // Add inline styles belonging to the stylesheet.
72
+
73
+ const inlineCssId = ownerNode.id.replace('-css', '-inline-css');
74
+ const inlineCssElement = document.getElementById(inlineCssId);
75
+
76
+ if (inlineCssElement) {
77
+ doc.head.appendChild(inlineCssElement.cloneNode(true));
78
+ }
59
79
  }
60
80
  });
61
81
  }
@@ -236,15 +256,24 @@ function Iframe({
236
256
  href,
237
257
  id,
238
258
  rel,
239
- media
240
- }, index) => {
259
+ media,
260
+ textContent
261
+ }) => {
241
262
  const TagName = tagName.toLowerCase();
263
+
264
+ if (TagName === 'style') {
265
+ return createElement(TagName, {
266
+ id,
267
+ key: id
268
+ }, textContent);
269
+ }
270
+
242
271
  return createElement(TagName, {
243
272
  href,
244
273
  id,
245
274
  rel,
246
275
  media,
247
- key: index
276
+ key: id
248
277
  });
249
278
  }), head);
250
279
  return createElement("iframe", _extends({}, props, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["useState","createPortal","useCallback","forwardRef","useEffect","useMemo","useReducer","__","useMergeRefs","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","isMatch","find","selectorText","includes","getElementById","id","console","error","head","appendChild","cloneNode","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","setBodyClassName","dir","body","className","classList","startsWith","add","useParsedAssets","html","implementation","createHTMLDocument","innerHTML","children","loadScript","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","contentRef","props","ref","forceRender","iframeDocument","setIframeDocument","styles","__editorAssets","scripts","clearerRef","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","current","reduce","promise","then","finally","map","tagName","href","rel","media","index","TagName","toLowerCase"],"mappings":";;;AAAA;AACA;AACA;AACA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AqBkF,IAAAA,GAArB;AAA0BC,IAAAA;AAA1B,GAAF,EAAqCC,KAArC,KAAgD;AAC7D,UAAMC,OAAO,GAAGL,OAAO,CAACM,WAAR,EAAhB;AACA,WACC,cAAC,OAAD;AAAgBL,MAAAA,IAAhB;AAAsBjF,MAAAA,EAAtB;AAA0BkF,MAAAA,GAA1B;AAA+BC,MAAAA,KAA/B;AAAyC,MAAA,GAAG,EAAGC;AAA/C,MADD;AAGA,GALC,CAFH,EAQGjF,IARH,CADD;AAaA,SACC,qCACMwD,KADN;AAEC,IAAA,GAAG,EAAGjF,YAAY,CAAE,CAAEkF,GAAF,EAAOQ,MAAP,CAAF,CAFnB;AAGC,IAAA,QAAQ,EAAC,GAHV;AAIC,IAAA,KAAK,EAAG3F,EAAE,CAAE,eAAF,CAJX;AAKC,IAAA,IAAI,EAAC;AALN,MAOGqF,cAAc,IACf3F,YAAY,CACX,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAG2F;AAA1B,KACGf,QADH,CADW,EAIXe,cAAc,CAACzB,IAJJ,CARd,EAcGyB,cAAc,IAAI3F,YAAY,CAAEgC,IAAF,EAAQ2D,cAAc,CAAC3D,IAAvB,CAdjC,CADD;AAkBA;;AAED,eAAe9B,UAAU,CAAEoF,MAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tuseCallback,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\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\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// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`Stylesheet ${ ownerNode.id } was not properly added.\nFor blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).\nFor themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,\n\t\t\t\townerNode\n\t\t\t);\n\t\t\tdoc.head.appendChild( ownerNode.cloneNode( true ) );\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 = [ 'keydown', 'keypress', 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\n/**\n * Sets the document direction.\n *\n * Sets the `editor-styles-wrapper` class name on the body.\n *\n * Copies the `admin-color-*` class name to the body so that the admin color\n * scheme applies to components in the iframe.\n *\n * @param {Document} doc Document to add class name to.\n */\nfunction setBodyClassName( doc ) {\n\tdoc.dir = document.dir;\n\tdoc.body.className = BODY_CLASS_NAME;\n\n\tfor ( const name of document.body.classList ) {\n\t\tif ( name.startsWith( 'admin-color-' ) ) {\n\t\t\tdoc.body.classList.add( name );\n\t\t} else if ( name === 'wp-embed-responsive' ) {\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\tdoc.body.classList.add( 'wp-embed-responsive' );\n\t\t}\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( doc, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = doc.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\tdoc.head.appendChild( script );\n\t} );\n}\n\nfunction Iframe( { contentRef, children, head, ...props }, ref ) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst styles = useParsedAssets( window.__editorAssets.styles );\n\tconst scripts = useParsedAssets( window.__editorAssets.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst setRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { readyState, body, 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\tif ( typeof contentRef === 'function' ) {\n\t\t\t\tcontentRef( body );\n\t\t\t} else if ( contentRef ) {\n\t\t\t\tcontentRef.current = body;\n\t\t\t}\n\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\t\t\tclearerRef( body );\n\n\t\t\tscripts\n\t\t\t\t.reduce(\n\t\t\t\t\t( promise, script ) =>\n\t\t\t\t\t\tpromise.then( () =>\n\t\t\t\t\t\t\tloadScript( contentDocument, script )\n\t\t\t\t\t\t),\n\t\t\t\t\tPromise.resolve()\n\t\t\t\t)\n\t\t\t\t.finally( () => {\n\t\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t\t// to initialise.\n\t\t\t\t\tforceRender();\n\t\t\t\t} );\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( setDocumentIfReady() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Document is not immediately loaded in Firefox.\n\t\tnode.addEventListener( 'load', () => {\n\t\t\tsetDocumentIfReady();\n\t\t} );\n\t}, [] );\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( ( { tagName, href, id, rel, media }, index ) => {\n\t\t\t\tconst TagName = tagName.toLowerCase();\n\t\t\t\treturn (\n\t\t\t\t\t<TagName { ...{ href, id, rel, media } } key={ index } />\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<iframe\n\t\t\t{ ...props }\n\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\ttabIndex=\"0\"\n\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ iframeDocument &&\n\t\t\t\tcreatePortal(\n\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</StyleProvider>,\n\t\t\t\t\tiframeDocument.body\n\t\t\t\t) }\n\t\t\t{ iframeDocument && createPortal( head, iframeDocument.head ) }\n\t\t</iframe>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["useState","createPortal","useCallback","forwardRef","useEffect","useMemo","useReducer","__","useMergeRefs","__experimentalStyleProvider","StyleProvider","useBlockSelectionClearer","BODY_CLASS_NAME","BLOCK_PREFIX","styleSheetsCompat","doc","Array","from","document","styleSheets","forEach","styleSheet","cssRules","e","ownerNode","tagName","id","isMatch","find","selectorText","includes","getElementById","console","error","outerHTML","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","setBodyClassName","dir","body","className","classList","startsWith","add","useParsedAssets","html","implementation","createHTMLDocument","innerHTML","children","loadScript","src","Promise","resolve","reject","script","createElement","onload","onerror","Iframe","contentRef","props","ref","forceRender","iframeDocument","setIframeDocument","styles","__editorAssets","scripts","clearerRef","setRef","node","setDocumentIfReady","contentDocument","readyState","documentElement","current","reduce","promise","then","finally","map","href","rel","media","textContent","TagName","toLowerCase"],"mappings":";;;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,YAFD,EAGCC,WAHD,EAICC,UAJD,EAKCC,SALD,EAMCC,OAND,EAOCC,UAPD,QAQO,oBARP;AASA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;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,OAAV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AKA;;AAED,WACC,cAAC,OAAD;AAAgBH,MAAAA,IAAhB;AAAsBzF,MAAAA,EAAtB;AAA0B0F,MAAAA,GAA1B;AAA+BC,MAAAA,KAA/B;AAAyC,MAAA,GAAG,EAAG3F;AAA/C,MADD;AAGA,GAfA,CAFH,EAmBGS,IAnBH,CADD;AAwBA,SACC,qCACM2D,KADN;AAEC,IAAA,GAAG,EAAGtF,YAAY,CAAE,CAAEuF,GAAF,EAAOQ,MAAP,CAAF,CAFnB;AAGC,IAAA,QAAQ,EAAC,GAHV;AAIC,IAAA,KAAK,EAAGhG,EAAE,CAAE,eAAF,CAJX;AAKC,IAAA,IAAI,EAAC;AALN,MAOG0F,cAAc,IACfhG,YAAY,CACX,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGgG;AAA1B,KACGf,QADH,CADW,EAIXe,cAAc,CAACzB,IAJJ,CARd,EAcGyB,cAAc,IAAIhG,YAAY,CAAEkC,IAAF,EAAQ8D,cAAc,CAAC9D,IAAvB,CAdjC,CADD;AAkBA;;AAED,eAAehC,UAAU,CAAEyF,MAAF,CAAzB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tuseCallback,\n\tforwardRef,\n\tuseEffect,\n\tuseMemo,\n\tuseReducer,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\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// eslint-disable-next-line no-console\n\t\t\tconsole.error(\n\t\t\t\t`Stylesheet ${ ownerNode.id } was not properly added.\nFor blocks, use the block API's style (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#style) or editorStyle (https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/#editor-style).\nFor themes, use add_editor_style (https://developer.wordpress.org/block-editor/how-to-guides/themes/theme-support/#editor-styles).`,\n\t\t\t\townerNode.outerHTML\n\t\t\t);\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 = [ 'keydown', 'keypress', 'dragover' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\n/**\n * Sets the document direction.\n *\n * Sets the `editor-styles-wrapper` class name on the body.\n *\n * Copies the `admin-color-*` class name to the body so that the admin color\n * scheme applies to components in the iframe.\n *\n * @param {Document} doc Document to add class name to.\n */\nfunction setBodyClassName( doc ) {\n\tdoc.dir = document.dir;\n\tdoc.body.className = BODY_CLASS_NAME;\n\n\tfor ( const name of document.body.classList ) {\n\t\tif ( name.startsWith( 'admin-color-' ) ) {\n\t\t\tdoc.body.classList.add( name );\n\t\t} else if ( name === 'wp-embed-responsive' ) {\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\tdoc.body.classList.add( 'wp-embed-responsive' );\n\t\t}\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( doc, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = doc.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\tdoc.head.appendChild( script );\n\t} );\n}\n\nfunction Iframe( { contentRef, children, head, ...props }, ref ) {\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst styles = useParsedAssets( window.__editorAssets.styles );\n\tconst scripts = useParsedAssets( window.__editorAssets.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst setRef = useCallback( ( node ) => {\n\t\tif ( ! node ) {\n\t\t\treturn;\n\t\t}\n\n\t\tfunction setDocumentIfReady() {\n\t\t\tconst { contentDocument } = node;\n\t\t\tconst { readyState, body, 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\tif ( typeof contentRef === 'function' ) {\n\t\t\t\tcontentRef( body );\n\t\t\t} else if ( contentRef ) {\n\t\t\t\tcontentRef.current = body;\n\t\t\t}\n\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetBodyClassName( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\t\t\tclearerRef( body );\n\n\t\t\tscripts\n\t\t\t\t.reduce(\n\t\t\t\t\t( promise, script ) =>\n\t\t\t\t\t\tpromise.then( () =>\n\t\t\t\t\t\t\tloadScript( contentDocument, script )\n\t\t\t\t\t\t),\n\t\t\t\t\tPromise.resolve()\n\t\t\t\t)\n\t\t\t\t.finally( () => {\n\t\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t\t// to initialise.\n\t\t\t\t\tforceRender();\n\t\t\t\t} );\n\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( setDocumentIfReady() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Document is not immediately loaded in Firefox.\n\t\tnode.addEventListener( 'load', () => {\n\t\t\tsetDocumentIfReady();\n\t\t} );\n\t}, [] );\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<iframe\n\t\t\t{ ...props }\n\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\ttabIndex=\"0\"\n\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\tname=\"editor-canvas\"\n\t\t>\n\t\t\t{ iframeDocument &&\n\t\t\t\tcreatePortal(\n\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</StyleProvider>,\n\t\t\t\t\tiframeDocument.body\n\t\t\t\t) }\n\t\t\t{ iframeDocument && createPortal( head, iframeDocument.head ) }\n\t\t</iframe>\n\t);\n}\n\nexport default forwardRef( Iframe );\n"]}
@@ -64,7 +64,8 @@ export function useInputRules(props) {
64
64
 
65
65
  function onInput(event) {
66
66
  const {
67
- inputType
67
+ inputType,
68
+ type
68
69
  } = event;
69
70
  const {
70
71
  value,
@@ -73,7 +74,7 @@ export function useInputRules(props) {
73
74
  formatTypes
74
75
  } = propsRef.current; // Only run input rules when inserting text.
75
76
 
76
- if (inputType !== 'insertText') {
77
+ if (inputType !== 'insertText' && type !== 'compositionend') {
77
78
  return;
78
79
  }
79
80
 
@@ -103,8 +104,10 @@ export function useInputRules(props) {
103
104
  }
104
105
 
105
106
  element.addEventListener('input', onInput);
107
+ element.addEventListener('compositionend', onInput);
106
108
  return () => {
107
109
  element.removeEventListener('input', onInput);
110
+ element.removeEventListener('compositionend', onInput);
108
111
  };
109
112
  }, []);
110
113
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useRef","useRefEffect","slice","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA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,MAAAA,OAAO,CAAC8B,mBAAR,CAA6B,OAA7B,EAAsCZ,OAAtC;AACA,KAFD;AAGA,GAnFkB,EAmFhB,EAnFgB,CAAnB;AAoFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { slice, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction inputRule() {\n\t\t\tconst { value, onReplace } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: slice( value, start, text.length ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType } = event;\n\t\t\tconst {\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule ) {\n\t\t\t\tinputRule();\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-input-rules.js"],"names":["useRef","useRefEffect","slice","toHTMLString","getBlockTransforms","findTransform","useDispatch","store","blockEditorStore","useInputRules","props","__unstableMarkLastChangeAsPersistent","__unstableMarkAutomaticChange","propsRef","current","element","inputRule","value","onReplace","start","text","characterBefore","trimmedTextBefore","trim","prefixTransforms","filter","type","transformation","prefix","content","length","block","transform","onInput","event","inputType","onChange","__unstableAllowPrefixTransformations","formatTypes","transformed","reduce","accumlator","__unstableInputRule","activeFormats","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB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AEDG,IAAAA,OAAO,CAAC6B,gBAAR,CAA0B,OAA1B,EAAmCX,OAAnC;AACAlB,IAAAA,OAAO,CAAC6B,gBAAR,CAA0B,gBAA1B,EAA4CX,OAA5C;AACA,WAAO,MAAM;AACZlB,MAAAA,OAAO,CAAC8B,mBAAR,CAA6B,OAA7B,EAAsCZ,OAAtC;AACAlB,MAAAA,OAAO,CAAC8B,mBAAR,CAA6B,gBAA7B,EAA+CZ,OAA/C;AACA,KAHD;AAIA,GArFkB,EAqFhB,EArFgB,CAAnB;AAsFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { slice, toHTMLString } from '@wordpress/rich-text';\nimport { getBlockTransforms, findTransform } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport function useInputRules( props ) {\n\tconst {\n\t\t__unstableMarkLastChangeAsPersistent,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\treturn useRefEffect( ( element ) => {\n\t\tfunction inputRule() {\n\t\t\tconst { value, onReplace } = propsRef.current;\n\n\t\t\tif ( ! onReplace ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { start, text } = value;\n\t\t\tconst characterBefore = text.slice( start - 1, start );\n\n\t\t\t// The character right before the caret must be a plain space.\n\t\t\tif ( characterBefore !== ' ' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst trimmedTextBefore = text.slice( 0, start ).trim();\n\t\t\tconst prefixTransforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t( { type } ) => type === 'prefix'\n\t\t\t);\n\t\t\tconst transformation = findTransform(\n\t\t\t\tprefixTransforms,\n\t\t\t\t( { prefix } ) => {\n\t\t\t\t\treturn trimmedTextBefore === prefix;\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( ! transformation ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst content = toHTMLString( {\n\t\t\t\tvalue: slice( value, start, text.length ),\n\t\t\t} );\n\t\t\tconst block = transformation.transform( content );\n\n\t\t\tonReplace( [ block ] );\n\t\t\t__unstableMarkAutomaticChange();\n\t\t}\n\n\t\tfunction onInput( event ) {\n\t\t\tconst { inputType, type } = event;\n\t\t\tconst {\n\t\t\t\tvalue,\n\t\t\t\tonChange,\n\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\tformatTypes,\n\t\t\t} = propsRef.current;\n\n\t\t\t// Only run input rules when inserting text.\n\t\t\tif ( inputType !== 'insertText' && type !== 'compositionend' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( __unstableAllowPrefixTransformations && inputRule ) {\n\t\t\t\tinputRule();\n\t\t\t}\n\n\t\t\tconst transformed = formatTypes.reduce(\n\t\t\t\t( accumlator, { __unstableInputRule } ) => {\n\t\t\t\t\tif ( __unstableInputRule ) {\n\t\t\t\t\t\taccumlator = __unstableInputRule( accumlator );\n\t\t\t\t\t}\n\n\t\t\t\t\treturn accumlator;\n\t\t\t\t},\n\t\t\t\tvalue\n\t\t\t);\n\n\t\t\tif ( transformed !== value ) {\n\t\t\t\t__unstableMarkLastChangeAsPersistent();\n\t\t\t\tonChange( {\n\t\t\t\t\t...transformed,\n\t\t\t\t\tactiveFormats: value.activeFormats,\n\t\t\t\t} );\n\t\t\t\t__unstableMarkAutomaticChange();\n\t\t\t}\n\t\t}\n\n\t\telement.addEventListener( 'input', onInput );\n\t\telement.addEventListener( 'compositionend', onInput );\n\t\treturn () => {\n\t\t\telement.removeEventListener( 'input', onInput );\n\t\t\telement.removeEventListener( 'compositionend', onInput );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -27,7 +27,7 @@ const deprecatedFlags = {
27
27
  }
28
28
 
29
29
  if (settings.enableCustomUnits === true) {
30
- return ['px', 'em', 'rem', 'vh', 'vw'];
30
+ return ['px', 'em', 'rem', 'vh', 'vw', '%'];
31
31
  }
32
32
 
33
33
  return settings.enableCustomUnits;