@wordpress/edit-widgets 2.1.19 → 2.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/build/blocks/widget-area/edit/index.js +3 -1
  2. package/build/blocks/widget-area/edit/index.js.map +1 -1
  3. package/build/blocks/widget-area/edit/inner-blocks.js +4 -1
  4. package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  5. package/build/components/error-boundary/index.js +76 -0
  6. package/build/components/error-boundary/index.js.map +1 -0
  7. package/build/components/layout/index.js +8 -3
  8. package/build/components/layout/index.js.map +1 -1
  9. package/build/components/more-menu/index.js +1 -1
  10. package/build/components/more-menu/index.js.map +1 -1
  11. package/build/components/sidebar/widget-areas.js +11 -1
  12. package/build/components/sidebar/widget-areas.js.map +1 -1
  13. package/build/hooks/use-widget-library-insertion-point.js +11 -0
  14. package/build/hooks/use-widget-library-insertion-point.js.map +1 -1
  15. package/build/index.js +24 -2
  16. package/build/index.js.map +1 -1
  17. package/build/store/selectors.js +20 -0
  18. package/build/store/selectors.js.map +1 -1
  19. package/build-module/blocks/widget-area/edit/index.js +3 -1
  20. package/build-module/blocks/widget-area/edit/index.js.map +1 -1
  21. package/build-module/blocks/widget-area/edit/inner-blocks.js +4 -1
  22. package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  23. package/build-module/components/error-boundary/index.js +65 -0
  24. package/build-module/components/error-boundary/index.js.map +1 -0
  25. package/build-module/components/layout/index.js +7 -3
  26. package/build-module/components/layout/index.js.map +1 -1
  27. package/build-module/components/more-menu/index.js +1 -1
  28. package/build-module/components/more-menu/index.js.map +1 -1
  29. package/build-module/components/sidebar/widget-areas.js +10 -1
  30. package/build-module/components/sidebar/widget-areas.js.map +1 -1
  31. package/build-module/hooks/use-widget-library-insertion-point.js +10 -0
  32. package/build-module/hooks/use-widget-library-insertion-point.js.map +1 -1
  33. package/build-module/index.js +24 -3
  34. package/build-module/index.js.map +1 -1
  35. package/build-module/store/selectors.js +18 -0
  36. package/build-module/store/selectors.js.map +1 -1
  37. package/build-style/style-rtl.css +8 -0
  38. package/build-style/style.css +8 -0
  39. package/package.json +26 -25
  40. package/src/blocks/widget-area/edit/index.js +1 -1
  41. package/src/blocks/widget-area/edit/inner-blocks.js +2 -1
  42. package/src/components/error-boundary/index.js +64 -0
  43. package/src/components/error-boundary/style.scss +7 -0
  44. package/src/components/layout/index.js +14 -11
  45. package/src/components/more-menu/index.js +1 -1
  46. package/src/components/sidebar/widget-areas.js +10 -1
  47. package/src/hooks/use-widget-library-insertion-point.js +11 -0
  48. package/src/index.js +22 -3
  49. package/src/store/selectors.js +12 -0
  50. package/src/style.scss +1 -0
@@ -83,7 +83,9 @@ function WidgetAreaEdit({
83
83
  kind: "root",
84
84
  type: "postType",
85
85
  id: `widget-area-${id}`
86
- }, (0, _element.createElement)(_innerBlocks.default, null)))));
86
+ }, (0, _element.createElement)(_innerBlocks.default, {
87
+ id: id
88
+ })))));
87
89
  }
88
90
  /**
89
91
  * A React hook to determine if dragging is active.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"names":["WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","editWidgetsStore","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","opened","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AASA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAUA;AACA;AACA;;AAKA;AAEe,SAASA,cAAT,CAAyB;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,SAFuC;AAGvCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN;AAH2B,CAAzB,EAIX;AACH,QAAMC,MAAM,GAAG,q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,CAAEQ;AANrB,KAQG,CAAE;AAAEK,IAAAA;AAAF,GAAF,KACD;AACA;AACA;AACA;AACA,8BAAC,uCAAD;AACC,IAAA,SAAS,EAAC,0CADX;AAEC,IAAA,OAAO,EAAGA;AAFX,KAIC,4BAAC,wBAAD;AACC,IAAA,IAAI,EAAC,MADN;AAEC,IAAA,IAAI,EAAC,UAFN;AAGC,IAAA,EAAE,EAAI,eAAef,EAAI;AAH1B,KAKC,4BAAC,oBAAD,OALD,CAJD,CAbF,CADD,CADD;AA+BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMW,aAAa,GAAKK,UAAF,IAAkB;AACvC,QAAM,CAAEN,UAAF,EAAcO,aAAd,IAAgC,uBAAU,KAAV,CAAtC;AAEA,0BAAW,MAAM;AAChB,UAAM;AAAEC,MAAAA;AAAF,QAAoBF,UAAU,CAACG,OAArC;;AAEA,aAASC,eAAT,GAA2B;AAC1BH,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;;AAED,aAASI,aAAT,GAAyB;AACxBJ,MAAAA,aAAa,CAAE,KAAF,CAAb;AACA;;AAEDC,IAAAA,aAAa,CAACI,gBAAd,CAAgC,WAAhC,EAA6CF,eAA7C;AACAF,IAAAA,aAAa,CAACI,gBAAd,CAAgC,SAAhC,EAA2CD,aAA3C;AAEA,WAAO,MAAM;AACZH,MAAAA,aAAa,CAACK,mBAAd,CAAmC,WAAnC,EAAgDH,eAAhD;AACAF,MAAAA,aAAa,CAACK,mBAAd,CAAmC,SAAnC,EAA8CF,aAA9C;AACA,KAHD;AAIA,GAlBD,EAkBG,EAlBH;AAoBA,SAAOX,UAAP;AACA,CAxBD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"names":["WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","editWidgetsStore","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","opened","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","remov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AA,aAAa,CAACK,mBAAd,CAAmC,SAAnC,EAA8CF,aAA9C;AACA,KAHD;AAIA,GAlBD,EAkBG,EAlBH;AAoBA,SAAOX,UAAP;AACA,CAxBD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"]}
@@ -28,7 +28,9 @@ var _useIsDraggingWithin = _interopRequireDefault(require("./use-is-dragging-wit
28
28
  /**
29
29
  * Internal dependencies
30
30
  */
