@wordpress/block-editor 10.0.2 → 10.1.1-next.4d3b314fd5.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 (153) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/block-draggable/index.js +1 -1
  3. package/build/components/block-draggable/index.js.map +1 -1
  4. package/build/components/block-list/index.js +19 -5
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-list/use-block-props/index.js +7 -1
  7. package/build/components/block-list/use-block-props/index.js.map +1 -1
  8. package/build/components/block-list/use-in-between-inserter.js +14 -5
  9. package/build/components/block-list/use-in-between-inserter.js.map +1 -1
  10. package/build/components/block-popover/inbetween.js +24 -9
  11. package/build/components/block-popover/inbetween.js.map +1 -1
  12. package/build/components/block-popover/index.js +29 -3
  13. package/build/components/block-popover/index.js.map +1 -1
  14. package/build/components/block-preview/auto.js +23 -11
  15. package/build/components/block-preview/auto.js.map +1 -1
  16. package/build/components/block-styles/index.js +1 -3
  17. package/build/components/block-styles/index.js.map +1 -1
  18. package/build/components/block-tools/index.js +18 -13
  19. package/build/components/block-tools/index.js.map +1 -1
  20. package/build/components/block-tools/insertion-point.js +5 -3
  21. package/build/components/block-tools/insertion-point.js.map +1 -1
  22. package/build/components/block-tools/use-block-toolbar-popover-props.js +6 -3
  23. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  24. package/build/components/block-variation-picker/index.native.js +2 -1
  25. package/build/components/block-variation-picker/index.native.js.map +1 -1
  26. package/build/components/button-block-appender/index.native.js +1 -0
  27. package/build/components/button-block-appender/index.native.js.map +1 -1
  28. package/build/components/index.js +9 -0
  29. package/build/components/index.js.map +1 -1
  30. package/build/components/list-view/index.js +2 -1
  31. package/build/components/list-view/index.js.map +1 -1
  32. package/build/components/rich-text/format-toolbar-container.js +8 -1
  33. package/build/components/rich-text/format-toolbar-container.js.map +1 -1
  34. package/build/components/rich-text/index.js +12 -0
  35. package/build/components/rich-text/index.js.map +1 -1
  36. package/build/components/url-input/index.js +1 -3
  37. package/build/components/url-input/index.js.map +1 -1
  38. package/build/components/url-popover/image-url-input-ui.js +1 -1
  39. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  40. package/build/components/use-block-drop-zone/index.js +19 -1
  41. package/build/components/use-block-drop-zone/index.js.map +1 -1
  42. package/build/components/use-on-block-drop/index.js +62 -20
  43. package/build/components/use-on-block-drop/index.js.map +1 -1
  44. package/build/components/use-setting/index.js +16 -12
  45. package/build/components/use-setting/index.js.map +1 -1
  46. package/build/components/writing-flow/use-arrow-nav.js +21 -8
  47. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  48. package/build/hooks/index.js +13 -1
  49. package/build/hooks/index.js.map +1 -1
  50. package/build/hooks/layout.js +76 -23
  51. package/build/hooks/layout.js.map +1 -1
  52. package/build/index.js +14 -0
  53. package/build/index.js.map +1 -1
  54. package/build/store/reducer.js +33 -19
  55. package/build/store/reducer.js.map +1 -1
  56. package/build/store/selectors.js +5 -5
  57. package/build/store/selectors.js.map +1 -1
  58. package/build-module/components/block-draggable/index.js +1 -1
  59. package/build-module/components/block-draggable/index.js.map +1 -1
  60. package/build-module/components/block-list/index.js +22 -8
  61. package/build-module/components/block-list/index.js.map +1 -1
  62. package/build-module/components/block-list/use-block-props/index.js +8 -2
  63. package/build-module/components/block-list/use-block-props/index.js.map +1 -1
  64. package/build-module/components/block-list/use-in-between-inserter.js +15 -6
  65. package/build-module/components/block-list/use-in-between-inserter.js.map +1 -1
  66. package/build-module/components/block-popover/inbetween.js +24 -9
  67. package/build-module/components/block-popover/inbetween.js.map +1 -1
  68. package/build-module/components/block-popover/index.js +29 -4
  69. package/build-module/components/block-popover/index.js.map +1 -1
  70. package/build-module/components/block-preview/auto.js +22 -10
  71. package/build-module/components/block-preview/auto.js.map +1 -1
  72. package/build-module/components/block-styles/index.js +1 -2
  73. package/build-module/components/block-styles/index.js.map +1 -1
  74. package/build-module/components/block-tools/index.js +18 -12
  75. package/build-module/components/block-tools/index.js.map +1 -1
  76. package/build-module/components/block-tools/insertion-point.js +5 -3
  77. package/build-module/components/block-tools/insertion-point.js.map +1 -1
  78. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +6 -3
  79. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  80. package/build-module/components/block-variation-picker/index.native.js +2 -1
  81. package/build-module/components/block-variation-picker/index.native.js.map +1 -1
  82. package/build-module/components/button-block-appender/index.native.js +1 -0
  83. package/build-module/components/button-block-appender/index.native.js.map +1 -1
  84. package/build-module/components/index.js +1 -0
  85. package/build-module/components/index.js.map +1 -1
  86. package/build-module/components/list-view/index.js +2 -1
  87. package/build-module/components/list-view/index.js.map +1 -1
  88. package/build-module/components/rich-text/format-toolbar-container.js +6 -1
  89. package/build-module/components/rich-text/format-toolbar-container.js.map +1 -1
  90. package/build-module/components/rich-text/index.js +12 -0
  91. package/build-module/components/rich-text/index.js.map +1 -1
  92. package/build-module/components/url-input/index.js +1 -2
  93. package/build-module/components/url-input/index.js.map +1 -1
  94. package/build-module/components/url-popover/image-url-input-ui.js +1 -1
  95. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  96. package/build-module/components/use-block-drop-zone/index.js +19 -1
  97. package/build-module/components/use-block-drop-zone/index.js.map +1 -1
  98. package/build-module/components/use-on-block-drop/index.js +62 -21
  99. package/build-module/components/use-on-block-drop/index.js.map +1 -1
  100. package/build-module/components/use-setting/index.js +16 -12
  101. package/build-module/components/use-setting/index.js.map +1 -1
  102. package/build-module/components/writing-flow/use-arrow-nav.js +22 -9
  103. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  104. package/build-module/hooks/index.js +1 -0
  105. package/build-module/hooks/index.js.map +1 -1
  106. package/build-module/hooks/layout.js +73 -23
  107. package/build-module/hooks/layout.js.map +1 -1
  108. package/build-module/index.js +1 -1
  109. package/build-module/index.js.map +1 -1
  110. package/build-module/store/reducer.js +29 -18
  111. package/build-module/store/reducer.js.map +1 -1
  112. package/build-module/store/selectors.js +5 -5
  113. package/build-module/store/selectors.js.map +1 -1
  114. package/build-style/style-rtl.css +24 -6
  115. package/build-style/style.css +24 -6
  116. package/package.json +29 -29
  117. package/src/components/block-controls/test/index.js +84 -8
  118. package/src/components/block-draggable/index.js +1 -1
  119. package/src/components/block-draggable/test/index.native.js +0 -9
  120. package/src/components/block-list/index.js +42 -6
  121. package/src/components/block-list/use-block-props/index.js +6 -1
  122. package/src/components/block-list/use-in-between-inserter.js +14 -8
  123. package/src/components/block-mover/style.scss +2 -7
  124. package/src/components/block-popover/inbetween.js +34 -10
  125. package/src/components/block-popover/index.js +47 -3
  126. package/src/components/block-preview/auto.js +77 -65
  127. package/src/components/block-preview/style.scss +13 -0
  128. package/src/components/block-styles/index.js +1 -2
  129. package/src/components/block-tools/index.js +16 -10
  130. package/src/components/block-tools/insertion-point.js +3 -3
  131. package/src/components/block-tools/use-block-toolbar-popover-props.js +6 -0
  132. package/src/components/block-variation-picker/index.native.js +1 -0
  133. package/src/components/button-block-appender/index.native.js +1 -0
  134. package/src/components/index.js +1 -0
  135. package/src/components/link-control/test/index.js +1 -2
  136. package/src/components/list-view/index.js +1 -0
  137. package/src/components/rich-text/format-toolbar-container.js +8 -2
  138. package/src/components/rich-text/index.js +14 -0
  139. package/src/components/url-input/index.js +6 -2
  140. package/src/components/url-popover/image-url-input-ui.js +1 -1
  141. package/src/components/use-block-drop-zone/index.js +26 -1
  142. package/src/components/use-on-block-drop/index.js +110 -35
  143. package/src/components/use-on-block-drop/test/index.js +33 -43
  144. package/src/components/use-setting/index.js +18 -16
  145. package/src/components/warning/style.scss +1 -0
  146. package/src/components/writing-flow/use-arrow-nav.js +23 -9
  147. package/src/hooks/index.js +1 -0
  148. package/src/hooks/layout.js +64 -21
  149. package/src/index.js +2 -0
  150. package/src/store/reducer.js +22 -14
  151. package/src/store/selectors.js +5 -4
  152. package/src/store/test/reducer.js +0 -17
  153. package/src/components/block-controls/test/__snapshots__/index.js.snap +0 -64
@@ -11,13 +11,14 @@ import classnames from 'classnames';
11
11
 
12
12
  import { useMergeRefs } from '@wordpress/compose';
13
13
  import { Popover } from '@wordpress/components';
14
- import { forwardRef, useMemo } from '@wordpress/element';
14
+ import { forwardRef, useMemo, useReducer, useLayoutEffect } from '@wordpress/element';
15
15
  /**
16
16
  * Internal dependencies
17
17
  */
18
18
 
19
19
  import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
20
20
  import usePopoverScroll from './use-popover-scroll';
21
+ const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
21
22
 
22
23
  function BlockPopover(_ref, ref) {
23
24
  let {
@@ -44,8 +45,33 @@ function BlockPopover(_ref, ref) {
44
45
  height: selectedElement.offsetHeight
45
46
  };
46
47
  }, [selectedElement, lastSelectedElement, __unstableRefreshSize]);
