@wordpress/block-editor 15.12.0 → 15.12.2-next.v.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 (149) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/block-allowed-blocks/modal.cjs +1 -1
  3. package/build/components/block-allowed-blocks/modal.cjs.map +2 -2
  4. package/build/components/block-inspector/index.cjs +9 -9
  5. package/build/components/block-inspector/index.cjs.map +3 -3
  6. package/build/components/block-removal-warning-modal/index.cjs +30 -5
  7. package/build/components/block-removal-warning-modal/index.cjs.map +3 -3
  8. package/build/components/block-visibility/use-block-visibility.cjs +14 -29
  9. package/build/components/block-visibility/use-block-visibility.cjs.map +2 -2
  10. package/build/components/global-styles/hooks.cjs +7 -0
  11. package/build/components/global-styles/hooks.cjs.map +2 -2
  12. package/build/components/global-styles/typography-panel.cjs +71 -3
  13. package/build/components/global-styles/typography-panel.cjs.map +3 -3
  14. package/build/components/grid/grid-visualizer.cjs +49 -13
  15. package/build/components/grid/grid-visualizer.cjs.map +2 -2
  16. package/build/components/iframe/index.cjs +3 -1
  17. package/build/components/iframe/index.cjs.map +2 -2
  18. package/build/components/iframe/use-scale-canvas.cjs +1 -0
  19. package/build/components/iframe/use-scale-canvas.cjs.map +2 -2
  20. package/build/components/inspector-controls/last-item.cjs +41 -0
  21. package/build/components/inspector-controls/last-item.cjs.map +7 -0
  22. package/build/components/inspector-controls-tabs/styles-tab.cjs +3 -3
  23. package/build/components/inspector-controls-tabs/styles-tab.cjs.map +2 -2
  24. package/build/components/link-control/index.cjs +73 -2
  25. package/build/components/link-control/index.cjs.map +3 -3
  26. package/build/components/link-control/is-url-like.cjs +15 -3
  27. package/build/components/link-control/is-url-like.cjs.map +2 -2
  28. package/build/components/link-control/search-input.cjs +4 -1
  29. package/build/components/link-control/search-input.cjs.map +2 -2
  30. package/build/components/link-control/use-search-handler.cjs +1 -1
  31. package/build/components/link-control/use-search-handler.cjs.map +2 -2
  32. package/build/components/provider/use-block-sync.cjs +60 -8
  33. package/build/components/provider/use-block-sync.cjs.map +2 -2
  34. package/build/components/text-indent-control/index.cjs +121 -0
  35. package/build/components/text-indent-control/index.cjs.map +7 -0
  36. package/build/components/url-input/index.cjs +22 -2
  37. package/build/components/url-input/index.cjs.map +3 -3
  38. package/build/components/url-popover/image-url-input-ui.cjs +1 -1
  39. package/build/components/url-popover/image-url-input-ui.cjs.map +2 -2
  40. package/build/components/writing-flow/use-arrow-nav.cjs +0 -3
  41. package/build/components/writing-flow/use-arrow-nav.cjs.map +2 -2
  42. package/build/hooks/anchor.cjs +1 -1
  43. package/build/hooks/anchor.cjs.map +1 -1
  44. package/build/hooks/aria-label.cjs +2 -1
  45. package/build/hooks/aria-label.cjs.map +2 -2
  46. package/build/hooks/grid-visualizer.cjs +59 -6
  47. package/build/hooks/grid-visualizer.cjs.map +3 -3
  48. package/build/hooks/layout-child.cjs +47 -6
  49. package/build/hooks/layout-child.cjs.map +3 -3
  50. package/build/hooks/typography.cjs +2 -0
  51. package/build/hooks/typography.cjs.map +2 -2
  52. package/build/hooks/utils.cjs +4 -0
  53. package/build/hooks/utils.cjs.map +2 -2
  54. package/build/private-apis.cjs +2 -0
  55. package/build/private-apis.cjs.map +3 -3
  56. package/build/store/actions.cjs +2 -2
  57. package/build/store/actions.cjs.map +2 -2
  58. package/build-module/components/block-allowed-blocks/modal.mjs +2 -2
  59. package/build-module/components/block-allowed-blocks/modal.mjs.map +2 -2
  60. package/build-module/components/block-inspector/index.mjs +10 -9
  61. package/build-module/components/block-inspector/index.mjs.map +2 -2
  62. package/build-module/components/block-removal-warning-modal/index.mjs +34 -7
  63. package/build-module/components/block-removal-warning-modal/index.mjs.map +2 -2
  64. package/build-module/components/block-visibility/use-block-visibility.mjs +14 -29
  65. package/build-module/components/block-visibility/use-block-visibility.mjs.map +2 -2
  66. package/build-module/components/global-styles/hooks.mjs +7 -0
  67. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  68. package/build-module/components/global-styles/typography-panel.mjs +73 -4
  69. package/build-module/components/global-styles/typography-panel.mjs.map +2 -2
  70. package/build-module/components/grid/grid-visualizer.mjs +50 -14
  71. package/build-module/components/grid/grid-visualizer.mjs.map +2 -2
  72. package/build-module/components/iframe/index.mjs +9 -2
  73. package/build-module/components/iframe/index.mjs.map +2 -2
  74. package/build-module/components/iframe/use-scale-canvas.mjs +1 -0
  75. package/build-module/components/iframe/use-scale-canvas.mjs.map +2 -2
  76. package/build-module/components/inspector-controls/last-item.mjs +23 -0
  77. package/build-module/components/inspector-controls/last-item.mjs.map +7 -0
  78. package/build-module/components/inspector-controls-tabs/styles-tab.mjs +3 -3
  79. package/build-module/components/inspector-controls-tabs/styles-tab.mjs.map +2 -2
  80. package/build-module/components/link-control/index.mjs +74 -3
  81. package/build-module/components/link-control/index.mjs.map +2 -2
  82. package/build-module/components/link-control/is-url-like.mjs +10 -3
  83. package/build-module/components/link-control/is-url-like.mjs.map +2 -2
  84. package/build-module/components/link-control/search-input.mjs +4 -1
  85. package/build-module/components/link-control/search-input.mjs.map +2 -2
  86. package/build-module/components/link-control/use-search-handler.mjs +2 -2
  87. package/build-module/components/link-control/use-search-handler.mjs.map +2 -2
  88. package/build-module/components/provider/use-block-sync.mjs +60 -8
  89. package/build-module/components/provider/use-block-sync.mjs.map +2 -2
  90. package/build-module/components/text-indent-control/index.mjs +110 -0
  91. package/build-module/components/text-indent-control/index.mjs.map +7 -0
  92. package/build-module/components/url-input/index.mjs +24 -4
  93. package/build-module/components/url-input/index.mjs.map +2 -2
  94. package/build-module/components/url-popover/image-url-input-ui.mjs +2 -2
  95. package/build-module/components/url-popover/image-url-input-ui.mjs.map +2 -2
  96. package/build-module/components/writing-flow/use-arrow-nav.mjs +0 -3
  97. package/build-module/components/writing-flow/use-arrow-nav.mjs.map +2 -2
  98. package/build-module/hooks/anchor.mjs +1 -1
  99. package/build-module/hooks/anchor.mjs.map +1 -1
  100. package/build-module/hooks/aria-label.mjs +2 -1
  101. package/build-module/hooks/aria-label.mjs.map +2 -2
  102. package/build-module/hooks/grid-visualizer.mjs +37 -6
  103. package/build-module/hooks/grid-visualizer.mjs.map +2 -2
  104. package/build-module/hooks/layout-child.mjs +37 -6
  105. package/build-module/hooks/layout-child.mjs.map +2 -2
  106. package/build-module/hooks/typography.mjs +2 -0
  107. package/build-module/hooks/typography.mjs.map +2 -2
  108. package/build-module/hooks/utils.mjs +4 -0
  109. package/build-module/hooks/utils.mjs.map +2 -2
  110. package/build-module/private-apis.mjs +2 -0
  111. package/build-module/private-apis.mjs.map +2 -2
  112. package/build-module/store/actions.mjs +2 -2
  113. package/build-module/store/actions.mjs.map +2 -2
  114. package/package.json +39 -39
  115. package/src/components/block-allowed-blocks/modal.js +2 -2
  116. package/src/components/block-inspector/index.js +19 -17
  117. package/src/components/block-removal-warning-modal/index.js +55 -19
  118. package/src/components/block-switcher/block-transformations-menu.native.js +1 -0
  119. package/src/components/block-toolbar/test/__snapshots__/block-toolbar-menu.native.js.snap +4 -6
  120. package/src/components/block-toolbar/test/block-toolbar-menu.native.js +2 -2
  121. package/src/components/block-visibility/use-block-visibility.js +17 -32
  122. package/src/components/global-styles/hooks.js +10 -0
  123. package/src/components/global-styles/typography-panel.js +78 -1
  124. package/src/components/grid/grid-visualizer.js +58 -12
  125. package/src/components/iframe/index.js +12 -2
  126. package/src/components/iframe/use-scale-canvas.js +1 -0
  127. package/src/components/inserter/menu.native.js +1 -0
  128. package/src/components/inspector-controls/last-item.js +29 -0
  129. package/src/components/inspector-controls-tabs/styles-tab.js +3 -3
  130. package/src/components/link-control/index.js +160 -3
  131. package/src/components/link-control/is-url-like.js +43 -8
  132. package/src/components/link-control/search-input.js +7 -0
  133. package/src/components/link-control/test/index.js +260 -0
  134. package/src/components/link-control/test/is-url-like.js +49 -1
  135. package/src/components/link-control/use-search-handler.js +2 -2
  136. package/src/components/provider/test/use-block-sync.js +105 -0
  137. package/src/components/provider/use-block-sync.js +118 -9
  138. package/src/components/text-indent-control/index.js +138 -0
  139. package/src/components/url-input/index.js +21 -2
  140. package/src/components/url-popover/image-url-input-ui.js +2 -2
  141. package/src/components/writing-flow/use-arrow-nav.js +0 -4
  142. package/src/hooks/anchor.js +1 -1
  143. package/src/hooks/aria-label.js +9 -1
  144. package/src/hooks/grid-visualizer.js +63 -24
  145. package/src/hooks/layout-child.js +45 -3
  146. package/src/hooks/typography.js +2 -0
  147. package/src/hooks/utils.js +4 -0
  148. package/src/private-apis.js +2 -0
  149. package/src/store/actions.js +8 -6