31
- function WidgetAreaInnerBlocks() {
31
+ function WidgetAreaInnerBlocks({
32
+ id
33
+ }) {
32
34
  const [blocks, onInput, onChange] = (0, _coreData.useEntityBlockEditor)('root', 'postType');
33
35
  const innerBlocksRef = (0, _element.useRef)();
34
36
  const isDraggingWithinInnerBlocks = (0, _useIsDraggingWithin.default)(innerBlocksRef);
@@ -44,6 +46,7 @@ function WidgetAreaInnerBlocks() {
44
46
  renderAppender: _blockEditor.InnerBlocks.ButtonBlockAppender
45
47
  });
46
48
  return (0, _element.createElement)("div", {
49
+ "data-widget-area-id": id,
47
50
  className: (0, _classnames.default)('wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper', {
48
51
  'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone
49
52
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js"],"names":["WidgetAreaInnerBlocks","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","InnerBlocks","ButtonBlockAppender"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AASA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,qBAAT,GAAiC;AAC/C,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgC,oCACrC,MADqC,EAErC,UAFqC,CAAtC;AAIA,QAAMC,cAAc,GAAG,sBAAvB;AACA,QAAMC,2BAA2B,GAAG,kCAAqBD,cAArB,CAApC;AACA,QAAME,uBAAuB,GAAGD,2BAAhC,CAP+C,CAQ/C;;AACA,QAAME,gBAAgB,GAAG,oDACxB;AAAEC,IAAAA,GAAG,EAAEJ;AAAP,GADwB,EAExB;AACCK,IAAAA,KAAK,EAAER,MADR;AAECC,IAAAA,OAFD;AAGCC,IAAAA,QAHD;AAICO,IAAAA,YAAY,EAAE,KAJf;AAKCC,IAAAA,cAAc,EAAEC,yBAAYC;AAL7B,GAFwB,CAAzB;AAWA,SACC;AACC,IAAA,SAAS,EAAG,yBACX,oFADW,EAEX;AACC,mDAA6CP;AAD9C,KAFW;AADb,KAQC,mCAAUC,gBAAV,CARD,CADD;AAYA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tInnerBlocks,\n\t__experimentalUseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks() {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = __experimentalUseInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js"],"names":["WidgetAreaInnerBlocks","id","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","InnerBlocks","ButtonBlockAppender"],"mappings":";;;;;;;;;AAaA;;AAVA;;AAKA;;AACA;;AASA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;AAGe,SAASA,qBAAT,CAAgC;AAAEC,EAAAA;AAAF,CAAhC,EAAyC;AACvD,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgC,oCACrC,MADqC,EAErC,UAFqC,CAAtC;AAIA,QAAMC,cAAc,GAAG,sBAAvB;AACA,QAAMC,2BAA2B,GAAG,kCAAqBD,cAArB,CAApC;AACA,QAAME,uBAAuB,GAAGD,2BAAhC,CAPuD,CAQvD;;AACA,QAAME,gBAAgB,GAAG,oDACxB;AAAEC,IAAAA,GAAG,EAAEJ;AAAP,GADwB,EAExB;AACCK,IAAAA,KAAK,EAAER,MADR;AAECC,IAAAA,OAFD;AAGCC,IAAAA,QAHD;AAICO,IAAAA,YAAY,EAAE,KAJf;AAKCC,IAAAA,cAAc,EAAEC,yBAAYC;AAL7B,GAFwB,CAAzB;AAWA,SACC;AACC,2BAAsBb,EADvB;AAEC,IAAA,SAAS,EAAG,yBACX,oFADW,EAEX;AACC,mDAA6CM;AAD9C,KAFW;AAFb,KASC,mCAAUC,gBAAV,CATD,CADD;AAaA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tInnerBlocks,\n\t__experimentalUseInnerBlocksProps,\n} from '@wordpress/block-editor';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useIsDraggingWithin from './use-is-dragging-within';\n\nexport default function WidgetAreaInnerBlocks( { id } ) {\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'root',\n\t\t'postType'\n\t);\n\tconst innerBlocksRef = useRef();\n\tconst isDraggingWithinInnerBlocks = useIsDraggingWithin( innerBlocksRef );\n\tconst shouldHighlightDropZone = isDraggingWithinInnerBlocks;\n\t// Using the experimental hook so that we can control the className of the element.\n\tconst innerBlocksProps = __experimentalUseInnerBlocksProps(\n\t\t{ ref: innerBlocksRef },\n\t\t{\n\t\t\tvalue: blocks,\n\t\t\tonInput,\n\t\t\tonChange,\n\t\t\ttemplateLock: false,\n\t\t\trenderAppender: InnerBlocks.ButtonBlockAppender,\n\t\t}\n\t);\n\n\treturn (\n\t\t<div\n\t\t\tdata-widget-area-id={ id }\n\t\t\tclassName={ classnames(\n\t\t\t\t'wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper',\n\t\t\t\t{\n\t\t\t\t\t'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone,\n\t\t\t\t}\n\t\t\t) }\n\t\t>\n\t\t\t<div { ...innerBlocksProps } />\n\t\t</div>\n\t);\n}\n"]}
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _element = require("@wordpress/element");
9
+
10
+ var _i18n = require("@wordpress/i18n");
11
+
12
+ var _components = require("@wordpress/components");
13
+
14
+ var _blockEditor = require("@wordpress/block-editor");
15
+
16
+ var _compose = require("@wordpress/compose");
17
+
18
+ /**
19
+ * WordPress dependencies
20
+ */
21
+ function CopyButton({
22
+ text,
23
+ children
24
+ }) {
25
+ const ref = (0, _compose.useCopyToClipboard)(text);
26
+ return (0, _element.createElement)(_components.Button, {
27
+ variant: "secondary",
28
+ ref: ref
29
+ }, children);
30
+ }
31
+
32
+ class ErrorBoundary extends _element.Component {
33
+ constructor() {
34
+ super(...arguments);
35
+ this.reboot = this.reboot.bind(this);
36
+ this.state = {
37
+ error: null
38
+ };
39
+ }
40
+
41
+ componentDidCatch(error) {
42
+ this.setState({
43
+ error
44
+ });
45
+ }
46
+
47
+ reboot() {
48
+ this.props.onError();
49
+ }
50
+
51
+ render() {
52
+ const {
53
+ error
54
+ } = this.state;
55
+
56
+ if (!error) {
57
+ return this.props.children;
58
+ }
59
+
60
+ return (0, _element.createElement)(_blockEditor.Warning, {
61
+ className: "edit-widgets-error-boundary",
62
+ actions: [(0, _element.createElement)(_components.Button, {
63
+ key: "recovery",
64
+ onClick: this.reboot,
65
+ variant: "secondary"
66
+ }, (0, _i18n.__)('Attempt Recovery')), (0, _element.createElement)(CopyButton, {
67
+ key: "copy-error",
68
+ text: error.stack
69
+ }, (0, _i18n.__)('Copy Error'))]
70
+ }, (0, _i18n.__)('The editor has encountered an unexpected error.'));
71
+ }
72
+
73
+ }
74
+
75
+ exports.default = ErrorBoundary;
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/error-boundary/index.js"],"names":["CopyButton","text","children","ref","ErrorBoundary","Component","constructor","arguments","reboot","bind","state","error","componentDidCatch","setState","props","onError","render","stack"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAPA;AACA;AACA;AAOA,SAASA,UAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAA0C;AACzC,QAAMC,GAAG,GAAG,iCAAoBF,IAApB,CAAZ;AACA,SACC,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAEc,MAAME,aAAN,SAA4BC,kBAA5B,CAAsC;AACpDC,EAAAA,WAAW,GAAG;AACb,UAAO,GAAGC,SAAV;AAEA,SAAKC,MAAL,GAAc,KAAKA,MAAL,CAAYC,IAAZ,CAAkB,IAAlB,CAAd;AAEA,SAAKC,KAAL,GAAa;AACZC,MAAAA,KAAK,EAAE;AADK,KAAb;AAGA;;AAEDC,EAAAA,iBAAiB,CAAED,KAAF,EAAU;AAC1B,SAAKE,QAAL,CAAe;AAAEF,MAAAA;AAAF,KAAf;AACA;;AAEDH,EAAAA,MAAM,GAAG;AACR,SAAKM,KAAL,CAAWC,OAAX;AACA;;AAEDC,EAAAA,MAAM,GAAG;AACR,UAAM;AAAEL,MAAAA;AAAF,QAAY,KAAKD,KAAvB;;AACA,QAAK,CAAEC,KAAP,EAAe;AACd,aAAO,KAAKG,KAAL,CAAWZ,QAAlB;AACA;;AAED,WACC,4BAAC,oBAAD;AACC,MAAA,SAAS,EAAC,6BADX;AAEC,MAAA,OAAO,EAAG,CACT,4BAAC,kBAAD;AACC,QAAA,GAAG,EAAC,UADL;AAEC,QAAA,OAAO,EAAG,KAAKM,MAFhB;AAGC,QAAA,OAAO,EAAC;AAHT,SAKG,cAAI,kBAAJ,CALH,CADS,EAQT,4BAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGG,KAAK,CAACM;AAA1C,SACG,cAAI,YAAJ,CADH,CARS;AAFX,OAeG,cAAI,iDAAJ,CAfH,CADD;AAmBA;;AA5CmD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { Warning } from '@wordpress/block-editor';\nimport { useCopyToClipboard } from '@wordpress/compose';\n\nfunction CopyButton( { text, children } ) {\n\tconst ref = useCopyToClipboard( text );\n\treturn (\n\t\t<Button variant=\"secondary\" ref={ ref }>\n\t\t\t{ children }\n\t\t</Button>\n\t);\n}\n\nexport default class ErrorBoundary extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.reboot = this.reboot.bind( this );\n\n\t\tthis.state = {\n\t\t\terror: null,\n\t\t};\n\t}\n\n\tcomponentDidCatch( error ) {\n\t\tthis.setState( { error } );\n\t}\n\n\treboot() {\n\t\tthis.props.onError();\n\t}\n\n\trender() {\n\t\tconst { error } = this.state;\n\t\tif ( ! error ) {\n\t\t\treturn this.props.children;\n\t\t}\n\n\t\treturn (\n\t\t\t<Warning\n\t\t\t\tclassName=\"edit-widgets-error-boundary\"\n\t\t\t\tactions={ [\n\t\t\t\t\t<Button\n\t\t\t\t\t\tkey=\"recovery\"\n\t\t\t\t\t\tonClick={ this.reboot }\n\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Attempt Recovery' ) }\n\t\t\t\t\t</Button>,\n\t\t\t\t\t<CopyButton key=\"copy-error\" text={ error.stack }>\n\t\t\t\t\t\t{ __( 'Copy Error' ) }\n\t\t\t\t\t</CopyButton>,\n\t\t\t\t] }\n\t\t\t>\n\t\t\t\t{ __( 'The editor has encountered an unexpected error.' ) }\n\t\t\t</Warning>\n\t\t);\n\t}\n}\n"]}
@@ -13,6 +13,8 @@ var _components = require("@wordpress/components");
13
13
 
14
14
  var _plugins = require("@wordpress/plugins");
15
15
 
16
+ var _errorBoundary = _interopRequireDefault(require("../error-boundary"));
17
+
16
18
  var _widgetAreasBlockEditorProvider = _interopRequireDefault(require("../widget-areas-block-editor-provider"));
17
19
 
18
20
  var _sidebar = _interopRequireDefault(require("../sidebar"));
@@ -31,13 +33,16 @@ var _welcomeGuide = _interopRequireDefault(require("../welcome-guide"));
31
33
  * Internal dependencies
32
34
  */
33
35
  function Layout({
34
- blockEditorSettings
36
+ blockEditorSettings,
37
+ onError
35
38
  }) {
36
- return (0, _element.createElement)(_widgetAreasBlockEditorProvider.default, {
39
+ return (0, _element.createElement)(_errorBoundary.default, {
40
+ onError: onError
41
+ }, (0, _element.createElement)(_widgetAreasBlockEditorProvider.default, {
37
42
  blockEditorSettings: blockEditorSettings
38
43
  }, (0, _element.createElement)(_interface.default, {
39
44
  blockEditorSettings: blockEditorSettings
40
- }), (0, _element.createElement)(_sidebar.default, null), (0, _element.createElement)(_components.Popover.Slot, null), (0, _element.createElement)(_plugins.PluginArea, null), (0, _element.createElement)(_unsavedChangesWarning.default, null), (0, _element.createElement)(_welcomeGuide.default, null));
45
+ }), (0, _element.createElement)(_sidebar.default, null), (0, _element.createElement)(_components.Popover.Slot, null), (0, _element.createElement)(_plugins.PluginArea, null), (0, _element.createElement)(_unsavedChangesWarning.default, null), (0, _element.createElement)(_welcomeGuide.default, null)));
41
46
  }
42
47
 
