@wordpress/block-editor 12.8.0 → 12.9.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 (173) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +30 -12
  3. package/build/components/block-controls/slot.js +1 -1
  4. package/build/components/block-controls/slot.js.map +1 -1
  5. package/build/components/block-controls/slot.native.js +1 -1
  6. package/build/components/block-controls/slot.native.js.map +1 -1
  7. package/build/components/block-controls/use-has-block-controls.js +1 -1
  8. package/build/components/block-controls/use-has-block-controls.js.map +1 -1
  9. package/build/components/block-list/block-outline.native.js +4 -3
  10. package/build/components/block-list/block-outline.native.js.map +1 -1
  11. package/build/components/block-list/index.js +4 -3
  12. package/build/components/block-list/index.js.map +1 -1
  13. package/build/components/block-list/use-block-props/index.js +27 -1
  14. package/build/components/block-list/use-block-props/index.js.map +1 -1
  15. package/build/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
  16. package/build/components/block-list/use-block-props/use-nav-mode-exit.js.map +1 -1
  17. package/build/components/block-lock/menu-item.js +3 -1
  18. package/build/components/block-lock/menu-item.js.map +1 -1
  19. package/build/components/block-lock/toolbar.js +3 -1
  20. package/build/components/block-lock/toolbar.js.map +1 -1
  21. package/build/components/block-popover/inbetween.js +4 -5
  22. package/build/components/block-popover/inbetween.js.map +1 -1
  23. package/build/components/block-popover/index.js +3 -2
  24. package/build/components/block-popover/index.js.map +1 -1
  25. package/build/components/color-style-selector/index.js +1 -1
  26. package/build/components/color-style-selector/index.js.map +1 -1
  27. package/build/components/iframe/index.js +1 -0
  28. package/build/components/iframe/index.js.map +1 -1
  29. package/build/components/inserter/reusable-blocks-tab.native.js +7 -4
  30. package/build/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  31. package/build/components/inserter/search-results.native.js +10 -8
  32. package/build/components/inserter/search-results.native.js.map +1 -1
  33. package/build/components/inspector-controls/fill.js +1 -1
  34. package/build/components/inspector-controls/fill.js.map +1 -1
  35. package/build/components/inspector-controls/fill.native.js +1 -1
  36. package/build/components/inspector-controls/fill.native.js.map +1 -1
  37. package/build/components/inspector-controls/slot.js +1 -1
  38. package/build/components/inspector-controls/slot.js.map +1 -1
  39. package/build/components/inspector-controls/slot.native.js +1 -1
  40. package/build/components/inspector-controls/slot.native.js.map +1 -1
  41. package/build/components/link-control/index.js +1 -7
  42. package/build/components/link-control/index.js.map +1 -1
  43. package/build/components/list-view/block-select-button.js +48 -7
  44. package/build/components/list-view/block-select-button.js.map +1 -1
  45. package/build/components/list-view/drop-indicator.js +3 -3
  46. package/build/components/list-view/drop-indicator.js.map +1 -1
  47. package/build/components/list-view/index.js +14 -8
  48. package/build/components/list-view/index.js.map +1 -1
  49. package/build/components/list-view/use-list-view-images.js +5 -4
  50. package/build/components/list-view/use-list-view-images.js.map +1 -1
  51. package/build/components/preview-options/index.js +3 -1
  52. package/build/components/preview-options/index.js.map +1 -1
  53. package/build/components/provider/index.js +3 -1
  54. package/build/components/provider/index.js.map +1 -1
  55. package/build/components/rich-text/use-remove-browser-shortcuts.js +1 -1
  56. package/build/components/rich-text/use-remove-browser-shortcuts.js.map +1 -1
  57. package/build/components/use-block-commands/index.js +74 -63
  58. package/build/components/use-block-commands/index.js.map +1 -1
  59. package/build/components/warning/index.js +1 -1
  60. package/build/components/warning/index.js.map +1 -1
  61. package/build/hooks/auto-inserting-blocks.js +174 -0
  62. package/build/hooks/auto-inserting-blocks.js.map +1 -0
  63. package/build/hooks/index.js +1 -0
  64. package/build/hooks/index.js.map +1 -1
  65. package/build/store/selectors.js +1 -1
  66. package/build/store/selectors.js.map +1 -1
  67. package/build-module/components/block-controls/slot.js +1 -1
  68. package/build-module/components/block-controls/slot.js.map +1 -1
  69. package/build-module/components/block-controls/slot.native.js +1 -1
  70. package/build-module/components/block-controls/slot.native.js.map +1 -1
  71. package/build-module/components/block-controls/use-has-block-controls.js +1 -1
  72. package/build-module/components/block-controls/use-has-block-controls.js.map +1 -1
  73. package/build-module/components/block-list/block-outline.native.js +4 -3
  74. package/build-module/components/block-list/block-outline.native.js.map +1 -1
  75. package/build-module/components/block-list/index.js +4 -3
  76. package/build-module/components/block-list/index.js.map +1 -1
  77. package/build-module/components/block-list/use-block-props/index.js +27 -1
  78. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  79. package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
  80. package/build-module/components/block-list/use-block-props/use-nav-mode-exit.js.map +1 -1
  81. package/build-module/components/block-lock/menu-item.js +3 -1
  82. package/build-module/components/block-lock/menu-item.js.map +1 -1
  83. package/build-module/components/block-lock/toolbar.js +3 -1
  84. package/build-module/components/block-lock/toolbar.js.map +1 -1
  85. package/build-module/components/block-popover/inbetween.js +4 -5
  86. package/build-module/components/block-popover/inbetween.js.map +1 -1
  87. package/build-module/components/block-popover/index.js +3 -2
  88. package/build-module/components/block-popover/index.js.map +1 -1
  89. package/build-module/components/color-style-selector/index.js +1 -1
  90. package/build-module/components/color-style-selector/index.js.map +1 -1
  91. package/build-module/components/iframe/index.js +1 -0
  92. package/build-module/components/iframe/index.js.map +1 -1
  93. package/build-module/components/inserter/reusable-blocks-tab.native.js +8 -4
  94. package/build-module/components/inserter/reusable-blocks-tab.native.js.map +1 -1
  95. package/build-module/components/inserter/search-results.native.js +11 -8
  96. package/build-module/components/inserter/search-results.native.js.map +1 -1
  97. package/build-module/components/inspector-controls/fill.js +1 -1
  98. package/build-module/components/inspector-controls/fill.js.map +1 -1
  99. package/build-module/components/inspector-controls/fill.native.js +1 -1
  100. package/build-module/components/inspector-controls/fill.native.js.map +1 -1
  101. package/build-module/components/inspector-controls/slot.js +1 -1
  102. package/build-module/components/inspector-controls/slot.js.map +1 -1
  103. package/build-module/components/inspector-controls/slot.native.js +1 -1
  104. package/build-module/components/inspector-controls/slot.native.js.map +1 -1
  105. package/build-module/components/link-control/index.js +1 -7
  106. package/build-module/components/link-control/index.js.map +1 -1
  107. package/build-module/components/list-view/block-select-button.js +48 -7
  108. package/build-module/components/list-view/block-select-button.js.map +1 -1
  109. package/build-module/components/list-view/drop-indicator.js +3 -3
  110. package/build-module/components/list-view/drop-indicator.js.map +1 -1
  111. package/build-module/components/list-view/index.js +14 -8
  112. package/build-module/components/list-view/index.js.map +1 -1
  113. package/build-module/components/list-view/use-list-view-images.js +5 -4
  114. package/build-module/components/list-view/use-list-view-images.js.map +1 -1
  115. package/build-module/components/preview-options/index.js +3 -1
  116. package/build-module/components/preview-options/index.js.map +1 -1
  117. package/build-module/components/provider/index.js +3 -1
  118. package/build-module/components/provider/index.js.map +1 -1
  119. package/build-module/components/rich-text/use-remove-browser-shortcuts.js +1 -1
  120. package/build-module/components/rich-text/use-remove-browser-shortcuts.js.map +1 -1
  121. package/build-module/components/use-block-commands/index.js +74 -63
  122. package/build-module/components/use-block-commands/index.js.map +1 -1
  123. package/build-module/components/warning/index.js +2 -2
  124. package/build-module/components/warning/index.js.map +1 -1
  125. package/build-module/hooks/auto-inserting-blocks.js +167 -0
  126. package/build-module/hooks/auto-inserting-blocks.js.map +1 -0
  127. package/build-module/hooks/index.js +1 -0
  128. package/build-module/hooks/index.js.map +1 -1
  129. package/build-module/store/selectors.js +1 -1
  130. package/build-module/store/selectors.js.map +1 -1
  131. package/build-style/content-rtl.css +8 -7
  132. package/build-style/content.css +8 -7
  133. package/build-style/style-rtl.css +0 -3
  134. package/build-style/style.css +0 -3
  135. package/package.json +32 -32
  136. package/src/components/block-icon/test/index.js +2 -2
  137. package/src/components/block-list/block-outline.native.js +5 -2
  138. package/src/components/block-list/content.scss +2 -3
  139. package/src/components/block-list/index.js +4 -3
  140. package/src/components/block-list/use-block-props/index.js +26 -0
  141. package/src/components/block-list/use-block-props/use-nav-mode-exit.js +1 -1
  142. package/src/components/block-lock/menu-item.js +2 -0
  143. package/src/components/block-lock/toolbar.js +3 -1
  144. package/src/components/block-popover/inbetween.js +4 -3
  145. package/src/components/block-popover/index.js +3 -2
  146. package/src/components/block-styles/style.scss +0 -3
  147. package/src/components/button-block-appender/content.scss +8 -0
  148. package/src/components/color-style-selector/index.js +1 -1
  149. package/src/components/iframe/index.js +1 -0
  150. package/src/components/inserter/reusable-blocks-tab.native.js +7 -2
  151. package/src/components/inserter/search-results.native.js +13 -9
  152. package/src/components/link-control/index.js +1 -5
  153. package/src/components/link-control/test/index.js +1 -0
  154. package/src/components/list-view/block-select-button.js +67 -15
  155. package/src/components/list-view/drop-indicator.js +4 -5
  156. package/src/components/list-view/index.js +19 -13
  157. package/src/components/list-view/use-list-view-images.js +8 -4
  158. package/src/components/observe-typing/README.md +2 -2
  159. package/src/components/preview-options/index.js +2 -0
  160. package/src/components/provider/index.js +8 -1
  161. package/src/components/rich-text/use-remove-browser-shortcuts.js +1 -1
  162. package/src/components/use-block-commands/index.js +92 -88
  163. package/src/components/warning/index.js +2 -2
  164. package/src/hooks/auto-inserting-blocks.js +232 -0
  165. package/src/hooks/index.js +1 -0
  166. package/src/store/selectors.js +1 -1
  167. package/build/utils/pre-parse-patterns.js +0 -68
  168. package/build/utils/pre-parse-patterns.js.map +0 -1
  169. package/build-module/utils/pre-parse-patterns.js +0 -61
  170. package/build-module/utils/pre-parse-patterns.js.map +0 -1
  171. package/src/components/url-popover/test/__snapshots__/index.js.snap +0 -133
  172. package/src/components/url-popover/test/index.js +0 -75
  173. package/src/utils/pre-parse-patterns.js +0 -69
@@ -7,6 +7,7 @@ import classnames from 'classnames';
7
7
  /**
8
8
  * WordPress dependencies
9
9
  */
10
+ import { hasBlockSupport } from '@wordpress/blocks';
10
11
  import { Button, __experimentalHStack as HStack, __experimentalTruncate as Truncate, Tooltip } from '@wordpress/components';
11
12
  import { forwardRef } from '@wordpress/element';
