@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
@@ -16,7 +16,9 @@ import { useRef } from '@wordpress/element';
16
16
  */
17
17
 
18
18
  import useIsDraggingWithin from './use-is-dragging-within';
19
- export default function WidgetAreaInnerBlocks() {
19
+ export default function WidgetAreaInnerBlocks({
20
+ id
21
+ }) {
20
22
  const [blocks, onInput, onChange] = useEntityBlockEditor('root', 'postType');
21
23
  const innerBlocksRef = useRef();
22
24
  const isDraggingWithinInnerBlocks = useIsDraggingWithin(innerBlocksRef);
@@ -33,6 +35,7 @@ export default function WidgetAreaInnerBlocks() {
33
35
  });
34
36
 
35
37
  return createElement("div", {
38
+ "data-widget-area-id": id,
36
39
  className: classnames('wp-block-widget-area__inner-blocks block-editor-inner-blocks editor-styles-wrapper', {
37
40
  'wp-block-widget-area__highlight-drop-zone': shouldHighlightDropZone
38
41
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/blocks/widget-area/edit/inner-blocks.js"],"names":["classnames","useEntityBlockEditor","InnerBlocks","__experimentalUseInnerBlocksProps","useRef","useIsDraggingWithin","WidgetAreaInnerBlocks","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","ButtonBlockAppender"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACCC,WADD,EAECC,iCAFD,QAGO,yBAHP;AAIA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA,eAAe,SAASC,qBAAT,GAAiC;AAC/C,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCR,oBAAoB,CACzD,MADyD,EAEzD,UAFyD,CAA1D;AAIA,QAAMS,cAAc,GAAGN,MAAM,EAA7B;AACA,QAAMO,2BAA2B,GAAGN,mBAAmB,CAAEK,cAAF,CAAvD;AACA,QAAME,uBAAuB,GAAGD,2BAAhC,CAP+C,CAQ/C;;AACA,QAAME,gBAAgB,GAAGV,iCAAiC,CACzD;AAAEW,IAAAA,GAAG,EAAEJ;AAAP,GADyD,EAEzD;AACCK,IAAAA,KAAK,EAAER,MADR;AAECC,IAAAA,OAFD;AAGCC,IAAAA,QAHD;AAICO,IAAAA,YAAY,EAAE,KAJf;AAKCC,IAAAA,cAAc,EAAEf,WAAW,CAACgB;AAL7B,GAFyD,CAA1D;;AAWA,SACC;AACC,IAAA,SAAS,EAAGlB,UAAU,CACrB,oFADqB,EAErB;AACC,mDAA6CY;AAD9C,KAFqB;AADvB,KAQC,qBAAUC,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":["classnames","useEntityBlockEditor","InnerBlocks","__experimentalUseInnerBlocksProps","useRef","useIsDraggingWithin","WidgetAreaInnerBlocks","id","blocks","onInput","onChange","innerBlocksRef","isDraggingWithinInnerBlocks","shouldHighlightDropZone","innerBlocksProps","ref","value","templateLock","renderAppender","ButtonBlockAppender"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,oBAAT,QAAqC,sBAArC;AACA,SACCC,WADD,EAECC,iCAFD,QAGO,yBAHP;AAIA,SAASC,MAAT,QAAuB,oBAAvB;AAEA;AACA;AACA;;AACA,OAAOC,mBAAP,MAAgC,0BAAhC;AAEA,eAAe,SAASC,qBAAT,CAAgC;AAAEC,EAAAA;AAAF,CAAhC,EAAyC;AACvD,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgCT,oBAAoB,CACzD,MADyD,EAEzD,UAFyD,CAA1D;AAIA,QAAMU,cAAc,GAAGP,MAAM,EAA7B;AACA,QAAMQ,2BAA2B,GAAGP,mBAAmB,CAAEM,cAAF,CAAvD;AACA,QAAME,uBAAuB,GAAGD,2BAAhC,CAPuD,CAQvD;;AACA,QAAME,gBAAgB,GAAGX,iCAAiC,CACzD;AAAEY,IAAAA,GAAG,EAAEJ;AAAP,GADyD,EAEzD;AACCK,IAAAA,KAAK,EAAER,MADR;AAECC,IAAAA,OAFD;AAGCC,IAAAA,QAHD;AAICO,IAAAA,YAAY,EAAE,KAJf;AAKCC,IAAAA,cAAc,EAAEhB,WAAW,CAACiB;AAL7B,GAFyD,CAA1D;;AAWA,SACC;AACC,2BAAsBZ,EADvB;AAEC,IAAA,SAAS,EAAGP,UAAU,CACrB,oFADqB,EAErB;AACC,mDAA6Ca;AAD9C,KAFqB;AAFvB,KASC,qBAAUC,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,65 @@
1
+ import { createElement } from "@wordpress/element";
2
+
3
+ /**
4
+ * WordPress dependencies
5
+ */
6
+ import { Component } from '@wordpress/element';
7
+ import { __ } from '@wordpress/i18n';
8
+ import { Button } from '@wordpress/components';
9
+ import { Warning } from '@wordpress/block-editor';
10
+ import { useCopyToClipboard } from '@wordpress/compose';
11
+
12
+ function CopyButton({
13
+ text,
14
+ children
15
+ }) {
16
+ const ref = useCopyToClipboard(text);
17
+ return createElement(Button, {
18
+ variant: "secondary",
19
+ ref: ref
20
+ }, children);
21
+ }
22
+
23
+ export default class ErrorBoundary extends Component {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.reboot = this.reboot.bind(this);
27
+ this.state = {
28
+ error: null
29
+ };
30
+ }
31
+
32
+ componentDidCatch(error) {
33
+ this.setState({
34
+ error
35
+ });
36
+ }
37
+
38
+ reboot() {
39
+ this.props.onError();
40
+ }
41
+
42
+ render() {
43
+ const {
44
+ error
45
+ } = this.state;
46
+
47
+ if (!error) {
48
+ return this.props.children;
49
+ }
50
+
51
+ return createElement(Warning, {
52
+ className: "edit-widgets-error-boundary",
53
+ actions: [createElement(Button, {
54
+ key: "recovery",
55
+ onClick: this.reboot,
56
+ variant: "secondary"
57
+ }, __('Attempt Recovery')), createElement(CopyButton, {
58
+ key: "copy-error",
59
+ text: error.stack
60
+ }, __('Copy Error'))]
61
+ }, __('The editor has encountered an unexpected error.'));
62
+ }
63
+
64
+ }
65
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/error-boundary/index.js"],"names":["Component","__","Button","Warning","useCopyToClipboard","CopyButton","text","children","ref","ErrorBoundary","constructor","arguments","reboot","bind","state","error","componentDidCatch","setState","props","onError","render","stack"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,oBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,OAAT,QAAwB,yBAAxB;AACA,SAASC,kBAAT,QAAmC,oBAAnC;;AAEA,SAASC,UAAT,CAAqB;AAAEC,EAAAA,IAAF;AAAQC,EAAAA;AAAR,CAArB,EAA0C;AACzC,QAAMC,GAAG,GAAGJ,kBAAkB,CAAEE,IAAF,CAA9B;AACA,SACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,WAAhB;AAA4B,IAAA,GAAG,EAAGE;AAAlC,KACGD,QADH,CADD;AAKA;;AAED,eAAe,MAAME,aAAN,SAA4BT,SAA5B,CAAsC;AACpDU,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,CAAWX,QAAlB;AACA;;AAED,WACC,cAAC,OAAD;AACC,MAAA,SAAS,EAAC,6BADX;AAEC,MAAA,OAAO,EAAG,CACT,cAAC,MAAD;AACC,QAAA,GAAG,EAAC,UADL;AAEC,QAAA,OAAO,EAAG,KAAKK,MAFhB;AAGC,QAAA,OAAO,EAAC;AAHT,SAKGX,EAAE,CAAE,kBAAF,CALL,CADS,EAQT,cAAC,UAAD;AAAY,QAAA,GAAG,EAAC,YAAhB;AAA6B,QAAA,IAAI,EAAGc,KAAK,CAACM;AAA1C,SACGpB,EAAE,CAAE,YAAF,CADL,CARS;AAFX,OAeGA,EAAE,CAAE,iDAAF,CAfL,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"]}
@@ -9,6 +9,7 @@ import { PluginArea } from '@wordpress/plugins';
9
9
  * Internal dependencies
10
10
  */
11
11
 
12
+ import ErrorBoundary from '../error-boundary';
12
13
  import WidgetAreasBlockEditorProvider from '../widget-areas-block-editor-provider';
13
14
  import Sidebar from '../sidebar';
14
15
  import Interface from './interface';
@@ -16,13 +17,16 @@ import UnsavedChangesWarning from './unsaved-changes-warning';
16
17
  import WelcomeGuide from '../welcome-guide';
17
18
 
18
19
  function Layout({
19
- blockEditorSettings
20
+ blockEditorSettings,
21
+ onError
20
22
  }) {
21
- return createElement(WidgetAreasBlockEditorProvider, {
23
+ return createElement(ErrorBoundary, {
24
+ onError: onError
25
+ }, createElement(WidgetAreasBlockEditorProvider, {
22
26
  blockEditorSettings: blockEditorSettings
23
27
  }, createElement(Interface, {
24
28
  blockEditorSettings: blockEditorSettings
25
- }), createElement(Sidebar, null), createElement(Popover.Slot, null), createElement(PluginArea, null), createElement(UnsavedChangesWarning, null), createElement(WelcomeGuide, null));
29
+ }), createElement(Sidebar, null), createElement(Popover.Slot, null), createElement(PluginArea, null), createElement(UnsavedChangesWarning, null), createElement(WelcomeGuide, null)));
26
30
  }
27
31
 
28
32
  export default Layout;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/layout/index.js"],"names":["Popover","PluginArea","WidgetAreasBlockEditorProvider","Sidebar","Interface","UnsavedChangesWarning","WelcomeGuide","Layout","blockEditorSettings"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,uBAAxB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,8BAAP,MAA2C,uCAA3C;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;;AAEA,SAASC,MAAT,CAAiB;AAAEC,EAAAA;AAAF,CAAjB,EAA2C;AAC1C,SACC,cAAC,8BAAD;AACC,IAAA,mBAAmB,EAAGA;AADvB,KAGC,cAAC,SAAD;AAAW,IAAA,mBAAmB,EAAGA;AAAjC,IAHD,EAIC,cAAC,OAAD,OAJD,EAKC,cAAC,OAAD,CAAS,IAAT,OALD,EAMC,cAAC,UAAD,OAND,EAOC,cAAC,qBAAD,OAPD,EAQC,cAAC,YAAD,OARD,CADD;AAYA;;AAED,eAAeD,MAAf","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":["Popover","PluginArea","ErrorBoundary","WidgetAreasBlockEditorProvider","Sidebar","Interface","UnsavedChangesWarning","WelcomeGuide","Layout","blockEditorSettings","onError"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,uBAAxB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,8BAAP,MAA2C,uCAA3C;AACA,OAAOC,OAAP,MAAoB,YAApB;AACA,OAAOC,SAAP,MAAsB,aAAtB;AACA,OAAOC,qBAAP,MAAkC,2BAAlC;AACA,OAAOC,YAAP,MAAyB,kBAAzB;;AAEA,SAASC,MAAT,CAAiB;AAAEC,EAAAA,mBAAF;AAAuBC,EAAAA;AAAvB,CAAjB,EAAoD;AACnD,SACC,cAAC,aAAD;AAAe,IAAA,OAAO,EAAGA;AAAzB,KACC,cAAC,8BAAD;AACC,IAAA,mBAAmB,EAAGD;AADvB,KAGC,cAAC,SAAD;AAAW,IAAA,mBAAmB,EAAGA;AAAjC,IAHD,EAIC,cAAC,OAAD,OAJD,EAKC,cAAC,OAAD,CAAS,IAAT,OALD,EAMC,cAAC,UAAD,OAND,EAOC,cAAC,qBAAD,OAPD,EAQC,cAAC,YAAD,OARD,CADD,CADD;AAcA;;AAED,eAAeD,MAAf","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"]}
@@ -61,7 +61,7 @@ export default function MoreMenu() {
61
61
  }), createElement(MenuItem, {
62
62
  role: "menuitem",
63
63
  icon: external,
64
- href: __('https://wordpress.org/support/article/wordpress-editor/'),
64
+ href: __('https://wordpress.org/support/article/block-based-widgets-editor/'),
65
65
  target: "_blank",
66
66
  rel: "noopener noreferrer"
67
67
  }, __('Help'), createElement(VisuallyHidden, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/more-menu/index.js"],"names":["DropdownMenu","MenuGroup","MenuItem","VisuallyHidden","useState","__","_x","external","moreVertical","displayShortcut","useShortcut","useViewportMatch","FeatureToggle","KeyboardShortcutHelpModal","POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","isLargeViewport","access"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,cAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,kBAAvC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,iCADU;AAErBC,EAAAA,QAAQ,EAAE;AAFW,CAAtB;AAIA,MAAMC,YAAY,GAAG;AACpBC,EAAAA,eAAe,EAAE;AADG,CAArB;AAIA,eAAe,SAASC,QAAT,GAAoB;AAClC,QAAM,CACLC,8BADK,EAELC,kCAFK,IAGF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,\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":["DropdownMenu","MenuGroup","MenuItem","VisuallyHidden","useState","__","_x","external","moreVertical","displayShortcut","useShortcut","useViewportMatch","FeatureToggle","KeyboardShortcutHelpModal","POPOVER_PROPS","className","position","TOGGLE_PROPS","tooltipPosition","MoreMenu","isKeyboardShortcutsModalActive","setIsKeyboardShortcutsModalVisible","toggleKeyboardShortcutsModal","bindGlobal","isLargeViewport","access"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,YADD,EAECC,SAFD,EAGCC,QAHD,EAICC,cAJD,QAKO,uBALP;AAMA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,QAAT,EAAmBC,YAAnB,QAAuC,kBAAvC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,WAAT,QAA4B,+BAA5B;AACA,SAASC,gBAAT,QAAiC,oBAAjC;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,yBAAP,MAAsC,iCAAtC;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,SAAS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AjDD,CATF,CADD,EAqGC,cAAC,yBAAD;AACC,IAAA,aAAa,EAAGe,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"]}
@@ -10,6 +10,7 @@ import { BlockIcon } from '@wordpress/block-editor';
10
10
  import { Button } from '@wordpress/components';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { addQueryArgs } from '@wordpress/url';
13
+ import { safeHTML } from '@wordpress/dom';
13
14
  /**
14
15
  * Internal dependencies
15
16
  */
@@ -36,7 +37,15 @@ export default function WidgetAreas({
36
37
  className: "edit-widgets-widget-areas__top-container"
37
38
  }, createElement(BlockIcon, {
38
39
  icon: blockDefault
39
- }), createElement("div", null, createElement("p", null, description), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && createElement("p", null, __('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && createElement(Button, {
40
+ }), createElement("div", null, createElement("p", {
41
+ // Use `dangerouslySetInnerHTML` to keep backwards
42
+ // compatibility. Basic markup in the description is an
43
+ // established feature of WordPress.
44
+ // @see https://github.com/WordPress/gutenberg/issues/33106
45
+ dangerouslySetInnerHTML: {
46
+ __html: safeHTML(description)
47
+ }
48
+ }), (widgetAreas === null || widgetAreas === void 0 ? void 0 : widgetAreas.length) === 0 && createElement("p", null, __('Your theme does not contain any Widget Areas.')), !selectedWidgetArea && createElement(Button, {
40
49
  href: addQueryArgs('customize.php', {
41
50
  'autofocus[panel]': 'widgets',
42
51
  return: window.location.pathname
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/sidebar/widget-areas.js"],"names":["useSelect","useMemo","blockDefault","BlockIcon","Button","__","addQueryArgs","store","editWidgetsStore","WidgetAreas","selectedWidgetAreaId","widgetAreas","select","getWidgetAreas","selectedWidgetArea","find","widgetArea","id","description","length","return","window","location","pathname"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,yBAA1B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAiD;AAC/D,QAAMC,WAAW,GAAGX,SAAS,CAC1BY,MAAF,IAAcA,MAAM,CAAEJ,gBAAF,CAAN,CAA2BK,cAA3B,EADc,EAE5B,EAF4B,CAA7B;AAKA,QAAMC,kBAAkB,GAAGb,OAAO,CACjC,MACCS,oBAAoB,KACpBC,WADoB,aACpBA,WADoB,uBACpBA,WAAW,CAAEI,IAAb,CACGC,UAAF,IAAkBA,UAAU,CAACC,EAAX,KAAkBP,oBADrC,CADoB,CAFY,EAMjC,CAAEA,oBAAF,EAAwBC,WAAxB,CANiC,CAAlC;AASA,MAAIO,WAAJ;;AACA,MAAK,CAAEJ,kBAAP,EAA4B;AAC3BI,IAAAA,WAAW,GAAGb,EAAE,CACf,uJADe,CAAhB;AAGA,GAJD,MAIO,IAAKK,oBAAoB,KAAK,qBAA9B,EAAsD;AAC5DQ,IAAAA,WAAW,GAAGb,EAAE,CACf,gEADe,CAAhB;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,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGhB;AAAlB,IADD,EAEC,2BACC,yBAAKgB,WAAL,CADD,EAEG,CAAAP,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAEQ,MAAb,MAAwB,CAAxB,IACD,yBACGd,EAAE,CACH,+CADG,CADL,CAHF,EASG,CAAES,kBAAF,IACD,cAAC,MAAD;AACC,IAAA,IAAI,EAAGR,YAAY,CAAE,eAAF,EAAmB;AACrC,0BAAoB,SADiB;AAErCc,MAAAA,MAAM,EAAEC,MAAM,CAACC,QAAP,CAAgBC;AAFa,KAAnB,CADpB;AAKC,IAAA,UAAU;AALX,KAOGlB,EAAE,CAAE,0BAAF,CAPL,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":["useSelect","useMemo","blockDefault","BlockIcon","Button","__","addQueryArgs","safeHTML","store","editWidgetsStore","WidgetAreas","selectedWidgetAreaId","widgetAreas","select","getWidgetAreas","selectedWidgetArea","find","widgetArea","id","description","__html","length","return","window","location","pathname"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,yBAA1B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,QAA6B,gBAA7B;AACA,SAASC,QAAT,QAAyB,gBAAzB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA,eAAe,SAASC,WAAT,CAAsB;AAAEC,EAAAA;AAAF,CAAtB,EAAiD;AAC/D,QAAMC,WAAW,GAAGZ,SAAS,CAC1Ba,MAAF,IAAcA,MAAM,CAAEJ,gBAAF,CAAN,CAA2BK,cAA3B,EADc,EAE5B,EAF4B,CAA7B;AAKA,QAAMC,kBAAkB,GAAGd,OAAO,CACjC,MACCU,oBAAoB,KACpBC,WADoB,aACpBA,WADoB,uBACpBA,WAAW,CAAEI,IAAb,CACGC,UAAF,IAAkBA,UAAU,CAACC,EAAX,KAAkBP,oBADrC,CADoB,CAFY,EAMjC,CAAEA,oBAAF,EAAwBC,WAAxB,CANiC,CAAlC;AASA,MAAIO,WAAJ;;AACA,MAAK,CAAEJ,kBAAP,EAA4B;AAC3BI,IAAAA,WAAW,GAAGd,EAAE,CACf,uJADe,CAAhB;AAGA,GAJD,MAIO,IAAKM,oBAAoB,KAAK,qBAA9B,EAAsD;AAC5DQ,IAAAA,WAAW,GAAGd,EAAE,CACf,gEADe,CAAhB;AAGA,GAJM,MAIA;AACNc,IAAAA,WAAW,GAAGJ,kBAAkB,CAACI,WAAjC;AACA;;AAED,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGjB;AAAlB,IADD,EAEC,2BACC;AACC;AACA;AACA;AACA;AACA,IAAA,uBAAuB,EAAG;AACzBkB,MAAAA,MAAM,EAAEb,QAAQ,CAAEY,WAAF;AADS;AAL3B,IADD,EAUG,CAAAP,WAAW,SAAX,IAAAA,WAAW,WAAX,YAAAA,WAAW,CAAES,MAAb,MAAwB,CAAxB,IACD,yBACGhB,EAAE,CACH,+CADG,CADL,CAXF,EAiBG,CAAEU,kBAAF,IACD,cAAC,MAAD;AACC,IAAA,IAAI,EAAGT,YAAY,CAAE,eAAF,EAAmB;AACrC,0BAAoB,SADiB;AAErCgB,MAAAA,MAAM,EAAEC,MAAM,CAACC,QAAP,CAAgBC;AAFa,KAAnB,CADpB;AAKC,IAAA,UAAU;AALX,KAOGpB,EAAE,CAAE,0BAAF,CAPL,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"]}
@@ -7,6 +7,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
7
7
  * Internal dependencies
8
8
  */
9
9
 
10
+ import { store as editWidgetsStore } from '../store';
10
11
  import { buildWidgetAreasPostId, KIND, POST_TYPE } from '../store/utils';
11
12
 
12
13
  const useWidgetLibraryInsertionPoint = () => {
@@ -27,6 +28,15 @@ const useWidgetLibraryInsertionPoint = () => {
27
28
  getBlockOrder,
28
29
  getBlockIndex
29
30
  } = select(blockEditorStore);
31
+
32
+ const insertionPoint = select(editWidgetsStore).__experimentalGetInsertionPoint(); // "Browse all" in the quick inserter will set the rootClientId to the current block.
33
+ // Otherwise, it will just be undefined, and we'll have to handle it differently below.
34
+
35
+
36
+ if (insertionPoint.rootClientId) {
37
+ return insertionPoint;
38
+ }
39
+
30
40
  const clientId = getBlockSelectionEnd() || firstRootId;
31
41
  const rootClientId = getBlockRootClientId(clientId); // If the selected block is at the root level, it's a widget area and
32
42
  // 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":["useSelect","store","blockEditorStore","buildWidgetAreasPostId","KIND","POST_TYPE","useWidgetLibraryInsertionPoint","firstRootId","select","getEntityRecord","widgetAreasPost","blocks","clientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","rootClientId","insertionIndex","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,EAAiCC,IAAjC,EAAuCC,SAAvC,QAAwD,gBAAxD;;AAEA,MAAMC,8BAA8B,GAAG,MAAM;AAC5C,QAAMC,WAAW,GAAGP,SAAS,CAAIQ,MAAF,IAAc;AAAA;;AAC5C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAE,MAAF,CAAlC;AACA,UAAME,eAAe,GAAGD,eAAe,CACtCL,IADsC,EAEtCC,SAFsC,EAGtCF,sBAAsB,EAHgB,CAAvC;AAKA,WAAOO,eAAP,aAAOA,eAAP,gDAAOA,eAAe,CAAEC,MAAjB,CAAyB,CAAzB,CAAP,0DAAO,sBAA8BC,QAArC;AACA,GAT4B,EAS1B,EAT0B,CAA7B;AAWA,SAAOZ,SAAS,CACbQ,MAAF,IAAc;AACb,UAAM;AACLK,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFR,MAAM,CAAEN,gBAAF,CALV;AAOA,UAAMU,QAAQ,GAAGE,oBAAoB,MAAMP,WAA3C;AACA,UAAMU,YAAY,GAAGJ,oBAAoB,CAAED,QAAF,CAAzC,CATa,CAWb;AACA;AACA;;AACA,QAAKA,QAAQ,IAAIK,YAAY,KAAK,EAAlC,EAAuC;AACtC,aAAO;AACNA,QAAAA,YAAY,EAAEL,QADR;AAENM,QAAAA,cAAc,EAAEH,aAAa,CAAEH,QAAF,CAAb,CAA0BO;AAFpC,OAAP;AAIA;;AAED,WAAO;AACNF,MAAAA,YADM;AAENC,MAAAA,cAAc,EAAEF,aAAa,CAAEJ,QAAF,EAAYK,YAAZ,CAAb,GAA0C;AAFpD,KAAP;AAIA,GA1Bc,EA2Bf,CAAEV,WAAF,CA3Be,CAAhB;AA6BA,CAzCD;;AA2CA,eAAeD,8BAAf","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":["useSelect","store","blockEditorStore","editWidgetsStore","buildWidgetAreasPostId","KIND","POST_TYPE","useWidgetLibraryInsertionPoint","firstRootId","select","getEntityRecord","widgetAreasPost","blocks","clientId","getBlockRootClientId","getBlockSelectionEnd","getBlockOrder","getBlockIndex","insertionPoint","__experimentalGetInsertionPoint","rootClientId","insertionIndex","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,UAA1C;AACA,SAASC,sBAAT,EAAiCC,IAAjC,EAAuCC,SAAvC,QAAwD,gBAAxD;;AAEA,MAAMC,8BAA8B,GAAG,MAAM;AAC5C,QAAMC,WAAW,GAAGR,SAAS,CAAIS,MAAF,IAAc;AAAA;;AAC5C;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAsBD,MAAM,CAAE,MAAF,CAAlC;AACA,UAAME,eAAe,GAAGD,eAAe,CACtCL,IADsC,EAEtCC,SAFsC,EAGtCF,sBAAsB,EAHgB,CAAvC;AAKA,WAAOO,eAAP,aAAOA,eAAP,gDAAOA,eAAe,CAAEC,MAAjB,CAAyB,CAAzB,CAAP,0DAAO,sBAA8BC,QAArC;AACA,GAT4B,EAS1B,EAT0B,CAA7B;AAWA,SAAOb,SAAS,CACbS,MAAF,IAAc;AACb,UAAM;AACLK,MAAAA,oBADK;AAELC,MAAAA,oBAFK;AAGLC,MAAAA,aAHK;AAILC,MAAAA;AAJK,QAKFR,MAAM,CAAEP,gBAAF,CALV;;AAOA,UAAMgB,cAAc,GAAGT,MAAM,CAC5BN,gBAD4B,CAAN,CAErBgB,+BAFqB,EAAvB,CARa,CAYb;AACA;;;AACA,QAAKD,cAAc,CAACE,YAApB,EAAmC;AAClC,aAAOF,cAAP;AACA;;AAED,UAAML,QAAQ,GAAGE,oBAAoB,MAAMP,WAA3C;AACA,UAAMY,YAAY,GAAGN,oBAAoB,CAAED,QAAF,CAAzC,CAnBa,CAqBb;AACA;AACA;;AACA,QAAKA,QAAQ,IAAIO,YAAY,KAAK,EAAlC,EAAuC;AACtC,aAAO;AACNA,QAAAA,YAAY,EAAEP,QADR;AAENQ,QAAAA,cAAc,EAAEL,aAAa,CAAEH,QAAF,CAAb,CAA0BS;AAFpC,OAAP;AAIA;;AAED,WAAO;AACNF,MAAAA,YADM;AAENC,MAAAA,cAAc,EAAEJ,aAAa,CAAEJ,QAAF,EAAYO,YAAZ,CAAb,GAA0C;AAFpD,KAAP;AAIA,GApCc,EAqCf,CAAEZ,WAAF,CArCe,CAAhB;AAuCA,CAnDD;;AAqDA,eAAeD,8BAAf","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"]}
@@ -5,7 +5,7 @@ import { createElement } from "@wordpress/element";
5
5
  */
6
6
  import { registerBlockType, unstable__bootstrapServerSideBlockDefinitions // eslint-disable-line camelcase
7
7
  , setFreeformContentHandlerName } from '@wordpress/blocks';
8
- import { render } from '@wordpress/element';
8
+ import { render, unmountComponentAtNode } from '@wordpress/element';
9
9
  import { registerCoreBlocks, __experimentalGetCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from '@wordpress/block-library';
10
10
  import { __experimentalFetchLinkSuggestions as fetchLinkSuggestions } from '@wordpress/core-data';
11
11
  import { registerLegacyWidgetBlock, registerLegacyWidgetVariations } from '@wordpress/widgets';
@@ -19,6 +19,23 @@ import * as widgetArea from './blocks/widget-area';
19
19
  import Layout from './components/layout';
20
20
  import { ALLOW_REUSABLE_BLOCKS, ENABLE_EXPERIMENTAL_FSE_BLOCKS } from './constants';
21
21
  const disabledBlocks = ['core/more', 'core/freeform', ...(!ALLOW_REUSABLE_BLOCKS && ['core/block'])];
22
+ /**
23
+ * Reinitializes the editor after the user chooses to reboot the editor after
24
+ * an unhandled error occurs, replacing previously mounted editor element using
25
+ * an initial state from prior to the crash.
26
+ *
27
+ * @param {Element} target DOM node in which editor is rendered.
28
+ * @param {?Object} settings Editor settings object.
29
+ */
30
+
31
+ export function reinitializeEditor(target, settings) {
32
+ unmountComponentAtNode(target);
33
+ const reboot = reinitializeEditor.bind(null, target, settings);
34
+ render(createElement(Layout, {
35
+ blockEditorSettings: settings,
36
+ onError: reboot
37
+ }), target);
38
+ }
22
39
  /**
23
40
  * Initializes the block editor in the widgets screen.
24
41
  *
@@ -27,6 +44,9 @@ const disabledBlocks = ['core/more', 'core/freeform', ...(!ALLOW_REUSABLE_BLOCKS
27
44
  */
28
45
 
29
46
  export function initialize(id, settings) {
47
+ const target = document.getElementById(id);
48
+ const reboot = reinitializeEditor.bind(null, target, settings);
49
+
30
50
  const coreBlocks = __experimentalGetCoreBlocks().filter(block => {
31
51
  return !(disabledBlocks.includes(block.name) || block.name.startsWith('core/post') || block.name.startsWith('core/query') || block.name.startsWith('core/site'));
32
52
  });
@@ -51,8 +71,9 @@ export function initialize(id, settings) {
51
71
 
52
72
  setFreeformContentHandlerName('core/html');
53
73
  render(createElement(Layout, {
54
- blockEditorSettings: settings
55
- }), document.getElementById(id));
74
+ blockEditorSettings: settings,
75
+ onError: reboot
76
+ }), target);
56
77
  }
57
78
  /**
58
79
  * Function to register an individual block.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/index.js"],"names":["registerBlockType","unstable__bootstrapServerSideBlockDefinitions","setFreeformContentHandlerName","render","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","registerLegacyWidgetBlock","registerLegacyWidgetVariations","widgetArea","Layout","ALLOW_REUSABLE_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","disabledBlocks","initialize","id","settings","coreBlocks","filter","block","includes","name","startsWith","process","env","GUTENBERG_PHASE","enableFSEBlocks","registerBlock","search","searchOptions","document","getElementById","metadata"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,iBADD,EAECC,6CAFD,CAEgD;AAFhD,EAGCC,6BAHD,QAIO,mBAJP;AAKA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SACCC,kBADD,EAECC,2BAFD,EAGCC,4CAHD,QAIO,0BAJP;AAKA,SAASC,kCAAkC,IAAIC,oBAA/C,QAA2E,sBAA3E;AACA,SACCC,yBADD,EAECC,8BAFD,QAGO,oBAHP;AAKA;AACA;AACA;;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAO,KAAKC,UAAZ,MAA4B,sBAA5B;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,SACCC,qBADD,EAECC,8BAFD,QAGO,aAHP;AAKA,MAAMC,cAAc,GAAG,CACtB,WADsB,EAEtB,eAFsB,EAGtB,IAAK,CAAEF,qBA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A;;AACD,QAAM;AAAEa,IAAAA,QAAF;AAAYhB,IAAAA,QAAZ;AAAsBK,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKa,QAAL,EAAgB;AACfjC,IAAAA,6CAA6C,CAAE;AAAE,OAAEsB,IAAF,GAAUW;AAAZ,KAAF,CAA7C;AACA;;AACDlC,EAAAA,iBAAiB,CAAEuB,IAAF,EAAQL,QAAR,CAAjB;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":["registerBlockType","unstable__bootstrapServerSideBlockDefinitions","setFreeformContentHandlerName","render","unmountComponentAtNode","registerCoreBlocks","__experimentalGetCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","registerLegacyWidgetBlock","registerLegacyWidgetVariations","widgetArea","Layout","ALLOW_REUSABLE_BLOCKS","ENABLE_EXPERIMENTAL_FSE_BLOCKS","disabledBlocks","reinitializeEditor","target","settings","reboot","bind","initialize","id","document","getElementById","coreBlocks","filter","block","includes","name","startsWith","process","env","GUTENBERG_PHASE","enableFSEBlocks","registerBlock","search","searchOptions","metadata"],"mappings":";;AAAA;AACA;AACA;AACA,SAC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AAF,GAAUS;AAAZ,KAAF,CAA7C;AACA;;AACDvC,EAAAA,iBAAiB,CAAE8B,IAAF,EAAQX,QAAR,CAAjB;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"]}
@@ -167,6 +167,24 @@ export const getIsWidgetAreaOpen = (state, clientId) => {
167
167
  export function isInserterOpened(state) {
168
168
  return !!state.blockInserterPanel;
169
169
  }
170
+ /**
171
+ * Get the insertion point for the inserter.
172
+ *
173
+ * @param {Object} state Global application state.
174
+ *
175
+ * @return {Object} The root client ID and index to insert at.
176
+ */
177
+
178
+ export function __experimentalGetInsertionPoint(state) {
179
+ const {
180
+ rootClientId,
181
+ insertionIndex
182
+ } = state.blockInserterPanel;
183
+ return {
184
+ rootClientId,
185
+ insertionIndex
186
+ };
187
+ }
170
188
  /**
171
189
  * Returns true if a block can be inserted into a widget area.
172
190
  *
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/selectors.js"],"names":["get","keyBy","createRegistrySelector","getWidgetIdFromBlock","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","getWidget","state","id","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","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":"AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,KAAd,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA,OAAO,MAAMC,UAAU,GAAGV,sBAAsB,CAAIW,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAE,MAAF,CAAN,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AP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASmC,yBAAT,CAAoCpD,KAApC,EAA2CqD,OAA3C,EAAqD;AAC3D,SAAOtE,GAAG,CAAEiB,KAAK,CAACsD,WAAN,CAAkBC,QAApB,EAA8B,CAAEF,OAAF,CAA9B,EAA2C,KAA3C,CAAV;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":["get","keyBy","createRegistrySelector","getWidgetIdFromBlock","buildWidgetsQuery","buildWidgetAreasQuery","buildWidgetAreaPostId","KIND","POST_TYPE","WIDGET_AREA_ENTITY_TYPE","STORE_NAME","editWidgetsStoreName","getWidgets","select","widgets","getEntityRecords","getWidget","state","id","getWidgetAreas","query","getWidgetAreaForWidgetId","widgetId","widgetAreas","find","widgetArea","post","getEditedEntityRecord","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":"AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,KAAd,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,oBAAT,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,SACCC,iBADD,EAECC,qBAFD,EAGCC,qBAHD,EAICC,IAJD,EAKCC,SALD,EAMCC,uBAND,QAOO,SAPP;AAQA,SAASC,UAAU,IAAIC,oBAAvB,QAAmD,aAAnD;AAEA,OAAO,MAAMC,UAAU,GAAGV,sBAAsB,CAAIW,MAAF,IAAc,MAAM;AACrE,QAAMC,OAAO,GAAGD,MAAM,CAAE,MAAF,CAAN,CAAiBE,gBAAjB,CACf,MADe,EAEf,QAFe,EAGfX,iBAAiB,EAHF,CAAhB;AAMA,SAAOH,KAAK,CAAEa,OAAF,EAAW,IAAX,CAAZ;AACA,CAR+C,CAAzC;AAUP;AACA;AAC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OV,MAAM,CAAE,mBAAF,CAAN,CAA8B0D,kBAA9B,CACNH,SADM,EAENE,eAAe,CAACpC,QAFV,CAAP;AAIA,CAb8D,CAAzD;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASsC,yBAAT,CAAoCvD,KAApC,EAA2CwD,OAA3C,EAAqD;AAC3D,SAAOzE,GAAG,CAAEiB,KAAK,CAACyD,WAAN,CAAkBC,QAApB,EAA8B,CAAEF,OAAF,CAA9B,EAA2C,KAA3C,CAAV;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"]}
@@ -439,6 +439,14 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
439
439
  pointer-events: none;
440
440
  }
441
441
 
442
+ .edit-widgets-error-boundary {
443
+ margin: auto;
444
+ max-width: 780px;
445
+ padding: 20px;
446
+ margin-top: 60px;
447
+ box-shadow: 0 10px 10px rgba(0, 0, 0, 0.25);
448
+ }
449
+
442
450
  .edit-widgets-header {
443
451
  display: flex;
444
452
  align-items: center;
@@ -439,6 +439,14 @@ body.is-dragging-components-draggable .wp-block[data-type="core/widget-area"] .c
439
439
  pointer-events: none;
440
440
  }
441
441
 
442
+ .edit-widgets-error-boundary {
443
+ margin: auto;
444
+ max-width: 780px;
445
+ padding: 20px;
446
+ margin-top: 60px;
447
+ box-shadow: 0 10px 10px rgba(0, 0, 0, 0.25);
448
+ }
449
+
442
450
  .edit-widgets-header {
443
451
  display: flex;
444
452
  align-items: center;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-widgets",
3
- "version": "2.1.19",
3
+ "version": "2.1.22",
4
4
  "description": "Widgets Page module for WordPress..",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,30 +27,31 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.13.10",
30
- "@wordpress/a11y": "^3.1.1",
31
- "@wordpress/api-fetch": "^5.1.1",
32
- "@wordpress/block-editor": "^6.1.12",
33
- "@wordpress/block-library": "^3.2.17",
34
- "@wordpress/blocks": "^9.1.7",
35
- "@wordpress/components": "^14.1.9",
36
- "@wordpress/compose": "^4.1.5",
37
- "@wordpress/core-data": "^3.1.11",
38
- "@wordpress/data": "^5.1.5",
39
- "@wordpress/data-controls": "^2.1.5",
40
- "@wordpress/element": "^3.1.1",
30
+ "@wordpress/a11y": "^3.1.2",
31
+ "@wordpress/api-fetch": "^5.1.3",
32
+ "@wordpress/block-editor": "^6.1.15",
33
+ "@wordpress/block-library": "^3.2.20",
34
+ "@wordpress/blocks": "^9.1.8",
35
+ "@wordpress/components": "^14.1.11",
36
+ "@wordpress/compose": "^4.1.6",
37
+ "@wordpress/core-data": "^3.1.13",
38
+ "@wordpress/data": "^5.1.6",
39
+ "@wordpress/data-controls": "^2.1.7",
40
+ "@wordpress/dom": "^3.1.5",
41
+ "@wordpress/element": "^3.1.2",
41
42
  "@wordpress/hooks": "^3.1.1",
42
- "@wordpress/i18n": "^4.1.1",
43
- "@wordpress/icons": "^4.0.2",
44
- "@wordpress/interface": "^3.1.10",
45
- "@wordpress/keyboard-shortcuts": "^2.1.5",
46
- "@wordpress/keycodes": "^3.1.1",
47
- "@wordpress/media-utils": "^2.1.1",
48
- "@wordpress/notices": "^3.1.5",
49
- "@wordpress/plugins": "^3.1.5",
50
- "@wordpress/reusable-blocks": "^2.1.15",
51
- "@wordpress/server-side-render": "^2.1.10",
52
- "@wordpress/url": "^3.1.1",
53
- "@wordpress/widgets": "^1.1.17",
43
+ "@wordpress/i18n": "^4.1.2",
44
+ "@wordpress/icons": "^4.0.3",
45
+ "@wordpress/interface": "^3.1.12",
46
+ "@wordpress/keyboard-shortcuts": "^2.1.7",
47
+ "@wordpress/keycodes": "^3.1.2",
48
+ "@wordpress/media-utils": "^2.1.3",
49
+ "@wordpress/notices": "^3.1.6",
50
+ "@wordpress/plugins": "^3.1.6",
51
+ "@wordpress/reusable-blocks": "^2.1.18",
52
+ "@wordpress/server-side-render": "^2.1.13",
53
+ "@wordpress/url": "^3.1.3",
54
+ "@wordpress/widgets": "^1.1.20",
54
55
  "classnames": "^2.2.5",
55
56
  "lodash": "^4.17.21",
56
57
  "rememo": "^3.0.0",
@@ -59,5 +60,5 @@
59
60
  "publishConfig": {
60
61
  "access": "public"
61
62
  },
62
- "gitHead": "42a6dbdbf9c981e71ea4752c94e5642d6f6cac1d"
63
+ "gitHead": "6464883c6c546233543a1ee01428059dee3560fc"
63
64
  }
@@ -78,7 +78,7 @@ export default function WidgetAreaEdit( {
78
78
  type="postType"
79
79
  id={ `widget-area-${ id }` }
80
80
  >
81
- <WidgetAreaInnerBlocks />
81
+ <WidgetAreaInnerBlocks id={ id } />
82
82
  </EntityProvider>
83
83
  </DisclosureContent>
84
84
  ) }