@wordpress/block-editor 14.3.2 → 14.3.3

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 (101) hide show
  1. package/build/components/block-heading-level-dropdown/index.js +3 -1
  2. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  3. package/build/components/block-list/block.js +27 -4
  4. package/build/components/block-list/block.js.map +1 -1
  5. package/build/components/block-list/use-block-props/use-focus-first-element.js +0 -1
  6. package/build/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  7. package/build/components/block-list/zoom-out-separator.js +18 -1
  8. package/build/components/block-list/zoom-out-separator.js.map +1 -1
  9. package/build/components/block-switcher/utils.js +1 -1
  10. package/build/components/block-switcher/utils.js.map +1 -1
  11. package/build/components/block-variation-transforms/index.js +6 -3
  12. package/build/components/block-variation-transforms/index.js.map +1 -1
  13. package/build/components/rich-text/event-listeners/paste-handler.js +2 -13
  14. package/build/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  15. package/build/components/rich-text/index.js +34 -20
  16. package/build/components/rich-text/index.js.map +1 -1
  17. package/build/components/writing-flow/index.js +1 -2
  18. package/build/components/writing-flow/index.js.map +1 -1
  19. package/build/components/writing-flow/use-arrow-nav.js +1 -4
  20. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  21. package/build/components/writing-flow/use-input.js +1 -31
  22. package/build/components/writing-flow/use-input.js.map +1 -1
  23. package/build/components/writing-flow/use-select-all.js +1 -14
  24. package/build/components/writing-flow/use-select-all.js.map +1 -1
  25. package/build/components/writing-flow/use-selection-observer.js +2 -6
  26. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  27. package/build/components/writing-flow/utils.js +0 -27
  28. package/build/components/writing-flow/utils.js.map +1 -1
  29. package/build/hooks/layout.js +12 -8
  30. package/build/hooks/layout.js.map +1 -1
  31. package/build/hooks/use-bindings-attributes.js +20 -26
  32. package/build/hooks/use-bindings-attributes.js.map +1 -1
  33. package/build/store/selectors.js +6 -3
  34. package/build/store/selectors.js.map +1 -1
  35. package/build-module/components/block-heading-level-dropdown/index.js +3 -1
  36. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  37. package/build-module/components/block-list/block.js +28 -7
  38. package/build-module/components/block-list/block.js.map +1 -1
  39. package/build-module/components/block-list/use-block-props/use-focus-first-element.js +0 -1
  40. package/build-module/components/block-list/use-block-props/use-focus-first-element.js.map +1 -1
  41. package/build-module/components/block-list/zoom-out-separator.js +18 -1
  42. package/build-module/components/block-list/zoom-out-separator.js.map +1 -1
  43. package/build-module/components/block-switcher/utils.js +1 -1
  44. package/build-module/components/block-switcher/utils.js.map +1 -1
  45. package/build-module/components/block-variation-transforms/index.js +6 -3
  46. package/build-module/components/block-variation-transforms/index.js.map +1 -1
  47. package/build-module/components/rich-text/event-listeners/paste-handler.js +2 -13
  48. package/build-module/components/rich-text/event-listeners/paste-handler.js.map +1 -1
  49. package/build-module/components/rich-text/index.js +34 -20
  50. package/build-module/components/rich-text/index.js.map +1 -1
  51. package/build-module/components/writing-flow/index.js +1 -2
  52. package/build-module/components/writing-flow/index.js.map +1 -1
  53. package/build-module/components/writing-flow/use-arrow-nav.js +1 -4
  54. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  55. package/build-module/components/writing-flow/use-input.js +1 -31
  56. package/build-module/components/writing-flow/use-input.js.map +1 -1
  57. package/build-module/components/writing-flow/use-select-all.js +1 -14
  58. package/build-module/components/writing-flow/use-select-all.js.map +1 -1
  59. package/build-module/components/writing-flow/use-selection-observer.js +2 -6
  60. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  61. package/build-module/components/writing-flow/utils.js +0 -26
  62. package/build-module/components/writing-flow/utils.js.map +1 -1
  63. package/build-module/hooks/layout.js +13 -9
  64. package/build-module/hooks/layout.js.map +1 -1
  65. package/build-module/hooks/use-bindings-attributes.js +20 -26
  66. package/build-module/hooks/use-bindings-attributes.js.map +1 -1
  67. package/build-module/store/selectors.js +6 -3
  68. package/build-module/store/selectors.js.map +1 -1
  69. package/build-style/content-rtl.css +10 -0
  70. package/build-style/content.css +10 -0
  71. package/build-style/style-rtl.css +4 -0
  72. package/build-style/style.css +4 -0
  73. package/package.json +20 -20
  74. package/src/components/block-heading-level-dropdown/index.js +7 -1
  75. package/src/components/block-list/block.js +47 -11
  76. package/src/components/block-list/content.scss +12 -0
  77. package/src/components/block-list/use-block-props/use-focus-first-element.js +0 -1
  78. package/src/components/block-list/zoom-out-separator.js +14 -1
  79. package/src/components/block-switcher/test/use-transformed.patterns.js +3 -3
  80. package/src/components/block-switcher/test/utils.js +3 -3
  81. package/src/components/block-switcher/utils.js +1 -1
  82. package/src/components/block-toolbar/style.scss +7 -0
  83. package/src/components/block-variation-transforms/index.js +6 -7
  84. package/src/components/rich-text/event-listeners/paste-handler.js +2 -7
  85. package/src/components/rich-text/index.js +36 -23
  86. package/src/components/writing-flow/index.js +0 -2
  87. package/src/components/writing-flow/use-arrow-nav.js +2 -9
  88. package/src/components/writing-flow/use-input.js +1 -36
  89. package/src/components/writing-flow/use-select-all.js +1 -18
  90. package/src/components/writing-flow/use-selection-observer.js +3 -14
  91. package/src/components/writing-flow/utils.js +0 -30
  92. package/src/hooks/layout.js +17 -12
  93. package/src/hooks/use-bindings-attributes.js +24 -29
  94. package/src/store/selectors.js +6 -6
  95. package/src/store/test/private-selectors.js +2 -2
  96. package/src/store/test/selectors.js +10 -6
  97. package/build/components/writing-flow/use-event-redirect.js +0 -66
  98. package/build/components/writing-flow/use-event-redirect.js.map +0 -1
  99. package/build-module/components/writing-flow/use-event-redirect.js +0 -60
  100. package/build-module/components/writing-flow/use-event-redirect.js.map +0 -1
  101. package/src/components/writing-flow/use-event-redirect.js +0 -72
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","hasBlockSupport","getBlockTransforms","findTransform","store","blockEditorStore","getSelectionRoot","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","getSelectedBlockClientId","__unstableIsSelectionMergeable","hasMultiSelection","getBlockName","canInsertBlockType","getBlockRootClientId","getSelectionStart","getSelectionEnd","getBlockAttributes","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableMarkAutomaticChange","node","onBeforeInput","event","contentEditable","selection","ownerDocument","defaultView","getSelection","range","rangeCount","getRangeAt","root","focus","removeAllRanges","addRange","preventDefault","onKeyDown","defaultPrevented","activeElement","key","selectionRoot","selectAllChildren","method","keyCode","shiftKey","clientId","blockName","selectionStart","selectionEnd","attributeKey","selectedAttributeValue","transforms","filter","type","transformation","item","regExp","test","transform","content","__deprecatedOnSplit","length","metaKey","ctrlKey","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getSelectionRoot } from './utils';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tconst selection = node.ownerDocument.defaultView.getSelection();\n\t\t\t\tconst range = selection.rangeCount\n\t\t\t\t\t? selection.getRangeAt( 0 )\n\t\t\t\t\t: null;\n\t\t\t\tconst root = getSelectionRoot( node.ownerDocument );\n\n\t\t\t\t// If selection is contained within a nested editable, allow\n\t\t\t\t// input. We need to ensure that selection is maintained.\n\t\t\t\tif ( root ) {\n\t\t\t\t\tnode.contentEditable = false;\n\t\t\t\t\troot.focus();\n\t\t\t\t\tselection.removeAllRanges();\n\t\t\t\t\tif ( range ) {\n\t\t\t\t\t\tselection.addRange( range );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tif ( node === ownerDocument.activeElement ) {\n\t\t\t\t\tif ( event.key === 'End' || event.key === 'Home' ) {\n\t\t\t\t\t\tconst selectionRoot = getSelectionRoot( ownerDocument );\n\t\t\t\t\t\tconst selection =\n\t\t\t\t\t\t\townerDocument.defaultView.getSelection();\n\t\t\t\t\t\tselection.selectAllChildren( selectionRoot );\n\t\t\t\t\t\tconst method =\n\t\t\t\t\t\t\tevent.key === 'End'\n\t\t\t\t\t\t\t\t? 'collapseToEnd'\n\t\t\t\t\t\t\t\t: 'collapseToStart';\n\t\t\t\t\t\tselection[ method ]();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\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__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAC9D,SACCC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QACP,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,gBAAgB,QAAQ,SAAS;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AAS,EAAE9B,SAAU,CAAC;MAChDhB,IAAI,CAAC8C,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","useRefEffect","ENTER","BACKSPACE","DELETE","createBlock","getDefaultBlockName","hasBlockSupport","getBlockTransforms","findTransform","store","blockEditorStore","useInput","__unstableIsFullySelected","getSelectedBlockClientIds","getSelectedBlockClientId","__unstableIsSelectionMergeable","hasMultiSelection","getBlockName","canInsertBlockType","getBlockRootClientId","getSelectionStart","getSelectionEnd","getBlockAttributes","replaceBlocks","__unstableSplitSelection","removeBlocks","__unstableDeleteSelection","__unstableExpandSelection","__unstableMarkAutomaticChange","node","onBeforeInput","event","contentEditable","preventDefault","onKeyDown","defaultPrevented","keyCode","shiftKey","clientId","blockName","selectionStart","selectionEnd","attributeKey","selectedAttributeValue","transforms","filter","type","transformation","item","regExp","test","transform","content","__deprecatedOnSplit","key","length","metaKey","ctrlKey","ownerDocument","defaultView","getSelection","removeAllRanges","onCompositionStart","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-input.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\thasBlockSupport,\n\tgetBlockTransforms,\n\tfindTransform,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Handles input for selections across blocks.\n */\nexport default function useInput() {\n\tconst {\n\t\t__unstableIsFullySelected,\n\t\tgetSelectedBlockClientIds,\n\t\tgetSelectedBlockClientId,\n\t\t__unstableIsSelectionMergeable,\n\t\thasMultiSelection,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t\tgetBlockRootClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\tgetBlockAttributes,\n\t} = useSelect( blockEditorStore );\n\tconst {\n\t\treplaceBlocks,\n\t\t__unstableSplitSelection,\n\t\tremoveBlocks,\n\t\t__unstableDeleteSelection,\n\t\t__unstableExpandSelection,\n\t\t__unstableMarkAutomaticChange,\n\t} = useDispatch( blockEditorStore );\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onBeforeInput( event ) {\n\t\t\t// If writing flow is editable, NEVER allow the browser to alter the\n\t\t\t// DOM. This will cause React errors (and the DOM should only be\n\t\t\t// altered in a controlled fashion).\n\t\t\tif ( node.contentEditable === 'true' ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\t\tif ( event.shiftKey || __unstableIsFullySelected() ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst clientId = getSelectedBlockClientId();\n\t\t\t\t\tconst blockName = getBlockName( clientId );\n\t\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\t\tconst selectionEnd = getSelectionEnd();\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tselectionStart.attributeKey ===\n\t\t\t\t\t\tselectionEnd.attributeKey\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst selectedAttributeValue =\n\t\t\t\t\t\t\tgetBlockAttributes( clientId )[\n\t\t\t\t\t\t\t\tselectionStart.attributeKey\n\t\t\t\t\t\t\t];\n\t\t\t\t\t\tconst transforms = getBlockTransforms( 'from' ).filter(\n\t\t\t\t\t\t\t( { type } ) => type === 'enter'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\t\t\ttransforms,\n\t\t\t\t\t\t\t( item ) => {\n\t\t\t\t\t\t\t\treturn item.regExp.test(\n\t\t\t\t\t\t\t\t\tselectedAttributeValue\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( transformation ) {\n\t\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\ttransformation.transform( {\n\t\t\t\t\t\t\t\t\tcontent: selectedAttributeValue,\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__unstableMarkAutomaticChange();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t! hasBlockSupport( blockName, 'splitting', false ) &&\n\t\t\t\t\t\t! event.__deprecatedOnSplit\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Ensure template is not locked.\n\t\t\t\t\tif (\n\t\t\t\t\t\tcanInsertBlockType(\n\t\t\t\t\t\t\tblockName,\n\t\t\t\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.keyCode === ENTER ) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\tgetSelectedBlockClientIds(),\n\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t__unstableSplitSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\t\tevent.keyCode === DELETE\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( __unstableIsFullySelected() ) {\n\t\t\t\t\tremoveBlocks( getSelectedBlockClientIds() );\n\t\t\t\t} else if ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\t__unstableExpandSelection();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\t// If key.length is longer than 1, it's a control key that doesn't\n\t\t\t\t// input anything.\n\t\t\t\tevent.key.length === 1 &&\n\t\t\t\t! ( event.metaKey || event.ctrlKey )\n\t\t\t) {\n\t\t\t\tnode.contentEditable = false;\n\t\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t\t__unstableDeleteSelection( event.keyCode === DELETE );\n\t\t\t\t} else {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfunction onCompositionStart( event ) {\n\t\t\tif ( ! hasMultiSelection() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tnode.contentEditable = false;\n\n\t\t\tif ( __unstableIsSelectionMergeable() ) {\n\t\t\t\t__unstableDeleteSelection();\n\t\t\t} else {\n\t\t\t\tevent.preventDefault();\n\t\t\t\t// Safari does not stop default behaviour with either\n\t\t\t\t// event.preventDefault() or node.contentEditable = false, so\n\t\t\t\t// remove the selection to stop browser manipulation.\n\t\t\t\tnode.ownerDocument.defaultView.getSelection().removeAllRanges();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'beforeinput', onBeforeInput );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'compositionstart', onCompositionStart );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'beforeinput', onBeforeInput );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'compositionstart', onCompositionStart );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AAC9D,SACCC,WAAW,EACXC,mBAAmB,EACnBC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,QACP,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA;AACA;AACA,eAAe,SAASC,QAAQA,CAAA,EAAG;EAClC,MAAM;IACLC,yBAAyB;IACzBC,yBAAyB;IACzBC,wBAAwB;IACxBC,8BAA8B;IAC9BC,iBAAiB;IACjBC,YAAY;IACZC,kBAAkB;IAClBC,oBAAoB;IACpBC,iBAAiB;IACjBC,eAAe;IACfC;EACD,CAAC,GAAGxB,SAAS,CAAEY,gBAAiB,CAAC;EACjC,MAAM;IACLa,aAAa;IACbC,wBAAwB;IACxBC,YAAY;IACZC,yBAAyB;IACzBC,yBAAyB;IACzBC;EACD,CAAC,GAAG7B,WAAW,CAAEW,gBAAiB,CAAC;EAEnC,OAAOV,YAAY,CAAI6B,IAAI,IAAM;IAChC,SAASC,aAAaA,CAAEC,KAAK,EAAG;MAC/B;MACA;MACA;MACA,IAAKF,IAAI,CAACG,eAAe,KAAK,MAAM,EAAG;QACtCD,KAAK,CAACE,cAAc,CAAC,CAAC;MACvB;IACD;IAEA,SAASC,SAASA,CAAEH,KAAK,EAAG;MAC3B,IAAKA,KAAK,CAACI,gBAAgB,EAAG;QAC7B;MACD;MAEA,IAAK,CAAEnB,iBAAiB,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D;IAEA,SAASC,kBAAkBA,CAAE/B,KAAK,EAAG;MACpC,IAAK,CAAEf,iBAAiB,CAAC,CAAC,EAAG;QAC5B;MACD;MAEAa,IAAI,CAACG,eAAe,GAAG,KAAK;MAE5B,IAAKjB,8BAA8B,CAAC,CAAC,EAAG;QACvCW,yBAAyB,CAAC,CAAC;MAC5B,CAAC,MAAM;QACNK,KAAK,CAACE,cAAc,CAAC,CAAC;QACtB;QACA;QACA;QACAJ,IAAI,CAAC6B,aAAa,CAACC,WAAW,CAACC,YAAY,CAAC,CAAC,CAACC,eAAe,CAAC,CAAC;MAChE;IACD;IAEAhC,IAAI,CAACkC,gBAAgB,CAAE,aAAa,EAAEjC,aAAc,CAAC;IACrDD,IAAI,CAACkC,gBAAgB,CAAE,SAAS,EAAE7B,SAAU,CAAC;IAC7CL,IAAI,CAACkC,gBAAgB,CAAE,kBAAkB,EAAED,kBAAmB,CAAC;IAC/D,OAAO,MAAM;MACZjC,IAAI,CAACmC,mBAAmB,CAAE,aAAa,EAAElC,aAAc,CAAC;MACxDD,IAAI,CAACmC,mBAAmB,CAAE,SAAS,EAAE9B,SAAU,CAAC;MAChDL,IAAI,CAACmC,mBAAmB,CAAE,kBAAkB,EAAEF,kBAAmB,CAAC;IACnE,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -10,7 +10,6 @@ import { useRefEffect } from '@wordpress/compose';
10
10
  * Internal dependencies
