@wordpress/block-editor 10.0.2 → 10.0.3

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.
@@ -36,6 +36,7 @@ var _usePopoverScroll = _interopRequireDefault(require("./use-popover-scroll"));
36
36
  /**
37
37
  * Internal dependencies
38
38
  */
39
+ const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
39
40
  const InsertionPointOpenRef = (0, _element.createContext)();
40
41
  exports.InsertionPointOpenRef = InsertionPointOpenRef;
41
42
 
@@ -49,7 +50,8 @@ function BlockPopoverInbetween(_ref) {
49
50
  ...props
50
51
  } = _ref;
51
52
  // This is a temporary hack to get the inbetween inserter to recompute properly.
52
- const [positionRecompute, forceRecompute] = (0, _element.useReducer)(s => s + 1, 0);
53
+ const [popoverRecomputeCounter, forcePopoverRecompute] = (0, _element.useReducer)( // Module is there to make sure that the counter doesn't overflow.
54
+ s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0);
53
55
  const {
54
56
  orientation,
55
57
  rootClientId,
@@ -75,7 +77,10 @@ function BlockPopoverInbetween(_ref) {
75
77
  const nextElement = (0, _useBlockRefs.__unstableUseBlockElement)(nextClientId);
76
78
  const isVertical = orientation === 'vertical';
77
79
  const style = (0, _element.useMemo)(() => {
78
- if (!previousElement && !nextElement || !isVisible) {
80
+ if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
81
+ // This check is only there to satisfy the correctness of the
82
+ // exhaustive-deps rule for the `useMemo` hook.
83
+ popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
79
84
  return {};
80
85
  }
81
86
 
@@ -99,9 +104,12 @@ function BlockPopoverInbetween(_ref) {
99
104
  width,
100
105
  height: previousRect ? previousRect.height : nextRect.height
101
106
  };
102
- }, [previousElement, nextElement, isVertical, positionRecompute, isVisible]);
107
+ }, [previousElement, nextElement, isVertical, popoverRecomputeCounter, isVisible]);
103
108
  const popoverAnchor = (0, _element.useMemo)(() => {
104
- if (!previousElement && !nextElement || !isVisible) {
109
+ if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
110
+ // This check is only there to satisfy the correctness of the
111
+ // exhaustive-deps rule for the `useMemo` hook.
112
+ popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
105
113
  return undefined;
106
114
  }
107
115
 
@@ -144,15 +152,22 @@ function BlockPopoverInbetween(_ref) {
144
152
  }
145
153
 
146
154
  };
147
- }, [previousElement, nextElement, positionRecompute, isVertical, isVisible]);
155
+ }, [previousElement, nextElement, popoverRecomputeCounter, isVertical, isVisible]);
148
156
  const popoverScrollRef = (0, _usePopoverScroll.default)(__unstableContentRef); // This is only needed for a smooth transition when moving blocks.
157
+ // When blocks are moved up/down, their position can be set by
158
+ // updating the `transform` property manually (i.e. without using CSS
159
+ // transitions or animations). The animation, which can also scroll the block
160
+ // editor, can sometimes cause the position of the Popover to get out of sync.
161
+ // A MutationObserver is therefore used to make sure that changes to the
162
+ // selectedElement's attribute (i.e. `transform`) can be tracked and used to
163
+ // trigger the Popover to rerender.
149
164
 
150
165
  (0, _element.useLayoutEffect)(() => {
151
166
  if (!previousElement) {
152
167
  return;
153
168
  }
154
169
 
155
- const observer = new window.MutationObserver(forceRecompute);
170
+ const observer = new window.MutationObserver(forcePopoverRecompute);
156
171
  observer.observe(previousElement, {
157
172
  attributes: true
158
173
  });
@@ -165,7 +180,7 @@ function BlockPopoverInbetween(_ref) {
165
180
  return;
166
181
  }
167
182
 
168
- const observer = new window.MutationObserver(forceRecompute);
183
+ const observer = new window.MutationObserver(forcePopoverRecompute);
169
184
  observer.observe(nextElement, {
170
185
  attributes: true
171
186
  });
@@ -178,9 +193,9 @@ function BlockPopoverInbetween(_ref) {
178
193
  return;
179
194
  }
180
195
 
181
- previousElement.ownerDocument.defaultView.addEventListener('resize', forceRecompute);
196
+ previousElement.ownerDocument.defaultView.addEventListener('resize', forcePopoverRecompute);
182
197
  return () => {
183
- previousElement.ownerDocument.defaultView.removeEventListener('resize', forceRecompute);
198
+ previousElement.ownerDocument.defaultView.removeEventListener('resize', forcePopoverRecompute);
184
199
  };
185
200
  }, [previousElement]); // If there's either a previous or a next element, show the inbetween popover.