43
48
  var _default = Layout;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/layout/index.js"],"names":["Layout","blockEditorSettings"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAbA;AACA;AACA;;AAIA;AACA;AACA;AAOA,SAASA,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAA2C;AAC1C,SACC,4BAAC,uCAAD;AACC,IAAA,mBAAmB,EAAGA;AADvB,KAGC,4BAAC,kBAAD;AAAW,IAAA,mBAAmB,EAAGA;AAAjC,IAHD,EAIC,4BAAC,gBAAD,OAJD,EAKC,4BAAC,mBAAD,CAAS,IAAT,OALD,EAMC,4BAAC,mBAAD,OAND,EAOC,4BAAC,8BAAD,OAPD,EAQC,4BAAC,qBAAD,OARD,CADD;AAYA;;eAEcD,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { PluginArea } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings } ) {\n\treturn (\n\t\t<WidgetAreasBlockEditorProvider\n\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t>\n\t\t\t<Interface blockEditorSettings={ blockEditorSettings } />\n\t\t\t<Sidebar />\n\t\t\t<Popover.Slot />\n\t\t\t<PluginArea />\n\t\t\t<UnsavedChangesWarning />\n\t\t\t<WelcomeGuide />\n\t\t</WidgetAreasBlockEditorProvider>\n\t);\n}\n\nexport default Layout;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/layout/index.js"],"names":["Layout","blockEditorSettings","onError"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAdA;AACA;AACA;;AAIA;AACA;AACA;AAQA,SAASA,MAAT,CAAiB;AAAEC,EAAAA,mBAAF;AAAuBC,EAAAA;AAAvB,CAAjB,EAAoD;AACnD,SACC,4BAAC,sBAAD;AAAe,IAAA,OAAO,EAAGA;AAAzB,KACC,4BAAC,uCAAD;AACC,IAAA,mBAAmB,EAAGD;AADvB,KAGC,4BAAC,kBAAD;AAAW,IAAA,mBAAmB,EAAGA;AAAjC,IAHD,EAIC,4BAAC,gBAAD,OAJD,EAKC,4BAAC,mBAAD,CAAS,IAAT,OALD,EAMC,4BAAC,mBAAD,OAND,EAOC,4BAAC,8BAAD,OAPD,EAQC,4BAAC,qBAAD,OARD,CADD,CADD;AAcA;;eAEcD,M","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Popover } from '@wordpress/components';\nimport { PluginArea } from '@wordpress/plugins';\n\n/**\n * Internal dependencies\n */\nimport ErrorBoundary from '../error-boundary';\nimport WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';\nimport Sidebar from '../sidebar';\nimport Interface from './interface';\nimport UnsavedChangesWarning from './unsaved-changes-warning';\nimport WelcomeGuide from '../welcome-guide';\n\nfunction Layout( { blockEditorSettings, onError } ) {\n\treturn (\n\t\t<ErrorBoundary onError={ onError }>\n\t\t\t<WidgetAreasBlockEditorProvider\n\t\t\t\tblockEditorSettings={ blockEditorSettings }\n\t\t\t>\n\t\t\t\t<Interface blockEditorSettings={ blockEditorSettings } />\n\t\t\t\t<Sidebar />\n\t\t\t\t<Popover.Slot />\n\t\t\t\t<PluginArea />\n\t\t\t\t<UnsavedChangesWarning />\n\t\t\t\t<WelcomeGuide />\n\t\t\t</WidgetAreasBlockEditorProvider>\n\t\t</ErrorBoundary>\n\t);\n}\n\nexport default Layout;\n"]}
@@ -78,7 +78,7 @@ function MoreMenu() {
78
78
  }), (0, _element.createElement)(_components.MenuItem, {
79
79
  role: "menuitem",
80
80
  icon: _icons.external,
81
- href: (0, _i18n.__)('https://wordpress.org/support/article/wordpress-editor/'),
81
+ href: (0, _i18n.__)('https://wordpress.org/support/article/block-based-widgets-editor/'),
82
82
  target: "_blank",
83
83
  rel: "noopener noreferrer"
84
84
  }, (0, _i18n.__)('Help'), (0, _element.createElement)(_components.VisuallyHidden, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/more-menu/index.js"],"names":["POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","isLargeViewport","moreVertical","displayShortcut","access","external"],"mappings":";;;;;;;;;AASA;;AANA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AApBA;AACA;AACA;;AAcA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,iCADU;AAErBC,EAAAA,QAAQ,EAAE;AAFW,CAAtB;AAIA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,eAAe,EAAE;AADG,CAArB;;AAIe,SAASC,QAAT,GAAoB;AAClC,QAAM,CACLC,8BADK,EAELC,kCAFK,IAGF,uBAAU,KAAV,CAHJ;;AAIA,QAAMC,4BAA4B,GAAG,MACpCD,kCAAkC,CAAE,CAAED,8BAAJ,CADnC;;AAGA,sCACC,sCADD,EAECE,4BAFD,EAGC;AACCC,IAAAA,UAAU,EAAE;AADb,GAHD;AAQA,QAAMC,eAAe,GAAG,+B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,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,aAAJ;AAAnB,KACC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAC,sBADT;AAEC,IAAA,KAAK,EAAG,cACP,kCADO,CAFT;AAKC,IAAA,IAAI,EAAG,cACN,iEADM,CALR;AAQC,IAAA,gBAAgB,EAAG,cAClB,4CADkB,CARpB;AAWC,IAAA,kBAAkB,EAAG,cACpB,8CADoB;AAXtB,IADD,EAgBC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAC,aADT;AAEC,IAAA,IAAI,EAAG,cACN,uCADM,CAFR;AAKC,IAAA,KAAK,EAAG,cAAI,kBAAJ;AALT,IAhBD,EAuBGJ,eAAe,IAChB,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAC,sBADT;AAEC,IAAA,KAAK,EAAG,cAAI,2BAAJ,CAFT;AAGC,IAAA,IAAI,EAAG,cACN,sDADM,CAHR;AAMC,IAAA,gBAAgB,EAAG,cAClB,qCADkB,CANpB;AASC,IAAA,kBAAkB,EAAG,cACpB,uCADoB;AATtB,IAxBF,CAjDD,CATF,CADD,EAqGC,4BAAC,kCAAD;AACC,IAAA,aAAa,EAAGJ,8BADjB;AAEC,IAAA,WAAW,EAAGE;AAFf,IArGD,CADD;AA4GA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { external, moreVertical } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport FeatureToggle from './feature-toggle';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\n\nconst POPOVER_PROPS = {\n\tclassName: 'edit-widgets-more-menu__content',\n\tposition: 'bottom left',\n};\nconst TOGGLE_PROPS = {\n\ttooltipPosition: 'bottom',\n};\n\nexport default function MoreMenu() {\n\tconst [\n\t\tisKeyboardShortcutsModalActive,\n\t\tsetIsKeyboardShortcutsModalVisible,\n\t] = useState( false );\n\tconst toggleKeyboardShortcutsModal = () =>\n\t\tsetIsKeyboardShortcutsModalVisible( ! isKeyboardShortcutsModalActive );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/keyboard-shortcuts',\n\t\ttoggleKeyboardShortcutsModal,\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-widgets-more-menu\"\n\t\t\t\ticon={ moreVertical }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\ttoggleProps={ TOGGLE_PROPS }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\t\tfeature=\"fixedToolbar\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsKeyboardShortcutsModalVisible( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"welcomeGuide\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/wordpress-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Preferences' ) }>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"keepCaretInsideBlock\"\n\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block deactivated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"themeStyles\"\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Make the editor look like your theme.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use theme styles' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\t\tfeature=\"showBlockBreadcrumbs\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Display block breadcrumbs' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Shows block breadcrumbs at the bottom of the editor.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isKeyboardShortcutsModalActive }\n\t\t\t\ttoggleModal={ toggleKeyboardShortcutsModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/more-menu/index.js"],"names":["POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","isLargeViewport","moreVertical","displayShortcut","access","external"],"mappings":";;;;;;;;;AASA;;AANA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AApBA;AACA;AACA;;AAcA;AACA;AACA;AAIA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,iCADU;AAErBC,EAAAA,QAAQ,EAAE;AAFW,CAAtB;AAIA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,eAAe,EAAE;AADG,CAArB;;AAIe,SAASC,QAAT,GAAoB;AAClC,QAAM,CACLC,8BADK,EAELC,kCAFK,IAGF,uBAAU,KAAV,CAHJ;;AAIA,QAAMC,4BAA4B,GAAG,MACpCD,kCAAkC,CAAE,CAAED,8BAAJ,CADnC;;AAGA,sCACC,sCADD,EAECE,4BAFD,EAGC;AACCC,IAAAA,UAAU,EAAE;AADb,GAHD;AAQA,QAAMC,eAAe,GAAG,+BAAkB,QAAlB,CAAxB;AAEA,SACC,qDACC,4BAAC,wBAAD;AACC,IAAA,SAAS,EAAC,wBADX;AAEC,IAAA,IAAI,EAAGC;AACP;AAHD;AAIC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAJT;AAKC,IAAA,YAAY,EAAGX,aALhB;AAMC,IAAA,WAAW,EAAGG;AANf,KAQG,MACD,qDACGO,eAAe,IAChB,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,MAAJ,EAAY,MAAZ;AAAnB,KACC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAC,cADT;AAEC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IAAA,KAAK,EAAG,cAAI,kBAAJ;AALT,IAhBD,EAuBGJ,eAAe,IAChB,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAC,sBADT;AAEC,IAAA,KAAK,EAAG,cAAI,2BAAJ,CAFT;AAGC,IAAA,IAAI,EAAG,cACN,sDADM,CAHR;AAMC,IAAA,gBAAgB,EAAG,cAClB,qCADkB,CANpB;AASC,IAAA,kBAAkB,EAAG,cACpB,uCADoB;AATtB,IAxBF,CAjDD,CATF,CADD,EAqGC,4BAAC,kCAAD;AACC,IAAA,aAAa,EAAGJ,8BADjB;AAEC,IAAA,WAAW,EAAGE;AAFf,IArGD,CADD;AA4GA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __, _x } from '@wordpress/i18n';\nimport { external, moreVertical } from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport FeatureToggle from './feature-toggle';\nimport KeyboardShortcutHelpModal from '../keyboard-shortcut-help-modal';\n\nconst POPOVER_PROPS = {\n\tclassName: 'edit-widgets-more-menu__content',\n\tposition: 'bottom left',\n};\nconst TOGGLE_PROPS = {\n\ttooltipPosition: 'bottom',\n};\n\nexport default function MoreMenu() {\n\tconst [\n\t\tisKeyboardShortcutsModalActive,\n\t\tsetIsKeyboardShortcutsModalVisible,\n\t] = useState( false );\n\tconst toggleKeyboardShortcutsModal = () =>\n\t\tsetIsKeyboardShortcutsModalVisible( ! isKeyboardShortcutsModalActive );\n\n\tuseShortcut(\n\t\t'core/edit-widgets/keyboard-shortcuts',\n\t\ttoggleKeyboardShortcutsModal,\n\t\t{\n\t\t\tbindGlobal: true,\n\t\t}\n\t);\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tclassName=\"edit-widgets-more-menu\"\n\t\t\t\ticon={ moreVertical }\n\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\tlabel={ __( 'Options' ) }\n\t\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\t\ttoggleProps={ TOGGLE_PROPS }\n\t\t\t>\n\t\t\t\t{ () => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\t\tfeature=\"fixedToolbar\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Top toolbar deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsKeyboardShortcutsModalVisible( true );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"welcomeGuide\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/support/article/block-based-widgets-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t<MenuGroup label={ __( 'Preferences' ) }>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"keepCaretInsideBlock\"\n\t\t\t\t\t\t\t\tlabel={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block activated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t'Contain text cursor inside block deactivated'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\tfeature=\"themeStyles\"\n\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t'Make the editor look like your theme.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tlabel={ __( 'Use theme styles' ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ isLargeViewport && (\n\t\t\t\t\t\t\t\t<FeatureToggle\n\t\t\t\t\t\t\t\t\tfeature=\"showBlockBreadcrumbs\"\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Display block breadcrumbs' ) }\n\t\t\t\t\t\t\t\t\tinfo={ __(\n\t\t\t\t\t\t\t\t\t\t'Shows block breadcrumbs at the bottom of the editor.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageActivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs activated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tmessageDeactivated={ __(\n\t\t\t\t\t\t\t\t\t\t'Display block breadcrumbs deactivated'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</DropdownMenu>\n\t\t\t<KeyboardShortcutHelpModal\n\t\t\t\tisModalActive={ isKeyboardShortcutsModalActive }\n\t\t\t\ttoggleModal={ toggleKeyboardShortcutsModal }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"]}