11
11
  */
12
12
  import { store as blockEditorStore } from '../../store';
13
- import { getSelectionRoot } from './utils';
14
13
  export default function useSelectAll() {
15
14
  const {
16
15
  getBlockOrder,
@@ -27,19 +26,8 @@ export default function useSelectAll() {
27
26
  if (!isMatch('core/block-editor/select-all', event)) {
28
27
  return;
29
28
  }
30
- const selectionRoot = getSelectionRoot(node.ownerDocument);
31
29
  const selectedClientIds = getSelectedBlockClientIds();
32
-
33
- // Abort if there is selection, but it is not within a block.
34
- if (selectionRoot && !selectedClientIds.length) {
35
- return;
36
- }
37
- if (selectionRoot && selectedClientIds.length < 2 && !isEntirelySelected(selectionRoot)) {
38
- if (node === node.ownerDocument.activeElement) {
39
- event.preventDefault();
40
- node.ownerDocument.defaultView.getSelection().selectAllChildren(selectionRoot);
41
- return;
42
- }
30
+ if (selectedClientIds.length < 2 && !isEntirelySelected(event.target)) {
43
31
  return;
44
32
  }
45
33
  event.preventDefault();
@@ -52,7 +40,6 @@ export default function useSelectAll() {
52
40
  if (selectedClientIds.length === blockClientIds.length) {
53
41
  if (rootClientId) {
54
42
  node.ownerDocument.defaultView.getSelection().removeAllRanges();
55
- node.contentEditable = 'false';
56
43
  selectBlock(rootClientId);
57
44
  }
58
45
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["isEntirelySelected","useSelect","useDispatch","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRefEffect","store","blockEditorStore","getSelectionRoot","useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","multiSelect","selectBlock","isMatch","node","onKeyDown","event","selectionRoot","ownerDocument","selectedClientIds","length","activeElement","preventDefault","defaultView","getSelection","selectAllChildren","firstSelectedClientId","rootClientId","blockClientIds","removeAllRanges","contentEditable","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isEntirelySelected } from '@wordpress/dom';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getSelectionRoot } from './utils';\n\nexport default function useSelectAll() {\n\tconst { getBlockOrder, getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { multiSelect, selectBlock } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectionRoot = getSelectionRoot( node.ownerDocument );\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\n\t\t\t// Abort if there is selection, but it is not within a block.\n\t\t\tif ( selectionRoot && ! selectedClientIds.length ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\tselectionRoot &&\n\t\t\t\tselectedClientIds.length < 2 &&\n\t\t\t\t! isEntirelySelected( selectionRoot )\n\t\t\t) {\n\t\t\t\tif ( node === node.ownerDocument.activeElement ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.selectAllChildren( selectionRoot );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a\n\t\t\t// level. See: https://github.com/WordPress/gutenberg/pull/31859/\n\t\t\tif ( selectedClientIds.length === blockClientIds.length ) {\n\t\t\t\tif ( rootClientId ) {\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t\tnode.contentEditable = 'false';\n\t\t\t\t\tselectBlock( rootClientId );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ]\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\n\t\treturn () => {\n\t\t\tnode.remov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iB,CAAER,aAAc,CAAC;UACpC;QACD;QAEA;MACD;MAEAD,KAAK,CAACM,cAAc,CAAC,CAAC;MAEtB,MAAM,CAAEI,qBAAqB,CAAE,GAAGP,iBAAiB;MACnD,MAAMQ,YAAY,GAAGjB,oBAAoB,CAAEgB,qBAAsB,CAAC;MAClE,MAAME,cAAc,GAAGpB,aAAa,CAAEmB,YAAa,CAAC;;MAEpD;MACA;MACA,IAAKR,iBAAiB,CAACC,MAAM,KAAKQ,cAAc,CAACR,MAAM,EAAG;QACzD,IAAKO,YAAY,EAAG;UACnBb,IAAI,CAACI,aAAa,CAACK,WAAW,CAC5BC,YAAY,CAAC,CAAC,CACdK,eAAe,CAAC,CAAC;UACnBf,IAAI,CAACgB,eAAe,GAAG,OAAO;UAC9BlB,WAAW,CAAEe,YAAa,CAAC;QAC5B;QACA;MACD;MAEAhB,WAAW,CACViB,cAAc,CAAE,CAAC,CAAE,EACnBA,cAAc,CAAEA,cAAc,CAACR,MAAM,GAAG,CAAC,CAC1C,CAAC;IACF;IAEAN,IAAI,CAACiB,gBAAgB,CAAE,SAAS,EAAEhB,SAAU,CAAC;IAE7C,OAAO,MAAM;MACZD,IAAI,CAACkB,mBAAmB,CAAE,SAAS,EAAEjB,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
1
+ {"version":3,"names":["isEntirelySelected","useSelect","useDispatch","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRefEffect","store","blockEditorStore","useSelectAll","getBlockOrder","getSelectedBlockClientIds","getBlockRootClientId","multiSelect","selectBlock","isMatch","node","onKeyDown","event","selectedClientIds","length","target","preventDefault","firstSelectedClientId","rootClientId","blockClientIds","ownerDocument","defaultView","getSelection","removeAllRanges","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-select-all.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { isEntirelySelected } from '@wordpress/dom';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\nexport default function useSelectAll() {\n\tconst { getBlockOrder, getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { multiSelect, selectBlock } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( ! isMatch( 'core/block-editor/select-all', event ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst selectedClientIds = getSelectedBlockClientIds();\n\n\t\t\tif (\n\t\t\t\tselectedClientIds.length < 2 &&\n\t\t\t\t! isEntirelySelected( event.target )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\n\t\t\tconst [ firstSelectedClientId ] = selectedClientIds;\n\t\t\tconst rootClientId = getBlockRootClientId( firstSelectedClientId );\n\t\t\tconst blockClientIds = getBlockOrder( rootClientId );\n\n\t\t\t// If we have selected all sibling nested blocks, try selecting up a\n\t\t\t// level. See: https://github.com/WordPress/gutenberg/pull/31859/\n\t\t\tif ( selectedClientIds.length === blockClientIds.length ) {\n\t\t\t\tif ( rootClientId ) {\n\t\t\t\t\tnode.ownerDocument.defaultView\n\t\t\t\t\t\t.getSelection()\n\t\t\t\t\t\t.removeAllRanges();\n\t\t\t\t\tselectBlock( rootClientId );\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tmultiSelect(\n\t\t\t\tblockClientIds[ 0 ],\n\t\t\t\tblockClientIds[ blockClientIds.length - 1 ]\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );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;UACnBf,WAAW,CAAEU,YAAa,CAAC;QAC5B;QACA;MACD;MAEAX,WAAW,CACVY,cAAc,CAAE,CAAC,CAAE,EACnBA,cAAc,CAAEA,cAAc,CAACL,MAAM,GAAG,CAAC,CAC1C,CAAC;IACF;IAEAJ,IAAI,CAACc,gBAAgB,CAAE,SAAS,EAAEb,SAAU,CAAC;IAE7C,OAAO,MAAM;MACZD,IAAI,CAACe,mBAAmB,CAAE,SAAS,EAAEd,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR","ignoreList":[]}
@@ -109,8 +109,7 @@ export default function useSelectionObserver() {
109
109
  const {
110
110
  getBlockParents,
111
111
  getBlockSelectionStart,
112
- isMultiSelecting,
113
- getSelectedBlockClientId
112
+ isMultiSelecting
114
113
  } = useSelect(blockEditorStore);
115
114
  return useRefEffect(node => {
116
115
  const {
@@ -173,13 +172,10 @@ export default function useSelectionObserver() {
173
172
  setContentEditableWrapper(node, false);
174
173
  return;
175
174
  }
176
- setContentEditableWrapper(node, !!(startClientId && endClientId));
177
175
  const isSingularSelection = startClientId === endClientId;
178
176
  if (isSingularSelection) {
179
177
  if (!isMultiSelecting()) {
180
- if (getSelectedBlockClientId() !== startClientId) {
181
- selectBlock(startClientId);
182
- }
178
+ selectBlock(startClientId);
183
179
  } else {
184
180
  multiSelect(startClientId, startClientId);
185
181
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","useRefEffect","create","isSelectionForward","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","_focusNode$previousSi","previousSibling","parentElement","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","getBlockSelectionStart","isMultiSelecting","getSelectedBlockClientId","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// When the selection is forward (the selection ends with the focus node),\n\t// the selection may extend into the next element with an offset of 0. This\n\t// may trigger multi selection even though the selection does not visually\n\t// end in the next block.\n\tif ( focusOffset === 0 && isSelectionForward( selection ) ) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockParents,\n\t\tgetBlockSelectionStart,\n\t\tisMultiSelecting,\n\t\tgetSelectedBlockClientId,\n\t} = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsetContentEditableWrapper(\n\t\t\t\t\tnode,\n\t\t\t\t\t!! ( startClientId && endClientId )\n\t\t\t\t);\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tif ( getSelectedBlockClientId() !== startClientId ) {\n\t\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAEC,SAAS,EAAG;EAC/C,MAAM;IAAEC,UAAU;IAAEC;EAAa,CAAC,GAAGF,SAAS;EAE9C,IAAKC,UAAU,CAACE,QAAQ,KAAKF,UAAU,CAACG,SAAS,EAAG;IACnD,OAAOH,UAAU;EAClB;EAEA,IAAKC,YAAY,KAAK,CAAC,EAAG;IACzB,OAAOD,UAAU;EAClB;EAEA,OAAOA,UAAU,CAACI,UAAU,CAAEH,YAAY,GAAG,CAAC,CAAE;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,uBAAuBA,CAAEN,SAAS,EAAG;EAC7C,MAAM;IAAEO,SAAS;IAAEC;EAAY,CAAC,GAAGR,SAAS;EAE5C,IAAKO,SAAS,CAACJ,QAAQ,KAAKI,SAAS,CAACH,SAAS,EAAG;IACjD,OAAOG,SAAS;EACjB;EAEA,IAAKC,WAAW,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EAAEL;YACT;UACD,CAAE,CAAC;QACJ,CAAC,MAAM;UACN1C,WAAW,CAAEoB,aAAa,EAAEC,WAAY,CAAC;QAC1C;MACD;IACD;IAEAd,aAAa,CAACyC,gBAAgB,CAC7B,iBAAiB,EACjBvC,iBACD,CAAC;IACDD,WAAW,CAACwC,gBAAgB,CAAE,SAAS,EAAEvC,iBAAkB,CAAC;IAC5D,OAAO,MAAM;MACZF,aAAa,CAAC0C,mBAAmB,CAChC,iBAAiB,EACjBxC,iBACD,CAAC;MACDD,WAAW,CAACyC,mBAAmB,CAAE,SAAS,EAAExC,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAET,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEC,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","useRefEffect","create","isSelectionForward","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","length","_focusNode$previousSi","previousSibling","parentElement","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","String","focus","getRichTextElement","element","ELEMENT_NODE","closest","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","getBlockSelectionStart","isMultiSelecting","ownerDocument","defaultView","onSelectionChange","event","getSelection","rangeCount","startNode","endNode","contains","isClickShift","shiftKey","type","isCollapsed","startClientId","endClientId","selectedClientId","clickedClientId","target","focusNodeIsNonSelectable","undefined","isSingularSelection","startPath","endPath","richTextElementStart","richTextElementEnd","_richTextDataStart$st","_richTextDataEnd$star","range","getRangeAt","richTextDataStart","__unstableIsEditableTree","richTextDataEnd","startOffset","start","end","endOffset","clientId","attributeKey","dataset","wpBlockAttributeKey","offset","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { create } from '@wordpress/rich-text';\nimport { isSelectionForward } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\tif ( anchorOffset === 0 ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset - 1 ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\tif ( focusOffset === focusNode.childNodes.length ) {\n\t\treturn focusNode;\n\t}\n\n\t// When the selection is forward (the selection ends with the focus node),\n\t// the selection may extend into the next element with an offset of 0. This\n\t// may trigger multi selection even though the selection does not visually\n\t// end in the next block.\n\tif ( focusOffset === 0 && isSelectionForward( selection ) ) {\n\t\treturn focusNode.previousSibling ?? focusNode.parentElement;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\t// Since we are calling this on every selection change, check if the value\n\t// needs to be updated first because it trigger the browser to recalculate\n\t// style.\n\tif ( node.contentEditable !== String( value ) ) {\n\t\tnode.contentEditable = value;\n\n\t\t// Firefox doesn't automatically move focus.\n\t\tif ( value ) {\n\t\t\tnode.focus();\n\t\t}\n\t}\n}\n\nfunction getRichTextElement( node ) {\n\tconst element =\n\t\tnode.nodeType === node.ELEMENT_NODE ? node : node.parentElement;\n\treturn element?.closest( '[data-wp-block-attribute-key]' );\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { getBlockParents, getBlockSelectionStart, isMultiSelecting } =\n\t\tuseSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange( event ) {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\tif ( ! selection.rangeCount ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst startNode = extractSelectionStartNode( selection );\n\t\t\t\tconst endNode = extractSelectionEndNode( selection );\n\n\t\t\t\tif (\n\t\t\t\t\t! node.contains( startNode ) ||\n\t\t\t\t\t! node.contains( endNode )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// If selection is collapsed and we haven't used `shift+click`,\n\t\t\t\t// end multi selection and disable the contentEditable wrapper.\n\t\t\t\t// We have to check about `shift+click` case because elements\n\t\t\t\t// that don't support text selection might be involved, and we might\n\t\t\t\t// update the clientIds to multi-select blocks.\n\t\t\t\t// For now we check if the event is a `mouse` event.\n\t\t\t\tconst isClickShift = event.shiftKey && event.type === 'mouseup';\n\t\t\t\tif ( selection.isCollapsed && ! isClickShift ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tnode.contentEditable === 'true' &&\n\t\t\t\t\t\t! isMultiSelecting()\n\t\t\t\t\t) {\n\t\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\t\tlet element =\n\t\t\t\t\t\t\tstartNode.nodeType === startNode.ELEMENT_NODE\n\t\t\t\t\t\t\t\t? startNode\n\t\t\t\t\t\t\t\t: startNode.parentElement;\n\t\t\t\t\t\telement = element?.closest( '[contenteditable]' );\n\t\t\t\t\t\telement?.focus();\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet startClientId = getBlockClientId( startNode );\n\t\t\t\tlet endClientId = getBlockClientId( endNode );\n\n\t\t\t\t// If the selection has changed and we had pressed `shift+click`,\n\t\t\t\t// we need to check if in an element that doesn't support\n\t\t\t\t// text selection has been clicked.\n\t\t\t\tif ( isClickShift ) {\n\t\t\t\t\tconst selectedClientId = getBlockSelectionStart();\n\t\t\t\t\tconst clickedClientId = getBlockClientId( event.target );\n\t\t\t\t\t// `endClientId` is not defined if we end the selection by clicking a non-selectable block.\n\t\t\t\t\t// We need to check if there was already a selection with a non-selectable focusNode.\n\t\t\t\t\tconst focusNodeIsNonSelectable =\n\t\t\t\t\t\tclickedClientId !== endClientId;\n\t\t\t\t\tif (\n\t\t\t\t\t\t( startClientId === endClientId &&\n\t\t\t\t\t\t\tselection.isCollapsed ) ||\n\t\t\t\t\t\t! endClientId ||\n\t\t\t\t\t\tfocusNodeIsNonSelectable\n\t\t\t\t\t) {\n\t\t\t\t\t\tendClientId = clickedClientId;\n\t\t\t\t\t}\n\t\t\t\t\t// Handle the case when we have a non-selectable block\n\t\t\t\t\t// selected and click another one.\n\t\t\t\t\tif ( startClientId !== selectedClientId ) {\n\t\t\t\t\t\tstartClientId = selectedClientId;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the selection did not involve a block, return.\n\t\t\t\tif (\n\t\t\t\t\tstartClientId === undefined &&\n\t\t\t\t\tendClientId === undefined\n\t\t\t\t) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = startClientId === endClientId;\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tif ( ! isMultiSelecting() ) {\n\t\t\t\t\t\tselectBlock( startClientId );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, startClientId );\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( startClientId ),\n\t\t\t\t\t\tstartClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tstartPath[ depth ] !== startClientId ||\n\t\t\t\t\t\tendPath[ depth ] !== endClientId\n\t\t\t\t\t) {\n\t\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tconst richTextElementStart =\n\t\t\t\t\t\tgetRichTextElement( startNode );\n\t\t\t\t\tconst richTextElementEnd = getRichTextElement( endNode );\n\n\t\t\t\t\tif ( richTextElementStart && richTextElementEnd ) {\n\t\t\t\t\t\tconst range = selection.getRangeAt( 0 );\n\t\t\t\t\t\tconst richTextDataStart = create( {\n\t\t\t\t\t\t\telement: richTextElementStart,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\t\t\t\t\t\tconst richTextDataEnd = create( {\n\t\t\t\t\t\t\telement: richTextElementEnd,\n\t\t\t\t\t\t\trange,\n\t\t\t\t\t\t\t__unstableIsEditableTree: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\tconst startOffset =\n\t\t\t\t\t\t\trichTextDataStart.start ?? richTextDataStart.end;\n\t\t\t\t\t\tconst endOffset =\n\t\t\t\t\t\t\trichTextDataEnd.start ?? richTextDataEnd.end;\n\t\t\t\t\t\tselectionChange( {\n\t\t\t\t\t\t\tstart: {\n\t\t\t\t\t\t\t\tclientId: startClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementStart.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: startOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tend: {\n\t\t\t\t\t\t\t\tclientId: endClientId,\n\t\t\t\t\t\t\t\tattributeKey:\n\t\t\t\t\t\t\t\t\trichTextElementEnd.dataset\n\t\t\t\t\t\t\t\t\t\t.wpBlockAttributeKey,\n\t\t\t\t\t\t\t\toffset: endOffset,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t} );\n\t\t\t\t\t} else {\n\t\t\t\t\t\tmultiSelect( startClientId, endClientId );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\townerDocument.addEventListener(\n\t\t\t\t'selectionchange',\n\t\t\t\tonSelectionChange\n\t\t\t);\n\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,kBAAkB,QAAQ,gBAAgB;;AAEnD;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,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AAME,WAAW,IAAAP,qBAAA,GAChBI,iBAAiB,CAACI,KAAK,cAAAR,qBAAA,cAAAA,qBAAA,GAAII,iBAAiB,CAACK,GAAG;UACjD,MAAMC,SAAS,IAAAT,qBAAA,GACdK,eAAe,CAACE,KAAK,cAAAP,qBAAA,cAAAA,qBAAA,GAAIK,eAAe,CAACG,GAAG;UAC7CtC,eAAe,CAAE;YAChBqC,KAAK,EAAE;cACNG,QAAQ,EAAEvB,aAAa;cACvBwB,YAAY,EACXd,oBAAoB,CAACe,OAAO,CAC1BC,mBAAmB;cACtBC,MAAM,EAAER;YACT,CAAC;YACDE,GAAG,EAAE;cACJE,QAAQ,EAAEtB,WAAW;cACrBuB,YAAY,EACXb,kBAAkB,CAACc,OAAO,CACxBC,mBAAmB;cACtBC,MAAM,EAAEL;YACT;UACD,CAAE,CAAC;QACJ,CAAC,MAAM;UACNzC,WAAW,CAAEmB,aAAa,EAAEC,WAAY,CAAC;QAC1C;MACD;IACD;IAEAd,aAAa,CAACyC,gBAAgB,CAC7B,iBAAiB,EACjBvC,iBACD,CAAC;IACDD,WAAW,CAACwC,gBAAgB,CAAE,SAAS,EAAEvC,iBAAkB,CAAC;IAC5D,OAAO,MAAM;MACZF,aAAa,CAAC0C,mBAAmB,CAChC,iBAAiB,EACjBxC,iBACD,CAAC;MACDD,WAAW,CAACyC,mBAAmB,CAAE,SAAS,EAAExC,iBAAkB,CAAC;IAChE,CAAC;EACF,CAAC,EACD,CAAER,WAAW,EAAEC,WAAW,EAAEC,eAAe,EAAEC,eAAe,CAC7D,CAAC;AACF","ignoreList":[]}
@@ -91,30 +91,4 @@ function toPlainText(html) {
91
91
  // Merge any consecutive line breaks
92
92
  return plainText.replace(/\n\n+/g, '\n\n');
93
93
  }
94
-
95
- /**
96
- * Gets the current content editable root element based on the selection.
97
- * @param {Document} ownerDocument
98
- * @return {Element|undefined} The content editable root element.
99
- */
100
- export function getSelectionRoot(ownerDocument) {
101
- const {
102
- defaultView
103
- } = ownerDocument;
104
- const {
105
- anchorNode,
106
- focusNode
107
- } = defaultView.getSelection();
108
- if (!anchorNode || !focusNode) {
109
- return;
110
- }
111
- const anchorElement = (anchorNode.nodeType === anchorNode.ELEMENT_NODE ? anchorNode : anchorNode.parentElement).closest('[contenteditable]');
112
- if (!anchorElement) {
113
- return;
114
- }
115
- if (!anchorElement.contains(focusNode)) {
116
- return;
117
- }
118
- return anchorElement;
119
- }
120
94
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","store","blocksStore","getPasteEventData","blockEditorStore","requiresWrapperOnCopy","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","wrapperBlockClientId","clientId","wrapperBlockName","serialized","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","length","fromTransforms","reduce","accumulator","file","transformation","transform","type","isMatch","push","flat","HTML","mode","replace","trim","getSelectionRoot","ownerDocument","defaultView","anchorNode","focusNode","getSelection","anchorElement","nodeType","ELEMENT_NODE","parentElement","closest","contains"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n\n/**\n * Gets the current content editable root element based on the selection.\n * @param {Document} ownerDocument\n * @return {Element|undefined} The content editable root element.\n */\nexport function getSelectionRoot( ownerDocument ) {\n\tconst { defaultView } = ownerDocument;\n\tconst { anchorNode, focusNode } = defaultView.getSelection();\n\n\tif ( ! anchorNode || ! focusNode ) {\n\t\treturn;\n\t}\n\n\tconst anchorElement = (\n\t\tanchorNode.nodeType === anchorNode.ELEMENT_NODE\n\t\t\t? anchorNode\n\t\t\t: anchorNode.parentElement\n\t).closest( '[contenteditable]' );\n\n\tif ( ! anchorElement ) {\n\t\treturn;\n\t}\n\n\tif ( ! anchorElement.contains( focusNode ) ) {\n\t\treturn;\n\t}\n\n\treturn anchorElement;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,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,CAAC,CAAC;EAE5D,IAAK,CAAEF,UAAU,IAAI,CAAEC,SAAS,EAAG;IAClC;EACD;EAEA,MAAME,aAAa,GAAG,CACrBH,UAAU,CAACI,QAAQ,KAAKJ,UAAU,CAACK,YAAY,GAC5CL,UAAU,GACVA,UAAU,CAACM,aAAa,EAC1BC,OAAO,CAAE,mBAAoB,CAAC;EAEhC,IAAK,CAAEJ,aAAa,EAAG;IACtB;EACD;EAEA,IAAK,CAAEA,aAAa,CAACK,QAAQ,CAAEP,SAAU,CAAC,EAAG;IAC5C;EACD;EAEA,OAAOE,aAAa;AACrB","ignoreList":[]}
1
+ {"version":3,"names":["__unstableStripHTML","stripHTML","serialize","createBlock","pasteHandler","findTransform","getBlockTransforms","store","blocksStore","getPasteEventData","blockEditorStore","requiresWrapperOnCopy","Symbol","setClipboardBlocks","event","blocks","registry","_blocks","firstBlock","firstBlockType","select","getBlockType","name","getBlockRootClientId","getBlockName","getBlockAttributes","wrapperBlockClientId","clientId","wrapperBlockName","serialized","clipboardData","setData","toPlainText","getPasteBlocks","canUserUseUnfilteredHTML","plainText","html","files","length","fromTransforms","reduce","accumulator","file","transformation","transform","type","isMatch","push","flat","HTML","mode","replace","trim"],"sources":["@wordpress/block-editor/src/components/writing-flow/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport {\n\tserialize,\n\tcreateBlock,\n\tpasteHandler,\n\tfindTransform,\n\tgetBlockTransforms,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { getPasteEventData } from '../../utils/pasting';\nimport { store as blockEditorStore } from '../../store';\n\nexport const requiresWrapperOnCopy = Symbol( 'requiresWrapperOnCopy' );\n\n/**\n * Sets the clipboard data for the provided blocks, with both HTML and plain\n * text representations.\n *\n * @param {ClipboardEvent} event Clipboard event.\n * @param {WPBlock[]} blocks Blocks to set as clipboard data.\n * @param {Object} registry The registry to select from.\n */\nexport function setClipboardBlocks( event, blocks, registry ) {\n\tlet _blocks = blocks;\n\n\tconst [ firstBlock ] = blocks;\n\n\tif ( firstBlock ) {\n\t\tconst firstBlockType = registry\n\t\t\t.select( blocksStore )\n\t\t\t.getBlockType( firstBlock.name );\n\n\t\tif ( firstBlockType[ requiresWrapperOnCopy ] ) {\n\t\t\tconst { getBlockRootClientId, getBlockName, getBlockAttributes } =\n\t\t\t\tregistry.select( blockEditorStore );\n\t\t\tconst wrapperBlockClientId = getBlockRootClientId(\n\t\t\t\tfirstBlock.clientId\n\t\t\t);\n\t\t\tconst wrapperBlockName = getBlockName( wrapperBlockClientId );\n\n\t\t\tif ( wrapperBlockName ) {\n\t\t\t\t_blocks = createBlock(\n\t\t\t\t\twrapperBlockName,\n\t\t\t\t\tgetBlockAttributes( wrapperBlockClientId ),\n\t\t\t\t\t_blocks\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tconst serialized = serialize( _blocks );\n\n\tevent.clipboardData.setData( 'text/plain', toPlainText( serialized ) );\n\tevent.clipboardData.setData( 'text/html', serialized );\n}\n\n/**\n * Returns the blocks to be pasted from the clipboard event.\n *\n * @param {ClipboardEvent} event The clipboard event.\n * @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.\n * @return {Array|string} A list of blocks or a string, depending on `handlerMode`.\n */\nexport function getPasteBlocks( event, canUserUseUnfilteredHTML ) {\n\tconst { plainText, html, files } = getPasteEventData( event );\n\tlet blocks = [];\n\n\tif ( files.length ) {\n\t\tconst fromTransforms = getBlockTransforms( 'from' );\n\t\tblocks = files\n\t\t\t.reduce( ( accumulator, file ) => {\n\t\t\t\tconst transformation = findTransform(\n\t\t\t\t\tfromTransforms,\n\t\t\t\t\t( transform ) =>\n\t\t\t\t\t\ttransform.type === 'files' &&\n\t\t\t\t\t\ttransform.isMatch( [ file ] )\n\t\t\t\t);\n\t\t\t\tif ( transformation ) {\n\t\t\t\t\taccumulator.push( transformation.transform( [ file ] ) );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t}, [] )\n\t\t\t.flat();\n\t} else {\n\t\tblocks = pasteHandler( {\n\t\t\tHTML: html,\n\t\t\tplainText,\n\t\t\tmode: 'BLOCKS',\n\t\t\tcanUserUseUnfilteredHTML,\n\t\t} );\n\t}\n\n\treturn blocks;\n}\n\n/**\n * Given a string of HTML representing serialized blocks, returns the plain\n * text extracted after stripping the HTML of any tags and fixing line breaks.\n *\n * @param {string} html Serialized blocks.\n * @return {string} The plain-text content with any html removed.\n */\nfunction toPlainText( html ) {\n\t// Manually handle BR tags as line breaks prior to `stripHTML` call\n\thtml = html.replace( /<br>/g, '\\n' );\n\n\tconst plainText = stripHTML( html ).trim();\n\n\t// Merge any consecutive line breaks\n\treturn plainText.replace( /\\n\\n+/g, '\\n\\n' );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SACCC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,aAAa,EACbC,kBAAkB,EAClBC,KAAK,IAAIC,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,qBAAqB;AACvD,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,aAAa;AAEvD,OAAO,MAAMC,qBAAqB,GAAGC,MAAM,CAAE,uBAAwB,CAAC;;AAEtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAG;EAC7D,IAAIC,OAAO,GAAGF,MAAM;EAEpB,MAAM,CAAEG,UAAU,CAAE,GAAGH,MAAM;EAE7B,IAAKG,UAAU,EAAG;IACjB,MAAMC,cAAc,GAAGH,QAAQ,CAC7BI,MAAM,CAAEZ,WAAY,CAAC,CACrBa,YAAY,CAAEH,UAAU,CAACI,IAAK,CAAC;IAEjC,IAAKH,cAAc,CAAER,qBAAqB,CAAE,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,SAAS,CAAE,CAAEF,IAAI,CAAG,CAAE,CAAC;MACzD;MACA,OAAOD,WAAW;IACnB,CAAC,EAAE,EAAG,CAAC,CACNO,IAAI,CAAC,CAAC;EACT,CAAC,MAAM;IACNjC,MAAM,GAAGX,YAAY,CAAE;MACtB6C,IAAI,EAAEb,IAAI;MACVD,SAAS;MACTe,IAAI,EAAE,QAAQ;MACdhB;IACD,CAAE,CAAC;EACJ;EAEA,OAAOnB,MAAM;AACd;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASiB,WAAWA,CAAEI,IAAI,EAAG;EAC5B;EACAA,IAAI,GAAGA,IAAI,CAACe,OAAO,CAAE,OAAO,EAAE,IAAK,CAAC;EAEpC,MAAMhB,SAAS,GAAGlC,SAAS,CAAEmC,IAAK,CAAC,CAACgB,IAAI,CAAC,CAAC;;EAE1C;EACA,OAAOjB,SAAS,CAACgB,OAAO,CAAE,QAAQ,EAAE,MAAO,CAAC;AAC7C","ignoreList":[]}
@@ -10,7 +10,7 @@ import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
10
10
  import { addFilter } from '@wordpress/hooks';
11
11
  import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
12
12
  import { useSelect } from '@wordpress/data';
13
- import { Button, ButtonGroup, ToggleControl, PanelBody, privateApis as componentsPrivateApis } from '@wordpress/components';
13
+ import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, ToggleControl, PanelBody, privateApis as componentsPrivateApis } from '@wordpress/components';
14
14
  import { __ } from '@wordpress/i18n';
15
15
 
16
16
  /**
@@ -250,18 +250,22 @@ function LayoutTypeSwitcher({
250
250
  type,
251
251
  onChange
252
252
  }) {
253
- return /*#__PURE__*/_jsx(ButtonGroup, {
253
+ return /*#__PURE__*/_jsx(ToggleGroupControl, {
254
+ __next40pxDefaultSize: true,
255
+ isBlock: true,
256
+ label: __('Layout type'),
257
+ __nextHasNoMarginBottom: true,
258
+ hideLabelFromVision: true,
259
+ isAdaptiveWidth: true,
260
+ value: type,
261
+ onChange: onChange,
254
262
  children: getLayoutTypes().map(({
255
263
  name,
256
264
  label
257
265
  }) => {
258
- return /*#__PURE__*/_jsx(Button
259
- // TODO: Switch to `true` (40px size) if possible
260
- , {
261
- __next40pxDefaultSize: false,
262
- isPressed: type === name,
263
- onClick: () => onChange(name),
264
- children: label
266
+ return /*#__PURE__*/_jsx(ToggleGroupControlOption, {
267
+ value: name,
268
+ label: label
265
269
  }, name);
266
270
  })
267
271
  });
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","Button","ButtonGroup","ToggleControl","PanelBody","privateApis","componentsPrivateApis","__","store","blockEditorStore","InspectorControls","useSettings","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","useBlockSettings","useStyleOverride","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","layoutBlockSupportKey","kebabCase","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","hasGlobalPadding","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","getLayoutStyle","LayoutPanelPure","setAttributes","name","clientId","settings","layoutSettings","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","blockSupportAndThemeSettings","allowSwitching","allowEditing","allowInheriting","blockSupportAndLayout","defaultType","blockLayoutType","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","children","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","shareWithChildBlocks","edit","attributeKeys","hasSupport","map","__next40pxDefaultSize","isPressed","onClick","addAttribute","_settings$attributes$","attributes","BlockWithLayoutStyles","block","BlockListBlock","props","layoutClasses","id","selectorPrefix","css","layoutClassNames","__unstableLayoutClassNames","withLayoutStyles","blockSupportsLayout","extraProps","getBlockSettings","disableLayoutStyles","undefined"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\tButton,\n\tButtonGroup,\n\tToggleControl,\n\tPanelBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t( usedLayout?.inherit ||\n\t\t\t\t\tusedLayout?.contentSize ||\n\t\t\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\t\t\tselect( blockEditorStore ).getSettings().__experimentalFeatures\n\t\t\t\t\t?.useRootPaddingAwareAlignments\n\t\t\t);\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...layout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\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\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\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\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ButtonGroup>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<Button\n\t\t\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tisPressed={ type === name }\n\t\t\t\t\t\tonClick={ () => onChange( name ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</Button>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ButtonGroup>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\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\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t} );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { clientId, name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\tconst extraProps = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tconst { disableLayoutStyles } = getSettings();\n\n\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t);\n\n\t\t\t\treturn { blockGapSupport };\n\t\t\t},\n\t\t\t[ blockSupportsLayout, clientId ]\n\t\t);\n\n\t\tif ( ! extraProps ) {\n\t\t\treturn (\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockWithLayoutStyles\n\t\t\t\tblock={ BlockListBlock }\n\t\t\t\tprops={ props }\n\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t{ ...extraProps }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\n);\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/layout/addAttribute',\n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J;EAEA,oBACC1G,IAAA,CAAC2F,qBAAqB;IACrBC,KAAK,EAAGC,cAAgB;IACxBC,KAAK,EAAGA,KAAO;IACfC,aAAa,EAAGA,aAAe;IAAA,GAC1BQ;EAAU,CACf,CAAC;AAEJ,CAAC,EACD,kBACD,CAAC;AAED9H,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1B+G,YACD,CAAC;AACD/G,SAAS,CACR,uBAAuB,EACvB,uCAAuC,EACvC4H,gBACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["clsx","createHigherOrderComponent","useInstanceId","addFilter","getBlockSupport","hasBlockSupport","useSelect","__experimentalToggleGroupControl","ToggleGroupControl","__experimentalToggleGroupControlOption","ToggleGroupControlOption","ToggleControl","PanelBody","privateApis","componentsPrivateApis","__","store","blockEditorStore","InspectorControls","useSettings","getLayoutType","getLayoutTypes","useBlockEditingMode","LAYOUT_DEFINITIONS","useBlockSettings","useStyleOverride","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","layoutBlockSupportKey","kebabCase","hasLayoutBlockSupport","blockName","useLayoutClasses","blockAttributes","layout","default","defaultBlockLayout","usedLayout","inherit","contentSize","wideSize","type","layoutClassnames","className","baseClassName","splitBlockName","split","fullBlockName","pop","join","compoundClassName","push","hasGlobalPadding","select","getSettings","__experimentalFeatures","useRootPaddingAwareAlignments","orientation","justifyContent","flexWrap","useLayoutStyles","selector","style","fullLayoutType","blockGapSupport","hasBlockGapSupport","getLayoutStyle","LayoutPanelPure","setAttributes","name","clientId","settings","layoutSettings","themeSupportsLayout","supportsLayout","blockEditingMode","layoutBlockSupport","blockSupportAndThemeSettings","allowSwitching","allowEditing","allowInheriting","blockSupportAndLayout","defaultType","blockLayoutType","showInheritToggle","layoutType","constrainedType","displayControlsForLegacyLayouts","hasContentSizeOrLegacySettings","onChangeType","newType","onChangeLayout","newLayout","children","title","__nextHasNoMarginBottom","label","checked","onChange","help","LayoutTypeSwitcher","inspectorControls","toolBarControls","shareWithChildBlocks","edit","attributeKeys","hasSupport","__next40pxDefaultSize","isBlock","hideLabelFromVision","isAdaptiveWidth","value","map","addAttribute","_settings$attributes$","attributes","BlockWithLayoutStyles","block","BlockListBlock","props","layoutClasses","id","selectorPrefix","css","layoutClassNames","__unstableLayoutClassNames","withLayoutStyles","blockSupportsLayout","extraProps","getBlockSettings","disableLayoutStyles","undefined"],"sources":["@wordpress/block-editor/src/hooks/layout.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport {\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n\tToggleControl,\n\tPanelBody,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { InspectorControls } from '../components';\nimport { useSettings } from '../components/use-settings';\nimport { getLayoutType, getLayoutTypes } from '../layouts';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\nimport { LAYOUT_DEFINITIONS } from '../layouts/definitions';\nimport { useBlockSettings, useStyleOverride } from './utils';\nimport { unlock } from '../lock-unlock';\n\nconst layoutBlockSupportKey = 'layout';\nconst { kebabCase } = unlock( componentsPrivateApis );\n\nfunction hasLayoutBlockSupport( blockName ) {\n\treturn (\n\t\thasBlockSupport( blockName, 'layout' ) ||\n\t\thasBlockSupport( blockName, '__experimentalLayout' )\n\t);\n}\n\n/**\n * Generates the utility classnames for the given block's layout attributes.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n *\n * @return { Array } Array of CSS classname strings.\n */\nexport function useLayoutClasses( blockAttributes = {}, blockName = '' ) {\n\tconst { layout } = blockAttributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( blockName, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst layoutClassnames = [];\n\n\tif ( LAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className ) {\n\t\tconst baseClassName =\n\t\t\tLAYOUT_DEFINITIONS[ usedLayout?.type || 'default' ]?.className;\n\t\tconst splitBlockName = blockName.split( '/' );\n\t\tconst fullBlockName =\n\t\t\tsplitBlockName[ 0 ] === 'core'\n\t\t\t\t? splitBlockName.pop()\n\t\t\t\t: splitBlockName.join( '-' );\n\t\tconst compoundClassName = `wp-block-${ fullBlockName }-${ baseClassName }`;\n\t\tlayoutClassnames.push( baseClassName, compoundClassName );\n\t}\n\n\tconst hasGlobalPadding = useSelect(\n\t\t( select ) => {\n\t\t\treturn (\n\t\t\t\t( usedLayout?.inherit ||\n\t\t\t\t\tusedLayout?.contentSize ||\n\t\t\t\t\tusedLayout?.type === 'constrained' ) &&\n\t\t\t\tselect( blockEditorStore ).getSettings().__experimentalFeatures\n\t\t\t\t\t?.useRootPaddingAwareAlignments\n\t\t\t);\n\t\t},\n\t\t[ usedLayout?.contentSize, usedLayout?.inherit, usedLayout?.type ]\n\t);\n\n\tif ( hasGlobalPadding ) {\n\t\tlayoutClassnames.push( 'has-global-padding' );\n\t}\n\n\tif ( usedLayout?.orientation ) {\n\t\tlayoutClassnames.push( `is-${ kebabCase( usedLayout.orientation ) }` );\n\t}\n\n\tif ( usedLayout?.justifyContent ) {\n\t\tlayoutClassnames.push(\n\t\t\t`is-content-justification-${ kebabCase(\n\t\t\t\tusedLayout.justifyContent\n\t\t\t) }`\n\t\t);\n\t}\n\n\tif ( usedLayout?.flexWrap && usedLayout.flexWrap === 'nowrap' ) {\n\t\tlayoutClassnames.push( 'is-nowrap' );\n\t}\n\n\treturn layoutClassnames;\n}\n\n/**\n * Generates a CSS rule with the given block's layout styles.\n *\n * @param { Object } blockAttributes Block attributes.\n * @param { string } blockName Block name.\n * @param { string } selector A selector to use in generating the CSS rule.\n *\n * @return { string } CSS rule.\n */\nexport function useLayoutStyles( blockAttributes = {}, blockName, selector ) {\n\tconst { layout = {}, style = {} } = blockAttributes;\n\t// Update type for blocks using legacy layouts.\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || {};\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst [ blockGapSupport ] = useSettings( 'spacing.blockGap' );\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\treturn fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName,\n\t\tselector,\n\t\tlayout,\n\t\tstyle,\n\t\thasBlockGapSupport,\n\t} );\n}\n\nfunction LayoutPanelPure( {\n\tlayout,\n\tsetAttributes,\n\tname: blockName,\n\tclientId,\n} ) {\n\tconst settings = useBlockSettings( blockName );\n\t// Block settings come from theme.json under settings.[blockName].\n\tconst { layout: layoutSettings } = settings;\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tthemeSupportsLayout: getSettings().supportsLayout,\n\t\t};\n\t}, [] );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\n\t// Layout block support comes from the block's block.json.\n\tconst layoutBlockSupport = getBlockSupport(\n\t\tblockName,\n\t\tlayoutBlockSupportKey,\n\t\t{}\n\t);\n\tconst blockSupportAndThemeSettings = {\n\t\t...layoutSettings,\n\t\t...layoutBlockSupport,\n\t};\n\tconst {\n\t\tallowSwitching,\n\t\tallowEditing = true,\n\t\tallowInheriting = true,\n\t\tdefault: defaultBlockLayout,\n\t} = blockSupportAndThemeSettings;\n\n\tif ( ! allowEditing ) {\n\t\treturn null;\n\t}\n\n\t/*\n\t * Try to find the layout type from either the\n\t * block's layout settings or any saved layout config.\n\t */\n\tconst blockSupportAndLayout = {\n\t\t...layoutBlockSupport,\n\t\t...layout,\n\t};\n\tconst { type, default: { type: defaultType = 'default' } = {} } =\n\t\tblockSupportAndLayout;\n\tconst blockLayoutType = type || defaultType;\n\n\t// Only show the inherit toggle if it's supported,\n\t// and either the default / flow or the constrained layout type is in use, as the toggle switches from one to the other.\n\tconst showInheritToggle = !! (\n\t\tallowInheriting &&\n\t\t( ! blockLayoutType ||\n\t\t\tblockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ||\n\t\t\tblockSupportAndLayout.inherit )\n\t);\n\n\tconst usedLayout = layout || defaultBlockLayout || {};\n\tconst { inherit = false, contentSize = null } = usedLayout;\n\t/**\n\t * `themeSupportsLayout` is only relevant to the `default/flow` or\n\t * `constrained` layouts and it should not be taken into account when other\n\t * `layout` types are used.\n\t */\n\tif (\n\t\t( blockLayoutType === 'default' ||\n\t\t\tblockLayoutType === 'constrained' ) &&\n\t\t! themeSupportsLayout\n\t) {\n\t\treturn null;\n\t}\n\tconst layoutType = getLayoutType( blockLayoutType );\n\tconst constrainedType = getLayoutType( 'constrained' );\n\tconst displayControlsForLegacyLayouts =\n\t\t! usedLayout.type && ( contentSize || inherit );\n\tconst hasContentSizeOrLegacySettings = !! inherit || !! contentSize;\n\n\tconst onChangeType = ( newType ) =>\n\t\tsetAttributes( { layout: { type: newType } } );\n\tconst onChangeLayout = ( newLayout ) =>\n\t\tsetAttributes( { layout: newLayout } );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Layout' ) }>\n\t\t\t\t\t{ showInheritToggle && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tlabel={ __( 'Inner blocks use content width' ) }\n\t\t\t\t\t\t\t\tchecked={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonChange={ () =>\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\ttype:\n\t\t\t\t\t\t\t\t\t\t\t\tlayoutType?.name ===\n\t\t\t\t\t\t\t\t\t\t\t\t\t'constrained' ||\n\t\t\t\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t\t\t\t? 'default'\n\t\t\t\t\t\t\t\t\t\t\t\t\t: 'constrained',\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\thelp={\n\t\t\t\t\t\t\t\t\tlayoutType?.name === 'constrained' ||\n\t\t\t\t\t\t\t\t\thasContentSizeOrLegacySettings\n\t\t\t\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Nested blocks use content width with options for full and wide widths.'\n\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\t\t\t'Nested blocks will fill the width of this container. Toggle to constrain.'\n\t\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</>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ ! inherit && allowSwitching && (\n\t\t\t\t\t\t<LayoutTypeSwitcher\n\t\t\t\t\t\t\ttype={ blockLayoutType }\n\t\t\t\t\t\t\tonChange={ onChangeType }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ layoutType && layoutType.name !== 'default' && (\n\t\t\t\t\t\t<layoutType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ constrainedType && displayControlsForLegacyLayouts && (\n\t\t\t\t\t\t<constrainedType.inspectorControls\n\t\t\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\t\t\tlayoutBlockSupport={ blockSupportAndThemeSettings }\n\t\t\t\t\t\t\tname={ blockName }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && layoutType && (\n\t\t\t\t<layoutType.toolBarControls\n\t\t\t\t\tlayout={ usedLayout }\n\t\t\t\t\tonChange={ onChangeLayout }\n\t\t\t\t\tlayoutBlockSupport={ layoutBlockSupport }\n\t\t\t\t\tname={ blockName }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default {\n\tshareWithChildBlocks: true,\n\tedit: LayoutPanelPure,\n\tattributeKeys: [ 'layout' ],\n\thasSupport( name ) {\n\t\treturn hasLayoutBlockSupport( name );\n\t},\n};\n\nfunction LayoutTypeSwitcher( { type, onChange } ) {\n\treturn (\n\t\t<ToggleGroupControl\n\t\t\t__next40pxDefaultSize\n\t\t\tisBlock\n\t\t\tlabel={ __( 'Layout type' ) }\n\t\t\t__nextHasNoMarginBottom\n\t\t\thideLabelFromVision\n\t\t\tisAdaptiveWidth\n\t\t\tvalue={ type }\n\t\t\tonChange={ onChange }\n\t\t>\n\t\t\t{ getLayoutTypes().map( ( { name, label } ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\tkey={ name }\n\t\t\t\t\t\tvalue={ name }\n\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</ToggleGroupControl>\n\t);\n}\n\n/**\n * Filters registered block settings, extending attributes to include `layout`.\n *\n * @param {Object} settings Original block settings.\n *\n * @return {Object} Filtered block settings.\n */\nexport function addAttribute( settings ) {\n\tif ( 'type' in ( settings.attributes?.layout ?? {} ) ) {\n\t\treturn settings;\n\t}\n\tif ( hasLayoutBlockSupport( settings ) ) {\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\nfunction BlockWithLayoutStyles( {\n\tblock: BlockListBlock,\n\tprops,\n\tblockGapSupport,\n\tlayoutClasses,\n} ) {\n\tconst { name, attributes } = props;\n\tconst id = useInstanceId( BlockListBlock );\n\tconst { layout } = attributes;\n\tconst { default: defaultBlockLayout } =\n\t\tgetBlockSupport( name, layoutBlockSupportKey ) || {};\n\tconst usedLayout =\n\t\tlayout?.inherit || layout?.contentSize || layout?.wideSize\n\t\t\t? { ...layout, type: 'constrained' }\n\t\t\t: layout || defaultBlockLayout || {};\n\n\tconst selectorPrefix = `wp-container-${ kebabCase( name ) }-is-layout-`;\n\t// Higher specificity to override defaults from theme.json.\n\tconst selector = `.${ selectorPrefix }${ id }`;\n\tconst hasBlockGapSupport = blockGapSupport !== null;\n\n\t// Get CSS string for the current layout type.\n\t// The CSS and `style` element is only output if it is not empty.\n\tconst fullLayoutType = getLayoutType( usedLayout?.type || 'default' );\n\tconst css = fullLayoutType?.getLayoutStyle?.( {\n\t\tblockName: name,\n\t\tselector,\n\t\tlayout: usedLayout,\n\t\tstyle: attributes?.style,\n\t\thasBlockGapSupport,\n\t} );\n\n\t// Attach a `wp-container-` id-based class name as well as a layout class name such as `is-layout-flex`.\n\tconst layoutClassNames = clsx(\n\t\t{\n\t\t\t[ `${ selectorPrefix }${ id }` ]: !! css, // Only attach a container class if there is generated CSS to be attached.\n\t\t},\n\t\tlayoutClasses\n\t);\n\n\tuseStyleOverride( { css } );\n\n\treturn (\n\t\t<BlockListBlock\n\t\t\t{ ...props }\n\t\t\t__unstableLayoutClassNames={ layoutClassNames }\n\t\t/>\n\t);\n}\n\n/**\n * Override the default block element to add the layout styles.\n *\n * @param {Function} BlockListBlock Original component.\n *\n * @return {Function} Wrapped component.\n */\nexport const withLayoutStyles = createHigherOrderComponent(\n\t( BlockListBlock ) => ( props ) => {\n\t\tconst { clientId, name, attributes } = props;\n\t\tconst blockSupportsLayout = hasLayoutBlockSupport( name );\n\t\tconst layoutClasses = useLayoutClasses( attributes, name );\n\t\tconst extraProps = useSelect(\n\t\t\t( select ) => {\n\t\t\t\t// The callback returns early to avoid block editor subscription.\n\t\t\t\tif ( ! blockSupportsLayout ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { getSettings, getBlockSettings } = unlock(\n\t\t\t\t\tselect( blockEditorStore )\n\t\t\t\t);\n\t\t\t\tconst { disableLayoutStyles } = getSettings();\n\n\t\t\t\tif ( disableLayoutStyles ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst [ blockGapSupport ] = getBlockSettings(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'spacing.blockGap'\n\t\t\t\t);\n\n\t\t\t\treturn { blockGapSupport };\n\t\t\t},\n\t\t\t[ blockSupportsLayout, clientId ]\n\t\t);\n\n\t\tif ( ! extraProps ) {\n\t\t\treturn (\n\t\t\t\t<BlockListBlock\n\t\t\t\t\t{ ...props }\n\t\t\t\t\t__unstableLayoutClassNames={\n\t\t\t\t\t\tblockSupportsLayout ? layoutClasses : undefined\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<BlockWithLayoutStyles\n\t\t\t\tblock={ BlockListBlock }\n\t\t\t\tprops={ props }\n\t\t\t\tlayoutClasses={ layoutClasses }\n\t\t\t\t{ ...extraProps }\n\t\t\t/>\n\t\t);\n\t},\n\t'withLayoutStyles'\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);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,0BAA0B,EAAEC,aAAa,QAAQ,oBAAoB;AAC9E,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,eAAe,EAAEC,eAAe,QAAQ,mBAAmB;AACpE,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,gCAAgC,IAAIC,kBAAkB,EACtDC,sCAAsC,IAAIC,wBAAwB,EAClEC,aAAa,EACbC,SAAS,EACTC,WAAW,IAAIC,qBAAqB,QAC9B,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,iBAAiB,QAAQ,eAAe;AACjD,SAASC,WAAW,QAAQ,4BAA4B;AACxD,SAASC,aAAa,EAAEC,cAAc,QAAQ,YAAY;AAC1D,SAASC,mBAAmB,QAAQ,kCAAkC;AACtE,SAASC,kBAAkB,QAAQ,wBAAwB;AAC3D,SAASC,gBAAgB,EAAEC,gBAAgB,QAAQ,SAAS;AAC5D,SAASC,MAAM,QAAQ,gBAAgB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAExC,MAAMC,qBAAqB,GAAG,QAAQ;AACtC,MAAM;EAAEC;AAAU,CAAC,GAAGR,MAAM,CAAEZ,qBAAsB,CAAC;AAErD,SAASqB,qBAAqBA,CAAEC,SAAS,EAAG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AQ,EACR,kBACD,CAAC;IAED,OAAO;MAAEN;IAAgB,CAAC;EAC3B,CAAC,EACD,CAAE+D,mBAAmB,EAAEzD,QAAQ,CAChC,CAAC;EAED,IAAK,CAAE0D,UAAU,EAAG;IACnB,oBACCzG,IAAA,CAAC+F,cAAc;MAAA,GACTC,KAAK;MACVM,0BAA0B,EACzBE,mBAAmB,GAAGP,aAAa,GAAGW;IACtC,CACD,CAAC;EAEJ;EAEA,oBACC5G,IAAA,CAAC6F,qBAAqB;IACrBC,KAAK,EAAGC,cAAgB;IACxBC,KAAK,EAAGA,KAAO;IACfC,aAAa,EAAGA,aAAe;IAAA,GAC1BQ;EAAU,CACf,CAAC;AAEJ,CAAC,EACD,kBACD,CAAC;AAEDlI,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1BmH,YACD,CAAC;AACDnH,SAAS,CACR,uBAAuB,EACvB,uCAAuC,EACvCgI,gBACD,CAAC","ignoreList":[]}
@@ -93,16 +93,17 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
93
93
  const sources = useSelect(select => unlock(select(blocksStore)).getAllBlockBindingsSources());
94
94
  const {
95
95
  name,
96
- clientId
96
+ clientId,
97
+ context,
98
+ setAttributes
97
99
  } = props;
98
- const hasParentPattern = !!props.context['pattern/overrides'];
99
- const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
100
100
  const blockBindings = useMemo(() => replacePatternOverrideDefaultBindings(name, props.attributes.metadata?.bindings), [props.attributes.metadata?.bindings, name]);
101
101
 
102
102
  // While this hook doesn't directly call any selectors, `useSelect` is
103
103
  // used purposely here to ensure `boundAttributes` is updated whenever
104
104
  // there are attribute updates.
105
105
  // `source.getValues` may also call a selector via `registry.select`.
106
+ const updatedContext = {};
106
107
  const boundAttributes = useSelect(() => {
107
108
  if (!blockBindings) {
108
109
  return;
@@ -118,6 +119,11 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
118
119
  if (!source || !canBindAttribute(name, attributeName)) {
119
120
  continue;
120
121
  }
122
+
123
+ // Populate context.
124
+ for (const key of source.usesContext || []) {
125
+ updatedContext[key] = blockContext[key];
126
+ }
121
127
  blockBindingsBySource.set(source, {
122
128
  ...blockBindingsBySource.get(source),
123
129
  [attributeName]: {
@@ -127,14 +133,6 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
127
133
  }
128
134
  if (blockBindingsBySource.size) {
129
135
  for (const [source, bindings] of blockBindingsBySource) {
130
- // Populate context.
131
- const context = {};
132
- if (source.usesContext?.length) {
133
- for (const key of source.usesContext) {
134
- context[key] = blockContext[key];
135
- }
136
- }
137
-
138
136
  // Get values in batch if the source supports it.
139
137
  let values = {};
140
138
  if (!source.getValues) {
@@ -145,7 +143,7 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
145
143
  } else {
146
144
  values = source.getValues({
147
145
  registry,
148
- context,
146
+ context: updatedContext,
149
147
  clientId,
150
148
  bindings
151
149
  });
@@ -161,10 +159,9 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
161
159
  }
162
160
  }
163
161
  return attributes;
164
- }, [blockBindings, name, clientId, blockContext, registry, sources]);
165
- const {
166
- setAttributes
167
- } = props;
162
+ }, [blockBindings, name, clientId, updatedContext, registry, sources]);
163
+ const hasParentPattern = !!updatedContext['pattern/overrides'];
164
+ const hasPatternOverridesDefaultBinding = props.attributes.metadata?.bindings?.[DEFAULT_ATTRIBUTE]?.source === 'core/pattern-overrides';
168
165
  const _setAttributes = useCallback(nextAttributes => {
169
166
  registry.batch(() => {
170
167
  if (!blockBindings) {
@@ -197,16 +194,9 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
197
194
  }
198
195
  if (blockBindingsBySource.size) {
199
196
  for (const [source, bindings] of blockBindingsBySource) {
200
- // Populate context.
201
- const context = {};
202
- if (source.usesContext?.length) {
203
- for (const key of source.usesContext) {
204
- context[key] = blockContext[key];
205
- }
206
- }
207
197
  source.setValues({
208
198
  registry,
209
- context,
199
+ context: updatedContext,
210
200
  clientId,
211
201
  bindings
212
202
  });
@@ -224,7 +214,7 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
224
214
  setAttributes(keptAttributes);
225
215
  }
226
216
  });
227
- }, [registry, blockBindings, name, clientId, blockContext, setAttributes, sources, hasPatternOverridesDefaultBinding, hasParentPattern]);
217
+ }, [registry, blockBindings, name, clientId, updatedContext, setAttributes, sources, hasPatternOverridesDefaultBinding, hasParentPattern]);
228
218
  return /*#__PURE__*/_jsx(_Fragment, {
229
219
  children: /*#__PURE__*/_jsx(BlockEdit, {
230
220
  ...props,
@@ -232,7 +222,11 @@ export const withBlockBindingSupport = createHigherOrderComponent(BlockEdit => p
232
222
  ...props.attributes,
233
223
  ...boundAttributes
234
224
  },
235
- setAttributes: _setAttributes
225
+ setAttributes: _setAttributes,
226
+ context: {
227
+ ...context,
228
+ ...updatedContext
229
+ }
236
230
  })
237
231
  });
238
232
  }, 'withBlockBindingSupport');