@wordpress/edit-widgets 3.1.2 → 3.1.6

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 (85) hide show
  1. package/build/blocks/widget-area/edit/index.js +29 -24
  2. package/build/blocks/widget-area/edit/index.js.map +1 -1
  3. package/build/blocks/widget-area/edit/inner-blocks.js +4 -3
  4. package/build/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  5. package/build/blocks/widget-area/index.js +6 -3
  6. package/build/blocks/widget-area/index.js.map +1 -1
  7. package/build/components/error-boundary/index.js +5 -4
  8. package/build/components/error-boundary/index.js.map +1 -1
  9. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +4 -3
  10. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  11. package/build/components/keyboard-shortcut-help-modal/index.js +50 -41
  12. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  13. package/build/components/keyboard-shortcut-help-modal/shortcut.js +12 -10
  14. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  15. package/build/components/layout/index.js +5 -4
  16. package/build/components/layout/index.js.map +1 -1
  17. package/build/components/layout/interface.js +4 -3
  18. package/build/components/layout/interface.js.map +1 -1
  19. package/build/components/sidebar/index.js +6 -5
  20. package/build/components/sidebar/index.js.map +1 -1
  21. package/build/components/sidebar/widget-areas.js +4 -3
  22. package/build/components/sidebar/widget-areas.js.map +1 -1
  23. package/build/components/welcome-guide/index.js +5 -4
  24. package/build/components/welcome-guide/index.js.map +1 -1
  25. package/build/components/widget-areas-block-editor-content/index.js +4 -3
  26. package/build/components/widget-areas-block-editor-content/index.js.map +1 -1
  27. package/build/components/widget-areas-block-editor-provider/index.js +17 -12
  28. package/build/components/widget-areas-block-editor-provider/index.js.map +1 -1
  29. package/build/index.js +5 -3
  30. package/build/index.js.map +1 -1
  31. package/build/store/actions.js +74 -51
  32. package/build/store/actions.js.map +1 -1
  33. package/build/store/index.js +4 -2
  34. package/build/store/index.js.map +1 -1
  35. package/build/store/reducer.js +13 -5
  36. package/build/store/reducer.js.map +1 -1
  37. package/build/store/resolvers.js +10 -8
  38. package/build/store/resolvers.js.map +1 -1
  39. package/build/store/selectors.js +28 -14
  40. package/build/store/selectors.js.map +1 -1
  41. package/build/store/transformers.js +3 -2
  42. package/build/store/transformers.js.map +1 -1
  43. package/build/store/utils.js +2 -1
  44. package/build/store/utils.js.map +1 -1
  45. package/build-module/blocks/widget-area/edit/index.js +29 -24
  46. package/build-module/blocks/widget-area/edit/index.js.map +1 -1
  47. package/build-module/blocks/widget-area/edit/inner-blocks.js +4 -3
  48. package/build-module/blocks/widget-area/edit/inner-blocks.js.map +1 -1
  49. package/build-module/blocks/widget-area/index.js +6 -3
  50. package/build-module/blocks/widget-area/index.js.map +1 -1
  51. package/build-module/components/error-boundary/index.js +5 -4
  52. package/build-module/components/error-boundary/index.js.map +1 -1
  53. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +4 -3
  54. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
  55. package/build-module/components/keyboard-shortcut-help-modal/index.js +48 -39
  56. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  57. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +12 -10
  58. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  59. package/build-module/components/layout/index.js +5 -4
  60. package/build-module/components/layout/index.js.map +1 -1
  61. package/build-module/components/layout/interface.js +4 -3
  62. package/build-module/components/layout/interface.js.map +1 -1
  63. package/build-module/components/sidebar/index.js +6 -5
  64. package/build-module/components/sidebar/index.js.map +1 -1
  65. package/build-module/components/sidebar/widget-areas.js +4 -3
  66. package/build-module/components/sidebar/widget-areas.js.map +1 -1
  67. package/build-module/components/welcome-guide/index.js +5 -4
  68. package/build-module/components/welcome-guide/index.js.map +1 -1
  69. package/build-module/components/widget-areas-block-editor-content/index.js +4 -3
  70. package/build-module/components/widget-areas-block-editor-content/index.js.map +1 -1
  71. package/build-module/components/widget-areas-block-editor-provider/index.js +17 -12
  72. package/build-module/components/widget-areas-block-editor-provider/index.js.map +1 -1
  73. package/build-module/index.js +2 -2
  74. package/build-module/index.js.map +1 -1
  75. package/build-module/store/actions.js +70 -47
  76. package/build-module/store/actions.js.map +1 -1
  77. package/build-module/store/reducer.js +11 -3
  78. package/build-module/store/reducer.js.map +1 -1
  79. package/build-module/store/resolvers.js +10 -8
  80. package/build-module/store/resolvers.js.map +1 -1
  81. package/build-module/store/selectors.js +25 -12
  82. package/build-module/store/selectors.js.map +1 -1
  83. package/build-module/store/transformers.js +2 -1
  84. package/build-module/store/transformers.js.map +1 -1
  85. package/package.json +27 -27
@@ -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","__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,OAAO,EAAC;AALT,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\tvariant=\"tertiary\"\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,OAAiD;AAAA,MAA3B;AAAEC,IAAAA;AAAF,GAA2B;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,OAAO,EAAC;AALT,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\tvariant=\"tertiary\"\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"]}
@@ -105,10 +105,11 @@ function WelcomeGuide() {
105
105
  });
106
106
  }
107
107
 