@@ -19,6 +19,8 @@ var _i18n = require("@wordpress/i18n");
19
19
 
20
20
  var _url = require("@wordpress/url");
21
21
 
22
+ var _dom = require("@wordpress/dom");
23
+
22
24
  var _store = require("../../store");
23
25
 
24
26
  /**
@@ -49,7 +51,15 @@ function WidgetAreas({
49
51
  className: "edit-widgets-widget-areas__top-container"
50
52
  }, (0, _element.createElement)(_blockEditor.BlockIcon, {
51
53
  icon: _icons.blockDefault
52
- }), (0, _element.createElement)("div", null, (0, _element.createElement)("p", null, description), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && (0, _element.createElement)("p", null, (0, _i18n.__)('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && (0, _element.createElement)(_components.Button, {
54
+ }), (0, _element.createElement)("div", null, (0, _element.createElement)("p", {
55
+ // Use `dangerouslySetInnerHTML` to keep backwards
56
+ // compatibility. Basic markup in the description is an
57
+ // established feature of WordPress.
58
+ // @see https://github.com/WordPress/gutenberg/issues/33106
59
+ dangerouslySetInnerHTML: {
60
+ __html: (0, _dom.safeHTML)(description)
61
+ }
62
+ }), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && (0, _element.createElement)("p", null, (0, _i18n.__)('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && (0, _element.createElement)(_components.Button, {
53
63
  href: (0, _url.addQueryArgs)('customize.php', {
54
64
  'autofocus[panel]': 'widgets',
55
65
  return: window.location.pathname
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/sidebar/widget-areas.js"],"names":["WidgetAreas","selectedWidgetAreaId","widgetAreas","select","editWidgetsStore","getWidgetAreas","selectedWidgetArea","find","widgetArea","id","description","blockDefault","length","return","window","location","pathname"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAdA;AACA;AACA;;AASA;AACA;AACA;AAGe,SAASA,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAiD;AAC/D,QAAMC,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,cAA3B,EADK,EAEnB,EAFmB,CAApB;AAKA,QAAMC,kBAAkB,GAAG,sBAC1B,MACCL,oBAAoB,KACpBC,WADoB,aACpBA,WADoB,uBACpBA,WAAW,CAAEK,IAAb,CACGC,UAAF,IAAkBA,UAAU,CAACC,EAAX,KAAkBR,oBADrC,CADoB,CAFK,EAM1B,CAAEA,oBAAF,EAAwBC,WAAxB,CAN0B,CAA3B;AASA,MAAIQ,WAAJ;;AACA,MAAK,CAAEJ,kBAAP,EAA4B;AAC3BI,IAAAA,WAAW,GAAG,cACb,uJADa,CAAd;AAGA,GAJD,MAIO,IAAKT,oBAAoB,KAAK,qBAA9B,EAAsD;AAC5DS,IAAAA,WAAW,GAAG,cACb,gEADa,CAAd;AAGA,GAJM,MAIA;AACNA,IAAAA,WAAW,GAAGJ,kBAAkB,CAACI,WAAjC;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGC;AAAlB,IADD,EAEC,yCACC,uCAAKD,WAAL,CADD,EAEG,CAAAR,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEU,MAAb,MAAwB,CAAxB,IACD,uCACG,cACD,+CADC,CADH,CAHF,EASG,CAAEN,kBAAF,IACD,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAG,uBAAc,eAAd,EAA+B;AACrC,0BAAoB,SADiB;AAErCO,MAAAA,MAAM,EAAEC,MAAM,CAACC,QAAP,CAAgBC;AAFa,KAA/B,CADR;AAKC,IAAA,UAAU;AALX,KAOG,cAAI,0BAAJ,CAPH,CAVF,CAFD,CADD,CADD;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { blockDefault } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ blockDefault } />\n\t\t\t\t<div>\n\t\t\t\t\t<p>{ description }</p>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tisTertiary\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/sidebar/widget-areas.js"],"names":["WidgetAreas","selectedWidgetAreaId","widgetAreas","select","editWidgetsStore","getWidgetAreas","selectedWidgetArea","find","widgetArea","id","description","blockDefault","__html","length","return","window","location","pathname"],"mappings":";;;;;;;AAIA;;AADA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAfA;AACA;AACA;;AAUA;AACA;AACA;AAGe,SAASA,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAiD;AAC/D,QAAMC,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAA2BC,cAA3B,EADK,EAEnB,EAFmB,CAApB;AAKA,QAAMC,kBAAkB,GAAG,sBAC1B,MACCL,oBAAoB,KACpBC,WADoB,aACpBA,WADoB,uBACpBA,WAAW,CAAEK,IAAb,CACGC,UAAF,IAAkBA,UAAU,CAACC,EAAX,KAAkBR,oBADrC,CADoB,CAFK,EAM1B,CAAEA,oBAAF,EAAwBC,WAAxB,CAN0B,CAA3B;AASA,MAAIQ,WAAJ;;AACA,MAAK,CAAEJ,kBAAP,EAA4B;AAC3BI,IAAAA,WAAW,GAAG,cACb,uJADa,CAAd;AAGA,GAJD,MAIO,IAAKT,oBAAoB,KAAK,qBAA9B,EAAsD;AAC5DS,IAAAA,WAAW,GAAG,cACb,gEADa,CAAd;AAGA,GAJM,MAIA;AACNA,IAAAA,WAAW,GAAGJ,kBAAkB,CAACI,WAAjC;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGC;AAAlB,IADD,EAEC,yCACC;AACC;AACA;AACA;AACA;AACA,IAAA,uBAAuB,EAAG;AACzBC,MAAAA,MAAM,EAAE,mBAAUF,WAAV;AADiB;AAL3B,IADD,EAUG,CAAAR,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEW,MAAb,MAAwB,CAAxB,IACD,uCACG,cACD,+CADC,CADH,CAXF,EAiBG,CAAEP,kBAAF,IACD,4BAAC,kBAAD;AACC,IAAA,IAAI,EAAG,uBAAc,eAAd,EAA+B;AACrC,0BAAoB,SADiB;AAErCQ,MAAAA,MAAM,EAAEC,MAAM,CAACC,QAAP,CAAgBC;AAFa,KAA/B,CADR;AAKC,IAAA,UAAU;AALX,KAOG,cAAI,0BAAJ,CAPH,CAlBF,CAFD,CADD,CADD;AAoCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { blockDefault } from '@wordpress/icons';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs } from '@wordpress/url';\nimport { safeHTML } from '@wordpress/dom';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WidgetAreas( { selectedWidgetAreaId } ) {\n\tconst widgetAreas = useSelect(\n\t\t( select ) => select( editWidgetsStore ).getWidgetAreas(),\n\t\t[]\n\t);\n\n\tconst selectedWidgetArea = useMemo(\n\t\t() =>\n\t\t\tselectedWidgetAreaId &&\n\t\t\twidgetAreas?.find(\n\t\t\t\t( widgetArea ) => widgetArea.id === selectedWidgetAreaId\n\t\t\t),\n\t\t[ selectedWidgetAreaId, widgetAreas ]\n\t);\n\n\tlet description;\n\tif ( ! selectedWidgetArea ) {\n\t\tdescription = __(\n\t\t\t'Widget Areas are global parts in your site’s layout that can accept blocks. These vary by theme, but are typically parts like your Sidebar or Footer.'\n\t\t);\n\t} else if ( selectedWidgetAreaId === 'wp_inactive_widgets' ) {\n\t\tdescription = __(\n\t\t\t'Blocks in this Widget Area will not be displayed in your site.'\n\t\t);\n\t} else {\n\t\tdescription = selectedWidgetArea.description;\n\t}\n\n\treturn (\n\t\t<div className=\"edit-widgets-widget-areas\">\n\t\t\t<div className=\"edit-widgets-widget-areas__top-container\">\n\t\t\t\t<BlockIcon icon={ blockDefault } />\n\t\t\t\t<div>\n\t\t\t\t\t<p\n\t\t\t\t\t\t// Use `dangerouslySetInnerHTML` to keep backwards\n\t\t\t\t\t\t// compatibility. Basic markup in the description is an\n\t\t\t\t\t\t// established feature of WordPress.\n\t\t\t\t\t\t// @see https://github.com/WordPress/gutenberg/issues/33106\n\t\t\t\t\t\tdangerouslySetInnerHTML={ {\n\t\t\t\t\t\t\t__html: safeHTML( description ),\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t\t{ widgetAreas?.length === 0 && (\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Your theme does not contain any Widget Areas.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! selectedWidgetArea && (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\thref={ addQueryArgs( 'customize.php', {\n\t\t\t\t\t\t\t\t'autofocus[panel]': 'widgets',\n\t\t\t\t\t\t\t\treturn: window.location.pathname,\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t\tisTertiary\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Manage with live preview' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -9,6 +9,8 @@ var _data = require("@wordpress/data");
9
9
 
10
10
  var _blockEditor = require("@wordpress/block-editor");
11
11
 
12
+ var _store = require("../store");
13
+
12
14
  var _utils = require("../store/utils");
13
15
 
14
16
  /**
@@ -36,6 +38,15 @@ const useWidgetLibraryInsertionPoint = () => {
36
38
  getBlockOrder,
37
39
  getBlockIndex
38
40
  } = select(_blockEditor.store);
41
+
42
+ const insertionPoint = select(_store.store).__experimentalGetInsertionPoint(); // "Browse all" in the quick inserter will set the rootClientId to the current block.
43
+ // Otherwise, it will just be undefined, and we'll have to handle it differently below.
44
+
45
+
46
+ if (insertionPoint.rootClientId) {
47
+ return insertionPoint;
48
+ }
49
+
39
50
  const clientId = getBlockSelectionEnd() || firstRootId;
40
51
  const rootClientId = getBlockRootClientId(clientId); // If the selected block is at the root level, it's a widget area and
41
52
  // blocks can't be inserted here. Return this block as the root and the
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/hooks/use-widget-library-insertion-point.js"],"names":["useWidgetLibraryInsertionPoint","firstRootId","select","getEntityRecord","widgetAreasPost","KIND","POST_TYPE","blocks","clientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","blockEditorStore","rootClientId","insertionIndex","length"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,8BAA8B,GAAG,MAAM;AAC5C,QAAMC,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AAC5C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAE,MAAF,CAAlC;AACA,UAAME,eAAe,GAAGD,eAAe,CACtCE,WADsC,EAEtCC,gBAFsC,EAGtC,oCAHsC,CAAvC;AAKA,WAAOF,eAAP,aAAOA,eAAP,gDAAOA,eAAe,CAAEG,MAAjB,CAAyB,CAAzB,CAAP,0DAAO,sBAA8BC,QAArC;AACA,GATmB,EASjB,EATiB,CAApB;AAWA,SAAO,qBACJN,MAAF,IAAc;AACb,UAAM;AACLO,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFV,MAAM,CAAEW,kBAAF,CALV;AAOA,UAAML,QAAQ,GAAGE,oBAAoB,MAAMT,WAA3C;AACA,UAAMa,YAAY,GAAGL,oBAAoB,CAAED,QAAF,CAAzC,CATa,CAWb;AACA;AACA;;AACA,QAAKA,QAAQ,IAAIM,YAAY,KAAK,EAAlC,EAAuC;AACtC,aAAO;AACNA,QAAAA,YAAY,EAAEN,QADR;AAENO,QAAAA,cAAc,EAAEJ,aAAa,CAAEH,QAAF,CAAb,CAA0BQ;AAFpC,OAAP;AAIA;;AAED,WAAO;AACNF,MAAAA,YADM;AAENC,MAAAA,cAAc,EAAEH,aAAa,CAAEJ,QAAF,EAAYM,YAAZ,CAAb,GAA0C;AAFpD,KAAP;AAIA,GA1BK,EA2BN,CAAEb,WAAF,CA3BM,CAAP;AA6BA,CAzCD;;eA2CeD,8B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\nconst useWidgetLibraryInsertionPoint = () => {\n\tconst firstRootId = useSelect( ( select ) => {\n\t\t// Default to the first widget area\n\t\tconst { getEntityRecord } = select( 'core' );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockIndex,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst clientId = getBlockSelectionEnd() || firstRootId;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t// If the selected block is at the root level, it's a widget area and\n\t\t\t// blocks can't be inserted here. Return this block as the root and the\n\t\t\t// last child clientId indicating insertion at the end.\n\t\t\tif ( clientId && rootClientId === '' ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: clientId,\n\t\t\t\t\tinsertionIndex: getBlockOrder( clientId ).length,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trootClientId,\n\t\t\t\tinsertionIndex: getBlockIndex( clientId, rootClientId ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ firstRootId ]\n\t);\n};\n\nexport default useWidgetLibraryInsertionPoint;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/hooks/use-widget-library-insertion-point.js"],"names":["useWidgetLibraryInsertionPoint","firstRootId","select","getEntityRecord","widgetAreasPost","KIND","POST_TYPE","blocks","clientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","blockEditorStore","insertionPoint","editWidgetsStore","__experimentalGetInsertionPoint","rootClientId","insertionIndex","length"],"mappings":";;;;;;;AAGA;;AACA;;AAKA;;AACA;;AAVA;AACA;AACA;;AAIA;AACA;AACA;AAIA,MAAMA,8BAA8B,GAAG,MAAM;AAC5C,QAAMC,WAAW,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AAC5C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAE,MAAF,CAAlC;AACA,UAAME,eAAe,GAAGD,eAAe,CACtCE,WADsC,EAEtCC,gBAFsC,EAGtC,oCAHsC,CAAvC;AAKA,WAAOF,eAAP,aAAOA,eAAP,gDAAOA,eAAe,CAAEG,MAAjB,CAAyB,CAAzB,CAAP,0DAAO,sBAA8BC,QAArC;AACA,GATmB,EASjB,EATiB,CAApB;AAWA,SAAO,qBACJN,MAAF,IAAc;AACb,UAAM;AACLO,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFV,MAAM,CAAEW,kBAAF,CALV;;AAOA,UAAMC,cAAc,GAAGZ,MAAM,CAC5Ba,YAD4B,CAAN,CAErBC,+BAFqB,EAAvB,CARa,CAYb;AACA;;;AACA,QAAKF,cAAc,CAACG,YAApB,EAAmC;AAClC,aAAOH,cAAP;AACA;;AAED,UAAMN,QAAQ,GAAGE,oBAAoB,MAAMT,WAA3C;AACA,UAAMgB,YAAY,GAAGR,oBAAoB,CAAED,QAAF,CAAzC,CAnBa,CAqBb;AACA;AACA;;AACA,QAAKA,QAAQ,IAAIS,YAAY,KAAK,EAAlC,EAAuC;AACtC,aAAO;AACNA,QAAAA,YAAY,EAAET,QADR;AAENU,QAAAA,cAAc,EAAEP,aAAa,CAAEH,QAAF,CAAb,CAA0BW;AAFpC,OAAP;AAIA;;AAED,WAAO;AACNF,MAAAA,YADM;AAENC,MAAAA,cAAc,EAAEN,aAAa,CAAEJ,QAAF,EAAYS,YAAZ,CAAb,GAA0C;AAFpD,KAAP;AAIA,GApCK,EAqCN,CAAEhB,WAAF,CArCM,CAAP;AAuCA,CAnDD;;eAqDeD,8B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../store';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';\n\nconst useWidgetLibraryInsertionPoint = () => {\n\tconst firstRootId = useSelect( ( select ) => {\n\t\t// Default to the first widget area\n\t\tconst { getEntityRecord } = select( 'core' );\n\t\tconst widgetAreasPost = getEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreasPostId()\n\t\t);\n\t\treturn widgetAreasPost?.blocks[ 0 ]?.clientId;\n\t}, [] );\n\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockSelectionEnd,\n\t\t\t\tgetBlockOrder,\n\t\t\t\tgetBlockIndex,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tconst insertionPoint = select(\n\t\t\t\teditWidgetsStore\n\t\t\t).__experimentalGetInsertionPoint();\n\n\t\t\t// \"Browse all\" in the quick inserter will set the rootClientId to the current block.\n\t\t\t// Otherwise, it will just be undefined, and we'll have to handle it differently below.\n\t\t\tif ( insertionPoint.rootClientId ) {\n\t\t\t\treturn insertionPoint;\n\t\t\t}\n\n\t\t\tconst clientId = getBlockSelectionEnd() || firstRootId;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\t// If the selected block is at the root level, it's a widget area and\n\t\t\t// blocks can't be inserted here. Return this block as the root and the\n\t\t\t// last child clientId indicating insertion at the end.\n\t\t\tif ( clientId && rootClientId === '' ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: clientId,\n\t\t\t\t\tinsertionIndex: getBlockOrder( clientId ).length,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\trootClientId,\n\t\t\t\tinsertionIndex: getBlockIndex( clientId, rootClientId ) + 1,\n\t\t\t};\n\t\t},\n\t\t[ firstRootId ]\n\t);\n};\n\nexport default useWidgetLibraryInsertionPoint;\n"]}
package/build/index.js CHANGED
@@ -7,6 +7,7 @@ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWild
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
+ exports.reinitializeEditor = reinitializeEditor;
10
11
  exports.initialize = initialize;
11
12
 
12
13
  var _element = require("@wordpress/element");
@@ -37,6 +38,23 @@ var _constants = require("./constants");
37
38
  * Internal dependencies
38
39
  */