12
13
  import { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';
@@ -51,13 +52,16 @@ function ListViewBlockSelectButton({
51
52
  isLocked
52
53
  } = useBlockLock(clientId);
53
54
  const {
55
+ canInsertBlockType,
54
56
  getSelectedBlockClientIds,
55
57
  getPreviousBlockClientId,
56
58
  getBlockRootClientId,
57
59
  getBlockOrder,
60
+ getBlocksByClientId,
58
61
  canRemoveBlocks
59
62
  } = useSelect(blockEditorStore);
60
63
  const {
64
+ duplicateBlocks,
61
65
  removeBlocks
62
66
  } = useDispatch(blockEditorStore);
63
67
  const isMatch = useShortcutEventMatch();
@@ -79,19 +83,37 @@ function ListViewBlockSelectButton({
79
83
  onDragStart?.(event);
80
84
  };
81
85
 
86
+ // Determine which blocks to update:
87
+ // If the current (focused) block is part of the block selection, use the whole selection.
88
+ // If the focused block is not part of the block selection, only update the focused block.
89
+ function getBlocksToUpdate() {
90
+ const selectedBlockClientIds = getSelectedBlockClientIds();
91
+ const isUpdatingSelectedBlocks = selectedBlockClientIds.includes(clientId);
92
+ const firstBlockClientId = isUpdatingSelectedBlocks ? selectedBlockClientIds[0] : clientId;
93
+ const firstBlockRootClientId = getBlockRootClientId(firstBlockClientId);
94
+ const blocksToUpdate = isUpdatingSelectedBlocks ? selectedBlockClientIds : [clientId];
95
+ return {
96
+ blocksToUpdate,
97
+ firstBlockClientId,
98
+ firstBlockRootClientId,
99
+ selectedBlockClientIds
100
+ };
101
+ }
102
+
82
103
  /**
83
104
  * @param {KeyboardEvent} event
84
105
  */
85
- function onKeyDownHandler(event) {
106
+ async function onKeyDownHandler(event) {
86
107
  if (event.keyCode === ENTER || event.keyCode === SPACE) {
87
108
  onClick(event);
88
109
  } else if (event.keyCode === BACKSPACE || event.keyCode === DELETE || isMatch('core/block-editor/remove', event)) {
89
110
  var _getPreviousBlockClie;
90
- const selectedBlockClientIds = getSelectedBlockClientIds();
91
- const isDeletingSelectedBlocks = selectedBlockClientIds.includes(clientId);
92
- const firstBlockClientId = isDeletingSelectedBlocks ? selectedBlockClientIds[0] : clientId;
93
- const firstBlockRootClientId = getBlockRootClientId(firstBlockClientId);
94
- const blocksToDelete = isDeletingSelectedBlocks ? selectedBlockClientIds : [clientId];
111
+ const {
112
+ blocksToUpdate: blocksToDelete,
113
+ firstBlockClientId,
114
+ firstBlockRootClientId,
115
+ selectedBlockClientIds
116
+ } = getBlocksToUpdate();
95
117
 
96
118
  // Don't update the selection if the blocks cannot be deleted.
97
119
  if (!canRemoveBlocks(blocksToDelete, firstBlockRootClientId)) {
@@ -111,6 +133,25 @@ function ListViewBlockSelectButton({
111
133
  blockToFocus = getBlockOrder()[0];
112
134
  }
113
135
  updateFocusAndSelection(blockToFocus, shouldUpdateSelection);
136
+ } else if (isMatch('core/block-editor/duplicate', event)) {
137
+ if (event.defaultPrevented) {
138
+ return;
139
+ }
140
+ event.preventDefault();
141
+ const {
142
+ blocksToUpdate,
143
+ firstBlockRootClientId
144
+ } = getBlocksToUpdate();
145
+ const canDuplicate = getBlocksByClientId(blocksToUpdate).every(block => {
146
+ return !!block && hasBlockSupport(block.name, 'multiple', true) && canInsertBlockType(block.name, firstBlockRootClientId);
147
+ });
148
+ if (canDuplicate) {
149
+ const updatedBlocks = await duplicateBlocks(blocksToUpdate, false);
150
+ if (updatedBlocks?.length) {
151
+ // If blocks have been duplicated, focus the first duplicated block.
152
+ updateFocusAndSelection(updatedBlocks[0], false);
153
+ }
154
+ }
114
155
  }
115
156
  }
116
157
  return createElement(Fragment, null, createElement(Button, {
@@ -158,7 +199,7 @@ function ListViewBlockSelectButton({
158
199
  "aria-hidden": true
159
200
  }, images.map((image, index) => createElement("span", {
160
201
  className: "block-editor-list-view-block-select-button__image",
161
- key: `img-${image.url}`,
202
+ key: image.clientId,
162
203
  style: {
163
204
  backgroundImage: `url(${image.url})`,
164
205
  zIndex: images.length - index // Ensure the first image is on top, and subsequent images are behind.
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","Tooltip","forwardRef","Icon","lockSmall","lock","pinSmall","SPACE","ENTER","BACKSPACE","DELETE","useSelect","useDispatch","__unstableUseShortcutEventMatch","useShortcutEventMatch","__","sprintf","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","store","blockEditorStore","useListViewImages","ListViewBlockSelectButton","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaLabel","ariaDescribedBy","updateFocusAndSelection","ref","blockInformation","blockTitle","context","isLocked","getSelectedBlockClientIds","getPreviousBlockClientId","getBlockRootClientId","getBlockOrder","canRemoveBlocks","removeBlocks","isMatch","isSticky","positionType","images","positionLabel","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","_getPreviousBlockClie","selectedBlockClientIds","isDeletingSelectedBlocks","includes","firstBlockClientId","firstBlockRootClientId","blocksToDelete","blockToFocus","shouldUpdateSelection","length","createElement","Fragment","onKeyDown","href","icon","showColors","alignment","justify","spacing","ellipsizeMode","anchor","text","map","image","index","key","url","style","backgroundImage","zIndex"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tTooltip,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport useListViewImages from './use-list-view-images';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaLabel,\n\t\tariaDescribedBy,\n\t\tupdateFocusAndSelection,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst {\n\t\tgetSelectedBlockClientIds,\n\t\tgetPreviousBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t\tcanRemoveBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst { removeBlocks } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\n\tconst positionLabel = blockInformation?.positionLabel\n\t\t? sprintf(\n\t\t\t\t// translators: 1: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t__( 'Position: %1$s' ),\n\t\t\t\tblockInformation.positionLabel\n\t\t )\n\t\t: '';\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t} else if (\n\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\tevent.keyCode === DELETE ||\n\t\t\tisMatch( 'core/block-editor/remove', event )\n\t\t) {\n\t\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\t\tconst isDeletingSelectedBlocks =\n\t\t\t\tselectedBlockClientIds.includes( clientId );\n\t\t\tconst firstBlockClientId = isDeletingSelectedBlocks\n\t\t\t\t? selectedBlockClientIds[ 0 ]\n\t\t\t\t: clientId;\n\t\t\tconst firstBlockRootClientId =\n\t\t\t\tgetBlockRootClientId( firstBlockClientId );\n\n\t\t\tconst blocksToDelete = isDeletingSelectedBlocks\n\t\t\t\t? selectedBlockClientIds\n\t\t\t\t: [ clientId ];\n\n\t\t\t// Don't update the selection if the blocks cannot be deleted.\n\t\t\tif ( ! canRemoveBlocks( blocksToDelete, firstBlockRootClientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet blockToFocus =\n\t\t\t\tgetPreviousBlockClientId( firstBlockClientId ) ??\n\t\t\t\t// If the previous block is not found (when the first block is deleted),\n\t\t\t\t// fallback to focus the parent block.\n\t\t\t\tfirstBlockRootClientId;\n\n\t\t\tremoveBlocks( blocksToDelete, false );\n\n\t\t\t// Update the selection if the original selection has been removed.\n\t\t\tconst shouldUpdateSelection =\n\t\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\t\tgetSelectedBlockClientIds().length === 0;\n\n\t\t\t// If there's no previous block nor parent block, focus the first block.\n\t\t\tif ( ! blockToFocus ) {\n\t\t\t\tblockToFocus = getBlockOrder()[ 0 ];\n\t\t\t}\n\n\t\t\tupdateFocusAndSelection( blockToFocus, shouldUpdateSelection );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-label={ ariaLabel }\n\t\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon\n\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\tshowColors\n\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ positionLabel && isSticky && (\n\t\t\t\t\t\t<Tooltip text={ positionLabel }>\n\t\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__sticky\">\n\t\t\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t\t{ images.length ? (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\t\tkey={ `img-${ image.url }` }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\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</span>\n\t\t\t\t\t) : null }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,SAAS,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACpE,SAASC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AACrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,+BAA+B,IAAIC,qBAAqB,QAAQ,+BAA+B;AACxG,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,OAAOC,oBA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AAQ,IAC1BoB,aAAA,CAACvE,OAAO;IAACkF,IAAI,EAAG5B;EAAe,GAC9BiB,aAAA;IAAM9C,SAAS,EAAC;EAAoD,GACnE8C,aAAA,CAACrE,IAAI;IAACyE,IAAI,EAAGtE;EAAU,CAAE,CACpB,CACE,CACT,EACCgD,MAAM,CAACiB,MAAM,GACdC,aAAA;IACC9C,SAAS,EAAC,oDAAoD;IAC9D;EAAW,GAET4B,MAAM,CAAC8B,GAAG,CAAE,CAAEC,KAAK,EAAEC,KAAK,KAC3Bd,aAAA;IACC9C,SAAS,EAAC,mDAAmD;IAC7D6D,GAAG,EAAI,OAAOF,KAAK,CAACG,GAAK,EAAG;IAC5BC,KAAK,EAAG;MACPC,eAAe,EAAG,OAAOL,KAAK,CAACG,GAAK,GAAE;MACtCG,MAAM,EAAErC,MAAM,CAACiB,MAAM,GAAGe,KAAK,CAAE;IAChC;EAAG,CACH,CACA,CACG,CAAC,GACJ,IAAI,EACN1C,QAAQ,IACT4B,aAAA;IAAM9C,SAAS,EAAC;EAAkD,GACjE8C,aAAA,CAACrE,IAAI;IAACyE,IAAI,EAAGvE;EAAM,CAAE,CAChB,CAEA,CACD,CACP,CAAC;AAEL;AAEA,eAAeH,UAAU,CAAEuB,yBAA0B,CAAC"}
1
+ {"version":3,"names":["classnames","hasBlockSupport","Button","__experimentalHStack","HStack","__experimentalTruncate","Truncate","Tooltip","forwardRef","Icon","lockSmall","lock","pinSmall","SPACE","ENTER","BACKSPACE","DELETE","useSelect","useDispatch","__unstableUseShortcutEventMatch","useShortcutEventMatch","__","sprintf","BlockIcon","useBlockDisplayInformation","useBlockDisplayTitle","ListViewExpander","useBlockLock","store","blockEditorStore","useListViewImages","ListViewBlockSelectButton","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","isExpanded","ariaLabel","ariaDescribedBy","updateFocusAndSelection","ref","blockInformation","blockTitle","context","isLocked","canInsertBlockType","getSelectedBlockClientIds","getPreviousBlockClientId","getBlockRootClientId","getBlockOrder","getBlocksByClientId","canRemoveBlocks","duplicateBlocks","removeBlocks","isMatch","isSticky","positionType","images","positionLabel","onDragStartHandler","event","dataTransfer","clearData","getBlocksToUpdate","selectedBlockClientIds","isUpdatingSelectedBlocks","includes","firstBlockClientId","firstBlockRootClientId","blocksToUpdate","onKeyDownHandler","keyCode","_getPreviousBlockClie","blocksToDelete","blockToFocus","shouldUpdateSelection","length","defaultPrevented","preventDefault","canDuplicate","every","name","updatedBlocks","createElement","Fragment","onKeyDown","href","icon","showColors","alignment","justify","spacing","ellipsizeMode","anchor","text","map","image","index","key","style","backgroundImage","url","zIndex"],"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport {\n\tButton,\n\t__experimentalHStack as HStack,\n\t__experimentalTruncate as Truncate,\n\tTooltip,\n} from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lockSmall as lock, pinSmall } from '@wordpress/icons';\nimport { SPACE, ENTER, BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport useBlockDisplayTitle from '../block-title/use-block-display-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\nimport { store as blockEditorStore } from '../../store';\nimport useListViewImages from './use-list-view-images';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t\tisExpanded,\n\t\tariaLabel,\n\t\tariaDescribedBy,\n\t\tupdateFocusAndSelection,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst blockTitle = useBlockDisplayTitle( {\n\t\tclientId,\n\t\tcontext: 'list-view',\n\t} );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst {\n\t\tcanInsertBlockType,\n\t\tgetSelectedBlockClientIds,\n\t\tgetPreviousBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlockOrder,\n\t\tgetBlocksByClientId,\n\t\tcanRemoveBlocks,\n\t} = useSelect( blockEditorStore );\n\tconst { duplicateBlocks, removeBlocks } = useDispatch( blockEditorStore );\n\tconst isMatch = useShortcutEventMatch();\n\tconst isSticky = blockInformation?.positionType === 'sticky';\n\tconst images = useListViewImages( { clientId, isExpanded } );\n\n\tconst positionLabel = blockInformation?.positionLabel\n\t\t? sprintf(\n\t\t\t\t// translators: 1: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t__( 'Position: %1$s' ),\n\t\t\t\tblockInformation.positionLabel\n\t\t )\n\t\t: '';\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\t// Determine which blocks to update:\n\t// If the current (focused) block is part of the block selection, use the whole selection.\n\t// If the focused block is not part of the block selection, only update the focused block.\n\tfunction getBlocksToUpdate() {\n\t\tconst selectedBlockClientIds = getSelectedBlockClientIds();\n\t\tconst isUpdatingSelectedBlocks =\n\t\t\tselectedBlockClientIds.includes( clientId );\n\t\tconst firstBlockClientId = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds[ 0 ]\n\t\t\t: clientId;\n\t\tconst firstBlockRootClientId =\n\t\t\tgetBlockRootClientId( firstBlockClientId );\n\n\t\tconst blocksToUpdate = isUpdatingSelectedBlocks\n\t\t\t? selectedBlockClientIds\n\t\t\t: [ clientId ];\n\n\t\treturn {\n\t\t\tblocksToUpdate,\n\t\t\tfirstBlockClientId,\n\t\t\tfirstBlockRootClientId,\n\t\t\tselectedBlockClientIds,\n\t\t};\n\t}\n\n\t/**\n\t * @param {KeyboardEvent} event\n\t */\n\tasync function onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t} else if (\n\t\t\tevent.keyCode === BACKSPACE ||\n\t\t\tevent.keyCode === DELETE ||\n\t\t\tisMatch( 'core/block-editor/remove', event )\n\t\t) {\n\t\t\tconst {\n\t\t\t\tblocksToUpdate: blocksToDelete,\n\t\t\t\tfirstBlockClientId,\n\t\t\t\tfirstBlockRootClientId,\n\t\t\t\tselectedBlockClientIds,\n\t\t\t} = getBlocksToUpdate();\n\n\t\t\t// Don't update the selection if the blocks cannot be deleted.\n\t\t\tif ( ! canRemoveBlocks( blocksToDelete, firstBlockRootClientId ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tlet blockToFocus =\n\t\t\t\tgetPreviousBlockClientId( firstBlockClientId ) ??\n\t\t\t\t// If the previous block is not found (when the first block is deleted),\n\t\t\t\t// fallback to focus the parent block.\n\t\t\t\tfirstBlockRootClientId;\n\n\t\t\tremoveBlocks( blocksToDelete, false );\n\n\t\t\t// Update the selection if the original selection has been removed.\n\t\t\tconst shouldUpdateSelection =\n\t\t\t\tselectedBlockClientIds.length > 0 &&\n\t\t\t\tgetSelectedBlockClientIds().length === 0;\n\n\t\t\t// If there's no previous block nor parent block, focus the first block.\n\t\t\tif ( ! blockToFocus ) {\n\t\t\t\tblockToFocus = getBlockOrder()[ 0 ];\n\t\t\t}\n\n\t\t\tupdateFocusAndSelection( blockToFocus, shouldUpdateSelection );\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tevent.preventDefault();\n\n\t\t\tconst { blocksToUpdate, firstBlockRootClientId } =\n\t\t\t\tgetBlocksToUpdate();\n\n\t\t\tconst canDuplicate = getBlocksByClientId( blocksToUpdate ).every(\n\t\t\t\t( block ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t!! block &&\n\t\t\t\t\t\thasBlockSupport( block.name, 'multiple', true ) &&\n\t\t\t\t\t\tcanInsertBlockType( block.name, firstBlockRootClientId )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( canDuplicate ) {\n\t\t\t\tconst updatedBlocks = await duplicateBlocks(\n\t\t\t\t\tblocksToUpdate,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\n\t\t\t\tif ( updatedBlocks?.length ) {\n\t\t\t\t\t// If blocks have been duplicated, focus the first duplicated block.\n\t\t\t\t\tupdateFocusAndSelection( updatedBlocks[ 0 ], false );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-label={ ariaLabel }\n\t\t\t\taria-describedby={ ariaDescribedBy }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon\n\t\t\t\t\ticon={ blockInformation?.icon }\n\t\t\t\t\tshowColors\n\t\t\t\t\tcontext=\"list-view\"\n\t\t\t\t/>\n\t\t\t\t<HStack\n\t\t\t\t\talignment=\"center\"\n\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__label-wrapper\"\n\t\t\t\t\tjustify=\"flex-start\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t>\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t\t<Truncate ellipsizeMode=\"auto\">{ blockTitle }</Truncate>\n\t\t\t\t\t</span>\n\t\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor-wrapper\">\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__anchor\"\n\t\t\t\t\t\t\t\tellipsizeMode=\"auto\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ positionLabel && isSticky && (\n\t\t\t\t\t\t<Tooltip text={ positionLabel }>\n\t\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__sticky\">\n\t\t\t\t\t\t\t\t<Icon icon={ pinSmall } />\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</Tooltip>\n\t\t\t\t\t) }\n\t\t\t\t\t{ images.length ? (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__images\"\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ images.map( ( image, index ) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__image\"\n\t\t\t\t\t\t\t\t\tkey={ image.clientId }\n\t\t\t\t\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t\t\t\t\tbackgroundImage: `url(${ image.url })`,\n\t\t\t\t\t\t\t\t\t\tzIndex: images.length - index, // Ensure the first image is on top, and subsequent images are behind.\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</span>\n\t\t\t\t\t) : null }\n\t\t\t\t\t{ isLocked && (\n\t\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SACCC,MAAM,EACNC,oBAAoB,IAAIC,MAAM,EAC9BC,sBAAsB,IAAIC,QAAQ,EAClCC,OAAO,QACD,uBAAuB;AAC9B,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,IAAI,EAAEC,SAAS,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,kBAAkB;AACpE,SAASC,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAEC,MAAM,QAAQ,qBAAqB;AACrE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,+BAA+B,IAAIC,qBAAqB,QAAQ,+BAA+B;AACxG,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,SAAS,MAAM,eAAe;AACrC,OAAOC,0BAA0B,MAAM,kCAAkC;AACzE,OAAOC,oBAAoB,MAAM,wCAAwC;AACzE,OAAOC,gBAAgB,MAAM,YAAY;AACzC,SAASC,YAAY,QAAQ,eAAe;AAC5C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,OAAOC,iBAAiB,MAAM,wBAAwB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DwE,GAAG,EAAGF,KAAK,CAACpE,QAAU;IACtBuE,KAAK,EAAG;MACPC,eAAe,EAAG,OAAOJ,KAAK,CAACK,GAAK,GAAE;MACtCC,MAAM,EAAE7C,MAAM,CAACmB,MAAM,GAAGqB,KAAK,CAAE;IAChC;EAAG,CACH,CACA,CACG,CAAC,GACJ,IAAI,EACNrD,QAAQ,IACTuC,aAAA;IAAMzD,SAAS,EAAC;EAAkD,GACjEyD,aAAA,CAAChF,IAAI;IAACoF,IAAI,EAAGlF;EAAM,CAAE,CAChB,CAEA,CACD,CACP,CAAC;AAEL;AAEA,eAAeH,UAAU,CAAEuB,yBAA0B,CAAC"}
@@ -106,9 +106,8 @@ export default function ListViewDropIndicator({
106
106
  if (!targetElement || !isValidDropPosition) {
107
107
  return undefined;
108
108
  }
109
- const ownerDocument = targetElement.ownerDocument;
110
109
  return {
111
- ownerDocument,
110
+ contextElement: targetElement,
112
111
  getBoundingClientRect() {
113
112
  const rect = targetElement.getBoundingClientRect();
114
113
  const indent = getDropIndicatorIndent(rect);
@@ -131,7 +130,8 @@ export default function ListViewDropIndicator({
131
130
  // that the drop indicator position never breaks out of the
132
131
  // visible area of the scroll container.
133
132
  const scrollContainer = getScrollContainer(targetElement, 'horizontal');
134
- const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
133
+ const doc = targetElement.ownerDocument;
134
+ const windowScroll = scrollContainer === doc.body || scrollContainer === doc.documentElement;
135
135
 
136
136
  // If the scroll container is not the window, offset the left position, if need be.
137
137
  if (scrollContainer && !windowScroll) {
@@ -1 +1 @@
1
- {"version":3,"names":["Popover","getScrollContainer","useCallback","useMemo","isRTL","ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","rtl","getDropIndicatorIndent","targetElementRect","rootBlockIconElement","rootBlockIconRect","getBoundingClientRect","right","left","getDropIndicatorWidth","indent","width","offsetWidth","scrollContainer","ownerDocument","windowScroll","body","documentElement","scrollContainerRect","distanceBetweenContainerAndTarget","scrollContainerWidth","clientWidth","style","popoverAnchor","isValidDropPosition","rect","top","bottom","scrollbarWidth","height","window","DOMRect","createElement","animate","anchor","focusOnMount","className","variant"],"sources":["@wordpress/block-editor/src/components/list-view/drop-indicator.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\nexport default function ListViewDropIndicator( {\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst rtl = isRTL();\n\n\tconst getDropIndicatorIndent = useCallback(\n\t\t( targetElementRect ) => {\n\t\t\tif ( ! rootBlockElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Calculate the indent using the block icon of the root block.\n\t\t\t// Using a classname selector here might be flaky and could be\n\t\t\t// improved.\n\t\t\tconst rootBlockIconElement = rootBlockElement.querySelector(\n\t\t\t\t'.block-editor-block-icon'\n\t\t\t);\n\t\t\tconst rootBlockIconRect =\n\t\t\t\trootBlockIconElement.getBoundingClientRect();\n\t\t\treturn rtl\n\t\t\t\t? targetElementRect.right - rootBlockIconRect.left\n\t\t\t\t: rootBlockIconRect.right - targetElementRect.left;\n\t\t},\n\t\t[ rootBlockElement, rtl ]\n\t);\n\n\tconst getDropIndicatorWidth = useCallback(\n\t\t( targetElementRect, indent ) => {\n\t\t\tif ( ! targetElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Default to assuming that the width of the drop indicator\n\t\t\t// should be the same as the target element.\n\t\t\tlet width = targetElement.offsetWidth;\n\n\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t// the width of the drop indicator should be the width of\n\t\t\t// the scroll container, minus the distance from the left\n\t\t\t// edge of the scroll container to the left edge of the\n\t\t\t// target element.\n\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\ttargetElement,\n\t\t\t\t'horizontal'\n\t\t\t);\n\n\t\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\tconst distanceBetweenContainerAndTarget = isRTL()\n\t\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\t\tconst scrollContainerWidth = scrollContainer.clientWidth;\n\n\t\t\t\tif (\n\t\t\t\t\tscrollContainerWidth <\n\t\t\t\t\twidth + distanceBetweenContainerAndTarget\n\t\t\t\t) {\n\t\t\t\t\twidth =\n\t\t\t\t\t\tscrollContainerWidth -\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget;\n\t\t\t\t}\n\n\t\t\t\t// LTR logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\t! rtl &&\n\t\t\t\t\ttargetElementRect.left + indent < scrollContainerRect.left\n\t\t\t\t) {\n\t\t\t\t\twidth -= scrollContainerRect.left - targetElementRect.left;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\n\t\t\t\t// RTL logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\trtl &&\n\t\t\t\t\ttargetElementRect.right - indent > scrollContainerRect.right\n\t\t\t\t) {\n\t\t\t\t\twidth -=\n\t\t\t\t\t\ttargetElementRect.right - scrollContainerRect.right;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Subtract the indent from the final width of the indicator.\n\t\t\treturn width - indent;\n\t\t},\n\t\t[ rtl, targetElement ]\n\t);\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\t\tconst indent = getDropIndicatorIndent( targetElementRect );\n\n\t\treturn {\n\t\t\twidth: getDropIndicatorWidth( targetElementRect, indent ),\n\t\t};\n\t}, [ getDropIndicatorIndent, getDropIndicatorWidth, targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst ownerDocument = targetElement.ownerDocument;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\tconst indent = getDropIndicatorIndent( rect );\n\t\t\t\t// In RTL languages, the drop indicator should be positioned\n\t\t\t\t// to the left of the target element, with the width of the\n\t\t\t\t// indicator determining the indent at the right edge of the\n\t\t\t\t// target element. In LTR languages, the drop indicator should\n\t\t\t\t// end at the right edge of the target element, with the indent\n\t\t\t\t// added to the position of the left edge of the target element.\n\t\t\t\tlet left = rtl ? rect.left : rect.left + indent;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet bottom = 0;\n\n\t\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t\t// the width of the drop indicator should be the width of\n\t\t\t\t// the visible area of the scroll container. Additionally,\n\t\t\t\t// the left edge of the drop indicator line needs to be\n\t\t\t\t// offset by the distance the left edge of the target element\n\t\t\t\t// and the left edge of the scroll container. The ensures\n\t\t\t\t// that the drop indicator position never breaks out of the\n\t\t\t\t// visible area of the scroll container.\n\t\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\t\ttargetElement,\n\t\t\t\t\t'horizontal'\n\t\t\t\t);\n\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t\t\t// If the scroll container is not the window, offset the left position, if need be.\n\t\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\t\t// In RTL languages, a vertical scrollbar is present on the\n\t\t\t\t\t// left edge of the scroll container. The width of the\n\t\t\t\t\t// scrollbar needs to be accounted for when positioning the\n\t\t\t\t\t// drop indicator.\n\t\t\t\t\tconst scrollbarWidth = rtl\n\t\t\t\t\t\t? scrollContainer.offsetWidth -\n\t\t\t\t\t\t scrollContainer.clientWidth\n\t\t\t\t\t\t: 0;\n\n\t\t\t\t\tif ( left < scrollContainerRect.left + scrollbarWidth ) {\n\t\t\t\t\t\tleft = scrollContainerRect.left + scrollbarWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t\tbottom = rect.top;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.bottom;\n\t\t\t\t\tbottom = rect.bottom;\n\t\t\t\t}\n\n\t\t\t\tconst width = getDropIndicatorWidth( rect, indent );\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\ttargetElement,\n\t\tdropPosition,\n\t\tgetDropIndicatorIndent,\n\t\tgetDropIndicatorWidth,\n\t\trtl,\n\t] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName=\"block-editor-list-view-drop-indicator__line\"\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,KAAK,QAAQ,iBAAiB;AAEvC,eAAe,SAASC,qBAAqBA,CAAE;EAC9CC,WAAW;EACXC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,YAAY;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,eAAe,IAAI,CAAC,CAAC;EAEtE,MAAM,CAAEI,gBAAgB,EAAEC,YAAY,CAAE,GAAGT,OAAO,CAAE,MAAM;IACzD,IAAK,CAAEG,WAAW,CAACO,OAAO,EAAG;MAC5B,OAA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,CAACD,WAAW,GAC3BC,eAAe,CAACQ,WAAW,GAC3B,CAAC;UAEJ,IAAKb,IAAI,GAAGU,mBAAmB,CAACV,IAAI,GAAGoB,cAAc,EAAG;YACvDpB,IAAI,GAAGU,mBAAmB,CAACV,IAAI,GAAGoB,cAAc;UACjD;QACD;QAEA,IAAKpC,YAAY,KAAK,KAAK,EAAG;UAC7BkC,GAAG,GAAGD,IAAI,CAACC,GAAG;UACdC,MAAM,GAAGF,IAAI,CAACC,GAAG;QAClB,CAAC,MAAM;UACN;UACAA,GAAG,GAAGD,IAAI,CAACE,MAAM;UACjBA,MAAM,GAAGF,IAAI,CAACE,MAAM;QACrB;QAEA,MAAMhB,KAAK,GAAGF,qBAAqB,CAAEgB,IAAI,EAAEf,MAAO,CAAC;QACnD,MAAMmB,MAAM,GAAGF,MAAM,GAAGD,GAAG;QAE3B,OAAO,IAAII,MAAM,CAACC,OAAO,CAAEvB,IAAI,EAAEkB,GAAG,EAAEf,KAAK,EAAEkB,MAAO,CAAC;MACtD;IACD,CAAC;EACF,CAAC,EAAE,CACF7B,aAAa,EACbR,YAAY,EACZU,sBAAsB,EACtBO,qBAAqB,EACrBR,GAAG,CACF,CAAC;EAEH,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OACCgC,aAAA,CAAClD,OAAO;IACPmD,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAGX,aAAe;IACxBY,YAAY,EAAG,KAAO;IACtBC,SAAS,EAAC,uCAAuC;IACjDC,OAAO,EAAC;EAAU,GAElBL,aAAA;IACCV,KAAK,EAAGA,KAAO;IACfc,SAAS,EAAC;EAA6C,CACvD,CACO,CAAC;AAEZ"}
1
+ {"version":3,"names":["Popover","getScrollContainer","useCallback","useMemo","isRTL","ListViewDropIndicator","listViewRef","blockDropTarget","rootClientId","clientId","dropPosition","rootBlockElement","blockElement","current","_rootBlockElement","querySelector","undefined","_blockElement","targetElement","rtl","getDropIndicatorIndent","targetElementRect","rootBlockIconElement","rootBlockIconRect","getBoundingClientRect","right","left","getDropIndicatorWidth","indent","width","offsetWidth","scrollContainer","ownerDocument","windowScroll","body","documentElement","scrollContainerRect","distanceBetweenContainerAndTarget","scrollContainerWidth","clientWidth","style","popoverAnchor","isValidDropPosition","contextElement","rect","top","bottom","doc","scrollbarWidth","height","window","DOMRect","createElement","animate","anchor","focusOnMount","className","variant"],"sources":["@wordpress/block-editor/src/components/list-view/drop-indicator.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { getScrollContainer } from '@wordpress/dom';\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { isRTL } from '@wordpress/i18n';\n\nexport default function ListViewDropIndicator( {\n\tlistViewRef,\n\tblockDropTarget,\n} ) {\n\tconst { rootClientId, clientId, dropPosition } = blockDropTarget || {};\n\n\tconst [ rootBlockElement, blockElement ] = useMemo( () => {\n\t\tif ( ! listViewRef.current ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// The rootClientId will be defined whenever dropping into inner\n\t\t// block lists, but is undefined when dropping at the root level.\n\t\tconst _rootBlockElement = rootClientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ rootClientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\t// The clientId represents the sibling block, the dragged block will\n\t\t// usually be inserted adjacent to it. It will be undefined when\n\t\t// dropping a block into an empty block list.\n\t\tconst _blockElement = clientId\n\t\t\t? listViewRef.current.querySelector(\n\t\t\t\t\t`[data-block=\"${ clientId }\"]`\n\t\t\t )\n\t\t\t: undefined;\n\n\t\treturn [ _rootBlockElement, _blockElement ];\n\t}, [ rootClientId, clientId ] );\n\n\t// The targetElement is the element that the drop indicator will appear\n\t// before or after. When dropping into an empty block list, blockElement\n\t// is undefined, so the indicator will appear after the rootBlockElement.\n\tconst targetElement = blockElement || rootBlockElement;\n\n\tconst rtl = isRTL();\n\n\tconst getDropIndicatorIndent = useCallback(\n\t\t( targetElementRect ) => {\n\t\t\tif ( ! rootBlockElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Calculate the indent using the block icon of the root block.\n\t\t\t// Using a classname selector here might be flaky and could be\n\t\t\t// improved.\n\t\t\tconst rootBlockIconElement = rootBlockElement.querySelector(\n\t\t\t\t'.block-editor-block-icon'\n\t\t\t);\n\t\t\tconst rootBlockIconRect =\n\t\t\t\trootBlockIconElement.getBoundingClientRect();\n\t\t\treturn rtl\n\t\t\t\t? targetElementRect.right - rootBlockIconRect.left\n\t\t\t\t: rootBlockIconRect.right - targetElementRect.left;\n\t\t},\n\t\t[ rootBlockElement, rtl ]\n\t);\n\n\tconst getDropIndicatorWidth = useCallback(\n\t\t( targetElementRect, indent ) => {\n\t\t\tif ( ! targetElement ) {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// Default to assuming that the width of the drop indicator\n\t\t\t// should be the same as the target element.\n\t\t\tlet width = targetElement.offsetWidth;\n\n\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t// the width of the drop indicator should be the width of\n\t\t\t// the scroll container, minus the distance from the left\n\t\t\t// edge of the scroll container to the left edge of the\n\t\t\t// target element.\n\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\ttargetElement,\n\t\t\t\t'horizontal'\n\t\t\t);\n\n\t\t\tconst ownerDocument = targetElement.ownerDocument;\n\t\t\tconst windowScroll =\n\t\t\t\tscrollContainer === ownerDocument.body ||\n\t\t\t\tscrollContainer === ownerDocument.documentElement;\n\n\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\tconst distanceBetweenContainerAndTarget = isRTL()\n\t\t\t\t\t? scrollContainerRect.right - targetElementRect.right\n\t\t\t\t\t: targetElementRect.left - scrollContainerRect.left;\n\n\t\t\t\tconst scrollContainerWidth = scrollContainer.clientWidth;\n\n\t\t\t\tif (\n\t\t\t\t\tscrollContainerWidth <\n\t\t\t\t\twidth + distanceBetweenContainerAndTarget\n\t\t\t\t) {\n\t\t\t\t\twidth =\n\t\t\t\t\t\tscrollContainerWidth -\n\t\t\t\t\t\tdistanceBetweenContainerAndTarget;\n\t\t\t\t}\n\n\t\t\t\t// LTR logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\t! rtl &&\n\t\t\t\t\ttargetElementRect.left + indent < scrollContainerRect.left\n\t\t\t\t) {\n\t\t\t\t\twidth -= scrollContainerRect.left - targetElementRect.left;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\n\t\t\t\t// RTL logic for ensuring the drop indicator does not extend\n\t\t\t\t// beyond the right edge of the scroll container.\n\t\t\t\tif (\n\t\t\t\t\trtl &&\n\t\t\t\t\ttargetElementRect.right - indent > scrollContainerRect.right\n\t\t\t\t) {\n\t\t\t\t\twidth -=\n\t\t\t\t\t\ttargetElementRect.right - scrollContainerRect.right;\n\t\t\t\t\treturn width;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Subtract the indent from the final width of the indicator.\n\t\t\treturn width - indent;\n\t\t},\n\t\t[ rtl, targetElement ]\n\t);\n\n\tconst style = useMemo( () => {\n\t\tif ( ! targetElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst targetElementRect = targetElement.getBoundingClientRect();\n\t\tconst indent = getDropIndicatorIndent( targetElementRect );\n\n\t\treturn {\n\t\t\twidth: getDropIndicatorWidth( targetElementRect, indent ),\n\t\t};\n\t}, [ getDropIndicatorIndent, getDropIndicatorWidth, targetElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tconst isValidDropPosition =\n\t\t\tdropPosition === 'top' ||\n\t\t\tdropPosition === 'bottom' ||\n\t\t\tdropPosition === 'inside';\n\t\tif ( ! targetElement || ! isValidDropPosition ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tcontextElement: targetElement,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst rect = targetElement.getBoundingClientRect();\n\t\t\t\tconst indent = getDropIndicatorIndent( rect );\n\t\t\t\t// In RTL languages, the drop indicator should be positioned\n\t\t\t\t// to the left of the target element, with the width of the\n\t\t\t\t// indicator determining the indent at the right edge of the\n\t\t\t\t// target element. In LTR languages, the drop indicator should\n\t\t\t\t// end at the right edge of the target element, with the indent\n\t\t\t\t// added to the position of the left edge of the target element.\n\t\t\t\tlet left = rtl ? rect.left : rect.left + indent;\n\t\t\t\tlet top = 0;\n\t\t\t\tlet bottom = 0;\n\n\t\t\t\t// In deeply nested lists, where a scrollbar is present,\n\t\t\t\t// the width of the drop indicator should be the width of\n\t\t\t\t// the visible area of the scroll container. Additionally,\n\t\t\t\t// the left edge of the drop indicator line needs to be\n\t\t\t\t// offset by the distance the left edge of the target element\n\t\t\t\t// and the left edge of the scroll container. The ensures\n\t\t\t\t// that the drop indicator position never breaks out of the\n\t\t\t\t// visible area of the scroll container.\n\t\t\t\tconst scrollContainer = getScrollContainer(\n\t\t\t\t\ttargetElement,\n\t\t\t\t\t'horizontal'\n\t\t\t\t);\n\n\t\t\t\tconst doc = targetElement.ownerDocument;\n\t\t\t\tconst windowScroll =\n\t\t\t\t\tscrollContainer === doc.body ||\n\t\t\t\t\tscrollContainer === doc.documentElement;\n\n\t\t\t\t// If the scroll container is not the window, offset the left position, if need be.\n\t\t\t\tif ( scrollContainer && ! windowScroll ) {\n\t\t\t\t\tconst scrollContainerRect =\n\t\t\t\t\t\tscrollContainer.getBoundingClientRect();\n\n\t\t\t\t\t// In RTL languages, a vertical scrollbar is present on the\n\t\t\t\t\t// left edge of the scroll container. The width of the\n\t\t\t\t\t// scrollbar needs to be accounted for when positioning the\n\t\t\t\t\t// drop indicator.\n\t\t\t\t\tconst scrollbarWidth = rtl\n\t\t\t\t\t\t? scrollContainer.offsetWidth -\n\t\t\t\t\t\t scrollContainer.clientWidth\n\t\t\t\t\t\t: 0;\n\n\t\t\t\t\tif ( left < scrollContainerRect.left + scrollbarWidth ) {\n\t\t\t\t\t\tleft = scrollContainerRect.left + scrollbarWidth;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif ( dropPosition === 'top' ) {\n\t\t\t\t\ttop = rect.top;\n\t\t\t\t\tbottom = rect.top;\n\t\t\t\t} else {\n\t\t\t\t\t// `dropPosition` is either `bottom` or `inside`\n\t\t\t\t\ttop = rect.bottom;\n\t\t\t\t\tbottom = rect.bottom;\n\t\t\t\t}\n\n\t\t\t\tconst width = getDropIndicatorWidth( rect, indent );\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t};\n\t}, [\n\t\ttargetElement,\n\t\tdropPosition,\n\t\tgetDropIndicatorIndent,\n\t\tgetDropIndicatorWidth,\n\t\trtl,\n\t] );\n\n\tif ( ! targetElement ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\n\t\t\tclassName=\"block-editor-list-view-drop-indicator\"\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div\n\t\t\t\tstyle={ style }\n\t\t\t\tclassName=\"block-editor-list-view-drop-indicator__line\"\n\t\t\t/>\n\t\t</Popover>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,kBAAkB,QAAQ,gBAAgB;AACnD,SAASC,WAAW,EAAEC,OAAO,QAAQ,oBAAoB;AACzD,SAASC,KAAK,QAAQ,iBAAiB;AAEvC,eAAe,SAASC,qBAAqBA,CAAE;EAC9CC,WAAW;EACXC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,YAAY;IAAEC,QAAQ;IAAEC;EAAa,CAAC,GAAGH,eAAe,IAAI,CAAC,CAAC;EAEtE,MAAM,CAAEI,gBAAgB,EAAEC,YAAY,CAAE,GAAGT,OA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AACP,qBAAqB,CAAC,CAAC;;UAExC;UACA;UACA;UACA;UACA,MAAMwB,cAAc,GAAG7B,GAAG,GACvBY,eAAe,CAACD,WAAW,GAC3BC,eAAe,CAACQ,WAAW,GAC3B,CAAC;UAEJ,IAAKb,IAAI,GAAGU,mBAAmB,CAACV,IAAI,GAAGsB,cAAc,EAAG;YACvDtB,IAAI,GAAGU,mBAAmB,CAACV,IAAI,GAAGsB,cAAc;UACjD;QACD;QAEA,IAAKtC,YAAY,KAAK,KAAK,EAAG;UAC7BmC,GAAG,GAAGD,IAAI,CAACC,GAAG;UACdC,MAAM,GAAGF,IAAI,CAACC,GAAG;QAClB,CAAC,MAAM;UACN;UACAA,GAAG,GAAGD,IAAI,CAACE,MAAM;UACjBA,MAAM,GAAGF,IAAI,CAACE,MAAM;QACrB;QAEA,MAAMjB,KAAK,GAAGF,qBAAqB,CAAEiB,IAAI,EAAEhB,MAAO,CAAC;QACnD,MAAMqB,MAAM,GAAGH,MAAM,GAAGD,GAAG;QAE3B,OAAO,IAAIK,MAAM,CAACC,OAAO,CAAEzB,IAAI,EAAEmB,GAAG,EAAEhB,KAAK,EAAEoB,MAAO,CAAC;MACtD;IACD,CAAC;EACF,CAAC,EAAE,CACF/B,aAAa,EACbR,YAAY,EACZU,sBAAsB,EACtBO,qBAAqB,EACrBR,GAAG,CACF,CAAC;EAEH,IAAK,CAAED,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OACCkC,aAAA,CAACpD,OAAO;IACPqD,OAAO,EAAG,KAAO;IACjBC,MAAM,EAAGb,aAAe;IACxBc,YAAY,EAAG,KAAO;IACtBC,SAAS,EAAC,uCAAuC;IACjDC,OAAO,EAAC;EAAU,GAElBL,aAAA;IACCZ,KAAK,EAAGA,KAAO;IACfgB,SAAS,EAAC;EAA6C,CACvD,CACO,CAAC;AAEZ"}
@@ -138,14 +138,6 @@ function ListViewComponent({
138
138
  useEffect(() => {
139
139
  isMounted.current = true;
140
140
  }, []);
141
-
142
- // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
143
- // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
144
- // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
145
- const [fixedListWindow] = useFixedWindowList(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
146
- useWindowing: true,
147
- windowOverscan: 40
148
- });
149
141
  const expand = useCallback(clientId => {
150
142
  if (!clientId) {
151
143
  return;
@@ -189,6 +181,20 @@ function ListViewComponent({
189
181
  treeGridElementRef: elementRef
190
182
  }), [draggedClientIds, expandedState, expand, collapse, BlockSettingsMenu, instanceId, AdditionalBlockContent, insertedBlock, setInsertedBlock]);
191
183
 
184
+ // List View renders a fixed number of items and relies on each having a fixed item height of 36px.
185
+ // If this value changes, we should also change the itemHeight value set in useFixedWindowList.
186
+ // See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.
187
+ const [fixedListWindow] = useFixedWindowList(elementRef, BLOCK_LIST_ITEM_HEIGHT, visibleBlockCount, {
188
+ // Ensure that the windowing logic is recalculated when the expanded state changes.
189
+ // This is necessary because expanding a collapsed block in a short list view can
190
+ // switch the list view to a tall list view with a scrollbar, and vice versa.
191
+ // When this happens, the windowing logic needs to be recalculated to ensure that
192
+ // the correct number of blocks are rendered, by rechecking for a scroll container.
193
+ expandedState,
194
+ useWindowing: true,
195
+ windowOverscan: 40
196
+ });
197
+
192
198
  // If there are no blocks to show and we're not showing the appender, do not render the list view.
193
199
  if (!clientIdsTree.length && !showAppender) {
194
200
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["useInstanceId","useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","useState","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","blocks","dropZoneElement","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","description","onSelect","additionalBlockContent","AdditionalBlockContent","ref","since","alternative","instanceId","clientIdsTree","draggedClientIds","selectedClientIds","getBlock","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","insertedBlock","setInsertedBlock","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","focusPosition","current","fixedListWindow","useWindowing","windowOverscan","expand","clientId","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted","listViewInstanceId","treeGridElementRef","createElement","value","listViewRef","className","onCollapseRow","onExpandRow","onFocusRow","applicationAriaLabel","Provider","parentId","selectBlock","PrivateListView","props","undefined"],"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?HTMLElement} props.dropZoneElement Optional element to be used as the drop zone.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.\n * @param {?ComponentType} props.additionalBlockContent Component that renders additional block content UI.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tdropZoneElement,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t\tdescription,\n\t\tonSelect,\n\t\tadditionalBlockContent: AdditionalBlockContent,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst instanceId = useInstanceId( ListViewComponent );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t} );\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\n\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t/**\n\t\t * @param {MouseEvent | KeyboardEvent | undefined} event\n\t\t * @param {string} blockClientId\n\t\t * @param {null | undefined | -1 | 1} focusPosition\n\t\t */\n\t\t( event, blockClientId, focusPosition ) => {\n\t\t\tupdateBlockSelection( event, blockClientId, null, focusPosition );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tlistViewInstanceId: instanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\ttreeGridElementRef: elementRef,\n\t\t} ),\n\t\t[\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t]\n\t);\n\n\t// If there are no blocks to show and we're not showing the appender, do not render the list view.\n\tif ( ! clientIdsTree.length && ! showAppender ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\taria-description={ description }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\n\n// This is the private API for the ListView component.\n// It allows access to all props, not just the public ones.\nexport const PrivateListView = forwardRef( ListViewComponent );\n\n// This is the public API for the ListView component.\n// We wrap the PrivateListView component to hide some props from the public API.\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\trootClientId={ null }\n\t\t\tonSelect={ null }\n\t\t\tadditionalBlockContent={ null }\n\t\t\tblockSettingsMenu={ undefined }\n\t\t/>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,gCAAgC,IAAIC,kBAAkB,QAChD,oBAAoB;AAC3B,SAASC,sBAAsB,IAAIC,QAAQ,QAAQ,uBAAuB;AAC1E,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,iBAAiB;AAC9D,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SACCC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,UAAU;A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BAAsB,EAAG,IAAM;IAC/BL,iBAAiB,EAAGyE;EAAW,CAC/B,CAAC;AAEJ,CAAE,CAAC"}
1
+ {"version":3,"names":["useInstanceId","useMergeRefs","__experimentalUseFixedWindowList","useFixedWindowList","__experimentalTreeGrid","TreeGrid","AsyncModeProvider","useSelect","deprecated","useCallback","useEffect","useMemo","useRef","useReducer","forwardRef","useState","__","ListViewBranch","ListViewContext","ListViewDropIndicator","useBlockSelection","useListViewClientIds","useListViewDropZone","useListViewExpandSelectedItem","store","blockEditorStore","BlockSettingsDropdown","expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListViewComponent","blocks","dropZoneElement","showBlockMovers","isExpanded","showAppender","blockSettingsMenu","BlockSettingsMenu","rootClientId","description","onSelect","additionalBlockContent","AdditionalBlockContent","ref","since","alternative","instanceId","clientIdsTree","draggedClientIds","selectedClientIds","getBlock","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","insertedBlock","setInsertedBlock","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","blockClientId","focusPosition","current","expand","clientId","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted","listViewInstanceId","treeGridElementRef","fixedListWindow","useWindowing","windowOverscan","createElement","value","listViewRef","className","onCollapseRow","onExpandRow","onFocusRow","applicationAriaLabel","Provider","parentId","selectBlock","PrivateListView","props","undefined"],"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockSettingsDropdown } from '../block-settings-menu/block-settings-dropdown';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/** @typedef {import('react').ComponentType} ComponentType */\n/** @typedef {import('react').Ref<HTMLElement>} Ref */\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks _deprecated_ Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {?HTMLElement} props.dropZoneElement Optional element to be used as the drop zone.\n * @param {?boolean} props.showBlockMovers Flag to enable block movers. Defaults to `false`.\n * @param {?boolean} props.isExpanded Flag to determine whether nested levels are expanded by default. Defaults to `false`.\n * @param {?boolean} props.showAppender Flag to show or hide the block appender. Defaults to `false`.\n * @param {?ComponentType} props.blockSettingsMenu Optional more menu substitution. Defaults to the standard `BlockSettingsDropdown` component.\n * @param {string} props.rootClientId The client id of the root block from which we determine the blocks to show in the list.\n * @param {string} props.description Optional accessible description for the tree grid component.\n * @param {?Function} props.onSelect Optional callback to be invoked when a block is selected. Receives the block object that was selected.\n * @param {?ComponentType} props.additionalBlockContent Component that renders additional block content UI.\n * @param {Ref} ref Forwarded ref\n */\nfunction ListViewComponent(\n\t{\n\t\tid,\n\t\tblocks,\n\t\tdropZoneElement,\n\t\tshowBlockMovers = false,\n\t\tisExpanded = false,\n\t\tshowAppender = false,\n\t\tblockSettingsMenu: BlockSettingsMenu = BlockSettingsDropdown,\n\t\trootClientId,\n\t\tdescription,\n\t\tonSelect,\n\t\tadditionalBlockContent: AdditionalBlockContent,\n\t},\n\tref\n) {\n\t// This can be removed once we no longer need to support the blocks prop.\n\tif ( blocks ) {\n\t\tdeprecated(\n\t\t\t'`blocks` property in `wp.blockEditor.__experimentalListView`',\n\t\t\t{\n\t\t\t\tsince: '6.3',\n\t\t\t\talternative: '`rootClientId` property',\n\t\t\t}\n\t\t);\n\t}\n\n\tconst instanceId = useInstanceId( ListViewComponent );\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( { blocks, rootClientId } );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t} );\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\n\tconst [ insertedBlock, setInsertedBlock ] = useState( null );\n\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t/**\n\t\t * @param {MouseEvent | KeyboardEvent | undefined} event\n\t\t * @param {string} blockClientId\n\t\t * @param {null | undefined | -1 | 1} focusPosition\n\t\t */\n\t\t( event, blockClientId, focusPosition ) => {\n\t\t\tupdateBlockSelection( event, blockClientId, null, focusPosition );\n\t\t\tsetSelectedTreeId( blockClientId );\n\t\t\tif ( onSelect ) {\n\t\t\t\tonSelect( getBlock( blockClientId ) );\n\t\t\t}\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection, onSelect, getBlock ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tlistViewInstanceId: instanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\ttreeGridElementRef: elementRef,\n\t\t} ),\n\t\t[\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t]\n\t);\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\t// Ensure that the windowing logic is recalculated when the expanded state changes.\n\t\t\t// This is necessary because expanding a collapsed block in a short list view can\n\t\t\t// switch the list view to a tall list view with a scrollbar, and vice versa.\n\t\t\t// When this happens, the windowing logic needs to be recalculated to ensure that\n\t\t\t// the correct number of blocks are rendered, by rechecking for a scroll container.\n\t\t\texpandedState,\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\t// If there are no blocks to show and we're not showing the appender, do not render the list view.\n\tif ( ! clientIdsTree.length && ! showAppender ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t\t// eslint-disable-next-line jsx-a11y/aria-props\n\t\t\t\taria-description={ description }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tparentId={ rootClientId }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t\tshowAppender={ showAppender }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\n\n// This is the private API for the ListView component.\n// It allows access to all props, not just the public ones.\nexport const PrivateListView = forwardRef( ListViewComponent );\n\n// This is the public API for the ListView component.\n// We wrap the PrivateListView component to hide some props from the public API.\nexport default forwardRef( ( props, ref ) => {\n\treturn (\n\t\t<PrivateListView\n\t\t\tref={ ref }\n\t\t\t{ ...props }\n\t\t\tshowAppender={ false }\n\t\t\trootClientId={ null }\n\t\t\tonSelect={ null }\n\t\t\tadditionalBlockContent={ null }\n\t\t\tblockSettingsMenu={ undefined }\n\t\t/>\n\t);\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,YAAY,EACZC,gCAAgC,IAAIC,kBAAkB,QAChD,oBAAoB;AAC3B,SAASC,sBAAsB,IAAIC,QAAQ,QAAQ,uBAAuB;AAC1E,SAASC,iBAAiB,EAAEC,SAAS,QAAQ,iBAAiB;AAC9D,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SACCC,WAAW,EACXC,SAAS,EACTC,OAAO,EACPC,MAAM,EACNC,UAAU,EACVC,UAAU,EACVC,QAAQ,QACF,oBAAoB;AAC3B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,cAAc,MAAM,UAAU;AACrC,SAASC,eAAe,QAAQ,WAAW;AAC3C,OAAOC,qBAAqB,MAAM,kBAAkB;AACpD,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,oBAAoB,MAAM,4BAA4B;AAC7D,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,OAAOC,6BAA6B,MAAM,sCAAsC;AAChF,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,qBAAqB,QAAQ,gDAAgD;AAEtF,MAAMC,QAAQ,GAAGA,CAAEC,KAAK,EAAEC,MAAM,KAAM;EACrC,IAAKC,KAAK,CAACC,OAAO,CAAEF,MAAM,CAACG,SAAU,CAAC,EAAG;IACxC,OAAO;MACN,GAAGJ,KAAK;MACR,GAAGC,MAAM,CAACG,SAAS,CAACC,MAAM,CACzB,CAAEC,QAAQ,EAAEC,EAAE,MAAQ;QACrB,GAAGD,QAAQ;QACX,CAAEC,EAAE,GAAIN,MAAM,CAACO,IAAI,KAAK;MACzB,CAAC,CAAE,EACH,CAAC,CACF;IACD,CAAC;EACF;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sB,MAAM,EAAGgB,aAAe;IACxB0D,QAAQ,EAAGnE,YAAc;IACzBoE,WAAW,EAAGlC,iBAAmB;IACjCvC,eAAe,EAAGA,eAAiB;IACnC4D,eAAe,EAAGA,eAAiB;IACnC5C,iBAAiB,EAAGA,iBAAmB;IACvCf,UAAU,EAAGA,UAAY;IACzBkB,qBAAqB,EAAGA,qBAAuB;IAC/CjB,YAAY,EAAGA;EAAc,CAC7B,CACwB,CACjB,CACQ,CAAC;AAEtB;;AAEA;AACA;AACA,OAAO,MAAMwE,eAAe,GAAGrG,UAAU,CAAEwB,iBAAkB,CAAC;;AAE9D;AACA;AACA,eAAexB,UAAU,CAAE,CAAEsG,KAAK,EAAEjE,GAAG,KAAM;EAC5C,OACCqD,aAAA,CAACW,eAAe;IACfhE,GAAG,EAAGA,GAAK;IAAA,GACNiE,KAAK;IACVzE,YAAY,EAAG,KAAO;IACtBG,YAAY,EAAG,IAAM;IACrBE,QAAQ,EAAG,IAAM;IACjBC,sBAAsB,EAAG,IAAM;IAC/BL,iBAAiB,EAAGyE;EAAW,CAC/B,CAAC;AAEJ,CAAE,CAAC"}
@@ -11,14 +11,15 @@ import { store as blockEditorStore } from '../../store';
11
11
 
12
12
  // Maximum number of images to display in a list view row.
13
13
  const MAX_IMAGES = 3;
14
- function getImageUrl(block) {
14
+ function getImage(block) {
15
15
  if (block.name !== 'core/image') {
16
16
  return;
17
17
  }
18
18
  if (block.attributes?.url) {
19
19
  return {
20
20
  url: block.attributes.url,
21
- alt: block.attributes.alt
21
+ alt: block.attributes.alt,
22
+ clientId: block.clientId
22
23
  };
23
24
  }
24
25
  }
@@ -28,7 +29,7 @@ function getImagesFromGallery(block) {
28
29
  }
29
30
  const images = [];
30
31
  for (const innerBlock of block.innerBlocks) {
31
- const img = getImageUrl(innerBlock);
32
+ const img = getImage(innerBlock);
32
33
  if (img) {
33
34
  images.push(img);
34
35
  }
@@ -39,7 +40,7 @@ function getImagesFromGallery(block) {
39
40
  return images;
40
41
  }
41
42
  function getImagesFromBlock(block, isExpanded) {
42
- const img = getImageUrl(block);
43
+ const img = getImage(block);
43
44
  if (img) {
44
45
  return [img];
45
46
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","useSelect","store","blockEditorStore","MAX_IMAGES","getImageUrl","block","name","attributes","url","alt","getImagesFromGallery","innerBlocks","images","innerBlock","img","push","length","getImagesFromBlock","isExpanded","useListViewImages","clientId","select","_block","getBlock"],"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-images.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n// Maximum number of images to display in a list view row.\nconst MAX_IMAGES = 3;\n\nfunction getImageUrl( block ) {\n\tif ( block.name !== 'core/image' ) {\n\t\treturn;\n\t}\n\n\tif ( block.attributes?.url ) {\n\t\treturn { url: block.attributes.url, alt: block.attributes.alt };\n\t}\n}\n\nfunction getImagesFromGallery( block ) {\n\tif ( block.name !== 'core/gallery' || ! block.innerBlocks ) {\n\t\treturn [];\n\t}\n\n\tconst images = [];\n\n\tfor ( const innerBlock of block.innerBlocks ) {\n\t\tconst img = getImageUrl( innerBlock );\n\t\tif ( img ) {\n\t\t\timages.push( img );\n\t\t}\n\t\tif ( images.length >= MAX_IMAGES ) {\n\t\t\treturn images;\n\t\t}\n\t}\n\n\treturn images;\n}\n\nfunction getImagesFromBlock( block, isExpanded ) {\n\tconst img = getImageUrl( block );\n\tif ( img ) {\n\t\treturn [ img ];\n\t}\n\treturn isExpanded ? [] : getImagesFromGallery( block );\n}\n\n/**\n * Get a block's preview images for display within a list view row.\n *\n * TODO: Currently only supports images from the core/image and core/gallery\n * blocks. This should be expanded to support other blocks that have images,\n * potentially via an API that blocks can opt into / provide their own logic.\n *\n * @param {Object} props Hook properties.\n * @param {string} props.clientId The block's clientId.\n * @param {boolean} props.isExpanded Whether or not the block is expanded in the list view.\n * @return {Array} Images.\n */\nexport default function useListViewImages( { clientId, isExpanded } ) {\n\tconst { block } = useSelect(\n\t\t( select ) => {\n\t\t\tconst _block = select( blockEditorStore ).getBlock( clientId );\n\t\t\treturn { block: _block };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst images = useMemo( () => {\n\t\treturn getImagesFromBlock( block, isExpanded );\n\t}, [ block, isExpanded ] );\n\n\treturn images;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA,MAAMC,UAAU,GAAG,CAAC;AAEpB,SAASC,WAAWA,CAAEC,KAAK,EAAG;EAC7B,IAAKA,KAAK,CAACC,IAAI,KAAK,YAAY,EAAG;IAClC;EACD;EAEA,IAAKD,KAAK,CAACE,UAAU,EAAEC,GAAG,EAAG;IAC5B,OAAO;MAAEA,GAAG,EAAEH,KAAK,CAACE,UAAU,CAACC,GAAG;MAAEC,GAAG,EAAEJ,KAAK,CAACE,UAAU,CAACE;IAAI,CAAC;EAChE;AACD;AAEA,SAASC,oBAAoBA,CAAEL,KAAK,EAAG;EACtC,IAAKA,KAAK,CAACC,IAAI,KAAK,cAAc,IAAI,CAAED,KAAK,CAACM,WAAW,EAAG;IAC3D,OAAO,EAAE;EACV;EAEA,MAAMC,MAAM,GAAG,EAAE;EAEjB,KAAM,MAAMC,UAAU,IAAIR,KAAK,CAACM,WAAW,EAAG;IAC7C,MAAMG,GAAG,GAAGV,WAAW,CAAES,UAAW,CAAC;IACrC,IAAKC,GAAG,EAAG;MACVF,MAAM,CAACG,IAAI,CAAED,GAAI,CAAC;IACnB;IACA,IAAKF,MAAM,CAACI,MAAM,IAAIb,UAAU,EAAG;MAClC,OAAOS,MAAM;IACd;EACD;EAEA,OAAOA,MAAM;AACd;AAEA,SAASK,kBAAkBA,CAAEZ,KAAK,EAAEa,UAAU,EAAG;EAChD,MAAMJ,GAAG,GAAGV,WAAW,CAAEC,KAAM,CAAC;EAChC,IAAKS,GAAG,EAAG;IACV,OAAO,CAAEA,GAAG,CAAE;EACf;EACA,OAAOI,UAAU,GAAG,EAAE,GAAGR,oBAAoB,CAAEL,KAAM,CAAC;AACvD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASc,iBAAiBA,CAAE;EAAEC,QAAQ;EAAEF;AAAW,CAAC,EAAG;EACrE,MAAM;IAAEb;EAAM,CAAC,GAAGL,SAAS,CACxBqB,MAAM,IAAM;IACb,MAAMC,MAAM,GAAGD,MAAM,CAAEnB,gBAAiB,CAAC,CAACqB,QAAQ,CAAEH,QAAS,CAAC;IAC9D,OAAO;MAAEf,KAAK,EAAEiB;IAAO,CAAC;EACzB,CAAC,EACD,CAAEF,QAAQ,CACX,CAAC;EAED,MAAMR,MAAM,GAAGb,OAAO,CAAE,MAAM;IAC7B,OAAOkB,kBAAkB,CAAEZ,KAAK,EAAEa,UAAW,CAAC;EAC/C,CAAC,EAAE,CAAEb,KAAK,EAAEa,UAAU,CAAG,CAAC;EAE1B,OAAON,MAAM;AACd"}
1
+ {"version":3,"names":["useMemo","useSelect","store","blockEditorStore","MAX_IMAGES","getImage","block","name","attributes","url","alt","clientId","getImagesFromGallery","innerBlocks","images","innerBlock","img","push","length","getImagesFromBlock","isExpanded","useListViewImages","select","_block","getBlock"],"sources":["@wordpress/block-editor/src/components/list-view/use-list-view-images.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n// Maximum number of images to display in a list view row.\nconst MAX_IMAGES = 3;\n\nfunction getImage( block ) {\n\tif ( block.name !== 'core/image' ) {\n\t\treturn;\n\t}\n\n\tif ( block.attributes?.url ) {\n\t\treturn {\n\t\t\turl: block.attributes.url,\n\t\t\talt: block.attributes.alt,\n\t\t\tclientId: block.clientId,\n\t\t};\n\t}\n}\n\nfunction getImagesFromGallery( block ) {\n\tif ( block.name !== 'core/gallery' || ! block.innerBlocks ) {\n\t\treturn [];\n\t}\n\n\tconst images = [];\n\n\tfor ( const innerBlock of block.innerBlocks ) {\n\t\tconst img = getImage( innerBlock );\n\t\tif ( img ) {\n\t\t\timages.push( img );\n\t\t}\n\t\tif ( images.length >= MAX_IMAGES ) {\n\t\t\treturn images;\n\t\t}\n\t}\n\n\treturn images;\n}\n\nfunction getImagesFromBlock( block, isExpanded ) {\n\tconst img = getImage( block );\n\tif ( img ) {\n\t\treturn [ img ];\n\t}\n\treturn isExpanded ? [] : getImagesFromGallery( block );\n}\n\n/**\n * Get a block's preview images for display within a list view row.\n *\n * TODO: Currently only supports images from the core/image and core/gallery\n * blocks. This should be expanded to support other blocks that have images,\n * potentially via an API that blocks can opt into / provide their own logic.\n *\n * @param {Object} props Hook properties.\n * @param {string} props.clientId The block's clientId.\n * @param {boolean} props.isExpanded Whether or not the block is expanded in the list view.\n * @return {Array} Images.\n */\nexport default function useListViewImages( { clientId, isExpanded } ) {\n\tconst { block } = useSelect(\n\t\t( select ) => {\n\t\t\tconst _block = select( blockEditorStore ).getBlock( clientId );\n\t\t\treturn { block: _block };\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst images = useMemo( () => {\n\t\treturn getImagesFromBlock( block, isExpanded );\n\t}, [ block, isExpanded ] );\n\n\treturn images;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;;AAEvD;AACA,MAAMC,UAAU,GAAG,CAAC;AAEpB,SAASC,QAAQA,CAAEC,KAAK,EAAG;EAC1B,IAAKA,KAAK,CAACC,IAAI,KAAK,YAA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,OAAO;MAAEL,KAAK,EAAEiB;IAAO,CAAC;EACzB,CAAC,EACD,CAAEZ,QAAQ,CACX,CAAC;EAED,MAAMG,MAAM,GAAGd,OAAO,CAAE,MAAM;IAC7B,OAAOmB,kBAAkB,CAAEb,KAAK,EAAEc,UAAW,CAAC;EAC/C,CAAC,EAAE,CAAEd,KAAK,EAAEc,UAAU,CAAG,CAAC;EAE1B,OAAON,MAAM;AACd"}
@@ -29,6 +29,7 @@ export default function PreviewOptions({
29
29
  const toggleProps = {
30
30
  className: 'block-editor-post-preview__button-toggle',
31
31
  disabled: !isEnabled,
32
+ __experimentalIsFocusable: !isEnabled,
32
33
  children: viewLabel
33
34
  };
34
35
  const menuProps = {
@@ -45,7 +46,8 @@ export default function PreviewOptions({
45
46
  toggleProps: toggleProps,
46
47
  menuProps: menuProps,
47
48
  icon: deviceIcons[deviceType.toLowerCase()],
48
- label: label || __('Preview')
49
+ label: label || __('Preview'),
50
+ disableOpenOnArrowDown: !isEnabled
49
51
  }, renderProps => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
50
52
  className: "block-editor-post-preview__button-resize",
51
53
  onClick: () => setDeviceType('Desktop'),
@@ -1 +1 @@
1
- {"version":3,"names":["classnames","useViewportMatch","DropdownMenu","MenuGroup","MenuItem","__","check","desktop","mobile","tablet","PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","label","isMobile","popoverProps","placement","toggleProps","disabled","menuProps","deviceIcons","createElement","icon","toLowerCase","renderProps","Fragment","onClick"],"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tviewLabel,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n\tlabel,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\tchildren: viewLabel,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ label || __( 'Preview' ) }\n\t\t>\n\t\t\t{ ( renderProps ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ children( renderProps ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,QAAQ,kBAAkB;AAEjE,eAAe,SAASC,cAAcA,CAAE;EACvCC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC,SAAS,GAAG,IAAI;EAChBC,UAAU;EACVC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAGjB,gBAAgB,CAAE,OAAO,EAAE,GAAI,CAAC;EACjD,IAAKiB,QAAQ,EAAG,OAAO,IAAI;EAE3B,MAAMC,YAAY,GAAG;IACpBN,SAAS,EAAEb,UAAU,CACpBa,SAAS,EACT,6CACD,CAAC;IACDO,SAAS,EAAE;EACZ,CAAC;EACD,MAAMC,WAAW,GAAG;IACnBR,SAAS,EAAE,0CAA0C;IACrDS,QAAQ,EAAE,CAAER,SAAS;IACrBH,QAAQ,EAAEC;EACX,CAAC;EACD,MAAMW,SAAS,GAAG;IACjB,YAAY,EAAElB,EAAE,CAAE,cAAe;EAClC,CAAC;EAED,MAAMmB,WAAW,GAAG;IACnBhB,MAAM;IACNC,MAAM;IACNF;EACD,CAAC;EAED,OACCkB,aAAA,CAACvB,YAAY;IACZW,SAAS,EAAC,qCAAqC;IAC/CM,YAAY,EAAGA,YAAc;IAC7BE,WAAW,EAAGA,WAAa;IAC3BE,SAAS,EAAGA,SAAW;IACvBG,IAAI,EAAGF,WAAW,CAAET,UAAU,CAACY,WAAW,CAAC,CAAC,CAAI;IAChDV,KAAK,EAAGA,KAAK,IAAIZ,EAAE,CAAE,SAAU;EAAG,GAE9BuB,WAAW,IACdH,aAAA,CAAAI,QAAA,QACCJ,aAAA,CAACtB,SAAS,QACTsB,aAAA,CAACrB,QAAQ;IACRS,SAAS,EAAC,0CAA0C;IACpDiB,OAAO,EAAGA,CAAA,KAAMd,aAAa,CAAE,SAAU,CAAG;IAC5CU,IAAI,EAAGX,UAAU,KAAK,SAAS,IAAIT;EAAO,GAExCD,EAAE,CAAE,SAAU,CACP,CAAC,EACXoB,aAAA,CAACrB,QAAQ;IACRS,SAAS,EAAC,0CAA0C;IACpDiB,OAAO,EAAGA,CAAA,KAAMd,aAAa,CAAE,QAAS,CAAG;IAC3CU,IAAI,EAAGX,UAAU,KAAK,QAAQ,IAAIT;EAAO,GAEvCD,EAAE,CAAE,QAAS,CACN,CAAC,EACXoB,aAAA,CAACrB,QAAQ;IACRS,SAAS,EAAC,0CAA0C;IACpDiB,OAAO,EAAGA,CAAA,KAAMd,aAAa,CAAE,QAAS,CAAG;IAC3CU,IAAI,EAAGX,UAAU,KAAK,QAAQ,IAAIT;EAAO,GAEvCD,EAAE,CAAE,QAAS,CACN,CACA,CAAC,EACVM,QAAQ,CAAEiB,WAAY,CACvB,CAEU,CAAC;AAEjB"}
1
+ {"version":3,"names":["classnames","useViewportMatch","DropdownMenu","MenuGroup","MenuItem","__","check","desktop","mobile","tablet","PreviewOptions","children","viewLabel","className","isEnabled","deviceType","setDeviceType","label","isMobile","popoverProps","placement","toggleProps","disabled","__experimentalIsFocusable","menuProps","deviceIcons","createElement","icon","toLowerCase","disableOpenOnArrowDown","renderProps","Fragment","onClick"],"sources":["@wordpress/block-editor/src/components/preview-options/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet } from '@wordpress/icons';\n\nexport default function PreviewOptions( {\n\tchildren,\n\tviewLabel,\n\tclassName,\n\tisEnabled = true,\n\tdeviceType,\n\tsetDeviceType,\n\tlabel,\n} ) {\n\tconst isMobile = useViewportMatch( 'small', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tclassName: classnames(\n\t\t\tclassName,\n\t\t\t'block-editor-post-preview__dropdown-content'\n\t\t),\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'block-editor-post-preview__button-toggle',\n\t\tdisabled: ! isEnabled,\n\t\t__experimentalIsFocusable: ! isEnabled,\n\t\tchildren: viewLabel,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"block-editor-post-preview__dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ label || __( 'Preview' ) }\n\t\t\tdisableOpenOnArrowDown={ ! isEnabled }\n\t\t>\n\t\t\t{ ( renderProps ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tclassName=\"block-editor-post-preview__button-resize\"\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ children( renderProps ) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,YAAY,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,uBAAuB;AACzE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,QAAQ,kBAAkB;AAEjE,eAAe,SAASC,cAAcA,CAAE;EACvCC,QAAQ;EACRC,SAAS;EACTC,SAAS;EACTC,SAAS,GAAG,IAAI;EAChBC,UAAU;EACVC,aAAa;EACbC;AACD,CAAC,EAAG;EACH,MAAMC,QAAQ,GAAGjB,gBAAgB,CAAE,OAAO,EAAE,GAAI,CAAC;EACjD,IAAKiB,QAAQ,EAAG,OAAO,IAAI;EAE3B,MAAMC,YAAY,GAAG;IACpBN,SAAS,EAAEb,UAAU,CACpB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E,QAAS,CAAG;IAC3CW,IAAI,EAAGZ,UAAU,KAAK,QAAQ,IAAIT;EAAO,GAEvCD,EAAE,CAAE,QAAS,CACN,CACA,CAAC,EACVM,QAAQ,CAAEmB,WAAY,CACvB,CAEU,CAAC;AAEjB"}
@@ -4,6 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  */
5
5
  import { useDispatch } from '@wordpress/data';
6
6
  import { useEffect } from '@wordpress/element';
7
+ import { SlotFillProvider } from '@wordpress/components';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -13,6 +14,7 @@ import useBlockSync from './use-block-sync';
13
14
  import { store as blockEditorStore } from '../../store';
14
15
  import { BlockRefsProvider } from './block-refs-provider';
15
16
  import { unlock } from '../../lock-unlock';
17
+ import KeyboardShortcuts from '../keyboard-shortcuts';
16
18
 
17
19
  /** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */
18
20
 
@@ -37,7 +39,7 @@ export const ExperimentalBlockEditorProvider = withRegistryProvider(props => {
37
39
 
38
40
  // Syncs the entity provider with changes in the block-editor store.
39
41
  useBlockSync(props);
40
- return createElement(BlockRefsProvider, null, children);
42
+ return createElement(SlotFillProvider, null, createElement(KeyboardShortcuts.Register, null), createElement(BlockRefsProvider, null, children));
41
43
  });
42
44
  export const BlockEditorProvider = props => {
43
45
  return createElement(ExperimentalBlockEditorProvider, {
@@ -1 +1 @@
1
- {"version":3,"names":["useDispatch","useEffect","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","unlock","ExperimentalBlockEditorProvider","props","children","settings","stripExperimentalSettings","__experimentalUpdateSettings","__internalIsInitialized","reset","createElement","BlockEditorProvider"],"sources":["@wordpress/block-editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst { children, settings, stripExperimentalSettings = false } = props;\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\treturn <BlockRefsProvider>{ children }</BlockRefsProvider>;\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\t{ ...props }\n\t\t\tstripExperimentalSettings={ true }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,oBAAoB;;AAE9C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,MAAM,QAAQ,mBAAmB;;AAE1C;;AAEA,OAAO,MAAMC,+BAA+B,GAAGN,oBAAoB,CAChEO,KAAK,IAAM;EACZ,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,yBAAyB,GAAG;EAAM,CAAC,GAAGH,KAAK;EAEvE,MAAM;IAAEI;EAA6B,CAAC,GAAGN,MAAM,CAC9CP,WAAW,CAAEK,gBAAiB,CAC/B,CAAC;EACDJ,SAAS,CAAE,MAAM;IAChBY,4BAA4B,CAC3B;MACC,GAAGF,QAAQ;MACXG,uBAAuB,EAAE;IAC1B,CAAC,EACD;MACCF,yBAAyB;MACzBG,KAAK,EAAE;IACR,CACD,CAAC;EACF,CAAC,EAAE,CACFJ,QAAQ,EACRC,yBAAyB,EACzBC,4BAA4B,CAC3B,CAAC;;EAEH;EACAV,YAAY,CAAEM,KAAM,CAAC;EAErB,OAAOO,aAAA,CAACV,iBAAiB,QAAGI,QAA6B,CAAC;AAC3D,CACD,CAAC;AAED,OAAO,MAAMO,mBAAmB,GAAKR,KAAK,IAAM;EAC/C,OACCO,aAAA,CAACR,+BAA+B;IAAA,GAC1BC,KAAK;IACVG,yBAAyB,EAAG;EAAM,GAEhCH,KAAK,CAACC,QACwB,CAAC;AAEpC,CAAC;AAED,eAAeO,mBAAmB"}
1
+ {"version":3,"names":["useDispatch","useEffect","SlotFillProvider","withRegistryProvider","useBlockSync","store","blockEditorStore","BlockRefsProvider","unlock","KeyboardShortcuts","ExperimentalBlockEditorProvider","props","children","settings","stripExperimentalSettings","__experimentalUpdateSettings","__internalIsInitialized","reset","createElement","Register","BlockEditorProvider"],"sources":["@wordpress/block-editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { useEffect } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport useBlockSync from './use-block-sync';\nimport { store as blockEditorStore } from '../../store';\nimport { BlockRefsProvider } from './block-refs-provider';\nimport { unlock } from '../../lock-unlock';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\n\n/** @typedef {import('@wordpress/data').WPDataRegistry} WPDataRegistry */\n\nexport const ExperimentalBlockEditorProvider = withRegistryProvider(\n\t( props ) => {\n\t\tconst { children, settings, stripExperimentalSettings = false } = props;\n\n\t\tconst { __experimentalUpdateSettings } = unlock(\n\t\t\tuseDispatch( blockEditorStore )\n\t\t);\n\t\tuseEffect( () => {\n\t\t\t__experimentalUpdateSettings(\n\t\t\t\t{\n\t\t\t\t\t...settings,\n\t\t\t\t\t__internalIsInitialized: true,\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tstripExperimentalSettings,\n\t\t\t\t\treset: true,\n\t\t\t\t}\n\t\t\t);\n\t\t}, [\n\t\t\tsettings,\n\t\t\tstripExperimentalSettings,\n\t\t\t__experimentalUpdateSettings,\n\t\t] );\n\n\t\t// Syncs the entity provider with changes in the block-editor store.\n\t\tuseBlockSync( props );\n\n\t\treturn (\n\t\t\t<SlotFillProvider>\n\t\t\t\t<KeyboardShortcuts.Register />\n\t\t\t\t<BlockRefsProvider>{ children }</BlockRefsProvider>\n\t\t\t</SlotFillProvider>\n\t\t);\n\t}\n);\n\nexport const BlockEditorProvider = ( props ) => {\n\treturn (\n\t\t<ExperimentalBlockEditorProvider\n\t\t\t{ ...props }\n\t\t\tstripExperimentalSettings={ true }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalBlockEditorProvider>\n\t);\n};\n\nexport default BlockEditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,gBAAgB,QAAQ,uBAAuB;;AAExD;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,iBAAiB,QAAQ,uBAAuB;AACzD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,iBAAiB,MAAM,uBAAuB;;AAErD;;AAEA,OAAO,MAAMC,+BAA+B,GAAGP,oBAAoB,CAChEQ,KAAK,IAAM;EACZ,MAAM;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,yBAAyB,GAAG;EAAM,CAAC,GAAGH,KAAK;EAEvE,MAAM;IAAEI;EAA6B,CAAC,GAAGP,MAAM,CAC9CR,WAAW,CAAEM,gBAAiB,CAC/B,CAAC;EACDL,SAAS,CAAE,MAAM;IAChBc,4BAA4B,CAC3B;MACC,GAAGF,QAAQ;MACXG,uBAAuB,EAAE;IAC1B,CAAC,EACD;MACCF,yBAAyB;MACzBG,KAAK,EAAE;IACR,CACD,CAAC;EACF,CAAC,EAAE,CACFJ,QAAQ,EACRC,yBAAyB,EACzBC,4BAA4B,CAC3B,CAAC;;EAEH;EACAX,YAAY,CAAEO,KAAM,CAAC;EAErB,OACCO,aAAA,CAAChB,gBAAgB,QAChBgB,aAAA,CAACT,iBAAiB,CAACU,QAAQ,MAAE,CAAC,EAC9BD,aAAA,CAACX,iBAAiB,QAAGK,QAA6B,CACjC,CAAC;AAErB,CACD,CAAC;AAED,OAAO,MAAMQ,mBAAmB,GAAKT,KAAK,IAAM;EAC/C,OACCO,aAAA,CAACR,+BAA+B;IAAA,GAC1BC,KAAK;IACVG,yBAAyB,EAAG;EAAM,GAEhCH,KAAK,CAACC,QACwB,CAAC;AAEpC,CAAC;AAED,eAAeQ,mBAAmB"}
@@ -19,7 +19,7 @@ export function useRemoveBrowserShortcuts() {
19
19
  }
20
20
  node.addEventListener('keydown', onKeydown);
21
21
  return () => {
22
- node.addEventListener('keydown', onKeydown);
22
+ node.removeEventListener('keydown', onKeydown);
23
23
  };
24
24
  }, []);
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"names":["useRefEffect","isKeyboardEvent","useRemoveBrowserShortcuts","node","onKeydown","event","primary","primaryShift","preventDefault","addEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-remove-browser-shortcuts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Hook to prevent default behaviors for key combinations otherwise handled\n * internally by RichText.\n *\n * @return {import('react').RefObject} The component to be rendered.\n */\nexport function useRemoveBrowserShortcuts() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeydown( event ) {\n\t\t\tif (\n\t\t\t\tisKeyboardEvent.primary( event, 'z' ) ||\n\t\t\t\tisKeyboardEvent.primary( event, 'y' ) ||\n\t\t\t\tisKeyboardEvent.primaryShift( event, 'z' )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t\tnode.addEventListener( 'keydown', onKeydown );\n\t\treturn () => {\n\t\t\tnode.addEventListener( 'keydown', onKeydown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC3C,OAAOF,YAAY,CAAIG,IAAI,IAAM;IAChC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IACCJ,eAAe,CAACK,OAAO,CAAED,KAAK,EAAE,GAAI,CAAC,IACrCJ,eAAe,CAACK,OAAO,CAAED,KAAK,EAAE,GAAI,CAAC,IACrCJ,eAAe,CAACM,YAAY,CAAEF,KAAK,EAAE,GAAI,CAAC,EACzC;QACDA,KAAK,CAACG,cAAc,CAAC,CAAC;MACvB;IACD;IACAL,IAAI,CAACM,gBAAgB,CAAE,SAAS,EAAEL,SAAU,CAAC;IAC7C,OAAO,MAAM;MACZD,IAAI,CAACM,gBAAgB,CAAE,SAAS,EAAEL,SAAU,CAAC;IAC9C,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}
1
+ {"version":3,"names":["useRefEffect","isKeyboardEvent","useRemoveBrowserShortcuts","node","onKeydown","event","primary","primaryShift","preventDefault","addEventListener","removeEventListener"],"sources":["@wordpress/block-editor/src/components/rich-text/use-remove-browser-shortcuts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { isKeyboardEvent } from '@wordpress/keycodes';\n\n/**\n * Hook to prevent default behaviors for key combinations otherwise handled\n * internally by RichText.\n *\n * @return {import('react').RefObject} The component to be rendered.\n */\nexport function useRemoveBrowserShortcuts() {\n\treturn useRefEffect( ( node ) => {\n\t\tfunction onKeydown( event ) {\n\t\t\tif (\n\t\t\t\tisKeyboardEvent.primary( event, 'z' ) ||\n\t\t\t\tisKeyboardEvent.primary( event, 'y' ) ||\n\t\t\t\tisKeyboardEvent.primaryShift( event, 'z' )\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\t\tnode.addEventListener( 'keydown', onKeydown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'keydown', onKeydown );\n\t\t};\n\t}, [] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAY,QAAQ,oBAAoB;AACjD,SAASC,eAAe,QAAQ,qBAAqB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,yBAAyBA,CAAA,EAAG;EAC3C,OAAOF,YAAY,CAAIG,IAAI,IAAM;IAChC,SAASC,SAASA,CAAEC,KAAK,EAAG;MAC3B,IACCJ,eAAe,CAACK,OAAO,CAAED,KAAK,EAAE,GAAI,CAAC,IACrCJ,eAAe,CAACK,OAAO,CAAED,KAAK,EAAE,GAAI,CAAC,IACrCJ,eAAe,CAACM,YAAY,CAAEF,KAAK,EAAE,GAAI,CAAC,EACzC;QACDA,KAAK,CAACG,cAAc,CAAC,CAAC;MACvB;IACD;IACAL,IAAI,CAACM,gBAAgB,CAAE,SAAS,EAAEL,SAAU,CAAC;IAC7C,OAAO,MAAM;MACZD,IAAI,CAACO,mBAAmB,CAAE,SAAS,EAAEN,SAAU,CAAC;IACjD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;AACR"}