108
- function WelcomeGuideImage({
109
- nonAnimatedSrc,
110
- animatedSrc
111
- }) {
108
+ function WelcomeGuideImage(_ref) {
109
+ let {
110
+ nonAnimatedSrc,
111
+ animatedSrc
112
+ } = _ref;
112
113
  return (0, _element.createElement)("picture", {
113
114
  className: "edit-widgets-welcome-guide__image"
114
115
  }, (0, _element.createElement)("source", {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/welcome-guide/index.js"],"names":["WelcomeGuide","isActive","select","interfaceStore","isFeatureActive","toggleFeature","widgetAreas","editWidgetsStore","getWidgetAreas","per_page","isEntirelyBlockWidgets","every","widgetArea","id","widgets","widgetId","startsWith","numWidgetAreas","filter","length","image","content","InserterIconImage","WelcomeGuideImage","nonAnimatedSrc","animatedSrc"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,YAAT,GAAwB;AAAA;;AACtC,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IACCA,MAAM,CAAEC,gBAAF,CAAN,CAAyBC,eAAzB,CACC,mBADD,EAEC,cAFD,CAFe,EAMhB,EANgB,CAAjB;AASA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaF,gBAAb,CAA1B;AAEA,QAAMG,WAAW,GAAG,qBACjBJ,MAAF,IACCA,MAAM,CAAEK,YAAF,CAAN,CAA2BC,cAA3B,CAA2C;AAAEC,IAAAA,QAAQ,EAAE,CAAC;AAAb,GAA3C,CAFkB,EAGnB,EAHmB,CAApB;;AAMA,MAAK,CAAER,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMS,sBAAsB,GAAGJ,WAAH,aAAGA,WAAH,uBAAGA,WAAW,CAAEK,KAAb,CAC5BC,UAAF,IACCA,UAAU,CAACC,EAAX,KAAkB,qBAAlB,IACAD,UAAU,CAACE,OAAX,CAAmBH,KAAnB,CAA4BI,QAAF,IACzBA,QAAQ,CAACC,UAAT,CAAqB,QAArB,CADD,CAH6B,CAA/B;AAQA,QAAM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{ useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\ttoggleFeature( 'core/edit-widgets', 'welcomeGuide' )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\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\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Make each block your own' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Get to know the block library' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\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</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn how to use the block editor' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'New to the block editor? Want to learn more about using it? '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\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\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/welcome-guide/index.js"],"names":["WelcomeGuide","isActive","select","interfaceStore","isFeatureActive","toggleFeature","widgetAreas","editWidgetsStore","getWidgetAreas","per_page","isEntirelyBlockWidgets","every","widgetArea","id","widgets","widgetId","startsWith","numWidgetAreas","filter","length","image","content","InserterIconImage","WelcomeGuideImage","nonAnimatedSrc","animatedSrc"],"mappings":";;;;;;;AAMA;;AAHA;;AACA;;AACA;;AAEA;;AAKA;;AAZA;AACA;AACA;;AAOA;AACA;AACA;AAGe,SAASA,YAAT,GAAwB;AAAA;;AACtC,QAAMC,QAAQ,GAAG,qBACdC,MAAF,IACCA,MAAM,CAAEC,gBAAF,CAAN,CAAyBC,eAAzB,CACC,mBADD,EAEC,cAFD,CAFe,EAMhB,EANgB,CAAjB;AASA,QAAM;AAAEC,IAAAA;AAAF,MAAoB,uBAAaF,gBAAb,CAA1B;AAEA,QAAMG,WAAW,GAAG,qBACjBJ,MAAF,IACCA,MAAM,CAAEK,YAAF,CAAN,CAA2BC,cAA3B,CAA2C;AAAEC,IAAAA,QAAQ,EAAE,CAAC;AAAb,GAA3C,CAFkB,EAGnB,EAHmB,CAApB;;AAMA,MAAK,CAAER,QAAP,EAAkB;AACjB,WAAO,IAAP;AACA;;AAED,QAAMS,sBAAsB,GAAGJ,WAAH,aAAGA,WAAH,uBAAGA,WAAW,CAAEK,KAAb,CAC5BC,UAAF,IACCA,UAAU,CAACC,EAAX,KAAkB,qBAAlB,IACAD,UAAU,CAACE,OAAX,CAAmBH,KAAnB,CAA4BI,QAAF,IACzBA,QAAQ,CAACC,UAAT,CAAqB,QAArB,CADD,CAH6B,CAA/B;AAQA,QAAMC,cAAc,4BACnBX,WADmB,aACnBA,WADmB,uBACnBA,WAAW,CAAEY,MAAb,CACGN,UAAF,IAAkBA,UAAU,CAACC,EAAX,KAAkB,qBADrC,EAEEM,MAHiB,yEAGP,CAHb;AAKA,SACC,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,YAAY,EAAG,cAAI,0BAAJ,CAFhB;AAGC,IAAA,gBAAgB,EAAG,cAAI,aAAJ,CAHpB;AAIC,IAAA,QAAQ,EAAG,MACVd,aAAa,CAAE,m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AAA,SAAS,EAAC,2CADX;AAEC,UAAA,GAAG,EAAG,cAAI,UAAJ,CAFP;AAGC,UAAA,GAAG,EAAC;AAHL;AAFF,OAJC,CADH,CAJD;AARF,KA3EO,EA0GP;AACCF,MAAAA,KAAK,EACJ,4BAAC,iBAAD;AACC,QAAA,cAAc,EAAC,+DADhB;AAEC,QAAA,WAAW,EAAC;AAFb,QAFF;AAOCC,MAAAA,OAAO,EACN,qDACC;AAAI,QAAA,SAAS,EAAC;AAAd,SACG,cAAI,mCAAJ,CADH,CADD,EAIC;AAAG,QAAA,SAAS,EAAC;AAAb,SACG,cACD,8DADC,CADH,EAIC,4BAAC,wBAAD;AACC,QAAA,IAAI,EAAG,cACN,yDADM;AADR,SAKG,cAAI,0BAAJ,CALH,CAJD,CAJD;AARF,KA1GO;AAPT,IADD;AAgJA;;AAED,SAASE,iBAAT,OAA8D;AAAA,MAAlC;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA;AAAlB,GAAkC;AAC7D,SACC;AAAS,IAAA,SAAS,EAAC;AAAnB,KACC;AACC,IAAA,MAAM,EAAGD,cADV;AAEC,IAAA,KAAK,EAAC;AAFP,IADD,EAKC;AAAK,IAAA,GAAG,EAAGC,WAAX;AAAyB,IAAA,KAAK,EAAC,KAA/B;AAAqC,IAAA,MAAM,EAAC,KAA5C;AAAkD,IAAA,GAAG,EAAC;AAAtD,IALD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ExternalLink, Guide } from '@wordpress/components';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editWidgetsStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst isActive = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'welcomeGuide'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst { toggleFeature } = useDispatch( interfaceStore );\n\n\tconst widgetAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editWidgetsStore ).getWidgetAreas( { per_page: -1 } ),\n\t\t[]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\tconst isEntirelyBlockWidgets = widgetAreas?.every(\n\t\t( widgetArea ) =>\n\t\t\twidgetArea.id === 'wp_inactive_widgets' ||\n\t\t\twidgetArea.widgets.every( ( widgetId ) =>\n\t\t\t\twidgetId.startsWith( 'block-' )\n\t\t\t)\n\t);\n\n\tconst numWidgetAreas =\n\t\twidgetAreas?.filter(\n\t\t\t( widgetArea ) => widgetArea.id !== 'wp_inactive_widgets'\n\t\t).length ?? 0;\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-widgets-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to block Widgets' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () =>\n\t\t\t\ttoggleFeature( 'core/edit-widgets', 'welcomeGuide' )\n\t\t\t}\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-canvas.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to block Widgets' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t{ isEntirelyBlockWidgets ? (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s: Number of block areas in the current theme.\n\t\t\t\t\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s “block” area for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\t'Your theme provides %s different “block” areas for you to add and edit content. Try adding a search bar, social icons, or other types of blocks here and see how they’ll look on your site.',\n\t\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tnumWidgetAreas\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\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\t<>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t'You can now add any block to your site’s widget areas. Don’t worry, all of your favorite widgets still work flawlessly.'\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t\t\t<strong>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Want to stick with the old widgets?'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</strong>{ ' ' }\n\t\t\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'https://wordpress.org/plugins/classic-widgets/'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t\t\t'Get the Classic Widgets plugin.'\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Make each block your own' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Each block comes with its own set of controls for changing things like color, width, and alignment. These will show and hide automatically when you have a block selected.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-library.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Get to know the block library' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'All of the blocks available to you live in the block library. You’ll find it wherever you see the <InserterIconImage /> icon.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tInserterIconImage: (\n\t\t\t\t\t\t\t\t\t\t\t<img\n\t\t\t\t\t\t\t\t\t\t\t\tclassName=\"edit-widgets-welcome-guide__inserter-icon\"\n\t\t\t\t\t\t\t\t\t\t\t\talt={ __( 'inserter' ) }\n\t\t\t\t\t\t\t\t\t\t\t\tsrc=\"data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='18' height='18' rx='2' fill='%231E1E1E'/%3E%3Cpath d='M9.22727 4V14M4 8.77273H14' stroke='white' stroke-width='1.5'/%3E%3C/svg%3E%0A\"\n\t\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t\t),\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</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-documentation.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-widgets-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Learn how to use the block editor' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-widgets-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'New to the block editor? Want to learn more about using it? '\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t<ExternalLink\n\t\t\t\t\t\t\t\t\thref={ __(\n\t\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\t) }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( \"Here's a detailed guide.\" ) }\n\t\t\t\t\t\t\t\t</ExternalLink>\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n\nfunction WelcomeGuideImage( { nonAnimatedSrc, animatedSrc } ) {\n\treturn (\n\t\t<picture className=\"edit-widgets-welcome-guide__image\">\n\t\t\t<source\n\t\t\t\tsrcSet={ nonAnimatedSrc }\n\t\t\t\tmedia=\"(prefers-reduced-motion: reduce)\"\n\t\t\t/>\n\t\t\t<img src={ animatedSrc } width=\"312\" height=\"240\" alt=\"\" />\n\t\t</picture>\n\t);\n}\n"]}
@@ -26,9 +26,10 @@ var _keyboardShortcuts = _interopRequireDefault(require("../keyboard-shortcuts")
26
26
  /**
27
27
  * Internal dependencies
28
28
  */
29
- function WidgetAreasBlockEditorContent({
30
- blockEditorSettings
31
- }) {
29
+ function WidgetAreasBlockEditorContent(_ref) {
30
+ let {
31
+ blockEditorSettings
32
+ } = _ref;
32
33
  const hasThemeStyles = (0, _data.useSelect)(select => select(_interface.store).isFeatureActive('core/edit-widgets', 'themeStyles'), []);
33
34
  const styles = (0, _element.useMemo)(() => {
34
35
  return hasThemeStyles ? blockEditorSettings.styles : [];
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-content/index.js"],"names":["WidgetAreasBlockEditorContent","blockEditorSettings","hasThemeStyles","select","interfaceStore","isFeatureActive","styles"],"mappings":";;;;;;;;;AAYA;;AATA;;AAQA;;AAEA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIe,SAASA,6BAAT,CAAwC;AACtDC,EAAAA;AADsD,CAAxC,EAEX;AACH,QAAMC,cAAc,GAAG,qBACpBC,MAAF,IACCA,MAAM,CAAEC,gBAAF,CAAN,CAAyBC,eAAzB,CACC,mBADD,EAEC,aAFD,CAFqB,EAMtB,EANsB,CAAvB;AASA,QAAMC,MAAM,GAAG,sBAAS,MAAM;AAC7B,WAAOJ,cAAc,GAAGD,mBAAmB,CAACK,MAAvB,GAAgC,EAArD;AACA,GAFc,EAEZ,CAAEL,mBAAF,EAAuBC,cAAvB,CAFY,CAAf;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD,OADD,EAEC,4BAAC,uBAAD,QACC,4BAAC,0BAAD,OADD,EAEC,4BAAC,mCAAD;AAAc,IAAA,MAAM,EAAGI;AAAvB,IAFD,EAGC,4BAAC,kCAAD,QACC,4BAAC,wBAAD,QACC,4BAAC,0BAAD,QACC,4BAAC,sBAAD;AAAW,IAAA,SAAS,EAAC;AAArB,IADD,CADD,CADD,CAHD,CAFD,CADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tWritingFlow,\n\tObserveTyping,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport Notices from '../notices';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\n\nexport default function WidgetAreasBlockEditorContent( {\n\tblockEditorSettings,\n} ) {\n\tconst hasThemeStyles = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'themeStyles'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst styles = useMemo( () => {\n\t\treturn hasThemeStyles ? blockEditorSettings.styles : [];\n\t}, [ blockEditorSettings, hasThemeStyles ] );\n\n\treturn (\n\t\t<div className=\"edit-widgets-block-editor\">\n\t\t\t<Notices />\n\t\t\t<BlockTools>\n\t\t\t\t<KeyboardShortcuts />\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t<WritingFlow>\n\t\t\t\t\t\t<ObserveTyping>\n\t\t\t\t\t\t\t<BlockList className=\"edit-widgets-main-block-list\" />\n\t\t\t\t\t\t</ObserveTyping>\n\t\t\t\t\t</WritingFlow>\n\t\t\t\t</BlockSelectionClearer>\n\t\t\t</BlockTools>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-content/index.js"],"names":["WidgetAreasBlockEditorContent","blockEditorSettings","hasThemeStyles","select","interfaceStore","isFeatureActive","styles"],"mappings":";;;;;;;;;AAYA;;AATA;;AAQA;;AAEA;;AAKA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIe,SAASA,6BAAT,OAEX;AAAA,MAFmD;AACtDC,IAAAA;AADsD,GAEnD;AACH,QAAMC,cAAc,GAAG,qBACpBC,MAAF,IACCA,MAAM,CAAEC,gBAAF,CAAN,CAAyBC,eAAzB,CACC,mBADD,EAEC,aAFD,CAFqB,EAMtB,EANsB,CAAvB;AASA,QAAMC,MAAM,GAAG,sBAAS,MAAM;AAC7B,WAAOJ,cAAc,GAAGD,mBAAmB,CAACK,MAAvB,GAAgC,EAArD;AACA,GAFc,EAEZ,CAAEL,mBAAF,EAAuBC,cAAvB,CAFY,CAAf;AAIA,SACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,gBAAD,OADD,EAEC,4BAAC,uBAAD,QACC,4BAAC,0BAAD,OADD,EAEC,4BAAC,mCAAD;AAAc,IAAA,MAAM,EAAGI;AAAvB,IAFD,EAGC,4BAAC,kCAAD,QACC,4BAAC,wBAAD,QACC,4BAAC,0BAAD,QACC,4BAAC,sBAAD;AAAW,IAAA,SAAS,EAAC;AAArB,IADD,CADD,CADD,CAHD,CAFD,CADD;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockList,\n\tBlockTools,\n\tBlockSelectionClearer,\n\tWritingFlow,\n\tObserveTyping,\n\t__unstableEditorStyles as EditorStyles,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport Notices from '../notices';\nimport KeyboardShortcuts from '../keyboard-shortcuts';\n\nexport default function WidgetAreasBlockEditorContent( {\n\tblockEditorSettings,\n} ) {\n\tconst hasThemeStyles = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'themeStyles'\n\t\t\t),\n\t\t[]\n\t);\n\n\tconst styles = useMemo( () => {\n\t\treturn hasThemeStyles ? blockEditorSettings.styles : [];\n\t}, [ blockEditorSettings, hasThemeStyles ] );\n\n\treturn (\n\t\t<div className=\"edit-widgets-block-editor\">\n\t\t\t<Notices />\n\t\t\t<BlockTools>\n\t\t\t\t<KeyboardShortcuts />\n\t\t\t\t<EditorStyles styles={ styles } />\n\t\t\t\t<BlockSelectionClearer>\n\t\t\t\t\t<WritingFlow>\n\t\t\t\t\t\t<ObserveTyping>\n\t\t\t\t\t\t\t<BlockList className=\"edit-widgets-main-block-list\" />\n\t\t\t\t\t\t</ObserveTyping>\n\t\t\t\t\t</WritingFlow>\n\t\t\t\t</BlockSelectionClearer>\n\t\t\t</BlockTools>\n\t\t</div>\n\t);\n}\n"]}
@@ -50,11 +50,12 @@ var _constants = require("../../constants");
50
50
  /**
51
51
  * Internal dependencies
52
52
  */
53
- function WidgetAreasBlockEditorProvider({
54
- blockEditorSettings,
55
- children,
56
- ...props
57
- }) {
53
+ function WidgetAreasBlockEditorProvider(_ref) {
54
+ let {
55
+ blockEditorSettings,
56
+ children,
57
+ ...props
58
+ } = _ref;
58
59
  const {
59
60
  hasUploadPermissions,
60
61
  reusableBlocks,
@@ -75,15 +76,19 @@ function WidgetAreasBlockEditorProvider({
75
76
  let mediaUploadBlockEditor;
76
77
 
77
78
  if (hasUploadPermissions) {
78
- mediaUploadBlockEditor = ({
79
- onError,
80
- ...argumentsObject
81
- }) => {
79
+ mediaUploadBlockEditor = _ref2 => {
80
+ let {
81
+ onError,
82
+ ...argumentsObject
83
+ } = _ref2;
82
84
  (0, _mediaUtils.uploadMedia)({
83
85
  wpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,
84
- onError: ({
85
- message
86
- }) => onError(message),
86
+ onError: _ref3 => {
87
+ let {
88
+ message
89
+ } = _ref3;
90
+ return onError(message);
91
+ },
87
92
  ...argumentsObject
88
93
  });
89
94
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"names":["WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","select","coreStore","canUser","widgetAreas","editWidgetsStore","getWidgetAreas","widgets","getWidgets","ALLOW_REUSABLE_BLOCKS","getEntityRecords","interfaceStore","isFeatureActive","setIsInserterOpened","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","blocks","onInput","onChange","KIND","POST_TYPE","id"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AA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CAAE;AAAEI,YAAAA;AAAF,WAAF,KAAmBJ,OAAO,CAAEI,OAAF,CAFvB;AAGZ,aAAGH;AAHS,SAAb;AAKA,OAND;AAOA;;AACD,WAAO,EACN,GAAGvB,mBADG;AAEN2B,MAAAA,4BAA4B,EAAEvB,cAFxB;AAGNwB,MAAAA,eAAe,EAAEvB,oBAHX;AAINC,MAAAA,oBAJM;AAKNuB,MAAAA,WAAW,EAAER,sBALP;AAMNS,MAAAA,YAAY,EAAE,KANR;AAONC,MAAAA,iCAAiC,EAAEZ;AAP7B,KAAP;AASA,GApBgB,EAoBd,CACFnB,mBADE,EAEFK,oBAFE,EAGFC,oBAHE,EAIFH,oBAJE,EAKFC,cALE,EAMFe,mBANE,CApBc,CAAjB;AA6BA,QAAMa,YAAY,GAAG,yCAArB;AAEA,QAAM,CAAEC,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgC,oCACrCC,WADqC,EAErCC,gBAFqC,EAGrC;AAAEC,IAAAA,EAAE,EAAE;AAAN,GAHqC,CAAtC;AAMA,SACC,4BAAC,mCAAD,QACC,4BAAC,yCAAD,CAA8B,QAA9B,OADD,EAEC,4BAAC,2BAAD,CAAmB,QAAnB,OAFD,EAGC,4BAAC,4BAAD,QACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGL,MADT;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGf,QAJZ;AAKC,IAAA,cAAc,EAAG;AALlB,KAMMlB,KANN,GAQC,4BAAC,wBAAD,QAAeD,QAAf,CARD,EASC,4BAAC,uCAAD;AAAyB,IAAA,YAAY,EAAG+B;AAAxC,IATD,CADD,CAHD,CADD;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport { defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBlockEditorProvider,\n\tBlockEditorKeyboardShortcuts,\n\tCopyHandler,\n} from '@wordpress/block-editor';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tselect( coreStore ).canUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? select( coreStore ).getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: select( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: select( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<ShortcutProvider>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<SlotFillProvider>\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<CopyHandler>{ children }</CopyHandler>\n\t\t\t\t\t<ReusableBlocksMenuItems rootClientId={ widgetAreaId } />\n\t\t\t\t</BlockEditorProvider>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/components/widget-areas-block-editor-provider/index.js"],"names":["WidgetAreasBlockEditorProvider","blockEditorSettings","children","props","hasUploadPermissions","reusableBlocks","isFixedToolbarActive","keepCaretInsideBlock","select","coreStore","canUser","widgetAreas","editWidgetsStore","getWidgetAreas","widgets","getWidgets","ALLOW_REUSABLE_BLOCKS","getEntityRecords","interfaceStore","isFeatureActive","setIsInserterOpened","settings","mediaUploadBlockEditor","onError","argumentsObject","wpAllowedMimeTypes","allowedMimeTypes","message","__experimentalReusableBlocks","hasFixedToolbar","mediaUpload","templateLock","__experimentalSetIsInserterOpened","widgetAreaId","blocks","onInput","onChange","KIND","POST_TYPE","id"],"mappings":";;;;;;;;;AAWA;;;;AARA;;AAKA;;AACA;;AACA;;AAEA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAcA;AACA;AACA;AAQe,SAASA,8BAAT,OAIX;AAAA,MAJoD;AACvDC,IAAAA,mBADuD;AAEvDC,IAAAA,QAFuD;AAGvD,OAAGC;AAHoD,GAIpD;AACH,QAAM;AACLC,IAAAA,oBADK;AAELC,IAAAA,cAFK;AAGLC,IAAAA,oBAHK;AAILC,IAAAA;AAJK,MAKF,qBACDC,MAAF,KAAgB;AACfJ,IAAAA,oBAAoB,EAAE,uBACrBI,MAAM,CAAEC,eAAF,CAAN,CAAoBC,OAApB,CAA6B,QAA7B,EAAuC,OAAvC,CADqB,EAErB,IAFqB,CADP;AAKfC,IAAAA,WAAW,EAAEH,MAAM,CAAEI,YAAF,CAAN,CAA2BC,cAA3B,EALE;AAMfC,IAAAA,OAAO,EAAEN,MAAM,CAAEI,YAAF,CAAN,CAA2BG,UAA3B,EANM;AAOfV,IAAAA,cAAc,EAAEW,mCACbR,MAAM,CAAEC,eAAF,CAAN,CAAoBQ,gBAApB,CAAsC,UAAtC,EAAkD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C;AAAEC,IAAAA,EAAE,EAAE;AAAN,GAHqC,CAAtC;AAMA,SACC,4BAAC,mCAAD,QACC,4BAAC,yCAAD,CAA8B,QAA9B,OADD,EAEC,4BAAC,2BAAD,CAAmB,QAAnB,OAFD,EAGC,4BAAC,4BAAD,QACC,4BAAC,gCAAD;AACC,IAAA,KAAK,EAAGL,MADT;AAEC,IAAA,OAAO,EAAGC,OAFX;AAGC,IAAA,QAAQ,EAAGC,QAHZ;AAIC,IAAA,QAAQ,EAAGf,QAJZ;AAKC,IAAA,cAAc,EAAG;AALlB,KAMMlB,KANN,GAQC,4BAAC,wBAAD,QAAeD,QAAf,CARD,EASC,4BAAC,uCAAD;AAAyB,IAAA,YAAY,EAAG+B;AAAxC,IATD,CADD,CAHD,CADD;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport { defaultTo } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { SlotFillProvider } from '@wordpress/components';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport {\n\tBlockEditorProvider,\n\tBlockEditorKeyboardShortcuts,\n\tCopyHandler,\n} from '@wordpress/block-editor';\nimport { ReusableBlocksMenuItems } from '@wordpress/reusable-blocks';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport KeyboardShortcuts from '../keyboard-shortcuts';\nimport { useEntityBlockEditor, store as coreStore } from '@wordpress/core-data';\nimport { buildWidgetAreasPostId, KIND, POST_TYPE } from '../../store/utils';\nimport useLastSelectedWidgetArea from '../../hooks/use-last-selected-widget-area';\nimport { store as editWidgetsStore } from '../../store';\nimport { ALLOW_REUSABLE_BLOCKS } from '../../constants';\n\nexport default function WidgetAreasBlockEditorProvider( {\n\tblockEditorSettings,\n\tchildren,\n\t...props\n} ) {\n\tconst {\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t} = useSelect(\n\t\t( select ) => ( {\n\t\t\thasUploadPermissions: defaultTo(\n\t\t\t\tselect( coreStore ).canUser( 'create', 'media' ),\n\t\t\t\ttrue\n\t\t\t),\n\t\t\twidgetAreas: select( editWidgetsStore ).getWidgetAreas(),\n\t\t\twidgets: select( editWidgetsStore ).getWidgets(),\n\t\t\treusableBlocks: ALLOW_REUSABLE_BLOCKS\n\t\t\t\t? select( coreStore ).getEntityRecords( 'postType', 'wp_block' )\n\t\t\t\t: [],\n\t\t\tisFixedToolbarActive: select( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: select( interfaceStore ).isFeatureActive(\n\t\t\t\t'core/edit-widgets',\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setIsInserterOpened } = useDispatch( editWidgetsStore );\n\n\tconst settings = useMemo( () => {\n\t\tlet mediaUploadBlockEditor;\n\t\tif ( hasUploadPermissions ) {\n\t\t\tmediaUploadBlockEditor = ( { onError, ...argumentsObject } ) => {\n\t\t\t\tuploadMedia( {\n\t\t\t\t\twpAllowedMimeTypes: blockEditorSettings.allowedMimeTypes,\n\t\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t\t...argumentsObject,\n\t\t\t\t} );\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...blockEditorSettings,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\thasFixedToolbar: isFixedToolbarActive,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: mediaUploadBlockEditor,\n\t\t\ttemplateLock: 'all',\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t};\n\t}, [\n\t\tblockEditorSettings,\n\t\tisFixedToolbarActive,\n\t\tkeepCaretInsideBlock,\n\t\thasUploadPermissions,\n\t\treusableBlocks,\n\t\tsetIsInserterOpened,\n\t] );\n\n\tconst widgetAreaId = useLastSelectedWidgetArea();\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\tKIND,\n\t\tPOST_TYPE,\n\t\t{ id: buildWidgetAreasPostId() }\n\t);\n\n\treturn (\n\t\t<ShortcutProvider>\n\t\t\t<BlockEditorKeyboardShortcuts.Register />\n\t\t\t<KeyboardShortcuts.Register />\n\t\t\t<SlotFillProvider>\n\t\t\t\t<BlockEditorProvider\n\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tsettings={ settings }\n\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<CopyHandler>{ children }</CopyHandler>\n\t\t\t\t\t<ReusableBlocksMenuItems rootClientId={ widgetAreaId } />\n\t\t\t\t</BlockEditorProvider>\n\t\t\t</SlotFillProvider>\n\t\t</ShortcutProvider>\n\t);\n}\n"]}
package/build/index.js CHANGED
@@ -2,13 +2,11 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
- exports.reinitializeEditor = reinitializeEditor;
11
8
  exports.initialize = initialize;
9
+ exports.reinitializeEditor = reinitializeEditor;
12
10
 
13
11
  var _element = require("@wordpress/element");
14
12
 
@@ -34,6 +32,10 @@ var _layout = _interopRequireDefault(require("./components/layout"));
34
32
 
35
33
  var _constants = require("./constants");
36
34
 
35
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
+
37
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
38
+
37
39
  /**
38
40
  * WordPress dependencies
39
41
  */
@@ -1 +1 @@
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","interfaceStore","setFeatureDefaults","fixedToolbar","welcomeGuide","showBlockBreadcrumbs","themeStyles","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","ENABLE_EXPERIMENTAL_FSE_BLOCKS","registerBlock","widgetArea","__experimentalFetchLinkSuggestions","search","searchOptions","metadata"],"mappings":";;;;;;;;;;;;AAUA;;AAPA;;AAMA;;AAEA;;AAKA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AAhCA;AACA;AACA;;AAsBA;AACA;AACA;AAWA,MAAMA,cAAc,GAAG,CACtB,WADsB,EAEtB,eAFsB,EAGtB,oBAHsB,EAItB,IAAKC,mCAAwB,EAAxB,GAA6B,CAAE,YAAF,CAAlC,CAJsB,CAAvB;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,SAASC,kBAAT,CAA6BC,MAA7B,EAAqCC,QAArC,EAA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C7CC,MAAAA,eAAe,EAAEC;AAD4B,KAA9C;AAGA;;AACD,+CAAgCzB,QAAhC;AACA0B,EAAAA,aAAa,CAAEC,UAAF,CAAb;AACA;;AAEA3B,EAAAA,QAAQ,CAAC4B,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6C9B,QAA7C,CADD,CAhC0C,CAmC1C;AACA;AACA;AACA;;;AACA,6CAA+B,WAA/B;AACA,uBACC,4BAAC,eAAD;AAAQ,IAAA,mBAAmB,EAAGA,QAA9B;AAAyC,IAAA,OAAO,EAAGC;AAAnD,IADD,EAECF,MAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAM2B,aAAa,GAAKjB,KAAF,IAAa;AAClC,MAAK,CAAEA,KAAP,EAAe;AACd;AACA;;AACD,QAAM;AAAEsB,IAAAA,QAAF;AAAY/B,IAAAA,QAAZ;AAAsBW,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKsB,QAAL,EAAgB;AACf,+DAA+C;AAAE,OAAEpB,IAAF,GAAUoB;AAAZ,KAA/C;AACA;;AACD,iCAAmBpB,IAAnB,EAAyBX,QAAzB;AACA,CATD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\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\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\n\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'core/template-part',\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\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\n\tdispatch( interfaceStore ).setFeatureDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\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\tregisterWidgetGroupBlock();\n\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"]}
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","interfaceStore","setFeatureDefaults","fixedToolbar","welcomeGuide","showBlockBreadcrumbs","themeStyles","blocksStore","__experimentalReapplyBlockTypeFilters","process","env","GUTENBERG_PHASE","enableFSEBlocks","ENABLE_EXPERIMENTAL_FSE_BLOCKS","registerBlock","widgetArea","__experimentalFetchLinkSuggestions","search","searchOptions","metadata"],"mappings":";;;;;;;;;;AAUA;;AAPA;;AAMA;;AAEA;;AAKA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;;;;;AAhCA;AACA;AACA;;AAsBA;AACA;AACA;A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qD;AAGnEC,IAAAA,oBAAoB,EAAE,IAH6C;AAInEC,IAAAA,WAAW,EAAE;AAJsD,GAApE;;AAOA,sBAAUC,aAAV,EAAwBC,qCAAxB;;AACA,wCAAoBb,UAApB;AACA;;AACA,MAAKc,OAAO,CAACC,GAAR,CAAYC,eAAZ,KAAgC,CAArC,EAAyC;AACxC,oEAA8C;AAC7CC,MAAAA,eAAe,EAAEC;AAD4B,KAA9C;AAGA;;AACD,+CAAgCzB,QAAhC;AACA0B,EAAAA,aAAa,CAAEC,UAAF,CAAb;AACA;;AAEA3B,EAAAA,QAAQ,CAAC4B,kCAAT,GAA8C,CAAEC,MAAF,EAAUC,aAAV,KAC7C,kDAAsBD,MAAtB,EAA8BC,aAA9B,EAA6C9B,QAA7C,CADD,CAhC0C,CAmC1C;AACA;AACA;AACA;;;AACA,6CAA+B,WAA/B;AACA,uBACC,4BAAC,eAAD;AAAQ,IAAA,mBAAmB,EAAGA,QAA9B;AAAyC,IAAA,OAAO,EAAGC;AAAnD,IADD,EAECF,MAFD;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;;;AACA,MAAM2B,aAAa,GAAKjB,KAAF,IAAa;AAClC,MAAK,CAAEA,KAAP,EAAe;AACd;AACA;;AACD,QAAM;AAAEsB,IAAAA,QAAF;AAAY/B,IAAAA,QAAZ;AAAsBW,IAAAA;AAAtB,MAA+BF,KAArC;;AACA,MAAKsB,QAAL,EAAgB;AACf,+DAA+C;AAAE,OAAEpB,IAAF,GAAUoB;AAAZ,KAA/C;AACA;;AACD,iCAAmBpB,IAAnB,EAAyBX,QAAzB;AACA,CATD","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tregisterBlockType,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n\tsetFreeformContentHandlerName,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\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\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport './store';\nimport './filters';\nimport * as widgetArea from './blocks/widget-area';\n\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'core/template-part',\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\tblock.name.startsWith( 'core/navigation' )\n\t\t);\n\t} );\n\n\tdispatch( interfaceStore ).setFeatureDefaults( 'core/edit-widgets', {\n\t\tfixedToolbar: false,\n\t\twelcomeGuide: true,\n\t\tshowBlockBreadcrumbs: true,\n\t\tthemeStyles: true,\n\t} );\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\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\tregisterWidgetGroupBlock();\n\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"]}
@@ -3,12 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setWidgetIdForClientId = setWidgetIdForClientId;
7
- exports.setWidgetAreasOpenState = setWidgetAreasOpenState;
8
- exports.setIsWidgetAreaOpen = setIsWidgetAreaOpen;
6
+ exports.saveWidgetAreas = exports.saveWidgetArea = exports.saveEditedWidgetAreas = exports.persistStubPost = exports.moveBlockToWidgetArea = exports.closeGeneralSidebar = void 0;
9
7
  exports.setIsInserterOpened = setIsInserterOpened;
10
8
  exports.setIsListViewOpened = setIsListViewOpened;
11
- exports.moveBlockToWidgetArea = exports.closeGeneralSidebar = exports.saveWidgetArea = exports.saveWidgetAreas = exports.saveEditedWidgetAreas = exports.persistStubPost = void 0;
9
+ exports.setIsWidgetAreaOpen = setIsWidgetAreaOpen;
10
+ exports.setWidgetAreasOpenState = setWidgetAreasOpenState;
11
+ exports.setWidgetIdForClientId = setWidgetIdForClientId;
12
12
 
13
13
  var _i18n = require("@wordpress/i18n");
14
14
 
@@ -44,9 +44,10 @@ var _constants = require("./constants");
44
44
  * @param {Array} blocks Blocks the post should consist of.
45
45
  * @return {Object} The post object.
46
46
  */
47
- const persistStubPost = (id, blocks) => ({
48
- registry
49
- }) => {
47
+ const persistStubPost = (id, blocks) => _ref => {
48
+ let {
49
+ registry
50
+ } = _ref;
50
51
  const stubPost = (0, _utils.createStubPost)(id, blocks);
51
52
  registry.dispatch(_coreData.store).receiveEntityRecords(_utils.KIND, _utils.POST_TYPE, stubPost, {
52
53
  id: stubPost.id
@@ -65,11 +66,12 @@ const persistStubPost = (id, blocks) => ({
65
66
 
66
67
  exports.persistStubPost = persistStubPost;
67
68
 
68
- const saveEditedWidgetAreas = () => async ({
69
- select,
70
- dispatch,
71
- registry
72
- }) => {
69
+ const saveEditedWidgetAreas = () => async _ref2 => {
70
+ let {
71
+ select,
72
+ dispatch,
73
+ registry
74
+ } = _ref2;
73
75
  const editedWidgetAreas = select.getEditedWidgetAreas();
74
76
 
75
77
  if (!(editedWidgetAreas !== null && editedWidgetAreas !== void 0 && editedWidgetAreas.length)) {
@@ -100,10 +102,12 @@ const saveEditedWidgetAreas = () => async ({
100
102
 
101
103
  exports.saveEditedWidgetAreas = saveEditedWidgetAreas;
102
104
 
103
- const saveWidgetAreas = widgetAreas => async ({
104
- dispatch,
105
- registry
106
- }) => {
105
+ const saveWidgetAreas = widgetAreas => async _ref3 => {
106
+ let {
107
+ dispatch,
108
+ registry
109
+ } = _ref3;
110
+
107
111
  try {
108
112
  for (const widgetArea of widgetAreas) {
109
113
  await dispatch.saveWidgetArea(widgetArea.id);
@@ -124,17 +128,21 @@ const saveWidgetAreas = widgetAreas => async ({
124
128
 
125
129
  exports.saveWidgetAreas = saveWidgetAreas;
126
130
 
127
- const saveWidgetArea = widgetAreaId => async ({
128
- dispatch,
129
- select,
130
- registry
131
- }) => {
131
+ const saveWidgetArea = widgetAreaId => async _ref4 => {
132
+ let {
133
+ dispatch,
134
+ select,
135
+ registry
136
+ } = _ref4;
132
137
  const widgets = select.getWidgets();
133
138
  const post = registry.select(_coreData.store).getEditedEntityRecord(_utils.KIND, _utils.POST_TYPE, (0, _utils.buildWidgetAreaPostId)(widgetAreaId)); // Get all widgets from this area
134
139
 
135
- const areaWidgets = Object.values(widgets).filter(({
136
- sidebar
137
- }) => sidebar === widgetAreaId); // Remove all duplicate reference widget instances for legacy widgets.
140
+ const areaWidgets = Object.values(widgets).filter(_ref5 => {
141
+ let {
142
+ sidebar
143
+ } = _ref5;
144
+ return sidebar === widgetAreaId;
145
+ }); // Remove all duplicate reference widget instances for legacy widgets.
138
146
  // Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget
139
147
  // implemented using a function. WordPress doesn't support having more than one instance of these, if you try to
140
148
  // save multiple instances of these in different sidebars you will run into undefined behaviors.
@@ -195,16 +203,22 @@ const saveWidgetArea = widgetAreaId => async ({
195
203
  continue;
196
204
  }
197
205
 
198
- batchTasks.push(({
199
- saveEditedEntityRecord
200
- }) => saveEditedEntityRecord('root', 'widget', widgetId));
206
+ batchTasks.push(_ref6 => {
207
+ let {
208
+ saveEditedEntityRecord
209
+ } = _ref6;
210
+ return saveEditedEntityRecord('root', 'widget', widgetId);
211
+ });
201
212
  } else {
202
213
  // Create a new widget.
203
- batchTasks.push(({
204
- saveEntityRecord
205
- }) => saveEntityRecord('root', 'widget', { ...widget,
206
- sidebar: widgetAreaId
207
- }));
214
+ batchTasks.push(_ref7 => {
215
+ let {
216
+ saveEntityRecord
217
+ } = _ref7;
218
+ return saveEntityRecord('root', 'widget', { ...widget,
219
+ sidebar: widgetAreaId
220
+ });
221
+ });
208
222
  }
209
223
 
210
224
  batchMeta.push({
@@ -215,11 +229,14 @@ const saveWidgetArea = widgetAreaId => async ({
215
229
  }
216
230
 
217
231
  for (const widget of deletedWidgets) {
218
- batchTasks.push(({
219
- deleteEntityRecord
220
- }) => deleteEntityRecord('root', 'widget', widget.id, {
221
- force: true
222
- }));
232
+ batchTasks.push(_ref8 => {
233
+ let {
234
+ deleteEntityRecord
235
+ } = _ref8;
236
+ return deleteEntityRecord('root', 'widget', widget.id, {
237
+ force: true
238
+ });
239
+ });
223
240
  }
224
241
 
225
242
  const records = await registry.dispatch(_coreData.store).__experimentalBatch(batchTasks);
@@ -265,9 +282,10 @@ const saveWidgetArea = widgetAreaId => async ({
265
282
 
266
283
  exports.saveWidgetArea = saveWidgetArea;
267
284
 
268
- const trySaveWidgetArea = widgetAreaId => ({
269
- registry
270
- }) => {
285
+ const trySaveWidgetArea = widgetAreaId => _ref9 => {
286
+ let {
287
+ registry
288
+ } = _ref9;
271
289
  const saveErrorBefore = registry.select(_coreData.store).getLastEntitySaveError(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, widgetAreaId);
272
290
  registry.dispatch(_coreData.store).saveEditedEntityRecord(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, widgetAreaId);
273
291
  const saveErrorAfter = registry.select(_coreData.store).getLastEntitySaveError(_utils.KIND, _utils.WIDGET_AREA_ENTITY_TYPE, widgetAreaId);
@@ -366,9 +384,10 @@ function setIsListViewOpened(isOpen) {
366
384
  */
367
385
 
368
386
 
369
- const closeGeneralSidebar = () => ({
370
- registry
371
- }) => {
387
+ const closeGeneralSidebar = () => _ref10 => {
388
+ let {
389
+ registry
390
+ } = _ref10;
372
391
  registry.dispatch(_interface.store).disableComplementaryArea(_constants.STORE_NAME);
373
392
  };
374
393
  /**
@@ -381,19 +400,23 @@ const closeGeneralSidebar = () => ({
381
400
 
382
401
  exports.closeGeneralSidebar = closeGeneralSidebar;
383
402
 
384
- const moveBlockToWidgetArea = (clientId, widgetAreaId) => async ({
385
- dispatch,
386
- select,
387
- registry
388
- }) => {
403
+ const moveBlockToWidgetArea = (clientId, widgetAreaId) => async _ref11 => {
404
+ let {
405
+ dispatch,
406
+ select,
407
+ registry
408
+ } = _ref11;
389
409
  const sourceRootClientId = registry.select(_blockEditor.store).getBlockRootClientId([clientId]); // Search the top level blocks (widget areas) for the one with the matching
390
410
  // id attribute. Makes the assumption that all top-level blocks are widget
391
411
  // areas.
392
412
 
393
413
  const widgetAreas = registry.select(_blockEditor.store).getBlocks();
394
- const destinationWidgetAreaBlock = widgetAreas.find(({
395
- attributes
396
- }) => attributes.id === widgetAreaId);
414
+ const destinationWidgetAreaBlock = widgetAreas.find(_ref12 => {
415
+ let {
416
+ attributes
417
+ } = _ref12;
418
+ return attributes.id === widgetAreaId;
419
+ });
397
420
  const destinationRootClientId = destinationWidgetAreaBlock.clientId; // Get the index for moving to the end of the the destination widget area.
398
421
 
399
422
  const destinationInnerBlocksClientIds = registry.select(_blockEditor.store).getBlockOrder(destinationRootClientId);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-widgets/src/store/actions.js"],"names":["persistStubPost","id","blocks","registry","stubPost","dispatch","coreStore","receiveEntityRecords","KIND","POST_TYPE","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","noticesStore","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","WIDGET_AREA_ENTITY_TYPE","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","oldWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","saveErrorBefore","saveErrorAfter","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","interfaceStore","disableComplementaryArea","editWidgetsStoreName","moveBlockToWidgetArea","sourceRootClientId","blockEditorStore","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAQA;;AAtBA;AACA;AACA;;AAQA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG,CAAEC,EAAF,EAAMC,MAAN,KAAkB,CAAE;AAAEC,EAAAA;AAAF,CAAF,KAAoB;AACpE,QAAMC,QAAQ,GAAG,2BAAgBH,EAAhB,EAAoBC,MAApB,CAAjB;AACAC,EAAAA,QAAQ,CACNE,QADF,CACYC,eADZ,EAEEC,oBAFF,CAGEC,WAHF,EAIEC,gBAJF,EAKEL,QALF,EAME;AAAEH,IAAAA,EAAE,EAAEG,QAAQ,CAACH;AAAf,GANF,EAOE,KAPF;AASA,SAAOG,QAAP;AACA,CAZM;AAcP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,qBAAqB,GAAG,MAAM,OAAQ;AAClDC,EAAAA,MADkD;AAElDN,EAAAA,QAFkD;AAGlDF,EAAAA;AAHkD,CAAR,KAIpC;AACN,QAAMS,iBAAiB,GAAGD,MA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,YAAZ,KAA8B,OAAQ;AAC1EtB,EAAAA,QAD0E;AAE1EM,EAAAA,MAF0E;AAG1ER,EAAAA;AAH0E,CAAR,KAI5D;AACN,QAAMyF,kBAAkB,GAAGzF,QAAQ,CACjCQ,MADyB,CACjBkF,kBADiB,EAEzBC,oBAFyB,CAEH,CAAEjC,QAAF,CAFG,CAA3B,CADM,CAKN;AACA;AACA;;AACA,QAAMvC,WAAW,GAAGnB,QAAQ,CAACQ,MAAT,CAAiBkF,kBAAjB,EAAoCE,SAApC,EAApB;AACA,QAAMC,0BAA0B,GAAG1E,WAAW,CAAC2E,IAAZ,CAClC,CAAE;AAAEzD,IAAAA;AAAF,GAAF,KAAsBA,UAAU,CAACvC,EAAX,KAAkB0B,YADN,CAAnC;AAGA,QAAMuE,uBAAuB,GAAGF,0BAA0B,CAACnC,QAA3D,CAZM,CAcN;;AACA,QAAMsC,+BAA+B,GAAGhG,QAAQ,CAC9CQ,MADsC,CAC9BkF,kBAD8B,EAEtCO,aAFsC,CAEvBF,uBAFuB,CAAxC;AAGA,QAAMG,gBAAgB,GAAGF,+BAA+B,CAACrF,MAAzD,CAlBM,CAoBN;;AACA,QAAMwF,2BAA2B,GAAG3F,MAAM,CAAC4F,mBAAP,CACnCL,uBADmC,CAApC;;AAIA,MAAK,CAAEI,2BAAP,EAAqC;AACpCjG,IAAAA,QAAQ,CAAC6E,mBAAT,CAA8BgB,uBAA9B,EAAuD,IAAvD;AACA,GA3BK,CA6BN;;;AACA/F,EAAAA,QAAQ,CACNE,QADF,CACYwF,kBADZ,EAEEW,oBAFF,CAGE,CAAE3C,QAAF,CAHF,EAIE+B,kBAJF,EAKEM,uBALF,EAMEG,gBANF;AAQA,CA1CM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost = ( id, blocks ) => ( { registry } ) => {\n\tconst stubPost = createStubPost( id, blocks );\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.receiveEntityRecords(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tstubPost,\n\t\t\t{ id: stubPost.id },\n\t\t\tfalse\n\t\t);\n\treturn stubPost;\n};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas = () => async ( {\n\tselect,\n\tdispatch,\n\tregistry,\n} ) => {\n\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\tif ( ! editedWidgetAreas?.length ) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t} catch ( e ) {\n\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t/* translators: %s: The error message. */\n\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t}\n};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas = ( widgetAreas ) => async ( {\n\tdispatch,\n\tregistry,\n} ) => {\n\ttry {\n\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t}\n\t} finally {\n\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.finishResolution(\n\t\t\t\t'getEntityRecord',\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t);\n\t}\n};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea = ( widgetAreaId ) => async ( {\n\tdispatch,\n\tselect,\n\tregistry,\n} ) => {\n\tconst widgets = select.getWidgets();\n\n\tconst post = registry\n\t\t.select( coreStore )\n\t\t.getEditedEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t);\n\n\t// Get all widgets from this area\n\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t);\n\n\t// Remove all duplicate reference widget instances for legacy widgets.\n\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\tconst usedReferenceWidgets = [];\n\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\tconst { id } = block.attributes;\n\n\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tusedReferenceWidgets.push( id );\n\t\t}\n\t\treturn true;\n\t} );\n\n\t// Determine which widgets have been deleted. We can tell if a widget is\n\t// deleted and not just moved to a different area by looking to see if\n\t// getWidgetAreaForWidgetId() finds something.\n\tconst deletedWidgets = [];\n\tfor ( const widget of areaWidgets ) {\n\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\tif ( ! widgetsNewArea ) {\n\t\t\tdeletedWidgets.push( widget );\n\t\t}\n\t}\n\n\tconst batchMeta = [];\n\tconst batchTasks = [];\n\tconst sidebarWidgetsIds = [];\n\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\tconst block = widgetsBlocks[ i ];\n\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\tconst oldWidget = widgets[ widgetId ];\n\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t// since order is important.\n\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\tif ( oldWidget ) {\n\t\t\t// Update an existing widget.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\twidgetId,\n\t\t\t\t{\n\t\t\t\t\t...widget,\n\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t},\n\t\t\t\t{ undoIgnore: true }\n\t\t\t);\n\n\t\t\tconst hasEdits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\tif ( ! hasEdits ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t);\n\t\t} else {\n\t\t\t// Create a new widget.\n\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t...widget,\n\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tbatchMeta.push( {\n\t\t\tblock,\n\t\t\tposition: i,\n\t\t\tclientId: block.clientId,\n\t\t} );\n\t}\n\tfor ( const widget of deletedWidgets ) {\n\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\tforce: true,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst records = await registry\n\t\t.dispatch( coreStore )\n\t\t.__experimentalBatch( batchTasks );\n\tconst preservedRecords = records.filter(\n\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t);\n\n\tconst failedWidgetNames = [];\n\n\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\tconst widget = preservedRecords[ i ];\n\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\tconst error = registry\n\t\t\t.select( coreStore )\n\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\tif ( error ) {\n\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t}\n\n\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t}\n\t}\n\n\tif ( failedWidgetNames.length ) {\n\t\tthrow new Error(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t)\n\t\t);\n\t}\n\n\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\twidgetAreaId,\n\t\t{\n\t\t\twidgets: sidebarWidgetsIds,\n\t\t},\n\t\t{ undoIgnore: true }\n\t);\n\n\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n};\n\nconst trySaveWidgetArea = ( widgetAreaId ) => ( { registry } ) => {\n\tconst saveErrorBefore = registry\n\t\t.select( coreStore )\n\t\t.getLastEntitySaveError( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.saveEditedEntityRecord( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tconst saveErrorAfter = registry\n\t\t.select( coreStore )\n\t\t.getLastEntitySaveError( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tif ( saveErrorAfter && saveErrorBefore !== saveErrorAfter ) {\n\t\tthrow new Error( saveErrorAfter );\n\t}\n};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editWidgetsStoreName );\n};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea = ( clientId, widgetAreaId ) => async ( {\n\tdispatch,\n\tselect,\n\tregistry,\n} ) => {\n\tconst sourceRootClientId = registry\n\t\t.select( blockEditorStore )\n\t\t.getBlockRootClientId( [ clientId ] );\n\n\t// Search the top level blocks (widget areas) for the one with the matching\n\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t// areas.\n\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t);\n\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t// Get the index for moving to the end of the the destination widget area.\n\tconst destinationInnerBlocksClientIds = registry\n\t\t.select( blockEditorStore )\n\t\t.getBlockOrder( destinationRootClientId );\n\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t// Reveal the widget area, if it's not open.\n\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\tdestinationRootClientId\n\t);\n\n\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t}\n\n\t// Move the block.\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.moveBlocksToPosition(\n\t\t\t[ clientId ],\n\t\t\tsourceRootClientId,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex\n\t\t);\n};\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-widgets/src/store/actions.js"],"names":["persistStubPost","id","blocks","registry","stubPost","dispatch","coreStore","receiveEntityRecords","KIND","POST_TYPE","saveEditedWidgetAreas","select","editedWidgetAreas","getEditedWidgetAreas","length","saveWidgetAreas","noticesStore","createSuccessNotice","type","e","createErrorNotice","message","widgetAreas","widgetArea","saveWidgetArea","finishResolution","WIDGET_AREA_ENTITY_TYPE","widgetAreaId","widgets","getWidgets","post","getEditedEntityRecord","areaWidgets","Object","values","filter","sidebar","usedReferenceWidgets","widgetsBlocks","block","attributes","name","includes","push","deletedWidgets","widget","widgetsNewArea","getWidgetAreaForWidgetId","batchMeta","batchTasks","sidebarWidgetsIds","i","widgetId","oldWidget","editEntityRecord","undoIgnore","hasEdits","hasEditsForEntityRecord","saveEditedEntityRecord","saveEntityRecord","position","clientId","deleteEntityRecord","force","records","__experimentalBatch","preservedRecords","record","hasOwnProperty","failedWidgetNames","__internalWidgetId","error","getLastEntitySaveError","Error","join","trySaveWidgetArea","undefined","saveErrorBefore","saveErrorAfter","setWidgetIdForClientId","setWidgetAreasOpenState","widgetAreasOpenState","setIsWidgetAreaOpen","isOpen","setIsInserterOpened","value","setIsListViewOpened","closeGeneralSidebar","interfaceStore","disableComplementaryArea","editWidgetsStoreName","moveBlockToWidgetArea","sourceRootClientId","blockEditorStore","getBlockRootClientId","getBlocks","destinationWidgetAreaBlock","find","destinationRootClientId","destinationInnerBlocksClientIds","getBlockOrder","destinationIndex","isDestinationWidgetAreaOpen","getIsWidgetAreaOpen","moveBlocksToPosition"],"mappings":";;;;;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AAQA;;AAtBA;AACA;AACA;;AAQA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAG,CAAEC,EAAF,EAAMC,MAAN,KAAkB,QAAoB;AAAA,MAAlB;AAAEC,IAAAA;AAAF,GAAkB;AACpE,QAAMC,QAAQ,GAAG,2BAAgBH,EAAhB,EAAoBC,MAApB,CAAjB;AACAC,EAAAA,QAAQ,CACNE,QADF,CACYC,eADZ,EAEEC,oBAFF,CAGEC,WAHF,EAIEC,gBAJF,EAKEL,QALF,EAME;AAAEH,IAAAA,EAAE,EAAEG,QAAQ,CAACH;AAAf,GANF,EAOE,KAPF;AASA,SAAOG,QAAP;AACA,CAZM;AAcP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,qBAAqB,GAAG,MAAM,eAIpC;AAAA,MAJ4C;AAClDC,IAAAA,MADkD;AAElDN,IAAAA,QAFkD;AAGlDF,IAAAA;AAHkD,GAI5C;AACN,QAAMS,iBAAiB,GAAGD,MAAM,CAACE,oBAAP,EAA1B;;AACA,MAAK,EAAED,iBAAF,aAAEA,iBAAF,eAAEA,iBAAiB,CAAEE,MAArB,CAAL,EAAmC;AAClC;AACA;;AACD,MAAI;AACH,UAAMT,QAAQ,CAACU,eAAT,CAA0BH,iBAA1B,CAAN;AACAT,IAAAA,QAAQ,CACNE,QADF,CACYW,cADZ,EAEEC,mBAFF,CAEuB,cAAI,gBAAJ,CAFvB,EAE+C;AAC7CC,MAAAA,IAAI,EAAE;AADuC,KAF/C;AAKA,GAPD,CAOE,OAAQC,CAAR,EAAY;AACbhB,IAAAA,QAAQ,CAACE,QAAT,C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AMvC,WAAW,GAAGnB,QAAQ,CAACQ,MAAT,CAAiBkF,kBAAjB,EAAoCE,SAApC,EAApB;AACA,QAAMC,0BAA0B,GAAG1E,WAAW,CAAC2E,IAAZ,CAClC;AAAA,QAAE;AAAEzD,MAAAA;AAAF,KAAF;AAAA,WAAsBA,UAAU,CAACvC,EAAX,KAAkB0B,YAAxC;AAAA,GADkC,CAAnC;AAGA,QAAMuE,uBAAuB,GAAGF,0BAA0B,CAACnC,QAA3D,CAZM,CAcN;;AACA,QAAMsC,+BAA+B,GAAGhG,QAAQ,CAC9CQ,MADsC,CAC9BkF,kBAD8B,EAEtCO,aAFsC,CAEvBF,uBAFuB,CAAxC;AAGA,QAAMG,gBAAgB,GAAGF,+BAA+B,CAACrF,MAAzD,CAlBM,CAoBN;;AACA,QAAMwF,2BAA2B,GAAG3F,MAAM,CAAC4F,mBAAP,CACnCL,uBADmC,CAApC;;AAIA,MAAK,CAAEI,2BAAP,EAAqC;AACpCjG,IAAAA,QAAQ,CAAC6E,mBAAT,CAA8BgB,uBAA9B,EAAuD,IAAvD;AACA,GA3BK,CA6BN;;;AACA/F,EAAAA,QAAQ,CACNE,QADF,CACYwF,kBADZ,EAEEW,oBAFF,CAGE,CAAE3C,QAAF,CAHF,EAIE+B,kBAJF,EAKEM,uBALF,EAMEG,gBANF;AAQA,CA1CM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { getWidgetIdFromBlock } from '@wordpress/widgets';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { transformBlockToWidget } from './transformers';\nimport {\n\tbuildWidgetAreaPostId,\n\tbuildWidgetAreasQuery,\n\tcreateStubPost,\n\tKIND,\n\tPOST_TYPE,\n\tWIDGET_AREA_ENTITY_TYPE,\n} from './utils';\nimport { STORE_NAME as editWidgetsStoreName } from './constants';\n\n/**\n * Persists a stub post with given ID to core data store. The post is meant to be in-memory only and\n * shouldn't be saved via the API.\n *\n * @param {string} id Post ID.\n * @param {Array} blocks Blocks the post should consist of.\n * @return {Object} The post object.\n */\nexport const persistStubPost = ( id, blocks ) => ( { registry } ) => {\n\tconst stubPost = createStubPost( id, blocks );\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.receiveEntityRecords(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tstubPost,\n\t\t\t{ id: stubPost.id },\n\t\t\tfalse\n\t\t);\n\treturn stubPost;\n};\n\n/**\n * Converts all the blocks from edited widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * Creates a snackbar notice on either success or error.\n *\n * @return {Function} An action creator.\n */\nexport const saveEditedWidgetAreas = () => async ( {\n\tselect,\n\tdispatch,\n\tregistry,\n} ) => {\n\tconst editedWidgetAreas = select.getEditedWidgetAreas();\n\tif ( ! editedWidgetAreas?.length ) {\n\t\treturn;\n\t}\n\ttry {\n\t\tawait dispatch.saveWidgetAreas( editedWidgetAreas );\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice( __( 'Widgets saved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t} catch ( e ) {\n\t\tregistry.dispatch( noticesStore ).createErrorNotice(\n\t\t\t/* translators: %s: The error message. */\n\t\t\tsprintf( __( 'There was an error. %s' ), e.message ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t}\n};\n\n/**\n * Converts all the blocks from specified widget areas into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {Object[]} widgetAreas Widget areas to save.\n * @return {Function} An action creator.\n */\nexport const saveWidgetAreas = ( widgetAreas ) => async ( {\n\tdispatch,\n\tregistry,\n} ) => {\n\ttry {\n\t\tfor ( const widgetArea of widgetAreas ) {\n\t\t\tawait dispatch.saveWidgetArea( widgetArea.id );\n\t\t}\n\t} finally {\n\t\t// saveEditedEntityRecord resets the resolution status, let's fix it manually\n\t\tawait registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.finishResolution(\n\t\t\t\t'getEntityRecord',\n\t\t\t\tKIND,\n\t\t\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\t\t\tbuildWidgetAreasQuery()\n\t\t\t);\n\t}\n};\n\n/**\n * Converts all the blocks from a widget area specified by ID into widgets,\n * and submits a batch request to save everything at once.\n *\n * @param {string} widgetAreaId ID of the widget area to process.\n * @return {Function} An action creator.\n */\nexport const saveWidgetArea = ( widgetAreaId ) => async ( {\n\tdispatch,\n\tselect,\n\tregistry,\n} ) => {\n\tconst widgets = select.getWidgets();\n\n\tconst post = registry\n\t\t.select( coreStore )\n\t\t.getEditedEntityRecord(\n\t\t\tKIND,\n\t\t\tPOST_TYPE,\n\t\t\tbuildWidgetAreaPostId( widgetAreaId )\n\t\t);\n\n\t// Get all widgets from this area\n\tconst areaWidgets = Object.values( widgets ).filter(\n\t\t( { sidebar } ) => sidebar === widgetAreaId\n\t);\n\n\t// Remove all duplicate reference widget instances for legacy widgets.\n\t// Why? We filter out the widgets with duplicate IDs to prevent adding more than one instance of a widget\n\t// implemented using a function. WordPress doesn't support having more than one instance of these, if you try to\n\t// save multiple instances of these in different sidebars you will run into undefined behaviors.\n\tconst usedReferenceWidgets = [];\n\tconst widgetsBlocks = post.blocks.filter( ( block ) => {\n\t\tconst { id } = block.attributes;\n\n\t\tif ( block.name === 'core/legacy-widget' && id ) {\n\t\t\tif ( usedReferenceWidgets.includes( id ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tusedReferenceWidgets.push( id );\n\t\t}\n\t\treturn true;\n\t} );\n\n\t// Determine which widgets have been deleted. We can tell if a widget is\n\t// deleted and not just moved to a different area by looking to see if\n\t// getWidgetAreaForWidgetId() finds something.\n\tconst deletedWidgets = [];\n\tfor ( const widget of areaWidgets ) {\n\t\tconst widgetsNewArea = select.getWidgetAreaForWidgetId( widget.id );\n\t\tif ( ! widgetsNewArea ) {\n\t\t\tdeletedWidgets.push( widget );\n\t\t}\n\t}\n\n\tconst batchMeta = [];\n\tconst batchTasks = [];\n\tconst sidebarWidgetsIds = [];\n\tfor ( let i = 0; i < widgetsBlocks.length; i++ ) {\n\t\tconst block = widgetsBlocks[ i ];\n\t\tconst widgetId = getWidgetIdFromBlock( block );\n\t\tconst oldWidget = widgets[ widgetId ];\n\t\tconst widget = transformBlockToWidget( block, oldWidget );\n\n\t\t// We'll replace the null widgetId after save, but we track it here\n\t\t// since order is important.\n\t\tsidebarWidgetsIds.push( widgetId );\n\n\t\t// Check oldWidget as widgetId might refer to an ID which has been\n\t\t// deleted, e.g. if a deleted block is restored via undo after saving.\n\t\tif ( oldWidget ) {\n\t\t\t// Update an existing widget.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'root',\n\t\t\t\t'widget',\n\t\t\t\twidgetId,\n\t\t\t\t{\n\t\t\t\t\t...widget,\n\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t},\n\t\t\t\t{ undoIgnore: true }\n\t\t\t);\n\n\t\t\tconst hasEdits = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.hasEditsForEntityRecord( 'root', 'widget', widgetId );\n\n\t\t\tif ( ! hasEdits ) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tbatchTasks.push( ( { saveEditedEntityRecord } ) =>\n\t\t\t\tsaveEditedEntityRecord( 'root', 'widget', widgetId )\n\t\t\t);\n\t\t} else {\n\t\t\t// Create a new widget.\n\t\t\tbatchTasks.push( ( { saveEntityRecord } ) =>\n\t\t\t\tsaveEntityRecord( 'root', 'widget', {\n\t\t\t\t\t...widget,\n\t\t\t\t\tsidebar: widgetAreaId,\n\t\t\t\t} )\n\t\t\t);\n\t\t}\n\n\t\tbatchMeta.push( {\n\t\t\tblock,\n\t\t\tposition: i,\n\t\t\tclientId: block.clientId,\n\t\t} );\n\t}\n\tfor ( const widget of deletedWidgets ) {\n\t\tbatchTasks.push( ( { deleteEntityRecord } ) =>\n\t\t\tdeleteEntityRecord( 'root', 'widget', widget.id, {\n\t\t\t\tforce: true,\n\t\t\t} )\n\t\t);\n\t}\n\n\tconst records = await registry\n\t\t.dispatch( coreStore )\n\t\t.__experimentalBatch( batchTasks );\n\tconst preservedRecords = records.filter(\n\t\t( record ) => ! record.hasOwnProperty( 'deleted' )\n\t);\n\n\tconst failedWidgetNames = [];\n\n\tfor ( let i = 0; i < preservedRecords.length; i++ ) {\n\t\tconst widget = preservedRecords[ i ];\n\t\tconst { block, position } = batchMeta[ i ];\n\n\t\t// Set __internalWidgetId on the block. This will be persisted to the\n\t\t// store when we dispatch receiveEntityRecords( post ) below.\n\t\tpost.blocks[ position ].attributes.__internalWidgetId = widget.id;\n\n\t\tconst error = registry\n\t\t\t.select( coreStore )\n\t\t\t.getLastEntitySaveError( 'root', 'widget', widget.id );\n\t\tif ( error ) {\n\t\t\tfailedWidgetNames.push( block.attributes?.name || block?.name );\n\t\t}\n\n\t\tif ( ! sidebarWidgetsIds[ position ] ) {\n\t\t\tsidebarWidgetsIds[ position ] = widget.id;\n\t\t}\n\t}\n\n\tif ( failedWidgetNames.length ) {\n\t\tthrow new Error(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: List of widget names */\n\t\t\t\t__( 'Could not save the following widgets: %s.' ),\n\t\t\t\tfailedWidgetNames.join( ', ' )\n\t\t\t)\n\t\t);\n\t}\n\n\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\tKIND,\n\t\tWIDGET_AREA_ENTITY_TYPE,\n\t\twidgetAreaId,\n\t\t{\n\t\t\twidgets: sidebarWidgetsIds,\n\t\t},\n\t\t{ undoIgnore: true }\n\t);\n\n\tdispatch( trySaveWidgetArea( widgetAreaId ) );\n\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.receiveEntityRecords( KIND, POST_TYPE, post, undefined );\n};\n\nconst trySaveWidgetArea = ( widgetAreaId ) => ( { registry } ) => {\n\tconst saveErrorBefore = registry\n\t\t.select( coreStore )\n\t\t.getLastEntitySaveError( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tregistry\n\t\t.dispatch( coreStore )\n\t\t.saveEditedEntityRecord( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tconst saveErrorAfter = registry\n\t\t.select( coreStore )\n\t\t.getLastEntitySaveError( KIND, WIDGET_AREA_ENTITY_TYPE, widgetAreaId );\n\tif ( saveErrorAfter && saveErrorBefore !== saveErrorAfter ) {\n\t\tthrow new Error( saveErrorAfter );\n\t}\n};\n\n/**\n * Sets the clientId stored for a particular widgetId.\n *\n * @param {number} clientId Client id.\n * @param {number} widgetId Widget id.\n *\n * @return {Object} Action.\n */\nexport function setWidgetIdForClientId( clientId, widgetId ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_ID_FOR_CLIENT_ID',\n\t\tclientId,\n\t\twidgetId,\n\t};\n}\n\n/**\n * Sets the open state of all the widget areas.\n *\n * @param {Object} widgetAreasOpenState The open states of all the widget areas.\n *\n * @return {Object} Action.\n */\nexport function setWidgetAreasOpenState( widgetAreasOpenState ) {\n\treturn {\n\t\ttype: 'SET_WIDGET_AREAS_OPEN_STATE',\n\t\twidgetAreasOpenState,\n\t};\n}\n\n/**\n * Sets the open state of the widget area.\n *\n * @param {string} clientId The clientId of the widget area.\n * @param {boolean} isOpen Whether the widget area should be opened.\n *\n * @return {Object} Action.\n */\nexport function setIsWidgetAreaOpen( clientId, isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_WIDGET_AREA_OPEN',\n\t\tclientId,\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the inserter.\n *\n * @param {boolean|Object} value Whether the inserter should be\n * opened (true) or closed (false).\n * To specify an insertion point,\n * use an object.\n * @param {string} value.rootClientId The root client ID to insert at.\n * @param {number} value.insertionIndex The index to insert at.\n *\n * @return {Object} Action object.\n */\nexport function setIsInserterOpened( value ) {\n\treturn {\n\t\ttype: 'SET_IS_INSERTER_OPENED',\n\t\tvalue,\n\t};\n}\n\n/**\n * Returns an action object used to open/close the list view.\n *\n * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.\n * @return {Object} Action object.\n */\nexport function setIsListViewOpened( isOpen ) {\n\treturn {\n\t\ttype: 'SET_IS_LIST_VIEW_OPENED',\n\t\tisOpen,\n\t};\n}\n\n/**\n * Returns an action object signalling that the user closed the sidebar.\n *\n * @return {Object} Action creator.\n */\nexport const closeGeneralSidebar = () => ( { registry } ) => {\n\tregistry\n\t\t.dispatch( interfaceStore )\n\t\t.disableComplementaryArea( editWidgetsStoreName );\n};\n\n/**\n * Action that handles moving a block between widget areas\n *\n * @param {string} clientId The clientId of the block to move.\n * @param {string} widgetAreaId The id of the widget area to move the block to.\n */\nexport const moveBlockToWidgetArea = ( clientId, widgetAreaId ) => async ( {\n\tdispatch,\n\tselect,\n\tregistry,\n} ) => {\n\tconst sourceRootClientId = registry\n\t\t.select( blockEditorStore )\n\t\t.getBlockRootClientId( [ clientId ] );\n\n\t// Search the top level blocks (widget areas) for the one with the matching\n\t// id attribute. Makes the assumption that all top-level blocks are widget\n\t// areas.\n\tconst widgetAreas = registry.select( blockEditorStore ).getBlocks();\n\tconst destinationWidgetAreaBlock = widgetAreas.find(\n\t\t( { attributes } ) => attributes.id === widgetAreaId\n\t);\n\tconst destinationRootClientId = destinationWidgetAreaBlock.clientId;\n\n\t// Get the index for moving to the end of the the destination widget area.\n\tconst destinationInnerBlocksClientIds = registry\n\t\t.select( blockEditorStore )\n\t\t.getBlockOrder( destinationRootClientId );\n\tconst destinationIndex = destinationInnerBlocksClientIds.length;\n\n\t// Reveal the widget area, if it's not open.\n\tconst isDestinationWidgetAreaOpen = select.getIsWidgetAreaOpen(\n\t\tdestinationRootClientId\n\t);\n\n\tif ( ! isDestinationWidgetAreaOpen ) {\n\t\tdispatch.setIsWidgetAreaOpen( destinationRootClientId, true );\n\t}\n\n\t// Move the block.\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.moveBlocksToPosition(\n\t\t\t[ clientId ],\n\t\t\tsourceRootClientId,\n\t\t\tdestinationRootClientId,\n\t\t\tdestinationIndex\n\t\t);\n};\n"]}