@wordpress/block-editor 9.7.1-next.d6164808d3.0 → 9.8.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 9.8.0 (2022-08-24)
6
+
5
7
  ## 9.7.0 (2022-08-10)
6
8
 
7
9
  ## 9.6.0 (2022-07-27)
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = BlockPopover;
8
+ exports.default = void 0;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
@@ -13,6 +13,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
13
13
 
14
14
  var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
+ var _compose = require("@wordpress/compose");
17
+
16
18
  var _components = require("@wordpress/components");
17
19
 
18
20
  var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
@@ -30,7 +32,7 @@ var _usePopoverScroll = _interopRequireDefault(require("./use-popover-scroll"));
30
32
  /**
31
33
  * Internal dependencies
32
34
  */
33
- function BlockPopover(_ref) {
35
+ function BlockPopover(_ref, ref) {
34
36
  let {
35
37
  clientId,
36
38
  bottomClientId,
@@ -43,7 +45,7 @@ function BlockPopover(_ref) {
43
45
  } = _ref;
44
46
  const selectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
45
47
  const lastSelectedElement = (0, _useBlockRefs.__unstableUseBlockElement)(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
46
- const popoverScrollRef = (0, _usePopoverScroll.default)(__unstableContentRef);
48
+ const mergedRefs = (0, _compose.useMergeRefs)([ref, (0, _usePopoverScroll.default)(__unstableContentRef)]);
47
49
  const style = (0, _element.useMemo)(() => {
48
50
  if (!selectedElement || lastSelectedElement !== selectedElement) {
49
51
  return {};
@@ -65,7 +67,7 @@ function BlockPopover(_ref) {
65
67
  bottom: lastSelectedElement
66
68
  };
67
69
  return (0, _element.createElement)(_components.Popover, (0, _extends2.default)({
68
- ref: popoverScrollRef,
70
+ ref: mergedRefs,
69
71
  animate: false,
70
72
  position: "top right left",
71
73
  focusOnMount: false,
@@ -83,4 +85,8 @@ function BlockPopover(_ref) {
83
85
  style: style
84
86
  }, children), !__unstableCoverTarget && children);
85
87
  }
88
+
89
+ var _default = (0, _element.forwardRef)(BlockPopover);
90
+
91
+ exports.default = _default;
86
92
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["BlockPopover","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","popoverScrollRef","style","position","width","offsetWidth","height","offsetHeight","anchorRef","top","bottom","className"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAMA;;AACA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAIe,SAASA,YAAT,OASX;AAAA,MATkC;AACrCC,IAAAA,QADqC;AAErCC,IAAAA,cAFqC;AAGrCC,IAAAA,QAHqC;AAIrCC,IAAAA,qBAJqC;AAKrCC,IAAAA,qBAAqB,GAAG,KALa;AAMrCC,IAAAA,qBANqC;AAOrCC,IAAAA,oBAPqC;AAQrC,OAAGC;AARkC,GASlC;AACH,QAAMC,eAAe,GAAG,6CAAiBR,QAAjB,CAAxB;AACA,QAAMS,mBAAmB,GAAG,6CAAiBR,cAAjB,aAAiBA,cAAjB,cAAiBA,cAAjB,GAAmCD,QAAnC,CAA5B;AACA,QAAMU,gBAAgB,GAAG,+BAAkBJ,oBAAlB,CAAzB;AACA,QAAMK,KAAK,GAAG,sBAAS,MAAM;AAC5B,QAAK,CAAEH,eAAF,IAAqBC,mBAAmB,KAAKD,eAAlD,EAAoE;AACnE,aAAO,EAAP;AACA;;AAED,WAAO;AACNI,MAAAA,QAAQ,EAAE,UADJ;AAENC,MAAAA,KAAK,EAAEL,eAAe,CAACM,WAFjB;AAGNC,MAAAA,MAAM,EAAEP,eAAe,CAACQ;AAHlB,KAAP;AAKA,GAVa,EAUX,CAAER,eAAF,EAAmBC,mBAAnB,EAAwCN,qBAAxC,CAVW,CAAd;;AAYA,MAAK,CAAEK,eAAF,IAAuBP,cAAc,IAAI,CAAEQ,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,QAAMQ,SAAS,GAAG;AACjBC,IAAAA,GAAG,EAAEV,eADY;AAEjBW,IAAAA,MAAM,EAAEV;AAFS,GAAlB;AAKA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGC,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,QAAQ,EAAC,gBAHV;AAIC,IAAA,YAAY,EAAG,KAJhB;AAKC,IAAA,SAAS,EAAGO,SALb,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGZ,qBAAqB,IAAI,IAR/C,CASC;AATD;AAUC,IAAA,wBAAwB,EAAGG,eAV5B;AAWC,IAAA,uBAAuB,MAXxB;AAYC,IAAA,eAAe;AAZhB,KAaMD,KAbN;AAcC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEXA,KAAK,CAACa,SAFK;AAdb,MAmBGhB,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAnB5B,EAoBG,CAAEE,qBAAF,IAA2BF,QApB9B,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { 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\nexport default function BlockPopover( {\n\tclientId,\n\tbottomClientId,\n\tchildren,\n\t__unstableRefreshSize,\n\t__unstableCoverTarget = false,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\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\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\tconst anchorRef = {\n\t\ttop: selectedElement,\n\t\tbottom: lastSelectedElement,\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchorRef={ anchorRef }\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\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ selectedElement }\n\t\t\t__unstableForcePosition\n\t\t\t__unstableShift\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"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","anchorRef","top","bottom","className"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAMA;;AACA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;AAIA,SAASA,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,GAAG,6CAAiBR,QAAjB,CAAxB;AACA,QAAMS,mBAAmB,GAAG,6CAAiBR,cAAjB,aAAiBA,cAAjB,cAAiBA,cAAjB,GAAmCD,QAAnC,CAA5B;AACA,QAAMU,UAAU,GAAG,2BAAc,CAChCX,GADgC,EAEhC,+BAAkBO,oBAAlB,CAFgC,CAAd,CAAnB;AAIA,QAAMK,KAAK,GAAG,sBAAS,MAAM;AAC5B,QAAK,CAAEH,eAAF,IAAqBC,mBAAmB,KAAKD,eAAlD,EAAoE;AACnE,aAAO,EAAP;AACA;;AAED,WAAO;AACNI,MAAAA,QAAQ,EAAE,UADJ;AAENC,MAAAA,KAAK,EAAEL,eAAe,CAACM,WAFjB;AAGNC,MAAAA,MAAM,EAAEP,eAAe,CAACQ;AAHlB,KAAP;AAKA,GAVa,EAUX,CAAER,eAAF,EAAmBC,mBAAnB,EAAwCN,qBAAxC,CAVW,CAAd;;AAYA,MAAK,CAAEK,eAAF,IAAuBP,cAAc,IAAI,CAAEQ,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,QAAMQ,SAAS,GAAG;AACjBC,IAAAA,GAAG,EAAEV,eADY;AAEjBW,IAAAA,MAAM,EAAEV;AAFS,GAAlB;AAKA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGC,UADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,QAAQ,EAAC,gBAHV;AAIC,IAAA,YAAY,EAAG,KAJhB;AAKC,IAAA,SAAS,EAAGO,SALb,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGZ,qBAAqB,IAAI,IAR/C,CASC;AATD;AAUC,IAAA,wBAAwB,EAAGG,eAV5B;AAWC,IAAA,uBAAuB,MAXxB;AAYC,IAAA,eAAe;AAZhB,KAaMD,KAbN;AAcC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEXA,KAAK,CAACa,SAFK;AAdb,MAmBGhB,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAnB5B,EAoBG,CAAEE,qBAAF,IAA2BF,QApB9B,CADD;AAwBA;;eAEc,yBAAYJ,YAAZ,C","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\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\tconst anchorRef = {\n\t\ttop: selectedElement,\n\t\tbottom: lastSelectedElement,\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\tanchorRef={ anchorRef }\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\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ selectedElement }\n\t\t\t__unstableForcePosition\n\t\t\t__unstableShift\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"]}
@@ -9,6 +9,8 @@ exports.default = WrappedBlockPopover;
9
9
 
10
10
  var _element = require("@wordpress/element");
11
11
 
12
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
+
12
14
  var _lodash = require("lodash");
13
15
 
14
16
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -29,6 +31,8 @@ var _store = require("../../store");
29
31
 
30
32
  var _blockPopover = _interopRequireDefault(require("../block-popover"));
31
33
 
34
+ var _useBlockToolbarPopoverProps = _interopRequireDefault(require("./use-block-toolbar-popover-props"));
35
+
32
36
  /**
33
37
  * External dependencies
34
38
  */
@@ -110,12 +114,16 @@ function SelectedBlockPopover(_ref) {
110
114
  // to it when re-mounting.
111
115
 
112
116
  const initialToolbarItemIndexRef = (0, _element.useRef)();
117
+ const popoverProps = (0, _useBlockToolbarPopoverProps.default)({
118
+ contentElement: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current,
119
+ clientId
120
+ });
113
121
 
114
122
  if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
115
123
  return null;
116
124
  }
117
125
 
118
- return (0, _element.createElement)(_blockPopover.default, {
126
+ return (0, _element.createElement)(_blockPopover.default, (0, _extends2.default)({
119
127
  clientId: capturingClientId || clientId,
120
128
  bottomClientId: lastClientId,
121
129
  className: (0, _classnames.default)('block-editor-block-list__block-popover', {
@@ -123,7 +131,7 @@ function SelectedBlockPopover(_ref) {
123
131
  }),
124
132
  __unstablePopoverSlot: __unstablePopoverSlot,
125
133
  __unstableContentRef: __unstableContentRef
126
- }, shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
134
+ }, popoverProps), shouldShowContextualToolbar && (0, _element.createElement)(_blockContextualToolbar.default // If the toolbar is being shown because of being forced
127
135
  // it should focus the toolbar right after the mount.
128
136
  , {
129
137
  focusOnMount: isToolbarForced.current,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AArBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAMA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEO,YAAF,CAPV;AAQA,SAAO;AACNN,IAAAA,gBAAgB,EAAEA,gBAAgB,EAD5B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAINI,IAAAA,eAAe,EAAEH,WAAW,GAAGG,eAJzB;AAKNC,IAAAA,YAAY,EAAEN,iBAAiB,KAC5BG,iCAAiC,EADL,GAE5B;AAPG,GAAP;AASA;;AAED,SAASI,oBAAT,OAOI;AAAA,MAP2B;AAC9BC,IAAAA,QAD8B;AAE9BC,IAAAA,YAF8B;AAG9BC,IAAAA,mBAH8B;AAI9BC,IAAAA,iBAJ8B;AAK9BC,IAAAA,qBAL8B;AAM9BC,IAAAA;AAN8B,GAO3B;AACH,QAAM;AACLf,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLE,IAAAA,QAHK;AAILI,IAAAA,eAJK;AAKLC,IAAAA;AALK,MAMF,qBAAWV,QAAX,EAAqB,EAArB,CANJ;AAOA,QAAMkB,uBAAuB,GAAG,qBAC7BjB,MAAF,IAAc;AACb,UAAM;AACLkB,MAAAA,4BADK;AAELC,MAAAA,sBAFK;AAGLC,MAAAA;AAHK,QAIFpB,MAAM,CAA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C,CAyBlC;;;AACA,QAAM7B,iBAAiB,GAAG,kBACzB6B,qBADyB,EAEvBE,cAAF;AAAA;;AAAA,oCACCD,uBAAuB,CAAEC,cAAF,CADxB,0DACC,sBACGC,6BAFJ;AAAA,GAFyB,CAA1B;AAOA,SAAO;AACNnC,IAAAA,QADM;AAENC,IAAAA,YAAY,EAAEyB,oBAAoB,CAAE1B,QAAF,CAF5B;AAGN8B,IAAAA,IAHM;AAIN5B,IAAAA,mBAAmB,EAClB4B,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CALH;AAMN5B,IAAAA;AANM,GAAP;AAQA;;AAEc,SAASiC,mBAAT,QAGX;AAAA,MAHyC;AAC5ChC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMgC,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLrC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGL6B,IAAAA,IAHK;AAIL5B,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFkC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAG9B,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","blockEditorStore","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","popoverProps","contentElement","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;;;;;;;AASA;;;;AANA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAtBA;AACA;AACA;;AAIA;AACA;AACA;;AAOA;AACA;AACA;AAOA,SAASA,QAAT,CAAmBC,MAAnB,EAA4B;A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FyB,CAA1B;AAOA,SAAO;AACNrC,IAAAA,QADM;AAENC,IAAAA,YAAY,EAAE2B,oBAAoB,CAAE5B,QAAF,CAF5B;AAGNgC,IAAAA,IAHM;AAIN9B,IAAAA,mBAAmB,EAClB8B,IAAI,IAAI,sCAA0B;AAAEA,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAA1B,CALH;AAMN9B,IAAAA;AANM,GAAP;AAQA;;AAEc,SAASmC,mBAAT,QAGX;AAAA,MAHyC;AAC5ClC,IAAAA,qBAD4C;AAE5CC,IAAAA;AAF4C,GAGzC;AACH,QAAMkC,QAAQ,GAAG,qBAAWd,eAAX,EAA4B,EAA5B,CAAjB;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLvC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGL+B,IAAAA,IAHK;AAIL9B,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFoC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGhC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useBlockToolbarPopoverProps;
7
+
8
+ var _compose = require("@wordpress/compose");
9
+
10
+ var _data = require("@wordpress/data");
11
+
12
+ var _element = require("@wordpress/element");
13
+
14
+ var _store = require("../../store");
15
+
16
+ var _useBlockRefs = require("../block-list/use-block-props/use-block-refs");
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+
22
+ /**
23
+ * Internal dependencies
24
+ */
25
+ // By default the toolbar sets the `shift` prop. If the user scrolls the page
26
+ // down the toolbar will stay on screen by adopting a sticky position at the
27
+ // top of the viewport.
28
+ const DEFAULT_PROPS = {
29
+ __unstableForcePosition: true,
30
+ __unstableShift: true
31
+ }; // When there isn't enough height between the top of the block and the editor
32
+ // canvas, the `shift` prop is set to `false`, as it will cause the block to be
33
+ // obscured. The `flip` behavior is enabled (by setting `forcePosition` to
34
+ // `false`), which positions the toolbar below the block.
35
+
36
+ const RESTRICTED_HEIGHT_PROPS = {
37
+ __unstableForcePosition: false,
38
+ __unstableShift: false
39
+ };
40
+ /**
41
+ * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
42
+ *
43
+ * @param {Element} contentElement The DOM element that represents the editor content or canvas.
44
+ * @param {Element} selectedBlockElement The outer DOM element of the first selected block.
45
+ * @param {number} toolbarHeight The height of the toolbar in pixels.
46
+ *
47
+ * @return {Object} The popover props used to determine the position of the toolbar.
48
+ */
49
+
50
+ function getProps(contentElement, selectedBlockElement, toolbarHeight) {
51
+ if (!contentElement || !selectedBlockElement) {
52
+ return DEFAULT_PROPS;
53
+ }
54
+
55
+ const blockRect = selectedBlockElement.getBoundingClientRect();
56
+ const contentRect = contentElement.getBoundingClientRect();
57
+
58
+ if (blockRect.top - contentRect.top > toolbarHeight) {
59
+ return DEFAULT_PROPS;
60
+ }
61
+
62
+ return RESTRICTED_HEIGHT_PROPS;
63
+ }
64
+ /**
65
+ * Determines the desired popover positioning behavior, returning a set of appropriate props.
66
+ *
67
+ * @param {Object} elements
68
+ * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
69
+ * @param {string} elements.clientId The clientId of the first selected block.
70
+ *
71
+ * @return {Object} The popover props used to determine the position of the toolbar.
72
+ */
73
+
74
+
75
+ function useBlockToolbarPopoverProps(_ref) {
76
+ let {
77
+ contentElement,
78
+ clientId
79
+ } = _ref;
80
+ const selectedBlockElement = (0, _useBlockRefs.__unstableUseBlockElement)(clientId);
81
+ const [toolbarHeight, setToolbarHeight] = (0, _element.useState)(0);
82
+ const [props, setProps] = (0, _element.useState)(() => getProps(contentElement, selectedBlockElement, toolbarHeight));
83
+ const blockIndex = (0, _data.useSelect)(select => select(_store.store).getBlockIndex(clientId), [clientId]);
84
+ const popoverRef = (0, _compose.useRefEffect)(popoverNode => {
85
+ setToolbarHeight(popoverNode.offsetHeight);
86
+ }, []);
87
+ const updateProps = (0, _element.useCallback)(() => setProps(getProps(contentElement, selectedBlockElement, toolbarHeight)), [contentElement, selectedBlockElement, toolbarHeight]); // Update props when the block is moved. This also ensures the props are
88
+ // correct on initial mount, and when the selected block or content element
89
+ // changes (since the callback ref will update).
90
+
91
+ (0, _element.useLayoutEffect)(updateProps, [blockIndex, updateProps]); // Update props when the viewport is resized or the block is resized.
92
+
93
+ (0, _element.useLayoutEffect)(() => {
94
+ var _contentElement$owner, _contentView$addEvent, _selectedBlockElement;
95
+
96
+ if (!contentElement || !selectedBlockElement) {
97
+ return;
98
+ } // Update the toolbar props on viewport resize.
99
+
100
+
101
+ const contentView = contentElement === null || contentElement === void 0 ? void 0 : (_contentElement$owner = contentElement.ownerDocument) === null || _contentElement$owner === void 0 ? void 0 : _contentElement$owner.defaultView;
102
+ contentView === null || contentView === void 0 ? void 0 : (_contentView$addEvent = contentView.addEventHandler) === null || _contentView$addEvent === void 0 ? void 0 : _contentView$addEvent.call(contentView, 'resize', updateProps); // Update the toolbar props on block resize.
103
+
104
+ let resizeObserver;
105
+ const blockView = selectedBlockElement === null || selectedBlockElement === void 0 ? void 0 : (_selectedBlockElement = selectedBlockElement.ownerDocument) === null || _selectedBlockElement === void 0 ? void 0 : _selectedBlockElement.defaultView;
106
+
107
+ if (blockView.ResizeObserver) {
108
+ resizeObserver = new blockView.ResizeObserver(updateProps);
109
+ resizeObserver.observe(selectedBlockElement);
110
+ }
111
+
112
+ return () => {
113
+ var _contentView$removeEv;
114
+
115
+ contentView === null || contentView === void 0 ? void 0 : (_contentView$removeEv = contentView.removeEventHandler) === null || _contentView$removeEv === void 0 ? void 0 : _contentView$removeEv.call(contentView, 'resize', updateProps);
116
+
117
+ if (resizeObserver) {
118
+ resizeObserver.disconnect();
119
+ }
120
+ };
121
+ }, [updateProps, contentElement, selectedBlockElement]);
122
+ return { ...props,
123
+ ref: popoverRef
124
+ };
125
+ }
126
+ //# sourceMappingURL=use-block-toolbar-popover-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/use-block-toolbar-popover-props.js"],"names":["DEFAULT_PROPS","__unstableForcePosition","__unstableShift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","top","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","blockEditorStore","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","ownerDocument","defaultView","addEventHandler","resizeObserver","blockView","ResizeObserver","observe","removeEventHandler","disconnect","ref"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA;AACA;AACA,MAAMA,aAAa,GAAG;AAAEC,EAAAA,uBAAuB,EAAE,IAA3B;AAAiCC,EAAAA,eAAe,EAAE;AAAlD,CAAtB,C,CAEA;AACA;AACA;AACA;;AACA,MAAMC,uBAAuB,GAAG;AAC/BF,EAAAA,uBAAuB,EAAE,KADM;AAE/BC,EAAAA,eAAe,EAAE;AAFc,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;;AAEA,MAAKD,SAAS,CAACG,GAAV,GAAgBD,WAAW,CAACC,GAA5B,GAAkCJ,aAAvC,EAAuD;AACtD,WAAOP,aAAP;AACA;;AAED,SAAOG,uBAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACe,SAASS,2BAAT,OAGX;AAAA,MAHiD;AACpDP,IAAAA,cADoD;AAEpDQ,IAAAA;AAFoD,GAGjD;AACH,QAAMP,oBAAoB,GAAG,6CAAiBO,QAAjB,CAA7B;AACA,QAAM,CAAEN,aAAF,EAAiBO,gBAAjB,IAAsC,uBAAU,CAAV,CAA5C;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,MACrCZ,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cAAc,CAACG,OAAf,CAAwB1B,oBAAxB;AACA;;AAED,WAAO,MAAM;AAAA;;AACZmB,MAAAA,WAAW,SAAX,IAAAA,WAAW,WAAX,qCAAAA,WAAW,CAAEQ,kBAAb,qFAAAR,WAAW,EAAwB,QAAxB,EAAkCD,WAAlC,CAAX;;AAEA,UAAKK,cAAL,EAAsB;AACrBA,QAAAA,cAAc,CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBD,EAwBG,CAAEV,WAAF,EAAenB,cAAf,EAA+BC,oBAA/B,CAxBH;AA0BA,SAAO,EACN,GAAGS,KADG;AAENoB,IAAAA,GAAG,EAAEd;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 = { __unstableForcePosition: true, __unstableShift: true };\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 (by setting `forcePosition` to\n// `false`), which positions the toolbar below the block.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t__unstableForcePosition: false,\n\t__unstableShift: 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\tif ( blockRect.top - contentRect.top > toolbarHeight ) {\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"]}
@@ -70,6 +70,10 @@ var _default = {
70
70
  }));
71
71
  }
72
72
 
73
+ const {
74
+ contentSize,
75
+ wideSize
76
+ } = layout;
73
77
  const alignments = [{
74
78
  name: 'left'
75
79
  }, {
@@ -77,6 +81,20 @@ var _default = {
77
81
  }, {
78
82
  name: 'right'
79
83
  }];
84
+
85
+ if (contentSize) {
86
+ alignments.unshift({
87
+ name: 'full'
88
+ });
89
+ }
90
+
91
+ if (wideSize) {
92
+ alignments.unshift({
93
+ name: 'wide',
94
+ info: alignmentInfo.wide
95
+ });
96
+ }
97
+
80
98
  alignments.unshift({
81
99
  name: 'none',
82
100
  info: alignmentInfo.none
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["name","label","inspectorControls","DefaultLayoutInspectorControls","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","getOrientation","getAlignments","layout","alignmentInfo","alignments","undefined","includes","unshift","map","alignment","info","none"],"mappings":";;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;eAMe;AACdA,EAAAA,IAAI,EAAE,SADQ;AAEdC,EAAAA,KAAK,EAAE,cAAI,MAAJ,CAFO;AAGdC,EAAAA,i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AA3B;AACA;;AACD,aAAOL,MAAM,CAACE,UAAP,CAAkBI,GAAlB,CAAyBC,SAAF,KAAmB;AAChD3B,QAAAA,IAAI,EAAE2B,SAD0C;AAEhDC,QAAAA,IAAI,EAAEP,aAAa,CAAEM,SAAF;AAF6B,OAAnB,CAAvB,CAAP;AAIA;;AAED,UAAML,UAAU,GAAG,CAClB;AAAEtB,MAAAA,IAAI,EAAE;AAAR,KADkB,EAElB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAFkB,EAGlB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAHkB,CAAnB;AAMAsB,IAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,MAAAA,IAAI,EAAE,MAAR;AAAgB4B,MAAAA,IAAI,EAAEP,aAAa,CAACQ;AAApC,KAApB;AAEA,WAAOP,UAAP;AACA;;AAhEa,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls() {\n\t\treturn null;\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output = '';\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["name","label","inspectorControls","DefaultLayoutInspectorControls","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","getOrientation","getAlignments","layout","alignmentInfo","alignments","undefined","includes","unshift","map","alignment","info","contentSize","wideSize","wide","none"],"mappings":";;;;;;;AAGA;;AAMA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;eAMe;AACdA,EAAAA,IAAI,EAAE,SADQ;AAEdC,EAAAA,KAAK,EAAE,cAAI,MAAJ,CAFO;AAGdC,EAAAA,iBAAiB,EAAE,SAASC,8BAAT,GAA0C;AAC5D,WAAO,IAAP;AACA,GALa;AA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,SAAF,KAAmB;AAChD3B,QAAAA,IAAI,EAAE2B,SAD0C;AAEhDC,QAAAA,IAAI,EAAEP,aAAa,CAAEM,SAAF;AAF6B,OAAnB,CAAvB,CAAP;AAIA;;AACD,UAAM;AAAEE,MAAAA,WAAF;AAAeC,MAAAA;AAAf,QAA4BV,MAAlC;AAEA,UAAME,UAAU,GAAG,CAClB;AAAEtB,MAAAA,IAAI,EAAE;AAAR,KADkB,EAElB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAFkB,EAGlB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAHkB,CAAnB;;AAMA,QAAK6B,WAAL,EAAmB;AAClBP,MAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,QAAAA,IAAI,EAAE;AAAR,OAApB;AACA;;AAED,QAAK8B,QAAL,EAAgB;AACfR,MAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,QAAAA,IAAI,EAAE,MAAR;AAAgB4B,QAAAA,IAAI,EAAEP,aAAa,CAACU;AAApC,OAApB;AACA;;AAEDT,IAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,MAAAA,IAAI,EAAE,MAAR;AAAgB4B,MAAAA,IAAI,EAAEP,aAAa,CAACW;AAApC,KAApB;AAEA,WAAOV,UAAP;AACA;;AAzEa,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls() {\n\t\treturn null;\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output = '';\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"]}
@@ -9,15 +9,17 @@ import classnames from 'classnames';
9
9
  * WordPress dependencies
10
10
  */
11
11
 
12
+ import { useMergeRefs } from '@wordpress/compose';
12
13
  import { Popover } from '@wordpress/components';
13
- import { useMemo } from '@wordpress/element';
14
+ import { forwardRef, useMemo } from '@wordpress/element';
14
15
  /**
15
16
  * Internal dependencies
16
17
  */
17
18
 
18
19
  import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
19
20
  import usePopoverScroll from './use-popover-scroll';
20
- export default function BlockPopover(_ref) {
21
+
22
+ function BlockPopover(_ref, ref) {
21
23
  let {
22
24
  clientId,
23
25
  bottomClientId,
@@ -30,7 +32,7 @@ export default function BlockPopover(_ref) {
30
32
  } = _ref;
31
33
  const selectedElement = useBlockElement(clientId);
32
34
  const lastSelectedElement = useBlockElement(bottomClientId !== null && bottomClientId !== void 0 ? bottomClientId : clientId);
33
- const popoverScrollRef = usePopoverScroll(__unstableContentRef);
35
+ const mergedRefs = useMergeRefs([ref, usePopoverScroll(__unstableContentRef)]);
34
36
  const style = useMemo(() => {
35
37
  if (!selectedElement || lastSelectedElement !== selectedElement) {
36
38
  return {};
@@ -52,7 +54,7 @@ export default function BlockPopover(_ref) {
52
54
  bottom: lastSelectedElement
53
55
  };
54
56
  return createElement(Popover, _extends({
55
- ref: popoverScrollRef,
57
+ ref: mergedRefs,
56
58
  animate: false,
57
59
  position: "top right left",
58
60
  focusOnMount: false,
@@ -70,4 +72,6 @@ export default function BlockPopover(_ref) {
70
72
  style: style
71
73
  }, children), !__unstableCoverTarget && children);
72
74
  }
75
+
76
+ export default forwardRef(BlockPopover);
73
77
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["classnames","Popover","useMemo","__unstableUseBlockElement","useBlockElement","usePopoverScroll","BlockPopover","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","popoverScrollRef","style","position","width","offsetWidth","height","offsetHeight","anchorRef","top","bottom","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S,GAAlB;AAKA,SACC,cAAC,OAAD;AACC,IAAA,GAAG,EAAGC,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,QAAQ,EAAC,gBAHV;AAIC,IAAA,YAAY,EAAG,KAJhB;AAKC,IAAA,SAAS,EAAGO,SALb,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGZ,qBAAqB,IAAI,IAR/C,CASC;AATD;AAUC,IAAA,wBAAwB,EAAGG,eAV5B;AAWC,IAAA,uBAAuB,MAXxB;AAYC,IAAA,eAAe;AAZhB,KAaMD,KAbN;AAcC,IAAA,SAAS,EAAGd,UAAU,CACrB,4BADqB,EAErBc,KAAK,CAACa,SAFe;AAdvB,MAmBGhB,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAnB5B,EAoBG,CAAEE,qBAAF,IAA2BF,QApB9B,CADD;AAwBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { 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\nexport default function BlockPopover( {\n\tclientId,\n\tbottomClientId,\n\tchildren,\n\t__unstableRefreshSize,\n\t__unstableCoverTarget = false,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\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\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\tconst anchorRef = {\n\t\ttop: selectedElement,\n\t\tbottom: lastSelectedElement,\n\t};\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchorRef={ anchorRef }\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\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ selectedElement }\n\t\t\t__unstableForcePosition\n\t\t\t__unstableShift\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"]}
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","anchorRef","top","bottom","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,O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O,SALb,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGZ,qBAAqB,IAAI,IAR/C,CASC;AATD;AAUC,IAAA,wBAAwB,EAAGG,eAV5B;AAWC,IAAA,uBAAuB,MAXxB;AAYC,IAAA,eAAe;AAZhB,KAaMD,KAbN;AAcC,IAAA,SAAS,EAAGjB,UAAU,CACrB,4BADqB,EAErBiB,KAAK,CAACa,SAFe;AAdvB,MAmBGhB,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAnB5B,EAoBG,CAAEE,qBAAF,IAA2BF,QApB9B,CADD;AAwBA;;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\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\tconst anchorRef = {\n\t\ttop: selectedElement,\n\t\tbottom: lastSelectedElement,\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\tanchorRef={ anchorRef }\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\t// Observe movement for block animations (especially horizontal).\n\t\t\t__unstableObserveElement={ selectedElement }\n\t\t\t__unstableForcePosition\n\t\t\t__unstableShift\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,3 +1,4 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
1
2
  import { createElement } from "@wordpress/element";
2
3
 
3
4
  /**
@@ -22,6 +23,7 @@ import BlockSelectionButton from './block-selection-button';
22
23
  import BlockContextualToolbar from './block-contextual-toolbar';
23
24
  import { store as blockEditorStore } from '../../store';
24
25
  import BlockPopover from '../block-popover';
26
+ import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
25
27
 
26
28
  function selector(select) {
27
29
  const {
@@ -93,12 +95,16 @@ function SelectedBlockPopover(_ref) {
93
95
  // to it when re-mounting.
94
96
 
95
97
  const initialToolbarItemIndexRef = useRef();
98
+ const popoverProps = useBlockToolbarPopoverProps({
99
+ contentElement: __unstableContentRef === null || __unstableContentRef === void 0 ? void 0 : __unstableContentRef.current,
100
+ clientId
101
+ });
96
102
 
97
103
  if (!shouldShowBreadcrumb && !shouldShowContextualToolbar) {
98
104
  return null;
99
105
  }
100
106
 
101
- return createElement(BlockPopover, {
107
+ return createElement(BlockPopover, _extends({
102
108
  clientId: capturingClientId || clientId,
103
109
  bottomClientId: lastClientId,
104
110
  className: classnames('block-editor-block-list__block-popover', {
@@ -106,7 +112,7 @@ function SelectedBlockPopover(_ref) {
106
112
  }),
107
113
  __unstablePopoverSlot: __unstablePopoverSlot,
108
114
  __unstableContentRef: __unstableContentRef
109
- }, shouldShowContextualToolbar && createElement(BlockContextualToolbar // If the toolbar is being shown because of being forced
115
+ }, popoverProps), shouldShowContextualToolbar && createElement(BlockContextualToolbar // If the toolbar is being shown because of being forced
110
116
  // it should focus the toolbar right after the mount.
111
117
  , {
112
118
  focusOnMount: isToolbarForced.current,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["find","classnames","useRef","useEffect","isUnmodifiedDefaultBlock","useDispatch","useSelect","useShortcut","useViewportMatch","BlockSelectionButton","BlockContextualToolbar","store","blockEditorStore","BlockPopover","selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAA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AGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-tools/selected-block-popover.js"],"names":["find","classnames","useRef","useEffect","isUnmodifiedDefaultBlock","useDispatch","useSelect","useShortcut","useViewportMatch","BlockSelectionButton","BlockContextualToolbar","store","blockEditorStore","BlockPopover","useBlockToolbarPopoverProps","selector","select","isNavigationMode","isMultiSelecting","hasMultiSelection","isTyping","getSettings","getLastMultiSelectedBlockClientId","hasFixedToolbar","lastClientId","SelectedBlockPopover","clientId","rootClientId","isEmptyDefaultBlock","capturingClientId","__unstablePopoverSlot","__unstableContentRef","isInsertionPointVisible","isBlockInsertionPointVisible","getBlockInsertionPoint","getBlockOrder","insertionPoint","order","index","isLargeViewport","isToolbarForced","stopTyping","showEmptyBlockSideInserter","shouldShowBreadcrumb","shouldShowContextualToolbar","canFocusHiddenToolbar","current","isDisabled","initialToolbarItemIndexRef","popoverProps","contentElement","wrapperSelector","getSelectedBlockClientId","getFirstMultiSelectedBlockClientId","getBlockRootClientId","getBlock","getBlockParents","__experimentalGetBlockListSettingsForBlocks","name","attributes","blockParentsClientIds","parentBlockListSettings","parentClientId","__experimentalCaptureToolbars","WrappedBlockPopover","selected"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,oBAAlC;AACA,SAASC,wBAAT,QAAyC,mBAAzC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,oBAAP,MAAiC,0BAAjC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,2BAAP,MAAwC,mCAAxC;;AAEA,SAASC,QAAT,CAAmBC,MAAnB,EAA4B;AAC3B,QAAM;AACLC,IAAAA,gBADK;AAELC,IAAAA,gBAFK;AAGLC,IAAAA,iBAHK;AAILC,IAAAA,QAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA;AANK,MAOFN,MAAM,CAAEJ,gBAAF,CAPV;AAQA,SAAO;AACNK,IAAAA,gBAAgB,EAAEA,gBAAgB,EAD5B;AAENC,IAAAA,gBAAgB,EAAEA,gBAAgB,EAF5B;AAGNE,IAAAA,QAAQ,EAAEA,QAAQ,EAHZ;AAING,IAAAA,eAAe,EAAEF,WAAW,GAAGE,eAJzB;AAKNC,IAAAA,YAAY,EAAEL,iBAAiB,KAC5BG,iCAAiC,EADL,GAE5B;AAPG,GAAP;AASA;;AAED,SAASG,oBAAT,OAOI;AAAA,MAP2B;A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GAGzC;AACH,QAAMkC,QAAQ,GAAG3D,SAAS,CAAE6C,eAAF,EAAmB,EAAnB,CAA1B;;AAEA,MAAK,CAAEc,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAM;AACLvC,IAAAA,QADK;AAELC,IAAAA,YAFK;AAGL+B,IAAAA,IAHK;AAIL9B,IAAAA,mBAJK;AAKLC,IAAAA;AALK,MAMFoC,QANJ;;AAQA,MAAK,CAAEP,IAAP,EAAc;AACb,WAAO,IAAP;AACA;;AAED,SACC,cAAC,oBAAD;AACC,IAAA,QAAQ,EAAGhC,QADZ;AAEC,IAAA,YAAY,EAAGC,YAFhB;AAGC,IAAA,mBAAmB,EAAGC,mBAHvB;AAIC,IAAA,iBAAiB,EAAGC,iBAJrB;AAKC,IAAA,qBAAqB,EAAGC,qBALzB;AAMC,IAAA,oBAAoB,EAAGC;AANxB,IADD;AAUA","sourcesContent":["/**\n * External dependencies\n */\nimport { find } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport BlockSelectionButton from './block-selection-button';\nimport BlockContextualToolbar from './block-contextual-toolbar';\nimport { store as blockEditorStore } from '../../store';\nimport BlockPopover from '../block-popover';\nimport useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';\n\nfunction selector( select ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\thasMultiSelection,\n\t\tisTyping,\n\t\tgetSettings,\n\t\tgetLastMultiSelectedBlockClientId,\n\t} = select( blockEditorStore );\n\treturn {\n\t\tisNavigationMode: isNavigationMode(),\n\t\tisMultiSelecting: isMultiSelecting(),\n\t\tisTyping: isTyping(),\n\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\tlastClientId: hasMultiSelection()\n\t\t\t? getLastMultiSelectedBlockClientId()\n\t\t\t: null,\n\t};\n}\n\nfunction SelectedBlockPopover( {\n\tclientId,\n\trootClientId,\n\tisEmptyDefaultBlock,\n\tcapturingClientId,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst {\n\t\tisNavigationMode,\n\t\tisMultiSelecting,\n\t\tisTyping,\n\t\thasFixedToolbar,\n\t\tlastClientId,\n\t} = useSelect( selector, [] );\n\tconst isInsertionPointVisible = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisBlockInsertionPointVisible,\n\t\t\t\tgetBlockInsertionPoint,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tif ( ! isBlockInsertionPointVisible() ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tconst insertionPoint = getBlockInsertionPoint();\n\t\t\tconst order = getBlockOrder( insertionPoint.rootClientId );\n\t\t\treturn order[ insertionPoint.index ] === clientId;\n\t\t},\n\t\t[ clientId ]\n\t);\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isToolbarForced = useRef( false );\n\tconst { stopTyping } = useDispatch( blockEditorStore );\n\n\tconst showEmptyBlockSideInserter =\n\t\t! isTyping && ! isNavigationMode && isEmptyDefaultBlock;\n\tconst shouldShowBreadcrumb = isNavigationMode;\n\tconst shouldShowContextualToolbar =\n\t\t! isNavigationMode &&\n\t\t! hasFixedToolbar &&\n\t\tisLargeViewport &&\n\t\t! isMultiSelecting &&\n\t\t! showEmptyBlockSideInserter &&\n\t\t! isTyping;\n\tconst canFocusHiddenToolbar =\n\t\t! isNavigationMode &&\n\t\t! shouldShowContextualToolbar &&\n\t\t! hasFixedToolbar &&\n\t\t! isEmptyDefaultBlock;\n\n\tuseShortcut(\n\t\t'core/block-editor/focus-toolbar',\n\t\t() => {\n\t\t\tisToolbarForced.current = true;\n\t\t\tstopTyping( true );\n\t\t},\n\t\t{\n\t\t\tisDisabled: ! canFocusHiddenToolbar,\n\t\t}\n\t);\n\n\tuseEffect( () => {\n\t\tisToolbarForced.current = false;\n\t} );\n\n\t// Stores the active toolbar item index so the block toolbar can return focus\n\t// to it when re-mounting.\n\tconst initialToolbarItemIndexRef = useRef();\n\n\tconst popoverProps = useBlockToolbarPopoverProps( {\n\t\tcontentElement: __unstableContentRef?.current,\n\t\tclientId,\n\t} );\n\n\tif ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<BlockPopover\n\t\t\tclientId={ capturingClientId || clientId }\n\t\t\tbottomClientId={ lastClientId }\n\t\t\tclassName={ classnames( 'block-editor-block-list__block-popover', {\n\t\t\t\t'is-insertion-point-visible': isInsertionPointVisible,\n\t\t\t} ) }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t\t{ ...popoverProps }\n\t\t>\n\t\t\t{ shouldShowContextualToolbar && (\n\t\t\t\t<BlockContextualToolbar\n\t\t\t\t\t// If the toolbar is being shown because of being forced\n\t\t\t\t\t// it should focus the toolbar right after the mount.\n\t\t\t\t\tfocusOnMount={ isToolbarForced.current }\n\t\t\t\t\t__experimentalInitialIndex={\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalOnIndexChange={ ( index ) => {\n\t\t\t\t\t\tinitialToolbarItemIndexRef.current = index;\n\t\t\t\t\t} }\n\t\t\t\t\t// Resets the index whenever the active block changes so\n\t\t\t\t\t// this is not persisted. See https://github.com/WordPress/gutenberg/pull/25760#issuecomment-717906169\n\t\t\t\t\tkey={ clientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ shouldShowBreadcrumb && (\n\t\t\t\t<BlockSelectionButton\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\trootClientId={ rootClientId }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</BlockPopover>\n\t);\n}\n\nfunction wrapperSelector( select ) {\n\tconst {\n\t\tgetSelectedBlockClientId,\n\t\tgetFirstMultiSelectedBlockClientId,\n\t\tgetBlockRootClientId,\n\t\tgetBlock,\n\t\tgetBlockParents,\n\t\t__experimentalGetBlockListSettingsForBlocks,\n\t} = select( blockEditorStore );\n\n\tconst clientId =\n\t\tgetSelectedBlockClientId() || getFirstMultiSelectedBlockClientId();\n\n\tif ( ! clientId ) {\n\t\treturn;\n\t}\n\n\tconst { name, attributes = {} } = getBlock( clientId ) || {};\n\tconst blockParentsClientIds = getBlockParents( clientId );\n\n\t// Get Block List Settings for all ancestors of the current Block clientId.\n\tconst parentBlockListSettings = __experimentalGetBlockListSettingsForBlocks(\n\t\tblockParentsClientIds\n\t);\n\n\t// Get the clientId of the topmost parent with the capture toolbars setting.\n\tconst capturingClientId = find(\n\t\tblockParentsClientIds,\n\t\t( parentClientId ) =>\n\t\t\tparentBlockListSettings[ parentClientId ]\n\t\t\t\t?.__experimentalCaptureToolbars\n\t);\n\n\treturn {\n\t\tclientId,\n\t\trootClientId: getBlockRootClientId( clientId ),\n\t\tname,\n\t\tisEmptyDefaultBlock:\n\t\t\tname && isUnmodifiedDefaultBlock( { name, attributes } ),\n\t\tcapturingClientId,\n\t};\n}\n\nexport default function WrappedBlockPopover( {\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n} ) {\n\tconst selected = useSelect( wrapperSelector, [] );\n\n\tif ( ! selected ) {\n\t\treturn null;\n\t}\n\n\tconst {\n\t\tclientId,\n\t\trootClientId,\n\t\tname,\n\t\tisEmptyDefaultBlock,\n\t\tcapturingClientId,\n\t} = selected;\n\n\tif ( ! name ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SelectedBlockPopover\n\t\t\tclientId={ clientId }\n\t\t\trootClientId={ rootClientId }\n\t\t\tisEmptyDefaultBlock={ isEmptyDefaultBlock }\n\t\t\tcapturingClientId={ capturingClientId }\n\t\t\t__unstablePopoverSlot={ __unstablePopoverSlot }\n\t\t\t__unstableContentRef={ __unstableContentRef }\n\t\t/>\n\t);\n}\n"]}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useRefEffect } from '@wordpress/compose';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useCallback, useLayoutEffect, useState } from '@wordpress/element';
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+
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
13
+ // down the toolbar will stay on screen by adopting a sticky position at the
14
+ // top of the viewport.
15
+
16
+ const DEFAULT_PROPS = {
17
+ __unstableForcePosition: true,
18
+ __unstableShift: true
19
+ }; // When there isn't enough height between the top of the block and the editor
20
+ // canvas, the `shift` prop is set to `false`, as it will cause the block to be
21
+ // obscured. The `flip` behavior is enabled (by setting `forcePosition` to
22
+ // `false`), which positions the toolbar below the block.
23
+
24
+ const RESTRICTED_HEIGHT_PROPS = {
25
+ __unstableForcePosition: false,
26
+ __unstableShift: false
27
+ };
28
+ /**
29
+ * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
30
+ *
31
+ * @param {Element} contentElement The DOM element that represents the editor content or canvas.
32
+ * @param {Element} selectedBlockElement The outer DOM element of the first selected block.
33
+ * @param {number} toolbarHeight The height of the toolbar in pixels.
34
+ *
35
+ * @return {Object} The popover props used to determine the position of the toolbar.
36
+ */
37
+
38
+ function getProps(contentElement, selectedBlockElement, toolbarHeight) {
39
+ if (!contentElement || !selectedBlockElement) {
40
+ return DEFAULT_PROPS;
41
+ }
42
+
43
+ const blockRect = selectedBlockElement.getBoundingClientRect();
44
+ const contentRect = contentElement.getBoundingClientRect();
45
+
46
+ if (blockRect.top - contentRect.top > toolbarHeight) {
47
+ return DEFAULT_PROPS;
48
+ }
49
+
50
+ return RESTRICTED_HEIGHT_PROPS;
51
+ }
52
+ /**
53
+ * Determines the desired popover positioning behavior, returning a set of appropriate props.
54
+ *
55
+ * @param {Object} elements
56
+ * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
57
+ * @param {string} elements.clientId The clientId of the first selected block.
58
+ *
59
+ * @return {Object} The popover props used to determine the position of the toolbar.
60
+ */
61
+
62
+
63
+ export default function useBlockToolbarPopoverProps(_ref) {
64
+ let {
65
+ contentElement,
66
+ clientId
67
+ } = _ref;
68
+ const selectedBlockElement = useBlockElement(clientId);
69
+ const [toolbarHeight, setToolbarHeight] = useState(0);
70
+ const [props, setProps] = useState(() => getProps(contentElement, selectedBlockElement, toolbarHeight));
71
+ const blockIndex = useSelect(select => select(blockEditorStore).getBlockIndex(clientId), [clientId]);
72
+ const popoverRef = useRefEffect(popoverNode => {
73
+ setToolbarHeight(popoverNode.offsetHeight);
74
+ }, []);
75
+ const updateProps = useCallback(() => setProps(getProps(contentElement, selectedBlockElement, toolbarHeight)), [contentElement, selectedBlockElement, toolbarHeight]); // Update props when the block is moved. This also ensures the props are
76
+ // correct on initial mount, and when the selected block or content element
77
+ // changes (since the callback ref will update).
78
+
79
+ useLayoutEffect(updateProps, [blockIndex, updateProps]); // Update props when the viewport is resized or the block is resized.
80
+
81
+ useLayoutEffect(() => {
82
+ var _contentElement$owner, _contentView$addEvent, _selectedBlockElement;
83
+
84
+ if (!contentElement || !selectedBlockElement) {
85
+ return;
86
+ } // Update the toolbar props on viewport resize.
87
+
88
+
89
+ const contentView = contentElement === null || contentElement === void 0 ? void 0 : (_contentElement$owner = contentElement.ownerDocument) === null || _contentElement$owner === void 0 ? void 0 : _contentElement$owner.defaultView;
90
+ contentView === null || contentView === void 0 ? void 0 : (_contentView$addEvent = contentView.addEventHandler) === null || _contentView$addEvent === void 0 ? void 0 : _contentView$addEvent.call(contentView, 'resize', updateProps); // Update the toolbar props on block resize.
91
+
92
+ let resizeObserver;
93
+ const blockView = selectedBlockElement === null || selectedBlockElement === void 0 ? void 0 : (_selectedBlockElement = selectedBlockElement.ownerDocument) === null || _selectedBlockElement === void 0 ? void 0 : _selectedBlockElement.defaultView;
94
+
95
+ if (blockView.ResizeObserver) {
96
+ resizeObserver = new blockView.ResizeObserver(updateProps);
97
+ resizeObserver.observe(selectedBlockElement);
98
+ }
99
+
100
+ return () => {
101
+ var _contentView$removeEv;
102
+
103
+ contentView === null || contentView === void 0 ? void 0 : (_contentView$removeEv = contentView.removeEventHandler) === null || _contentView$removeEv === void 0 ? void 0 : _contentView$removeEv.call(contentView, 'resize', updateProps);
104
+
105
+ if (resizeObserver) {
106
+ resizeObserver.disconnect();
107
+ }
108
+ };
109
+ }, [updateProps, contentElement, selectedBlockElement]);
110
+ return { ...props,
111
+ ref: popoverRef
112
+ };
113
+ }
114
+ //# sourceMappingURL=use-block-toolbar-popover-props.js.map
@@ -0,0 +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","__unstableForcePosition","__unstableShift","RESTRICTED_HEIGHT_PROPS","getProps","contentElement","selectedBlockElement","toolbarHeight","blockRect","getBoundingClientRect","contentRect","top","useBlockToolbarPopoverProps","clientId","setToolbarHeight","props","setProps","blockIndex","select","getBlockIndex","popoverRef","popoverNode","offsetHeight","updateProps","contentView","ownerDocument","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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wB,QAAxB,EAAkCD,WAAlC,CAAX;;AAEA,UAAKK,cAAL,EAAsB;AACrBA,QAAAA,cAAc,CAACK,UAAf;AACA;AACD,KAND;AAOA,GAxBc,EAwBZ,CAAEV,WAAF,EAAelB,cAAf,EAA+BC,oBAA/B,CAxBY,CAAf;AA0BA,SAAO,EACN,GAAGS,KADG;AAENmB,IAAAA,GAAG,EAAEd;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 = { __unstableForcePosition: true, __unstableShift: true };\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 (by setting `forcePosition` to\n// `false`), which positions the toolbar below the block.\nconst RESTRICTED_HEIGHT_PROPS = {\n\t__unstableForcePosition: false,\n\t__unstableShift: 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\tif ( blockRect.top - contentRect.top > toolbarHeight ) {\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"]}
@@ -59,6 +59,10 @@ export default {
59
59
  }));
60
60
  }
61
61
 
62
+ const {
63
+ contentSize,
64
+ wideSize
65
+ } = layout;
62
66
  const alignments = [{
63
67
  name: 'left'
64
68
  }, {
@@ -66,6 +70,20 @@ export default {
66
70
  }, {
67
71
  name: 'right'
68
72
  }];
73
+
74
+ if (contentSize) {
75
+ alignments.unshift({
76
+ name: 'full'
77
+ });
78
+ }
79
+
80
+ if (wideSize) {
81
+ alignments.unshift({
82
+ name: 'wide',
83
+ info: alignmentInfo.wide
84
+ });
85
+ }
86
+
69
87
  alignments.unshift({
70
88
  name: 'none',
71
89
  info: alignmentInfo.none
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["__","getBlockGapCSS","getAlignmentsInfo","getGapBoxControlValueFromStyle","shouldSkipSerialization","name","label","inspectorControls","DefaultLayoutInspectorControls","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","getOrientation","getAlignments","layout","alignmentInfo","alignments","undefined","includes","unshift","map","alignment","info","none"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,SAASC,cAAT,EAAyBC,iBAAzB,QAAkD,SAAlD;AACA,SAASC,8BAAT,QAA+C,cAA/C;AACA,SAASC,uBAAT,QAAwC,gBAAxC;AAEA,eAAe;AACdC,EAAAA,IAAI,EAAE,SADQ;AAEdC,EAAAA,KAAK,EAAEN,EAAE,CAAE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EAA8C;AAC7CJ,QAAAA,MAAM,CAACE,UAAP,CAAkBG,OAAlB,CAA2B,MAA3B;AACA;;AACD,aAAOL,MAAM,CAACE,UAAP,CAAkBI,GAAlB,CAAyBC,SAAF,KAAmB;AAChD3B,QAAAA,IAAI,EAAE2B,SAD0C;AAEhDC,QAAAA,IAAI,EAAEP,aAAa,CAAEM,SAAF;AAF6B,OAAnB,CAAvB,CAAP;AAIA;;AAED,UAAML,UAAU,GAAG,CAClB;AAAEtB,MAAAA,IAAI,EAAE;AAAR,KADkB,EAElB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAFkB,EAGlB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAHkB,CAAnB;AAMAsB,IAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,MAAAA,IAAI,EAAE,MAAR;AAAgB4B,MAAAA,IAAI,EAAEP,aAAa,CAACQ;AAApC,KAApB;AAEA,WAAOP,UAAP;AACA;;AAhEa,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls() {\n\t\treturn null;\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output = '';\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/layouts/flow.js"],"names":["__","getBlockGapCSS","getAlignmentsInfo","getGapBoxControlValueFromStyle","shouldSkipSerialization","name","label","inspectorControls","DefaultLayoutInspectorControls","toolBarControls","DefaultLayoutToolbarControls","getLayoutStyle","selector","style","blockName","hasBlockGapSupport","layoutDefinitions","blockGapStyleValue","spacing","blockGap","blockGapValue","top","output","getOrientation","getAlignments","layout","alignmentInfo","alignments","undefined","includes","unshift","map","alignment","info","contentSize","wideSize","wide","none"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AAEA,SAASC,cAAT,EAAyBC,iBAAzB,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GxB,iBAAiB,CAAEuB,MAAF,CAAvC;;AACA,QAAKA,MAAM,CAACE,UAAP,KAAsBC,SAA3B,EAAuC;AACtC,UAAK,CAAEH,MAAM,CAACE,UAAP,CAAkBE,QAAlB,CAA4B,MAA5B,CAAP,EAA8C;AAC7CJ,QAAAA,MAAM,CAACE,UAAP,CAAkBG,OAAlB,CAA2B,MAA3B;AACA;;AACD,aAAOL,MAAM,CAACE,UAAP,CAAkBI,GAAlB,CAAyBC,SAAF,KAAmB;AAChD3B,QAAAA,IAAI,EAAE2B,SAD0C;AAEhDC,QAAAA,IAAI,EAAEP,aAAa,CAAEM,SAAF;AAF6B,OAAnB,CAAvB,CAAP;AAIA;;AACD,UAAM;AAAEE,MAAAA,WAAF;AAAeC,MAAAA;AAAf,QAA4BV,MAAlC;AAEA,UAAME,UAAU,GAAG,CAClB;AAAEtB,MAAAA,IAAI,EAAE;AAAR,KADkB,EAElB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAFkB,EAGlB;AAAEA,MAAAA,IAAI,EAAE;AAAR,KAHkB,CAAnB;;AAMA,QAAK6B,WAAL,EAAmB;AAClBP,MAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,QAAAA,IAAI,EAAE;AAAR,OAApB;AACA;;AAED,QAAK8B,QAAL,EAAgB;AACfR,MAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,QAAAA,IAAI,EAAE,MAAR;AAAgB4B,QAAAA,IAAI,EAAEP,aAAa,CAACU;AAApC,OAApB;AACA;;AAEDT,IAAAA,UAAU,CAACG,OAAX,CAAoB;AAAEzB,MAAAA,IAAI,EAAE,MAAR;AAAgB4B,MAAAA,IAAI,EAAEP,aAAa,CAACW;AAApC,KAApB;AAEA,WAAOV,UAAP;AACA;;AAzEa,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\n\nimport { getBlockGapCSS, getAlignmentsInfo } from './utils';\nimport { getGapBoxControlValueFromStyle } from '../hooks/gap';\nimport { shouldSkipSerialization } from '../hooks/utils';\n\nexport default {\n\tname: 'default',\n\tlabel: __( 'Flow' ),\n\tinspectorControls: function DefaultLayoutInspectorControls() {\n\t\treturn null;\n\t},\n\ttoolBarControls: function DefaultLayoutToolbarControls() {\n\t\treturn null;\n\t},\n\tgetLayoutStyle: function getLayoutStyle( {\n\t\tselector,\n\t\tstyle,\n\t\tblockName,\n\t\thasBlockGapSupport,\n\t\tlayoutDefinitions,\n\t} ) {\n\t\tconst blockGapStyleValue = getGapBoxControlValueFromStyle(\n\t\t\tstyle?.spacing?.blockGap\n\t\t);\n\t\t// If a block's block.json skips serialization for spacing or\n\t\t// spacing.blockGap, don't apply the user-defined value to the styles.\n\t\tconst blockGapValue =\n\t\t\tblockGapStyleValue?.top &&\n\t\t\t! shouldSkipSerialization( blockName, 'spacing', 'blockGap' )\n\t\t\t\t? blockGapStyleValue?.top\n\t\t\t\t: '';\n\n\t\tlet output = '';\n\n\t\t// Output blockGap styles based on rules contained in layout definitions in theme.json.\n\t\tif ( hasBlockGapSupport && blockGapValue ) {\n\t\t\toutput += getBlockGapCSS(\n\t\t\t\tselector,\n\t\t\t\tlayoutDefinitions,\n\t\t\t\t'default',\n\t\t\t\tblockGapValue\n\t\t\t);\n\t\t}\n\t\treturn output;\n\t},\n\tgetOrientation() {\n\t\treturn 'vertical';\n\t},\n\tgetAlignments( layout ) {\n\t\tconst alignmentInfo = getAlignmentsInfo( layout );\n\t\tif ( layout.alignments !== undefined ) {\n\t\t\tif ( ! layout.alignments.includes( 'none' ) ) {\n\t\t\t\tlayout.alignments.unshift( 'none' );\n\t\t\t}\n\t\t\treturn layout.alignments.map( ( alignment ) => ( {\n\t\t\t\tname: alignment,\n\t\t\t\tinfo: alignmentInfo[ alignment ],\n\t\t\t} ) );\n\t\t}\n\t\tconst { contentSize, wideSize } = layout;\n\n\t\tconst alignments = [\n\t\t\t{ name: 'left' },\n\t\t\t{ name: 'center' },\n\t\t\t{ name: 'right' },\n\t\t];\n\n\t\tif ( contentSize ) {\n\t\t\talignments.unshift( { name: 'full' } );\n\t\t}\n\n\t\tif ( wideSize ) {\n\t\t\talignments.unshift( { name: 'wide', info: alignmentInfo.wide } );\n\t\t}\n\n\t\talignments.unshift( { name: 'none', info: alignmentInfo.none } );\n\n\t\treturn alignments;\n\t},\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "9.7.1-next.d6164808d3.0",
3
+ "version": "9.8.0",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -33,32 +33,32 @@
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.16.0",
35
35
  "@react-spring/web": "^9.4.5",
36
- "@wordpress/a11y": "^3.15.1-next.d6164808d3.0",
37
- "@wordpress/api-fetch": "^6.12.1-next.d6164808d3.0",
38
- "@wordpress/blob": "^3.15.1-next.d6164808d3.0",
39
- "@wordpress/blocks": "^11.14.1-next.d6164808d3.0",
40
- "@wordpress/components": "^20.0.1-next.d6164808d3.0",
41
- "@wordpress/compose": "^5.13.1-next.d6164808d3.0",
42
- "@wordpress/data": "^7.0.1-next.d6164808d3.0",
43
- "@wordpress/date": "^4.15.1-next.d6164808d3.0",
44
- "@wordpress/deprecated": "^3.15.1-next.d6164808d3.0",
45
- "@wordpress/dom": "^3.15.1-next.d6164808d3.0",
46
- "@wordpress/element": "^4.13.1-next.d6164808d3.0",
47
- "@wordpress/hooks": "^3.15.1-next.d6164808d3.0",
48
- "@wordpress/html-entities": "^3.15.1-next.d6164808d3.0",
49
- "@wordpress/i18n": "^4.15.1-next.d6164808d3.0",
50
- "@wordpress/icons": "^9.6.1-next.d6164808d3.0",
51
- "@wordpress/is-shallow-equal": "^4.15.1-next.d6164808d3.0",
52
- "@wordpress/keyboard-shortcuts": "^3.13.1-next.d6164808d3.0",
53
- "@wordpress/keycodes": "^3.15.1-next.d6164808d3.0",
54
- "@wordpress/notices": "^3.15.1-next.d6164808d3.0",
55
- "@wordpress/rich-text": "^5.13.1-next.d6164808d3.0",
56
- "@wordpress/shortcode": "^3.15.1-next.d6164808d3.0",
57
- "@wordpress/style-engine": "^0.14.1-next.d6164808d3.0",
58
- "@wordpress/token-list": "^2.15.1-next.d6164808d3.0",
59
- "@wordpress/url": "^3.16.1-next.d6164808d3.0",
60
- "@wordpress/warning": "^2.15.1-next.d6164808d3.0",
61
- "@wordpress/wordcount": "^3.15.1-next.d6164808d3.0",
36
+ "@wordpress/a11y": "^3.16.0",
37
+ "@wordpress/api-fetch": "^6.13.0",
38
+ "@wordpress/blob": "^3.16.0",
39
+ "@wordpress/blocks": "^11.15.0",
40
+ "@wordpress/components": "^20.0.0",
41
+ "@wordpress/compose": "^5.14.0",
42
+ "@wordpress/data": "^7.0.0",
43
+ "@wordpress/date": "^4.16.0",
44
+ "@wordpress/deprecated": "^3.16.0",
45
+ "@wordpress/dom": "^3.16.0",
46
+ "@wordpress/element": "^4.14.0",
47
+ "@wordpress/hooks": "^3.16.0",
48
+ "@wordpress/html-entities": "^3.16.0",
49
+ "@wordpress/i18n": "^4.16.0",
50
+ "@wordpress/icons": "^9.7.0",
51
+ "@wordpress/is-shallow-equal": "^4.16.0",
52
+ "@wordpress/keyboard-shortcuts": "^3.14.0",
53
+ "@wordpress/keycodes": "^3.16.0",
54
+ "@wordpress/notices": "^3.16.0",
55
+ "@wordpress/rich-text": "^5.14.0",
56
+ "@wordpress/shortcode": "^3.16.0",
57
+ "@wordpress/style-engine": "^0.15.0",
58
+ "@wordpress/token-list": "^2.16.0",
59
+ "@wordpress/url": "^3.17.0",
60
+ "@wordpress/warning": "^2.16.0",
61
+ "@wordpress/wordcount": "^3.16.0",
62
62
  "change-case": "^4.1.2",
63
63
  "classnames": "^2.3.1",
64
64
  "colord": "^2.7.0",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "ba8a396d2f418e53a6c4c50575582f3f3eb11ff7"
82
+ "gitHead": "171b87c7465b93e685e081c5f57f153507363c95"
83
83
  }
@@ -6,8 +6,9 @@ import classnames from 'classnames';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
+ import { useMergeRefs } from '@wordpress/compose';
9
10
  import { Popover } from '@wordpress/components';
10
- import { useMemo } from '@wordpress/element';
11
+ import { forwardRef, useMemo } from '@wordpress/element';
11
12
 
12
13
  /**
13
14
  * Internal dependencies
@@ -15,19 +16,25 @@ import { useMemo } from '@wordpress/element';
15
16
  import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
16
17
  import usePopoverScroll from './use-popover-scroll';
17
18
 
18
- export default function BlockPopover( {
19
- clientId,
20
- bottomClientId,
21
- children,
22
- __unstableRefreshSize,
23
- __unstableCoverTarget = false,
24
- __unstablePopoverSlot,
25
- __unstableContentRef,
26
- ...props
27
- } ) {
19
+ function BlockPopover(
20
+ {
21
+ clientId,
22
+ bottomClientId,
23
+ children,
24
+ __unstableRefreshSize,
25
+ __unstableCoverTarget = false,
26
+ __unstablePopoverSlot,
27
+ __unstableContentRef,
28
+ ...props
29
+ },
30
+ ref
31
+ ) {
28
32
  const selectedElement = useBlockElement( clientId );
29
33
  const lastSelectedElement = useBlockElement( bottomClientId ?? clientId );
30
- const popoverScrollRef = usePopoverScroll( __unstableContentRef );
34
+ const mergedRefs = useMergeRefs( [
35
+ ref,
36
+ usePopoverScroll( __unstableContentRef ),
37
+ ] );
31
38
  const style = useMemo( () => {
32
39
  if ( ! selectedElement || lastSelectedElement !== selectedElement ) {
33
40
  return {};
@@ -51,7 +58,7 @@ export default function BlockPopover( {
51
58
 
52
59
  return (
53
60
  <Popover
54
- ref={ popoverScrollRef }
61
+ ref={ mergedRefs }
55
62
  animate={ false }
56
63
  position="top right left"
57
64
  focusOnMount={ false }
@@ -74,3 +81,5 @@ export default function BlockPopover( {
74
81
  </Popover>
75
82
  );
76
83
  }
84
+
85
+ export default forwardRef( BlockPopover );
@@ -20,6 +20,7 @@ import BlockSelectionButton from './block-selection-button';
20
20
  import BlockContextualToolbar from './block-contextual-toolbar';
21
21
  import { store as blockEditorStore } from '../../store';
22
22
  import BlockPopover from '../block-popover';
23
+ import useBlockToolbarPopoverProps from './use-block-toolbar-popover-props';
23
24
 
24
25
  function selector( select ) {
25
26
  const {
@@ -113,6 +114,11 @@ function SelectedBlockPopover( {
113
114
  // to it when re-mounting.
114
115
  const initialToolbarItemIndexRef = useRef();
115
116
 
117
+ const popoverProps = useBlockToolbarPopoverProps( {
118
+ contentElement: __unstableContentRef?.current,
119
+ clientId,
120
+ } );
121
+
116
122
  if ( ! shouldShowBreadcrumb && ! shouldShowContextualToolbar ) {
117
123
  return null;
118
124
  }
@@ -126,6 +132,7 @@ function SelectedBlockPopover( {
126
132
  } ) }
127
133
  __unstablePopoverSlot={ __unstablePopoverSlot }
128
134
  __unstableContentRef={ __unstableContentRef }
135
+ { ...popoverProps }
129
136
  >
130
137
  { shouldShowContextualToolbar && (
131
138
  <BlockContextualToolbar
@@ -0,0 +1,123 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useRefEffect } from '@wordpress/compose';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useCallback, useLayoutEffect, useState } from '@wordpress/element';
7
+
8
+ /**
9
+ * Internal dependencies
10
+ */
11
+ import { store as blockEditorStore } from '../../store';
12
+ import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
13
+
14
+ // By default the toolbar sets the `shift` prop. If the user scrolls the page
15
+ // down the toolbar will stay on screen by adopting a sticky position at the
16
+ // top of the viewport.
17
+ const DEFAULT_PROPS = { __unstableForcePosition: true, __unstableShift: true };
18
+
19
+ // When there isn't enough height between the top of the block and the editor
20
+ // canvas, the `shift` prop is set to `false`, as it will cause the block to be
21
+ // obscured. The `flip` behavior is enabled (by setting `forcePosition` to
22
+ // `false`), which positions the toolbar below the block.
23
+ const RESTRICTED_HEIGHT_PROPS = {
24
+ __unstableForcePosition: false,
25
+ __unstableShift: false,
26
+ };
27
+
28
+ /**
29
+ * Get the popover props for the block toolbar, determined by the space at the top of the canvas and the toolbar height.
30
+ *
31
+ * @param {Element} contentElement The DOM element that represents the editor content or canvas.
32
+ * @param {Element} selectedBlockElement The outer DOM element of the first selected block.
33
+ * @param {number} toolbarHeight The height of the toolbar in pixels.
34
+ *
35
+ * @return {Object} The popover props used to determine the position of the toolbar.
36
+ */
37
+ function getProps( contentElement, selectedBlockElement, toolbarHeight ) {
38
+ if ( ! contentElement || ! selectedBlockElement ) {
39
+ return DEFAULT_PROPS;
40
+ }
41
+
42
+ const blockRect = selectedBlockElement.getBoundingClientRect();
43
+ const contentRect = contentElement.getBoundingClientRect();
44
+
45
+ if ( blockRect.top - contentRect.top > toolbarHeight ) {
46
+ return DEFAULT_PROPS;
47
+ }
48
+
49
+ return RESTRICTED_HEIGHT_PROPS;
50
+ }
51
+
52
+ /**
53
+ * Determines the desired popover positioning behavior, returning a set of appropriate props.
54
+ *
55
+ * @param {Object} elements
56
+ * @param {Element} elements.contentElement The DOM element that represents the editor content or canvas.
57
+ * @param {string} elements.clientId The clientId of the first selected block.
58
+ *
59
+ * @return {Object} The popover props used to determine the position of the toolbar.
60
+ */
61
+ export default function useBlockToolbarPopoverProps( {
62
+ contentElement,
63
+ clientId,
64
+ } ) {
65
+ const selectedBlockElement = useBlockElement( clientId );
66
+ const [ toolbarHeight, setToolbarHeight ] = useState( 0 );
67
+ const [ props, setProps ] = useState( () =>
68
+ getProps( contentElement, selectedBlockElement, toolbarHeight )
69
+ );
70
+ const blockIndex = useSelect(
71
+ ( select ) => select( blockEditorStore ).getBlockIndex( clientId ),
72
+ [ clientId ]
73
+ );
74
+
75
+ const popoverRef = useRefEffect( ( popoverNode ) => {
76
+ setToolbarHeight( popoverNode.offsetHeight );
77
+ }, [] );
78
+
79
+ const updateProps = useCallback(
80
+ () =>
81
+ setProps(
82
+ getProps( contentElement, selectedBlockElement, toolbarHeight )
83
+ ),
84
+ [ contentElement, selectedBlockElement, toolbarHeight ]
85
+ );
86
+
87
+ // Update props when the block is moved. This also ensures the props are
88
+ // correct on initial mount, and when the selected block or content element
89
+ // changes (since the callback ref will update).
90
+ useLayoutEffect( updateProps, [ blockIndex, updateProps ] );
91
+
92
+ // Update props when the viewport is resized or the block is resized.
93
+ useLayoutEffect( () => {
94
+ if ( ! contentElement || ! selectedBlockElement ) {
95
+ return;
96
+ }
97
+
98
+ // Update the toolbar props on viewport resize.
99
+ const contentView = contentElement?.ownerDocument?.defaultView;
100
+ contentView?.addEventHandler?.( 'resize', updateProps );
101
+
102
+ // Update the toolbar props on block resize.
103
+ let resizeObserver;
104
+ const blockView = selectedBlockElement?.ownerDocument?.defaultView;
105
+ if ( blockView.ResizeObserver ) {
106
+ resizeObserver = new blockView.ResizeObserver( updateProps );
107
+ resizeObserver.observe( selectedBlockElement );
108
+ }
109
+
110
+ return () => {
111
+ contentView?.removeEventHandler?.( 'resize', updateProps );
112
+
113
+ if ( resizeObserver ) {
114
+ resizeObserver.disconnect();
115
+ }
116
+ };
117
+ }, [ updateProps, contentElement, selectedBlockElement ] );
118
+
119
+ return {
120
+ ...props,
121
+ ref: popoverRef,
122
+ };
123
+ }
@@ -65,6 +65,7 @@ export default {
65
65
  info: alignmentInfo[ alignment ],
66
66
  } ) );
67
67
  }
68
+ const { contentSize, wideSize } = layout;
68
69
 
69
70
  const alignments = [
70
71
  { name: 'left' },
@@ -72,6 +73,14 @@ export default {
72
73
  { name: 'right' },
73
74
  ];
74
75
 
76
+ if ( contentSize ) {
77
+ alignments.unshift( { name: 'full' } );
78
+ }
79
+
80
+ if ( wideSize ) {
81
+ alignments.unshift( { name: 'wide', info: alignmentInfo.wide } );
82
+ }
83
+
75
84
  alignments.unshift( { name: 'none', info: alignmentInfo.none } );
76
85
 
77
86
  return alignments;