@wordpress/block-editor 15.10.1-next.79a2f3cdd.0 → 15.10.1-next.ba3aee3a2.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 (97) hide show
  1. package/build/components/block-edit/context.cjs +5 -5
  2. package/build/components/block-edit/context.cjs.map +1 -1
  3. package/build/components/block-list/block.cjs +24 -12
  4. package/build/components/block-list/block.cjs.map +3 -3
  5. package/build/components/block-list/use-block-props/index.cjs +8 -2
  6. package/build/components/block-list/use-block-props/index.cjs.map +2 -2
  7. package/build/components/block-visibility/constants.cjs +49 -0
  8. package/build/components/block-visibility/constants.cjs.map +7 -0
  9. package/build/components/block-visibility/index.cjs +5 -2
  10. package/build/components/block-visibility/index.cjs.map +2 -2
  11. package/build/components/block-visibility/use-block-visibility.cjs +69 -0
  12. package/build/components/block-visibility/use-block-visibility.cjs.map +7 -0
  13. package/build/components/collab/block-comment-icon-slot.cjs +1 -1
  14. package/build/components/collab/block-comment-icon-slot.cjs.map +1 -1
  15. package/build/components/collab/block-comment-icon-toolbar-slot.cjs +1 -1
  16. package/build/components/collab/block-comment-icon-toolbar-slot.cjs.map +1 -1
  17. package/build/components/inspector-controls/groups.cjs +1 -1
  18. package/build/components/inspector-controls/groups.cjs.map +1 -1
  19. package/build/components/inspector-controls-tabs/content-tab.cjs +1 -1
  20. package/build/components/inspector-controls-tabs/content-tab.cjs.map +2 -2
  21. package/build/components/list-view/index.cjs +11 -6
  22. package/build/components/list-view/index.cjs.map +2 -2
  23. package/build/components/list-view/utils.cjs +24 -17
  24. package/build/components/list-view/utils.cjs.map +2 -2
  25. package/build/components/rich-text/event-listeners/input-rules.cjs +13 -1
  26. package/build/components/rich-text/event-listeners/input-rules.cjs.map +2 -2
  27. package/build/components/rich-text/format-edit.cjs +1 -1
  28. package/build/components/rich-text/format-edit.cjs.map +1 -1
  29. package/build/components/rich-text/index.cjs +1 -1
  30. package/build/components/rich-text/index.cjs.map +1 -1
  31. package/build/components/writing-flow/utils.cjs +1 -1
  32. package/build/components/writing-flow/utils.cjs.map +1 -1
  33. package/build/hooks/block-fields/index.cjs +1 -1
  34. package/build/hooks/block-fields/index.cjs.map +2 -2
  35. package/build/hooks/fit-text.cjs +1 -1
  36. package/build/hooks/fit-text.cjs.map +1 -1
  37. package/build/store/private-keys.cjs +10 -10
  38. package/build/store/private-keys.cjs.map +1 -1
  39. package/build/store/utils.cjs +1 -1
  40. package/build/store/utils.cjs.map +1 -1
  41. package/build-module/components/block-edit/context.mjs +5 -5
  42. package/build-module/components/block-edit/context.mjs.map +1 -1
  43. package/build-module/components/block-list/block.mjs +24 -12
  44. package/build-module/components/block-list/block.mjs.map +3 -3
  45. package/build-module/components/block-list/use-block-props/index.mjs +8 -2
  46. package/build-module/components/block-list/use-block-props/index.mjs.map +2 -2
  47. package/build-module/components/block-visibility/constants.mjs +24 -0
  48. package/build-module/components/block-visibility/constants.mjs.map +7 -0
  49. package/build-module/components/block-visibility/index.mjs +3 -1
  50. package/build-module/components/block-visibility/index.mjs.map +2 -2
  51. package/build-module/components/block-visibility/use-block-visibility.mjs +44 -0
  52. package/build-module/components/block-visibility/use-block-visibility.mjs.map +7 -0
  53. package/build-module/components/collab/block-comment-icon-slot.mjs +1 -1
  54. package/build-module/components/collab/block-comment-icon-slot.mjs.map +1 -1
  55. package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs +1 -1
  56. package/build-module/components/collab/block-comment-icon-toolbar-slot.mjs.map +1 -1
  57. package/build-module/components/inspector-controls/groups.mjs +1 -1
  58. package/build-module/components/inspector-controls/groups.mjs.map +1 -1
  59. package/build-module/components/inspector-controls-tabs/content-tab.mjs +1 -1
  60. package/build-module/components/inspector-controls-tabs/content-tab.mjs.map +2 -2
  61. package/build-module/components/list-view/index.mjs +11 -7
  62. package/build-module/components/list-view/index.mjs.map +2 -2
  63. package/build-module/components/list-view/utils.mjs +24 -17
  64. package/build-module/components/list-view/utils.mjs.map +2 -2
  65. package/build-module/components/rich-text/event-listeners/input-rules.mjs +13 -1
  66. package/build-module/components/rich-text/event-listeners/input-rules.mjs.map +2 -2
  67. package/build-module/components/rich-text/format-edit.mjs +1 -1
  68. package/build-module/components/rich-text/format-edit.mjs.map +1 -1
  69. package/build-module/components/rich-text/index.mjs +1 -1
  70. package/build-module/components/rich-text/index.mjs.map +1 -1
  71. package/build-module/components/writing-flow/utils.mjs +1 -1
  72. package/build-module/components/writing-flow/utils.mjs.map +1 -1
  73. package/build-module/hooks/block-fields/index.mjs +1 -1
  74. package/build-module/hooks/block-fields/index.mjs.map +2 -2
  75. package/build-module/hooks/fit-text.mjs +1 -1
  76. package/build-module/hooks/fit-text.mjs.map +1 -1
  77. package/build-module/store/private-keys.mjs +10 -10
  78. package/build-module/store/private-keys.mjs.map +1 -1
  79. package/build-module/store/utils.mjs +1 -1
  80. package/build-module/store/utils.mjs.map +1 -1
  81. package/build-style/style-rtl.css +6 -1
  82. package/build-style/style.css +6 -1
  83. package/package.json +39 -39
  84. package/src/components/block-list/block.js +23 -9
  85. package/src/components/block-list/use-block-props/index.js +10 -2
  86. package/src/components/block-toolbar/style.scss +0 -1
  87. package/src/components/block-tools/style.scss +10 -0
  88. package/src/components/block-visibility/constants.js +29 -0
  89. package/src/components/block-visibility/index.js +1 -0
  90. package/src/components/block-visibility/test/use-block-visibility.js +360 -0
  91. package/src/components/block-visibility/use-block-visibility.js +73 -0
  92. package/src/components/inspector-controls-tabs/content-tab.js +0 -1
  93. package/src/components/list-view/index.js +15 -11
  94. package/src/components/list-view/utils.js +31 -23
  95. package/src/components/rich-text/event-listeners/input-rules.js +17 -0
  96. package/src/hooks/block-fields/index.js +0 -1
  97. package/src/hooks/fit-text.js +1 -1
@@ -20,6 +20,7 @@ import { useIntersectionObserver } from "./use-intersection-observer.mjs";
20
20
  import { useScrollIntoView } from "./use-scroll-into-view.mjs";
21
21
  import { useFlashEditableBlocks } from "../../use-flash-editable-blocks/index.mjs";
22
22
  import { useFirefoxDraggableCompatibility } from "./use-firefox-draggable-compatibility.mjs";