48
+ const [popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor] = useReducer( // Module is there to make sure that the counter doesn't overflow.
49
+ s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0); // When blocks are moved up/down, they are animated to their new position by
50
+ // updating the `transform` property manually (i.e. without using CSS
51
+ // transitions or animations). The animation, which can also scroll the block
52
+ // editor, can sometimes cause the position of the Popover to get out of sync.
53
+ // A MutationObserver is therefore used to make sure that changes to the
54
+ // selectedElement's attribute (i.e. `transform`) can be tracked and used to
55
+ // trigger the Popover to rerender.
56
+
57
+ useLayoutEffect(() => {
58
+ if (!selectedElement) {
59
+ return;
60
+ }
61
+
62
+ const observer = new window.MutationObserver(forceRecomputePopoverAnchor);
63
+ observer.observe(selectedElement, {
64
+ attributes: true
65
+ });
66
+ return () => {
67
+ observer.disconnect();
68
+ };
69
+ }, [selectedElement]);
47
70
  const popoverAnchor = useMemo(() => {
48
- if (!selectedElement || bottomClientId && !lastSelectedElement) {
71
+ if ( // popoverAnchorRecomputeCounter is by definition always equal or greater
72
+ // than 0. This check is only there to satisfy the correctness of the
73
+ // exhaustive-deps rule for the `useMemo` hook.
74
+ popoverAnchorRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
49
75
  return undefined;
50
76
  }
51
77
 
@@ -70,7 +96,7 @@ function BlockPopover(_ref, ref) {
70
96
 
71
97
  ownerDocument: selectedElement.ownerDocument
72
98
  };
73
- }, [bottomClientId, lastSelectedElement, selectedElement]);
99
+ }, [bottomClientId, lastSelectedElement, selectedElement, popoverAnchorRecomputeCounter]);
74
100
 