186
201
  // Note that drag and drop uses the inbetween popover to show the drop indicator
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","positionRecompute","forceRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAKO,MAAMA,qBAAqB,GAAG,6BAA9B;;;AAEP,SAASC,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH;AACA,QAAM,CAAEC,iBAAF,EAAqBC,cAArB,IAAwC,yBAC3CC,CAAF,IAASA,CAAC,GAAG,CADgC,EAE7C,CAF6C,CAA9C;AAKA,QAAM;AAAEC,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AAA6BC,IAAAA;AAA7B,MAA2C,qBAC9CC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJ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AACtB,QAAK,CAAED,eAAP,EAAyB;AACxB;AACA;;AACDA,IAAAA,eAAe,CAACe,aAAhB,CAA8BS,WAA9B,CAA0CC,gBAA1C,CACC,QADD,EAECpC,cAFD;AAIA,WAAO,MAAM;AACZW,MAAAA,eAAe,CAACe,aAAhB,CAA8BS,WAA9B,CAA0CE,mBAA1C,CACC,QADD,EAECrC,cAFD;AAIA,KALD;AAMA,GAdD,EAcG,CAAEW,eAAF,CAdH,EAjKG,CAiLH;AACA;AACA;;AACA,MAAO,CAAEA,eAAF,IAAqB,CAAEC,WAAzB,IAA0C,CAAER,SAAjD,EAA6D;AAC5D,WAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGyB,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,MAAM,EAAGL,aAHV;AAIC,IAAA,YAAY,EAAG,KAJhB,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAG5B,qBAAqB,IAAI,IAP/C,CAQC;AACA;AATD;AAUC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEX,uCAFW,EAGXA,KAAK,CAACwC,SAHK,CAZb;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGnB,QAJH,CArBD,CADD;AA8BA;AACA;;eAEcH,qB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\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';\nimport usePopoverScroll from './use-popover-scroll';\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ positionRecompute, forceRecompute ] = useReducer(\n\t\t( s ) => s + 1,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpositionRecompute,\n\t\tisVisible,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpositionRecompute,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forceRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forceRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforceRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforceRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\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// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/inbetween.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","InsertionPointOpenRef","BlockPopoverInbetween","previousClientId","nextClientId","children","__unstablePopoverSlot","__unstableContentRef","props","popoverRecomputeCounter","forcePopoverRecompute","s","orientation","rootClientId","isVisible","select","getBlockListSettings","getBlockRootClientId","isBlockVisible","blockEditorStore","_rootClientId","previousElement","nextElement","isVertical","style","previousRect","getBoundingClientRect","nextRect","width","height","top","bottom","left","right","popoverAnchor","undefined","ownerDocument","window","DOMRect","popoverScrollRef","observer","MutationObserver","observe","attributes","disconnect","defaultView","addEventListener","removeEventListener","className"],"mappings":";;;;;;;;;AASA;;;;AANA;;AAKA;;AAOA;;AACA;;AAKA;;AACA;;AACA;;AAvBA;AACA;AACA;;AAGA;AACA;AACA;;AAWA;AACA;AACA;AAKA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;AAEO,MAAMC,qBAAqB,GAAG,6BAA9B;;;AAEP,SAASC,qBAAT,OAOI;AAAA,MAP4B;AAC/BC,IAAAA,gBAD+B;AAE/BC,IAAAA,YAF+B;AAG/BC,IAAAA,QAH+B;AAI/BC,IAAAA,qBAJ+B;AAK/BC,IAAAA,oBAL+B;AAM/B,OAAGC;AAN4B,GAO5B;AACH;AACA,QAAM,CAAEC,uBAAF,EAA2BC,qBAA3B,IAAqD,0BAC1D;AACEC,EAAAA,CAAF,IAAS,CAAEA,CAAC,GAAG,CAAN,IAAYb,6BAFqC,EAG1D,CAH0D,CAA3D;AAMA,QAAM;AAAEc,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AAA6BC,IAAAA;AAA7B,MAA2C,qBAC9CC,MAAF,IAAc;AAAA;;AACb,UAAM;AACLC,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,YAAF,CAJV;;AAMA,UAAMC,aAAa,GAAGH,oBAAoB,CACzCd,gBADyC,aACzCA,gBADyC,cACzCA,gBADyC,GACrBC,YADqB,CAA1C;;AAGA,WAAO;AACNQ,MAAAA,WAAW,EACV,0BAAAI,oBAAoB,CAAEI,aAAF,CAApB,gFAAuCR,WAAvC,KACA,UAHK;AAINC,MAAAA,YAAY,EAAEO,aAJR;AAKNN,MAAAA,SAAS,EACRI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MAAM;AACZW,MAAAA,eAAe,CAACe,aAAhB,CAA8BS,WAA9B,CAA0CE,mBAA1C,CACC,QADD,EAECrC,qBAFD;AAIA,KALD;AAMA,GAdD,EAcG,CAAEW,eAAF,CAdH,EAvLG,CAuMH;AACA;AACA;;AACA,MAAO,CAAEA,eAAF,IAAqB,CAAEC,WAAzB,IAA0C,CAAER,SAAjD,EAA6D;AAC5D,WAAO,IAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,SACC,4BAAC,mBAAD;AACC,IAAA,GAAG,EAAGyB,gBADP;AAEC,IAAA,OAAO,EAAG,KAFX;AAGC,IAAA,MAAM,EAAGL,aAHV;AAIC,IAAA,YAAY,EAAG,KAJhB,CAKC;AACA;AAND;AAOC,IAAA,kBAAkB,EAAG5B,qBAAqB,IAAI,IAP/C,CAQC;AACA;AATD;AAUC,IAAA,GAAG,EAAGF,YAAY,GAAG,IAAf,GAAsBS;AAV7B,KAWML,KAXN;AAYC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEX,uCAFW,EAGXA,KAAK,CAACwC,SAHK,CAZb;AAiBC,IAAA,MAAM,EAAG,KAjBV;AAkBC,IAAA,IAAI,EAAG,KAlBR;AAmBC,IAAA,SAAS,EAAC;AAnBX,MAqBC;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,KAAK,EAAGxB;AAFT,KAIGnB,QAJH,CArBD,CADD;AA8BA;AACA;;eAEcH,qB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tuseMemo,\n\tcreateContext,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\nimport { Popover } from '@wordpress/components';\nimport { isRTL } from '@wordpress/i18n';\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';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nexport const InsertionPointOpenRef = createContext();\n\nfunction BlockPopoverInbetween( {\n\tpreviousClientId,\n\tnextClientId,\n\tchildren,\n\t__unstablePopoverSlot,\n\t__unstableContentRef,\n\t...props\n} ) {\n\t// This is a temporary hack to get the inbetween inserter to recompute properly.\n\tconst [ popoverRecomputeCounter, forcePopoverRecompute ] = useReducer(\n\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t0\n\t);\n\n\tconst { orientation, rootClientId, isVisible } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockListSettings,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tisBlockVisible,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst _rootClientId = getBlockRootClientId(\n\t\t\t\tpreviousClientId ?? nextClientId\n\t\t\t);\n\t\t\treturn {\n\t\t\t\torientation:\n\t\t\t\t\tgetBlockListSettings( _rootClientId )?.orientation ||\n\t\t\t\t\t'vertical',\n\t\t\t\trootClientId: _rootClientId,\n\t\t\t\tisVisible:\n\t\t\t\t\tisBlockVisible( previousClientId ) &&\n\t\t\t\t\tisBlockVisible( nextClientId ),\n\t\t\t};\n\t\t},\n\t\t[ previousClientId, nextClientId ]\n\t);\n\tconst previousElement = useBlockElement( previousClientId );\n\tconst nextElement = useBlockElement( nextClientId );\n\tconst isVertical = orientation === 'vertical';\n\tconst style = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst previousRect = previousElement\n\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t: null;\n\t\tconst nextRect = nextElement\n\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t: null;\n\n\t\tif ( isVertical ) {\n\t\t\treturn {\n\t\t\t\twidth: previousRect ? previousRect.width : nextRect.width,\n\t\t\t\theight:\n\t\t\t\t\tnextRect && previousRect\n\t\t\t\t\t\t? nextRect.top - previousRect.bottom\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\n\t\tlet width = 0;\n\t\tif ( previousRect && nextRect ) {\n\t\t\twidth = isRTL()\n\t\t\t\t? previousRect.left - nextRect.right\n\t\t\t\t: nextRect.left - previousRect.right;\n\t\t}\n\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: previousRect ? previousRect.height : nextRect.height,\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tisVertical,\n\t\tpopoverRecomputeCounter,\n\t\tisVisible,\n\t] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverRecomputeCounter is by definition always equal or greater than 0.\n\t\t\t// This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverRecomputeCounter < 0 ||\n\t\t\t( ! previousElement && ! nextElement ) ||\n\t\t\t! isVisible\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst { ownerDocument } = previousElement || nextElement;\n\n\t\treturn {\n\t\t\townerDocument,\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst previousRect = previousElement\n\t\t\t\t\t? previousElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\t\t\t\tconst nextRect = nextElement\n\t\t\t\t\t? nextElement.getBoundingClientRect()\n\t\t\t\t\t: null;\n\n\t\t\t\tlet left = 0;\n\t\t\t\tlet top = 0;\n\n\t\t\t\tif ( isVertical ) {\n\t\t\t\t\t// vertical\n\t\t\t\t\ttop = previousRect ? previousRect.bottom : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// vertical, ltr\n\t\t\t\t\t\tleft = previousRect ? previousRect.left : nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\ttop = previousRect ? previousRect.top : nextRect.top;\n\n\t\t\t\t\tif ( isRTL() ) {\n\t\t\t\t\t\t// non vertical, rtl\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.left\n\t\t\t\t\t\t\t: nextRect.right;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// non vertical, ltr\n\t\t\t\t\t\tleft = previousRect\n\t\t\t\t\t\t\t? previousRect.right\n\t\t\t\t\t\t\t: nextRect.left;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn new window.DOMRect( left, top, 0, 0 );\n\t\t\t},\n\t\t};\n\t}, [\n\t\tpreviousElement,\n\t\tnextElement,\n\t\tpopoverRecomputeCounter,\n\t\tisVertical,\n\t\tisVisible,\n\t] );\n\n\tconst popoverScrollRef = usePopoverScroll( __unstableContentRef );\n\n\t// This is only needed for a smooth transition when moving blocks.\n\t// When blocks are moved up/down, their position can be set by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( previousElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ previousElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! nextElement ) {\n\t\t\treturn;\n\t\t}\n\t\tconst observer = new window.MutationObserver( forcePopoverRecompute );\n\t\tobserver.observe( nextElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ nextElement ] );\n\n\tuseLayoutEffect( () => {\n\t\tif ( ! previousElement ) {\n\t\t\treturn;\n\t\t}\n\t\tpreviousElement.ownerDocument.defaultView.addEventListener(\n\t\t\t'resize',\n\t\t\tforcePopoverRecompute\n\t\t);\n\t\treturn () => {\n\t\t\tpreviousElement.ownerDocument.defaultView.removeEventListener(\n\t\t\t\t'resize',\n\t\t\t\tforcePopoverRecompute\n\t\t\t);\n\t\t};\n\t}, [ previousElement ] );\n\n\t// If there's either a previous or a next element, show the inbetween popover.\n\t// Note that drag and drop uses the inbetween popover to show the drop indicator\n\t// before the first block and after the last block.\n\tif ( ( ! previousElement && ! nextElement ) || ! isVisible ) {\n\t\treturn null;\n\t}\n\n\t/* eslint-disable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n\t// While ideally it would be enough to capture the\n\t// bubbling focus event from the Inserter, due to the\n\t// characteristics of click focusing of `button`s in\n\t// Firefox and Safari, it is not reliable.\n\t//\n\t// See: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#Clicking_and_focus\n\treturn (\n\t\t<Popover\n\t\t\tref={ popoverScrollRef }\n\t\t\tanimate={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\tfocusOnMount={ false }\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// Forces a remount of the popover when its position changes\n\t\t\t// This makes sure the popover doesn't animate from its previous position.\n\t\t\tkey={ nextClientId + '--' + rootClientId }\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\t'block-editor-block-popover__inbetween',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tplacement=\"bottom-start\"\n\t\t>\n\t\t\t<div\n\t\t\t\tclassName=\"block-editor-block-popover__inbetween-container\"\n\t\t\t\tstyle={ style }\n\t\t\t>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</Popover>\n\t);\n\t/* eslint-enable jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n}\n\nexport default BlockPopoverInbetween;\n"]}
@@ -32,6 +32,8 @@ var _usePopoverScroll = _interopRequireDefault(require("./use-popover-scroll"));
32
32
  /**
33
33
  * Internal dependencies
34
34
  */
35
+ const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
36
+
35
37
  function BlockPopover(_ref, ref) {
36
38
  let {
37
39
  clientId,
@@ -57,8 +59,33 @@ function BlockPopover(_ref, ref) {
57
59
  height: selectedElement.offsetHeight
58
60
  };
59
61
  }, [selectedElement, lastSelectedElement, __unstableRefreshSize]);
62
+ const [popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor] = (0, _element.useReducer)( // Module is there to make sure that the counter doesn't overflow.
63
+ s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0); // When blocks are moved up/down, they are animated to their new position by
64
+ // updating the `transform` property manually (i.e. without using CSS
65
+ // transitions or animations). The animation, which can also scroll the block
66
+ // editor, can sometimes cause the position of the Popover to get out of sync.
67
+ // A MutationObserver is therefore used to make sure that changes to the
68
+ // selectedElement's attribute (i.e. `transform`) can be tracked and used to
69
+ // trigger the Popover to rerender.
70
+
71
+ (0, _element.useLayoutEffect)(() => {
72
+ if (!selectedElement) {
73
+ return;
74
+ }
75
+
76
+ const observer = new window.MutationObserver(forceRecomputePopoverAnchor);
77
+ observer.observe(selectedElement, {
78
+ attributes: true
79
+ });
80
+ return () => {
81
+ observer.disconnect();
82
+ };
83
+ }, [selectedElement]);
60
84
  const popoverAnchor = (0, _element.useMemo)(() => {
61
- if (!selectedElement || bottomClientId && !lastSelectedElement) {
85
+ if ( // popoverAnchorRecomputeCounter is by definition always equal or greater
86
+ // than 0. This check is only there to satisfy the correctness of the
87
+ // exhaustive-deps rule for the `useMemo` hook.
88
+ popoverAnchorRecomputeCounter < 0 || !selectedElement || bottomClientId && !lastSelectedElement) {
62
89
  return undefined;
63
90
  }
64
91
 
@@ -83,7 +110,7 @@ function BlockPopover(_ref, ref) {
83
110
 
84
111
  ownerDocument: selectedElement.ownerDocument
85
112
  };
86
- }, [bottomClientId, lastSelectedElement, selectedElement]);
113
+ }, [bottomClientId, lastSelectedElement, selectedElement, popoverAnchorRecomputeCounter]);
87
114
 