23
+ import { useBlockVisibility } from "../../block-visibility/index.mjs";
23
24
  function useBlockProps(props = {}, { __unstableIsHtml } = {}) {
24
25
  const {
25
26
  clientId,
@@ -49,7 +50,8 @@ function useBlockProps(props = {}, { __unstableIsHtml } = {}) {
49
50
  isSectionBlock,
50
51
  isWithinSectionBlock,
51
52
  canMove,
52
- isBlockHidden
53
+ blockVisibility,
54
+ deviceType
53
55
  } = useContext(PrivateBlockContext);
54
56
  const blockLabel = sprintf(__("Block: %s"), blockTitle);
55
57
  const htmlSuffix = mode === "html" && !__unstableIsHtml ? "-visual" : "";
@@ -78,6 +80,10 @@ function useBlockProps(props = {}, { __unstableIsHtml } = {}) {
78
80
  "--wp-admin-theme-color": "var(--wp-block-synced-color)",
79
81
  "--wp-admin-theme-color--rgb": "var(--wp-block-synced-color--rgb)"
80
82
  } : {};
83
+ const { isBlockCurrentlyHidden } = useBlockVisibility({
84
+ blockVisibility,
85
+ deviceType
86
+ });
81
87
  if (blockApiVersion < 2 && clientId === blockEditContext.clientId) {
82
88
  warning(
83
89
  `Block type "${name}" must support API version 2 or higher to work correctly with "useBlockProps" method.`
@@ -117,7 +123,7 @@ function useBlockProps(props = {}, { __unstableIsHtml } = {}) {
117
123
  "has-editable-outline": hasEditableOutline,
118
124
  "has-negative-margin": hasNegativeMargin,
119
125
  "is-editing-content-only-section": isEditingContentOnlySection,
120
- "is-block-hidden": isBlockHidden
126
+ "is-block-hidden": isBlockCurrentlyHidden
121
127
  },
122
128
  className,
123
129
  props.className,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/components/block-list/use-block-props/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { useFirefoxDraggableCompatibility } from './use-firefox-draggable-compatibility';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps( {\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * } )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisEditingContentOnlySection,\n\t\tdefaultClassName,\n\t\tisSectionBlock,\n\t\tisWithinSectionBlock,\n\t\tcanMove,\n\t\tisBlockHidden,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst ffDragRef = useFirefoxDraggableCompatibility();\n\tconst isHoverEnabled = ! isWithinSectionBlock;\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseIsHovered( { isEnabled: isHoverEnabled } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: isSectionBlock,\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t\tcanMove ? ffDragRef : undefined,\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle = hasBlockBindings\n\t\t? {\n\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t }\n\t\t: {};\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\tdraggable: canMove && ! hasChildSelected ? true : undefined,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-editing-content-only-section': isEditingContentOnlySection,\n\t\t\t\t'is-block-hidden': isBlockHidden,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],
5
- "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAC3B,SAAS,IAAI,eAAe;AAC5B,SAAS,2BAA2B,qBAAqB;AACzD,SAAS,cAAc,mBAAmB;AAC1C,OAAO,aAAa;AAKpB,OAAO,wBAAwB;AAC/B,SAAS,2BAA2B;AACpC,SAAS,4BAA4B;AACrC,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,uBAAuB;AAChC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,+BAA+B;AACxC,SAAS,yBAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,wCAAwC;AA4C1C,SAAS,cAAe,QAAQ,CAAC,GAAG,EAAE,iBAAiB,IAAI,CAAC,GAAI;AACtE,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe,CAAC;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI,WAAY,mBAAoB;AAGpC,QAAM,aAAa,QAAS,GAAI,WAAY,GAAG,UAAW;AAC1D,QAAM,aAAa,SAAS,UAAU,CAAE,mBAAmB,YAAY;AACvE,QAAM,YAAY,iCAAiC;AACnD,QAAM,iBAAiB,CAAE;AACzB,QAAM,aAAa,aAAc;AAAA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,IACb,cAAc;AAAA,IACd,OAAO,oBAAoB,SAAS;AAAA,IACpC,WAAW;AAAA,MACV;AAAA,MACA;AAAA;AAAA,QAEC,YAAY,CAAE;AAAA,QACd,qBAAqB;AAAA,QACrB,eAAe;AAAA,QACf,kBAAkB;AAAA,QAClB,qBAAqB;AAAA,QACrB,yBAAyB;AAAA,QACzB,eAAe;AAAA,QACf,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,mCAAmC;AAAA,QACnC,mBAAmB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,aAAa;AAAA,MACb;AAAA,IACD;AAAA,IACA,OAAO,EAAE,GAAG,aAAa,OAAO,GAAG,MAAM,OAAO,GAAG,cAAc;AAAA,EAClE;AACD;AAOA,cAAc,OAAO;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useContext } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';\nimport { useMergeRefs, useDisabled } from '@wordpress/compose';\nimport warning from '@wordpress/warning';\n\n/**\n * Internal dependencies\n */\nimport useMovingAnimation from '../../use-moving-animation';\nimport { PrivateBlockContext } from '../private-block-context';\nimport { useFocusFirstElement } from './use-focus-first-element';\nimport { useIsHovered } from './use-is-hovered';\nimport {\n\tblockBindingsKey,\n\tuseBlockEditContext,\n} from '../../block-edit/context';\nimport { useFocusHandler } from './use-focus-handler';\nimport { useEventHandlers } from './use-selected-block-event-handlers';\nimport { useBlockRefProvider } from './use-block-refs';\nimport { useIntersectionObserver } from './use-intersection-observer';\nimport { useScrollIntoView } from './use-scroll-into-view';\nimport { useFlashEditableBlocks } from '../../use-flash-editable-blocks';\nimport { useFirefoxDraggableCompatibility } from './use-firefox-draggable-compatibility';\nimport { useBlockVisibility } from '../../block-visibility/';\n\n/**\n * This hook is used to lightly mark an element as a block element. The element\n * should be the outermost element of a block. Call this hook and pass the\n * returned props to the element to mark as a block. If you define a ref for the\n * element, it is important to pass the ref to this hook, which the hook in turn\n * will pass to the component through the props it returns. Optionally, you can\n * also pass any other props through this hook, and they will be merged and\n * returned.\n *\n * Use of this hook on the outermost element of a block is required if using API >= v2.\n *\n * @example\n * ```js\n * import { useBlockProps } from '@wordpress/block-editor';\n *\n * export default function Edit() {\n *\n * const blockProps = useBlockProps( {\n * className: 'my-custom-class',\n * style: {\n * color: '#222222',\n * backgroundColor: '#eeeeee'\n * }\n * } )\n *\n * return (\n *\t <div { ...blockProps }>\n *\n * </div>\n * )\n * }\n *\n * ```\n *\n *\n * @param {Object} props Optional. Props to pass to the element. Must contain\n * the ref if one is defined.\n * @param {Object} options Options for internal use only.\n * @param {boolean} options.__unstableIsHtml\n *\n * @return {Object} Props to pass to the element to mark as a block.\n */\nexport function useBlockProps( props = {}, { __unstableIsHtml } = {} ) {\n\tconst {\n\t\tclientId,\n\t\tclassName,\n\t\twrapperProps = {},\n\t\tisAligned,\n\t\tindex,\n\t\tmode,\n\t\tname,\n\t\tblockApiVersion,\n\t\tblockTitle,\n\t\tisSelected,\n\t\tisSubtreeDisabled,\n\t\thasOverlay,\n\t\tinitialPosition,\n\t\tblockEditingMode,\n\t\tisHighlighted,\n\t\tisMultiSelected,\n\t\tisPartiallySelected,\n\t\tisReusable,\n\t\tisDragging,\n\t\thasChildSelected,\n\t\tisEditingDisabled,\n\t\thasEditableOutline,\n\t\tisEditingContentOnlySection,\n\t\tdefaultClassName,\n\t\tisSectionBlock,\n\t\tisWithinSectionBlock,\n\t\tcanMove,\n\t\tblockVisibility,\n\t\tdeviceType,\n\t} = useContext( PrivateBlockContext );\n\n\t// translators: %s: Type of block (i.e. Text, Image etc)\n\tconst blockLabel = sprintf( __( 'Block: %s' ), blockTitle );\n\tconst htmlSuffix = mode === 'html' && ! __unstableIsHtml ? '-visual' : '';\n\tconst ffDragRef = useFirefoxDraggableCompatibility();\n\tconst isHoverEnabled = ! isWithinSectionBlock;\n\tconst mergedRefs = useMergeRefs( [\n\t\tprops.ref,\n\t\tuseFocusFirstElement( { clientId, initialPosition } ),\n\t\tuseBlockRefProvider( clientId ),\n\t\tuseFocusHandler( clientId ),\n\t\tuseEventHandlers( { clientId, isSelected } ),\n\t\tuseIsHovered( { isEnabled: isHoverEnabled } ),\n\t\tuseIntersectionObserver(),\n\t\tuseMovingAnimation( { triggerAnimationOnChange: index, clientId } ),\n\t\tuseDisabled( { isDisabled: ! hasOverlay } ),\n\t\tuseFlashEditableBlocks( {\n\t\t\tclientId,\n\t\t\tisEnabled: isSectionBlock,\n\t\t} ),\n\t\tuseScrollIntoView( { isSelected } ),\n\t\tcanMove ? ffDragRef : undefined,\n\t] );\n\n\tconst blockEditContext = useBlockEditContext();\n\tconst hasBlockBindings = !! blockEditContext[ blockBindingsKey ];\n\tconst bindingsStyle = hasBlockBindings\n\t\t? {\n\t\t\t\t'--wp-admin-theme-color': 'var(--wp-block-synced-color)',\n\t\t\t\t'--wp-admin-theme-color--rgb':\n\t\t\t\t\t'var(--wp-block-synced-color--rgb)',\n\t\t }\n\t\t: {};\n\n\t// Use block visibility hook with data from context to avoid extra subscription.\n\tconst { isBlockCurrentlyHidden } = useBlockVisibility( {\n\t\tblockVisibility,\n\t\tdeviceType,\n\t} );\n\n\t// Ensures it warns only inside the `edit` implementation for the block.\n\tif ( blockApiVersion < 2 && clientId === blockEditContext.clientId ) {\n\t\twarning(\n\t\t\t`Block type \"${ name }\" must support API version 2 or higher to work correctly with \"useBlockProps\" method.`\n\t\t);\n\t}\n\n\tlet hasNegativeMargin = false;\n\tif (\n\t\twrapperProps?.style?.marginTop?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginBottom?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginLeft?.charAt( 0 ) === '-' ||\n\t\twrapperProps?.style?.marginRight?.charAt( 0 ) === '-'\n\t) {\n\t\thasNegativeMargin = true;\n\t}\n\n\treturn {\n\t\ttabIndex: blockEditingMode === 'disabled' ? -1 : 0,\n\t\tdraggable: canMove && ! hasChildSelected ? true : undefined,\n\t\t...wrapperProps,\n\t\t...props,\n\t\tref: mergedRefs,\n\t\tid: `block-${ clientId }${ htmlSuffix }`,\n\t\trole: 'document',\n\t\t'aria-label': blockLabel,\n\t\t'data-block': clientId,\n\t\t'data-type': name,\n\t\t'data-title': blockTitle,\n\t\tinert: isSubtreeDisabled ? 'true' : undefined,\n\t\tclassName: clsx(\n\t\t\t'block-editor-block-list__block',\n\t\t\t{\n\t\t\t\t// The wp-block className is important for editor styles.\n\t\t\t\t'wp-block': ! isAligned,\n\t\t\t\t'has-block-overlay': hasOverlay,\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-highlighted': isHighlighted,\n\t\t\t\t'is-multi-selected': isMultiSelected,\n\t\t\t\t'is-partially-selected': isPartiallySelected,\n\t\t\t\t'is-reusable': isReusable,\n\t\t\t\t'is-dragging': isDragging,\n\t\t\t\t'has-child-selected': hasChildSelected,\n\t\t\t\t'is-editing-disabled': isEditingDisabled,\n\t\t\t\t'has-editable-outline': hasEditableOutline,\n\t\t\t\t'has-negative-margin': hasNegativeMargin,\n\t\t\t\t'is-editing-content-only-section': isEditingContentOnlySection,\n\t\t\t\t'is-block-hidden': isBlockCurrentlyHidden,\n\t\t\t},\n\t\t\tclassName,\n\t\t\tprops.className,\n\t\t\twrapperProps.className,\n\t\t\tdefaultClassName\n\t\t),\n\t\tstyle: { ...wrapperProps.style, ...props.style, ...bindingsStyle },\n\t};\n}\n\n/**\n * Call within a save function to get the props for the block wrapper.\n *\n * @param {Object} props Optional. Props to pass to the element.\n */\nuseBlockProps.save = getBlockProps;\n"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,kBAAkB;AAC3B,SAAS,IAAI,eAAe;AAC5B,SAAS,2BAA2B,qBAAqB;AACzD,SAAS,cAAc,mBAA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QACzB,eAAe;AAAA,QACf,eAAe;AAAA,QACf,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,wBAAwB;AAAA,QACxB,uBAAuB;AAAA,QACvB,mCAAmC;AAAA,QACnC,mBAAmB;AAAA,MACpB;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN,aAAa;AAAA,MACb;AAAA,IACD;AAAA,IACA,OAAO,EAAE,GAAG,aAAa,OAAO,GAAG,MAAM,OAAO,GAAG,cAAc;AAAA,EAClE;AACD;AAOA,cAAc,OAAO;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,24 @@
1
+ // packages/block-editor/src/components/block-visibility/constants.js
2
+ import { __ } from "@wordpress/i18n";
3
+ import { desktop, tablet, mobile } from "@wordpress/icons";
4
+ var BLOCK_VISIBILITY_VIEWPORTS = {
5
+ desktop: {
6
+ label: __("Desktop"),
7
+ icon: desktop,
8
+ value: "desktop"
9
+ },
10
+ tablet: {
11
+ label: __("Tablet"),
12
+ icon: tablet,
13
+ value: "tablet"
14
+ },
15
+ mobile: {
16
+ label: __("Mobile"),
17
+ icon: mobile,
18
+ value: "mobile"
19
+ }
20
+ };
21
+ export {
22
+ BLOCK_VISIBILITY_VIEWPORTS
23
+ };
24
+ //# sourceMappingURL=constants.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/block-visibility/constants.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { desktop, tablet, mobile } from '@wordpress/icons';\n\n/**\n * The choices for the block visibility.\n * Must match those in packages/editor/src/components/preview-dropdown/index.js.\n *\n * @todo create a single source of truth for the viewport types.\n */\nexport const BLOCK_VISIBILITY_VIEWPORTS = {\n\tdesktop: {\n\t\tlabel: __( 'Desktop' ),\n\t\ticon: desktop,\n\t\tvalue: 'desktop',\n\t},\n\ttablet: {\n\t\tlabel: __( 'Tablet' ),\n\t\ticon: tablet,\n\t\tvalue: 'tablet',\n\t},\n\tmobile: {\n\t\tlabel: __( 'Mobile' ),\n\t\ticon: mobile,\n\t\tvalue: 'mobile',\n\t},\n};\n"],
5
+ "mappings": ";AAGA,SAAS,UAAU;AACnB,SAAS,SAAS,QAAQ,cAAc;AAQjC,IAAM,6BAA6B;AAAA,EACzC,SAAS;AAAA,IACR,OAAO,GAAI,SAAU;AAAA,IACrB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,QAAQ;AAAA,IACP,OAAO,GAAI,QAAS;AAAA,IACpB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AAAA,EACA,QAAQ;AAAA,IACP,OAAO,GAAI,QAAS;AAAA,IACpB,MAAM;AAAA,IACN,OAAO;AAAA,EACR;AACD;",
6
+ "names": []
7
+ }
@@ -1,8 +1,10 @@
1
1
  // packages/block-editor/src/components/block-visibility/index.js
2
2
  import { default as default2 } from "./menu-item.mjs";
3
3
  import { default as default3 } from "./toolbar.mjs";
4
+ import { useBlockVisibility } from "./use-block-visibility.mjs";
4
5
  export {
5
6
  default2 as BlockVisibilityMenuItem,
6
- default3 as BlockVisibilityToolbar
7
+ default3 as BlockVisibilityToolbar,
8
+ useBlockVisibility
7
9
  };
8
10
  //# sourceMappingURL=index.mjs.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/block-visibility/index.js"],
4
- "sourcesContent": ["export { default as BlockVisibilityMenuItem } from './menu-item';\nexport { default as BlockVisibilityToolbar } from './toolbar';\n"],
5
- "mappings": ";AAAA,SAAoB,WAAXA,gBAA0C;AACnD,SAAoB,WAAXA,gBAAyC;",
4
+ "sourcesContent": ["export { default as BlockVisibilityMenuItem } from './menu-item';\nexport { default as BlockVisibilityToolbar } from './toolbar';\nexport { useBlockVisibility } from './use-block-visibility';\n"],
5
+ "mappings": ";AAAA,SAAoB,WAAXA,gBAA0C;AACnD,SAAoB,WAAXA,gBAAyC;AAClD,SAAS,0BAA0B;",
6
6
  "names": ["default"]
7
7
  }
@@ -0,0 +1,44 @@
1
+ // packages/block-editor/src/components/block-visibility/use-block-visibility.js
2
+ import { useViewportMatch } from "@wordpress/compose";
3
+ import { useMemo } from "@wordpress/element";
4
+ import { BLOCK_VISIBILITY_VIEWPORTS } from "./constants.mjs";
5
+ function useBlockVisibility(options = {}) {
6
+ const {
7
+ blockVisibility = void 0,
8
+ deviceType = BLOCK_VISIBILITY_VIEWPORTS.desktop.value
9
+ } = options;
10
+ const isLargerThanMobile = useViewportMatch("mobile", ">=");
11
+ const isLargerThanTablet = useViewportMatch("medium", ">=");
12
+ const currentViewport = useMemo(() => {
13
+ if (deviceType === BLOCK_VISIBILITY_VIEWPORTS.mobile.value) {
14
+ return BLOCK_VISIBILITY_VIEWPORTS.mobile.value;
15
+ }
16
+ if (deviceType === BLOCK_VISIBILITY_VIEWPORTS.tablet.value) {
17
+ return BLOCK_VISIBILITY_VIEWPORTS.tablet.value;
18
+ }
19
+ if (!isLargerThanMobile) {
20
+ return BLOCK_VISIBILITY_VIEWPORTS.mobile.value;
21
+ }
22
+ if (isLargerThanMobile && !isLargerThanTablet) {
23
+ return BLOCK_VISIBILITY_VIEWPORTS.tablet.value;
24
+ }
25
+ return BLOCK_VISIBILITY_VIEWPORTS.desktop.value;
26
+ }, [deviceType, isLargerThanMobile, isLargerThanTablet]);
27
+ const isBlockCurrentlyHidden = useMemo(() => {
28
+ if (blockVisibility === false) {
29
+ return true;
30
+ }
31
+ if (window.__experimentalHideBlocksBasedOnScreenSize && blockVisibility?.[currentViewport] === false) {
32
+ return true;
33
+ }
34
+ return false;
35
+ }, [blockVisibility, currentViewport]);
36
+ return useMemo(
37
+ () => ({ isBlockCurrentlyHidden, currentViewport }),
38
+ [isBlockCurrentlyHidden, currentViewport]
39
+ );
40
+ }
41
+ export {
42
+ useBlockVisibility
43
+ };
44
+ //# sourceMappingURL=use-block-visibility.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/block-visibility/use-block-visibility.js"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { BLOCK_VISIBILITY_VIEWPORTS } from './constants';\n\n/**\n * Determines if a block should be hidden based on visibility settings.\n *\n * Priority:\n * 1. Device type override (Mobile/Tablet) - uses device type to determine viewport\n * 2. Actual window size (Desktop mode) - uses viewport detection\n *\n * @param {Object} options Parameters to avoid extra store subscriptions.\n * @param {Object|boolean} options.blockVisibility Block visibility metadata.\n * @param {string} options.deviceType Current device type ('desktop', 'tablet', 'mobile').\n * @return {Object} Object with `isBlockCurrentlyHidden` boolean property.\n */\nexport function useBlockVisibility( options = {} ) {\n\tconst {\n\t\tblockVisibility = undefined,\n\t\tdeviceType = BLOCK_VISIBILITY_VIEWPORTS.desktop.value,\n\t} = options;\n\n\tconst isLargerThanMobile = useViewportMatch( 'mobile', '>=' ); // >= 480px\n\tconst isLargerThanTablet = useViewportMatch( 'medium', '>=' ); // >= 782px\n\n\t/*\n\t * When Desktop is selected, use actual viewport detection.\n\t * When Mobile/Tablet is selected, override with device type.\n\t */\n\tconst currentViewport = useMemo( () => {\n\t\tif ( deviceType === BLOCK_VISIBILITY_VIEWPORTS.mobile.value ) {\n\t\t\treturn BLOCK_VISIBILITY_VIEWPORTS.mobile.value;\n\t\t}\n\t\tif ( deviceType === BLOCK_VISIBILITY_VIEWPORTS.tablet.value ) {\n\t\t\treturn BLOCK_VISIBILITY_VIEWPORTS.tablet.value;\n\t\t}\n\t\tif ( ! isLargerThanMobile ) {\n\t\t\treturn BLOCK_VISIBILITY_VIEWPORTS.mobile.value;\n\t\t}\n\t\tif ( isLargerThanMobile && ! isLargerThanTablet ) {\n\t\t\treturn BLOCK_VISIBILITY_VIEWPORTS.tablet.value;\n\t\t}\n\t\treturn BLOCK_VISIBILITY_VIEWPORTS.desktop.value;\n\t}, [ deviceType, isLargerThanMobile, isLargerThanTablet ] );\n\n\t// Determine if block is currently hidden.\n\tconst isBlockCurrentlyHidden = useMemo( () => {\n\t\tif ( blockVisibility === false ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif (\n\t\t\twindow.__experimentalHideBlocksBasedOnScreenSize &&\n\t\t\tblockVisibility?.[ currentViewport ] === false\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}, [ blockVisibility, currentViewport ] );\n\n\treturn useMemo(\n\t\t() => ( { isBlockCurrentlyHidden, currentViewport } ),\n\t\t[ isBlockCurrentlyHidden, currentViewport ]\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,wBAAwB;AACjC,SAAS,eAAe;AAKxB,SAAS,kCAAkC;AAcpC,SAAS,mBAAoB,UAAU,CAAC,GAAI;AAClD,QAAM;AAAA,IACL,kBAAkB;AAAA,IAClB,aAAa,2BAA2B,QAAQ;AAAA,EACjD,IAAI;AAEJ,QAAM,qBAAqB,iBAAkB,UAAU,IAAK;AAC5D,QAAM,qBAAqB,iBAAkB,UAAU,IAAK;AAM5D,QAAM,kBAAkB,QAAS,MAAM;AACtC,QAAK,eAAe,2BAA2B,OAAO,OAAQ;AAC7D,aAAO,2BAA2B,OAAO;AAAA,IAC1C;AACA,QAAK,eAAe,2BAA2B,OAAO,OAAQ;AAC7D,aAAO,2BAA2B,OAAO;AAAA,IAC1C;AACA,QAAK,CAAE,oBAAqB;AAC3B,aAAO,2BAA2B,OAAO;AAAA,IAC1C;AACA,QAAK,sBAAsB,CAAE,oBAAqB;AACjD,aAAO,2BAA2B,OAAO;AAAA,IAC1C;AACA,WAAO,2BAA2B,QAAQ;AAAA,EAC3C,GAAG,CAAE,YAAY,oBAAoB,kBAAmB,CAAE;AAG1D,QAAM,yBAAyB,QAAS,MAAM;AAC7C,QAAK,oBAAoB,OAAQ;AAChC,aAAO;AAAA,IACR;AAEA,QACC,OAAO,6CACP,kBAAmB,eAAgB,MAAM,OACxC;AACD,aAAO;AAAA,IACR;AAEA,WAAO;AAAA,EACR,GAAG,CAAE,iBAAiB,eAAgB,CAAE;AAExC,SAAO;AAAA,IACN,OAAQ,EAAE,wBAAwB,gBAAgB;AAAA,IAClD,CAAE,wBAAwB,eAAgB;AAAA,EAC3C;AACD;",
6
+ "names": []
7
+ }
@@ -1,6 +1,6 @@
1
1
  // packages/block-editor/src/components/collab/block-comment-icon-slot.js
2
2
  import { createSlotFill } from "@wordpress/components";
3
- var CommentIconSlotFill = createSlotFill(Symbol("CommentIconSlotFill"));
3
+ var CommentIconSlotFill = createSlotFill(/* @__PURE__ */ Symbol("CommentIconSlotFill"));
4
4
  var block_comment_icon_slot_default = CommentIconSlotFill;
5
5
  export {
6
6
  block_comment_icon_slot_default as default
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab/block-comment-icon-slot.js"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst CommentIconSlotFill = createSlotFill( Symbol( 'CommentIconSlotFill' ) );\n\nexport default CommentIconSlotFill;\n"],
5
- "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,sBAAsB,eAAgB,OAAQ,qBAAsB,CAAE;AAE5E,IAAO,kCAAQ;",
5
+ "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,sBAAsB,eAAgB,uBAAQ,qBAAsB,CAAE;AAE5E,IAAO,kCAAQ;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  // packages/block-editor/src/components/collab/block-comment-icon-toolbar-slot.js
2
2
  import { createSlotFill } from "@wordpress/components";
3
3
  var CommentIconToolbarSlotFill = createSlotFill(
4
- Symbol("CommentIconToolbarSlotFill")
4
+ /* @__PURE__ */ Symbol("CommentIconToolbarSlotFill")
5
5
  );
6
6
  var block_comment_icon_toolbar_slot_default = CommentIconToolbarSlotFill;
7
7
  export {
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/collab/block-comment-icon-toolbar-slot.js"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst CommentIconToolbarSlotFill = createSlotFill(\n\tSymbol( 'CommentIconToolbarSlotFill' )\n);\n\nexport default CommentIconToolbarSlotFill;\n"],
5
- "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,6BAA6B;AAAA,EAClC,OAAQ,4BAA6B;AACtC;AAEA,IAAO,0CAAQ;",
5
+ "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,6BAA6B;AAAA,EAClC,uBAAQ,4BAA6B;AACtC;AAEA,IAAO,0CAAQ;",
6
6
  "names": []
7
7
  }
@@ -40,7 +40,7 @@ var groups = {
40
40
  };
41
41
  var groups_default = groups;
42
42
  var PrivateInspectorControlsAllowedBlocks = createSlotFill(
43
- Symbol("PrivateInspectorControlsAllowedBlocks")
43
+ /* @__PURE__ */ Symbol("PrivateInspectorControlsAllowedBlocks")
44
44
  );
45
45
  export {
46
46
  PrivateInspectorControlsAllowedBlocks,
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/inspector-controls/groups.js"],
4
4
  "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSlotFill } from '@wordpress/components';\n\nconst InspectorControlsDefault = createSlotFill( 'InspectorControls' );\nconst InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );\nconst InspectorControlsBindings = createSlotFill( 'InspectorControlsBindings' );\nconst InspectorControlsBackground = createSlotFill(\n\t'InspectorControlsBackground'\n);\nconst InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );\nconst InspectorControlsColor = createSlotFill( 'InspectorControlsColor' );\nconst InspectorControlsFilter = createSlotFill( 'InspectorControlsFilter' );\nconst InspectorControlsDimensions = createSlotFill(\n\t'InspectorControlsDimensions'\n);\nconst InspectorControlsPosition = createSlotFill( 'InspectorControlsPosition' );\nconst InspectorControlsTypography = createSlotFill(\n\t'InspectorControlsTypography'\n);\nconst InspectorControlsListView = createSlotFill( 'InspectorControlsListView' );\nconst InspectorControlsStyles = createSlotFill( 'InspectorControlsStyles' );\nconst InspectorControlsEffects = createSlotFill( 'InspectorControlsEffects' );\nconst InspectorControlsContent = createSlotFill( 'InspectorControlsContent' );\n\nconst groups = {\n\tdefault: InspectorControlsDefault,\n\tadvanced: InspectorControlsAdvanced,\n\tbackground: InspectorControlsBackground,\n\tbindings: InspectorControlsBindings,\n\tborder: InspectorControlsBorder,\n\tcolor: InspectorControlsColor,\n\tcontent: InspectorControlsContent,\n\tdimensions: InspectorControlsDimensions,\n\teffects: InspectorControlsEffects,\n\tfilter: InspectorControlsFilter,\n\tlist: InspectorControlsListView,\n\tposition: InspectorControlsPosition,\n\tsettings: InspectorControlsDefault, // Alias for default.\n\tstyles: InspectorControlsStyles,\n\ttypography: InspectorControlsTypography,\n};\n\nexport default groups;\n\n// Private slot for allowed blocks control UI.\nexport const PrivateInspectorControlsAllowedBlocks = createSlotFill(\n\tSymbol( 'PrivateInspectorControlsAllowedBlocks' )\n);\n"],
5
- "mappings": ";AAGA,SAAS,sBAAsB;AAE/B,IAAM,2BAA2B,eAAgB,mBAAoB;AACrE,IAAM,4BAA4B,eAAgB,2BAA4B;AAC9E,IAAM,4BAA4B,eAAgB,2BAA4B;AAC9E,IAAM,8BAA8B;AAAA,EACnC;AACD;AACA,IAAM,0BAA0B,eAAgB,yBAA0B;AAC1E,IAAM,yBAAyB,eAAgB,wBAAyB;AACxE,IAAM,0BAA0B,eAAgB,yBAA0B;AAC1E,IAAM,8BAA8B;AAAA,EACnC;AACD;AACA,IAAM,4BAA4B,eAAgB,2BAA4B;AAC9E,IAAM,8BAA8B;AAAA,EACnC;AACD;AACA,IAAM,4BAA4B,eAAgB,2BAA4B;AAC9E,IAAM,0BAA0B,eAAgB,yBAA0B;AAC1E,IAAM,2BAA2B,eAAgB,0BAA2B;AAC5E,IAAM,2BAA2B,eAAgB,0BAA2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,IAAM,wCAAwC;AAAA,EACpD,uBAAQ,uCAAwC;AACjD;",
6
6
  "names": []
7
7
  }