39
40
  const disabledBlocks = ['core/more', 'core/freeform', ...(!_constants.ALLOW_REUSABLE_BLOCKS && ['core/block'])];
41
+ /**
42
+ * Reinitializes the editor after the user chooses to reboot the editor after
43
+ * an unhandled error occurs, replacing previously mounted editor element using
44
+ * an initial state from prior to the crash.
45
+ *
46
+ * @param {Element} target DOM node in which editor is rendered.
47
+ * @param {?Object} settings Editor settings object.
48
+ */
49
+
50
+ function reinitializeEditor(target, settings) {
51
+ (0, _element.unmountComponentAtNode)(target);
52
+ const reboot = reinitializeEditor.bind(null, target, settings);
53
+ (0, _element.render)((0, _element.createElement)(_layout.default, {
54
+ blockEditorSettings: settings,
55
+ onError: reboot
56
+ }), target);
57
+ }
40
58
  /**
41
59
  * Initializes the block editor in the widgets screen.
42
60
  *
@@ -44,7 +62,10 @@ const disabledBlocks = ['core/more', 'core/freeform', ...(!_constants.ALLOW_REUS
44
62
  * @param {Object} settings Block editor settings.
45
63
  */
46
64
 
65
+
47
66
  function initialize(id, settings) {
67
+ const target = document.getElementById(id);
68
+ const reboot = reinitializeEditor.bind(null, target, settings);
48
69
  const coreBlocks = (0, _blockLibrary.__experimentalGetCoreBlocks)().filter(block => {
49
70
  return !(disabledBlocks.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site'));
50
71
  });
@@ -68,8 +89,9 @@ function initialize(id, settings) {
68
89
 
69
90
  (0, _blocks.setFreeformContentHandlerName)('core/html');
70
91
  (0, _element.render)((0, _element.createElement)(_layout.default, {
71
- blockEditorSettings: settings
72
- }), document.getElementById(id));
92
+ blockEditorSettings: settings,
93
+ onError: reboot
94
+ }), target);
73
95
  }