75
101
  if (!selectedElement || bottomClientId && !lastSelectedElement) {
76
102
  return null;
@@ -79,7 +105,6 @@ function BlockPopover(_ref, ref) {
79
105
  return createElement(Popover, _extends({
80
106
  ref: mergedRefs,
81
107
  animate: false,
82
- position: "top right left",
83
108
  focusOnMount: false,
84
109
  anchor: popoverAnchor // Render in the old slot if needed for backward compatibility,
85
110
  // otherwise render in place (not in the default popover slot).
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","useMergeRefs","Popover","forwardRef","useMemo","__unstableUseBlockElement","useBlockElement","usePopoverScroll","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","window","DOMRect","ownerDocument","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,UAAT,EAAqBC,OAArB,QAAoC,oBAApC;AAEA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;A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N;AAaC,IAAA,SAAS,EAAGjB,UAAU,CACrB,4BADqB,EAErBiB,KAAK,CAAC0B,SAFe;AAbvB,MAkBG7B,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAlB5B,EAmBG,CAAEE,qBAAF,IAA2BF,QAnB9B,CADD;AAuBA;;AAED,eAAeT,UAAU,CAAEK,YAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { forwardRef, useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\tconst style = useMemo( () => {\n\t\tif ( ! selectedElement || lastSelectedElement !== selectedElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [ selectedElement, lastSelectedElement, __unstableRefreshSize ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [ bottomClientId, lastSelectedElement, selectedElement ] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","useMergeRefs","Popover","forwardRef","useMemo","useReducer","useLayoutEffect","__unstableUseBlockElement","useBlockElement","usePopoverScroll","MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","popoverAnchorRecomputeCounter","forceRecomputePopoverAnchor","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SACCC,UADD,EAECC,OAFD,EAGCC,UAHD,EAICC,eAJD,QAKO,oBALP;AAOA;AACA;AACA;;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AAEA,MAAMC,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,QADD;AAECC,IAAAA,cAFD;AAGCC,IAAAA,QAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,qBAAqB,GAAG,KALzB;AAMCC,IAAAA,qBAND;AAOCC,IAAAA,oBAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,eAAe,GAA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F,IAAuBP,cAAc,IAAI,CAAEQ,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGC,UADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,YAAY,EAAG,KAHhB;AAIC,IAAA,MAAM,EAAGgB,aAJV,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAGrB,qBAAqB,IAAI,IAP/C;AAQC,IAAA,MAAM,EAAG,KARV;AASC,IAAA,IAAI,EAAG,KATR;AAUC,IAAA,KAAK;AAVN,KAWME,KAXN;AAYC,IAAA,SAAS,EAAGtB,UAAU,CACrB,4BADqB,EAErBsB,KAAK,CAACkC,SAFe;AAZvB,MAiBGrC,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAjB5B,EAkBG,CAAEE,qBAAF,IAA2BF,QAlB9B,CADD;AAsBA;;AAED,eAAed,UAAU,CAAEU,YAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\tconst style = useMemo( () => {\n\t\tif ( ! selectedElement || lastSelectedElement !== selectedElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [ selectedElement, lastSelectedElement, __unstableRefreshSize ] );\n\n\tconst [ popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor ] =\n\t\tuseReducer(\n\t\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t\t0\n\t\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverAnchor\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverAnchorRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverAnchorRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverAnchorRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
@@ -1,4 +1,5 @@
1
- import { createElement } from "@wordpress/element";
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { createElement, Fragment } from "@wordpress/element";
2
3
 
3
4
  /**
4
5
  * WordPress dependencies
@@ -20,15 +21,13 @@ import { store } from '../../store'; // This is used to avoid rendering the bloc
20
21
  let MemoizedBlockList;
21
22
  const MAX_HEIGHT = 2000;
22
23
 
23
- function AutoBlockPreview(_ref) {
24
+ function ScaledBlockPreview(_ref) {
24
25
  let {
25
26
  viewportWidth,
27
+ containerWidth,
26
28
  __experimentalPadding,
27
29
  __experimentalMinHeight
28
30
  } = _ref;
29
- const [containerResizeListener, {
30
- width: containerWidth
31
- }] = useResizeObserver();
32
31
  const [contentResizeListener, {
33
32
  height: contentHeight
34
33
  }] = useResizeObserver();
@@ -65,9 +64,7 @@ function AutoBlockPreview(_ref) {
65
64
 
66
65
  MemoizedBlockList = MemoizedBlockList || pure(BlockList);
67
66
  const scale = containerWidth / viewportWidth;
68
- return createElement("div", {
69
- className: "block-editor-block-preview__container"
70
- }, containerResizeListener, createElement(Disabled, {
67
+ return createElement(Disabled, {
71
68
  className: "block-editor-block-preview__content",
72
69
  style: {
73
70
  transform: `scale(${scale})`,
@@ -114,8 +111,23 @@ function AutoBlockPreview(_ref) {
114
111
  key: preset.slug
115
112
  })), createElement(MemoizedBlockList, {
116
113
  renderAppender: false
117
- }))));
114
+ })));
118
115
  }
119
116
 
120
- export default AutoBlockPreview;
117
+ export default function AutoBlockPreview(props) {
118
+ const [containerResizeListener, {
119
+ width: containerWidth
120
+ }] = useResizeObserver();
121
+ return createElement(Fragment, null, createElement("div", {
122
+ style: {
123
+ position: 'relative',
124
+ width: '100%',
125
+ height: 0
126
+ }
127
+ }, containerResizeListener), createElement("div", {
128
+ className: "block-editor-block-preview__container"
129
+ }, !!containerWidth && createElement(ScaledBlockPreview, _extends({}, props, {
130
+ containerWidth: containerWidth
131
+ }))));
132
+ }
121
133
  //# sourceMappingURL=auto.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["Disabled","useResizeObserver","pure","useRefEffect","useSelect","useMemo","BlockList","Iframe","EditorStyles","__unstablePresetDuotoneFilter","PresetDuotoneFilter","store","MemoizedBlockList","MAX_HEIGHT","AutoBlockPreview","viewportWidth","__experimentalPadding","__experimentalMinHeight","containerResizeListener","width","containerWidth","contentResizeListener","height","contentHeight","styles","assets","duotone","select","settings","getSettings","__unstableResolvedAssets","__experimentalFeatures","color","editorStyles","css","__unstableType","svgFilters","default","theme","scale","transform","maxHeight","undefined","minHeight","bodyElement","ownerDocument","documentElement","classList","add","style","position","padding","boxSizing","pointerEvents","map","preset","slug"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,EAAkCC,YAAlC,QAAsD,oBAAtD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,6BAA6B,IAAIC,mBAA1C,QAAqE,0BAArE;AACA,SAASC,KAAT,QAAsB,aAAtB,C,CAEA;;AACA,IAAIC,iBAAJ;AAEA,MAAMC,UAAU,GAAG,IAAnB;;AAEA,SAASC,gBAAT,OAII;AAAA,MAJuB;AAC1BC,IAAAA,aAD0B;AAE1BC,IAAAA,qBAF0B;AAG1BC,IAAAA;AAH0B,GAIvB;AACH,QAAM,CAAEC,uBAAF,EAA2B;AAAEC,IAAAA,KAAK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ACP+B,MAAAA,QAAQ,EAAE,UADH;AAEP/B,MAAAA,KAAK,EAAEJ,aAFA;AAGPO,MAAAA,MAAM,EAAEC,aAHD;AAIP8B,MAAAA,aAAa,EAAE,MAJR;AAKP;AACA;AACAZ,MAAAA,SAAS,EAAE5B,UAPJ;AAQP8B,MAAAA,SAAS,EACRJ,KAAK,KAAK,CAAV,IAAeA,KAAK,GAAG,CAAvB,IAA4BtB,uBAA5B,GACGA,uBAAuB,GAAGsB,KAD7B,GAEGtB;AAXG;AAtBT,KAoCGI,qBApCH;AAsCE;AACAe,EAAAA,UAAU,CAACkB,GAAX,CAAkBC,MAAF,IACf,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,GAAG,EAAGA,MAAM,CAACC;AAFd,IADD,CAvCF,EA8CC,cAAC,iBAAD;AAAmB,IAAA,cAAc,EAAG;AAApC,IA9CD,CAZD,CAFD,CADD;AAkEA;;AAED,eAAe1C,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Disabled } from '@wordpress/components';\nimport { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport Iframe from '../iframe';\nimport EditorStyles from '../editor-styles';\nimport { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '../../components/duotone';\nimport { store } from '../../store';\n\n// This is used to avoid rendering the block list if the sizes change.\nlet MemoizedBlockList;\n\nconst MAX_HEIGHT = 2000;\n\nfunction AutoBlockPreview( {\n\tviewportWidth,\n\t__experimentalPadding,\n\t__experimentalMinHeight,\n} ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst { styles, assets, duotone } = useSelect( ( select ) => {\n\t\tconst settings = select( store ).getSettings();\n\t\treturn {\n\t\t\tstyles: settings.styles,\n\t\t\tassets: settings.__unstableResolvedAssets,\n\t\t\tduotone: settings.__experimentalFeatures?.color?.duotone,\n\t\t};\n\t}, [] );\n\n\t// Avoid scrollbars for pattern previews.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{height:auto;overflow:hidden;}',\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\tconst svgFilters = useMemo( () => {\n\t\treturn [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];\n\t}, [ duotone ] );\n\n\t// Initialize on render instead of module top level, to avoid circular dependency issues.\n\tMemoizedBlockList = MemoizedBlockList || pure( BlockList );\n\n\tconst scale = containerWidth / viewportWidth;\n\treturn (\n\t\t<div className=\"block-editor-block-preview__container\">\n\t\t\t{ containerResizeListener }\n\t\t\t<Disabled\n\t\t\t\tclassName=\"block-editor-block-preview__content\"\n\t\t\t\tstyle={ {\n\t\t\t\t\ttransform: `scale(${ scale })`,\n\t\t\t\t\theight: contentHeight * scale,\n\t\t\t\t\tmaxHeight:\n\t\t\t\t\t\tcontentHeight > MAX_HEIGHT\n\t\t\t\t\t\t\t? MAX_HEIGHT * scale\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\tminHeight: __experimentalMinHeight,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<Iframe\n\t\t\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\t\t\tassets={ assets }\n\t\t\t\t\tcontentRef={ useRefEffect( ( bodyElement ) => {\n\t\t\t\t\t\tconst {\n\t\t\t\t\t\t\townerDocument: { documentElement },\n\t\t\t\t\t\t} = bodyElement;\n\t\t\t\t\t\tdocumentElement.classList.add(\n\t\t\t\t\t\t\t'block-editor-block-preview__content-iframe'\n\t\t\t\t\t\t);\n\t\t\t\t\t\tdocumentElement.style.position = 'absolute';\n\t\t\t\t\t\tdocumentElement.style.width = '100%';\n\t\t\t\t\t\tbodyElement.style.padding =\n\t\t\t\t\t\t\t__experimentalPadding + 'px';\n\n\t\t\t\t\t\t// Necessary for contentResizeListener to work.\n\t\t\t\t\t\tbodyElement.style.boxSizing = 'border-box';\n\t\t\t\t\t\tbodyElement.style.position = 'absolute';\n\t\t\t\t\t\tbodyElement.style.width = '100%';\n\t\t\t\t\t}, [] ) }\n\t\t\t\t\taria-hidden\n\t\t\t\t\ttabIndex={ -1 }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\t\twidth: viewportWidth,\n\t\t\t\t\t\theight: contentHeight,\n\t\t\t\t\t\tpointerEvents: 'none',\n\t\t\t\t\t\t// This is a catch-all max-height for patterns.\n\t\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/38175.\n\t\t\t\t\t\tmaxHeight: MAX_HEIGHT,\n\t\t\t\t\t\tminHeight:\n\t\t\t\t\t\t\tscale !== 0 && scale < 1 && __experimentalMinHeight\n\t\t\t\t\t\t\t\t? __experimentalMinHeight / scale\n\t\t\t\t\t\t\t\t: __experimentalMinHeight,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t{\n\t\t\t\t\t\t/* Filters need to be rendered before children to avoid Safari rendering issues. */\n\t\t\t\t\t\tsvgFilters.map( ( preset ) => (\n\t\t\t\t\t\t\t<PresetDuotoneFilter\n\t\t\t\t\t\t\t\tpreset={ preset }\n\t\t\t\t\t\t\t\tkey={ preset.slug }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) )\n\t\t\t\t\t}\n\t\t\t\t\t<MemoizedBlockList renderAppender={ false } />\n\t\t\t\t</Iframe>\n\t\t\t</Disabled>\n\t\t</div>\n\t);\n}\n\nexport default AutoBlockPreview;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-preview/auto.js"],"names":["Disabled","useResizeObserver","pure","useRefEffect","useSelect","useMemo","BlockList","Iframe","EditorStyles","__unstablePresetDuotoneFilter","PresetDuotoneFilter","store","MemoizedBlockList","MAX_HEIGHT","ScaledBlockPreview","viewportWidth","containerWidth","__experimentalPadding","__experimentalMinHeight","contentResizeListener","height","contentHeight","styles","assets","duotone","select","settings","getSettings","__unstableResolvedAssets","__experimentalFeatures","color","editorStyles","css","__unstableType","svgFilters","default","theme","scale","transform","maxHeight","undefined","minHeight","bodyElement","ownerDocument","documentElement","classList","add","style","position","width","padding","boxSizing","pointerEvents","map","preset","slug","AutoBlockPreview","props","containerResizeListener"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,iBAAT,EAA4BC,IAA5B,EAAkCC,YAAlC,QAAsD,oBAAtD;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,MAAP,MAAmB,WAAnB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,SAASC,6BAA6B,IAAIC,mBAA1C,QAAqE,0BAArE;AACA,SAASC,KAAT,QAAsB,aAAtB,C,CAEA;;AACA,IAAIC,iBAAJ;AAEA,MAAMC,UAAU,GAAG,IAAnB;;AAEA,SAASC,kBAAT,OAKI;AAAA,MALyB;AAC5BC,IAAAA,aAD4B;AAE5BC,IAAAA,cAF4B;AAG5BC,IAAAA,qBAH4B;AAI5BC,IAAAA;AAJ4B,GAKzB;AACH,QAAM,CAAEC,qBAAF,EAAyB;AAAEC,IAAAA,MAAM,EAAEC;AAAV,GAAzB,IACLpB,iBAAiB,EADlB;AAEA,QAAM;AAAEqB,IAAAA,MAAF;AAAUC,IAAAA,MAAV;AAAkBC,IAAAA;AAAlB,MAA8BpB,SAAS,CAAIqB,MAAF,IAAc;AAAA;;AAC5D,UAAMC,QAAQ,GAAGD,MAAM,CAAEd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,EAAAA,UAAU,CAACmB,GAAX,CAAkBC,MAAF,IACf,cAAC,mBAAD;AACC,IAAA,MAAM,EAAGA,MADV;AAEC,IAAA,GAAG,EAAGA,MAAM,CAACC;AAFd,IADD,CAtCF,EA6CC,cAAC,iBAAD;AAAmB,IAAA,cAAc,EAAG;AAApC,IA7CD,CAVD,CADD;AA4DA;;AAED,eAAe,SAASC,gBAAT,CAA2BC,KAA3B,EAAmC;AACjD,QAAM,CAAEC,uBAAF,EAA2B;AAAET,IAAAA,KAAK,EAAEjC;AAAT,GAA3B,IACLf,iBAAiB,EADlB;AAGA,SACC,8BACC;AAAK,IAAA,KAAK,EAAG;AAAE+C,MAAAA,QAAQ,EAAE,UAAZ;AAAwBC,MAAAA,KAAK,EAAE,MAA/B;AAAuC7B,MAAAA,MAAM,EAAE;AAA/C;AAAb,KACGsC,uBADH,CADD,EAIC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAC,CAAE1C,cAAH,IACD,cAAC,kBAAD,eACMyC,KADN;AAEC,IAAA,cAAc,EAAGzC;AAFlB,KAFF,CAJD,CADD;AAeA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Disabled } from '@wordpress/components';\nimport { useResizeObserver, pure, useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockList from '../block-list';\nimport Iframe from '../iframe';\nimport EditorStyles from '../editor-styles';\nimport { __unstablePresetDuotoneFilter as PresetDuotoneFilter } from '../../components/duotone';\nimport { store } from '../../store';\n\n// This is used to avoid rendering the block list if the sizes change.\nlet MemoizedBlockList;\n\nconst MAX_HEIGHT = 2000;\n\nfunction ScaledBlockPreview( {\n\tviewportWidth,\n\tcontainerWidth,\n\t__experimentalPadding,\n\t__experimentalMinHeight,\n} ) {\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst { styles, assets, duotone } = useSelect( ( select ) => {\n\t\tconst settings = select( store ).getSettings();\n\t\treturn {\n\t\t\tstyles: settings.styles,\n\t\t\tassets: settings.__unstableResolvedAssets,\n\t\t\tduotone: settings.__experimentalFeatures?.color?.duotone,\n\t\t};\n\t}, [] );\n\n\t// Avoid scrollbars for pattern previews.\n\tconst editorStyles = useMemo( () => {\n\t\tif ( styles ) {\n\t\t\treturn [\n\t\t\t\t...styles,\n\t\t\t\t{\n\t\t\t\t\tcss: 'body{height:auto;overflow:hidden;}',\n\t\t\t\t\t__unstableType: 'presets',\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\treturn styles;\n\t}, [ styles ] );\n\n\tconst svgFilters = useMemo( () => {\n\t\treturn [ ...( duotone?.default ?? [] ), ...( duotone?.theme ?? [] ) ];\n\t}, [ duotone ] );\n\n\t// Initialize on render instead of module top level, to avoid circular dependency issues.\n\tMemoizedBlockList = MemoizedBlockList || pure( BlockList );\n\n\tconst scale = containerWidth / viewportWidth;\n\treturn (\n\t\t<Disabled\n\t\t\tclassName=\"block-editor-block-preview__content\"\n\t\t\tstyle={ {\n\t\t\t\ttransform: `scale(${ scale })`,\n\t\t\t\theight: contentHeight * scale,\n\t\t\t\tmaxHeight:\n\t\t\t\t\tcontentHeight > MAX_HEIGHT ? MAX_HEIGHT * scale : undefined,\n\t\t\t\tminHeight: __experimentalMinHeight,\n\t\t\t} }\n\t\t>\n\t\t\t<Iframe\n\t\t\t\thead={ <EditorStyles styles={ editorStyles } /> }\n\t\t\t\tassets={ assets }\n\t\t\t\tcontentRef={ useRefEffect( ( bodyElement ) => {\n\t\t\t\t\tconst {\n\t\t\t\t\t\townerDocument: { documentElement },\n\t\t\t\t\t} = bodyElement;\n\t\t\t\t\tdocumentElement.classList.add(\n\t\t\t\t\t\t'block-editor-block-preview__content-iframe'\n\t\t\t\t\t);\n\t\t\t\t\tdocumentElement.style.position = 'absolute';\n\t\t\t\t\tdocumentElement.style.width = '100%';\n\t\t\t\t\tbodyElement.style.padding = __experimentalPadding + 'px';\n\n\t\t\t\t\t// Necessary for contentResizeListener to work.\n\t\t\t\t\tbodyElement.style.boxSizing = 'border-box';\n\t\t\t\t\tbodyElement.style.position = 'absolute';\n\t\t\t\t\tbodyElement.style.width = '100%';\n\t\t\t\t}, [] ) }\n\t\t\t\taria-hidden\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tstyle={ {\n\t\t\t\t\tposition: 'absolute',\n\t\t\t\t\twidth: viewportWidth,\n\t\t\t\t\theight: contentHeight,\n\t\t\t\t\tpointerEvents: 'none',\n\t\t\t\t\t// This is a catch-all max-height for patterns.\n\t\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/38175.\n\t\t\t\t\tmaxHeight: MAX_HEIGHT,\n\t\t\t\t\tminHeight:\n\t\t\t\t\t\tscale !== 0 && scale < 1 && __experimentalMinHeight\n\t\t\t\t\t\t\t? __experimentalMinHeight / scale\n\t\t\t\t\t\t\t: __experimentalMinHeight,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ contentResizeListener }\n\t\t\t\t{\n\t\t\t\t\t/* Filters need to be rendered before children to avoid Safari rendering issues. */\n\t\t\t\t\tsvgFilters.map( ( preset ) => (\n\t\t\t\t\t\t<PresetDuotoneFilter\n\t\t\t\t\t\t\tpreset={ preset }\n\t\t\t\t\t\t\tkey={ preset.slug }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) )\n\t\t\t\t}\n\t\t\t\t<MemoizedBlockList renderAppender={ false } />\n\t\t\t</Iframe>\n\t\t</Disabled>\n\t);\n}\n\nexport default function AutoBlockPreview( props ) {\n\tconst [ containerResizeListener, { width: containerWidth } ] =\n\t\tuseResizeObserver();\n\n\treturn (\n\t\t<>\n\t\t\t<div style={ { position: 'relative', width: '100%', height: 0 } }>\n\t\t\t\t{ containerResizeListener }\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-block-preview__container\">\n\t\t\t\t{ !! containerWidth && (\n\t\t\t\t\t<ScaledBlockPreview\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t\tcontainerWidth={ containerWidth }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
@@ -3,14 +3,13 @@ import { createElement } from "@wordpress/element";
3
3
  /**
4
4
  * External dependencies
5
5
  */
6
- import { debounce } from 'lodash';
7
6
  import classnames from 'classnames';
8
7
  /**
9
8
  * WordPress dependencies
10
9
  */
11
10
 
12
11
  import { useState, useLayoutEffect } from '@wordpress/element';
13
- import { useViewportMatch } from '@wordpress/compose';
12
+ import { debounce, useViewportMatch } from '@wordpress/compose';
14
13
  import { Button, __experimentalTruncate as Truncate, Slot, Fill } from '@wordpress/components';
15
14
  /**
16
15
  * Internal dependencies
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["debounce","classnames","useState","useLayoutEffect","useViewportMatch","Button","__experimentalTruncate","Truncate","Slot","Fill","BlockStylesPreviewPanel","useStylesForBlocks","BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","top"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,QAAzB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,oBAA1C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SACCC,MADD,EAECC,sBAAsB,IAAIC,QAF3B,EAGCC,IAHD,EAICC,IAJD,QAKO,uBALP;AAOA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,iBAApC;AACA,OAAOC,kBAAP,MAA+B,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C,WATT;AAUC,MAAA,KAAK,EAAGE,UAVT;AAWC,MAAA,YAAY,EAAG,MAAMJ,gBAAgB,CAAEF,KAAF,CAXtC;AAYC,MAAA,OAAO,EAAG,MAAME,gBAAgB,CAAEF,KAAF,CAZjC;AAaC,MAAA,YAAY,EAAG,MAAME,gBAAgB,CAAE,IAAF,CAbtC;AAcC,MAAA,MAAM,EAAG,MAAMA,gBAAgB,CAAE,IAAF,CAdhC;AAeC,MAAA,OAAO,EAAG,MAAMH,oBAAoB,CAAEC,KAAF,CAfrC;AAgBC,sBAAehB,WAAW,CAACoB,IAAZ,KAAqBJ,KAAK,CAACI;AAhB3C,OAkBC,cAAC,QAAD;AACC,MAAA,aAAa,EAAG,CADjB;AAEC,MAAA,SAAS,EAAC;AAFX,OAIGE,UAJH,CAlBD,CADD;AA2BA,GA9BC,CADH,CADD,EAkCGlB,YAAY,IAAI,CAAEI,gBAAlB,IACD,cAAC,2BAAD;AACC,IAAA,KAAK,EAAGpB,KADT;AAEC,IAAA,SAAS,EAAC,0CAFX;AAGC,IAAA,KAAK,EAAG;AAAEoC,MAAAA,GAAG,EAAElB;AAAP,KAHT;AAIC,IAAA,YAAY,EAAG,MAAMY,gBAAgB,CAAE,IAAF;AAJtC,KAMC,cAAC,uBAAD;AACC,IAAA,WAAW,EAAGlB,WADf;AAEC,IAAA,SAAS,EAAGG,gBAFb;AAGC,IAAA,mBAAmB,EAAGF,mBAHvB;AAIC,IAAA,KAAK,EAAGG;AAJT,IAND,CAnCF,CADD;AAoDA;;AAEDV,WAAW,CAACX,IAAZ,GAAmBI,2BAAnB;AACA,eAAeO,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalTruncate as Truncate,\n\tSlot,\n\tFill,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nfunction BlockStylesPreviewPanelSlot( { scope } ) {\n\treturn <Slot name={ `BlockStylesPreviewPanel/${ scope }` } />;\n}\n\nfunction BlockStylesPreviewPanelFill( { children, scope, ...props } ) {\n\treturn (\n\t\t<Fill name={ `BlockStylesPreviewPanel/${ scope }` }>\n\t\t\t<div { ...props }>{ children }</div>\n\t\t</Fill>\n\t);\n}\n\n// Top position (in px) of the Block Styles container\n// relative to the editor pane.\n// The value is the equivalent of the container's right position.\nconst DEFAULT_POSITION_TOP = 16;\n\nconst noop = () => {};\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\tscope,\n} ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ containerScrollTop, setContainerScrollTop ] = useState( 0 );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tuseLayoutEffect( () => {\n\t\tconst scrollContainer = document.querySelector(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\t\tsetContainerScrollTop( scrollTop + DEFAULT_POSITION_TOP );\n\t}, [ hoveredStyle ] );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<BlockStylesPreviewPanelFill\n\t\t\t\t\tscope={ scope }\n\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\tstyle={ { top: containerScrollTop } }\n\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t>\n\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t/>\n\t\t\t\t</BlockStylesPreviewPanelFill>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nBlockStyles.Slot = BlockStylesPreviewPanelSlot;\nexport default BlockStyles;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-styles/index.js"],"names":["classnames","useState","useLayoutEffect","debounce","useViewportMatch","Button","__experimentalTruncate","Truncate","Slot","Fill","BlockStylesPreviewPanel","useStylesForBlocks","BlockStylesPreviewPanelSlot","scope","BlockStylesPreviewPanelFill","children","props","DEFAULT_POSITION_TOP","noop","BlockStyles","clientId","onSwitch","onHoverClassName","onSelect","stylesToRender","activeStyle","genericPreviewBlock","className","previewClassName","hoveredStyle","setHoveredStyle","containerScrollTop","setContainerScrollTop","isMobileViewport","scrollContainer","document","querySelector","scrollTop","length","debouncedSetHoveredStyle","onSelectStylePreview","style","cancel","styleItemHandler","item","name","map","buttonText","label","top"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,QAAT,EAAmBC,eAAnB,QAA0C,oBAA1C;AACA,SAASC,QAAT,EAAmBC,gBAAnB,QAA2C,oBAA3C;AACA,SACCC,MADD,EAECC,sBAAsB,IAAIC,QAF3B,EAGCC,IAHD,EAICC,IAJD,QAKO,uBALP;AAOA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,iBAApC;AACA,OAAOC,kBAAP,MAA+B,wBAA/B;;AAEA,SAASC,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AK,EAAGE,UAVT;AAWC,MAAA,YAAY,EAAG,MAAMJ,gBAAgB,CAAEF,KAAF,CAXtC;AAYC,MAAA,OAAO,EAAG,MAAME,gBAAgB,CAAEF,KAAF,CAZjC;AAaC,MAAA,YAAY,EAAG,MAAME,gBAAgB,CAAE,IAAF,CAbtC;AAcC,MAAA,MAAM,EAAG,MAAMA,gBAAgB,CAAE,IAAF,CAdhC;AAeC,MAAA,OAAO,EAAG,MAAMH,oBAAoB,CAAEC,KAAF,CAfrC;AAgBC,sBAAehB,WAAW,CAACoB,IAAZ,KAAqBJ,KAAK,CAACI;AAhB3C,OAkBC,cAAC,QAAD;AACC,MAAA,aAAa,EAAG,CADjB;AAEC,MAAA,SAAS,EAAC;AAFX,OAIGE,UAJH,CAlBD,CADD;AA2BA,GA9BC,CADH,CADD,EAkCGlB,YAAY,IAAI,CAAEI,gBAAlB,IACD,cAAC,2BAAD;AACC,IAAA,KAAK,EAAGpB,KADT;AAEC,IAAA,SAAS,EAAC,0CAFX;AAGC,IAAA,KAAK,EAAG;AAAEoC,MAAAA,GAAG,EAAElB;AAAP,KAHT;AAIC,IAAA,YAAY,EAAG,MAAMY,gBAAgB,CAAE,IAAF;AAJtC,KAMC,cAAC,uBAAD;AACC,IAAA,WAAW,EAAGlB,WADf;AAEC,IAAA,SAAS,EAAGG,gBAFb;AAGC,IAAA,mBAAmB,EAAGF,mBAHvB;AAIC,IAAA,KAAK,EAAGG;AAJT,IAND,CAnCF,CADD;AAoDA;;AAEDV,WAAW,CAACX,IAAZ,GAAmBI,2BAAnB;AACA,eAAeO,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useState, useLayoutEffect } from '@wordpress/element';\nimport { debounce, useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__experimentalTruncate as Truncate,\n\tSlot,\n\tFill,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport BlockStylesPreviewPanel from './preview-panel';\nimport useStylesForBlocks from './use-styles-for-block';\n\nfunction BlockStylesPreviewPanelSlot( { scope } ) {\n\treturn <Slot name={ `BlockStylesPreviewPanel/${ scope }` } />;\n}\n\nfunction BlockStylesPreviewPanelFill( { children, scope, ...props } ) {\n\treturn (\n\t\t<Fill name={ `BlockStylesPreviewPanel/${ scope }` }>\n\t\t\t<div { ...props }>{ children }</div>\n\t\t</Fill>\n\t);\n}\n\n// Top position (in px) of the Block Styles container\n// relative to the editor pane.\n// The value is the equivalent of the container's right position.\nconst DEFAULT_POSITION_TOP = 16;\n\nconst noop = () => {};\n\n// Block Styles component for the Settings Sidebar.\nfunction BlockStyles( {\n\tclientId,\n\tonSwitch = noop,\n\tonHoverClassName = noop,\n\tscope,\n} ) {\n\tconst {\n\t\tonSelect,\n\t\tstylesToRender,\n\t\tactiveStyle,\n\t\tgenericPreviewBlock,\n\t\tclassName: previewClassName,\n\t} = useStylesForBlocks( {\n\t\tclientId,\n\t\tonSwitch,\n\t} );\n\tconst [ hoveredStyle, setHoveredStyle ] = useState( null );\n\tconst [ containerScrollTop, setContainerScrollTop ] = useState( 0 );\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\n\tuseLayoutEffect( () => {\n\t\tconst scrollContainer = document.querySelector(\n\t\t\t'.interface-interface-skeleton__content'\n\t\t);\n\t\tconst scrollTop = scrollContainer?.scrollTop || 0;\n\t\tsetContainerScrollTop( scrollTop + DEFAULT_POSITION_TOP );\n\t}, [ hoveredStyle ] );\n\n\tif ( ! stylesToRender || stylesToRender.length === 0 ) {\n\t\treturn null;\n\t}\n\n\tconst debouncedSetHoveredStyle = debounce( setHoveredStyle, 250 );\n\n\tconst onSelectStylePreview = ( style ) => {\n\t\tonSelect( style );\n\t\tonHoverClassName( null );\n\t\tsetHoveredStyle( null );\n\t\tdebouncedSetHoveredStyle.cancel();\n\t};\n\n\tconst styleItemHandler = ( item ) => {\n\t\tif ( hoveredStyle === item ) {\n\t\t\tdebouncedSetHoveredStyle.cancel();\n\t\t\treturn;\n\t\t}\n\t\tdebouncedSetHoveredStyle( item );\n\t\tonHoverClassName( item?.name ?? null );\n\t};\n\n\treturn (\n\t\t<div className=\"block-editor-block-styles\">\n\t\t\t<div className=\"block-editor-block-styles__variants\">\n\t\t\t\t{ stylesToRender.map( ( style ) => {\n\t\t\t\t\tconst buttonText = style.label || style.name;\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-block-styles__item',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-active':\n\t\t\t\t\t\t\t\t\t\tactiveStyle.name === style.name,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tkey={ style.name }\n\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\tlabel={ buttonText }\n\t\t\t\t\t\t\tonMouseEnter={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonFocus={ () => styleItemHandler( style ) }\n\t\t\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonBlur={ () => styleItemHandler( null ) }\n\t\t\t\t\t\t\tonClick={ () => onSelectStylePreview( style ) }\n\t\t\t\t\t\t\taria-current={ activeStyle.name === style.name }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Truncate\n\t\t\t\t\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-block-styles__item-text\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ buttonText }\n\t\t\t\t\t\t\t</Truncate>\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t\t{ hoveredStyle && ! isMobileViewport && (\n\t\t\t\t<BlockStylesPreviewPanelFill\n\t\t\t\t\tscope={ scope }\n\t\t\t\t\tclassName=\"block-editor-block-styles__preview-panel\"\n\t\t\t\t\tstyle={ { top: containerScrollTop } }\n\t\t\t\t\tonMouseLeave={ () => styleItemHandler( null ) }\n\t\t\t\t>\n\t\t\t\t\t<BlockStylesPreviewPanel\n\t\t\t\t\t\tactiveStyle={ activeStyle }\n\t\t\t\t\t\tclassName={ previewClassName }\n\t\t\t\t\t\tgenericPreviewBlock={ genericPreviewBlock }\n\t\t\t\t\t\tstyle={ hoveredStyle }\n\t\t\t\t\t/>\n\t\t\t\t</BlockStylesPreviewPanelFill>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n\nBlockStyles.Slot = BlockStylesPreviewPanelSlot;\nexport default BlockStyles;\n"]}
@@ -19,6 +19,19 @@ import { store as blockEditorStore } from '../../store';
19
19
  import BlockContextualToolbar from './block-contextual-toolbar';
20
20
  import usePopoverScroll from '../block-popover/use-popover-scroll';
21
21
  import ZoomOutModeInserters from './zoom-out-mode-inserters';
22
+
23
+ function selector(select) {
24
+ const {
25
+ __unstableGetEditorMode,
26
+ getSettings,
27
+ isTyping
28
+ } = select(blockEditorStore);
29
+ return {
30
+ isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
31
+ hasFixedToolbar: getSettings().hasFixedToolbar,
32
+ isTyping: isTyping()
33
+ };
34
+ }
22
35
  /**
23
36
  * Renders block tools (the block toolbar, select/navigation mode toolbar, the
24
37
  * insertion point and a slot for the inline rich text toolbar). Must be wrapped
@@ -29,6 +42,7 @@ import ZoomOutModeInserters from './zoom-out-mode-inserters';
29
42
  * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.
30
43
  */
31
44
 
45
+
32
46
  export default function BlockTools(_ref) {
33
47
  let {
34
48
  children,
@@ -38,17 +52,9 @@ export default function BlockTools(_ref) {
38
52
  const isLargeViewport = useViewportMatch('medium');
39
53
  const {
40
54
  hasFixedToolbar,
41
- isZoomOutMode
42
- } = useSelect(select => {
43
- const {
44
- __unstableGetEditorMode,
45
- getSettings
46
- } = select(blockEditorStore);
47
- return {
48
- isZoomOutMode: __unstableGetEditorMode() === 'zoom-out',
49
- hasFixedToolbar: getSettings().hasFixedToolbar
50
- };
51
- }, []);
55
+ isZoomOutMode,
56
+ isTyping
57
+ } = useSelect(selector, []);
52
58
  const isMatch = useShortcutEventMatch();
53
59
  const {
54
60
  getSelectedBlockClientIds,
@@ -130,7 +136,7 @@ export default function BlockTools(_ref) {
130
136
  onKeyDown: onKeyDown
131
137
  }), createElement(InsertionPointOpenRef.Provider, {
132
138
  value: useRef(false)
133
- }, !isZoomOutMode && createElement(InsertionPoint, {
139
+ }, !isTyping && createElement(InsertionPoint, {
134
140
  __unstableContentRef: __unstableContentRef
135
141
  }), !isZoomOutMode && (hasFixedToolbar || !isLargeViewport) && createElement(BlockContextualToolbar, {
136
142
  isFixed: true
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"names":["useSelect","useDispatch","useViewportMatch","Popover","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRef","InsertionPointOpenRef","default","InsertionPoint","SelectedBlockPopover","store","blockEditorStore","BlockContextualToolbar","usePopoverScroll","ZoomOutModeInserters","BlockTools","children","__unstableContentRef","props","isLargeViewport","hasFixedToolbar","isZoomOutMode","select","__unstableGetEditorMode","getSettings","isMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","moveBlocksUp","moveBlocksDown","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","blockToolbarAfterRef"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,+BAA+B,IAAIC,qBAA5C,QAAyE,+BAAzE;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA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B,MAZD,EAgBC,cAAC,OAAD,CAAS,IAAT;AAAc,MAAA,IAAI,EAAC,eAAnB;AAAmC,MAAA,GAAG,EAAGgC;AAAzC,MAhBD,EAiBGjC,QAjBH,EAmBC,cAAC,OAAD,CAAS,IAAT;AACC,MAAA,IAAI,EAAC,8BADN;AAEC,MAAA,GAAG,EAAGkC;AAFP,MAnBD,EAuBG7B,aAAa,IACd,cAAC,oBAAD;AACC,MAAA,oBAAoB,EAAGJ;AADxB,MAxBF,CADD;AAFD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport SelectedBlockPopover from './selected-block-popover';\nimport { store as blockEditorStore } from '../../store';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { hasFixedToolbar, isZoomOutMode } = useSelect( ( select ) => {\n\t\tconst { __unstableGetEditorMode, getSettings } =\n\t\t\tselect( blockEditorStore );\n\n\t\treturn {\n\t\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t};\n\t}, [] );\n\tconst isMatch = useShortcutEventMatch();\n\tconst { getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tclearSelectedBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) return;\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tevent.target.ownerDocument.defaultView\n\t\t\t\t\t.getSelection()\n\t\t\t\t\t.removeAllRanges();\n\t\t\t\t__unstableContentRef?.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isZoomOutMode && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isZoomOutMode &&\n\t\t\t\t\t( hasFixedToolbar || ! isLargeViewport ) && (\n\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t) }\n\t\t\t\t{ /* Even if the toolbar is fixed, the block popover is still\n\t\t\t\t\tneeded for navigation and zoom-out mode. */ }\n\t\t\t\t<SelectedBlockPopover\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t\t{ /* Used for the inline rich text toolbar. */ }\n\t\t\t\t<Popover.Slot name=\"block-toolbar\" ref={ blockToolbarRef } />\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/index.js"],"names":["useSelect","useDispatch","useViewportMatch","Popover","__unstableUseShortcutEventMatch","useShortcutEventMatch","useRef","InsertionPointOpenRef","default","InsertionPoint","SelectedBlockPopover","store","blockEditorStore","BlockContextualToolbar","usePopoverScroll","ZoomOutModeInserters","selector","select","__unstableGetEditorMode","getSettings","isTyping","isZoomOutMode","hasFixedToolbar","BlockTools","children","__unstableContentRef","props","isLargeViewport","isMatch","getSelectedBlockClientIds","getBlockRootClientId","duplicateBlocks","removeBlocks","insertAfterBlock","insertBeforeBlock","clearSelectedBlock","moveBlocksUp","moveBlocksDown","onKeyDown","event","defaultPrevented","clientIds","length","preventDefault","rootClientId","target","ownerDocument","defaultView","getSelection","removeAllRanges","current","focus","blockToolbarRef","blockToolbarAfterRef"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AACA,SAASC,OAAT,QAAwB,uBAAxB;AACA,SAASC,+BAA+B,IAAIC,qBAA5C,QAAyE,+BAAzE;AACA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,SACCC,qBADD,EAECC,OAAO,IAAIC,cAFZ,QAGO,mBAHP;AAIA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,sBAAP,MAAmC,4BA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AAc,MAAA,IAAI,EAAC,eAAnB;AAAmC,MAAA,GAAG,EAAG2B;AAAzC,MAhBD,EAiBG5B,QAjBH,EAmBC,cAAC,OAAD,CAAS,IAAT;AACC,MAAA,IAAI,EAAC,8BADN;AAEC,MAAA,GAAG,EAAG6B;AAFP,MAnBD,EAuBGhC,aAAa,IACd,cAAC,oBAAD;AACC,MAAA,oBAAoB,EAAGI;AADxB,MAxBF,CADD;AAFD;AAkCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport { __unstableUseShortcutEventMatch as useShortcutEventMatch } from '@wordpress/keyboard-shortcuts';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tInsertionPointOpenRef,\n\tdefault as InsertionPoint,\n} from './insertion-point';\nimport SelectedBlockPopover from './selected-block-popover';\nimport { store as blockEditorStore } from '../../store';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport usePopoverScroll from '../block-popover/use-popover-scroll';\nimport ZoomOutModeInserters from './zoom-out-mode-inserters';\n\nfunction selector( select ) {\n\tconst { __unstableGetEditorMode, getSettings, isTyping } =\n\t\tselect( blockEditorStore );\n\n\treturn {\n\t\tisZoomOutMode: __unstableGetEditorMode() === 'zoom-out',\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tisTyping: isTyping(),\n\t};\n}\n\n/**\n * Renders block tools (the block toolbar, select/navigation mode toolbar, the\n * insertion point and a slot for the inline rich text toolbar). Must be wrapped\n * around the block content and editor styles wrapper or iframe.\n *\n * @param {Object} $0 Props.\n * @param {Object} $0.children The block content and style container.\n * @param {Object} $0.__unstableContentRef Ref holding the content scroll container.\n */\nexport default function BlockTools( {\n\tchildren,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst { hasFixedToolbar, isZoomOutMode, isTyping } = useSelect(\n\t\tselector,\n\t\t[]\n\t);\n\tconst isMatch = useShortcutEventMatch();\n\tconst { getSelectedBlockClientIds, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst {\n\t\tduplicateBlocks,\n\t\tremoveBlocks,\n\t\tinsertAfterBlock,\n\t\tinsertBeforeBlock,\n\t\tclearSelectedBlock,\n\t\tmoveBlocksUp,\n\t\tmoveBlocksDown,\n\t} = useDispatch( blockEditorStore );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( event.defaultPrevented ) return;\n\n\t\tif ( isMatch( 'core/block-editor/move-up', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksUp( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/move-down', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\t\tmoveBlocksDown( clientIds, rootClientId );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/duplicate', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tduplicateBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/remove', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tremoveBlocks( clientIds );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-after', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertAfterBlock( clientIds[ clientIds.length - 1 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/insert-before', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tinsertBeforeBlock( clientIds[ 0 ] );\n\t\t\t}\n\t\t} else if ( isMatch( 'core/block-editor/unselect', event ) ) {\n\t\t\tconst clientIds = getSelectedBlockClientIds();\n\t\t\tif ( clientIds.length ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tclearSelectedBlock();\n\t\t\t\tevent.target.ownerDocument.defaultView\n\t\t\t\t\t.getSelection()\n\t\t\t\t\t.removeAllRanges();\n\t\t\t\t__unstableContentRef?.current.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst blockToolbarRef = usePopoverScroll( __unstableContentRef );\n\tconst blockToolbarAfterRef = usePopoverScroll( __unstableContentRef );\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div { ...props } onKeyDown={ onKeyDown }>\n\t\t\t<InsertionPointOpenRef.Provider value={ useRef( false ) }>\n\t\t\t\t{ ! isTyping && (\n\t\t\t\t\t<InsertionPoint\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! isZoomOutMode &&\n\t\t\t\t\t( hasFixedToolbar || ! isLargeViewport ) && (\n\t\t\t\t\t\t<BlockContextualToolbar isFixed />\n\t\t\t\t\t) }\n\t\t\t\t{ /* Even if the toolbar is fixed, the block popover is still\n\t\t\t\t\tneeded for navigation and zoom-out mode. */ }\n\t\t\t\t<SelectedBlockPopover\n\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t/>\n\t\t\t\t{ /* Used for the inline rich text toolbar. */ }\n\t\t\t\t<Popover.Slot name=\"block-toolbar\" ref={ blockToolbarRef } />\n\t\t\t\t{ children }\n\t\t\t\t{ /* Used for inline rich text popovers. */ }\n\t\t\t\t<Popover.Slot\n\t\t\t\t\tname=\"__unstable-block-tools-after\"\n\t\t\t\t\tref={ blockToolbarAfterRef }\n\t\t\t\t/>\n\t\t\t\t{ isZoomOutMode && (\n\t\t\t\t\t<ZoomOutModeInserters\n\t\t\t\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</InsertionPointOpenRef.Provider>\n\t\t</div>\n\t);\n}\n"]}
@@ -152,14 +152,16 @@ function InsertionPointPopover(_ref) {
152
152
  opacity: 1,
153
153
  borderRadius: '2px',
154
154
  transition: {
155
- delay: isInserterShown ? 0.4 : 0
155
+ delay: isInserterShown ? 0.1 : 0,
156
+ type: 'tween'
156
157
  }
157
158
  },
158
159
  hover: { ...(!isVertical ? horizontalLine.hover : verticalLine.hover),
159
160
  opacity: 1,
160
161
  borderRadius: '2px',
161
162
  transition: {
162
- delay: 0.4
163
+ delay: 0.1,
164
+ type: 'tween'
163
165
  }
164
166
  }
165
167
  };
@@ -170,7 +172,7 @@ function InsertionPointPopover(_ref) {
170
172
  rest: {
171
173
  scale: 1,
172
174
  transition: {
173
- delay: 0.2
175
+ type: 'tween'
174
176
  }
175
177
  }
176
178
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["classnames","useSelect","useDispatch","useRef","createContext","useContext","__unstableMotion","motion","useReducedMotion","Inserter","store","blockEditorStore","BlockPopoverInbetween","InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","isVertical","disableMotion","onClick","event","target","current","onFocus","maybeHideInserterPoint","horizontalLine","start","width","top","bottom","x","rest","hover","verticalLine","height","left","right","y","lineVariants","opacity","borderRadius","transition","delay","inserterVariants","scale","className","isOpen","InsertionPoint","props","isVisible","isBlockInsertionPointVisible"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,aAAjB,EAAgCC,UAAhC,QAAkD,oBAAlD;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,OAAO,MAAMC,qBAAqB,GAAGT,aAAa,EAA3C;;AAEP,SAASU,qBAAT,OAGI;AAAA,MAH4B;AAC/BC,IAAAA,qBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAsChB,WAAW,CAAES,gBAAF,CAAvD;AACA,QAAMQ,OAAO,GAAGd,UAAU,CAAEQ,qBAAF,CAA1B;AACA,QAAMO,GAAG,GAAGjB,MAAM,EAAlB;AACA,QAAM;AACLkB,IAAAA,WADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,YAJK;AAKLC,IAAAA;AALK,MAMFxB,SAAS,CAAIyB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MAAAA,aADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,sBAHK;AAILC,MAAAA,mBAJK;AAKLC,MAAAA,wBALK;AAMLC,MAAAA;AANK,QAOFN,MAAM,CAAEf,gBAAF,CAPV;AAQA,UAAMsB,cAAc,GAAGJ,sBAAsB,EAA7C;AACA,UAAMK,KAAK,GAAGP,aAAa,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GvE,SAAS,CAAIyB,MAAF,IAAc;AAC1C,WAAOA,MAAM,CAAEf,gBAAF,CAAN,CAA2B8D,4BAA3B,EAAP;AACA,GAF0B,EAExB,EAFwB,CAA3B;AAIA,SAAOD,SAAS,IAAI,cAAC,qBAAD,EAA4BD,KAA5B,CAApB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: isInserterShown ? 0.4 : 0 },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.4 },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { delay: 0.2 },\n\t\t},\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t\tdata-testid=\"block-list-insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( props ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn isVisible && <InsertionPointPopover { ...props } />;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/insertion-point.js"],"names":["classnames","useSelect","useDispatch","useRef","createContext","useContext","__unstableMotion","motion","useReducedMotion","Inserter","store","blockEditorStore","BlockPopoverInbetween","InsertionPointOpenRef","InsertionPointPopover","__unstablePopoverSlot","__unstableContentRef","selectBlock","hideInsertionPoint","openRef","ref","orientation","previousClientId","nextClientId","rootClientId","isInserterShown","select","getBlockOrder","getBlockListSettings","getBlockInsertionPoint","isBlockBeingDragged","getPreviousBlockClientId","getNextBlockClientId","insertionPoint","order","length","_previousClientId","index","_nextClientId","__unstableWithInserter","isVertical","disableMotion","onClick","event","target","current","onFocus","maybeHideInserterPoint","horizontalLine","start","width","top","bottom","x","rest","hover","verticalLine","height","left","right","y","lineVariants","opacity","borderRadius","transition","delay","type","inserterVariants","scale","className","isOpen","InsertionPoint","props","isVisible","isBlockInsertionPointVisible"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,MAAT,EAAiBC,aAAjB,EAAgCC,UAAhC,QAAkD,oBAAlD;AACA,SAASC,gBAAgB,IAAIC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,aAArB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AAEA,OAAO,MAAMC,qBAAqB,GAAGT,aAAa,EAA3C;;AAEP,SAASU,qBAAT,OAGI;AAAA,MAH4B;AAC/BC,IAAAA,qBAD+B;AAE/BC,IAAAA;AAF+B,GAG5B;AACH,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA;AAAf,MAAsChB,WAAW,CAAES,gBAAF,CAAvD;AACA,QAAMQ,OAAO,GAAGd,UAAU,CAAEQ,qBAAF,CAA1B;AACA,QAAMO,GAAG,GAAGjB,MAAM,EAAlB;AACA,QAAM;AACLkB,IAAAA,WADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,YAHK;AAILC,IAAAA,YAJK;AAKLC,IAAAA;AALK,MAMFxB,SAAS,CAAIyB,MAAF,IAAc;AAAA;;AAC5B,UAAM;AACLC,MA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IAAA,QAAQ,EAAK8C,MAAF,IAAc;AACxBnD,MAAAA,OAAO,CAAC0B,OAAR,GAAkByB,MAAlB;AACA,KAPF;AAQC,IAAA,eAAe,EAAG,MAAM;AACvBnD,MAAAA,OAAO,CAAC0B,OAAR,GAAkB,KAAlB;AACA;AAVF,IAND,CAtBF,CAND,CADD;AAoDA;;AAED,eAAe,SAAS0B,cAAT,CAAyBC,KAAzB,EAAiC;AAC/C,QAAMC,SAAS,GAAGxE,SAAS,CAAIyB,MAAF,IAAc;AAC1C,WAAOA,MAAM,CAAEf,gBAAF,CAAN,CAA2B+D,4BAA3B,EAAP;AACA,GAF0B,EAExB,EAFwB,CAA3B;AAIA,SAAOD,SAAS,IAAI,cAAC,qBAAD,EAA4BD,KAA5B,CAApB;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRef, createContext, useContext } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport Inserter from '../inserter';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopoverInbetween from '../block-popover/inbetween';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction InsertionPointPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst { selectBlock, hideInsertionPoint } = useDispatch( blockEditorStore );\n\tconst openRef = useContext( InsertionPointOpenRef );\n\tconst ref = useRef();\n\tconst {\n\t\torientation,\n\t\tpreviousClientId,\n\t\tnextClientId,\n\t\trootClientId,\n\t\tisInserterShown,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetBlockOrder,\n\t\t\tgetBlockListSettings,\n\t\t\tgetBlockInsertionPoint,\n\t\t\tisBlockBeingDragged,\n\t\t\tgetPreviousBlockClientId,\n\t\t\tgetNextBlockClientId,\n\t\t} = select( blockEditorStore );\n\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\n\t\tif ( ! order.length ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tlet _previousClientId = order[ insertionPoint.index - 1 ];\n\t\tlet _nextClientId = order[ insertionPoint.index ];\n\n\t\twhile ( isBlockBeingDragged( _previousClientId ) ) {\n\t\t\t_previousClientId = getPreviousBlockClientId( _previousClientId );\n\t\t}\n\n\t\twhile ( isBlockBeingDragged( _nextClientId ) ) {\n\t\t\t_nextClientId = getNextBlockClientId( _nextClientId );\n\t\t}\n\n\t\treturn {\n\t\t\tpreviousClientId: _previousClientId,\n\t\t\tnextClientId: _nextClientId,\n\t\t\torientation:\n\t\t\t\tgetBlockListSettings( insertionPoint.rootClientId )\n\t\t\t\t\t?.orientation || 'vertical',\n\t\t\trootClientId: insertionPoint.rootClientId,\n\t\t\tisInserterShown: insertionPoint?.__unstableWithInserter,\n\t\t};\n\t}, [] );\n\tconst isVertical = orientation === 'vertical';\n\n\tconst disableMotion = useReducedMotion();\n\n\tfunction onClick( event ) {\n\t\tif ( event.target === ref.current && nextClientId ) {\n\t\t\tselectBlock( nextClientId, -1 );\n\t\t}\n\t}\n\n\tfunction onFocus( event ) {\n\t\t// Only handle click on the wrapper specifically, and not an event\n\t\t// bubbled from the inserter itself.\n\t\tif ( event.target !== ref.current ) {\n\t\t\topenRef.current = true;\n\t\t}\n\t}\n\n\tfunction maybeHideInserterPoint( event ) {\n\t\t// Only hide the inserter if it's triggered on the wrapper,\n\t\t// and the inserter is not open.\n\t\tif ( event.target === ref.current && ! openRef.current ) {\n\t\t\thideInsertionPoint();\n\t\t}\n\t}\n\n\t// Define animation variants for the line element.\n\tconst horizontalLine = {\n\t\tstart: {\n\t\t\twidth: 0,\n\t\t\ttop: '50%',\n\t\t\tbottom: '50%',\n\t\t\tx: 0,\n\t\t},\n\t\trest: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t\thover: {\n\t\t\twidth: 4,\n\t\t\ttop: 0,\n\t\t\tbottom: 0,\n\t\t\tx: -2,\n\t\t},\n\t};\n\tconst verticalLine = {\n\t\tstart: {\n\t\t\theight: 0,\n\t\t\tleft: '50%',\n\t\t\tright: '50%',\n\t\t\ty: 0,\n\t\t},\n\t\trest: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t\thover: {\n\t\t\theight: 4,\n\t\t\tleft: 0,\n\t\t\tright: 0,\n\t\t\ty: -2,\n\t\t},\n\t};\n\tconst lineVariants = {\n\t\t// Initial position starts from the center and invisible.\n\t\tstart: {\n\t\t\t...( ! isVertical ? horizontalLine.start : verticalLine.start ),\n\t\t\topacity: 0,\n\t\t},\n\t\t// The line expands to fill the container. If the inserter is visible it\n\t\t// is delayed so it appears orchestrated.\n\t\trest: {\n\t\t\t...( ! isVertical ? horizontalLine.rest : verticalLine.rest ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: isInserterShown ? 0.1 : 0, type: 'tween' },\n\t\t},\n\t\thover: {\n\t\t\t...( ! isVertical ? horizontalLine.hover : verticalLine.hover ),\n\t\t\topacity: 1,\n\t\t\tborderRadius: '2px',\n\t\t\ttransition: { delay: 0.1, type: 'tween' },\n\t\t},\n\t};\n\n\tconst inserterVariants = {\n\t\tstart: {\n\t\t\tscale: disableMotion ? 1 : 0,\n\t\t},\n\t\trest: {\n\t\t\tscale: 1,\n\t\t\ttransition: { type: 'tween' },\n\t\t},\n\t};\n\n\tconst className = classnames(\n\t\t'block-editor-block-list__insertion-point',\n\t\t'is-' + orientation\n\t);\n\n\treturn (\n\t\t<BlockPopoverInbetween\n\t\t\tpreviousClientId={ previousClientId }\n\t\t\tnextClientId={ nextClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tlayout={ ! disableMotion }\n\t\t\t\tinitial={ disableMotion ? 'rest' : 'start' }\n\t\t\t\tanimate=\"rest\"\n\t\t\t\twhileHover=\"hover\"\n\t\t\t\twhileTap=\"pressed\"\n\t\t\t\texit=\"start\"\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ -1 }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tclassName={ classnames( className, {\n\t\t\t\t\t'is-with-inserter': isInserterShown,\n\t\t\t\t} ) }\n\t\t\t\tonHoverEnd={ maybeHideInserterPoint }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ lineVariants }\n\t\t\t\t\tclassName=\"block-editor-block-list__insertion-point-indicator\"\n\t\t\t\t\tdata-testid=\"block-list-insertion-point-indicator\"\n\t\t\t\t/>\n\t\t\t\t{ isInserterShown && (\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tvariants={ inserterVariants }\n\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t'block-editor-block-list__insertion-point-inserter'\n\t\t\t\t\t\t) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Inserter\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tclientId={ nextClientId }\n\t\t\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t\t\t\t__experimentalIsQuick\n\t\t\t\t\t\t\tonToggle={ ( isOpen ) => {\n\t\t\t\t\t\t\t\topenRef.current = isOpen;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonSelectOrClose={ () => {\n\t\t\t\t\t\t\t\topenRef.current = false;\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</motion.div>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t</BlockPopoverInbetween>\n\t);\n}\n\nexport default function InsertionPoint( props ) {\n\tconst isVisible = useSelect( ( select ) => {\n\t\treturn select( blockEditorStore ).isBlockInsertionPointVisible();\n\t}, [] );\n\n\treturn isVisible && <InsertionPointPopover { ...props } />;\n}\n"]}
@@ -9,11 +9,14 @@ import { useCallback, useLayoutEffect, useState } from '@wordpress/element';
9
9
  */
10
10
 
11
11
  import { store as blockEditorStore } from '../../store';
12
- import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs'; // By default the toolbar sets the `shift` prop. If the user scrolls the page
12
+ import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
13
+ const COMMON_PROPS = {
14
+ placement: 'top-start'
15
+ }; // By default the toolbar sets the `shift` prop. If the user scrolls the page
13
16
  // down the toolbar will stay on screen by adopting a sticky position at the
14
17
  // top of the viewport.
15
18
 
16
- const DEFAULT_PROPS = {
19
+ const DEFAULT_PROPS = { ...COMMON_PROPS,
17
20
  flip: false,
18
21
  shift: true
19
22
  }; // When there isn't enough height between the top of the block and the editor
@@ -22,7 +25,7 @@ const DEFAULT_PROPS = {
22
25
  // the block. This only happens if the block is smaller than the viewport, as
23
26
  // otherwise the toolbar will be off-screen.
24
27
 
25
- const RESTRICTED_HEIGHT_PROPS = {
28
+ const RESTRICTED_HEIGHT_PROPS = { ...COMMON_PROPS,
26
29
  flip: true,
27
30
  shift: false
28
31
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["useRefEffect","useSelect","useCallback","useLayoutEffect","useState","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","viewportHeight","ownerDocument","documentElement","clientHeight","hasSpaceForToolbarAbove","top","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,EAAsBC,eAAtB,EAAuCC,QAAvC,QAAuD,oBAAvD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D,C,CAEA;AACA;AACA;;AACA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE,KADe;AAErBC,EAAAA,KAAK,EAAE;AAFc,CAAtB,C,CAKA;AACA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAG;AAC/BF,EAAAA,IAAI,EAAE,IADyB;AAE/BC,EAAAA,KAAK,EAAE;AAFwB,CAAhC;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASE,QAAT,CAAmBC,cAAnB,EAAmCC,oBAAnC,EAAyDC,aAAzD,EAAyE;AACxE,MAAK,CAAEF,cAAF,IAAoB,CAAEC,oBAA3B,EAAkD;AACjD,WAAON,aAAP;AACA;;AAED,QAAMQ,SAAS,GAAGF,oBAAoB,CAACG,qBAArB,EAAlB;AACA,QAAMC,WAAW,GAAGL,cAAc,CAACI,qBAAf,EAApB,CANwE,CAQxE;;AACA,QAAME,cAAc,GACnBN,cAAc,CAACO,aAAf,CAA6BC,eAA7B,CAA6CC,YAD9C;AAGA,QAAMC,uBAAuB,GAC5BP,SAAS,CAACQ,GAAV,GAAgBN,WAAW,CAACM,GAA5B,GAAkCT,aADnC;AAEA,QAAMU,yBAAyB,GAC9BT,SAAS,CAACU,MAAV,GAAmBP,cAAc,GAAGJ,aADrC;;AAGA,MAAKQ,uBAAuB,IAAIE,yBAAhC,EAA4D;AAC3D,WAAOjB,aAAP;AACA;;AAED,SAAOG,uBAAP;AACA;AAED;AACA;AACA;AACA;A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A,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEE,eAAb,qFAAAF,WAAW,EAAqB,QAArB,EAA+BD,WAA/B,CAAX,CAPsB,CAStB;;AACA,QAAII,cAAJ;AACA,UAAMC,SAAS,GAAG7B,oBAAH,aAAGA,oBAAH,gDAAGA,oBAAoB,CAAEM,aAAzB,0DAAG,sBAAqCoB,WAAvD;;AACA,QAAKG,SAAS,CAACC,cAAf,EAAgC;AAC/BF,MAAAA,cAAc,GAAG,IAAIC,SAAS,CAACC,cAAd,CAA8BN,WAA9B,CAAjB;AACAI,MAAAA,cAAc,CAACG,OAAf,CAAwB/B,oBAAxB;AACA;;AAED,WAAO,MAAM;AAAA;;AACZyB,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEO,kBAAb,qFAAAP,WAAW,EAAwB,QAAxB,EAAkCD,WAAlC,CAAX;;AAEA,UAAKI,cAAL,EAAsB;AACrBA,QAAAA,cAAc,CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBc,EAwBZ,CAAET,WAAF,EAAezB,cAAf,EAA+BC,oBAA/B,CAxBY,CAAf;AA0BA,SAAO,EACN,GAAGgB,KADG;AAENkB,IAAAA,GAAG,EAAEb;AAFC,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = {\n\tflip: false,\n\tshift: true,\n};\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled, which positions the toolbar below\n// the block. This only happens if the block is smaller than the viewport, as\n// otherwise the toolbar will be off-screen.\nconst RESTRICTED_HEIGHT_PROPS = {\n\tflip: true,\n\tshift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps( contentElement, selectedBlockElement, toolbarHeight ) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\tconst blockRect = selectedBlockElement.getBoundingClientRect();\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\t// The document element's clientHeight represents the viewport height.\n\tconst viewportHeight =\n\t\tcontentElement.ownerDocument.documentElement.clientHeight;\n\n\tconst hasSpaceForToolbarAbove =\n\t\tblockRect.top - contentRect.top > toolbarHeight;\n\tconst isBlockTallerThanViewport =\n\t\tblockRect.height > viewportHeight - toolbarHeight;\n\n\tif ( hasSpaceForToolbarAbove || isBlockTallerThanViewport ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t);\n\tconst blockIndex = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["useRefEffect","useSelect","useCallback","useLayoutEffect","useState","store","blockEditorStore","__unstableUseBlockElement","useBlockElement","COMMON_PROPS","placement","DEFAULT_PROPS","flip","shift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","viewportHeight","ownerDocument","documentElement","clientHeight","hasSpaceForToolbarAbove","top","isBlockTallerThanViewport","height","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,WAAT,EAAsBC,eAAtB,EAAuCC,QAAvC,QAAuD,oBAAvD;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,yBAAyB,IAAIC,eAAtC,QAA6D,8CAA7D;AAEA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,SAAS,EAAE;AADS,CAArB,C,CAIA;AACA;AACA;;AACA,MAAMC,aAAa,GAAG,EACrB,GAAGF,YADkB;AAErBG,EAAAA,IAAI,EAAE,KAFe;AAGrBC,EAAAA,KAAK,EAAE;AAHc,CAAtB,C,CAMA;AACA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAG,EAC/B,GAAGL,YAD4B;AAE/BG,EAAAA,IAAI,EAAE,IAFyB;AAG/BC,EAAAA,KAAK,EAAE;AAHwB,CAAhC;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASE,QAAT,CAAmBC,cAAnB,EAAmCC,oBAAnC,EAAyDC,aAAzD,EAAyE;AACxE,MAAK,CAAEF,cAAF,IAAoB,CAAEC,oBAA3B,EAAkD;AACjD,WAAON,aAAP;AACA;;AAED,QAAMQ,SAAS,GAAGF,oBAAoB,CAACG,qBAArB,EAAlB;AACA,QAAMC,WAAW,GAAGL,cAAc,CAACI,qBAAf,EAApB,CANwE,CAQxE;;AACA,QAAME,cAAc,GACnBN,cAAc,CAACO,aAAf,CAA6BC,eAA7B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EsC,WAAF,EAAe,CAAEN,UAAF,EAAcM,WAAd,CAAf,CAAf,CA1BG,CA4BH;;AACAtC,EAAAA,eAAe,CAAE,MAAM;AAAA;;AACtB,QAAK,CAAEa,cAAF,IAAoB,CAAEC,oBAA3B,EAAkD;AACjD;AACA,KAHqB,CAKtB;;;AACA,UAAMyB,WAAW,GAAG1B,cAAH,aAAGA,cAAH,gDAAGA,cAAc,CAAEO,aAAnB,0DAAG,sBAA+BoB,WAAnD;AACAD,IAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEE,eAAb,qFAAAF,WAAW,EAAqB,QAArB,EAA+BD,WAA/B,CAAX,CAPsB,CAStB;;AACA,QAAII,cAAJ;AACA,UAAMC,SAAS,GAAG7B,oBAAH,aAAGA,oBAAH,gDAAGA,oBAAoB,CAAEM,aAAzB,0DAAG,sBAAqCoB,WAAvD;;AACA,QAAKG,SAAS,CAACC,cAAf,EAAgC;AAC/BF,MAAAA,cAAc,GAAG,IAAIC,SAAS,CAACC,cAAd,CAA8BN,WAA9B,CAAjB;AACAI,MAAAA,cAAc,CAACG,OAAf,CAAwB/B,oBAAxB;AACA;;AAED,WAAO,MAAM;AAAA;;AACZyB,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEO,kBAAb,qFAAAP,WAAW,EAAwB,QAAxB,EAAkCD,WAAlC,CAAX;;AAEA,UAAKI,cAAL,EAAsB;AACrBA,QAAAA,cAAc,CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBc,EAwBZ,CAAET,WAAF,EAAezB,cAAf,EAA+BC,oBAA/B,CAxBY,CAAf;AA0BA,SAAO,EACN,GAAGgB,KADG;AAENkB,IAAAA,GAAG,EAAEb;AAFC,GAAP;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { useCallback, useLayoutEffect, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\n\nconst COMMON_PROPS = {\n\tplacement: 'top-start',\n};\n\n// By default the toolbar sets the `shift` prop. If the user scrolls the page\n// down the toolbar will stay on screen by adopting a sticky position at the\n// top of the viewport.\nconst DEFAULT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: false,\n\tshift: true,\n};\n\n// When there isn't enough height between the top of the block and the editor\n// canvas, the `shift` prop is set to `false`, as it will cause the block to be\n// obscured. The `flip` behavior is enabled, which positions the toolbar below\n// the block. This only happens if the block is smaller than the viewport, as\n// otherwise the toolbar will be off-screen.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t...COMMON_PROPS,\n\tflip: true,\n\tshift: false,\n};\n\n/**\n * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.\n *\n * @param {Element} contentElement The DOM element that represents the editor content or canvas.\n * @param {Element} selectedBlockElement The outer DOM element of the first selected block.\n * @param {number} toolbarHeight The height of the toolbar in pixels.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nfunction getProps( contentElement, selectedBlockElement, toolbarHeight ) {\n\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\tconst blockRect = selectedBlockElement.getBoundingClientRect();\n\tconst contentRect = contentElement.getBoundingClientRect();\n\n\t// The document element's clientHeight represents the viewport height.\n\tconst viewportHeight =\n\t\tcontentElement.ownerDocument.documentElement.clientHeight;\n\n\tconst hasSpaceForToolbarAbove =\n\t\tblockRect.top - contentRect.top > toolbarHeight;\n\tconst isBlockTallerThanViewport =\n\t\tblockRect.height > viewportHeight - toolbarHeight;\n\n\tif ( hasSpaceForToolbarAbove || isBlockTallerThanViewport ) {\n\t\treturn DEFAULT_PROPS;\n\t}\n\n\treturn RESTRICTED_HEIGHT_PROPS;\n}\n\n/**\n * Determines the desired popover positioning behavior, returning a set of appropriate props.\n *\n * @param {Object} elements\n * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.\n * @param {string} elements.clientId The clientId of the first selected block.\n *\n * @return {Object} The popover props used to determine the position of the toolbar.\n */\nexport default function useBlockToolbarPopoverProps( {\n\tcontentElement,\n\tclientId,\n} ) {\n\tconst selectedBlockElement = useBlockElement( clientId );\n\tconst [ toolbarHeight, setToolbarHeight ] = useState( 0 );\n\tconst [ props, setProps ] = useState( () =>\n\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t);\n\tconst blockIndex = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ),\n\t\t[ clientId ]\n\t);\n\n\tconst popoverRef = useRefEffect( ( popoverNode ) => {\n\t\tsetToolbarHeight( popoverNode.offsetHeight );\n\t}, [] );\n\n\tconst updateProps = useCallback(\n\t\t() =>\n\t\t\tsetProps(\n\t\t\t\tgetProps( contentElement, selectedBlockElement, toolbarHeight )\n\t\t\t),\n\t\t[ contentElement, selectedBlockElement, toolbarHeight ]\n\t);\n\n\t// Update props when the block is moved. This also ensures the props are\n\t// correct on initial mount, and when the selected block or content element\n\t// changes (since the callback ref will update).\n\tuseLayoutEffect( updateProps, [ blockIndex, updateProps ] );\n\n\t// Update props when the viewport is resized or the block is resized.\n\tuseLayoutEffect( () => {\n\t\tif ( ! contentElement || ! selectedBlockElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update the toolbar props on viewport resize.\n\t\tconst contentView = contentElement?.ownerDocument?.defaultView;\n\t\tcontentView?.addEventHandler?.( 'resize', updateProps );\n\n\t\t// Update the toolbar props on block resize.\n\t\tlet resizeObserver;\n\t\tconst blockView = selectedBlockElement?.ownerDocument?.defaultView;\n\t\tif ( blockView.ResizeObserver ) {\n\t\t\tresizeObserver = new blockView.ResizeObserver( updateProps );\n\t\t\tresizeObserver.observe( selectedBlockElement );\n\t\t}\n\n\t\treturn () => {\n\t\t\tcontentView?.removeEventHandler?.( 'resize', updateProps );\n\n\t\t\tif ( resizeObserver ) {\n\t\t\t\tresizeObserver.disconnect();\n\t\t\t}\n\t\t};\n\t}, [ updateProps, contentElement, selectedBlockElement ] );\n\n\treturn {\n\t\t...props,\n\t\tref: popoverRef,\n\t};\n}\n"]}
@@ -62,7 +62,8 @@ function BlockVariationPicker(_ref) {
62
62
  onClose: onClose,
63
63
  title: __('Select a layout'),
64
64
  contentStyle: styles.contentStyle,
65
- leftButton: leftButton
65
+ leftButton: leftButton,
66
+ testID: "block-variation-modal"
66
67
  }, createElement(ScrollView, {
67
68
  horizontal: true,
68
69
  showsHorizontalScrollIndicator: false,