88
115
  if (!selectedElement || bottomClientId && !lastSelectedElement) {
89
116
  return null;
@@ -1 +1 @@
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","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","window","DOMRect","ownerDocument","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,cA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,MAAM,GAAGN,IAAI,CAACK,GAAL,CACdR,WAAW,CAACS,MADE,2BAEdR,eAAe,CAACQ,MAFF,yEAEY,CAACJ,QAFb,CAAf;AAIA,cAAMZ,KAAK,GAAGc,KAAK,GAAGL,IAAtB;AACA,cAAMP,MAAM,GAAGc,MAAM,GAAGH,GAAxB;AAEA,eAAO,IAAII,MAAM,CAACC,OAAX,CAAoBT,IAApB,EAA0BI,GAA1B,EAA+Bb,KAA/B,EAAsCE,MAAtC,CAAP;AACA,OA9BK;;AA+BNiB,MAAAA,aAAa,EAAExB,eAAe,CAACwB;AA/BzB,KAAP;AAiCA,GAzCqB,EAyCnB,CAAE/B,cAAF,EAAkBQ,mBAAlB,EAAuCD,eAAvC,CAzCmB,CAAtB;;AA2CA,MAAK,CAAEA,eAAF,IAAuBP,cAAc,IAAI,CAAEQ,mBAAhD,EAAwE;AACvE,WAAO,IAAP;AACA;;AAED,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,MAAM,EAAGO,aALV,CAMC;AACA;AAPD;AAQC,IAAA,kBAAkB,EAAGZ,qBAAqB,IAAI,IAR/C;AASC,IAAA,MAAM,EAAG,KATV;AAUC,IAAA,IAAI,EAAG,KAVR;AAWC,IAAA,KAAK;AAXN,KAYME,KAZN;AAaC,IAAA,SAAS,EAAG,yBACX,4BADW,EAEXA,KAAK,CAAC0B,SAFK;AAbb,MAkBG7B,qBAAqB,IAAI;AAAK,IAAA,KAAK,EAAGO;AAAb,KAAuBT,QAAvB,CAlB5B,EAmBG,CAAEE,qBAAF,IAA2BF,QAnB9B,CADD;AAuBA;;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\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [ bottomClientId, lastSelectedElement, selectedElement ] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-popover/index.js"],"names":["MAX_POPOVER_RECOMPUTE_COUNTER","Number","MAX_SAFE_INTEGER","BlockPopover","ref","clientId","bottomClientId","children","__unstableRefreshSize","__unstableCoverTarget","__unstablePopoverSlot","__unstableContentRef","props","selectedElement","lastSelectedElement","mergedRefs","style","position","width","offsetWidth","height","offsetHeight","popoverAnchorRecomputeCounter","forceRecomputePopoverAnchor","s","observer","window","MutationObserver","observe","attributes","disconnect","popoverAnchor","undefined","getBoundingClientRect","selectedBCR","lastSelectedBCR","left","Math","min","Infinity","top","right","max","bottom","DOMRect","ownerDocument","className"],"mappings":";;;;;;;;;AAUA;;;;AAPA;;AAKA;;AACA;;AAWA;;AACA;;AArBA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AAIA,MAAMA,6BAA6B,GAAGC,MAAM,CAACC,gBAA7C;;AAEA,SAASC,YAAT,OAWCC,GAXD,EAYE;AAAA,MAXD;AACCC,IAAAA,QADD;AAECC,IAAAA,cAFD;AAGCC,IAAAA,QAHD;AAICC,IAAAA,qBAJD;AAKCC,IAAAA,qBAAqB,GAAG,KALzB;AAMCC,IAAAA,qBAND;AAOCC,IAAAA,oBAPD;AAQC,OAAGC;AARJ,GAWC;AACD,QAAMC,eAAe,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,QAAM,CAAEc,6BAAF,EAAiCC,2BAAjC,IACL,0BACC;AACEC,EAAAA,CAAF,IAA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port { useMergeRefs } from '@wordpress/compose';\nimport { Popover } from '@wordpress/components';\nimport {\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseLayoutEffect,\n} from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';\nimport usePopoverScroll from './use-popover-scroll';\n\nconst MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;\n\nfunction BlockPopover(\n\t{\n\t\tclientId,\n\t\tbottomClientId,\n\t\tchildren,\n\t\t__unstableRefreshSize,\n\t\t__unstableCoverTarget = false,\n\t\t__unstablePopoverSlot,\n\t\t__unstableContentRef,\n\t\t...props\n\t},\n\tref\n) {\n\tconst selectedElement = useBlockElement( clientId );\n\tconst lastSelectedElement = useBlockElement( bottomClientId ?? clientId );\n\tconst mergedRefs = useMergeRefs( [\n\t\tref,\n\t\tusePopoverScroll( __unstableContentRef ),\n\t] );\n\tconst style = useMemo( () => {\n\t\tif ( ! selectedElement || lastSelectedElement !== selectedElement ) {\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tposition: 'absolute',\n\t\t\twidth: selectedElement.offsetWidth,\n\t\t\theight: selectedElement.offsetHeight,\n\t\t};\n\t}, [ selectedElement, lastSelectedElement, __unstableRefreshSize ] );\n\n\tconst [ popoverAnchorRecomputeCounter, forceRecomputePopoverAnchor ] =\n\t\tuseReducer(\n\t\t\t// Module is there to make sure that the counter doesn't overflow.\n\t\t\t( s ) => ( s + 1 ) % MAX_POPOVER_RECOMPUTE_COUNTER,\n\t\t\t0\n\t\t);\n\n\t// When blocks are moved up/down, they are animated to their new position by\n\t// updating the `transform` property manually (i.e. without using CSS\n\t// transitions or animations). The animation, which can also scroll the block\n\t// editor, can sometimes cause the position of the Popover to get out of sync.\n\t// A MutationObserver is therefore used to make sure that changes to the\n\t// selectedElement's attribute (i.e. `transform`) can be tracked and used to\n\t// trigger the Popover to rerender.\n\tuseLayoutEffect( () => {\n\t\tif ( ! selectedElement ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst observer = new window.MutationObserver(\n\t\t\tforceRecomputePopoverAnchor\n\t\t);\n\t\tobserver.observe( selectedElement, { attributes: true } );\n\n\t\treturn () => {\n\t\t\tobserver.disconnect();\n\t\t};\n\t}, [ selectedElement ] );\n\n\tconst popoverAnchor = useMemo( () => {\n\t\tif (\n\t\t\t// popoverAnchorRecomputeCounter is by definition always equal or greater\n\t\t\t// than 0. This check is only there to satisfy the correctness of the\n\t\t\t// exhaustive-deps rule for the `useMemo` hook.\n\t\t\tpopoverAnchorRecomputeCounter < 0 ||\n\t\t\t! selectedElement ||\n\t\t\t( bottomClientId && ! lastSelectedElement )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn {\n\t\t\tgetBoundingClientRect() {\n\t\t\t\tconst selectedBCR = selectedElement.getBoundingClientRect();\n\t\t\t\tconst lastSelectedBCR =\n\t\t\t\t\tlastSelectedElement?.getBoundingClientRect();\n\n\t\t\t\t// Get the biggest rectangle that encompasses completely the currently\n\t\t\t\t// selected element and the last selected element:\n\t\t\t\t// - for top/left coordinates, use the smaller numbers\n\t\t\t\t// - for the bottom/right coordinates, use the largest numbers\n\t\t\t\tconst left = Math.min(\n\t\t\t\t\tselectedBCR.left,\n\t\t\t\t\tlastSelectedBCR?.left ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst top = Math.min(\n\t\t\t\t\tselectedBCR.top,\n\t\t\t\t\tlastSelectedBCR?.top ?? Infinity\n\t\t\t\t);\n\t\t\t\tconst right = Math.max(\n\t\t\t\t\tselectedBCR.right,\n\t\t\t\t\tlastSelectedBCR.right ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst bottom = Math.max(\n\t\t\t\t\tselectedBCR.bottom,\n\t\t\t\t\tlastSelectedBCR.bottom ?? -Infinity\n\t\t\t\t);\n\t\t\t\tconst width = right - left;\n\t\t\t\tconst height = bottom - top;\n\n\t\t\t\treturn new window.DOMRect( left, top, width, height );\n\t\t\t},\n\t\t\townerDocument: selectedElement.ownerDocument,\n\t\t};\n\t}, [\n\t\tbottomClientId,\n\t\tlastSelectedElement,\n\t\tselectedElement,\n\t\tpopoverAnchorRecomputeCounter,\n\t] );\n\n\tif ( ! selectedElement || ( bottomClientId && ! lastSelectedElement ) ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ mergedRefs }\n\t\t\tanimate={ false }\n\t\t\tposition=\"top right left\"\n\t\t\tfocusOnMount={ false }\n\t\t\tanchor={ popoverAnchor }\n\t\t\t// Render in the old slot if needed for backward compatibility,\n\t\t\t// otherwise render in place (not in the default popover slot).\n\t\t\t__unstableSlotName={ __unstablePopoverSlot || null }\n\t\t\tresize={ false }\n\t\t\tflip={ false }\n\t\t\tshift\n\t\t\t{ ...props }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-block-popover',\n\t\t\t\tprops.className\n\t\t\t) }\n\t\t>\n\t\t\t{ __unstableCoverTarget && <div style={ style }>{ children }</div> }\n\t\t\t{ ! __unstableCoverTarget && children }\n\t\t</Popover>\n\t);\n}\n\nexport default forwardRef( BlockPopover );\n"]}
@@ -180,7 +180,8 @@ function ListView(_ref, ref) {
180
180
  ref: treeGridRef,
181
181
  onCollapseRow: collapseRow,
182
182
  onExpandRow: expandRow,
183
- onFocusRow: focusRow
183
+ onFocusRow: focusRow,
184
+ applicationAriaLabel: (0, _i18n.__)('Block navigation structure')
184
185
  }, (0, _element.createElement)(_context.ListViewContext.Provider, {
185
186
  value: contextValue
186
187
  }, (0, _element.createElement)(_branch.default, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListView","ref","blocks","showBlockMovers","isExpanded","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","blockEditorStore","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AASA;;AANA;;AAIA;;AACA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,QAAQ,GAAG,CAAEC,KAAF,EAASC,MAAT,KAAqB;AACrC,MAAKC,KAAK,CAACC,OAAN,CAAeF,MAAM,CAACG,SAAtB,CAAL,EAAyC;AACxC,WAAO,EACN,GAAGJ,KADG;AAEN,SAAGC,MAAM,CAACG,SAAP,CAAiBC,MAAjB,CACF,CAAEC,QAAF,EAAYC,EAAZ,MAAsB,EACrB,GAAGD,QADkB;AAErB,SAAEC,EAAF,GAAQN,MAAM,CAACO,IAAP,KAAgB;AAFH,OAAtB,CADE,EAKF,EALE;AAFG,KAAP;AAUA;;AACD,SAAOR,KAAP;AACA,CAdD;;AAgBO,MAAMS,sBAAsB,GAAG,EAA/B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,QAAT,OAECC,GAFD,EAGE;AAAA,MAFD;AAAEJ,IAAAA,EAAF;AAAMK,IAAAA,MAAN;AAAcC,IAAAA,eAAe,GAAG,KAAhC;AAAuCC,IAAAA,UAAU,GAAG;AAApD,GAEC;AACD,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA,gBAAjB;AAAmCC,IAAAA;AAAnC,MACL,mCAAsBL,MAAtB,CADD;AAGA,QAAM;AAAEM,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAA+C,qBAClDC,MAAF,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,EAAGzB,eAHnB;AAIC,IAAA,eAAe,EAAG6B,eAJnB;AAKC,IAAA,iBAAiB,EAAGzB,iBALrB;AAMC,IAAA,UAAU,EAAGH,UANd;AAOC,IAAA,qBAAqB,EAAGK;AAPzB,IADD,CATD,CALD,CADD;AA6BA;;eACc,yBAAYT,QAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{ id, blocks, showBlockMovers = false, isExpanded = false },\n\tref\n) {\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[ isMounted.current, draggedClientIds, expandedState, expand, collapse ]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/index.js"],"names":["expanded","state","action","Array","isArray","clientIds","reduce","newState","id","type","BLOCK_LIST_ITEM_HEIGHT","ListView","ref","blocks","showBlockMovers","isExpanded","clientIdsTree","draggedClientIds","selectedClientIds","visibleBlockCount","shouldShowInnerBlocks","select","getGlobalBlockCount","getClientIdsOfDescendants","__unstableGetEditorMode","blockEditorStore","draggedBlockCount","length","updateBlockSelection","expandedState","setExpandedState","dropZoneRef","target","blockDropTarget","elementRef","treeGridRef","isMounted","setSelectedTreeId","firstSelectedBlockClientId","selectEditorBlock","event","clientId","current","fixedListWindow","useWindowing","windowOverscan","expand","collapse","expandRow","row","dataset","block","collapseRow","focusRow","startRow","endRow","shiftKey","contextValue","isTreeGridMounted"],"mappings":";;;;;;;;;AASA;;AANA;;AAIA;;AACA;;AASA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAC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vB,oBAAF,CAVgB,CAAjB;AAaA,QAAM6B,YAAY,GAAG,sBACpB,OAAQ;AACPC,IAAAA,iBAAiB,EAAEtB,SAAS,CAACM,OADtB;AAEPzB,IAAAA,gBAFO;AAGPY,IAAAA,aAHO;AAIPiB,IAAAA,MAJO;AAKPC,IAAAA;AALO,GAAR,CADoB,EAQpB,CAAEX,SAAS,CAACM,OAAZ,EAAqBzB,gBAArB,EAAuCY,aAAvC,EAAsDiB,MAAtD,EAA8DC,QAA9D,CARoB,CAArB;AAWA,SACC,4BAAC,uBAAD;AAAmB,IAAA,KAAK,EAAG;AAA3B,KACC,4BAAC,sBAAD;AACC,IAAA,WAAW,EAAGb,UADf;AAEC,IAAA,eAAe,EAAGD;AAFnB,IADD,EAKC,4BAAC,kCAAD;AACC,IAAA,EAAE,EAAGzB,EADN;AAEC,IAAA,SAAS,EAAC,6BAFX;AAGC,kBAAa,cAAI,4BAAJ,CAHd;AAIC,IAAA,GAAG,EAAG2B,WAJP;AAKC,IAAA,aAAa,EAAGiB,WALjB;AAMC,IAAA,WAAW,EAAGJ,SANf;AAOC,IAAA,UAAU,EAAGK,QAPd;AAQC,IAAA,oBAAoB,EAAG,cAAI,4BAAJ;AARxB,KAUC,4BAAC,wBAAD,CAAiB,QAAjB;AAA0B,IAAA,KAAK,EAAGI;AAAlC,KACC,4BAAC,eAAD;AACC,IAAA,MAAM,EAAGzC,aADV;AAEC,IAAA,WAAW,EAAGuB,iBAFf;AAGC,IAAA,eAAe,EAAGzB,eAHnB;AAIC,IAAA,eAAe,EAAG6B,eAJnB;AAKC,IAAA,iBAAiB,EAAGzB,iBALrB;AAMC,IAAA,UAAU,EAAGH,UANd;AAOC,IAAA,qBAAqB,EAAGK;AAPzB,IADD,CAVD,CALD,CADD;AA8BA;;eACc,yBAAYT,QAAZ,C","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tuseMergeRefs,\n\t__experimentalUseFixedWindowList as useFixedWindowList,\n} from '@wordpress/compose';\nimport { __experimentalTreeGrid as TreeGrid } from '@wordpress/components';\nimport { AsyncModeProvider, useSelect } from '@wordpress/data';\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseReducer,\n\tforwardRef,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewBranch from './branch';\nimport { ListViewContext } from './context';\nimport ListViewDropIndicator from './drop-indicator';\nimport useBlockSelection from './use-block-selection';\nimport useListViewClientIds from './use-list-view-client-ids';\nimport useListViewDropZone from './use-list-view-drop-zone';\nimport useListViewExpandSelectedItem from './use-list-view-expand-selected-item';\nimport { store as blockEditorStore } from '../../store';\n\nconst expanded = ( state, action ) => {\n\tif ( Array.isArray( action.clientIds ) ) {\n\t\treturn {\n\t\t\t...state,\n\t\t\t...action.clientIds.reduce(\n\t\t\t\t( newState, id ) => ( {\n\t\t\t\t\t...newState,\n\t\t\t\t\t[ id ]: action.type === 'expand',\n\t\t\t\t} ),\n\t\t\t\t{}\n\t\t\t),\n\t\t};\n\t}\n\treturn state;\n};\n\nexport const BLOCK_LIST_ITEM_HEIGHT = 36;\n\n/**\n * Show a hierarchical list of blocks.\n *\n * @param {Object} props Components props.\n * @param {string} props.id An HTML element id for the root element of ListView.\n * @param {Array} props.blocks Custom subset of block client IDs to be used instead of the default hierarchy.\n * @param {boolean} props.showBlockMovers Flag to enable block movers\n * @param {boolean} props.isExpanded Flag to determine whether nested levels are expanded by default.\n * @param {Object} ref Forwarded ref\n */\nfunction ListView(\n\t{ id, blocks, showBlockMovers = false, isExpanded = false },\n\tref\n) {\n\tconst { clientIdsTree, draggedClientIds, selectedClientIds } =\n\t\tuseListViewClientIds( blocks );\n\n\tconst { visibleBlockCount, shouldShowInnerBlocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetGlobalBlockCount,\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\t__unstableGetEditorMode,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst draggedBlockCount =\n\t\t\t\tdraggedClientIds?.length > 0\n\t\t\t\t\t? getClientIdsOfDescendants( draggedClientIds ).length + 1\n\t\t\t\t\t: 0;\n\t\t\treturn {\n\t\t\t\tvisibleBlockCount: getGlobalBlockCount() - draggedBlockCount,\n\t\t\t\tshouldShowInnerBlocks: __unstableGetEditorMode() !== 'zoom-out',\n\t\t\t};\n\t\t},\n\t\t[ draggedClientIds ]\n\t);\n\n\tconst { updateBlockSelection } = useBlockSelection();\n\n\tconst [ expandedState, setExpandedState ] = useReducer( expanded, {} );\n\n\tconst { ref: dropZoneRef, target: blockDropTarget } = useListViewDropZone();\n\tconst elementRef = useRef();\n\tconst treeGridRef = useMergeRefs( [ elementRef, dropZoneRef, ref ] );\n\n\tconst isMounted = useRef( false );\n\tconst { setSelectedTreeId } = useListViewExpandSelectedItem( {\n\t\tfirstSelectedBlockClientId: selectedClientIds[ 0 ],\n\t\tsetExpandedState,\n\t} );\n\tconst selectEditorBlock = useCallback(\n\t\t( event, clientId ) => {\n\t\t\tupdateBlockSelection( event, clientId );\n\t\t\tsetSelectedTreeId( clientId );\n\t\t},\n\t\t[ setSelectedTreeId, updateBlockSelection ]\n\t);\n\tuseEffect( () => {\n\t\tisMounted.current = true;\n\t}, [] );\n\n\t// List View renders a fixed number of items and relies on each having a fixed item height of 36px.\n\t// If this value changes, we should also change the itemHeight value set in useFixedWindowList.\n\t// See: https://github.com/WordPress/gutenberg/pull/35230 for additional context.\n\tconst [ fixedListWindow ] = useFixedWindowList(\n\t\telementRef,\n\t\tBLOCK_LIST_ITEM_HEIGHT,\n\t\tvisibleBlockCount,\n\t\t{\n\t\t\tuseWindowing: true,\n\t\t\twindowOverscan: 40,\n\t\t}\n\t);\n\n\tconst expand = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'expand', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst collapse = useCallback(\n\t\t( clientId ) => {\n\t\t\tif ( ! clientId ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetExpandedState( { type: 'collapse', clientIds: [ clientId ] } );\n\t\t},\n\t\t[ setExpandedState ]\n\t);\n\tconst expandRow = useCallback(\n\t\t( row ) => {\n\t\t\texpand( row?.dataset?.block );\n\t\t},\n\t\t[ expand ]\n\t);\n\tconst collapseRow = useCallback(\n\t\t( row ) => {\n\t\t\tcollapse( row?.dataset?.block );\n\t\t},\n\t\t[ collapse ]\n\t);\n\tconst focusRow = useCallback(\n\t\t( event, startRow, endRow ) => {\n\t\t\tif ( event.shiftKey ) {\n\t\t\t\tupdateBlockSelection(\n\t\t\t\t\tevent,\n\t\t\t\t\tstartRow?.dataset?.block,\n\t\t\t\t\tendRow?.dataset?.block\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ updateBlockSelection ]\n\t);\n\n\tconst contextValue = useMemo(\n\t\t() => ( {\n\t\t\tisTreeGridMounted: isMounted.current,\n\t\t\tdraggedClientIds,\n\t\t\texpandedState,\n\t\t\texpand,\n\t\t\tcollapse,\n\t\t} ),\n\t\t[ isMounted.current, draggedClientIds, expandedState, expand, collapse ]\n\t);\n\n\treturn (\n\t\t<AsyncModeProvider value={ true }>\n\t\t\t<ListViewDropIndicator\n\t\t\t\tlistViewRef={ elementRef }\n\t\t\t\tblockDropTarget={ blockDropTarget }\n\t\t\t/>\n\t\t\t<TreeGrid\n\t\t\t\tid={ id }\n\t\t\t\tclassName=\"block-editor-list-view-tree\"\n\t\t\t\taria-label={ __( 'Block navigation structure' ) }\n\t\t\t\tref={ treeGridRef }\n\t\t\t\tonCollapseRow={ collapseRow }\n\t\t\t\tonExpandRow={ expandRow }\n\t\t\t\tonFocusRow={ focusRow }\n\t\t\t\tapplicationAriaLabel={ __( 'Block navigation structure' ) }\n\t\t\t>\n\t\t\t\t<ListViewContext.Provider value={ contextValue }>\n\t\t\t\t\t<ListViewBranch\n\t\t\t\t\t\tblocks={ clientIdsTree }\n\t\t\t\t\t\tselectBlock={ selectEditorBlock }\n\t\t\t\t\t\tshowBlockMovers={ showBlockMovers }\n\t\t\t\t\t\tfixedListWindow={ fixedListWindow }\n\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\tshouldShowInnerBlocks={ shouldShowInnerBlocks }\n\t\t\t\t\t/>\n\t\t\t\t</ListViewContext.Provider>\n\t\t\t</TreeGrid>\n\t\t</AsyncModeProvider>\n\t);\n}\nexport default forwardRef( ListView );\n"]}
@@ -227,6 +227,12 @@ function RichTextWrapper(_ref, forwardedRef) {
227
227
  let adjustedOnChange = originalOnChange; // Handle deprecated format.
228
228
 
229
229
  if (Array.isArray(originalValue)) {
230
+ (0, _deprecated.default)('wp.blockEditor.RichText value prop as children type', {
231
+ since: '6.1',
232
+ version: '6.3',
233
+ alternative: 'value prop as string',
234
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
235
+ });
230
236
  adjustedValue = _blocks.children.toHTML(originalValue);
231
237
 
232
238
  adjustedOnChange = newValue => originalOnChange(_blocks.children.fromDOM((0, _richText.__unstableCreateElement)(document, newValue).childNodes));
@@ -455,6 +461,12 @@ ForwardedRichTextContainer.Content = _ref3 => {
455
461
 
456
462
  // Handle deprecated `children` and `node` sources.
457
463
  if (Array.isArray(value)) {
464
+ (0, _deprecated.default)('wp.blockEditor.RichText value prop as children type', {
465
+ since: '6.1',
466
+ version: '6.3',
467
+ alternative: 'value prop as string',
468
+ link: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/'
469
+ });
458
470
  value = _blocks.children.toHTML(value);
459
471
  }
460
472
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","rootTagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","forwardedRef","children","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","since","version","alternative","link","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","blockEditorStore","selectionStart","selectionEnd","undefined","attributeKey","offset","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","childrenSource","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onKeyDown","event","keyCode","defaultPrevented","DELETE","BACKSPACE","isReverse","hasActiveFormats","activeFormats","preventDefault","onFocus","current","focus","TagName","className","ForwardedRichTextContainer","Content","Tag","MultilineTag","content","format","isEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;AALA;;AAYA;;AACA;;AACA;;AACA;;AAOA;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CrH,IAAAA,SAHsC;AAItC,OAAG7B;AAJmC,GAKhC;;AACN;AACA,MAAK+E,KAAK,CAACC,OAAN,CAAezD,KAAf,CAAL,EAA8B;AAC7BA,IAAAA,KAAK,GAAG0D,iBAAeC,MAAf,CAAuB3D,KAAvB,CAAR;AACA;;AAED,QAAM4H,YAAY,GAAG,4BAAiBtH,SAAjB,CAArB;;AAEA,MAAK,CAAEN,KAAF,IAAW4H,YAAhB,EAA+B;AAC9B5H,IAAAA,KAAK,GAAI,IAAI4H,YAAc,MAAMA,YAAc,GAA/C;AACA;;AAED,QAAMC,OAAO,GAAG,4BAAC,gBAAD,QAAW7H,KAAX,CAAhB;;AAEA,MAAK2H,GAAL,EAAW;AACV,UAAM;AAAEG,MAAAA,MAAF;AAAU,SAAGnI;AAAb,QAA2BlB,KAAjC;AACA,WAAO,4BAAC,GAAD,EAAUkB,SAAV,EAAwBkI,OAAxB,CAAP;AACA;;AAED,SAAOA,OAAP;AACA,CAzBD;;AA2BAJ,0BAA0B,CAACM,OAA3B,GAAuC/H,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACqD,MAAN,KAAiB,CAAnC;AACA,CAFD;AAIA;AACA;AACA;;;eACeoE,0B","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\tisCollapsed,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\trootTagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tif ( multiline ) {\n\t\tdeprecated( 'wp.blockEditor.RichText multiline prop', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'nested blocks (InnerBlocks)',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( keyCode === DELETE || keyCode === BACKSPACE ) {\n\t\t\tconst { start, end, text } = value;\n\t\t\tconst isReverse = keyCode === BACKSPACE;\n\t\t\tconst hasActiveFormats =\n\t\t\t\tvalue.activeFormats && !! value.activeFormats.length;\n\n\t\t\t// Only process delete if the key press occurs at an uncollapsed edge.\n\t\t\tif (\n\t\t\t\t! isCollapsed( value ) ||\n\t\t\t\thasActiveFormats ||\n\t\t\t\t( isReverse && start !== 0 ) ||\n\t\t\t\t( ! isReverse && end !== text.length )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\tif ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\tonFocus={ unstableOnFocus }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\tconst { format, ...restProps } = props;\n\t\treturn <Tag { ...restProps }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","rootTagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","forwardedRef","children","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","formattingControls","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","unstableOnFocus","__unstableAllowPrefixTransformations","since","version","alternative","link","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","blockEditorStore","selectionStart","selectionEnd","undefined","attributeKey","offset","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","childrenSource","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onKeyDown","event","keyCode","defaultPrevented","DELETE","BACKSPACE","isReverse","hasActiveFormats","activeFormats","preventDefault","onFocus","current","focus","TagName","className","ForwardedRichTextContainer","Content","Tag","MultilineTag","content","format","isEmpty"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;;;;AALA;;AAYA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA+aA;;AACA;;AACA;;AAjeA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAmBO,MAAMA,uBAAuB,GAAG,6BAAhC;;AACA,MAAMC,iBAAiB,GAAG,6BAA1B;AAEP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACA,SAASC,iBAAT,CAA4BC,KAA5B,EAAoC;AACnC,QAAM;AACLC,IAAAA,8BADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,cALK;AAMLC,IAAAA,eANK;AAOLC,IAAAA,mBAPK;AAQLC,IAAAA,kBARK;AASLC,IAAAA,QATK;AAULC,IAAAA,UAVK;AAWLC,IAAAA,UAXK;AAYLC,IAAAA,SAZK;AAaLC,IAAAA,QAbK;AAcLC,IAAAA,QAdK;AAeLC,IAAAA,MAfK;AAgBLC,IAAAA,kBAhBK;AAiBLC,IAAAA,qBAjBK;AAkBL,OAAGC;AAlBE,MAmBFlB,KAnBJ;AAoBA,SAAOkB,SAAP;AACA;;AAED,SAASC,eAAT,OA+BCC,YA/BD,EAgCE;AAAA,MA/BD;AACCC,IAAAA,QADD;AAECC,IAAAA,OAAO,GAAG,KAFX;AAGCC,IAAAA,KAAK,EAAEC,aAAa,GAAG,EAHxB;AAICC,IAAAA,QAAQ,EAAEC,gBAJX;AAKCC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;AAkCAJ,0BAA0B,CAACM,OAA3B,GAAuC/H,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACqD,MAAN,KAAiB,CAAnC;AACA,CAFD;AAIA;AACA;AACA;;;eACeoE,0B","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tRawHTML,\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tisEmpty,\n\tisCollapsed,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { BACKSPACE, DELETE } from '@wordpress/keycodes';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\trootTagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\tunstableOnFocus,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tif ( multiline ) {\n\t\tdeprecated( 'wp.blockEditor.RichText multiline prop', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'nested blocks (InnerBlocks)',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tformattingControls,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onKeyDown( event ) {\n\t\tconst { keyCode } = event;\n\n\t\tif ( event.defaultPrevented ) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ( keyCode === DELETE || keyCode === BACKSPACE ) {\n\t\t\tconst { start, end, text } = value;\n\t\t\tconst isReverse = keyCode === BACKSPACE;\n\t\t\tconst hasActiveFormats =\n\t\t\t\tvalue.activeFormats && !! value.activeFormats.length;\n\n\t\t\t// Only process delete if the key press occurs at an uncollapsed edge.\n\t\t\tif (\n\t\t\t\t! isCollapsed( value ) ||\n\t\t\t\thasActiveFormats ||\n\t\t\t\t( isReverse && start !== 0 ) ||\n\t\t\t\t( ! isReverse && end !== text.length )\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( onMerge ) {\n\t\t\t\tonMerge( ! isReverse );\n\t\t\t}\n\n\t\t\t// Only handle remove on Backspace. This serves dual-purpose of being\n\t\t\t// an intentional user interaction distinguishing between Backspace and\n\t\t\t// Delete to remove the empty field, but also to avoid merge & remove\n\t\t\t// causing destruction of two fields (merge, then removed merged).\n\t\t\tif ( onRemove && isEmpty( value ) && isReverse ) {\n\t\t\t\tonRemove( ! isReverse );\n\t\t\t}\n\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat(),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\tonFocus={ unstableOnFocus }\n\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = ( {\n\tvalue,\n\ttagName: Tag,\n\tmultiline,\n\t...props\n} ) => {\n\t// Handle deprecated `children` and `node` sources.\n\tif ( Array.isArray( value ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tvalue = childrenSource.toHTML( value );\n\t}\n\n\tconst MultilineTag = getMultilineTag( multiline );\n\n\tif ( ! value && MultilineTag ) {\n\t\tvalue = `<${ MultilineTag }></${ MultilineTag }>`;\n\t}\n\n\tconst content = <RawHTML>{ value }</RawHTML>;\n\n\tif ( Tag ) {\n\t\tconst { format, ...restProps } = props;\n\t\treturn <Tag { ...restProps }>{ content }</Tag>;\n\t}\n\n\treturn content;\n};\n\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
@@ -20,6 +20,7 @@ import { isRTL } from '@wordpress/i18n';
20
20
  import { store as blockEditorStore } from '../../store';
21
21
  import { __unstableUseBlockElement as useBlockElement } from '../block-list/use-block-props/use-block-refs';
22
22
  import usePopoverScroll from './use-popover-scroll';
23
+ const MAX_POPOVER_RECOMPUTE_COUNTER = Number.MAX_SAFE_INTEGER;
23
24
  export const InsertionPointOpenRef = createContext();
24
25
 
25
26
  function BlockPopoverInbetween(_ref) {
@@ -32,7 +33,8 @@ function BlockPopoverInbetween(_ref) {
32
33
  ...props
33
34
  } = _ref;
34
35
  // This is a temporary hack to get the inbetween inserter to recompute properly.
35
- const [positionRecompute, forceRecompute] = useReducer(s => s + 1, 0);
36
+ const [popoverRecomputeCounter, forcePopoverRecompute] = useReducer( // Module is there to make sure that the counter doesn't overflow.
37
+ s => (s + 1) % MAX_POPOVER_RECOMPUTE_COUNTER, 0);
36
38
  const {
37
39
  orientation,
38
40
  rootClientId,
@@ -58,7 +60,10 @@ function BlockPopoverInbetween(_ref) {
58
60
  const nextElement = useBlockElement(nextClientId);
59
61
  const isVertical = orientation === 'vertical';
60
62
  const style = useMemo(() => {
61
- if (!previousElement && !nextElement || !isVisible) {
63
+ if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
64
+ // This check is only there to satisfy the correctness of the
65
+ // exhaustive-deps rule for the `useMemo` hook.
66
+ popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
62
67
  return {};
63
68
  }
64
69
 
@@ -82,9 +87,12 @@ function BlockPopoverInbetween(_ref) {
82
87
  width,
83
88
  height: previousRect ? previousRect.height : nextRect.height
84
89
  };
85
- }, [previousElement, nextElement, isVertical, positionRecompute, isVisible]);
90
+ }, [previousElement, nextElement, isVertical, popoverRecomputeCounter, isVisible]);
86
91
  const popoverAnchor = useMemo(() => {
87
- if (!previousElement && !nextElement || !isVisible) {
92
+ if ( // popoverRecomputeCounter is by definition always equal or greater than 0.
93
+ // This check is only there to satisfy the correctness of the
94
+ // exhaustive-deps rule for the `useMemo` hook.
95
+ popoverRecomputeCounter < 0 || !previousElement && !nextElement || !isVisible) {
88
96
  return undefined;
89
97
  }
90
98
 
@@ -127,15 +135,22 @@ function BlockPopoverInbetween(_ref) {
127
135
  }
128
136
 
129
137
  };
130
- }, [previousElement, nextElement, positionRecompute, isVertical, isVisible]);
138
+ }, [previousElement, nextElement, popoverRecomputeCounter, isVertical, isVisible]);
131
139
  const popoverScrollRef = usePopoverScroll(__unstableContentRef); // This is only needed for a smooth transition when moving blocks.
140
+ // When blocks are moved up/down, their position can be set by
141
+ // updating the `transform` property manually (i.e. without using CSS
142
+ // transitions or animations). The animation, which can also scroll the block
143
+ // editor, can sometimes cause the position of the Popover to get out of sync.
144
+ // A MutationObserver is therefore used to make sure that changes to the
145
+ // selectedElement's attribute (i.e. `transform`) can be tracked and used to
146
+ // trigger the Popover to rerender.
132
147
 
133
148
  useLayoutEffect(() => {
134
149
  if (!previousElement) {
135
150
  return;
136
151
  }
137
152
 
138
- const observer = new window.MutationObserver(forceRecompute);
153
+ const observer = new window.MutationObserver(forcePopoverRecompute);
139
154
  observer.observe(previousElement, {
140
155
  attributes: true
141
156
  });
@@ -148,7 +163,7 @@ function BlockPopoverInbetween(_ref) {
148
163
  return;
149
164
  }
150
165
 
151
- const observer = new window.MutationObserver(forceRecompute);
166
+ const observer = new window.MutationObserver(forcePopoverRecompute);
152
167
  observer.observe(nextElement, {
153
168
  attributes: true
154
169
  });
@@ -161,9 +176,9 @@ function BlockPopoverInbetween(_ref) {
161
176
  return;
162
177
  }
163
178
 
164
- previousElement.ownerDocument.defaultView.addEventListener('resize', forceRecompute);
179
+ previousElement.ownerDocument.defaultView.addEventListener('resize', forcePopoverRecompute);
165
180
  return () => {
166
- previousElement.ownerDocument.defaultView.removeEventListener('resize', forceRecompute);
181
+ previousElement.ownerDocument.defaultView.removeEventListener('resize', forcePopoverRecompute);
167
182
  };
168
183
  }, [previousElement]); // If there's either a previous or a next element, show the inbetween popover.
169
184
  // Note that drag and drop uses the inbetween popover to show the drop indicator