74
96
  /**
75
97
  * Function to register an individual block.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/index.js"],"names":["disabledBlocks","ALLOW_REUSABLE_BLOCKS","initialize","id","settings","coreBlocks","filter","block","includes","name","startsWith","process","env","GUTENBERG_PHASE","enableFSEBlocks","ENABLE_EXPERIMENTAL_FSE_BLOCKS","registerBlock","widgetArea","__experimentalFetchLinkSuggestions","search","searchOptions","document","getElementById","metadata"],"mappings":";;;;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAkBA;AACA;AACA;AAUA,MAAMA,cAAc,GAAG,CACtB,WADsB,EAEtB,eAFsB,EAGtB,IAAK,CAAEC,gCAAF,IAA2B,CAAE,YAAF,CAAhC,CAHsB,CAAvB;AAMA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,UAAT,CAAqBC,EAArB,EAAyBC,QAAzB,EAAoC;AAC1C,QAAMC,UAAU,GAAG,iDAA8BC,MAA9B,CAAwCC,KAAF,IAAa;AACrE,WAAO,EACNP,cAAc,CAACQ,QAAf,CAAyBD,KAAK,CAACE,IAA/B,KACAF,KAAK,CAACE,IAAN,CAAWC,UAAX,CAAuB,WAAvB,CADA,IAEAH,KAAK,CAACE,IAAN,CAAWC,UAAX,CAAuB,YAAvB,CAFA,IAGAH,KAAK,CAACE,IAAN,CAAWC,UAAX,CAAuB,WAAvB,CAJM,CAAP;AAMA,GAPkB,CAAnB;AASA,wCAAoBL,UAApB;AACA;;AACA,MAAKM,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAEC;AAD4B,KAA9C;AAGA;;AACD,+CAAgCX,QAAhC;AACAY,EAAAA,aAAa,CAAEC,UAAF,CAAb;;AACAb,EAAAA,QAAQ,CAACc,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6ChB,QAA7C,CADD,CAnB0C,CAsB1C;AACA;AACA;AACA;;;AACA,6CAA+B,WAA/B;AACA,uBACC,4BAAC,eAAD;AAAQ,IAAA,mBAAmB,EAAGA;AAA9B,IADD,EAECiB,QAAQ,CAACC,cAAT,CAAyBnB,EAAzB,CAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAMa,aAAa,GAAKT,KAAF,IAAa;AAClC,MAAK,CAAEA,KAAP,EAAe;AACd;AACA;;AACD,QAAM;AAAEgB,IAAAA,QAAF;AAAYnB,IAAAA,QAAZ;AAAsBK,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKgB,QAAL,EAAgB;AACf,+DAA+C;AAAE,OAAEd,IAAF,GAAUc;AAAZ,KAA/C;AACA;;AACD,iCAAmBd,IAAnB,EAAyBL,QAAzB;AACA,CATD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n} from '@wordpress/blocks';\nimport { render } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\nimport Layout from './components/layout';\nimport {\n\tALLOW_REUSABLE_BLOCKS,\n\tENABLE_EXPERIMENTAL_FSE_BLOCKS,\n} from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ),\n];\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initialize( id, settings ) {\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' )\n\t\t);\n\t} );\n\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\trender(\n\t\t<Layout blockEditorSettings={ settings } />,\n\t\tdocument.getElementById( id )\n\t);\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n *\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/index.js"],"names":["disabledBlocks","ALLOW_REUSABLE_BLOCKS","reinitializeEditor","target","settings","reboot","bind","initialize","id","document","getElementById","coreBlocks","filter","block","includes","name","startsWith","process","env","GUTENBERG_PHASE","enableFSEBlocks","ENABLE_EXPERIMENTAL_FSE_BLOCKS","registerBlock","widgetArea","__experimentalFetchLinkSuggestions","search","searchOptions","metadata"],"mappings":";;;;;;;;;;;;AAQA;;AALA;;AAMA;;AAKA;;AACA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AA3BA;AACA;AACA;;AAkBA;AACA;AACA;AAUA,MAAMA,cAAc,GAAG,CACtB,WADsB,EAEtB,eAFsB,EAGtB,IAAK,CAAEC,gCAAF,IAA2B,CAAE,YAAF,CAAhC,CAHsB,CAAvB;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAAgD;AACtD,uCAAwBD,MAAxB;AACA,QAAME,MAAM,GAAGH,kBAAkB,CAACI,IAAnB,CAAyB,IAAzB,EAA+BH,MAA/B,EAAuCC,QAAvC,CAAf;AACA,uBACC,4BAAC,eAAD;AAAQ,IAAA,mBAAmB,EAAGA,QAA9B;AAAyC,IAAA,OAAO,EAAGC;AAAnD,IADD,EAECF,MAFD;AAIA;AAED;AACA;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F;AAAYvB,IAAAA,QAAZ;AAAsBW,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKc,QAAL,EAAgB;AACf,+DAA+C;AAAE,OAAEZ,IAAF,GAAUY;AAAZ,KAA/C;AACA;;AACD,iCAAmBZ,IAAnB,EAAyBX,QAAzB;AACA,CATD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n} from '@wordpress/blocks';\nimport { render, unmountComponentAtNode } from '@wordpress/element';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterLegacyWidgetVariations,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\nimport Layout from './components/layout';\nimport {\n\tALLOW_REUSABLE_BLOCKS,\n\tENABLE_EXPERIMENTAL_FSE_BLOCKS,\n} from './constants';\n\nconst disabledBlocks = [\n\t'core/more',\n\t'core/freeform',\n\t...( ! ALLOW_REUSABLE_BLOCKS && [ 'core/block' ] ),\n];\n\n/**\n * Reinitializes the editor after the user chooses to reboot the editor after\n * an unhandled error occurs, replacing previously mounted editor element using\n * an initial state from prior to the crash.\n *\n * @param {Element} target DOM node in which editor is rendered.\n * @param {?Object} settings Editor settings object.\n */\nexport function reinitializeEditor( target, settings ) {\n\tunmountComponentAtNode( target );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\trender(\n\t\t<Layout blockEditorSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\n}\n\n/**\n * Initializes the block editor in the widgets screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Block editor settings.\n */\nexport function initialize( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst reboot = reinitializeEditor.bind( null, target, settings );\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter( ( block ) => {\n\t\treturn ! (\n\t\t\tdisabledBlocks.includes( block.name ) ||\n\t\t\tblock.name.startsWith( 'core/post' ) ||\n\t\t\tblock.name.startsWith( 'core/query' ) ||\n\t\t\tblock.name.startsWith( 'core/site' )\n\t\t);\n\t} );\n\n\tregisterCoreBlocks( coreBlocks );\n\tregisterLegacyWidgetBlock();\n\tif ( process.env.GUTENBERG_PHASE === 2 ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: ENABLE_EXPERIMENTAL_FSE_BLOCKS,\n\t\t} );\n\t}\n\tregisterLegacyWidgetVariations( settings );\n\tregisterBlock( widgetArea );\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\n\t// As we are unregistering `core/freeform` to avoid the Classic block, we must\n\t// replace it with something as the default freeform content handler. Failure to\n\t// do this will result in errors in the default block parser.\n\t// see: https://github.com/WordPress/gutenberg/issues/33097\n\tsetFreeformContentHandlerName( 'core/html' );\n\trender(\n\t\t<Layout blockEditorSettings={ settings } onError={ reboot } />,\n\t\ttarget\n\t);\n}\n\n/**\n * Function to register an individual block.\n *\n * @param {Object} block The block to be registered.\n *\n */\nconst registerBlock = ( block ) => {\n\tif ( ! block ) {\n\t\treturn;\n\t}\n\tconst { metadata, settings, name } = block;\n\tif ( metadata ) {\n\t\tunstable__bootstrapServerSideBlockDefinitions( { [ name ]: metadata } );\n\t}\n\tregisterBlockType( name, settings );\n};\n"]}
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isInserterOpened = isInserterOpened;
7
+ exports.__experimentalGetInsertionPoint = __experimentalGetInsertionPoint;
7
8
  exports.__unstableIsFeatureActive = __unstableIsFeatureActive;
8
9
  exports.canInsertBlockInWidgetArea = exports.getIsWidgetAreaOpen = exports.isSavingWidgetAreas = exports.getReferenceWidgetBlocks = exports.getEditedWidgetAreas = exports.getParentWidgetAreaBlock = exports.getWidgetAreaForWidgetId = exports.getWidgetAreas = exports.getWidget = exports.getWidgets = void 0;
9
10
 
@@ -193,6 +194,25 @@ exports.getIsWidgetAreaOpen = getIsWidgetAreaOpen;
193
194
  function isInserterOpened(state) {
194
195
  return !!state.blockInserterPanel;
195
196
  }
