@wordpress/block-editor 15.15.0 → 15.16.1-next.v.202604091042.0

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 (197) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/autocomplete/index.cjs +1 -2
  3. package/build/components/autocomplete/index.cjs.map +3 -3
  4. package/build/components/block-inspector/index.cjs +2 -1
  5. package/build/components/block-inspector/index.cjs.map +2 -2
  6. package/build/components/block-list/block-crash-warning.cjs +4 -2
  7. package/build/components/block-list/block-crash-warning.cjs.map +2 -2
  8. package/build/components/block-list/block-html.cjs +6 -2
  9. package/build/components/block-list/block-html.cjs.map +2 -2
  10. package/build/components/block-mover/button.cjs +4 -3
  11. package/build/components/block-mover/button.cjs.map +2 -2
  12. package/build/components/block-mover/index.cjs +1 -8
  13. package/build/components/block-mover/index.cjs.map +2 -2
  14. package/build/components/block-visibility/modal.cjs +2 -2
  15. package/build/components/block-visibility/modal.cjs.map +1 -1
  16. package/build/components/block-visibility/viewport-visibility-info.cjs +6 -1
  17. package/build/components/block-visibility/viewport-visibility-info.cjs.map +2 -2
  18. package/build/components/global-styles/background-panel.cjs +142 -33
  19. package/build/components/global-styles/background-panel.cjs.map +2 -2
  20. package/build/components/global-styles/color-panel.cjs +18 -7
  21. package/build/components/global-styles/color-panel.cjs.map +2 -2
  22. package/build/components/global-styles/hooks.cjs +8 -4
  23. package/build/components/global-styles/hooks.cjs.map +2 -2
  24. package/build/components/iframe/get-compatibility-styles.cjs +1 -1
  25. package/build/components/iframe/get-compatibility-styles.cjs.map +2 -2
  26. package/build/components/inserter/media-tab/hooks.cjs +1 -1
  27. package/build/components/inserter/media-tab/hooks.cjs.map +2 -2
  28. package/build/components/inspector-controls-tabs/styles-tab.cjs +2 -1
  29. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  30. package/build/components/link-control/search-input.cjs +1 -1
  31. package/build/components/link-control/search-input.cjs.map +2 -2
  32. package/build/components/link-picker/link-preview.cjs +2 -1
  33. package/build/components/link-picker/link-preview.cjs.map +3 -3
  34. package/build/components/rich-text/index.cjs +1 -1
  35. package/build/components/rich-text/index.cjs.map +2 -2
  36. package/build/components/rich-text/input-event.cjs +3 -3
  37. package/build/components/rich-text/input-event.cjs.map +2 -2
  38. package/build/components/use-on-block-drop/index.cjs +1 -1
  39. package/build/components/use-on-block-drop/index.cjs.map +2 -2
  40. package/build/components/use-paste-styles/index.cjs +2 -2
  41. package/build/components/use-paste-styles/index.cjs.map +2 -2
  42. package/build/hooks/background.cjs +74 -21
  43. package/build/hooks/background.cjs.map +3 -3
  44. package/build/hooks/block-style-variation.cjs +5 -6
  45. package/build/hooks/block-style-variation.cjs.map +3 -3
  46. package/build/hooks/cross-origin-isolation.cjs +6 -6
  47. package/build/hooks/cross-origin-isolation.cjs.map +2 -2
  48. package/build/hooks/custom-css.cjs +5 -0
  49. package/build/hooks/custom-css.cjs.map +2 -2
  50. package/build/hooks/fit-text.cjs +46 -58
  51. package/build/hooks/fit-text.cjs.map +3 -3
  52. package/build/hooks/index.cjs +2 -2
  53. package/build/hooks/index.cjs.map +2 -2
  54. package/build/hooks/utils.cjs +5 -1
  55. package/build/hooks/utils.cjs.map +2 -2
  56. package/build/private-apis.cjs +1 -1
  57. package/build/private-apis.cjs.map +1 -1
  58. package/build/store/actions.cjs +8 -12
  59. package/build/store/actions.cjs.map +2 -2
  60. package/build/store/private-selectors.cjs +2 -2
  61. package/build/store/private-selectors.cjs.map +2 -2
  62. package/build/store/reducer.cjs +112 -146
  63. package/build/store/reducer.cjs.map +2 -2
  64. package/build/store/selectors.cjs +14 -15
  65. package/build/store/selectors.cjs.map +2 -2
  66. package/build/store/utils.cjs +1 -1
  67. package/build/store/utils.cjs.map +2 -2
  68. package/build/utils/pasting.cjs +1 -1
  69. package/build/utils/pasting.cjs.map +2 -2
  70. package/build-module/components/autocomplete/index.mjs +1 -2
  71. package/build-module/components/autocomplete/index.mjs.map +2 -2
  72. package/build-module/components/block-inspector/index.mjs +2 -1
  73. package/build-module/components/block-inspector/index.mjs.map +2 -2
  74. package/build-module/components/block-list/block-crash-warning.mjs +4 -2
  75. package/build-module/components/block-list/block-crash-warning.mjs.map +2 -2
  76. package/build-module/components/block-list/block-html.mjs +7 -3
  77. package/build-module/components/block-list/block-html.mjs.map +2 -2
  78. package/build-module/components/block-mover/button.mjs +4 -3
  79. package/build-module/components/block-mover/button.mjs.map +2 -2
  80. package/build-module/components/block-mover/index.mjs +1 -8
  81. package/build-module/components/block-mover/index.mjs.map +2 -2
  82. package/build-module/components/block-visibility/modal.mjs +2 -2
  83. package/build-module/components/block-visibility/modal.mjs.map +1 -1
  84. package/build-module/components/block-visibility/viewport-visibility-info.mjs +6 -1
  85. package/build-module/components/block-visibility/viewport-visibility-info.mjs.map +2 -2
  86. package/build-module/components/global-styles/background-panel.mjs +141 -34
  87. package/build-module/components/global-styles/background-panel.mjs.map +2 -2
  88. package/build-module/components/global-styles/color-panel.mjs +17 -7
  89. package/build-module/components/global-styles/color-panel.mjs.map +2 -2
  90. package/build-module/components/global-styles/hooks.mjs +8 -4
  91. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  92. package/build-module/components/iframe/get-compatibility-styles.mjs +1 -1
  93. package/build-module/components/iframe/get-compatibility-styles.mjs.map +2 -2
  94. package/build-module/components/inserter/media-tab/hooks.mjs +1 -1
  95. package/build-module/components/inserter/media-tab/hooks.mjs.map +2 -2
  96. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +2 -1
  97. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  98. package/build-module/components/link-control/search-input.mjs +1 -1
  99. package/build-module/components/link-control/search-input.mjs.map +2 -2
  100. package/build-module/components/link-picker/link-preview.mjs +2 -1
  101. package/build-module/components/link-picker/link-preview.mjs.map +2 -2
  102. package/build-module/components/rich-text/index.mjs +2 -2
  103. package/build-module/components/rich-text/index.mjs.map +2 -2
  104. package/build-module/components/rich-text/input-event.mjs +2 -2
  105. package/build-module/components/rich-text/input-event.mjs.map +2 -2
  106. package/build-module/components/use-on-block-drop/index.mjs +1 -1
  107. package/build-module/components/use-on-block-drop/index.mjs.map +2 -2
  108. package/build-module/components/use-paste-styles/index.mjs +2 -2
  109. package/build-module/components/use-paste-styles/index.mjs.map +2 -2
  110. package/build-module/hooks/background.mjs +76 -22
  111. package/build-module/hooks/background.mjs.map +2 -2
  112. package/build-module/hooks/block-style-variation.mjs +4 -5
  113. package/build-module/hooks/block-style-variation.mjs.map +2 -2
  114. package/build-module/hooks/cross-origin-isolation.mjs +6 -6
  115. package/build-module/hooks/cross-origin-isolation.mjs.map +2 -2
  116. package/build-module/hooks/custom-css.mjs +5 -0
  117. package/build-module/hooks/custom-css.mjs.map +2 -2
  118. package/build-module/hooks/fit-text.mjs +46 -58
  119. package/build-module/hooks/fit-text.mjs.map +2 -2
  120. package/build-module/hooks/index.mjs +2 -2
  121. package/build-module/hooks/index.mjs.map +2 -2
  122. package/build-module/hooks/utils.mjs +5 -1
  123. package/build-module/hooks/utils.mjs.map +2 -2
  124. package/build-module/private-apis.mjs +2 -2
  125. package/build-module/private-apis.mjs.map +1 -1
  126. package/build-module/store/actions.mjs +8 -12
  127. package/build-module/store/actions.mjs.map +2 -2
  128. package/build-module/store/private-selectors.mjs +2 -2
  129. package/build-module/store/private-selectors.mjs.map +2 -2
  130. package/build-module/store/reducer.mjs +112 -145
  131. package/build-module/store/reducer.mjs.map +2 -2
  132. package/build-module/store/selectors.mjs +14 -15
  133. package/build-module/store/selectors.mjs.map +2 -2
  134. package/build-module/store/utils.mjs +1 -1
  135. package/build-module/store/utils.mjs.map +2 -2
  136. package/build-module/utils/pasting.mjs +1 -1
  137. package/build-module/utils/pasting.mjs.map +2 -2
  138. package/build-style/content-rtl.css +2 -2
  139. package/build-style/content.css +2 -2
  140. package/build-style/style-rtl.css +35 -14
  141. package/build-style/style.css +35 -14
  142. package/package.json +38 -39
  143. package/src/autocompleters/style.scss +0 -8
  144. package/src/components/autocomplete/index.js +1 -2
  145. package/src/components/background-image-control/style.scss +0 -4
  146. package/src/components/block-draggable/test/helpers.native.js +1 -1
  147. package/src/components/block-inspector/index.js +1 -0
  148. package/src/components/block-list/block-crash-warning.js +3 -1
  149. package/src/components/block-list/block-crash-warning.native.js +3 -1
  150. package/src/components/block-list/block-html.js +13 -3
  151. package/src/components/block-mover/button.js +7 -4
  152. package/src/components/block-mover/index.js +1 -8
  153. package/src/components/block-visibility/viewport-visibility-info.js +8 -1
  154. package/src/components/fit-text-size-warning/style.scss +1 -5
  155. package/src/components/global-styles/background-panel.js +157 -11
  156. package/src/components/global-styles/color-panel.js +23 -7
  157. package/src/components/global-styles/hooks.js +12 -4
  158. package/src/components/global-styles/test/background-panel.js +44 -1
  159. package/src/components/iframe/get-compatibility-styles.js +1 -1
  160. package/src/components/inserter/media-tab/hooks.js +1 -1
  161. package/src/components/inspector-controls-tabs/styles-tab.js +1 -0
  162. package/src/components/link-control/README.md +2 -2
  163. package/src/components/link-control/search-input.js +1 -1
  164. package/src/components/link-picker/link-preview.js +2 -1
  165. package/src/components/rich-text/index.js +1 -1
  166. package/src/components/rich-text/index.native.js +1 -1
  167. package/src/components/rich-text/input-event.js +1 -1
  168. package/src/components/rich-text/input-event.native.js +1 -1
  169. package/src/components/rich-text/native/index.native.js +18 -17
  170. package/src/components/use-on-block-drop/index.js +1 -1
  171. package/src/components/use-paste-styles/index.js +2 -2
  172. package/src/hooks/background.js +122 -21
  173. package/src/hooks/background.scss +45 -0
  174. package/src/hooks/block-style-variation.js +3 -4
  175. package/src/hooks/cross-origin-isolation.js +6 -6
  176. package/src/hooks/custom-css.js +6 -0
  177. package/src/hooks/fit-text.js +73 -83
  178. package/src/hooks/index.js +1 -1
  179. package/src/hooks/test/cross-origin-isolation.js +7 -3
  180. package/src/hooks/utils.js +4 -0
  181. package/src/private-apis.js +2 -2
  182. package/src/store/actions.js +9 -16
  183. package/src/store/private-selectors.js +2 -2
  184. package/src/store/reducer.js +144 -193
  185. package/src/store/selectors.js +33 -23
  186. package/src/store/test/private-selectors.js +107 -71
  187. package/src/store/test/reducer.js +593 -152
  188. package/src/store/test/registry-selectors.js +1 -1
  189. package/src/store/test/selectors.js +345 -262
  190. package/src/store/utils.js +1 -1
  191. package/src/style.scss +1 -0
  192. package/src/utils/pasting.js +1 -1
  193. package/build/autocompleters/link.cjs +0 -81
  194. package/build/autocompleters/link.cjs.map +0 -7
  195. package/build-module/autocompleters/link.mjs +0 -50
  196. package/build-module/autocompleters/link.mjs.map +0 -7
  197. package/src/autocompleters/link.js +0 -63
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-on-block-drop/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch ( err ) {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) => {\n\t\t\t\t\treturn createBlock(\n\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAOO;AACP,kBAAoD;AACpD,iBAAyC;AAKzC,mBAA0C;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IAC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M,uBACL,cAAe,kBAAmB;AACnC,cAAM,sBACL,qBAAsB,gBAAiB;AAExC,iBAAS,MAAO,MAAM;AAErB,uBAAc,iBAAiB,KAAM;AAErC;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH,OAAO;AACN;AAAA,UACC;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,UAAU;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,eAAe;AAAA,IACpB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACA,QAAM,cAAc,WAAY,qBAAsB;AAEtD,SAAO,CAAE,UAAW;AACnB,UAAM,YAAQ,qCAA0B,MAAM,YAAa;AAC3D,UAAM,OAAO,MAAM,aAAa,QAAS,WAAY;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport {\n\tcloneBlock,\n\tcreateBlock,\n\tfindTransform,\n\tgetBlockTransforms,\n\tpasteHandler,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { useDispatch, useSelect, useRegistry } from '@wordpress/data';\nimport { getFilesFromDataTransfer } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/** @typedef {React.SyntheticEvent} SyntheticEvent */\n/** @typedef {import('./types').WPDropOperation} WPDropOperation */\n\n/**\n * Retrieve the data for a block drop event.\n *\n * @param {SyntheticEvent} event The drop event.\n *\n * @return {Object} An object with block drag and drop data.\n */\nexport function parseDropEvent( event ) {\n\tlet result = {\n\t\tsrcRootClientId: null,\n\t\tsrcClientIds: null,\n\t\tsrcIndex: null,\n\t\ttype: null,\n\t\tblocks: null,\n\t};\n\n\tif ( ! event.dataTransfer ) {\n\t\treturn result;\n\t}\n\n\ttry {\n\t\tresult = Object.assign(\n\t\t\tresult,\n\t\t\tJSON.parse( event.dataTransfer.getData( 'wp-blocks' ) )\n\t\t);\n\t} catch {\n\t\treturn result;\n\t}\n\n\treturn result;\n}\n\n/**\n * A function that returns an event handler function for block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Function} getBlockIndex A function that gets the index of a block.\n * @param {Function} getClientIdsOfDescendants A function that gets the client ids of descendant blocks.\n * @param {Function} moveBlocks A function that moves blocks.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n * @param {Function} clearSelectedBlock A function that clears block selection.\n * @param {string} operation The type of operation to perform on drop. Could be `insert` or `replace` or `group`.\n * @param {Function} getBlock A function that returns a block given its client id.\n * @return {Function} The event handler for a block drop event.\n */\nexport function onBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\tgetBlockIndex,\n\tgetClientIdsOfDescendants,\n\tmoveBlocks,\n\tinsertOrReplaceBlocks,\n\tclearSelectedBlock,\n\toperation,\n\tgetBlock\n) {\n\treturn ( event ) => {\n\t\tconst {\n\t\t\tsrcRootClientId: sourceRootClientId,\n\t\t\tsrcClientIds: sourceClientIds,\n\t\t\ttype: dropType,\n\t\t\tblocks,\n\t\t} = parseDropEvent( event );\n\n\t\t// If the user is inserting a block.\n\t\tif ( dropType === 'inserter' ) {\n\t\t\tclearSelectedBlock();\n\t\t\tconst blocksToInsert = blocks.map( ( block ) =>\n\t\t\t\tcloneBlock( block )\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocksToInsert, true, null );\n\t\t}\n\n\t\t// If the user is moving a block.\n\t\tif ( dropType === 'block' ) {\n\t\t\tconst sourceBlockIndex = getBlockIndex( sourceClientIds[ 0 ] );\n\n\t\t\t// If the user is dropping to the same position, return early.\n\t\t\tif (\n\t\t\t\tsourceRootClientId === targetRootClientId &&\n\t\t\t\tsourceBlockIndex === targetBlockIndex\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is attempting to drop a block within its own\n\t\t\t// nested blocks, return early as this would create infinite\n\t\t\t// recursion.\n\t\t\tif (\n\t\t\t\tsourceClientIds.includes( targetRootClientId ) ||\n\t\t\t\tgetClientIdsOfDescendants( sourceClientIds ).some(\n\t\t\t\t\t( id ) => id === targetRootClientId\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If the user is dropping a block over another block, replace both blocks\n\t\t\t// with a group block containing them\n\t\t\tif ( operation === 'group' ) {\n\t\t\t\tconst blocksToInsert = sourceClientIds.map( ( clientId ) =>\n\t\t\t\t\tgetBlock( clientId )\n\t\t\t\t);\n\t\t\t\tinsertOrReplaceBlocks(\n\t\t\t\t\tblocksToInsert,\n\t\t\t\t\ttrue,\n\t\t\t\t\tnull,\n\t\t\t\t\tsourceClientIds\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isAtSameLevel = sourceRootClientId === targetRootClientId;\n\t\t\tconst draggedBlockCount = sourceClientIds.length;\n\n\t\t\t// If the block is kept at the same level and moved downwards,\n\t\t\t// subtract to take into account that the blocks being dragged\n\t\t\t// were removed from the block list above the insertion point.\n\t\t\tconst insertIndex =\n\t\t\t\tisAtSameLevel && sourceBlockIndex < targetBlockIndex\n\t\t\t\t\t? targetBlockIndex - draggedBlockCount\n\t\t\t\t\t: targetBlockIndex;\n\n\t\t\tmoveBlocks( sourceClientIds, sourceRootClientId, insertIndex );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related file drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {Function} getSettings A function that gets the block editor settings.\n * @param {Function} updateBlockAttributes A function that updates a block's attributes.\n * @param {Function} canInsertBlockType A function that returns checks whether a block type can be inserted.\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related file drop event.\n */\nexport function onFilesDrop(\n\ttargetRootClientId,\n\tgetSettings,\n\tupdateBlockAttributes,\n\tcanInsertBlockType,\n\tinsertOrReplaceBlocks\n) {\n\treturn ( files ) => {\n\t\tif ( ! getSettings().mediaUpload ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst transformation = findTransform(\n\t\t\tgetBlockTransforms( 'from' ),\n\t\t\t( transform ) =>\n\t\t\t\ttransform.type === 'files' &&\n\t\t\t\tcanInsertBlockType( transform.blockName, targetRootClientId ) &&\n\t\t\t\ttransform.isMatch( files )\n\t\t);\n\n\t\tif ( transformation ) {\n\t\t\tconst blocks = transformation.transform(\n\t\t\t\tfiles,\n\t\t\t\tupdateBlockAttributes\n\t\t\t);\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A function that returns an event handler function for block-related HTML drop events.\n *\n * @param {Function} insertOrReplaceBlocks A function that inserts or replaces blocks.\n *\n * @return {Function} The event handler for a block-related HTML drop event.\n */\nexport function onHTMLDrop( insertOrReplaceBlocks ) {\n\treturn ( HTML ) => {\n\t\tconst blocks = pasteHandler( { HTML, mode: 'BLOCKS' } );\n\n\t\tif ( blocks.length ) {\n\t\t\tinsertOrReplaceBlocks( blocks );\n\t\t}\n\t};\n}\n\n/**\n * A React hook for handling block drop events.\n *\n * @param {string} targetRootClientId The root client id where the block(s) will be inserted.\n * @param {number} targetBlockIndex The index where the block(s) will be inserted.\n * @param {Object} options The optional options.\n * @param {WPDropOperation} [options.operation] The type of operation to perform on drop. Could be `insert` or `replace` for now.\n *\n * @return {Function} A function to be passed to the onDrop handler.\n */\nexport default function useOnBlockDrop(\n\ttargetRootClientId,\n\ttargetBlockIndex,\n\toptions = {}\n) {\n\tconst { operation = 'insert', nearestSide = 'right' } = options;\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tgetSettings,\n\t\tgetBlock,\n\t} = useSelect( blockEditorStore );\n\tconst { getGroupingBlockName } = useSelect( blocksStore );\n\tconst {\n\t\tinsertBlocks,\n\t\tmoveBlocksToPosition,\n\t\tupdateBlockAttributes,\n\t\tclearSelectedBlock,\n\t\treplaceBlocks,\n\t\tremoveBlocks,\n\t} = useDispatch( blockEditorStore );\n\tconst registry = useRegistry();\n\n\tconst insertOrReplaceBlocks = useCallback(\n\t\t(\n\t\t\tblocks,\n\t\t\tupdateSelection = true,\n\t\t\tinitialPosition = 0,\n\t\t\tclientIdsToReplace = []\n\t\t) => {\n\t\t\tif ( ! Array.isArray( blocks ) ) {\n\t\t\t\tblocks = [ blocks ];\n\t\t\t}\n\t\t\tconst clientIds = getBlockOrder( targetRootClientId );\n\t\t\tconst clientId = clientIds[ targetBlockIndex ];\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\treplaceBlocks( clientId, blocks, undefined, initialPosition );\n\t\t\t} else if ( operation === 'group' ) {\n\t\t\t\tconst targetBlock = getBlock( clientId );\n\t\t\t\tif ( nearestSide === 'left' ) {\n\t\t\t\t\tblocks.push( targetBlock );\n\t\t\t\t} else {\n\t\t\t\t\tblocks.unshift( targetBlock );\n\t\t\t\t}\n\n\t\t\t\tconst groupInnerBlocks = blocks.map( ( block ) => {\n\t\t\t\t\treturn createBlock(\n\t\t\t\t\t\tblock.name,\n\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t);\n\t\t\t\t} );\n\n\t\t\t\tconst areAllImages = blocks.every( ( block ) => {\n\t\t\t\t\treturn block.name === 'core/image';\n\t\t\t\t} );\n\n\t\t\t\tconst galleryBlock = canInsertBlockType(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\ttargetRootClientId\n\t\t\t\t);\n\n\t\t\t\tconst wrappedBlocks = createBlock(\n\t\t\t\t\tareAllImages && galleryBlock\n\t\t\t\t\t\t? 'core/gallery'\n\t\t\t\t\t\t: getGroupingBlockName(),\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: {\n\t\t\t\t\t\t\ttype: 'flex',\n\t\t\t\t\t\t\tflexWrap:\n\t\t\t\t\t\t\t\tareAllImages && galleryBlock ? null : 'nowrap',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t\tgroupInnerBlocks\n\t\t\t\t);\n\t\t\t\t// Need to make sure both the target block and the block being dragged are replaced\n\t\t\t\t// otherwise the dragged block will be duplicated.\n\t\t\t\treplaceBlocks(\n\t\t\t\t\t[ clientId, ...clientIdsToReplace ],\n\t\t\t\t\twrappedBlocks,\n\t\t\t\t\tundefined,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tinsertBlocks(\n\t\t\t\t\tblocks,\n\t\t\t\t\ttargetBlockIndex,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tupdateSelection,\n\t\t\t\t\tinitialPosition\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tgetBlockOrder,\n\t\t\ttargetRootClientId,\n\t\t\ttargetBlockIndex,\n\t\t\toperation,\n\t\t\treplaceBlocks,\n\t\t\tgetBlock,\n\t\t\tnearestSide,\n\t\t\tcanInsertBlockType,\n\t\t\tgetGroupingBlockName,\n\t\t\tinsertBlocks,\n\t\t]\n\t);\n\n\tconst moveBlocks = useCallback(\n\t\t( sourceClientIds, sourceRootClientId, insertIndex ) => {\n\t\t\tif ( operation === 'replace' ) {\n\t\t\t\tconst sourceBlocks = getBlocksByClientId( sourceClientIds );\n\t\t\t\tconst targetBlockClientIds =\n\t\t\t\t\tgetBlockOrder( targetRootClientId );\n\t\t\t\tconst targetBlockClientId =\n\t\t\t\t\ttargetBlockClientIds[ targetBlockIndex ];\n\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\t// Remove the source blocks.\n\t\t\t\t\tremoveBlocks( sourceClientIds, false );\n\t\t\t\t\t// Replace the target block with the source blocks.\n\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\ttargetBlockClientId,\n\t\t\t\t\t\tsourceBlocks,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t0\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tmoveBlocksToPosition(\n\t\t\t\t\tsourceClientIds,\n\t\t\t\t\tsourceRootClientId,\n\t\t\t\t\ttargetRootClientId,\n\t\t\t\t\tinsertIndex\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\toperation,\n\t\t\tgetBlockOrder,\n\t\t\tgetBlocksByClientId,\n\t\t\tmoveBlocksToPosition,\n\t\t\tregistry,\n\t\t\tremoveBlocks,\n\t\t\treplaceBlocks,\n\t\t\ttargetBlockIndex,\n\t\t\ttargetRootClientId,\n\t\t]\n\t);\n\n\tconst _onDrop = onBlockDrop(\n\t\ttargetRootClientId,\n\t\ttargetBlockIndex,\n\t\tgetBlockIndex,\n\t\tgetClientIdsOfDescendants,\n\t\tmoveBlocks,\n\t\tinsertOrReplaceBlocks,\n\t\tclearSelectedBlock,\n\t\toperation,\n\t\tgetBlock\n\t);\n\tconst _onFilesDrop = onFilesDrop(\n\t\ttargetRootClientId,\n\t\tgetSettings,\n\t\tupdateBlockAttributes,\n\t\tcanInsertBlockType,\n\t\tinsertOrReplaceBlocks\n\t);\n\tconst _onHTMLDrop = onHTMLDrop( insertOrReplaceBlocks );\n\n\treturn ( event ) => {\n\t\tconst files = getFilesFromDataTransfer( event.dataTransfer );\n\t\tconst html = event.dataTransfer.getData( 'text/html' );\n\n\t\t/**\n\t\t * From Windows Chrome 96, the `event.dataTransfer` returns both file object and HTML.\n\t\t * The order of the checks is important to recognise the HTML drop.\n\t\t */\n\t\tif ( html ) {\n\t\t\t_onHTMLDrop( html );\n\t\t} else if ( files.length ) {\n\t\t\t_onFilesDrop( files );\n\t\t} else {\n\t\t\t_onDrop( event );\n\t\t}\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAOO;AACP,kBAAoD;AACpD,iBAAyC;AAKzC,mBAA0C;AAYnC,SAAS,eAAgB,OAAQ;AACvC,MAAI,SAAS;AAAA,IACZ,iBAAiB;AAAA,IACjB,cAAc;AAAA,IACd,UAAU;AAAA,IACV,MAAM;AAAA,IACN,QAAQ;AAAA,EACT;AAEA,MAAK,CAAE,MAAM,cAAe;AAC3B,WAAO;AAAA,EACR;AAEA,MAAI;AACH,aAAS,OAAO;AAAA,MACf;AAAA,MACA,KAAK,MAAO,MAAM,aAAa,QAAS,WAAY,CAAE;AAAA,IACvD;AAAA,EACD,QAAQ;AACP,WAAO;AAAA,EACR;AAEA,SAAO;AACR;AAgBO,SAAS,YACf,oBACA,kBACA,eACA,2BACA,YACA,uBACA,oBACA,WACA,UACC;AACD,SAAO,CAAE,UAAW;AACnB,UAAM;AAAA,MACL,iBAAiB;AAAA,MACjB,cAAc;AAAA,MACd,MAAM;AAAA,MACN;AAAA,IACD,IAAI,eAAgB,KAAM;AAG1B,QAAK,aAAa,YAAa;AAC9B,yBAAmB;AACnB,YAAM,iBAAiB,OAAO;AAAA,QAAK,CAAE,cACpC,0BAAY,KAAM;AAAA,MACnB;AACA,4BAAuB,gBAAgB,MAAM,IAAK;AAAA,IACnD;AAGA,QAAK,aAAa,SAAU;AAC3B,YAAM,mBAAmB,cAAe,gBAAiB,CAAE,CAAE;AAG7D,UACC,uBAAu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;AAMrD,QAAK,MAAO;AACX,kBAAa,IAAK;AAAA,IACnB,WAAY,MAAM,QAAS;AAC1B,mBAAc,KAAM;AAAA,IACrB,OAAO;AACN,cAAS,KAAM;AAAA,IAChB;AAAA,EACD;AACD;",
6
6
  "names": ["blockEditorStore", "blocksStore"]
7
7
  }
@@ -40,7 +40,7 @@ function hasSerializedBlocks(text) {
40
40
  return false;
41
41
  }
42
42
  return true;
43
- } catch (err) {
43
+ } catch {
44
44
  return false;
45
45
  }
46
46
  }
@@ -99,7 +99,7 @@ function usePasteStyles() {
99
99
  return;
100
100
  }
101
101
  html = await window.navigator.clipboard.readText();
102
- } catch (error) {
102
+ } catch {
103
103
  createErrorNotice(
104
104
  (0, import_i18n.__)(
105
105
  "Unable to paste styles. Please allow browser clipboard permissions before continuing."
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/use-paste-styles/index.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { getBlockType, parse } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\thasAlignSupport,\n\thasBorderSupport,\n\thasBackgroundColorSupport,\n\thasTextAlignSupport,\n\thasTextColorSupport,\n\thasGradientSupport,\n\thasCustomClassNameSupport,\n\thasFontFamilySupport,\n\thasFontSizeSupport,\n\thasLayoutSupport,\n\thasStyleSupport,\n} from '../../hooks/supports';\n\n/**\n * Determine if the copied text looks like serialized blocks or not.\n * Since plain text will always get parsed into a freeform block,\n * we check that if the parsed blocks is anything other than that.\n *\n * @param {string} text The copied text.\n * @return {boolean} True if the text looks like serialized blocks, false otherwise.\n */\nfunction hasSerializedBlocks( text ) {\n\ttry {\n\t\tconst blocks = parse( text, {\n\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( blocks.length === 1 && blocks[ 0 ].name === 'core/freeform' ) {\n\t\t\t// It's likely that the text is just plain text and not serialized blocks.\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t} catch ( err ) {\n\t\t// Parsing error, the text is not serialized blocks.\n\t\t// (Even though that it technically won't happen)\n\t\treturn false;\n\t}\n}\n\n/**\n * Style attributes are attributes being added in `block-editor/src/hooks/*`.\n * (Except for some unrelated to style like `anchor` or `settings`.)\n * They generally represent the default block supports.\n */\nconst STYLE_ATTRIBUTES = {\n\talign: hasAlignSupport,\n\tborderColor: ( nameOrType ) => hasBorderSupport( nameOrType, 'color' ),\n\tbackgroundColor: hasBackgroundColorSupport,\n\ttextAlign: hasTextAlignSupport,\n\ttextColor: hasTextColorSupport,\n\tgradient: hasGradientSupport,\n\tclassName: hasCustomClassNameSupport,\n\tfontFamily: hasFontFamilySupport,\n\tfontSize: hasFontSizeSupport,\n\tlayout: hasLayoutSupport,\n\tstyle: hasStyleSupport,\n};\n\n/**\n * Get the \"style attributes\" from a given block to a target block.\n *\n * @param {WPBlock} sourceBlock The source block.\n * @param {WPBlock} targetBlock The target block.\n * @return {Object} the filtered attributes object.\n */\nfunction getStyleAttributes( sourceBlock, targetBlock ) {\n\treturn Object.entries( STYLE_ATTRIBUTES ).reduce(\n\t\t( attributes, [ attributeKey, hasSupport ] ) => {\n\t\t\t// Only apply the attribute if both blocks support it.\n\t\t\tif (\n\t\t\t\thasSupport( sourceBlock.name ) &&\n\t\t\t\thasSupport( targetBlock.name )\n\t\t\t) {\n\t\t\t\t// Override attributes that are not present in the block to their defaults.\n\t\t\t\tattributes[ attributeKey ] =\n\t\t\t\t\tsourceBlock.attributes[ attributeKey ];\n\t\t\t}\n\t\t\treturn attributes;\n\t\t},\n\t\t{}\n\t);\n}\n\n/**\n * Update the target blocks with style attributes recursively.\n *\n * @param {WPBlock[]} targetBlocks The target blocks to be updated.\n * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.\n * @param {Function} updateBlockAttributes The function to update the attributes.\n */\nfunction recursivelyUpdateBlockAttributes(\n\ttargetBlocks,\n\tsourceBlocks,\n\tupdateBlockAttributes\n) {\n\tfor (\n\t\tlet index = 0;\n\t\tindex < Math.min( sourceBlocks.length, targetBlocks.length );\n\t\tindex += 1\n\t) {\n\t\tupdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].clientId,\n\t\t\tgetStyleAttributes( sourceBlocks[ index ], targetBlocks[ index ] )\n\t\t);\n\n\t\trecursivelyUpdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].innerBlocks,\n\t\t\tsourceBlocks[ index ].innerBlocks,\n\t\t\tupdateBlockAttributes\n\t\t);\n\t}\n}\n\n/**\n * A hook to return a pasteStyles event function for handling pasting styles to blocks.\n *\n * @return {Function} A function to update the styles to the blocks.\n */\nexport default function usePasteStyles() {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { createSuccessNotice, createWarningNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\treturn useCallback(\n\t\tasync ( targetBlocks ) => {\n\t\t\tlet html = '';\n\t\t\ttry {\n\t\t\t\t// `http:` sites won't have the clipboard property on navigator.\n\t\t\t\t// (with the exception of localhost.)\n\t\t\t\tif ( ! window.navigator.clipboard ) {\n\t\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thtml = await window.navigator.clipboard.readText();\n\t\t\t} catch ( error ) {\n\t\t\t\t// Possibly the permission is denied.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Unable to paste styles. Please allow browser clipboard permissions before continuing.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if the copied text is empty or doesn't look like serialized blocks.\n\t\t\tif ( ! html || ! hasSerializedBlocks( html ) ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t\"Unable to paste styles. Block styles couldn't be found within the copied content.\"\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst copiedBlocks = parse( html );\n\n\t\t\tif ( copiedBlocks.length === 1 ) {\n\t\t\t\t// Apply styles of the block to all the target blocks.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\ttargetBlocks.map( () => copiedBlocks[ 0 ] ),\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\tcopiedBlocks,\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( targetBlocks.length === 1 ) {\n\t\t\t\tconst title = getBlockType( targetBlocks[ 0 ].name )?.title;\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: %s: Name of the block being pasted, e.g. \"Paragraph\".\n\t\t\t\t\t\t__( 'Pasted styles to %s.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: %d: The number of the blocks.\n\t\t\t\t\t\t__( 'Pasted styles to %d blocks.' ),\n\t\t\t\t\t\ttargetBlocks.length\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tregistry.batch,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t\tcreateErrorNotice,\n\t\t]\n\t);\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAAoC;AACpC,kBAAyC;AACzC,qBAAsC;AACtC,kBAA4B;AAK5B,mBAA0C;AAC1C,sBAYO;AAUP,SAAS,oBAAqB,MAAO;AACpC,MAAI;AACH,UAAM,aAAS,qBAAO,MAAM;AAAA,MAC3B,6BAA6B;AAAA,MAC7B,qBAAqB;AAAA,IACtB,CAAE;AACF,QAAK,OAAO,WAAW,KAAK,OAAQ,CAAE,EAAE,SAAS,iBAAkB;AAElE,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR,SAAU,KAAM;AAGf,WAAO;AAAA,EACR;AACD;AAOA,IAAM,mBAAmB;AAAA,EACxB,OAAO;AAAA,EACP,aAAa,CAAE,mBAAgB,kCAAkB,YAAY,OAAQ;AAAA,EACrE,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AACR;AASA,SAAS,mBAAoB,aAAa,aAAc;AACvD,SAAO,OAAO,QAAS,gBAAiB,EAAE;AAAA,IACzC,CAAE,YAAY,CAAE,cAAc,UAAW,MAAO;AAE/C,UACC,WAAY,YAAY,IAAK,KAC7B,WAAY,YAAY,IAAK,GAC5B;AAED,mBAAY,Y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YACA,aAAa,IAAK,MAAM,aAAc,CAAE,CAAE;AAAA,YAC1C;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH,OAAO;AACN,iBAAS,MAAO,MAAM;AACrB;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAEA,UAAK,aAAa,WAAW,GAAI;AAChC,cAAM,YAAQ,4BAAc,aAAc,CAAE,EAAE,IAAK,GAAG;AACtD;AAAA,cACC;AAAA;AAAA,gBAEC,gBAAI,sBAAuB;AAAA,YAC3B;AAAA,UACD;AAAA,UACA,EAAE,MAAM,WAAW;AAAA,QACpB;AAAA,MACD,OAAO;AACN;AAAA,cACC;AAAA;AAAA,gBAEC,gBAAI,6BAA8B;AAAA,YAClC,aAAa;AAAA,UACd;AAAA,UACA,EAAE,MAAM,WAAW;AAAA,QACpB;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { getBlockType, parse } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\thasAlignSupport,\n\thasBorderSupport,\n\thasBackgroundColorSupport,\n\thasTextAlignSupport,\n\thasTextColorSupport,\n\thasGradientSupport,\n\thasCustomClassNameSupport,\n\thasFontFamilySupport,\n\thasFontSizeSupport,\n\thasLayoutSupport,\n\thasStyleSupport,\n} from '../../hooks/supports';\n\n/**\n * Determine if the copied text looks like serialized blocks or not.\n * Since plain text will always get parsed into a freeform block,\n * we check that if the parsed blocks is anything other than that.\n *\n * @param {string} text The copied text.\n * @return {boolean} True if the text looks like serialized blocks, false otherwise.\n */\nfunction hasSerializedBlocks( text ) {\n\ttry {\n\t\tconst blocks = parse( text, {\n\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( blocks.length === 1 && blocks[ 0 ].name === 'core/freeform' ) {\n\t\t\t// It's likely that the text is just plain text and not serialized blocks.\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t} catch {\n\t\t// Parsing error, the text is not serialized blocks.\n\t\t// (Even though that it technically won't happen)\n\t\treturn false;\n\t}\n}\n\n/**\n * Style attributes are attributes being added in `block-editor/src/hooks/*`.\n * (Except for some unrelated to style like `anchor` or `settings`.)\n * They generally represent the default block supports.\n */\nconst STYLE_ATTRIBUTES = {\n\talign: hasAlignSupport,\n\tborderColor: ( nameOrType ) => hasBorderSupport( nameOrType, 'color' ),\n\tbackgroundColor: hasBackgroundColorSupport,\n\ttextAlign: hasTextAlignSupport,\n\ttextColor: hasTextColorSupport,\n\tgradient: hasGradientSupport,\n\tclassName: hasCustomClassNameSupport,\n\tfontFamily: hasFontFamilySupport,\n\tfontSize: hasFontSizeSupport,\n\tlayout: hasLayoutSupport,\n\tstyle: hasStyleSupport,\n};\n\n/**\n * Get the \"style attributes\" from a given block to a target block.\n *\n * @param {WPBlock} sourceBlock The source block.\n * @param {WPBlock} targetBlock The target block.\n * @return {Object} the filtered attributes object.\n */\nfunction getStyleAttributes( sourceBlock, targetBlock ) {\n\treturn Object.entries( STYLE_ATTRIBUTES ).reduce(\n\t\t( attributes, [ attributeKey, hasSupport ] ) => {\n\t\t\t// Only apply the attribute if both blocks support it.\n\t\t\tif (\n\t\t\t\thasSupport( sourceBlock.name ) &&\n\t\t\t\thasSupport( targetBlock.name )\n\t\t\t) {\n\t\t\t\t// Override attributes that are not present in the block to their defaults.\n\t\t\t\tattributes[ attributeKey ] =\n\t\t\t\t\tsourceBlock.attributes[ attributeKey ];\n\t\t\t}\n\t\t\treturn attributes;\n\t\t},\n\t\t{}\n\t);\n}\n\n/**\n * Update the target blocks with style attributes recursively.\n *\n * @param {WPBlock[]} targetBlocks The target blocks to be updated.\n * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.\n * @param {Function} updateBlockAttributes The function to update the attributes.\n */\nfunction recursivelyUpdateBlockAttributes(\n\ttargetBlocks,\n\tsourceBlocks,\n\tupdateBlockAttributes\n) {\n\tfor (\n\t\tlet index = 0;\n\t\tindex < Math.min( sourceBlocks.length, targetBlocks.length );\n\t\tindex += 1\n\t) {\n\t\tupdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].clientId,\n\t\t\tgetStyleAttributes( sourceBlocks[ index ], targetBlocks[ index ] )\n\t\t);\n\n\t\trecursivelyUpdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].innerBlocks,\n\t\t\tsourceBlocks[ index ].innerBlocks,\n\t\t\tupdateBlockAttributes\n\t\t);\n\t}\n}\n\n/**\n * A hook to return a pasteStyles event function for handling pasting styles to blocks.\n *\n * @return {Function} A function to update the styles to the blocks.\n */\nexport default function usePasteStyles() {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { createSuccessNotice, createWarningNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\treturn useCallback(\n\t\tasync ( targetBlocks ) => {\n\t\t\tlet html = '';\n\t\t\ttry {\n\t\t\t\t// `http:` sites won't have the clipboard property on navigator.\n\t\t\t\t// (with the exception of localhost.)\n\t\t\t\tif ( ! window.navigator.clipboard ) {\n\t\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thtml = await window.navigator.clipboard.readText();\n\t\t\t} catch {\n\t\t\t\t// Possibly the permission is denied.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Unable to paste styles. Please allow browser clipboard permissions before continuing.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if the copied text is empty or doesn't look like serialized blocks.\n\t\t\tif ( ! html || ! hasSerializedBlocks( html ) ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t\"Unable to paste styles. Block styles couldn't be found within the copied content.\"\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst copiedBlocks = parse( html );\n\n\t\t\tif ( copiedBlocks.length === 1 ) {\n\t\t\t\t// Apply styles of the block to all the target blocks.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\ttargetBlocks.map( () => copiedBlocks[ 0 ] ),\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\tcopiedBlocks,\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( targetBlocks.length === 1 ) {\n\t\t\t\tconst title = getBlockType( targetBlocks[ 0 ].name )?.title;\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: %s: Name of the block being pasted, e.g. \"Paragraph\".\n\t\t\t\t\t\t__( 'Pasted styles to %s.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: %d: The number of the blocks.\n\t\t\t\t\t\t__( 'Pasted styles to %d blocks.' ),\n\t\t\t\t\t\ttargetBlocks.length\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tregistry.batch,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t\tcreateErrorNotice,\n\t\t]\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA4B;AAC5B,oBAAoC;AACpC,kBAAyC;AACzC,qBAAsC;AACtC,kBAA4B;AAK5B,mBAA0C;AAC1C,sBAYO;AAUP,SAAS,oBAAqB,MAAO;AACpC,MAAI;AACH,UAAM,aAAS,qBAAO,MAAM;AAAA,MAC3B,6BAA6B;AAAA,MAC7B,qBAAqB;AAAA,IACtB,CAAE;AACF,QAAK,OAAO,WAAW,KAAK,OAAQ,CAAE,EAAE,SAAS,iBAAkB;AAElE,aAAO;AAAA,IACR;AACA,WAAO;AAAA,EACR,QAAQ;AAGP,WAAO;AAAA,EACR;AACD;AAOA,IAAM,mBAAmB;AAAA,EACxB,OAAO;AAAA,EACP,aAAa,CAAE,mBAAgB,kCAAkB,YAAY,OAAQ;AAAA,EACrE,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,OAAO;AACR;AASA,SAAS,mBAAoB,aAAa,aAAc;AACvD,SAAO,OAAO,QAAS,gBAAiB,EAAE;AAAA,IACzC,CAAE,YAAY,CAAE,cAAc,UAAW,MAAO;AAE/C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,WAAW,GAAI;AAEhC,iBAAS,MAAO,MAAM;AACrB;AAAA,YACC;AAAA,YACA,aAAa,IAAK,MAAM,aAAc,CAAE,CAAE;AAAA,YAC1C;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH,OAAO;AACN,iBAAS,MAAO,MAAM;AACrB;AAAA,YACC;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,QACD,CAAE;AAAA,MACH;AAEA,UAAK,aAAa,WAAW,GAAI;AAChC,cAAM,YAAQ,4BAAc,aAAc,CAAE,EAAE,IAAK,GAAG;AACtD;AAAA,cACC;AAAA;AAAA,gBAEC,gBAAI,sBAAuB;AAAA,YAC3B;AAAA,UACD;AAAA,UACA,EAAE,MAAM,WAAW;AAAA,QACpB;AAAA,MACD,OAAO;AACN;AAAA,cACC;AAAA;AAAA,gBAEC,gBAAI,6BAA8B;AAAA,YAClC,aAAa;AAAA,UACd;AAAA,UACA,EAAE,MAAM,WAAW;AAAA,QACpB;AAAA,MACD;AAAA,IACD;AAAA,IACA;AAAA,MACC,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACD;",
6
6
  "names": ["blockEditorStore", "noticesStore"]
7
7
  }
@@ -39,6 +39,7 @@ __export(background_exports, {
39
39
  setBackgroundStyleDefaults: () => setBackgroundStyleDefaults
40
40
  });
41
41
  module.exports = __toCommonJS(background_exports);
42
+ var import_clsx = __toESM(require("clsx"));
42
43
  var import_blocks = require("@wordpress/blocks");
43
44
  var import_data = require("@wordpress/data");
44
45
  var import_element = require("@wordpress/element");
@@ -60,7 +61,7 @@ function hasBackgroundSupport(blockName, feature = "any") {
60
61
  return true;
61
62
  }
62
63
  if (feature === "any") {
63
- return !!support?.backgroundImage || !!support?.backgroundSize || !!support?.backgroundRepeat;
64
+ return !!support?.backgroundImage || !!support?.backgroundSize || !!support?.backgroundRepeat || !!support?.gradient;
64
65
  }
65
66
  return !!support?.[feature];
66
67
  }
@@ -96,18 +97,32 @@ function useBlockProps({ name, style }) {
96
97
  };
97
98
  }
98
99
  function getBackgroundImageClasses(style) {
99
- return (0, import_background_panel.hasBackgroundImageValue)(style) ? "has-background" : "";
100
+ return (0, import_background_panel.hasBackgroundImageValue)(style) || (0, import_background_panel.hasBackgroundGradientValue)(style) ? "has-background" : "";
100
101
  }
101
- function BackgroundInspectorControl({ children }) {
102
- const resetAllFilter = (0, import_element.useCallback)((attributes) => {
103
- return {
104
- ...attributes,
105
- style: {
106
- ...attributes.style,
107
- background: void 0
108
- }
109
- };
110
- }, []);
102
+ function BackgroundInspectorControl({
103
+ children,
104
+ backgroundGradientSupported = false
105
+ }) {
106
+ const resetAllFilter = (0, import_element.useCallback)(
107
+ (attributes) => {
108
+ const updatedClassName = attributes.className?.includes(
109
+ "has-background"
110
+ ) ? attributes.className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0 : attributes.className;
111
+ return {
112
+ ...attributes,
113
+ className: updatedClassName,
114
+ style: (0, import_utils.cleanEmptyObject)({
115
+ ...attributes.style,
116
+ background: void 0,
117
+ color: backgroundGradientSupported ? {
118
+ ...attributes.style?.color,
119
+ gradient: void 0
120
+ } : attributes.style?.color
121
+ })
122
+ };
123
+ },
124
+ [backgroundGradientSupported]
125
+ );
111
126
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inspector_controls.default, { group: "background", resetAllFilter, children });
112
127
  }
113
128
  function BackgroundImagePanel({
@@ -116,12 +131,14 @@ function BackgroundImagePanel({
116
131
  setAttributes,
117
132
  settings
118
133
  }) {
119
- const { style, inheritedValue } = (0, import_data.useSelect)(
134
+ const { style, className, inheritedValue } = (0, import_data.useSelect)(
120
135
  (select) => {
121
136
  const { getBlockAttributes, getSettings } = select(import_store.store);
122
137
  const _settings = getSettings();
138
+ const blockAttributes = getBlockAttributes(clientId);
123
139
  return {
124
- style: getBlockAttributes(clientId)?.style,
140
+ style: blockAttributes?.style,
141
+ className: blockAttributes?.className,
125
142
  /*
126
143
  * To ensure we pass down the right inherited values:
127
144
  * @TODO 1. Pass inherited value down to all block style controls,
@@ -134,14 +151,50 @@ function BackgroundImagePanel({
134
151
  },
135
152
  [clientId, name]
136
153
  );
137
- if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name, "backgroundImage")) {
154
+ const backgroundGradientSupported = hasBackgroundSupport(
155
+ name,
156
+ "gradient"
157
+ );
158
+ const as = (0, import_element.useCallback)(
159
+ ({ children }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
160
+ BackgroundInspectorControl,
161
+ {
162
+ backgroundGradientSupported,
163
+ children
164
+ }
165
+ ),
166
+ [backgroundGradientSupported]
167
+ );
168
+ if (!(0, import_background_panel.useHasBackgroundPanel)(settings) || !hasBackgroundSupport(name)) {
138
169
  return null;
139
170
  }
140
171
  const onChange = (newStyle) => {
141
- setAttributes({
142
- style: (0, import_utils.cleanEmptyObject)(newStyle)
143
- });
172
+ const isMigrating = backgroundGradientSupported && !!style?.color?.gradient;
173
+ const newAttributes = {
174
+ style: (0, import_utils.cleanEmptyObject)(
175
+ backgroundGradientSupported ? {
176
+ ...newStyle,
177
+ color: {
178
+ ...newStyle?.color,
179
+ gradient: void 0
180
+ }
181
+ } : newStyle
182
+ )
183
+ };
184
+ if (isMigrating && !!newStyle?.background?.gradient) {
185
+ newAttributes.className = (0, import_clsx.default)(className, "has-background");
186
+ } else if (!newStyle?.background?.gradient && className?.includes("has-background")) {
187
+ newAttributes.className = className.split(" ").filter((c) => c !== "has-background").join(" ") || void 0;
188
+ }
189
+ setAttributes(newAttributes);
144
190
  };
191
+ const styleValue = backgroundGradientSupported && !style?.background?.gradient && style?.color?.gradient ? {
192
+ ...style,
193
+ background: {
194
+ ...style?.background,
195
+ gradient: style?.color?.gradient
196
+ }
197
+ } : style;
145
198
  const updatedSettings = {
146
199
  ...settings,
147
200
  background: {
@@ -151,19 +204,19 @@ function BackgroundImagePanel({
151
204
  };
152
205
  const defaultControls = (0, import_blocks.getBlockSupport)(name, [
153
206
  BACKGROUND_SUPPORT_KEY,
154
- "defaultControls"
207
+ "__experimentalDefaultControls"
155
208
  ]);
156
209
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
157
210
  import_background_panel.default,
158
211
  {
159
212
  inheritedValue,
160
- as: BackgroundInspectorControl,
213
+ as,
161
214
  panelId: clientId,
162
215
  defaultValues: BACKGROUND_BLOCK_DEFAULT_VALUES,
163
216
  settings: updatedSettings,
164
217
  onChange,
165
218
  defaultControls,
166
- value: style
219
+ value: styleValue
167
220
  }
168
221
  );
169
222
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/background.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ? 'has-background' : '';\n}\n\nfunction BackgroundInspectorControl( { children } ) {\n\tconst resetAllFilter = useCallback( ( attributes ) => {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tstyle: {\n\t\t\t\t...attributes.style,\n\t\t\t\tbackground: undefined,\n\t\t\t},\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst { style, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name, 'backgroundImage' )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( newStyle ),\n\t\t} );\n\t};\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'defaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ BackgroundInspectorControl }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n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AY,kBACtB,qBAAsB,MAAM,gBAAiB;AAAA,IAC/C;AAAA,EACD;AAEA,QAAM,sBAAkB,+BAAiB,MAAM;AAAA,IAC9C;AAAA,IACA;AAAA,EACD,CAAE;AAEF,SACC;AAAA,IAAC,wBAAAC;AAAA,IAAA;AAAA,MACA;AAAA,MACA,IAAK;AAAA,MACL,SAAU;AAAA,MACV,eAAgB;AAAA,MAChB,UAAW;AAAA,MACX;AAAA,MACA;AAAA,MACA,OAAQ;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
6
- "names": ["InspectorControls", "blockEditorStore", "StylesBackgroundPanel"]
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport { cleanEmptyObject } from './utils';\nimport { store as blockEditorStore } from '../store';\nimport {\n\tdefault as StylesBackgroundPanel,\n\tuseHasBackgroundPanel,\n\thasBackgroundImageValue,\n\thasBackgroundGradientValue,\n} from '../components/global-styles/background-panel';\nimport { globalStylesDataKey } from '../store/private-keys';\n\nexport const BACKGROUND_SUPPORT_KEY = 'background';\n\n// Initial control values.\nexport const BACKGROUND_BLOCK_DEFAULT_VALUES = {\n\tbackgroundSize: 'cover',\n\tbackgroundPosition: '50% 50%', // used only when backgroundSize is 'contain'.\n};\n\n/**\n * Determine whether there is block support for background.\n *\n * @param {string} blockName Block name.\n * @param {string} feature Background image feature to check for.\n *\n * @return {boolean} Whether there is support.\n */\nexport function hasBackgroundSupport( blockName, feature = 'any' ) {\n\tconst support = getBlockSupport( blockName, BACKGROUND_SUPPORT_KEY );\n\n\tif ( support === true ) {\n\t\treturn true;\n\t}\n\n\tif ( feature === 'any' ) {\n\t\treturn (\n\t\t\t!! support?.backgroundImage ||\n\t\t\t!! support?.backgroundSize ||\n\t\t\t!! support?.backgroundRepeat ||\n\t\t\t!! support?.gradient\n\t\t);\n\t}\n\n\treturn !! support?.[ feature ];\n}\n\nexport function setBackgroundStyleDefaults( backgroundStyle ) {\n\tif ( ! backgroundStyle || ! backgroundStyle?.backgroundImage?.url ) {\n\t\treturn;\n\t}\n\n\tlet backgroundStylesWithDefaults;\n\n\t// Set block background defaults.\n\tif ( ! backgroundStyle?.backgroundSize ) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundSize: BACKGROUND_BLOCK_DEFAULT_VALUES.backgroundSize,\n\t\t};\n\t}\n\n\tif (\n\t\t'contain' === backgroundStyle?.backgroundSize &&\n\t\t! backgroundStyle?.backgroundPosition\n\t) {\n\t\tbackgroundStylesWithDefaults = {\n\t\t\tbackgroundPosition:\n\t\t\t\tBACKGROUND_BLOCK_DEFAULT_VALUES.backgroundPosition,\n\t\t};\n\t}\n\treturn backgroundStylesWithDefaults;\n}\n\nfunction useBlockProps( { name, style } ) {\n\tif (\n\t\t! hasBackgroundSupport( name ) ||\n\t\t! style?.background?.backgroundImage\n\t) {\n\t\treturn;\n\t}\n\n\tconst backgroundStyles = setBackgroundStyleDefaults( style?.background );\n\n\tif ( ! backgroundStyles ) {\n\t\treturn;\n\t}\n\n\treturn {\n\t\tstyle: {\n\t\t\t...backgroundStyles,\n\t\t},\n\t};\n}\n\n/**\n * Generates a CSS class name if an background image is set.\n *\n * @param {Object} style A block's style attribute.\n *\n * @return {string} CSS class name.\n */\nexport function getBackgroundImageClasses( style ) {\n\treturn hasBackgroundImageValue( style ) ||\n\t\thasBackgroundGradientValue( style )\n\t\t? 'has-background'\n\t\t: '';\n}\n\nfunction BackgroundInspectorControl( {\n\tchildren,\n\tbackgroundGradientSupported = false,\n} ) {\n\tconst resetAllFilter = useCallback(\n\t\t( attributes ) => {\n\t\t\tconst updatedClassName = attributes.className?.includes(\n\t\t\t\t'has-background'\n\t\t\t)\n\t\t\t\t? attributes.className\n\t\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t\t.join( ' ' ) || undefined\n\t\t\t\t: attributes.className;\n\t\t\treturn {\n\t\t\t\t...attributes,\n\t\t\t\tclassName: updatedClassName,\n\t\t\t\tstyle: cleanEmptyObject( {\n\t\t\t\t\t...attributes.style,\n\t\t\t\t\tbackground: undefined,\n\t\t\t\t\tcolor: backgroundGradientSupported\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t...attributes.style?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t }\n\t\t\t\t\t\t: attributes.style?.color,\n\t\t\t\t} ),\n\t\t\t};\n\t\t},\n\t\t[ backgroundGradientSupported ]\n\t);\n\treturn (\n\t\t<InspectorControls group=\"background\" resetAllFilter={ resetAllFilter }>\n\t\t\t{ children }\n\t\t</InspectorControls>\n\t);\n}\n\nexport function BackgroundImagePanel( {\n\tclientId,\n\tname,\n\tsetAttributes,\n\tsettings,\n} ) {\n\tconst { style, className, inheritedValue } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst _settings = getSettings();\n\t\t\tconst blockAttributes = getBlockAttributes( clientId );\n\t\t\treturn {\n\t\t\t\tstyle: blockAttributes?.style,\n\t\t\t\tclassName: blockAttributes?.className,\n\t\t\t\t/*\n\t\t\t\t * To ensure we pass down the right inherited values:\n\t\t\t\t * @TODO 1. Pass inherited value down to all block style controls,\n\t\t\t\t * See: packages/block-editor/src/hooks/style.js\n\t\t\t\t * @TODO 2. Add support for block style variations,\n\t\t\t\t * See implementation: packages/block-editor/src/hooks/block-style-variation.js\n\t\t\t\t */\n\t\t\t\tinheritedValue:\n\t\t\t\t\t_settings[ globalStylesDataKey ]?.blocks?.[ name ],\n\t\t\t};\n\t\t},\n\t\t[ clientId, name ]\n\t);\n\n\tconst backgroundGradientSupported = hasBackgroundSupport(\n\t\tname,\n\t\t'gradient'\n\t);\n\n\t// Must be declared before the early return to follow Rules of Hooks.\n\t// Passes backgroundGradientSupported so that \"Reset All\" also clears\n\t// the legacy color.gradient value when background.gradient is supported.\n\tconst as = useCallback(\n\t\t( { children } ) => (\n\t\t\t<BackgroundInspectorControl\n\t\t\t\tbackgroundGradientSupported={ backgroundGradientSupported }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</BackgroundInspectorControl>\n\t\t),\n\t\t[ backgroundGradientSupported ]\n\t);\n\n\tif (\n\t\t! useHasBackgroundPanel( settings ) ||\n\t\t! hasBackgroundSupport( name )\n\t) {\n\t\treturn null;\n\t}\n\n\tconst onChange = ( newStyle ) => {\n\t\tconst isMigrating =\n\t\t\tbackgroundGradientSupported && !! style?.color?.gradient;\n\t\tconst newAttributes = {\n\t\t\tstyle: cleanEmptyObject(\n\t\t\t\tbackgroundGradientSupported\n\t\t\t\t\t? {\n\t\t\t\t\t\t\t...newStyle,\n\t\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\t\t...newStyle?.color,\n\t\t\t\t\t\t\t\tgradient: undefined,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t }\n\t\t\t\t\t: newStyle\n\t\t\t),\n\t\t};\n\n\t\t// When migrating from color.gradient to background.gradient, preserve\n\t\t// the has-background class so existing styles relying on it (e.g.\n\t\t// theme padding) are not silently broken. Only add the class when a\n\t\t// gradient value is being set \u2014 not when it is being cleared/reset.\n\t\t// Conversely, if the gradient is cleared and has-background was added\n\t\t// during a previous migration, remove it so it does not linger.\n\t\tif ( isMigrating && !! newStyle?.background?.gradient ) {\n\t\t\tnewAttributes.className = clsx( className, 'has-background' );\n\t\t} else if (\n\t\t\t! newStyle?.background?.gradient &&\n\t\t\tclassName?.includes( 'has-background' )\n\t\t) {\n\t\t\tnewAttributes.className =\n\t\t\t\tclassName\n\t\t\t\t\t.split( ' ' )\n\t\t\t\t\t.filter( ( c ) => c !== 'has-background' )\n\t\t\t\t\t.join( ' ' ) || undefined;\n\t\t}\n\n\t\tsetAttributes( newAttributes );\n\t};\n\n\t// When background.gradient is supported but not yet explicitly set, fall\n\t// back to color.gradient for display. Any write from this panel migrates\n\t// the value to background.gradient and clears color.gradient atomically.\n\tconst styleValue =\n\t\tbackgroundGradientSupported &&\n\t\t! style?.background?.gradient &&\n\t\tstyle?.color?.gradient\n\t\t\t? {\n\t\t\t\t\t...style,\n\t\t\t\t\tbackground: {\n\t\t\t\t\t\t...style?.background,\n\t\t\t\t\t\tgradient: style?.color?.gradient,\n\t\t\t\t\t},\n\t\t\t }\n\t\t\t: style;\n\n\tconst updatedSettings = {\n\t\t...settings,\n\t\tbackground: {\n\t\t\t...settings.background,\n\t\t\tbackgroundSize:\n\t\t\t\tsettings?.background?.backgroundSize &&\n\t\t\t\thasBackgroundSupport( name, 'backgroundSize' ),\n\t\t},\n\t};\n\n\tconst defaultControls = getBlockSupport( name, [\n\t\tBACKGROUND_SUPPORT_KEY,\n\t\t'__experimentalDefaultControls',\n\t] );\n\n\treturn (\n\t\t<StylesBackgroundPanel\n\t\t\tinheritedValue={ inheritedValue }\n\t\t\tas={ as }\n\t\t\tpanelId={ clientId }\n\t\t\tdefaultValues={ BACKGROUND_BLOCK_DEFAULT_VALUES }\n\t\t\tsettings={ updatedSettings }\n\t\t\tonChange={ onChange }\n\t\t\tdefaultControls={ defaultControls }\n\t\t\tvalue={ styleValue }\n\t\t/>\n\t);\n}\n\nexport default {\n\tuseBlockProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport: hasBackgroundSupport,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,oBAAgC;AAChC,kBAA0B;AAC1B,qBAA4B;AAK5B,gCAA8B;AAC9B,mBAAiC;AACjC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,MACA;AAAA,MACA,OAAQ;AAAA;AAAA,EACT;AAEF;AAEA,IAAO,qBAAQ;AAAA,EACd;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,YAAY;AACb;",
6
+ "names": ["InspectorControls", "blockEditorStore", "clsx", "StylesBackgroundPanel"]
7
7
  }
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // packages/block-editor/src/hooks/block-style-variation.js
21
21
  var block_style_variation_exports = {};
22
22
  __export(block_style_variation_exports, {
23
- __unstableBlockStyleVariationOverridesWithConfig: () => __unstableBlockStyleVariationOverridesWithConfig,
23
+ BlockStyleVariationOverridesWithConfig: () => BlockStyleVariationOverridesWithConfig,
24
24
  default: () => block_style_variation_default,
25
25
  getVariationNameFromClass: () => getVariationNameFromClass,
26
26
  getVariationStylesWithRefValues: () => getVariationStylesWithRefValues
@@ -66,10 +66,9 @@ function getVariationNameFromClass(className, registeredStyles = []) {
66
66
  function OverrideStyles({ override }) {
67
67
  (0, import_utils.usePrivateStyleOverride)(override);
68
68
  }
69
- function __unstableBlockStyleVariationOverridesWithConfig({ config }) {
70
- const { getBlockStyles, overrides } = (0, import_data.useSelect)(
69
+ function BlockStyleVariationOverridesWithConfig({ config }) {
70
+ const { overrides } = (0, import_data.useSelect)(
71
71
  (select) => ({
72
- getBlockStyles: select(import_blocks.store).getBlockStyles,
73
72
  overrides: (0, import_lock_unlock.unlock)(select(import_store.store)).getStyleOverrides()
74
73
  }),
75
74
  []
@@ -145,7 +144,7 @@ function __unstableBlockStyleVariationOverridesWithConfig({ config }) {
145
144
  }
146
145
  }
147
146
  return newOverrides;
148
- }, [config, overrides, getBlockStyles, getBlockName]);
147
+ }, [config, overrides, getBlockName]);
149
148
  if (!overridesWithConfig || !overridesWithConfig.length) {
150
149
  return null;
151
150
  }
@@ -282,7 +281,7 @@ var block_style_variation_default = {
282
281
  };
283
282
  // Annotate the CommonJS export names for ESM import in node:
284
283
  0 && (module.exports = {
285
- __unstableBlockStyleVariationOverridesWithConfig,
284
+ BlockStyleVariationOverridesWithConfig,
286
285
  getVariationNameFromClass,
287
286
  getVariationStylesWithRefValues
288
287
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/block-style-variation.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { toStyles, getBlockSelectors } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { usePrivateStyleOverride } from './utils';\nimport { getValueFromObjectPath } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nexport function getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\n// A helper component to apply a style override using the useStyleOverride hook.\nfunction OverrideStyles( { override } ) {\n\tusePrivateStyleOverride( override );\n}\n\n/**\n * This component is used to generate new block style variation overrides\n * based on an incoming theme config. If a matching style is found in the config,\n * a new override is created and returned. The overrides can be used in conjunction with\n * useStyleOverride to apply the new styles to the editor. Its use is\n * subject to change.\n *\n * @param {Object} props Props.\n * @param {Object} props.config A global styles object, containing settings and styles.\n * @return {React.JSX.Element} An array of new block variation overrides.\n */\nexport function __unstableBlockStyleVariationOverridesWithConfig( { config } ) {\n\tconst { getBlockStyles, overrides } = useSelect(\n\t\t( select ) => ( {\n\t\t\tgetBlockStyles: select( blocksStore ).getBlockStyles,\n\t\t\toverrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\n\tconst overridesWithConfig = useMemo( () => {\n\t\tif ( ! overrides?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newOverrides = [];\n\t\tconst overriddenClientIds = [];\n\t\tfor ( const [ , override ] of overrides ) {\n\t\t\tif (\n\t\t\t\toverride?.variation &&\n\t\t\t\toverride?.clientId &&\n\t\t\t\t/*\n\t\t\t\t * Because this component overwrites existing style overrides,\n\t\t\t\t * filter out any overrides that are already present in the store.\n\t\t\t\t */\n\t\t\t\t! overriddenClientIds.includes( override.clientId )\n\t\t\t) {\n\t\t\t\tconst blockName = getBlockName( override.clientId );\n\t\t\t\tconst configStyles =\n\t\t\t\t\tconfig?.styles?.blocks?.[ blockName ]?.variations?.[\n\t\t\t\t\t\toverride.variation\n\t\t\t\t\t];\n\t\t\t\tif ( configStyles ) {\n\t\t\t\t\tconst variationConfig = {\n\t\t\t\t\t\tsettings: config?.settings,\n\t\t\t\t\t\t// The variation style data is all that is needed to generate\n\t\t\t\t\t\t// the styles for the current application to a block. The variation\n\t\t\t\t\t\t// name is updated to match the instance specific class name.\n\t\t\t\t\t\tstyles: {\n\t\t\t\t\t\t\tblocks: {\n\t\t\t\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t\t\t\t[ `${ override.variation }-${ override.clientId }` ]:\n\t\t\t\t\t\t\t\t\t\t\tconfigStyles,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst blockSelectors = getBlockSelectors(\n\t\t\t\t\t\tgetBlockTypes(),\n\t\t\t\t\t\toverride.clientId\n\t\t\t\t\t);\n\t\t\t\t\tconst hasBlockGapSupport = false;\n\t\t\t\t\tconst hasFallbackGapSupport = true;\n\t\t\t\t\tconst disableLayoutStyles = true;\n\t\t\t\t\tconst disableRootPadding = true;\n\t\t\t\t\tconst variationStyles = toStyles(\n\t\t\t\t\t\tvariationConfig,\n\t\t\t\t\t\tblockSelectors,\n\t\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\t\tdisableLayoutStyles,\n\t\t\t\t\t\tdisableRootPadding,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tblockGap: false,\n\t\t\t\t\t\t\tblockStyles: true,\n\t\t\t\t\t\t\tlayoutStyles: false,\n\t\t\t\t\t\t\tmarginReset: false,\n\t\t\t\t\t\t\tpresets: false,\n\t\t\t\t\t\t\trootPadding: false,\n\t\t\t\t\t\t\tvariationStyles: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tnewOverrides.push( {\n\t\t\t\t\t\tid: `${ override.variation }-${ override.clientId }`,\n\t\t\t\t\t\tcss: variationStyles,\n\t\t\t\t\t\t__unstableType: 'variation',\n\t\t\t\t\t\tvariation: override.variation,\n\t\t\t\t\t\t// The clientId will be stored with the override and used to ensure\n\t\t\t\t\t\t// the order of overrides matches the order of blocks so that the\n\t\t\t\t\t\t// correct CSS cascade is maintained.\n\t\t\t\t\t\tclientId: override.clientId,\n\t\t\t\t\t} );\n\t\t\t\t\toverriddenClientIds.push( override.clientId );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newOverrides;\n\t}, [ config, overrides, getBlockStyles, getBlockName ] );\n\n\tif ( ! overridesWithConfig || ! overridesWithConfig.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ overridesWithConfig.map( ( override ) => (\n\t\t\t\t<OverrideStyles key={ override.id } override={ override } />\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\n/**\n * Retrieves any variation styles data and resolves any referenced values.\n *\n * @param {Object} globalStyles A complete global styles object, containing settings and styles.\n * @param {string} name The name of the desired block type.\n * @param {variation} variation The of the block style variation to retrieve data for.\n *\n * @return {Object|undefined} The global styles data for the specified variation.\n */\nexport function getVariationStylesWithRefValues(\n\tglobalStyles,\n\tname,\n\tvariation\n) {\n\tif ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {\n\t\treturn;\n\t}\n\n\t// Helper to recursively look for `ref` values to resolve.\n\tconst replaceRefs = ( variationStyles ) => {\n\t\tObject.keys( variationStyles ).forEach( ( key ) => {\n\t\t\tconst value = variationStyles[ key ];\n\n\t\t\t// Only process objects.\n\t\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\t\t// Process `ref` value if present.\n\t\t\t\tif ( value.ref !== undefined ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value.ref !== 'string' ||\n\t\t\t\t\t\tvalue.ref.trim() === ''\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Remove invalid ref.\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Resolve `ref` value.\n\t\t\t\t\t\tconst refValue = getValueFromObjectPath(\n\t\t\t\t\t\t\tglobalStyles,\n\t\t\t\t\t\t\tvalue.ref\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( refValue ) {\n\t\t\t\t\t\t\tvariationStyles[ key ] = refValue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Recursively resolve `ref` values in nested objects.\n\t\t\t\t\treplaceRefs( value );\n\n\t\t\t\t\t// After recursion, if value is empty due to explicitly\n\t\t\t\t\t// `undefined` ref value, remove it.\n\t\t\t\t\tif ( Object.keys( value ).length === 0 ) {\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Deep clone variation node to avoid mutating it within global styles and losing refs.\n\tconst styles = JSON.parse(\n\t\tJSON.stringify(\n\t\t\tglobalStyles.styles.blocks[ name ].variations[ variation ]\n\t\t)\n\t);\n\treplaceRefs( styles );\n\n\treturn styles;\n}\n\nfunction useBlockStyleVariation( name, variation, clientId ) {\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst variationStyles = getVariationStylesWithRefValues(\n\t\t\t{\n\t\t\t\tsettings: globalSettings,\n\t\t\t\tstyles: globalStyles,\n\t\t\t},\n\t\t\tname,\n\t\t\tvariation\n\t\t);\n\n\t\treturn {\n\t\t\tsettings: globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [ globalSettings, globalStyles, variation, clientId, name ] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockStyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors( getBlockTypes(), clientId );\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, clientId ] );\n\n\tusePrivateStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\tvariation,\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlock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;AAC3B,UAAM,wBAAwB;AAC9B,UAAM,sBAAsB;AAC5B,UAAM,qBAAqB;AAE3B,eAAO;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACC,UAAU;AAAA,QACV,aAAa;AAAA,QACb,cAAc;AAAA,QACd,aAAa;AAAA,QACb,SAAS;AAAA,QACT,aAAa;AAAA,QACb,iBAAiB;AAAA,MAClB;AAAA,IACD;AAAA,EACD,GAAG,CAAE,WAAW,UAAU,QAAQ,QAAS,CAAE;AAE7C,4CAAyB;AAAA,IACxB,IAAI,aAAc,QAAS;AAAA,IAC3B,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB;AAAA;AAAA;AAAA;AAAA,IAIA;AAAA,EACD,CAAE;AAEF,SAAO,YAAY,EAAE,WAAW,eAAe,IAAI,CAAC;AACrD;AAEA,IAAO,gCAAQ;AAAA,EACd,YAAY,MAAM;AAAA,EAClB,eAAe,CAAE,WAAY;AAAA,EAC7B,SAAS,CAAE,EAAE,UAAU,MAAO,oBAAqB,SAAU,EAAE,SAAS;AAAA,EACxE;AACD;",
6
- "names": ["blocksStore", "blockEditorStore"]
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { getBlockTypes, store as blocksStore } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { toStyles, getBlockSelectors } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport { usePrivateStyleOverride } from './utils';\nimport { getValueFromObjectPath } from '../utils/object';\nimport { store as blockEditorStore } from '../store';\nimport { globalStylesDataKey } from '../store/private-keys';\nimport { unlock } from '../lock-unlock';\n\nconst VARIATION_PREFIX = 'is-style-';\n\nfunction getVariationMatches( className ) {\n\tif ( ! className ) {\n\t\treturn [];\n\t}\n\treturn className.split( /\\s+/ ).reduce( ( matches, name ) => {\n\t\tif ( name.startsWith( VARIATION_PREFIX ) ) {\n\t\t\tconst match = name.slice( VARIATION_PREFIX.length );\n\t\t\tif ( match !== 'default' ) {\n\t\t\t\tmatches.push( match );\n\t\t\t}\n\t\t}\n\t\treturn matches;\n\t}, [] );\n}\n\n/**\n * Get the first block style variation that has been registered from the class string.\n *\n * @param {string} className CSS class string for a block.\n * @param {Array} registeredStyles Currently registered block styles.\n *\n * @return {string|null} The name of the first registered variation.\n */\nexport function getVariationNameFromClass( className, registeredStyles = [] ) {\n\t// The global flag affects how capturing groups work in JS. So the regex\n\t// below will only return full CSS classes not just the variation name.\n\tconst matches = getVariationMatches( className );\n\n\tif ( ! matches ) {\n\t\treturn null;\n\t}\n\n\tfor ( const variation of matches ) {\n\t\tif ( registeredStyles.some( ( style ) => style.name === variation ) ) {\n\t\t\treturn variation;\n\t\t}\n\t}\n\treturn null;\n}\n\n// A helper component to apply a style override using the useStyleOverride hook.\nfunction OverrideStyles( { override } ) {\n\tusePrivateStyleOverride( override );\n}\n\n/**\n * This component is used to generate new block style variation overrides\n * based on an incoming theme config. If a matching style is found in the config,\n * a new override is created and returned. The overrides can be used in conjunction with\n * useStyleOverride to apply the new styles to the editor. Its use is\n * subject to change.\n *\n * @param {Object} props Props.\n * @param {Object} props.config A global styles object, containing settings and styles.\n * @return {React.JSX.Element} An array of new block variation overrides.\n */\nexport function BlockStyleVariationOverridesWithConfig( { config } ) {\n\tconst { overrides } = useSelect(\n\t\t( select ) => ( {\n\t\t\toverrides: unlock( select( blockEditorStore ) ).getStyleOverrides(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { getBlockName } = useSelect( blockEditorStore );\n\n\tconst overridesWithConfig = useMemo( () => {\n\t\tif ( ! overrides?.length ) {\n\t\t\treturn;\n\t\t}\n\t\tconst newOverrides = [];\n\t\tconst overriddenClientIds = [];\n\t\tfor ( const [ , override ] of overrides ) {\n\t\t\tif (\n\t\t\t\toverride?.variation &&\n\t\t\t\toverride?.clientId &&\n\t\t\t\t/*\n\t\t\t\t * Because this component overwrites existing style overrides,\n\t\t\t\t * filter out any overrides that are already present in the store.\n\t\t\t\t */\n\t\t\t\t! overriddenClientIds.includes( override.clientId )\n\t\t\t) {\n\t\t\t\tconst blockName = getBlockName( override.clientId );\n\t\t\t\tconst configStyles =\n\t\t\t\t\tconfig?.styles?.blocks?.[ blockName ]?.variations?.[\n\t\t\t\t\t\toverride.variation\n\t\t\t\t\t];\n\t\t\t\tif ( configStyles ) {\n\t\t\t\t\tconst variationConfig = {\n\t\t\t\t\t\tsettings: config?.settings,\n\t\t\t\t\t\t// The variation style data is all that is needed to generate\n\t\t\t\t\t\t// the styles for the current application to a block. The variation\n\t\t\t\t\t\t// name is updated to match the instance specific class name.\n\t\t\t\t\t\tstyles: {\n\t\t\t\t\t\t\tblocks: {\n\t\t\t\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t\t\t\t[ `${ override.variation }-${ override.clientId }` ]:\n\t\t\t\t\t\t\t\t\t\t\tconfigStyles,\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t};\n\t\t\t\t\tconst blockSelectors = getBlockSelectors(\n\t\t\t\t\t\tgetBlockTypes(),\n\t\t\t\t\t\toverride.clientId\n\t\t\t\t\t);\n\t\t\t\t\tconst hasBlockGapSupport = false;\n\t\t\t\t\tconst hasFallbackGapSupport = true;\n\t\t\t\t\tconst disableLayoutStyles = true;\n\t\t\t\t\tconst disableRootPadding = true;\n\t\t\t\t\tconst variationStyles = toStyles(\n\t\t\t\t\t\tvariationConfig,\n\t\t\t\t\t\tblockSelectors,\n\t\t\t\t\t\thasBlockGapSupport,\n\t\t\t\t\t\thasFallbackGapSupport,\n\t\t\t\t\t\tdisableLayoutStyles,\n\t\t\t\t\t\tdisableRootPadding,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tblockGap: false,\n\t\t\t\t\t\t\tblockStyles: true,\n\t\t\t\t\t\t\tlayoutStyles: false,\n\t\t\t\t\t\t\tmarginReset: false,\n\t\t\t\t\t\t\tpresets: false,\n\t\t\t\t\t\t\trootPadding: false,\n\t\t\t\t\t\t\tvariationStyles: true,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t\tnewOverrides.push( {\n\t\t\t\t\t\tid: `${ override.variation }-${ override.clientId }`,\n\t\t\t\t\t\tcss: variationStyles,\n\t\t\t\t\t\t__unstableType: 'variation',\n\t\t\t\t\t\tvariation: override.variation,\n\t\t\t\t\t\t// The clientId will be stored with the override and used to ensure\n\t\t\t\t\t\t// the order of overrides matches the order of blocks so that the\n\t\t\t\t\t\t// correct CSS cascade is maintained.\n\t\t\t\t\t\tclientId: override.clientId,\n\t\t\t\t\t} );\n\t\t\t\t\toverriddenClientIds.push( override.clientId );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn newOverrides;\n\t}, [ config, overrides, getBlockName ] );\n\n\tif ( ! overridesWithConfig || ! overridesWithConfig.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ overridesWithConfig.map( ( override ) => (\n\t\t\t\t<OverrideStyles key={ override.id } override={ override } />\n\t\t\t) ) }\n\t\t</>\n\t);\n}\n\n/**\n * Retrieves any variation styles data and resolves any referenced values.\n *\n * @param {Object} globalStyles A complete global styles object, containing settings and styles.\n * @param {string} name The name of the desired block type.\n * @param {variation} variation The of the block style variation to retrieve data for.\n *\n * @return {Object|undefined} The global styles data for the specified variation.\n */\nexport function getVariationStylesWithRefValues(\n\tglobalStyles,\n\tname,\n\tvariation\n) {\n\tif ( ! globalStyles?.styles?.blocks?.[ name ]?.variations?.[ variation ] ) {\n\t\treturn;\n\t}\n\n\t// Helper to recursively look for `ref` values to resolve.\n\tconst replaceRefs = ( variationStyles ) => {\n\t\tObject.keys( variationStyles ).forEach( ( key ) => {\n\t\t\tconst value = variationStyles[ key ];\n\n\t\t\t// Only process objects.\n\t\t\tif ( typeof value === 'object' && value !== null ) {\n\t\t\t\t// Process `ref` value if present.\n\t\t\t\tif ( value.ref !== undefined ) {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof value.ref !== 'string' ||\n\t\t\t\t\t\tvalue.ref.trim() === ''\n\t\t\t\t\t) {\n\t\t\t\t\t\t// Remove invalid ref.\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Resolve `ref` value.\n\t\t\t\t\t\tconst refValue = getValueFromObjectPath(\n\t\t\t\t\t\t\tglobalStyles,\n\t\t\t\t\t\t\tvalue.ref\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tif ( refValue ) {\n\t\t\t\t\t\t\tvariationStyles[ key ] = refValue;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\t// Recursively resolve `ref` values in nested objects.\n\t\t\t\t\treplaceRefs( value );\n\n\t\t\t\t\t// After recursion, if value is empty due to explicitly\n\t\t\t\t\t// `undefined` ref value, remove it.\n\t\t\t\t\tif ( Object.keys( value ).length === 0 ) {\n\t\t\t\t\t\tdelete variationStyles[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t};\n\n\t// Deep clone variation node to avoid mutating it within global styles and losing refs.\n\tconst styles = JSON.parse(\n\t\tJSON.stringify(\n\t\t\tglobalStyles.styles.blocks[ name ].variations[ variation ]\n\t\t)\n\t);\n\treplaceRefs( styles );\n\n\treturn styles;\n}\n\nfunction useBlockStyleVariation( name, variation, clientId ) {\n\tconst { globalSettings, globalStyles } = useSelect( ( select ) => {\n\t\tconst settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tglobalSettings: settings.__experimentalFeatures,\n\t\t\tglobalStyles: settings[ globalStylesDataKey ],\n\t\t};\n\t}, [] );\n\n\treturn useMemo( () => {\n\t\tconst variationStyles = getVariationStylesWithRefValues(\n\t\t\t{\n\t\t\t\tsettings: globalSettings,\n\t\t\t\tstyles: globalStyles,\n\t\t\t},\n\t\t\tname,\n\t\t\tvariation\n\t\t);\n\n\t\treturn {\n\t\t\tsettings: globalSettings,\n\t\t\t// The variation style data is all that is needed to generate\n\t\t\t// the styles for the current application to a block. The variation\n\t\t\t// name is updated to match the instance specific class name.\n\t\t\tstyles: {\n\t\t\t\tblocks: {\n\t\t\t\t\t[ name ]: {\n\t\t\t\t\t\tvariations: {\n\t\t\t\t\t\t\t[ `${ variation }-${ clientId }` ]: variationStyles,\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t};\n\t}, [ globalSettings, globalStyles, variation, clientId, name ] );\n}\n\n// Rather than leveraging `useInstanceId` here, the `clientId` is used.\n// This is so that the variation style override's ID is predictable\n// when the order of applied style variations changes.\nfunction useBlockProps( { name, className, clientId } ) {\n\tconst { getBlockStyles } = useSelect( blocksStore );\n\n\tconst registeredStyles = getBlockStyles( name );\n\tconst variation = getVariationNameFromClass( className, registeredStyles );\n\tconst variationClass = `${ VARIATION_PREFIX }${ variation }-${ clientId }`;\n\n\tconst { settings, styles } = useBlockStyleVariation(\n\t\tname,\n\t\tvariation,\n\t\tclientId\n\t);\n\n\tconst variationStyles = useMemo( () => {\n\t\tif ( ! variation ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst variationConfig = { settings, styles };\n\t\tconst blockSelectors = getBlockSelectors( getBlockTypes(), clientId );\n\t\tconst hasBlockGapSupport = false;\n\t\tconst hasFallbackGapSupport = true;\n\t\tconst disableLayoutStyles = true;\n\t\tconst disableRootPadding = true;\n\n\t\treturn toStyles(\n\t\t\tvariationConfig,\n\t\t\tblockSelectors,\n\t\t\thasBlockGapSupport,\n\t\t\thasFallbackGapSupport,\n\t\t\tdisableLayoutStyles,\n\t\t\tdisableRootPadding,\n\t\t\t{\n\t\t\t\tblockGap: false,\n\t\t\t\tblockStyles: true,\n\t\t\t\tlayoutStyles: false,\n\t\t\t\tmarginReset: false,\n\t\t\t\tpresets: false,\n\t\t\t\trootPadding: false,\n\t\t\t\tvariationStyles: true,\n\t\t\t}\n\t\t);\n\t}, [ variation, settings, styles, clientId ] );\n\n\tusePrivateStyleOverride( {\n\t\tid: `variation-${ clientId }`,\n\t\tcss: variationStyles,\n\t\t__unstableType: 'variation',\n\t\tvariation,\n\t\t// The clientId will be stored with the override and used to ensure\n\t\t// the order of overrides matches the order of blocks so that the\n\t\t// correct CSS cascade is maintained.\n\t\tclientId,\n\t} );\n\n\treturn variation ? { className: variationClass } : {};\n}\n\nexport default {\n\thasSupport: () => true,\n\tattributeKeys: [ 'className' ],\n\tisMatch: ( { className } ) => getVariationMatches( className ).length > 0,\n\tuseBlockProps,\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,oBAAoD;AACpD,kBAA0B;AAC1B,qBAAwB;AACxB,kCAA4C;AAK5C,mBAAwC;AACxC,oBAAuC;AACvC,mBAA0C;AAC1C,0BAAoC;AACpC,yBAAuB;AA0JrB;AAxJF,IAAM,mBAAmB;AAEzB,SAAS,oBAAqB,WAAY;AACzC,MAAK,CAAE,WAAY;AAClB,WAAO,CAAC;AAAA,EACT;AACA,SAAO,UAAU,MAAO,KAAM,EAAE,OAAQ,CAAE,SAAS,SAAU;AAC5D,QAAK,KAAK,WAAY,gBAAiB,GAAI;AAC1C,YAAM,QAAQ,KAAK,MAAO,iBAAiB,MAAO;AAClD,UAAK,UAAU,WAAY;AAC1B,gBAAQ,KAAM,KAAM;AAAA,MACrB;AAAA,IACD;AACA,WAAO;AAAA,EACR,GAAG,CAAC,CAAE;AACP;AAUO,SAAS,0BAA2B,WAAW,mBAAmB,CAAC,GAAI;AAG7E,QAAM,UAAU,oBAAqB,SAAU;AAE/C,MAAK,CAAE,SAAU;AAChB,WAAO;AAAA,EACR;AAEA,aAAY,aAAa,S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  return;
38
38
  }
39
- el.querySelectorAll(
40
- "img,source,script,video,link"
41
- ).forEach((v) => {
42
- addCrossOriginAttribute(v);
43
- });
44
- if (["IMG", "SOURCE", "SCRIPT", "VIDEO", "LINK"].includes(
39
+ el.querySelectorAll("source,script,video,link").forEach(
40
+ (v) => {
41
+ addCrossOriginAttribute(v);
42
+ }
43
+ );
44
+ if (["SOURCE", "SCRIPT", "VIDEO", "LINK"].includes(
45
45
  el.nodeName
46
46
  )) {
47
47
  addCrossOriginAttribute(el);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/cross-origin-isolation.js"],
4
- "sourcesContent": ["/**\n * Adds crossorigin=\"anonymous\" to an element if missing.\n *\n * @param {Element} el The element to modify.\n */\nfunction addCrossOriginAttribute( el ) {\n\tif ( ! el.hasAttribute( 'crossorigin' ) ) {\n\t\tel.setAttribute( 'crossorigin', 'anonymous' );\n\t}\n}\n\n// Only add the mutation observer if the site is cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\t/*\n\t * Detects dynamically added DOM nodes that are missing the `crossorigin` attribute.\n\t */\n\tconst observer = new window.MutationObserver( ( mutations ) => {\n\t\tmutations.forEach( ( mutation ) => {\n\t\t\t[ mutation.addedNodes, mutation.target ].forEach( ( value ) => {\n\t\t\t\tconst nodes =\n\t\t\t\t\tvalue instanceof window.NodeList ? value : [ value ];\n\t\t\t\tnodes.forEach( ( node ) => {\n\t\t\t\t\tconst el = node;\n\n\t\t\t\t\tif ( ! el.querySelectorAll ) {\n\t\t\t\t\t\t// Most likely a text node.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tel.querySelectorAll(\n\t\t\t\t\t\t'img,source,script,video,link'\n\t\t\t\t\t).forEach( ( v ) => {\n\t\t\t\t\t\taddCrossOriginAttribute( v );\n\t\t\t\t\t} );\n\n\t\t\t\t\tif (\n\t\t\t\t\t\t[ 'IMG', 'SOURCE', 'SCRIPT', 'VIDEO', 'LINK' ].includes(\n\t\t\t\t\t\t\tel.nodeName\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\taddCrossOriginAttribute( el );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t/**\n\t * Start observing the document body, waiting for it to be available if needed.\n\t */\n\tfunction startObservingBody() {\n\t\tif ( document.body ) {\n\t\t\tobserver.observe( document.body, {\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tsubtree: true,\n\t\t\t} );\n\t\t} else if ( document.readyState === 'loading' ) {\n\t\t\t// Wait for DOM to be ready.\n\t\t\tdocument.addEventListener( 'DOMContentLoaded', () => {\n\t\t\t\tif ( document.body ) {\n\t\t\t\t\tobserver.observe( document.body, {\n\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tstartObservingBody();\n}\n"],
5
- "mappings": ";;;AAKA,SAAS,wBAAyB,IAAK;AACtC,MAAK,CAAE,GAAG,aAAc,aAAc,GAAI;AACzC,OAAG,aAAc,eAAe,WAAY;AAAA,EAC7C;AACD;AAGA,IAAK,OAAO,qBAAsB;AAsCjC,MAAS,qBAAT,WAA8B;AAC7B,QAAK,SAAS,MAAO;AACpB,eAAS,QAAS,SAAS,MAAM;AAAA,QAChC,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,SAAS;AAAA,MACV,CAAE;AAAA,IACH,WAAY,SAAS,eAAe,WAAY;AAE/C,eAAS,iBAAkB,oBAAoB,MAAM;AACpD,YAAK,SAAS,MAAO;AACpB,mBAAS,QAAS,SAAS,MAAM;AAAA,YAChC,WAAW;AAAA,YACX,YAAY;AAAA,YACZ,SAAS;AAAA,UACV,CAAE;AAAA,QACH;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAnBS,EAAAA,sBAAA;AAlCT,QAAM,WAAW,IAAI,OAAO,iBAAkB,CAAE,cAAe;AAC9D,cAAU,QAAS,CAAE,aAAc;AAClC,OAAE,SAAS,YAAY,SAAS,MAAO,EAAE,QAAS,CAAE,UAAW;AAC9D,cAAM,QACL,iBAAiB,OAAO,WAAW,QAAQ,CAAE,KAAM;AACpD,cAAM,QAAS,CAAE,SAAU;AAC1B,gBAAM,KAAK;AAEX,cAAK,CAAE,GAAG,kBAAmB;AAE5B;AAAA,UACD;AAEA,aAAG;AAAA,YACF;AAAA,UACD,EAAE,QAAS,CAAE,MAAO;AACnB,oCAAyB,CAAE;AAAA,UAC5B,CAAE;AAEF,cACC,CAAE,OAAO,UAAU,UAAU,SAAS,MAAO,EAAE;AAAA,YAC9C,GAAG;AAAA,UACJ,GACC;AACD,oCAAyB,EAAG;AAAA,UAC7B;AAAA,QACD,CAAE;AAAA,MACH,CAAE;AAAA,IACH,CAAE;AAAA,EACH,CAAE;AA0BF,qBAAmB;AACpB;AAtBU,IAAAA;",
4
+ "sourcesContent": ["/**\n * Adds crossorigin=\"anonymous\" to an element if missing.\n *\n * @param {Element} el The element to modify.\n */\nfunction addCrossOriginAttribute( el ) {\n\tif ( ! el.hasAttribute( 'crossorigin' ) ) {\n\t\tel.setAttribute( 'crossorigin', 'anonymous' );\n\t}\n}\n\n// Only add the mutation observer if the site is cross-origin isolated.\nif ( window.crossOriginIsolated ) {\n\t/*\n\t * Detects dynamically added DOM nodes that are missing the `crossorigin` attribute.\n\t */\n\tconst observer = new window.MutationObserver( ( mutations ) => {\n\t\tmutations.forEach( ( mutation ) => {\n\t\t\t[ mutation.addedNodes, mutation.target ].forEach( ( value ) => {\n\t\t\t\tconst nodes =\n\t\t\t\t\tvalue instanceof window.NodeList ? value : [ value ];\n\t\t\t\tnodes.forEach( ( node ) => {\n\t\t\t\t\tconst el = node;\n\n\t\t\t\t\tif ( ! el.querySelectorAll ) {\n\t\t\t\t\t\t// Most likely a text node.\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tel.querySelectorAll( 'source,script,video,link' ).forEach(\n\t\t\t\t\t\t( v ) => {\n\t\t\t\t\t\t\taddCrossOriginAttribute( v );\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[ 'SOURCE', 'SCRIPT', 'VIDEO', 'LINK' ].includes(\n\t\t\t\t\t\t\tel.nodeName\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\taddCrossOriginAttribute( el );\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} );\n\t\t} );\n\t} );\n\n\t/**\n\t * Start observing the document body, waiting for it to be available if needed.\n\t */\n\tfunction startObservingBody() {\n\t\tif ( document.body ) {\n\t\t\tobserver.observe( document.body, {\n\t\t\t\tchildList: true,\n\t\t\t\tattributes: true,\n\t\t\t\tsubtree: true,\n\t\t\t} );\n\t\t} else if ( document.readyState === 'loading' ) {\n\t\t\t// Wait for DOM to be ready.\n\t\t\tdocument.addEventListener( 'DOMContentLoaded', () => {\n\t\t\t\tif ( document.body ) {\n\t\t\t\t\tobserver.observe( document.body, {\n\t\t\t\t\t\tchildList: true,\n\t\t\t\t\t\tattributes: true,\n\t\t\t\t\t\tsubtree: true,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} );\n\t\t}\n\t}\n\n\tstartObservingBody();\n}\n"],
5
+ "mappings": ";;;AAKA,SAAS,wBAAyB,IAAK;AACtC,MAAK,CAAE,GAAG,aAAc,aAAc,GAAI;AACzC,OAAG,aAAc,eAAe,WAAY;AAAA,EAC7C;AACD;AAGA,IAAK,OAAO,qBAAsB;AAsCjC,MAAS,qBAAT,WAA8B;AAC7B,QAAK,SAAS,MAAO;AACpB,eAAS,QAAS,SAAS,MAAM;AAAA,QAChC,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,SAAS;AAAA,MACV,CAAE;AAAA,IACH,WAAY,SAAS,eAAe,WAAY;AAE/C,eAAS,iBAAkB,oBAAoB,MAAM;AACpD,YAAK,SAAS,MAAO;AACpB,mBAAS,QAAS,SAAS,MAAM;AAAA,YAChC,WAAW;AAAA,YACX,YAAY;AAAA,YACZ,SAAS;AAAA,UACV,CAAE;AAAA,QACH;AAAA,MACD,CAAE;AAAA,IACH;AAAA,EACD;AAnBS,EAAAA,sBAAA;AAlCT,QAAM,WAAW,IAAI,OAAO,iBAAkB,CAAE,cAAe;AAC9D,cAAU,QAAS,CAAE,aAAc;AAClC,OAAE,SAAS,YAAY,SAAS,MAAO,EAAE,QAAS,CAAE,UAAW;AAC9D,cAAM,QACL,iBAAiB,OAAO,WAAW,QAAQ,CAAE,KAAM;AACpD,cAAM,QAAS,CAAE,SAAU;AAC1B,gBAAM,KAAK;AAEX,cAAK,CAAE,GAAG,kBAAmB;AAE5B;AAAA,UACD;AAEA,aAAG,iBAAkB,0BAA2B,EAAE;AAAA,YACjD,CAAE,MAAO;AACR,sCAAyB,CAAE;AAAA,YAC5B;AAAA,UACD;AAEA,cACC,CAAE,UAAU,UAAU,SAAS,MAAO,EAAE;AAAA,YACvC,GAAG;AAAA,UACJ,GACC;AACD,oCAAyB,EAAG;AAAA,UAC7B;AAAA,QACD,CAAE;AAAA,MACH,CAAE;AAAA,IACH,CAAE;AAAA,EACH,CAAE;AA0BF,qBAAmB;AACpB;AAtBU,IAAAA;",
6
6
  "names": ["startObservingBody"]
7
7
  }
@@ -39,6 +39,7 @@ var import_compose = require("@wordpress/compose");
39
39
  var import_blocks = require("@wordpress/blocks");
40
40
  var import_i18n = require("@wordpress/i18n");
41
41
  var import_global_styles_engine = require("@wordpress/global-styles-engine");
42
+ var import_block_editing_mode = require("../components/block-editing-mode/index.cjs");
42
43
  var import_inspector_controls = __toESM(require("../components/inspector-controls/index.cjs"));
43
44
  var import_advanced_panel = __toESM(require("../components/global-styles/advanced-panel.cjs"));
44
45
  var import_utils = require("./utils.cjs");
@@ -47,6 +48,10 @@ var import_jsx_runtime = require("react/jsx-runtime");
47
48
  var CUSTOM_CSS_INSTANCE_REFERENCE = {};
48
49
  var EMPTY_STYLE = {};
49
50
  function CustomCSSControl({ blockName, setAttributes, style }) {
51
+ const blockEditingMode = (0, import_block_editing_mode.useBlockEditingMode)();
52
+ if (blockEditingMode !== "default") {
53
+ return null;
54
+ }
50
55
  const blockType = (0, import_blocks.getBlockType)(blockName);
51
56
  function onChange(newStyle) {
52
57
  const css = newStyle?.css?.trim() ? newStyle.css : void 0;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/custom-css.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: `has-custom-css ${ customCSSIdentifier }`,\n\t};\n}\n\n/**\n * Adds a marker class to blocks with custom CSS for server-side rendering.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.style?.css?.trim() ) {\n\t\treturn props;\n\t}\n\n\t// Add a class to indicate this block has custom CSS.\n\t// The actual CSS is rendered server-side using the render_block filter.\n\tconst className = props.className\n\t\t? `${ props.className } has-custom-css`\n\t\t: 'has-custom-css';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\nexport default {\n\tedit: CustomCSSEdit,\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customCSS', true );\n\t},\n};\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAA0B;AAC1B,qBAA8B;AAC9B,oBAA8C;AAC9C,kBAA4B;AAC5B,kCAAkC;AAKlC,gCAA8B;AAC9B,4BAEO;AACP,mBAAmD;AACnD,mBAA0C;AAqCvC;AAlCH,IAAM,gCAAgC,CAAC;AAGv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oB;AAInD,QAAM,qBAAiB,wBAAS,MAAM;AACrC,QAAK,CAAE,YAAa;AACnB,aAAO;AAAA,IACR;AACA,eAAO,+CAAmB,WAAW,iBAAkB;AAAA,EACxD,GAAG,CAAE,WAAW,mBAAmB,UAAW,CAAE;AAGhD,qCAAkB,EAAE,KAAK,eAAe,CAAE;AAG1C,MAAK,CAAE,YAAa;AACnB,WAAO,CAAC;AAAA,EACT;AAEA,SAAO;AAAA,IACN,WAAW,kBAAmB,mBAAoB;AAAA,EACnD;AACD;AAUA,SAAS,aAAc,OAAO,WAAW,YAAa;AACrD,MAAK,KAAE,+BAAiB,WAAW,aAAa,IAAK,GAAI;AACxD,WAAO;AAAA,EACR;AAEA,MAAK,CAAE,YAAY,OAAO,KAAK,KAAK,GAAI;AACvC,WAAO;AAAA,EACR;AAIA,QAAM,YAAY,MAAM,YACrB,GAAI,MAAM,SAAU,oBACpB;AAEH,SAAO;AAAA,IACN,GAAG;AAAA,IACH;AAAA,EACD;AACD;AAEA,IAAO,qBAAQ;AAAA,EACd,MAAM;AAAA,EACN;AAAA,EACA;AAAA,EACA,eAAe,CAAE,OAAQ;AAAA,EACzB,WAAY,MAAO;AAClB,eAAO,+BAAiB,MAAM,aAAa,IAAK;AAAA,EACjD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { getBlockType, hasBlockSupport } from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { processCSSNesting } from '@wordpress/global-styles-engine';\nimport { useBlockEditingMode } from '../components/block-editing-mode';\n\n/**\n * Internal dependencies\n */\nimport InspectorControls from '../components/inspector-controls';\nimport AdvancedPanel, {\n\tvalidateCSS,\n} from '../components/global-styles/advanced-panel';\nimport { cleanEmptyObject, useStyleOverride } from './utils';\nimport { store as blockEditorStore } from '../store';\n\n// Stable reference for useInstanceId.\nconst CUSTOM_CSS_INSTANCE_REFERENCE = {};\n\n// Stable empty object reference for useSelect.\nconst EMPTY_STYLE = {};\n\n/**\n * Inspector control for custom CSS.\n *\n * @param {Object} props Component props.\n * @param {string} props.blockName Block name.\n * @param {Function} props.setAttributes Function to set block attributes.\n * @param {Object} props.style Block style attribute.\n */\nfunction CustomCSSControl( { blockName, setAttributes, style } ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tif ( blockEditingMode !== 'default' ) {\n\t\treturn null;\n\t}\n\tconst blockType = getBlockType( blockName );\n\n\tfunction onChange( newStyle ) {\n\t\t// Normalize whitespace-only CSS to undefined so it gets cleaned up.\n\t\tconst css = newStyle?.css?.trim() ? newStyle.css : undefined;\n\t\tsetAttributes( {\n\t\t\tstyle: cleanEmptyObject( { ...newStyle, css } ),\n\t\t} );\n\t}\n\n\tconst cssHelpText = sprintf(\n\t\t// translators: %s: is the name of a block e.g., 'Image' or 'Quote'.\n\t\t__(\n\t\t\t'Add your own CSS to customize the appearance of the %s block. You do not need to include a CSS selector, just add the property and value, e.g. color: red;.'\n\t\t),\n\t\tblockType?.title\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"advanced\">\n\t\t\t<AdvancedPanel\n\t\t\t\tvalue={ style }\n\t\t\t\tonChange={ onChange }\n\t\t\t\tinheritedValue={ style }\n\t\t\t\thelp={ cssHelpText }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction CustomCSSEdit( { clientId, name, setAttributes } ) {\n\tconst { style, canEditCSS } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockAttributes, getSettings } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn {\n\t\t\t\tstyle: getBlockAttributes( clientId )?.style || EMPTY_STYLE,\n\t\t\t\tcanEditCSS: getSettings().canEditCSS,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Don't render the panel if user lacks edit_css capability.\n\tif ( ! canEditCSS ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<CustomCSSControl\n\t\t\tblockName={ name }\n\t\t\tsetAttributes={ setAttributes }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\n/**\n * Hook to handle custom CSS for a block in the editor.\n * Generates a unique class and applies scoped CSS via style override.\n *\n * @param {Object} props Block props.\n * @param {Object} props.style Block style attribute.\n * @return {Object} Block props including className for custom CSS scoping.\n */\nfunction useBlockProps( { style } ) {\n\tconst customCSS = style?.css;\n\n\t// Validate CSS is non-empty and passes validation checks.\n\tconst isValidCSS =\n\t\ttypeof customCSS === 'string' &&\n\t\tcustomCSS.trim().length > 0 &&\n\t\tvalidateCSS( customCSS );\n\n\tconst customCSSIdentifier = useInstanceId(\n\t\tCUSTOM_CSS_INSTANCE_REFERENCE,\n\t\t'wp-custom-css'\n\t);\n\n\tconst customCSSSelector = `.${ customCSSIdentifier }`;\n\n\t// Transform the custom CSS using the same logic as global styles.\n\t// Only process if CSS is valid (doesn't contain HTML markup).\n\tconst transformedCSS = useMemo( () => {\n\t\tif ( ! isValidCSS ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn processCSSNesting( customCSS, customCSSSelector );\n\t}, [ customCSS, customCSSSelector, isValidCSS ] );\n\n\t// Inject the CSS via style override.\n\tuseStyleOverride( { css: transformedCSS } );\n\n\t// Only add the class if there's valid custom CSS.\n\tif ( ! isValidCSS ) {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\tclassName: `has-custom-css ${ customCSSIdentifier }`,\n\t};\n}\n\n/**\n * Adds a marker class to blocks with custom CSS for server-side rendering.\n *\n * @param {Object} props Additional props applied to save element.\n * @param {Object} blockType Block type definition.\n * @param {Object} attributes Block's attributes.\n * @return {Object} Filtered props applied to save element.\n */\nfunction addSaveProps( props, blockType, attributes ) {\n\tif ( ! hasBlockSupport( blockType, 'customCSS', true ) ) {\n\t\treturn props;\n\t}\n\n\tif ( ! attributes?.style?.css?.trim() ) {\n\t\treturn props;\n\t}\n\n\t// Add a class to indicate this block has custom CSS.\n\t// The actual CSS is rendered server-side using the render_block filter.\n\tconst className = props.className\n\t\t? `${ props.className } has-custom-css`\n\t\t: 'has-custom-css';\n\n\treturn {\n\t\t...props,\n\t\tclassName,\n\t};\n}\n\nexport default {\n\tedit: CustomCSSEdit,\n\tuseBlockProps,\n\taddSaveProps,\n\tattributeKeys: [ 'style' ],\n\thasSupport( name ) {\n\t\treturn hasBlockSupport( name, 'customCSS', true );\n\t},\n};\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAAwB;AACxB,kBAA0B;AAC1B,qBAA8B;AAC9B,oBAA8C;AAC9C,kBAA4B;AAC5B,kCAAkC;AAClC,gCAAoC;AAKpC,gCAA8B;AAC9B,4BAEO;AACP,mBAAmD;AACnD,mBAA0C;AA0CvC;AAvCH,IAAM,gCAAgC,CAAC;AAGvC,IAAM,cAAc,CAAC;AAUrB,SAAS,iBAAkB,EAAE,WAAW,eAAe,MAAM,GAAI;AAChE,QAAM,uBAAmB,+CAAoB;AAE7C,MAAK,qBAAqB,WAAY;AACrC,WAAO;AAAA,EACR;AACA,QAAM,gBAAY,4BAAc,SAAU;AAE1C,WAAS,SAAU,UAAW;AAE7B,UAAM,MAAM,UAAU,KAAK,KAAK,IAAI,SAAS,MAAM;AACnD,kBAAe;AAAA,MACd,WAAO,+BAAkB,EAAE,GAAG,UAAU,IAAI,CAAE;AAAA,IAC/C,CAAE;AAAA,EACH;AAEA,QAAM,kBAAc;AAAA;AAAA,QAEnB;AAAA,MACC;AAAA,IACD;AAAA,IACA,WAAW;AAAA,EACZ;AAEA,SACC,4CAAC,0BAAAA,SAAA,EAAkB,OAAM,YACxB;AAAA,IAAC,sBAAAC;AAAA,IAAA;AAAA,MACA,OAAQ;AAAA,MACR;AAAA,MACA,gBAAiB;AAAA,MACjB,MAAO;AAAA;AAAA,EACR,GACD;AAEF;AAEA,SAAS,cAAe,EAAE,UAAU,MAAM,cAAc,GA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