@@ -7,7 +7,7 @@ var ContentTab = ({ contentClientIds }) => {
7
7
  if (!contentClientIds || contentClientIds.length === 0) {
8
8
  return null;
9
9
  }
10
- const shouldShowBlockFields = window?.__experimentalContentOnlyPatternInsertion && window?.__experimentalContentOnlyInspectorFields;
10
+ const shouldShowBlockFields = window?.__experimentalContentOnlyInspectorFields;
11
11
  return /* @__PURE__ */ jsx(Fragment, { children: !shouldShowBlockFields && /* @__PURE__ */ jsx(PanelBody, { title: __("Content"), children: /* @__PURE__ */ jsx(BlockQuickNavigation, { clientIds: contentClientIds }) }) });
12
12
  };
13
13
  var content_tab_default = ContentTab;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/inspector-controls-tabs/content-tab.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockQuickNavigation from '../block-quick-navigation';\n\nconst ContentTab = ( { contentClientIds } ) => {\n\tif ( ! contentClientIds || contentClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowBlockFields =\n\t\twindow?.__experimentalContentOnlyPatternInsertion &&\n\t\twindow?.__experimentalContentOnlyInspectorFields;\n\n\treturn (\n\t\t<>\n\t\t\t{ ! shouldShowBlockFields && (\n\t\t\t\t<PanelBody title={ __( 'Content' ) }>\n\t\t\t\t\t<BlockQuickNavigation clientIds={ contentClientIds } />\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default ContentTab;\n"],
5
- "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,0BAA0B;AAY/B,mBAGG,WAHH;AAVF,IAAM,aAAa,CAAE,EAAE,iBAAiB,MAAO;AAC9C,MAAK,CAAE,oBAAoB,iBAAiB,WAAW,GAAI;AAC1D,WAAO;AAAA,EACR;AAEA,QAAM,wBACL,QAAQ,6CACR,QAAQ;AAET,SACC,gCACG,WAAE,yBACH,oBAAC,aAAU,OAAQ,GAAI,SAAU,GAChC,8BAAC,wBAAqB,WAAY,kBAAmB,GACtD,GAEF;AAEF;AAEA,IAAO,sBAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { PanelBody } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport BlockQuickNavigation from '../block-quick-navigation';\n\nconst ContentTab = ( { contentClientIds } ) => {\n\tif ( ! contentClientIds || contentClientIds.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst shouldShowBlockFields =\n\t\twindow?.__experimentalContentOnlyInspectorFields;\n\n\treturn (\n\t\t<>\n\t\t\t{ ! shouldShowBlockFields && (\n\t\t\t\t<PanelBody title={ __( 'Content' ) }>\n\t\t\t\t\t<BlockQuickNavigation clientIds={ contentClientIds } />\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default ContentTab;\n"],
5
+ "mappings": ";AAGA,SAAS,iBAAiB;AAC1B,SAAS,UAAU;AAKnB,OAAO,0BAA0B;AAW/B,mBAGG,WAHH;AATF,IAAM,aAAa,CAAE,EAAE,iBAAiB,MAAO;AAC9C,MAAK,CAAE,oBAAoB,iBAAiB,WAAW,GAAI;AAC1D,WAAO;AAAA,EACR;AAEA,QAAM,wBACL,QAAQ;AAET,SACC,gCACG,WAAE,yBACH,oBAAC,aAAU,OAAQ,GAAI,SAAU,GAChC,8BAAC,wBAAqB,WAAY,kBAAmB,GACtD,GAEF;AAEF;AAEA,IAAO,sBAAQ;",
6
6
  "names": []
7
7
  }
@@ -13,7 +13,6 @@ import { AsyncModeProvider, useSelect } from "@wordpress/data";
13
13
  import deprecated from "@wordpress/deprecated";
14
14
  import {
15
15
  useCallback,
16
- useEffect,
17
16
  useMemo,
18
17
  useRef,
19
18
  useReducer,
@@ -79,7 +78,7 @@ function ListViewComponent({
79
78
  const instanceId = useInstanceId(ListViewComponent);
80
79
  const { clientIdsTree, draggedClientIds, selectedClientIds } = useListViewClientIds({ blocks, rootClientId });
81
80
  const blockIndexes = useListViewBlockIndexes(clientIdsTree);
82
- const { getBlock } = useSelect(blockEditorStore);
81
+ const { getBlock, getSelectedBlockClientIds } = useSelect(blockEditorStore);
83
82
  const { visibleBlockCount } = useSelect(
84
83
  (select) => {
85
84
  const { getGlobalBlockCount, getClientIdsOfDescendants } = select(blockEditorStore);
@@ -121,17 +120,22 @@ function ListViewComponent({
121
120
  const clipBoardRef = useClipboardHandler({
122
121
  selectBlock: selectEditorBlock
123
122
  });
123
+ const focusSelectedBlock = useCallback(
124
+ (node) => {
125
+ const [firstSelectedClientId] = getSelectedBlockClientIds();
126
+ if (firstSelectedClientId && node) {
127
+ focusListItem(firstSelectedClientId, node);
128
+ }
129
+ },
130
+ [getSelectedBlockClientIds]
131
+ );
124
132
  const treeGridRef = useMergeRefs([
125
133
  clipBoardRef,
134
+ focusSelectedBlock,
126
135
  elementRef,
127
136
  dropZoneRef,
128
137
  ref
129
138
  ]);
130
- useEffect(() => {
131
- if (selectedClientIds?.length) {
132
- focusListItem(selectedClientIds[0], elementRef?.current);
133
- }
134
- }, []);
135
139
  const expand = useCallback(
136
140
  (clientId) => {
137
141
  if (!clientId) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/list-view/index.js"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\tVisuallyHidden,\n} 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 ListViewDropIndicatorPreview from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewBlockIndexes from './use-list-view-block-indexes';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewCollapseItems from './use-list-view-collapse-items';\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';\nimport { focusListItem } from './utils';\nimport useClipboardHandler from './use-clipboard-handler';\n\nconst expanded = ( state, action ) => {\n\tif ( action.type === 'clear' ) {\n\t\treturn {};\n\t}\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 = 32;\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\tconst blockIndexes = useListViewBlockIndexes( clientIdsTree );\n\n\tconst { getBlock } = useSelect( blockEditorStore );\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } =\n\t\t\t\tselect( 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};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\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\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t\texpandedState,\n\t\tsetExpandedState,\n\t} );\n\tconst elementRef = useRef();\n\n\t// Allow handling of copy, cut, and paste events.\n\tconst clipBoardRef = useClipboardHandler( {\n\t\tselectBlock: selectEditorBlock,\n\t} );\n\n\tconst treeGridRef = useMergeRefs( [\n\t\tclipBoardRef,\n\t\telementRef,\n\t\tdropZoneRef,\n\t\tref,\n\t] );\n\n\tuseEffect( () => {\n\t\t// If a blocks are already selected when the list view is initially\n\t\t// mounted, shift focus to the first selected block.\n\t\tif ( selectedClientIds?.length ) {\n\t\t\tfocusListItem( selectedClientIds[ 0 ], elementRef?.current );\n\t\t}\n\t\t// Only focus on the selected item when the list view is mounted.\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\tconst clientIds = Array.isArray( clientId )\n\t\t\t\t? clientId\n\t\t\t\t: [ clientId ];\n\t\t\tsetExpandedState( { type: 'expand', clientIds } );\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 collapseAll = useCallback( () => {\n\t\tsetExpandedState( { type: 'clear' } );\n\t}, [ setExpandedState ] );\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\tuseListViewCollapseItems( {\n\t\tcollapseAll,\n\t\texpand,\n\t} );\n\n\tconst firstDraggedBlockClientId = draggedClientIds?.[ 0 ];\n\n\t// Convert a blockDropTarget into indexes relative to the blocks in the list view.\n\t// These values are used to determine which blocks should be displaced to make room\n\t// for the drop indicator. See `ListViewBranch` and `getDragDisplacementValues`.\n\tconst { blockDropTargetIndex, blockDropPosition, firstDraggedBlockIndex } =\n\t\tuseMemo( () => {\n\t\t\tlet _blockDropTargetIndex, _firstDraggedBlockIndex;\n\n\t\t\tif ( blockDropTarget?.clientId ) {\n\t\t\t\tconst foundBlockIndex =\n\t\t\t\t\tblockIndexes[ blockDropTarget.clientId ];\n\t\t\t\t// If dragging below or inside the block, treat the drop target as the next block.\n\t\t\t\t_blockDropTargetIndex =\n\t\t\t\t\tfoundBlockIndex === undefined ||\n\t\t\t\t\tblockDropTarget?.dropPosition === 'top'\n\t\t\t\t\t\t? foundBlockIndex\n\t\t\t\t\t\t: foundBlockIndex + 1;\n\t\t\t} else if ( blockDropTarget === null ) {\n\t\t\t\t// A `null` value is used to indicate that the user is dragging outside of the list view.\n\t\t\t\t_blockDropTargetIndex = null;\n\t\t\t}\n\n\t\t\tif ( firstDraggedBlockClientId ) {\n\t\t\t\tconst foundBlockIndex =\n\t\t\t\t\tblockIndexes[ firstDraggedBlockClientId ];\n\t\t\t\t_firstDraggedBlockIndex =\n\t\t\t\t\tfoundBlockIndex === undefined ||\n\t\t\t\t\tblockDropTarget?.dropPosition === 'top'\n\t\t\t\t\t\t? foundBlockIndex\n\t\t\t\t\t\t: foundBlockIndex + 1;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tblockDropTargetIndex: _blockDropTargetIndex,\n\t\t\t\tblockDropPosition: blockDropTarget?.dropPosition,\n\t\t\t\tfirstDraggedBlockIndex: _firstDraggedBlockIndex,\n\t\t\t};\n\t\t}, [ blockDropTarget, blockIndexes, firstDraggedBlockClientId ] );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tblockDropPosition,\n\t\t\tblockDropTargetIndex,\n\t\t\tblockIndexes,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tfirstDraggedBlockIndex,\n\t\t\tcollapse,\n\t\t\tcollapseAll,\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\trootClientId,\n\t\t} ),\n\t\t[\n\t\t\tblockDropPosition,\n\t\t\tblockDropTargetIndex,\n\t\t\tblockIndexes,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tfirstDraggedBlockIndex,\n\t\t\tcollapse,\n\t\t\tcollapseAll,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\trootClientId,\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\tconst describedById =\n\t\tdescription && `block-editor-list-view-description-${ instanceId }`;\n\n\treturn (\n\t\t<AsyncModeProvider value>\n\t\t\t<ListViewDropIndicatorPreview\n\t\t\t\tdraggedBlockClientId={ firstDraggedBlockClientId }\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t{ description && (\n\t\t\t\t<VisuallyHidden id={ describedById }>\n\t\t\t\t\t{ description }\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName={ clsx( 'block-editor-list-view-tree', {\n\t\t\t\t\t'is-dragging':\n\t\t\t\t\t\tdraggedClientIds?.length > 0 &&\n\t\t\t\t\t\tblockDropTargetIndex !== undefined,\n\t\t\t\t} ) }\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\taria-describedby={ describedById }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-admin--list-view-dragged-items-height':\n\t\t\t\t\t\tdraggedClientIds?.length\n\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\tBLOCK_LIST_ITEM_HEIGHT *\n\t\t\t\t\t\t\t\t\t( draggedClientIds.length - 1 )\n\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t: null,\n\t\t\t\t} }\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\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\tadditional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mBAAoB;AAAA;AAAA,EACrB;AAEF,CAAE;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseInstanceId,\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport {\n\t__experimentalTreeGrid as TreeGrid,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport {\n\tuseCallback,\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 ListViewDropIndicatorPreview from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewBlockIndexes from './use-list-view-block-indexes';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewCollapseItems from './use-list-view-collapse-items';\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';\nimport { focusListItem } from './utils';\nimport useClipboardHandler from './use-clipboard-handler';\n\nconst expanded = ( state, action ) => {\n\tif ( action.type === 'clear' ) {\n\t\treturn {};\n\t}\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 = 32;\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\tconst blockIndexes = useListViewBlockIndexes( clientIdsTree );\n\n\tconst { getBlock, getSelectedBlockClientIds } =\n\t\tuseSelect( blockEditorStore );\n\tconst { visibleBlockCount } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getGlobalBlockCount, getClientIdsOfDescendants } =\n\t\t\t\tselect( 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};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\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\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone( {\n\t\tdropZoneElement,\n\t\texpandedState,\n\t\tsetExpandedState,\n\t} );\n\tconst elementRef = useRef();\n\n\t// Allow handling of copy, cut, and paste events.\n\tconst clipBoardRef = useClipboardHandler( {\n\t\tselectBlock: selectEditorBlock,\n\t} );\n\n\tconst focusSelectedBlock = useCallback(\n\t\t( node ) => {\n\t\t\tconst [ firstSelectedClientId ] = getSelectedBlockClientIds();\n\t\t\t// If a blocks are already selected when the list view is initially\n\t\t\t// mounted, shift focus to the first selected block.\n\t\t\tif ( firstSelectedClientId && node ) {\n\t\t\t\tfocusListItem( firstSelectedClientId, node );\n\t\t\t}\n\t\t},\n\t\t[ getSelectedBlockClientIds ]\n\t);\n\n\tconst treeGridRef = useMergeRefs( [\n\t\tclipBoardRef,\n\t\tfocusSelectedBlock,\n\t\telementRef,\n\t\tdropZoneRef,\n\t\tref,\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\tconst clientIds = Array.isArray( clientId )\n\t\t\t\t? clientId\n\t\t\t\t: [ clientId ];\n\t\t\tsetExpandedState( { type: 'expand', clientIds } );\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 collapseAll = useCallback( () => {\n\t\tsetExpandedState( { type: 'clear' } );\n\t}, [ setExpandedState ] );\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\tuseListViewCollapseItems( {\n\t\tcollapseAll,\n\t\texpand,\n\t} );\n\n\tconst firstDraggedBlockClientId = draggedClientIds?.[ 0 ];\n\n\t// Convert a blockDropTarget into indexes relative to the blocks in the list view.\n\t// These values are used to determine which blocks should be displaced to make room\n\t// for the drop indicator. See `ListViewBranch` and `getDragDisplacementValues`.\n\tconst { blockDropTargetIndex, blockDropPosition, firstDraggedBlockIndex } =\n\t\tuseMemo( () => {\n\t\t\tlet _blockDropTargetIndex, _firstDraggedBlockIndex;\n\n\t\t\tif ( blockDropTarget?.clientId ) {\n\t\t\t\tconst foundBlockIndex =\n\t\t\t\t\tblockIndexes[ blockDropTarget.clientId ];\n\t\t\t\t// If dragging below or inside the block, treat the drop target as the next block.\n\t\t\t\t_blockDropTargetIndex =\n\t\t\t\t\tfoundBlockIndex === undefined ||\n\t\t\t\t\tblockDropTarget?.dropPosition === 'top'\n\t\t\t\t\t\t? foundBlockIndex\n\t\t\t\t\t\t: foundBlockIndex + 1;\n\t\t\t} else if ( blockDropTarget === null ) {\n\t\t\t\t// A `null` value is used to indicate that the user is dragging outside of the list view.\n\t\t\t\t_blockDropTargetIndex = null;\n\t\t\t}\n\n\t\t\tif ( firstDraggedBlockClientId ) {\n\t\t\t\tconst foundBlockIndex =\n\t\t\t\t\tblockIndexes[ firstDraggedBlockClientId ];\n\t\t\t\t_firstDraggedBlockIndex =\n\t\t\t\t\tfoundBlockIndex === undefined ||\n\t\t\t\t\tblockDropTarget?.dropPosition === 'top'\n\t\t\t\t\t\t? foundBlockIndex\n\t\t\t\t\t\t: foundBlockIndex + 1;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tblockDropTargetIndex: _blockDropTargetIndex,\n\t\t\t\tblockDropPosition: blockDropTarget?.dropPosition,\n\t\t\t\tfirstDraggedBlockIndex: _firstDraggedBlockIndex,\n\t\t\t};\n\t\t}, [ blockDropTarget, blockIndexes, firstDraggedBlockClientId ] );\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tblockDropPosition,\n\t\t\tblockDropTargetIndex,\n\t\t\tblockIndexes,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tfirstDraggedBlockIndex,\n\t\t\tcollapse,\n\t\t\tcollapseAll,\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\trootClientId,\n\t\t} ),\n\t\t[\n\t\t\tblockDropPosition,\n\t\t\tblockDropTargetIndex,\n\t\t\tblockIndexes,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tfirstDraggedBlockIndex,\n\t\t\tcollapse,\n\t\t\tcollapseAll,\n\t\t\tBlockSettingsMenu,\n\t\t\tinstanceId,\n\t\t\tAdditionalBlockContent,\n\t\t\tinsertedBlock,\n\t\t\tsetInsertedBlock,\n\t\t\trootClientId,\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\tconst describedById =\n\t\tdescription && `block-editor-list-view-description-${ instanceId }`;\n\n\treturn (\n\t\t<AsyncModeProvider value>\n\t\t\t<ListViewDropIndicatorPreview\n\t\t\t\tdraggedBlockClientId={ firstDraggedBlockClientId }\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t{ description && (\n\t\t\t\t<VisuallyHidden id={ describedById }>\n\t\t\t\t\t{ description }\n\t\t\t\t</VisuallyHidden>\n\t\t\t) }\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName={ clsx( 'block-editor-list-view-tree', {\n\t\t\t\t\t'is-dragging':\n\t\t\t\t\t\tdraggedClientIds?.length > 0 &&\n\t\t\t\t\t\tblockDropTargetIndex !== undefined,\n\t\t\t\t} ) }\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\taria-describedby={ describedById }\n\t\t\t\tstyle={ {\n\t\t\t\t\t'--wp-admin--list-view-dragged-items-height':\n\t\t\t\t\t\tdraggedClientIds?.length\n\t\t\t\t\t\t\t? `${\n\t\t\t\t\t\t\t\t\tBLOCK_LIST_ITEM_HEIGHT *\n\t\t\t\t\t\t\t\t\t( draggedClientIds.length - 1 )\n\t\t\t\t\t\t\t }px`\n\t\t\t\t\t\t\t: null,\n\t\t\t\t} }\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\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"],
5
+ "mappings": ";AAGA,OAAO,UAAU;AAKjB;AAAA,EACC;AAAA,EACA;AAAA,EACA,oCAAoC;AAAA,OAC9B;AACP;AAAA,EACC,0BAA0B;AAAA,EAC1B;AAAA,OACM;AACP,SAAS,mBAAmB,iBAAiB;AAC7C,OAAO,gBAAgB;AACvB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,UAAU;AAKnB,OAAO,oBAAoB;AAC3B,SAAS,uBAAuB;AAChC,OAAO,kCAAkC;AACzC,OAAO,uBAAuB;AAC9B,OAAO,6BAA6B;AACpC,OAAO,0BAA0B;AACjC,OAAO,8BAA8B;AACrC,OAAO,yBAAyB;AAChC,OAAO,mCAAmC;AAC1C,SAAS,SAAS,wBAAwB;AAC1C,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,OAAO,yBAAyB;AAsT9B,SACC,KADD;AApTF,IAAM,WAAW,CAAE,OAAO,WAAY;AACrC,MAAK,OAAO,SAAS,SAAU;AAC9B,WAAO,CAAC;AAAA,EACT;AACA,MAAK,MAAM,QAAS,OAAO,SAAU,GAAI;AACxC,WAAO;AAAA,M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f,GACA,0BACE,iBAAiB,SAAS,EAC5B,OACA;AAAA,QACL;AAAA,QAEA,8BAAC,gBAAgB,UAAhB,EAAyB,OAAQ,cACjC;AAAA,UAAC;AAAA;AAAA,YACA,QAAS;AAAA,YACT,UAAW;AAAA,YACX,aAAc;AAAA,YACd;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD,GACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;AAIO,IAAM,kBAAkB,WAAY,iBAAkB;AAI7D,IAAO,oBAAQ,WAAY,CAAE,OAAO,QAAS;AAC5C,SACC;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACE,GAAG;AAAA,MACL,cAAe;AAAA,MACf,cAAe;AAAA,MACf,UAAW;AAAA,MACX,wBAAyB;AAAA,MACzB,mBAAoB;AAAA;AAAA,EACrB;AAEF,CAAE;",
6
6
  "names": []
7
7
  }
@@ -29,26 +29,33 @@ function getCommonDepthClientIds(startId, endId, startParents, endParents) {
29
29
  };
30
30
  }
31
31
  function focusListItem(focusClientId, treeGridElement) {
32
- const getFocusElement = () => {
33
- const row = treeGridElement?.querySelector(
34
- `[role=row][data-block="${focusClientId}"]`
35
- );
36
- if (!row) {
37
- return null;
32
+ if (!treeGridElement) {
33
+ return;
34
+ }
35
+ const selector = `[role=row][data-block="${focusClientId}"]`;
36
+ return new Promise((resolve) => {
37
+ if (treeGridElement.querySelector(selector)) {
38
+ return resolve(treeGridElement.querySelector(selector));
38
39
  }
39
- return focus.focusable.find(row)[0];
40
- };
41
- let focusElement = getFocusElement();
42
- if (focusElement) {
43
- focusElement.focus();
44
- } else {
45
- window.requestAnimationFrame(() => {
46
- focusElement = getFocusElement();
47
- if (focusElement) {
48
- focusElement.focus();
40
+ let timer = null;
41
+ const observer = new window.MutationObserver(() => {
42
+ if (treeGridElement.querySelector(selector)) {
43
+ clearTimeout(timer);
44
+ observer.disconnect();
45
+ resolve(treeGridElement.querySelector(selector));
49
46
  }
50
47
  });
51
- }
48
+ observer.observe(treeGridElement, {
49
+ childList: true,
50
+ subtree: true
51
+ });
52
+ timer = setTimeout(() => {
53
+ observer.disconnect();
54
+ resolve(null);
55
+ }, 3e3);
56
+ }).then((element) => {
57
+ focus.focusable.find(element)?.[0]?.focus();
58
+ });
52
59
  }
53
60
  function getDragDisplacementValues({
54
61
  blockIndexes,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/list-view/utils.js"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { focus } from '@wordpress/dom';\n\nexport const getBlockPositionDescription = ( position, siblingCount, level ) =>\n\tsprintf(\n\t\t/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */\n\t\t__( 'Block %1$d of %2$d, Level %3$d.' ),\n\t\tposition,\n\t\tsiblingCount,\n\t\tlevel\n\t);\n\nexport const getBlockPropertiesDescription = ( blockInformation, isLocked ) =>\n\t[\n\t\tblockInformation?.positionLabel\n\t\t\t? `${ sprintf(\n\t\t\t\t\t// translators: %s: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t\t__( 'Position: %s' ),\n\t\t\t\t\tblockInformation.positionLabel\n\t\t\t ) }.`\n\t\t\t: undefined,\n\t\tisLocked ? __( 'This block is locked.' ) : undefined,\n\t]\n\t\t.filter( Boolean )\n\t\t.join( ' ' );\n\n/**\n * Returns true if the client ID occurs within the block selection or multi-selection,\n * or false otherwise.\n *\n * @param {string} clientId Block client ID.\n * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.\n *\n * @return {boolean} Whether the block is in multi-selection set.\n */\nexport const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>\n\tArray.isArray( selectedBlockClientIds ) && selectedBlockClientIds.length\n\t\t? selectedBlockClientIds.indexOf( clientId ) !== -1\n\t\t: selectedBlockClientIds === clientId;\n\n/**\n * From a start and end clientId of potentially different nesting levels,\n * return the nearest-depth ids that have a common level of depth in the\n * nesting hierarchy. For multiple block selection, this ensure that the\n * selection is always at the same nesting level, and not split across\n * separate levels.\n *\n * @param {string} startId The first id of a selection.\n * @param {string} endId The end id of a selection, usually one that has been clicked on.\n * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.\n * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.\n * @return {Object} An object containing the start and end ids.\n */\nexport function getCommonDepthClientIds(\n\tstartId,\n\tendId,\n\tstartParents,\n\tendParents\n) {\n\tconst startPath = [ ...startParents, startId ];\n\tconst endPath = [ ...endParents, endId ];\n\tconst depth = Math.min( startPath.length, endPath.length ) - 1;\n\tconst start = startPath[ depth ];\n\tconst end = endPath[ depth ];\n\n\treturn {\n\t\tstart,\n\t\tend,\n\t};\n}\n\n/**\n * Shift focus to the list view item associated with a particular clientId.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {string} focusClientId The client ID of the block to focus.\n * @param {?HTMLElement} treeGridElement The container element to search within.\n */\nexport function focusListItem( focusClientId, treeGridElement ) {\n\tconst getFocusElement = () => {\n\t\tconst row = treeGridElement?.querySelector(\n\t\t\t`[role=row][data-block=\"${ focusClientId }\"]`\n\t\t);\n\t\tif ( ! row ) {\n\t\t\treturn null;\n\t\t}\n\t\t// Focus the first focusable in the row, which is the ListViewBlockSelectButton.\n\t\treturn focus.focusable.find( row )[ 0 ];\n\t};\n\n\tlet focusElement = getFocusElement();\n\tif ( focusElement ) {\n\t\tfocusElement.focus();\n\t} else {\n\t\t// The element hasn't been painted yet. Defer focusing on the next frame.\n\t\t// This could happen when all blocks have been deleted and the default block\n\t\t// hasn't been added to the editor yet.\n\t\twindow.requestAnimationFrame( () => {\n\t\t\tfocusElement = getFocusElement();\n\n\t\t\t// Ignore if the element still doesn't exist.\n\t\t\tif ( focusElement ) {\n\t\t\t\tfocusElement.focus();\n\t\t\t}\n\t\t} );\n\t}\n}\n\n/**\n * Get values for the block that flag whether the block should be displaced up or down,\n * whether the block is being nested, and whether the block appears after the dragged\n * blocks. These values are used to determine the class names to apply to the block.\n * The list view rows are displaced visually via CSS rules. Displacement rules:\n * - `normal`: no displacement \u2014 used to apply a translateY of `0` so that the block\n * appears in its original position, and moves to that position smoothly when dragging\n * outside of the list view area.\n * - `up`: the block should be displaced up, creating room beneath the block for the drop indicator.\n * - `down`: the block should be displaced down, creating room above the block for the drop indicator.\n *\n * @param {Object} props\n * @param {Object} props.blockIndexes The indexes of all the blocks in the list view, keyed by clientId.\n * @param {number|null|undefined} props.blockDropTargetIndex The index of the block that the user is dropping to.\n * @param {?string} props.blockDropPosition The position relative to the block that the user is dropping to.\n * @param {string} props.clientId The client id for the current block.\n * @param {?number} props.firstDraggedBlockIndex The index of the first dragged block.\n * @param {?boolean} props.isDragged Whether the current block is being dragged. Dragged blocks skip displacement.\n * @return {Object} An object containing the `displacement`, `isAfterDraggedBlocks` and `isNesting` values.\n */\nexport function getDragDisplacementValues( {\n\tblockIndexes,\n\tblockDropTargetIndex,\n\tblockDropPosition,\n\tclientId,\n\tfirstDraggedBlockIndex,\n\tisDragged,\n} ) {\n\tlet displacement;\n\tlet isNesting;\n\tlet isAfterDraggedBlocks;\n\n\tif ( ! isDragged ) {\n\t\tisNesting = false;\n\t\tconst thisBlockIndex = blockIndexes[ clientId ];\n\t\tisAfterDraggedBlocks = thisBlockIndex > firstDraggedBlockIndex;\n\n\t\t// Determine where to displace the position of the current block, relative\n\t\t// to the blocks being dragged (in their original position) and the drop target\n\t\t// (the position where a user is currently dragging the blocks to).\n\t\tif (\n\t\t\tblockDropTargetIndex !== undefined &&\n\t\t\tblockDropTargetIndex !== null &&\n\t\t\tfirstDraggedBlockIndex !== undefined\n\t\t) {\n\t\t\t// If the block is being dragged and there is a valid drop target,\n\t\t\t// determine if the block being rendered should be displaced up or down.\n\n\t\t\tif ( thisBlockIndex !== undefined ) {\n\t\t\t\tif (\n\t\t\t\t\tthisBlockIndex >= firstDraggedBlockIndex &&\n\t\t\t\t\tthisBlockIndex < blockDropTargetIndex\n\t\t\t\t) {\n\t\t\t\t\t// If the current block appears after the set of dragged blocks\n\t\t\t\t\t// (in their original position), but is before the drop target,\n\t\t\t\t\t// then the current block should be displaced up.\n\t\t\t\t\tdisplacement = 'up';\n\t\t\t\t} else if (\n\t\t\t\t\tthisBlockIndex < firstDraggedBlockIndex &&\n\t\t\t\t\tthisBlockIndex >= blockDropTargetIndex\n\t\t\t\t) {\n\t\t\t\t\t// If the current block appears before the set of dragged blocks\n\t\t\t\t\t// (in their original position), but is after the drop target,\n\t\t\t\t\t// then the current block should be displaced down.\n\t\t\t\t\tdisplacement = 'down';\n\t\t\t\t} else {\n\t\t\t\t\tdisplacement = 'normal';\n\t\t\t\t}\n\t\t\t\tisNesting =\n\t\t\t\t\ttypeof blockDropTargetIndex === 'number' &&\n\t\t\t\t\tblockDropTargetIndex - 1 === thisBlockIndex &&\n\t\t\t\t\tblockDropPosition === 'inside';\n\t\t\t}\n\t\t} else if (\n\t\t\tblockDropTargetIndex === null &&\n\t\t\tfirstDraggedBlockIndex !== undefined\n\t\t) {\n\t\t\t// A `null` value for `blockDropTargetIndex` indicates that the\n\t\t\t// drop target is outside of the valid areas within the list view.\n\t\t\t// In this case, the drag is still active, but as there is no\n\t\t\t// valid drop target, we should remove the gap indicating where\n\t\t\t// the block would be inserted.\n\t\t\tif (\n\t\t\t\tthisBlockIndex !== undefined &&\n\t\t\t\tthisBlockIndex >= firstDraggedBlockIndex\n\t\t\t) {\n\t\t\t\tdisplacement = 'up';\n\t\t\t} else {\n\t\t\t\tdisplacement = 'normal';\n\t\t\t}\n\t\t} else if (\n\t\t\tblockDropTargetIndex !== undefined &&\n\t\t\tblockDropTargetIndex !== null &&\n\t\t\tfirstDraggedBlockIndex === undefined\n\t\t) {\n\t\t\t// If the blockdrop target is defined, but there are no dragged blocks,\n\t\t\t// then the block should be displaced relative to the drop target.\n\t\t\tif ( thisBlockIndex !== undefined ) {\n\t\t\t\tif ( thisBlockIndex < blockDropTargetIndex ) {\n\t\t\t\t\tdisplacement = 'normal';\n\t\t\t\t} else {\n\t\t\t\t\tdisplacement = 'down';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( blockDropTargetIndex === null ) {\n\t\t\tdisplacement = 'normal';\n\t\t}\n\t}\n\n\treturn {\n\t\tdisplacement,\n\t\tisNesting,\n\t\tisAfterDraggedBlocks,\n\t};\n}\n"],
5
- "mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AAEf,IAAM,8BAA8B,CAAE,UAAU,cAAc,UACpE;AAAA;AAAA,EAEC,GAAI,iCAAkC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD;AAEM,IAAM,gCAAgC,CAAE,kBAAkB,aAChE;AAAA,EACC,kBAAkB,gBACf,GAAI;AAAA;AAAA,IAEJ,GAAI,cAAe;AAAA,IACnB,iBAAiB;AAAA,EACjB,CAAE,MACF;AAAA,EACH,WAAW,GAAI,uBAAwB,IAAI;AAC5C,EACE,OAAQ,OAAQ,EAChB,KAAM,GAAI;AAWN,IAAM,qBAAqB,CAAE,UAAU,2BAC7C,MAAM,QAAS,sBAAuB,KAAK,uBAAuB,SAC/D,uBAAuB,QAAS,QAAS,MAAM,KAC/C,2BAA2B;AAexB,SAAS,wBACf,SACA,OACA,cACA,YACC;AACD,QAAM,YAAY,CAAE,GAAG,cAAc,OAAQ;AAC7C,QAAM,UAAU,CAAE,GAAG,YAAY,KAAM;AACvC,QAAM,QAAQ,KAAK,IAAK,UAAU,QAAQ,QAAQ,MAAO,IAAI;AAC7D,QAAM,QAAQ,UAAW,KAAM;AAC/B,QAAM,MAAM,QAAS,KAAM;AAE3B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAUO,SAAS,cAAe,eAAe,iBAAkB;AAC/D,QAAM,kBAAkB,MAAM;AAC7B,UAAM,MAAM,iBAAiB;AAAA,MAC5B,0BAA2B,aAAc;AAAA,IAC1C;AACA,QAAK,CAAE,K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ACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { focus } from '@wordpress/dom';\n\nexport const getBlockPositionDescription = ( position, siblingCount, level ) =>\n\tsprintf(\n\t\t/* translators: 1: The numerical position of the block. 2: The total number of blocks. 3. The level of nesting for the block. */\n\t\t__( 'Block %1$d of %2$d, Level %3$d.' ),\n\t\tposition,\n\t\tsiblingCount,\n\t\tlevel\n\t);\n\nexport const getBlockPropertiesDescription = ( blockInformation, isLocked ) =>\n\t[\n\t\tblockInformation?.positionLabel\n\t\t\t? `${ sprintf(\n\t\t\t\t\t// translators: %s: Position of selected block, e.g. \"Sticky\" or \"Fixed\".\n\t\t\t\t\t__( 'Position: %s' ),\n\t\t\t\t\tblockInformation.positionLabel\n\t\t\t ) }.`\n\t\t\t: undefined,\n\t\tisLocked ? __( 'This block is locked.' ) : undefined,\n\t]\n\t\t.filter( Boolean )\n\t\t.join( ' ' );\n\n/**\n * Returns true if the client ID occurs within the block selection or multi-selection,\n * or false otherwise.\n *\n * @param {string} clientId Block client ID.\n * @param {string|string[]} selectedBlockClientIds Selected block client ID, or an array of multi-selected blocks client IDs.\n *\n * @return {boolean} Whether the block is in multi-selection set.\n */\nexport const isClientIdSelected = ( clientId, selectedBlockClientIds ) =>\n\tArray.isArray( selectedBlockClientIds ) && selectedBlockClientIds.length\n\t\t? selectedBlockClientIds.indexOf( clientId ) !== -1\n\t\t: selectedBlockClientIds === clientId;\n\n/**\n * From a start and end clientId of potentially different nesting levels,\n * return the nearest-depth ids that have a common level of depth in the\n * nesting hierarchy. For multiple block selection, this ensure that the\n * selection is always at the same nesting level, and not split across\n * separate levels.\n *\n * @param {string} startId The first id of a selection.\n * @param {string} endId The end id of a selection, usually one that has been clicked on.\n * @param {string[]} startParents An array of ancestor ids for the start id, in descending order.\n * @param {string[]} endParents An array of ancestor ids for the end id, in descending order.\n * @return {Object} An object containing the start and end ids.\n */\nexport function getCommonDepthClientIds(\n\tstartId,\n\tendId,\n\tstartParents,\n\tendParents\n) {\n\tconst startPath = [ ...startParents, startId ];\n\tconst endPath = [ ...endParents, endId ];\n\tconst depth = Math.min( startPath.length, endPath.length ) - 1;\n\tconst start = startPath[ depth ];\n\tconst end = endPath[ depth ];\n\n\treturn {\n\t\tstart,\n\t\tend,\n\t};\n}\n\n/**\n * Shift focus to the list view item associated with a particular clientId.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {string} focusClientId The client ID of the block to focus.\n * @param {?HTMLElement} treeGridElement The container element to search within.\n */\nexport function focusListItem( focusClientId, treeGridElement ) {\n\tif ( ! treeGridElement ) {\n\t\treturn;\n\t}\n\n\tconst selector = `[role=row][data-block=\"${ focusClientId }\"]`;\n\n\treturn new Promise( ( resolve ) => {\n\t\tif ( treeGridElement.querySelector( selector ) ) {\n\t\t\treturn resolve( treeGridElement.querySelector( selector ) );\n\t\t}\n\n\t\tlet timer = null;\n\t\t// Wait for the element to be added to the DOM.\n\t\tconst observer = new window.MutationObserver( () => {\n\t\t\tif ( treeGridElement.querySelector( selector ) ) {\n\t\t\t\tclearTimeout( timer );\n\t\t\t\tobserver.disconnect();\n\t\t\t\tresolve( treeGridElement.querySelector( selector ) );\n\t\t\t}\n\t\t} );\n\n\t\tobserver.observe( treeGridElement, {\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t} );\n\n\t\t// Stop trying after 3 seconds.\n\t\ttimer = setTimeout( () => {\n\t\t\tobserver.disconnect();\n\t\t\tresolve( null );\n\t\t}, 3000 );\n\t} ).then( ( element ) => {\n\t\t// Focus the first focusable in the row, which is the ListViewBlockSelectButton.\n\t\tfocus.focusable.find( element )?.[ 0 ]?.focus();\n\t} );\n}\n\n/**\n * Get values for the block that flag whether the block should be displaced up or down,\n * whether the block is being nested, and whether the block appears after the dragged\n * blocks. These values are used to determine the class names to apply to the block.\n * The list view rows are displaced visually via CSS rules. Displacement rules:\n * - `normal`: no displacement \u2014 used to apply a translateY of `0` so that the block\n * appears in its original position, and moves to that position smoothly when dragging\n * outside of the list view area.\n * - `up`: the block should be displaced up, creating room beneath the block for the drop indicator.\n * - `down`: the block should be displaced down, creating room above the block for the drop indicator.\n *\n * @param {Object} props\n * @param {Object} props.blockIndexes The indexes of all the blocks in the list view, keyed by clientId.\n * @param {number|null|undefined} props.blockDropTargetIndex The index of the block that the user is dropping to.\n * @param {?string} props.blockDropPosition The position relative to the block that the user is dropping to.\n * @param {string} props.clientId The client id for the current block.\n * @param {?number} props.firstDraggedBlockIndex The index of the first dragged block.\n * @param {?boolean} props.isDragged Whether the current block is being dragged. Dragged blocks skip displacement.\n * @return {Object} An object containing the `displacement`, `isAfterDraggedBlocks` and `isNesting` values.\n */\nexport function getDragDisplacementValues( {\n\tblockIndexes,\n\tblockDropTargetIndex,\n\tblockDropPosition,\n\tclientId,\n\tfirstDraggedBlockIndex,\n\tisDragged,\n} ) {\n\tlet displacement;\n\tlet isNesting;\n\tlet isAfterDraggedBlocks;\n\n\tif ( ! isDragged ) {\n\t\tisNesting = false;\n\t\tconst thisBlockIndex = blockIndexes[ clientId ];\n\t\tisAfterDraggedBlocks = thisBlockIndex > firstDraggedBlockIndex;\n\n\t\t// Determine where to displace the position of the current block, relative\n\t\t// to the blocks being dragged (in their original position) and the drop target\n\t\t// (the position where a user is currently dragging the blocks to).\n\t\tif (\n\t\t\tblockDropTargetIndex !== undefined &&\n\t\t\tblockDropTargetIndex !== null &&\n\t\t\tfirstDraggedBlockIndex !== undefined\n\t\t) {\n\t\t\t// If the block is being dragged and there is a valid drop target,\n\t\t\t// determine if the block being rendered should be displaced up or down.\n\n\t\t\tif ( thisBlockIndex !== undefined ) {\n\t\t\t\tif (\n\t\t\t\t\tthisBlockIndex >= firstDraggedBlockIndex &&\n\t\t\t\t\tthisBlockIndex < blockDropTargetIndex\n\t\t\t\t) {\n\t\t\t\t\t// If the current block appears after the set of dragged blocks\n\t\t\t\t\t// (in their original position), but is before the drop target,\n\t\t\t\t\t// then the current block should be displaced up.\n\t\t\t\t\tdisplacement = 'up';\n\t\t\t\t} else if (\n\t\t\t\t\tthisBlockIndex < firstDraggedBlockIndex &&\n\t\t\t\t\tthisBlockIndex >= blockDropTargetIndex\n\t\t\t\t) {\n\t\t\t\t\t// If the current block appears before the set of dragged blocks\n\t\t\t\t\t// (in their original position), but is after the drop target,\n\t\t\t\t\t// then the current block should be displaced down.\n\t\t\t\t\tdisplacement = 'down';\n\t\t\t\t} else {\n\t\t\t\t\tdisplacement = 'normal';\n\t\t\t\t}\n\t\t\t\tisNesting =\n\t\t\t\t\ttypeof blockDropTargetIndex === 'number' &&\n\t\t\t\t\tblockDropTargetIndex - 1 === thisBlockIndex &&\n\t\t\t\t\tblockDropPosition === 'inside';\n\t\t\t}\n\t\t} else if (\n\t\t\tblockDropTargetIndex === null &&\n\t\t\tfirstDraggedBlockIndex !== undefined\n\t\t) {\n\t\t\t// A `null` value for `blockDropTargetIndex` indicates that the\n\t\t\t// drop target is outside of the valid areas within the list view.\n\t\t\t// In this case, the drag is still active, but as there is no\n\t\t\t// valid drop target, we should remove the gap indicating where\n\t\t\t// the block would be inserted.\n\t\t\tif (\n\t\t\t\tthisBlockIndex !== undefined &&\n\t\t\t\tthisBlockIndex >= firstDraggedBlockIndex\n\t\t\t) {\n\t\t\t\tdisplacement = 'up';\n\t\t\t} else {\n\t\t\t\tdisplacement = 'normal';\n\t\t\t}\n\t\t} else if (\n\t\t\tblockDropTargetIndex !== undefined &&\n\t\t\tblockDropTargetIndex !== null &&\n\t\t\tfirstDraggedBlockIndex === undefined\n\t\t) {\n\t\t\t// If the blockdrop target is defined, but there are no dragged blocks,\n\t\t\t// then the block should be displaced relative to the drop target.\n\t\t\tif ( thisBlockIndex !== undefined ) {\n\t\t\t\tif ( thisBlockIndex < blockDropTargetIndex ) {\n\t\t\t\t\tdisplacement = 'normal';\n\t\t\t\t} else {\n\t\t\t\t\tdisplacement = 'down';\n\t\t\t\t}\n\t\t\t}\n\t\t} else if ( blockDropTargetIndex === null ) {\n\t\t\tdisplacement = 'normal';\n\t\t}\n\t}\n\n\treturn {\n\t\tdisplacement,\n\t\tisNesting,\n\t\tisAfterDraggedBlocks,\n\t};\n}\n"],
5
+ "mappings": ";AAGA,SAAS,IAAI,eAAe;AAC5B,SAAS,aAAa;AAEf,IAAM,8BAA8B,CAAE,UAAU,cAAc,UACpE;AAAA;AAAA,EAEC,GAAI,iCAAkC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD;AAEM,IAAM,gCAAgC,CAAE,kBAAkB,aAChE;AAAA,EACC,kBAAkB,gBACf,GAAI;AAAA;AAAA,IAEJ,GAAI,cAAe;AAAA,IACnB,iBAAiB;AAAA,EACjB,CAAE,MACF;AAAA,EACH,WAAW,GAAI,uBAAwB,IAAI;AAC5C,EACE,OAAQ,OAAQ,EAChB,KAAM,GAAI;AAWN,IAAM,qBAAqB,CAAE,UAAU,2BAC7C,MAAM,QAAS,sBAAuB,KAAK,uBAAuB,SAC/D,uBAAuB,QAAS,QAAS,MAAM,KAC/C,2BAA2B;AAexB,SAAS,wBACf,SACA,OACA,cACA,YACC;AACD,QAAM,YAAY,CAAE,GAAG,cAAc,OAAQ;AAC7C,QAAM,UAAU,CAAE,GAAG,YAAY,KAAM;AACvC,QAAM,QAAQ,KAAK,IAAK,UAAU,QAAQ,QAAQ,MAAO,IAAI;AAC7D,QAAM,QAAQ,UAAW,KAAM;AAC/B,QAAM,MAAM,QAAS,KAAM;AAE3B,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;AAUO,SAAS,cAAe,eAAe,iBAAkB;AAC/D,MAAK,CAAE,iBAAkB;AACxB;AAAA,EACD;AAEA,QAAM,WAAW,0BAA2B,aAAc;AAE1D,SAAO,IAAI,QAAS,CAAE,YAAa;AAClC,QAAK,gBAAgB,cAAe,QAAS,GAAI;AAChD,aAAO,QAAS,gBAAgB,cAAe,QAA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AyB,QACzB,2BAA2B,QAC1B;AAGD,UAAK,mBAAmB,QAAY;AACnC,YAAK,iBAAiB,sBAAuB;AAC5C,yBAAe;AAAA,QAChB,OAAO;AACN,yBAAe;AAAA,QAChB;AAAA,MACD;AAAA,IACD,WAAY,yBAAyB,MAAO;AAC3C,qBAAe;AAAA,IAChB;AAAA,EACD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA;AAAA,EACD;AACD;",
6
6
  "names": []
7
7
  }
@@ -65,7 +65,8 @@ var input_rules_default = (props) => (element) => {
65
65
  onChange,
66
66
  __unstableAllowPrefixTransformations,
67
67
  formatTypes,
68
- registry
68
+ registry,
69
+ onReplace
69
70
  } = props.current;
70
71
  if (inputType !== "insertText" && type !== "compositionend") {
71
72
  return;
@@ -74,6 +75,17 @@ var input_rules_default = (props) => (element) => {
74
75
  return;
75
76
  }
76
77
  const value = getValue();
78
+ const transforms = getBlockTransforms("from").filter(
79
+ (transform) => transform.type === "input"
80
+ );
81
+ const transformation = findTransform(transforms, (item) => {
82
+ return item.regExp.test(value.text);
83
+ });
84
+ if (transformation) {
85
+ onReplace(transformation.transform());
86
+ registry.dispatch(blockEditorStore).__unstableMarkAutomaticChange();
87
+ return;
88
+ }
77
89
  const transformed = formatTypes.reduce(
78
90
  (accumulator, { __unstableInputRule }) => {
79
91
  if (__unstableInputRule) {