197
+ /**
198
+ * Get the insertion point for the inserter.
199
+ *
200
+ * @param {Object} state Global application state.
201
+ *
202
+ * @return {Object} The root client ID and index to insert at.
203
+ */
204
+
205
+
206
+ function __experimentalGetInsertionPoint(state) {
207
+ const {
208
+ rootClientId,
209
+ insertionIndex
210
+ } = state.blockInserterPanel;
211
+ return {
212
+ rootClientId,
213
+ insertionIndex
214
+ };
215
+ }
196
216
  /**
197
217
  * Returns true if a block can be inserted into a widget area.
198
218
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["getWidgets","select","widgets","getEntityRecords","getWidget","state","id","editWidgetsStoreName","getWidgetAreas","query","KIND","WIDGET_AREA_ENTITY_TYPE","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","POST_TYPE","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","__unstableIsFeatureActive","feature","preferences","features"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;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AAP;AAIA,CAbwC,CAAnC;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASmC,yBAAT,CAAoCxD,KAApC,EAA2CyD,OAA3C,EAAqD;AAC3D,SAAO,iBAAKzD,KAAK,CAAC0D,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, keyBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( 'core' ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn keyBy( widgets, 'id' );\n} );\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( 'core' ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( 'core' ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } = select(\n\t\t\t'core/block-editor'\n\t\t);\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( 'core' ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( 'core' ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) => ( state, referenceWidgetName = null ) => {\n\t\tconst results = [];\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\tconst post = select( 'core' ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t);\n\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\tif (\n\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t) {\n\t\t\t\t\tresults.push( block );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n);\n\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( 'core' ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( 'core' ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( 'core/block-editor' ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( 'core/block-editor' ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * This function is unstable, as it is mostly copied from the edit-post\n * package. Editor features and preferences have a lot of scope for\n * being generalized and refactored.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function __unstableIsFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["getWidgets","select","widgets","getEntityRecords","getWidget","state","id","editWidgetsStoreName","getWidgetAreas","query","KIND","WIDGET_AREA_ENTITY_TYPE","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","POST_TYPE","blockWidgetIds","blocks","map","block","includes","getParentWidgetAreaBlock","clientId","getBlock","getBlockName","getBlockParents","blockParents","widgetAreaClientId","parentClientId","getEditedWidgetAreas","ids","filter","hasEditsForEntityRecord","getReferenceWidgetBlocks","referenceWidgetName","results","_widgetArea","name","attributes","push","isSavingWidgetAreas","widgetAreasIds","isSaving","isSavingEntityRecord","widgetIds","Object","keys","undefined","getIsWidgetAreaOpen","widgetAreasOpenState","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","canInsertBlockInWidgetArea","blockName","getBlocks","firstWidgetArea","canInsertBlockType","__unstableIsFeatureActive","feature","preferences","features"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAQA;;AAtBA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAWO,MAAMA,UAAU,GAAG,kCAA0BC,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAE,MAAF,CAAN,CAAiBE,gBAAjB,CACf,MADe,EAEf,QAFe,EAGf,+BAHe,CAAhB;AAMA,SAAO,mBAAOD,OAAP,EAAgB,IAAhB,CAAP;AACA,CARyB,CAAnB;AAUP;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAME,SAAS,GAAG,kCACtBH,MAAF,IAAc,CAAEI,KAAF,EAASC,EAAT,KAAiB;AAC9B,QAAMJ,OAAO,GAAGD,MAAM,CAAEM,qBAAF,CAAN,CAA+BP,UAA/B,EAAhB;AACA,SAAOE,OAAO,CAAEI,EAAF,CAAd;AACA,CAJuB,CAAlB;;AAOA,MAAME,cAAc,GAAG,kCAA0BP,MAAF,IAAc,MAAM;AACzE,QAAMQ,KAAK,GAAG,mCAAd;AACA,SAAOR,M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B,IAAAA;AAAF,MAA2BhD,KAAjC;AACA,SAAO,CAAC,CAAEgD,oBAAoB,CAAE3B,QAAF,CAA9B;AACA,CAHM;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAAS4B,gBAAT,CAA2BjD,KAA3B,EAAmC;AACzC,SAAO,CAAC,CAAEA,KAAK,CAACkD,kBAAhB;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASC,+BAAT,CAA0CnD,KAA1C,EAAkD;AACxD,QAAM;AAAEoD,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,MAAmCrD,KAAK,CAACkD,kBAA/C;AACA,SAAO;AAAEE,IAAAA,YAAF;AAAgBC,IAAAA;AAAhB,GAAP;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,MAAMC,0BAA0B,GAAG,kCACvC1D,MAAF,IAAc,CAAEI,KAAF,EAASuD,SAAT,KAAwB;AACrC;AACA,QAAM9C,WAAW,GAAGb,MAAM,CAAE,mBAAF,CAAN,CAA8B4D,SAA9B,EAApB,CAFqC,CAIrC;AACA;AACA;;AACA,QAAM,CAAEC,eAAF,IAAsBhD,WAA5B;AACA,SAAOb,MAAM,CAAE,mBAAF,CAAN,CAA8B8D,kBAA9B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAbwC,CAAnC;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,SAASsC,yBAAT,CAAoC3D,KAApC,EAA2C4D,OAA3C,EAAqD;AAC3D,SAAO,iBAAK5D,KAAK,CAAC6D,WAAN,CAAkBC,QAAvB,EAAiC,CAAEF,OAAF,CAAjC,EAA8C,KAA9C,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport { get, keyBy } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport {\n\tbuildWidgetsQuery,\n\tbuildWidgetAreasQuery,\n\tbuildWidgetAreaPostId,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\nexport const getWidgets = createRegistrySelector( ( select ) => () => {\n\tconst widgets = select( 'core' ).getEntityRecords(\n\t\t'root',\n\t\t'widget',\n\t\tbuildWidgetsQuery()\n\t);\n\n\treturn keyBy( widgets, 'id' );\n} );\n\n/**\n * Returns API widget data for a particular widget ID.\n *\n * @param {number} id Widget ID\n * @return {Object} API widget data for a particular widget ID.\n */\nexport const getWidget = createRegistrySelector(\n\t( select ) => ( state, id ) => {\n\t\tconst widgets = select( editWidgetsStoreName ).getWidgets();\n\t\treturn widgets[ id ];\n\t}\n);\n\nexport const getWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst query = buildWidgetAreasQuery();\n\treturn select( 'core' ).getEntityRecords(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\tquery\n\t);\n} );\n\n/**\n * Returns widgetArea containing a block identify by given widgetId\n *\n * @param {string} widgetId The ID of the widget.\n * @return {Object} Containing widget area.\n */\nexport const getWidgetAreaForWidgetId = createRegistrySelector(\n\t( select ) => ( state, widgetId ) => {\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\treturn widgetAreas.find( ( widgetArea ) => {\n\t\t\tconst post = select( 'core' ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( widgetArea.id )\n\t\t\t);\n\t\t\tconst blockWidgetIds = post.blocks.map( ( block ) =>\n\t\t\t\tgetWidgetIdFromBlock( block )\n\t\t\t);\n\t\t\treturn blockWidgetIds.includes( widgetId );\n\t\t} );\n\t}\n);\n\n/**\n * Given a child client id, returns the parent widget area block.\n *\n * @param {string} clientId The client id of a block in a widget area.\n *\n * @return {WPBlock} The widget area block.\n */\nexport const getParentWidgetAreaBlock = createRegistrySelector(\n\t( select ) => ( state, clientId ) => {\n\t\tconst { getBlock, getBlockName, getBlockParents } = select(\n\t\t\t'core/block-editor'\n\t\t);\n\t\tconst blockParents = getBlockParents( clientId );\n\t\tconst widgetAreaClientId = blockParents.find(\n\t\t\t( parentClientId ) =>\n\t\t\t\tgetBlockName( parentClientId ) === 'core/widget-area'\n\t\t);\n\t\treturn getBlock( widgetAreaClientId );\n\t}\n);\n\nexport const getEditedWidgetAreas = createRegistrySelector(\n\t( select ) => ( state, ids ) => {\n\t\tlet widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tif ( ! widgetAreas ) {\n\t\t\treturn [];\n\t\t}\n\t\tif ( ids ) {\n\t\t\twidgetAreas = widgetAreas.filter( ( { id } ) =>\n\t\t\t\tids.includes( id )\n\t\t\t);\n\t\t}\n\t\treturn widgetAreas\n\t\t\t.filter( ( { id } ) =>\n\t\t\t\tselect( 'core' ).hasEditsForEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tPOST_TYPE,\n\t\t\t\t\tbuildWidgetAreaPostId( id )\n\t\t\t\t)\n\t\t\t)\n\t\t\t.map( ( { id } ) =>\n\t\t\t\tselect( 'core' ).getEditedEntityRecord(\n\t\t\t\t\tKIND,\n\t\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\t\tid\n\t\t\t\t)\n\t\t\t);\n\t}\n);\n\n/**\n * Returns all blocks representing reference widgets.\n *\n * @param {string} referenceWidgetName Optional. If given, only reference widgets with this name will be returned.\n * @return {Array} List of all blocks representing reference widgets\n */\nexport const getReferenceWidgetBlocks = createRegistrySelector(\n\t( select ) => ( state, referenceWidgetName = null ) => {\n\t\tconst results = [];\n\t\tconst widgetAreas = select( editWidgetsStoreName ).getWidgetAreas();\n\t\tfor ( const _widgetArea of widgetAreas ) {\n\t\t\tconst post = select( 'core' ).getEditedEntityRecord(\n\t\t\t\tKIND,\n\t\t\t\tPOST_TYPE,\n\t\t\t\tbuildWidgetAreaPostId( _widgetArea.id )\n\t\t\t);\n\t\t\tfor ( const block of post.blocks ) {\n\t\t\t\tif (\n\t\t\t\t\tblock.name === 'core/legacy-widget' &&\n\t\t\t\t\t( ! referenceWidgetName ||\n\t\t\t\t\t\tblock.attributes?.referenceWidgetName ===\n\t\t\t\t\t\t\treferenceWidgetName )\n\t\t\t\t) {\n\t\t\t\t\tresults.push( block );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n);\n\nexport const isSavingWidgetAreas = createRegistrySelector( ( select ) => () => {\n\tconst widgetAreasIds = select( editWidgetsStoreName )\n\t\t.getWidgetAreas()\n\t\t?.map( ( { id } ) => id );\n\tif ( ! widgetAreasIds ) {\n\t\treturn false;\n\t}\n\n\tfor ( const id of widgetAreasIds ) {\n\t\tconst isSaving = select( 'core' ).isSavingEntityRecord(\n\t\t\tKIND,\n\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst widgetIds = [\n\t\t...Object.keys( select( editWidgetsStoreName ).getWidgets() ),\n\t\tundefined, // account for new widgets without an ID\n\t];\n\tfor ( const id of widgetIds ) {\n\t\tconst isSaving = select( 'core' ).isSavingEntityRecord(\n\t\t\t'root',\n\t\t\t'widget',\n\t\t\tid\n\t\t);\n\t\tif ( isSaving ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\n\treturn false;\n} );\n\n/**\n * Gets whether the widget area is opened.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} clientId The clientId of the widget area.\n * @return {boolean} True if the widget area is open.\n */\nexport const getIsWidgetAreaOpen = ( state, clientId ) => {\n\tconst { widgetAreasOpenState } = state;\n\treturn !! widgetAreasOpenState[ clientId ];\n};\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID and index to insert at.\n */\nexport function __experimentalGetInsertionPoint( state ) {\n\tconst { rootClientId, insertionIndex } = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex };\n}\n\n/**\n * Returns true if a block can be inserted into a widget area.\n *\n * @param {Array} state The open state of the widget areas.\n * @param {string} blockName The name of the block being inserted.\n *\n * @return {boolean} True if the block can be inserted in a widget area.\n */\nexport const canInsertBlockInWidgetArea = createRegistrySelector(\n\t( select ) => ( state, blockName ) => {\n\t\t// Widget areas are always top-level blocks, which getBlocks will return.\n\t\tconst widgetAreas = select( 'core/block-editor' ).getBlocks();\n\n\t\t// Makes an assumption that a block that can be inserted into one\n\t\t// widget area can be inserted into any widget area. Uses the first\n\t\t// widget area for testing whether the block can be inserted.\n\t\tconst [ firstWidgetArea ] = widgetAreas;\n\t\treturn select( 'core/block-editor' ).canInsertBlockType(\n\t\t\tblockName,\n\t\t\tfirstWidgetArea.clientId\n\t\t);\n\t}\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * This function is unstable, as it is mostly copied from the edit-post\n * package. Editor features and preferences have a lot of scope for\n * being generalized and refactored.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function __unstableIsFeatureActive( state, feature ) {\n\treturn get( state.preferences.features, [ feature ], false );\n}\n"]}
@@ -69,7 +69,9 @@ export default function WidgetAreaEdit({
69
69
  kind: "root",
70
70
  type: "postType",
71
71
  id: `widget-area-${id}`
72
- }, createElement(WidgetAreaInnerBlocks, null)))));
72
+ }, createElement(WidgetAreaInnerBlocks, {
73
+ id: id
74
+ })))));
73
75
  }