@@ -10,42 +10,81 @@ import { useSelect } from '@wordpress/data';
10
10
  */
11
11
  import { GridVisualizer, useGridLayoutSync } from '../components/grid';
12
12
  import { store as blockEditorStore } from '../store';
13
+ import { unlock } from '../lock-unlock';
14
+ import useBlockVisibility from '../components/block-visibility/use-block-visibility';
15
+ import { deviceTypeKey } from '../store/private-keys';
16
+ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
13
17
 
14
18
  function GridLayoutSync( props ) {
15
19
  useGridLayoutSync( props );
16
20
  }
17
21
 
18
22
  function GridTools( { clientId, layout } ) {
19
- const isVisible = useSelect(
20
- ( select ) => {
21
- const {
22
- isBlockSelected,
23
- isDraggingBlocks,
24
- getTemplateLock,
25
- getBlockEditingMode,
26
- } = select( blockEditorStore );
23
+ const { isVisible, blockVisibility, deviceType, isAnyAncestorHidden } =
24
+ useSelect(
25
+ ( select ) => {
26
+ const {
27
+ isBlockSelected,
28
+ hasSelectedInnerBlock,
29
+ isDraggingBlocks,
30
+ getTemplateLock,
31
+ getBlockEditingMode,
32
+ getBlockAttributes,
33
+ getSettings,
34
+ } = select( blockEditorStore );
27
35
 
28
- // These calls are purposely ordered from least expensive to most expensive.
29
- // Hides the visualizer in cases where the user is not or cannot interact with it.
30
- if (
31
- ( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||
32
- getTemplateLock( clientId ) ||
33
- getBlockEditingMode( clientId ) !== 'default'
34
- ) {
35
- return false;
36
- }
36
+ // These calls are purposely ordered from least expensive to most expensive.
37
+ // Hides the visualizer in cases where the user is not or cannot interact with it.
38
+ // Also hide if a child block is selected, because layout-child.js will render
39
+ // the visualizer in that case (with proper childGridClientId handling).
40
+ if (
41
+ ( ! isDraggingBlocks() && ! isBlockSelected( clientId ) ) ||
42
+ getTemplateLock( clientId ) ||
43
+ getBlockEditingMode( clientId ) !== 'default' ||
44
+ hasSelectedInnerBlock( clientId )
45
+ ) {
46
+ return { isVisible: false };
47
+ }
37
48
 
38
- return true;
39
- },
40
- [ clientId ]
41
- );
49
+ const { isBlockParentHiddenAtViewport } = unlock(
50
+ select( blockEditorStore )
51
+ );
52
+
53
+ const attributes = getBlockAttributes( clientId );
54
+ const settings = getSettings();
55
+ const currentDeviceType =
56
+ settings?.[ deviceTypeKey ]?.toLowerCase() ||
57
+ BLOCK_VISIBILITY_VIEWPORTS.desktop.value;
58
+
59
+ return {
60
+ isVisible: true,
61
+ blockVisibility: attributes?.metadata?.blockVisibility,
62
+ deviceType: currentDeviceType,
63
+ isAnyAncestorHidden: isBlockParentHiddenAtViewport(
64
+ clientId,
65
+ currentDeviceType
66
+ ),
67
+ };
68
+ },
69
+ [ clientId ]
70
+ );
71
+
72
+ const { isBlockCurrentlyHidden } = useBlockVisibility( {
73
+ blockVisibility,
74
+ deviceType,
75
+ } );
42
76
 
43
77
  return (
44
78
  <>
45
79
  <GridLayoutSync clientId={ clientId } />
46
- { isVisible && (
47
- <GridVisualizer clientId={ clientId } parentLayout={ layout } />
48
- ) }
80
+ { isVisible &&
81
+ ! isBlockCurrentlyHidden &&
82
+ ! isAnyAncestorHidden && (
83
+ <GridVisualizer
84
+ clientId={ clientId }
85
+ parentLayout={ layout }
86
+ />
87
+ ) }
49
88
  </>
50
89
  );
51
90
  }
@@ -16,6 +16,9 @@ import {
16
16
  GridItemResizer,
17
17
  GridItemMovers,
18
18
  } from '../components/grid';
19
+ import useBlockVisibility from '../components/block-visibility/use-block-visibility';
20
+ import { deviceTypeKey } from '../store/private-keys';
21
+ import { BLOCK_VISIBILITY_VIEWPORTS } from '../components/block-visibility/constants';
19
22
 
20
23
  // Used for generating the instance ID
21
24
  const LAYOUT_CHILD_BLOCK_PROPS_REFERENCE = {};
@@ -199,12 +202,21 @@ function GridTools( {
199
202
  isManualPlacement,
200
203
  parentLayout,
201
204
  } ) {
202
- const { rootClientId, isVisible } = useSelect(
205
+ const {
206
+ rootClientId,
207
+ isVisible,
208
+ parentBlockVisibility,
209
+ blockBlockVisibility,
210
+ deviceType,
211
+ isChildBlockAGrid,
212
+ } = useSelect(
203
213
  ( select ) => {
204
214
  const {
205
215
  getBlockRootClientId,
206
216
  getBlockEditingMode,
207
217
  getTemplateLock,
218
+ getBlockAttributes,
219
+ getSettings,
208
220
  } = select( blockEditorStore );
209
221
 
210
222
  const _rootClientId = getBlockRootClientId( clientId );
@@ -219,21 +231,50 @@ function GridTools( {
219
231
  };
220
232
  }
221
233
 
234
+ const parentAttributes = getBlockAttributes( _rootClientId );
235
+ const blockAttributes = getBlockAttributes( clientId );
236
+ const settings = getSettings();
237
+
222
238
  return {
223
239
  rootClientId: _rootClientId,
224
240
  isVisible: true,
241
+ parentBlockVisibility:
242
+ parentAttributes?.metadata?.blockVisibility,
243
+ blockBlockVisibility:
244
+ blockAttributes?.metadata?.blockVisibility,
245
+ deviceType:
246
+ settings?.[ deviceTypeKey ]?.toLowerCase() ||
247
+ BLOCK_VISIBILITY_VIEWPORTS.desktop.value,
248
+ // Check if the selected child block is itself a grid.
249
+ isChildBlockAGrid: blockAttributes?.layout?.type === 'grid',
225
250
  };
226
251
  },
227
252
  [ clientId ]
228
253
  );
229
254
 
255
+ const { isBlockCurrentlyHidden: isParentBlockCurrentlyHidden } =
256
+ useBlockVisibility( {
257
+ blockVisibility: parentBlockVisibility,
258
+ deviceType,
259
+ } );
260
+
261
+ const { isBlockCurrentlyHidden: isBlockItselfCurrentlyHidden } =
262
+ useBlockVisibility( {
263
+ blockVisibility: blockBlockVisibility,
264
+ deviceType,
265
+ } );
266
+
230
267
  // Use useState() instead of useRef() so that GridItemResizer updates when ref is set.
231
268
  const [ resizerBounds, setResizerBounds ] = useState();
232
269
 
233
- if ( ! isVisible ) {
270
+ const childGridClientId = isChildBlockAGrid ? clientId : undefined;
271
+
272
+ if ( ! isVisible || isParentBlockCurrentlyHidden ) {
234
273
  return null;
235
274
  }
236
275
 
276
+ const showResizer = allowSizingOnChildren && ! isBlockItselfCurrentlyHidden;
277
+
237
278
  function updateLayout( layout ) {
238
279
  setAttributes( {
239
280
  style: {
@@ -252,8 +293,9 @@ function GridTools( {
252
293
  clientId={ rootClientId }
253
294
  contentRef={ setResizerBounds }
254
295
  parentLayout={ parentLayout }
296
+ childGridClientId={ childGridClientId }
255
297
  />
256
- { allowSizingOnChildren && (
298
+ { showResizer && (
257
299
  <GridItemResizer
258
300
  clientId={ clientId }
259
301
  // Don't allow resizing beyond the grid visualizer.
@@ -31,6 +31,7 @@ function omit( object, keys ) {
31
31
  const LETTER_SPACING_SUPPORT_KEY = 'typography.__experimentalLetterSpacing';
32
32
  const TEXT_TRANSFORM_SUPPORT_KEY = 'typography.__experimentalTextTransform';
33
33
  const TEXT_DECORATION_SUPPORT_KEY = 'typography.__experimentalTextDecoration';
34
+ const TEXT_INDENT_SUPPORT_KEY = 'typography.textIndent';
34
35
  const TEXT_COLUMNS_SUPPORT_KEY = 'typography.textColumns';
35
36
  const FONT_STYLE_SUPPORT_KEY = 'typography.__experimentalFontStyle';
36
37
  const FONT_WEIGHT_SUPPORT_KEY = 'typography.__experimentalFontWeight';
@@ -45,6 +46,7 @@ export const TYPOGRAPHY_SUPPORT_KEYS = [
45
46
  TEXT_ALIGN_SUPPORT_KEY,
46
47
  TEXT_COLUMNS_SUPPORT_KEY,
47
48
  TEXT_DECORATION_SUPPORT_KEY,
49
+ TEXT_INDENT_SUPPORT_KEY,
48
50
  WRITING_MODE_SUPPORT_KEY,
49
51
  TEXT_TRANSFORM_SUPPORT_KEY,
50
52
  LETTER_SPACING_SUPPORT_KEY,
@@ -252,6 +252,7 @@ export function useBlockSettings( name, parentLayout ) {
252
252
  textAlign,
253
253
  textColumns,
254
254
  textDecoration,
255
+ textIndent,
255
256
  writingMode,
256
257
  textTransform,
257
258
  letterSpacing,
@@ -313,6 +314,7 @@ export function useBlockSettings( name, parentLayout ) {
313
314
  'typography.textAlign',
314
315
  'typography.textColumns',
315
316
  'typography.textDecoration',
317
+ 'typography.textIndent',
316
318
  'typography.writingMode',
317
319
  'typography.textTransform',
318
320
  'typography.letterSpacing',
@@ -412,6 +414,7 @@ export function useBlockSettings( name, parentLayout ) {
412
414
  textAlign,
413
415
  textColumns,
414
416
  textDecoration,
417
+ textIndent,
415
418
  textTransform,
416
419
  letterSpacing,
417
420
  writingMode,
@@ -464,6 +467,7 @@ export function useBlockSettings( name, parentLayout ) {
464
467
  textAlign,
465
468
  textColumns,
466
469
  textDecoration,
470
+ textIndent,
467
471
  textTransform,
468
472
  letterSpacing,
469
473
  writingMode,
@@ -13,6 +13,7 @@ import {
13
13
  normalizeString,
14
14
  } from './components/inserter/search-items';
15
15
  import { PrivateListView } from './components/list-view';
16
+ import InspectorControlsLastItem from './components/inspector-controls/last-item';
16
17
  import { useHasBlockToolbar } from './components/block-toolbar/use-has-block-toolbar';
17
18
  import { cleanEmptyObject } from './hooks/utils';
18
19
  import BlockQuickNavigation from './components/block-quick-navigation';
@@ -79,6 +80,7 @@ lock( privateApis, {
79
80
  normalizeString,
80
81
  PrivateListView,
81
82
  ResizableBoxPopover,
83
+ InspectorControlsLastItem,
82
84
  useHasBlockToolbar,
83
85
  cleanEmptyObject,
84
86
  BlockQuickNavigation,
@@ -517,11 +517,12 @@ export function moveBlockToPosition(
517
517
  * Only allowed blocks are inserted. The action may fail silently for blocks that are not allowed or if
518
518
  * a templateLock is active on the block list.
519
519
  *
520
- * @param {Object} block Block object to insert.
521
- * @param {?number} index Index at which block should be inserted.
522
- * @param {?string} rootClientId Optional root client ID of block list on which to insert.
523
- * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
524
- * @param {?Object} meta Optional Meta values to be passed to the action object.
520
+ * @param {Object} block Block object to insert.
521
+ * @param {?number} index Index at which block should be inserted.
522
+ * @param {?string} rootClientId Optional root client ID of block list on which to insert.
523
+ * @param {?boolean} updateSelection If true block selection will be updated. If false, block selection will not change. Defaults to true.
524
+ * @param {0|-1|null} initialPosition Initial focus position. Setting it to null prevent focusing the inserted block.
525
+ * @param {?Object} meta Optional Meta values to be passed to the action object.
525
526
  *
526
527
  * @return {Object} Action object.
527
528
  */
@@ -530,6 +531,7 @@ export function insertBlock(
530
531
  index,
531
532
  rootClientId,
532
533
  updateSelection,
534
+ initialPosition,
533
535
  meta
534
536
  ) {
535
537
  return insertBlocks(
@@ -537,7 +539,7 @@ export function insertBlock(
537
539
  index,
538
540
  rootClientId,
539
541
  updateSelection,
540
- 0,
542
+ initialPosition,
541
543
  meta
542
544
  );
543
545
  }