74
76
  /**
75
77
  * A React hook to determine if dragging is active.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","opened","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,WAA9B,EAA2CC,MAA3C,QAAyD,oBAAzD;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,cAAT,QAA+B,sBAA/B;AACA,SACCC,2BAA2B,IAAIC,iBADhC,EAECC,KAFD,EAGCC,SAHD,QAIO,uBAJP;AAMA;AACA;AACA;;AACA,OAAOC,qBAAP,MAAkC,gBAAlC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,gBAA1C;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA;;AAEA,eAAe,SAASC,cAAT,CAAyB;AACvCC,EAAAA,QADuC;AAEvCC,EAAAA,SAFuC;AAGvCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,EAAF;AAAMC,IAAAA;AAAN;AAH2B,CAAzB,EAIX;AACH,QAAMC,MAAM,GAAGjB,SAAS,CACrBkB,MAAF,IACCA,MAAM,CAAET,gBAAF,CAAN,CAA2BU,mBAA3B,CAAgDP,QAAhD,CAFsB,EAGvB,CAAEA,QAAF,CAHuB,CAAxB;AAKA,QAAM;AAAEQ,IAAAA;AAAF,MAA0BnB,WAAW,CAAEQ,gBAAF,CAA3C;AAEA,QAAMY,OAAO,GAAGtB,MAAM,EAAtB;AACA,QAAMuB,OAAO,GAAGxB,WAAW,CACxByB,SAAF,IAAiBH,mBAAmB,CAAER,QAAF,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AE,EAAI,eAAed,EAAI;AAH1B,KAKC,cAAC,qBAAD,OALD,CAJD,CAbF,CADD,CADD;AA+BA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMU,aAAa,GAAKK,UAAF,IAAkB;AACvC,QAAM,CAAEN,UAAF,EAAcO,aAAd,IAAgClC,QAAQ,CAAE,KAAF,CAA9C;AAEAD,EAAAA,SAAS,CAAE,MAAM;AAChB,UAAM;AAAEoC,MAAAA;AAAF,QAAoBF,UAAU,CAACG,OAArC;;AAEA,aAASC,eAAT,GAA2B;AAC1BH,MAAAA,aAAa,CAAE,IAAF,CAAb;AACA;;AAED,aAASI,aAAT,GAAyB;AACxBJ,MAAAA,aAAa,CAAE,KAAF,CAAb;AACA;;AAEDC,IAAAA,aAAa,CAACI,gBAAd,CAAgC,WAAhC,EAA6CF,eAA7C;AACAF,IAAAA,aAAa,CAACI,gBAAd,CAAgC,SAAhC,EAA2CD,aAA3C;AAEA,WAAO,MAAM;AACZH,MAAAA,aAAa,CAACK,mBAAd,CAAmC,WAAnC,EAAgDH,eAAhD;AACAF,MAAAA,aAAa,CAACK,mBAAd,CAAmC,SAAnC,EAA8CF,aAA9C;AACA,KAHD;AAIA,GAlBQ,EAkBN,EAlBM,CAAT;AAoBA,SAAOX,UAAP;AACA,CAxBD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/index.js"],"names":["useEffect","useState","useCallback","useRef","useSelect","useDispatch","EntityProvider","__unstableDisclosureContent","DisclosureContent","Panel","PanelBody","WidgetAreaInnerBlocks","store","editWidgetsStore","useIsDraggingWithin","WidgetAreaEdit","clientId","className","attributes","id","name","isOpen","select","getIsWidgetAreaOpen","setIsWidgetAreaOpen","wrapper","setOpen","openState","isDragging","useIsDragging","isDraggingWithin","openedWhileDragging","setOpenedWhileDragging","opened","elementRef","setIsDragging","ownerDocument","current","handleDragStart","handleDragEnd","addEventListener","removeEventListener"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,QAApB,EAA8BC,WAA9B,EAA2CC,MAA3C,QAAyD,oBAA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ED,aAASI,aAAT,GAAyB;AACxBJ,MAAAA,aAAa,CAAE,KAAF,CAAb;AACA;;AAEDC,IAAAA,aAAa,CAACI,gBAAd,CAAgC,WAAhC,EAA6CF,eAA7C;AACAF,IAAAA,aAAa,CAACI,gBAAd,CAAgC,SAAhC,EAA2CD,aAA3C;AAEA,WAAO,MAAM;AACZH,MAAAA,aAAa,CAACK,mBAAd,CAAmC,WAAnC,EAAgDH,eAAhD;AACAF,MAAAA,aAAa,CAACK,mBAAd,CAAmC,SAAnC,EAA8CF,aAA9C;AACA,KAHD;AAIA,GAlBQ,EAkBN,EAlBM,CAAT;AAoBA,SAAOX,UAAP;AACA,CAxBD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useState, useCallback, useRef } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { EntityProvider } from '@wordpress/core-data';\nimport {\n\t__unstableDisclosureContent as DisclosureContent,\n\tPanel,\n\tPanelBody,\n} from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport WidgetAreaInnerBlocks from './inner-blocks';\nimport { store as editWidgetsStore } from '../../../store';\nimport useIsDraggingWithin from './use-is-dragging-within';\n\n/** @typedef {import('@wordpress/element').RefObject} RefObject */\n\nexport default function WidgetAreaEdit( {\n\tclientId,\n\tclassName,\n\tattributes: { id, name },\n} ) {\n\tconst isOpen = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getIsWidgetAreaOpen( clientId ),\n\t\t[ clientId ]\n\t);\n\tconst { setIsWidgetAreaOpen } = useDispatch( editWidgetsStore );\n\n\tconst wrapper = useRef();\n\tconst setOpen = useCallback(\n\t\t( openState ) => setIsWidgetAreaOpen( clientId, openState ),\n\t\t[ clientId ]\n\t);\n\tconst isDragging = useIsDragging( wrapper );\n\tconst isDraggingWithin = useIsDraggingWithin( wrapper );\n\n\tconst [ openedWhileDragging, setOpenedWhileDragging ] = useState( false );\n\tuseEffect( () => {\n\t\tif ( ! isDragging ) {\n\t\t\tsetOpenedWhileDragging( false );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isDraggingWithin && ! isOpen ) {\n\t\t\tsetOpen( true );\n\t\t\tsetOpenedWhileDragging( true );\n\t\t} else if ( ! isDraggingWithin && isOpen && openedWhileDragging ) {\n\t\t\tsetOpen( false );\n\t\t}\n\t}, [ isOpen, isDragging, isDraggingWithin, openedWhileDragging ] );\n\n\treturn (\n\t\t<Panel className={ className } ref={ wrapper }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={ name }\n\t\t\t\topened={ isOpen }\n\t\t\t\tonToggle={ () => {\n\t\t\t\t\tsetIsWidgetAreaOpen( clientId, ! isOpen );\n\t\t\t\t} }\n\t\t\t\tscrollAfterOpen={ ! isDragging }\n\t\t\t>\n\t\t\t\t{ ( { opened } ) => (\n\t\t\t\t\t// This is required to ensure LegacyWidget blocks are not\n\t\t\t\t\t// unmounted when the panel is collapsed. Unmounting legacy\n\t\t\t\t\t// widgets may have unintended consequences (e.g. TinyMCE\n\t\t\t\t\t// not being properly reinitialized)\n\t\t\t\t\t<DisclosureContent\n\t\t\t\t\t\tclassName=\"wp-block-widget-area__panel-body-content\"\n\t\t\t\t\t\tvisible={ opened }\n\t\t\t\t\t>\n\t\t\t\t\t\t<EntityProvider\n\t\t\t\t\t\t\tkind=\"root\"\n\t\t\t\t\t\t\ttype=\"postType\"\n\t\t\t\t\t\t\tid={ `widget-area-${ id }` }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<WidgetAreaInnerBlocks id={ id } />\n\t\t\t\t\t\t</EntityProvider>\n\t\t\t\t\t</DisclosureContent>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</Panel>\n\t);\n}\n\n/**\n * A React hook to determine if dragging is active.\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the entire document.\n */\nconst useIsDragging = ( elementRef ) => {\n\tconst [ isDragging, setIsDragging ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart() {\n\t\t\tsetIsDragging( true );\n\t\t}\n\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDragging( false );\n\t\t}\n\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t};\n\t}, [] );\n\n\treturn isDragging;\n};\n"]}