@wordpress/edit-site 5.12.16 → 5.12.18

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 (31) hide show
  1. package/build/components/header-edit-mode/document-actions/index.js +11 -25
  2. package/build/components/header-edit-mode/document-actions/index.js.map +1 -1
  3. package/build/components/page/index.js +3 -3
  4. package/build/components/page/index.js.map +1 -1
  5. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +1 -1
  6. package/build/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  7. package/build/components/sidebar-navigation-screen-template/home-template-details.js +2 -2
  8. package/build/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
  9. package/build/hooks/push-changes-to-global-styles/index.js +147 -27
  10. package/build/hooks/push-changes-to-global-styles/index.js.map +1 -1
  11. package/build-module/components/header-edit-mode/document-actions/index.js +11 -26
  12. package/build-module/components/header-edit-mode/document-actions/index.js.map +1 -1
  13. package/build-module/components/page/index.js +3 -3
  14. package/build-module/components/page/index.js.map +1 -1
  15. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +1 -1
  16. package/build-module/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js.map +1 -1
  17. package/build-module/components/sidebar-navigation-screen-template/home-template-details.js +2 -2
  18. package/build-module/components/sidebar-navigation-screen-template/home-template-details.js.map +1 -1
  19. package/build-module/hooks/push-changes-to-global-styles/index.js +148 -28
  20. package/build-module/hooks/push-changes-to-global-styles/index.js.map +1 -1
  21. package/build-style/style-rtl.css +25 -11
  22. package/build-style/style.css +25 -11
  23. package/package.json +39 -39
  24. package/src/components/header-edit-mode/document-actions/index.js +13 -26
  25. package/src/components/header-edit-mode/document-actions/style.scss +14 -6
  26. package/src/components/page/index.js +8 -8
  27. package/src/components/page/style.scss +8 -5
  28. package/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js +11 -10
  29. package/src/components/sidebar-navigation-screen-template/home-template-details.js +4 -2
  30. package/src/components/table/style.scss +1 -0
  31. package/src/hooks/push-changes-to-global-styles/index.js +152 -28
@@ -42,8 +42,15 @@ var _store = require("../../../store");
42
42
  /**
43
43
  * Internal dependencies
44
44
  */
45
+ const typeLabels = {
46
+ wp_block: (0, _i18n.__)('Editing pattern:'),
47
+ wp_navigation: (0, _i18n.__)('Editing navigation menu:'),
48
+ wp_template: (0, _i18n.__)('Editing template:'),
49
+ wp_template_part: (0, _i18n.__)('Editing template part:')
50
+ };
51
+
45
52
  function DocumentActions() {
46
- const isPage = (0, _data.useSelect)(select => select(_store.store).isPage());
53
+ const isPage = (0, _data.useSelect)(select => select(_store.store).isPage(), []);
47
54
  return isPage ? (0, _element.createElement)(PageDocumentActions, null) : (0, _element.createElement)(TemplateDocumentActions, null);
48
55
  }
49
56
 
@@ -110,6 +117,8 @@ function TemplateDocumentActions({
110
117
  className,
111
118
  onBack
112
119
  }) {
120
+ var _typeLabels$record$ty;
121
+
113
122
  const {
114
123
  isLoaded,
115
124
  record,
@@ -127,7 +136,6 @@ function TemplateDocumentActions({
127
136
  }, (0, _i18n.__)('Document not found'));
128
137
  }
129
138
 
130
- const entityLabel = getEntityLabel(record.type);
131
139
  let typeIcon = icon;
132
140
 
133
141
  if (record.type === 'wp_navigation') {
@@ -142,9 +150,7 @@ function TemplateDocumentActions({
142
150
  onBack: onBack
143
151
  }, (0, _element.createElement)(_components.VisuallyHidden, {
144
152
  as: "span"
145
- }, (0, _i18n.sprintf)(
146
- /* translators: %s: the entity being edited, like "template"*/
147
- (0, _i18n.__)('Editing %s: '), entityLabel)), getTitle());
153
+ }, (_typeLabels$record$ty = typeLabels[record.type]) !== null && _typeLabels$record$ty !== void 0 ? _typeLabels$record$ty : typeLabels.wp_template), getTitle());
148
154
  }
149
155
 
150
156
  function BaseDocumentActions({
@@ -181,24 +187,4 @@ function BaseDocumentActions({
181
187
  className: "edit-site-document-actions__shortcut"
182
188
  }, _keycodes.displayShortcut.primary('k'))));
183
189
  }
184
-
185
- function getEntityLabel(entityType) {
186
- let label = '';
187
-
188
- switch (entityType) {
189
- case 'wp_navigation':
190
- label = 'navigation menu';
191
- break;
192
-
193
- case 'wp_template_part':
194
- label = 'template part';
195
- break;
196
-
197
- default:
198
- label = 'template';
199
- break;
200
- }
201
-
202
- return label;
203
- }
204
190
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/header-edit-mode/document-actions/index.js"],"names":["DocumentActions","isPage","select","editSiteStore","PageDocumentActions","hasPageContentFocus","hasResolved","isFound","title","_hasPageContentFocus","getEditedPostContext","getEditedEntityRecord","hasFinishedResolution","coreStore","context","queryArgs","postType","postId","page","setHasPageContentFocus","hasEditedTemplate","setHasEditedTemplate","prevHasPageContentFocus","current","pageIcon","TemplateDocumentActions","className","onBack","isLoaded","record","getTitle","icon","entityLabel","getEntityLabel","type","typeIcon","navigationIcon","symbol","BaseDocumentActions","children","open","openCommandCenter","commandsStore","chevronRightSmall","chevronLeftSmall","event","stopPropagation","displayShortcut","primary","entityType","label"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAOA;;AAEA;;AAKA;;AACA;;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAIe,SAASA,eAAT,GAA2B;AACzC,QAAMC,MAAM,GAAG,qBAAaC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAwBF,MAAxB,EAAzB,CAAf;AACA,SAAOA,MAAM,GAAG,4BAAC,mBAAD,OAAH,GAA6B,4BAAC,uBAAD,OAA1C;AACA;;AAED,SAASG,mBAAT,GAA+B;AAC9B,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,WAAvB;AAAoCC,IAAAA,OAApC;AAA6CC,IAAAA;AAA7C,MAAuD,qBAC1DN,MAAF,IAAc;AACb,UAAM;AACLG,MAAAA,mBAAmB,EAAEI,oBADhB;AA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AA;AAA7B,CAA9B,EAAsE;AACrE,QAAM;AAAEa,IAAAA,IAAI,EAAEC;AAAR,MAA8B,uBAAaC,eAAb,CAApC;AACA,SACC;AACC,IAAA,SAAS,EAAG,yBAAY,4BAAZ,EAA0ChB,SAA1C;AADb,KAGGC,MAAM,IACP,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,IAAI,EAAG,qBAAUgB,wBAAV,GAA8BC,uBAFtC;AAGC,IAAA,OAAO,EAAKC,KAAF,IAAa;AACtBA,MAAAA,KAAK,CAACC,eAAN;AACAnB,MAAAA,MAAM;AACN;AANF,KAQG,cAAI,MAAJ,CARH,CAJF,EAeC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,OAAO,EAAG,MAAMc,iBAAiB;AAFlC,KAIC,4BAAC,gCAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,OAAO,EAAC;AAHT,KAKC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGV;AAAlB,IALD,EAMC,4BAAC,8BAAD;AAAM,IAAA,IAAI,EAAC,MAAX;AAAkB,IAAA,EAAE,EAAC;AAArB,KACGQ,QADH,CAND,CAJD,EAcC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGQ,0BAAgBC,OAAhB,CAAyB,GAAzB,CADH,CAdD,CAfD,CADD;AAoCA;;AAED,SAASf,cAAT,CAAyBgB,UAAzB,EAAsC;AACrC,MAAIC,KAAK,GAAG,EAAZ;;AACA,UAASD,UAAT;AACC,SAAK,eAAL;AACCC,MAAAA,KAAK,GAAG,iBAAR;AACA;;AACD,SAAK,kBAAL;AACCA,MAAAA,KAAK,GAAG,eAAR;AACA;;AACD;AACCA,MAAAA,KAAK,GAAG,UAAR;AACA;AATF;;AAYA,SAAOA,KAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { sprintf, __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { store as commandsStore } from '@wordpress/commands';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\nimport { store as editSiteStore } from '../../../store';\n\nexport default function DocumentActions() {\n\tconst isPage = useSelect( ( select ) => select( editSiteStore ).isPage() );\n\treturn isPage ? <PageDocumentActions /> : <TemplateDocumentActions />;\n}\n\nfunction PageDocumentActions() {\n\tconst { hasPageContentFocus, hasResolved, isFound, title } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasPageContentFocus: _hasPageContentFocus,\n\t\t\t\tgetEditedPostContext,\n\t\t\t} = select( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst context = getEditedPostContext();\n\t\t\tconst queryArgs = [ 'postType', context.postType, context.postId ];\n\t\t\tconst page = getEditedEntityRecord( ...queryArgs );\n\t\t\treturn {\n\t\t\t\thasPageContentFocus: _hasPageContentFocus(),\n\t\t\t\thasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\tqueryArgs\n\t\t\t\t),\n\t\t\t\tisFound: !! page,\n\t\t\t\ttitle: page?.title,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setHasPageContentFocus } = useDispatch( editSiteStore );\n\n\tconst [ hasEditedTemplate, setHasEditedTemplate ] = useState( false );\n\tconst prevHasPageContentFocus = useRef( false );\n\tuseEffect( () => {\n\t\tif ( prevHasPageContentFocus.current && ! hasPageContentFocus ) {\n\t\t\tsetHasEditedTemplate( true );\n\t\t}\n\t\tprevHasPageContentFocus.current = hasPageContentFocus;\n\t}, [ hasPageContentFocus ] );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\tif ( ! isFound ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Document not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn hasPageContentFocus ? (\n\t\t<BaseDocumentActions\n\t\t\tclassName={ classnames( 'is-page', {\n\t\t\t\t'is-animated': hasEditedTemplate,\n\t\t\t} ) }\n\t\t\ticon={ pageIcon }\n\t\t>\n\t\t\t{ title }\n\t\t</BaseDocumentActions>\n\t) : (\n\t\t<TemplateDocumentActions\n\t\t\tclassName=\"is-animated\"\n\t\t\tonBack={ () => setHasPageContentFocus( true ) }\n\t\t/>\n\t);\n}\n\nfunction TemplateDocumentActions( { className, onBack } ) {\n\tconst { isLoaded, record, getTitle, icon } = useEditedEntityRecord();\n\n\tif ( ! isLoaded ) {\n\t\treturn null;\n\t}\n\n\tif ( ! record ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Document not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tconst entityLabel = getEntityLabel( record.type );\n\n\tlet typeIcon = icon;\n\tif ( record.type === 'wp_navigation' ) {\n\t\ttypeIcon = navigationIcon;\n\t} else if ( record.type === 'wp_block' ) {\n\t\ttypeIcon = symbol;\n\t}\n\n\treturn (\n\t\t<BaseDocumentActions\n\t\t\tclassName={ className }\n\t\t\ticon={ typeIcon }\n\t\t\tonBack={ onBack }\n\t\t>\n\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t{ sprintf(\n\t\t\t\t\t/* translators: %s: the entity being edited, like \"template\"*/\n\t\t\t\t\t__( 'Editing %s: ' ),\n\t\t\t\t\tentityLabel\n\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t\t{ getTitle() }\n\t\t</BaseDocumentActions>\n\t);\n}\n\nfunction BaseDocumentActions( { className, icon, children, onBack } ) {\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-document-actions', className ) }\n\t\t>\n\t\t\t{ onBack && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-document-actions__back\"\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tonBack();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-document-actions__command\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-site-document-actions__title\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<BlockIcon icon={ icon } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t\t<span className=\"edit-site-document-actions__shortcut\">\n\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n\nfunction getEntityLabel( entityType ) {\n\tlet label = '';\n\tswitch ( entityType ) {\n\t\tcase 'wp_navigation':\n\t\t\tlabel = 'navigation menu';\n\t\t\tbreak;\n\t\tcase 'wp_template_part':\n\t\t\tlabel = 'template part';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tlabel = 'template';\n\t\t\tbreak;\n\t}\n\n\treturn label;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/header-edit-mode/document-actions/index.js"],"names":["typeLabels","wp_block","wp_navigation","wp_template","wp_template_part","DocumentActions","isPage","select","editSiteStore","PageDocumentActions","hasPageContentFocus","hasResolved","isFound","title","_hasPageContentFocus","getEditedPostContext","getEditedEntityRecord","hasFinishedResolution","coreStore","context","queryArgs","postType","postId","page","setHasPageContentFocus","hasEditedTemplate","setHasEditedTemplate","prevHasPageContentFocus","current","pageIcon","TemplateDocumentActions","className","onBack","isLoaded","record","getTitle","icon","typeIcon","type","navigationIcon","symbol","BaseDocumentActions","children","open","openCommandCenter","commandsStore","chevronRightSmall","chevronLeftSmall","event","stopPropagation","displayShortcut","primary"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AAOA;;AAEA;;AAKA;;AACA;;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAsBA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,QAAQ,EAAE,cAAI,kBAAJ,CADQ;AAElBC,EAAAA,aAAa,EAAE,cAAI,0BAAJ,CAFG;AAGlBC,EAAAA,WAAW,EAAE,cAAI,mBAAJ,CAHK;AAIlBC,EAAAA,gBAAgB,EAAE,cAAI,wBAAJ;AAJA,CAAnB;;AAOe,SAASC,eAAT,GAA2B;AACzC,QAAMC,MAAM,GAAG,qBACZC,MAAF,IAAcA,MAAM,CAAEC,YAAF,CAAN,CAAwBF,MAAxB,EADA,EAEd,EAFc,CAAf;AAIA,SAAOA,MAAM,GAAG,4BAAC,mBAAD,OAAH,GAA6B,4BAAC,uBAAD,OAA1C;AACA;;AAED,SAASG,mBAAT,GAA+B;AAC9B,QAAM;AAAEC,IAAAA,mBAAF;AAAuBC,IAAAA,WAAvB;AAAoCC,IAAAA,OAApC;AAA6CC,IAAAA;AAA7C,MAAuD,qBAC1DN,MAAF,IAAc;AACb,UAAM;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A7B,CAA9B,EAAsE;AACrE,QAAM;AAAEW,IAAAA,IAAI,EAAEC;AAAR,MAA8B,uBAAaC,eAAb,CAApC;AACA,SACC;AACC,IAAA,SAAS,EAAG,yBAAY,4BAAZ,EAA0Cd,SAA1C;AADb,KAGGC,MAAM,IACP,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,kCADX;AAEC,IAAA,IAAI,EAAG,qBAAUc,wBAAV,GAA8BC,uBAFtC;AAGC,IAAA,OAAO,EAAKC,KAAF,IAAa;AACtBA,MAAAA,KAAK,CAACC,eAAN;AACAjB,MAAAA,MAAM;AACN;AANF,KAQG,cAAI,MAAJ,CARH,CAJF,EAeC,4BAAC,kBAAD;AACC,IAAA,SAAS,EAAC,qCADX;AAEC,IAAA,OAAO,EAAG,MAAMY,iBAAiB;AAFlC,KAIC,4BAAC,gCAAD;AACC,IAAA,SAAS,EAAC,mCADX;AAEC,IAAA,OAAO,EAAG,CAFX;AAGC,IAAA,OAAO,EAAC;AAHT,KAKC,4BAAC,sBAAD;AAAW,IAAA,IAAI,EAAGR;AAAlB,IALD,EAMC,4BAAC,8BAAD;AAAM,IAAA,IAAI,EAAC,MAAX;AAAkB,IAAA,EAAE,EAAC;AAArB,KACGM,QADH,CAND,CAJD,EAcC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGQ,0BAAgBC,OAAhB,CAAyB,GAAzB,CADH,CAdD,CAfD,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\tVisuallyHidden,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport { store as commandsStore } from '@wordpress/commands';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\nimport { store as editSiteStore } from '../../../store';\n\nconst typeLabels = {\n\twp_block: __( 'Editing pattern:' ),\n\twp_navigation: __( 'Editing navigation menu:' ),\n\twp_template: __( 'Editing template:' ),\n\twp_template_part: __( 'Editing template part:' ),\n};\n\nexport default function DocumentActions() {\n\tconst isPage = useSelect(\n\t\t( select ) => select( editSiteStore ).isPage(),\n\t\t[]\n\t);\n\treturn isPage ? <PageDocumentActions /> : <TemplateDocumentActions />;\n}\n\nfunction PageDocumentActions() {\n\tconst { hasPageContentFocus, hasResolved, isFound, title } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasPageContentFocus: _hasPageContentFocus,\n\t\t\t\tgetEditedPostContext,\n\t\t\t} = select( editSiteStore );\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst context = getEditedPostContext();\n\t\t\tconst queryArgs = [ 'postType', context.postType, context.postId ];\n\t\t\tconst page = getEditedEntityRecord( ...queryArgs );\n\t\t\treturn {\n\t\t\t\thasPageContentFocus: _hasPageContentFocus(),\n\t\t\t\thasResolved: hasFinishedResolution(\n\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\tqueryArgs\n\t\t\t\t),\n\t\t\t\tisFound: !! page,\n\t\t\t\ttitle: page?.title,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { setHasPageContentFocus } = useDispatch( editSiteStore );\n\n\tconst [ hasEditedTemplate, setHasEditedTemplate ] = useState( false );\n\tconst prevHasPageContentFocus = useRef( false );\n\tuseEffect( () => {\n\t\tif ( prevHasPageContentFocus.current && ! hasPageContentFocus ) {\n\t\t\tsetHasEditedTemplate( true );\n\t\t}\n\t\tprevHasPageContentFocus.current = hasPageContentFocus;\n\t}, [ hasPageContentFocus ] );\n\n\tif ( ! hasResolved ) {\n\t\treturn null;\n\t}\n\n\tif ( ! isFound ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Document not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn hasPageContentFocus ? (\n\t\t<BaseDocumentActions\n\t\t\tclassName={ classnames( 'is-page', {\n\t\t\t\t'is-animated': hasEditedTemplate,\n\t\t\t} ) }\n\t\t\ticon={ pageIcon }\n\t\t>\n\t\t\t{ title }\n\t\t</BaseDocumentActions>\n\t) : (\n\t\t<TemplateDocumentActions\n\t\t\tclassName=\"is-animated\"\n\t\t\tonBack={ () => setHasPageContentFocus( true ) }\n\t\t/>\n\t);\n}\n\nfunction TemplateDocumentActions( { className, onBack } ) {\n\tconst { isLoaded, record, getTitle, icon } = useEditedEntityRecord();\n\n\tif ( ! isLoaded ) {\n\t\treturn null;\n\t}\n\n\tif ( ! record ) {\n\t\treturn (\n\t\t\t<div className=\"edit-site-document-actions\">\n\t\t\t\t{ __( 'Document not found' ) }\n\t\t\t</div>\n\t\t);\n\t}\n\n\tlet typeIcon = icon;\n\tif ( record.type === 'wp_navigation' ) {\n\t\ttypeIcon = navigationIcon;\n\t} else if ( record.type === 'wp_block' ) {\n\t\ttypeIcon = symbol;\n\t}\n\n\treturn (\n\t\t<BaseDocumentActions\n\t\t\tclassName={ className }\n\t\t\ticon={ typeIcon }\n\t\t\tonBack={ onBack }\n\t\t>\n\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t{ typeLabels[ record.type ] ?? typeLabels.wp_template }\n\t\t\t</VisuallyHidden>\n\t\t\t{ getTitle() }\n\t\t</BaseDocumentActions>\n\t);\n}\n\nfunction BaseDocumentActions( { className, icon, children, onBack } ) {\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-site-document-actions', className ) }\n\t\t>\n\t\t\t{ onBack && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"edit-site-document-actions__back\"\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tonBack();\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t<Button\n\t\t\t\tclassName=\"edit-site-document-actions__command\"\n\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t>\n\t\t\t\t<HStack\n\t\t\t\t\tclassName=\"edit-site-document-actions__title\"\n\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\tjustify=\"center\"\n\t\t\t\t>\n\t\t\t\t\t<BlockIcon icon={ icon } />\n\t\t\t\t\t<Text size=\"body\" as=\"h1\">\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</Text>\n\t\t\t\t</HStack>\n\t\t\t\t<span className=\"edit-site-document-actions__shortcut\">\n\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t</span>\n\t\t\t</Button>\n\t\t</div>\n\t);\n}\n"]}
@@ -40,12 +40,12 @@ function Page({
40
40
  return (0, _element.createElement)(_interface.NavigableRegion, {
41
41
  className: classes,
42
42
  ariaLabel: title
43
+ }, (0, _element.createElement)("div", {
44
+ className: "edit-site-page-content"
43
45
  }, !hideTitleFromUI && title && (0, _element.createElement)(_header.default, {
44
46
  title: title,
45
47
  subTitle: subTitle,
46
48
  actions: actions
47
- }), (0, _element.createElement)("div", {
48
- className: "edit-site-page-content"
49
- }, children, (0, _element.createElement)(_editor.EditorSnackbars, null)));
49
+ }), children), (0, _element.createElement)(_editor.EditorSnackbars, null));
50
50
  }
51
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/page/index.js"],"names":["Page","title","subTitle","actions","children","className","hideTitleFromUI","classes"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,IAAT,CAAe;AAC7BC,EAAAA,KAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,OAH6B;AAI7BC,EAAAA,QAJ6B;AAK7BC,EAAAA,SAL6B;AAM7BC,EAAAA,eAAe,GAAG;AANW,CAAf,EAOX;AACH,QAAMC,OAAO,GAAG,yBAAY,gBAAZ,EAA8BF,SAA9B,CAAhB;AAEA,SACC,4BAAC,0BAAD;AAAiB,IAAA,SAAS,EAAGE,OAA7B;AAAuC,IAAA,SAAS,EAAGN;AAAnD,KACG,CAAEK,eAAF,IAAqBL,KAArB,IACD,4BAAC,eAAD;AACC,IAAA,KAAK,EAAGA,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,OAAO,EAAGC;AAHX,IAFF,EAQC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGC,QADH,EAEC,4BAAC,uBAAD,OAFD,CARD,CADD;AAeA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/interface';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Header from './header';\n\nexport default function Page( {\n\ttitle,\n\tsubTitle,\n\tactions,\n\tchildren,\n\tclassName,\n\thideTitleFromUI = false,\n} ) {\n\tconst classes = classnames( 'edit-site-page', className );\n\n\treturn (\n\t\t<NavigableRegion className={ classes } ariaLabel={ title }>\n\t\t\t{ ! hideTitleFromUI && title && (\n\t\t\t\t<Header\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tsubTitle={ subTitle }\n\t\t\t\t\tactions={ actions }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<div className=\"edit-site-page-content\">\n\t\t\t\t{ children }\n\t\t\t\t<EditorSnackbars />\n\t\t\t</div>\n\t\t</NavigableRegion>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/page/index.js"],"names":["Page","title","subTitle","actions","children","className","hideTitleFromUI","classes"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAKA;;AAdA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,IAAT,CAAe;AAC7BC,EAAAA,KAD6B;AAE7BC,EAAAA,QAF6B;AAG7BC,EAAAA,OAH6B;AAI7BC,EAAAA,QAJ6B;AAK7BC,EAAAA,SAL6B;AAM7BC,EAAAA,eAAe,GAAG;AANW,CAAf,EAOX;AACH,QAAMC,OAAO,GAAG,yBAAY,gBAAZ,EAA8BF,SAA9B,CAAhB;AAEA,SACC,4BAAC,0BAAD;AAAiB,IAAA,SAAS,EAAGE,OAA7B;AAAuC,IAAA,SAAS,EAAGN;AAAnD,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAEK,eAAF,IAAqBL,KAArB,IACD,4BAAC,eAAD;AACC,IAAA,KAAK,EAAGA,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,OAAO,EAAGC;AAHX,IAFF,EAQGC,QARH,CADD,EAWC,4BAAC,uBAAD,OAXD,CADD;AAeA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { NavigableRegion } from '@wordpress/interface';\nimport { EditorSnackbars } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport Header from './header';\n\nexport default function Page( {\n\ttitle,\n\tsubTitle,\n\tactions,\n\tchildren,\n\tclassName,\n\thideTitleFromUI = false,\n} ) {\n\tconst classes = classnames( 'edit-site-page', className );\n\n\treturn (\n\t\t<NavigableRegion className={ classes } ariaLabel={ title }>\n\t\t\t<div className=\"edit-site-page-content\">\n\t\t\t\t{ ! hideTitleFromUI && title && (\n\t\t\t\t\t<Header\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\tsubTitle={ subTitle }\n\t\t\t\t\t\tactions={ actions }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t\t<EditorSnackbars />\n\t\t</NavigableRegion>\n\t);\n}\n"]}
@@ -124,7 +124,7 @@ function LeafMoreMenu(props) {
124
124
  moveBlocksDown([clientId], rootClientId);
125
125
  onClose();
126
126
  }
127
- }, (0, _i18n.__)('Move down')), block.attributes?.id && (0, _element.createElement)(_components.MenuItem, {
127
+ }, (0, _i18n.__)('Move down')), block.attributes?.type === 'page' && block.attributes?.id && (0, _element.createElement)(_components.MenuItem, {
128
128
  onClick: () => {
129
129
  onGoToPage(block);
130
130
  onClose();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js"],"names":["POPOVER_PROPS","className","placement","useLocation","useHistory","routerPrivateApis","LeafMoreMenu","props","location","history","block","clientId","moveBlocksDown","moveBlocksUp","removeBlocks","blockEditorStore","removeLabel","maximumLength","goToLabel","rootClientId","select","getBlockRootClientId","onGoToPage","selectedBlock","attributes","name","kind","id","type","push","postType","postId","wp_theme_preview","backPath","params","moreVertical","onClose","chevronUp","chevronDown"],"mappings":";;;;;;;AAOA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAUA;;AAIA;;AACA;;AAzBA;AACA;AACA;AAUA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,EAAAA,SAAS,EAAE;AAFU,CAAtB;AAKA;AACA;AACA;;AAQA,MAAM;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,IAA8B,wBAAQC,mBAAR,CAApC;;AAEe,SAASC,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAMC,QAAQ,GAAGL,WAAW,EAA5B;AACA,QAAMM,OAAO,GAAGL,UAAU,EAA1B;AACA,QAA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D,EA+BC,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfJ,MAAAA,YAAY,CAAE,CAAEH,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAyB,MAAAA,OAAO;AACP;AAJF,KAMGpB,WANH,CADD,CA/BD,CATF,CADD;AAuDA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { chevronUp, chevronDown, moreVertical } from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { BlockTitle, store as blockEditorStore } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tplacement: 'bottom-start',\n};\n\n/**\n * Internal dependencies\n */\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from '../../utils/is-previewing-theme';\nimport { unlock } from '../../lock-unlock';\nimport { getPathFromURL } from '../sync-state-with-url/use-sync-path-with-url';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function LeafMoreMenu( props ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst { block } = props;\n\tconst { clientId } = block;\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst goToLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Go to %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst onGoToPage = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\t\twp_theme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tbackPath: getPathFromURL( location.params ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\t\twp_theme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tbackPath: getPathFromURL( location.params ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{ block.attributes?.id && (\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonGoToPage( block );\n\t\t\t\t\t\t\t\t\tonClose();\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{ goToLabel }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-navigation-menus/leaf-more-menu.js"],"names":["POPOVER_PROPS","className","placement","useLocation","useHistory","routerPrivateApis","LeafMoreMenu","props","location","history","block","clientId","moveBlocksDown","moveBlocksUp","removeBlocks","blockEditorStore","removeLabel","maximumLength","goToLabel","rootClientId","select","getBlockRootClientId","onGoToPage","selectedBlock","attributes","name","kind","id","type","push","postType","postId","wp_theme_preview","backPath","params","moreVertical","onClose","chevronUp","chevronDown"],"mappings":";;;;;;;AAOA;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAUA;;AAIA;;AACA;;AAzBA;AACA;AACA;AAUA,MAAMA,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,EAAAA,SAAS,EAAE;AAFU,CAAtB;AAKA;AACA;AACA;;AAQA,MAAM;AAAEC,EAAAA,WAAF;AAAeC,EAAAA;AAAf,IAA8B,wBAAQC,mBAAR,CAApC;;AAEe,SAASC,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAMC,QAAQ,GAAGL,WAAW,EAA5B;AACA,QAAMM,OAAO,GAAGL,UAAU,EAA1B;AACA,QAAM;AAAEM,IAAAA;AAAF,MAAYH,KAAlB;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAeD,KAArB;AACA,QAAM;AAAEE,IAAAA,cAAF;AAAkBC,IAAAA,YAAlB;AAAgCC,IAAAA;AAAhC,MACL,uBAAaC,kBAAb,CADD;AAGA,QAAMC,WAAW,GAAG;AACnB;AACA,gBAAI,WAAJ,CAFmB,EAGnB,6BAAY;AAAEL,IAAAA,QAAF;AAAYM,IAAAA,aAAa,EAAE;AAA3B,GAAZ,CAHmB,CAApB;AAMA,QAAMC,SAAS,GAAG;AACjB;AACA,gBAAI,UAAJ,CAFiB,EAGjB,6BAAY;AAAEP,IAAAA,QAAF;AAAYM,IAAAA,aAAa,EAAE;AAA3B,GAAZ,CAHiB,CAAlB;AAMA,QAAME,YAAY,GAAG,qBAClBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA2BD,MAAM,CAAEL,kBAAF,CAAvC;AAEA,WAAOM,oBAAoB,CAAEV,QAAF,CAA3B;AACA,GALmB,EAMpB,CAAEA,QAAF,CANoB,CAArB;A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;AAEC,IAAA,OAAO,EAAG,MAAM;AACfxB,MAAAA,YAAY,CAAE,CAAEF,QAAF,CAAF,EAAgBQ,YAAhB,CAAZ;AACAiB,MAAAA,OAAO;AACP;AALF,KAOG,cAAI,SAAJ,CAPH,CADD,EAUC,4BAAC,oBAAD;AACC,IAAA,IAAI,EAAGE,kBADR;AAEC,IAAA,OAAO,EAAG,MAAM;AACf1B,MAAAA,cAAc,CAAE,CAAED,QAAF,CAAF,EAAgBQ,YAAhB,CAAd;AACAiB,MAAAA,OAAO;AACP;AALF,KAOG,cAAI,WAAJ,CAPH,CAVD,EAmBG1B,KAAK,CAACc,UAAN,EAAkBI,IAAlB,KAA2B,MAA3B,IACDlB,KAAK,CAACc,UAAN,EAAkBG,EADjB,IAEA,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfL,MAAAA,UAAU,CAAEZ,KAAF,CAAV;AACA0B,MAAAA,OAAO;AACP;AAJF,KAMGlB,SANH,CArBH,CADD,EAgCC,4BAAC,qBAAD,QACC,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAG,MAAM;AACfJ,MAAAA,YAAY,CAAE,CAAEH,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAyB,MAAAA,OAAO;AACP;AAJF,KAMGpB,WANH,CADD,CAhCD,CATF,CADD;AAwDA","sourcesContent":["/**\n * WordPress dependencies\n */\n\nimport { chevronUp, chevronDown, moreVertical } from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useCallback } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { BlockTitle, store as blockEditorStore } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tplacement: 'bottom-start',\n};\n\n/**\n * Internal dependencies\n */\nimport {\n\tisPreviewingTheme,\n\tcurrentlyPreviewingTheme,\n} from '../../utils/is-previewing-theme';\nimport { unlock } from '../../lock-unlock';\nimport { getPathFromURL } from '../sync-state-with-url/use-sync-path-with-url';\n\nconst { useLocation, useHistory } = unlock( routerPrivateApis );\n\nexport default function LeafMoreMenu( props ) {\n\tconst location = useLocation();\n\tconst history = useHistory();\n\tconst { block } = props;\n\tconst { clientId } = block;\n\tconst { moveBlocksDown, moveBlocksUp, removeBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst removeLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst goToLabel = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Go to %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\tconst rootClientId = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId } = select( blockEditorStore );\n\n\t\t\treturn getBlockRootClientId( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst onGoToPage = useCallback(\n\t\t( selectedBlock ) => {\n\t\t\tconst { attributes, name } = selectedBlock;\n\t\t\tif (\n\t\t\t\tattributes.kind === 'post-type' &&\n\t\t\t\tattributes.id &&\n\t\t\t\tattributes.type &&\n\t\t\t\thistory\n\t\t\t) {\n\t\t\t\thistory.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tpostType: attributes.type,\n\t\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\t\twp_theme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tbackPath: getPathFromURL( location.params ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t\tif ( name === 'core/page-list-item' && attributes.id && history ) {\n\t\t\t\thistory.push(\n\t\t\t\t\t{\n\t\t\t\t\t\tpostType: 'page',\n\t\t\t\t\t\tpostId: attributes.id,\n\t\t\t\t\t\t...( isPreviewingTheme() && {\n\t\t\t\t\t\t\twp_theme_preview: currentlyPreviewingTheme(),\n\t\t\t\t\t\t} ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\tbackPath: getPathFromURL( location.params ),\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[ history ]\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronUp }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksUp( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move up' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\ticon={ chevronDown }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tmoveBlocksDown( [ clientId ], rootClientId );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Move down' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t{ block.attributes?.type === 'page' &&\n\t\t\t\t\t\t\tblock.attributes?.id && (\n\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\tonGoToPage( block );\n\t\t\t\t\t\t\t\t\t\tonClose();\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{ goToLabel }\n\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ removeLabel }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"]}
@@ -188,8 +188,8 @@ function HomeTemplateDetails() {
188
188
  spacing: 3
189
189
  }, (0, _element.createElement)(_sidebarNavigationScreenDetailsPanel.SidebarNavigationScreenDetailsPanelRow, null, (0, _element.createElement)(_components.CheckboxControl, {
190
190
  className: "edit-site-sidebar-navigation-screen__input-control",
191
- label: "Allow comments on new posts",
192
- help: "Changes will apply to new posts only. Individual posts may override these settings.",
191
+ label: (0, _i18n.__)('Allow comments on new posts'),
192
+ help: (0, _i18n.__)('Changes will apply to new posts only. Individual posts may override these settings.'),
193
193
  checked: commentsOnNewPostsValue,
194
194
  onChange: setAllowCommentsOnNewPosts
195
195
  }))), (0, _element.createElement)(_sidebarNavigationScreenDetailsPanel.SidebarNavigationScreenDetailsPanel, {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/home-template-details.js"],"names":["EMPTY_OBJECT","TemplateAreaButton","postId","icon","title","icons","header","footer","linkInfo","postType","layout","HomeTemplateDetails","navigator","params","editEntityRecord","coreStore","allowCommentsOnNewPosts","templatePartAreas","postsPerPage","postsPageTitle","postsPageId","currentTemplateParts","select","getEntityRecord","siteSettings","getSettings","editSiteStore","_currentTemplateParts","getCurrentTemplateTemplateParts","siteEditorSettings","_postsPageRecord","page_for_posts","default_comment_status","rendered","id","posts_per_page","defaultTemplatePartAreas","commentsOnNewPostsValue","setCommentsOnNewPostsValue","postsCountValue","setPostsCountValue","postsPageTitleValue","setPostsPageTitleValue","templateAreas","length","map","templatePart","find","area","setAllowCommentsOnNewPosts","newValue","undefined","setPostsPageTitle","setPostsPerPage","label","theme","slug"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAEA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,YAAY,GAAG,EAArB;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,MAAF;AAAUC,EAAAA,IAAV;AAAgBC,EAAAA;AAAhB,CAA7B,EAAuD;AAAA;;AACtD,QAAMC,KAAK,GAAG;AACbC,IAAAA,MAAM,EAANA,aADa;AAEbC,IAAAA,MAAM,EAANA;AAFa,GAAd;AAIA,QAAMC,QAAQ,GAAG,mBAAS;AACzBC,IAAAA,QAAQ,EAAE,kBADe;AAEzBP,IAAAA;AAFyB,GAAT,CAAjB;AAKA,SACC,4BAAC,8BAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAAA,OAEMM,QAFN;AAGC,IAAA,IAAI,iBAAGH,KAAK,CAAEF,IAAF,CAAR,qDAAoBO,aAHzB;AAIC,IAAA,WAAW;AAJZ,KAMC,4BAAC,kCAAD;AACC,IAAA,KAAK,EAAG,EADT;AAEC,IAAA,aAAa,EAAC,MAFf;AAGC,IAAA,aAAa,EAAG,CAHjB;AAIC,IAAA,SAAS,EAAC;AAJX,KAMG,kCAAgBN,KAAhB,CANH,CAND,CADD;AAiBA;;AAEc,SAASO,mBAAT,GAA+B;AAC7C,QAAMC,SAAS,GAAG,6CAAlB;AACA,QAAM;AACLC,IAAAA,MAAM,EAAE;AAAEJ,MAAAA,QAAF;AAAYP,MAAAA;AAAZ;AADH,M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AAI,EAAC,qFAHN;AAIC,IAAA,OAAO,EAAGhB,uBAJX;AAKC,IAAA,QAAQ,EAAGY;AALZ,IADD,CAJD,CAnCD,EAiDC,4BAAC,wEAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,OAAO,EAAG;AAFX,KAIC,4BAAC,mCAAD,QACGN,aAAa,CAACE,GAAd,CACD,CAAE;AAAES,IAAAA,KAAF;AAASnD,IAAAA,IAAT;AAAeoD,IAAAA,KAAf;AAAsBC,IAAAA,IAAtB;AAA4BpD,IAAAA;AAA5B,GAAF,KACC,4BAAC,2EAAD;AACC,IAAA,GAAG,EAAGoD;AADP,KAGC,4BAAC,kBAAD;AACC,IAAA,MAAM,EAAI,GAAGD,KAAO,KAAKC,IAAM,EADhC;AAEC,IAAA,KAAK,EAAGpD,KAAK,EAAE6B,QAAP,IAAmBqB,KAF5B;AAGC,IAAA,IAAI,EAAGnD;AAHR,IAHD,CAFA,CADH,CAJD,CAjDD,CADD;AAwEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tCheckboxControl,\n\t__experimentalUseNavigator as useNavigator,\n\t__experimentalInputControl as InputControl,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalTruncate as Truncate,\n\t__experimentalItemGroup as ItemGroup,\n} from '@wordpress/components';\nimport { header, footer, layout } from '@wordpress/icons';\nimport { useMemo, useState, useEffect } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tSidebarNavigationScreenDetailsPanel,\n\tSidebarNavigationScreenDetailsPanelRow,\n} from '../sidebar-navigation-screen-details-panel';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nconst EMPTY_OBJECT = {};\n\nfunction TemplateAreaButton( { postId, icon, title } ) {\n\tconst icons = {\n\t\theader,\n\t\tfooter,\n\t};\n\tconst linkInfo = useLink( {\n\t\tpostType: 'wp_template_part',\n\t\tpostId,\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template__template-area-button\"\n\t\t\t{ ...linkInfo }\n\t\t\ticon={ icons[ icon ] ?? layout }\n\t\t\twithChevron\n\t\t>\n\t\t\t<Truncate\n\t\t\t\tlimit={ 20 }\n\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template__template-area-label-text\"\n\t\t\t>\n\t\t\t\t{ decodeEntities( title ) }\n\t\t\t</Truncate>\n\t\t</SidebarNavigationItem>\n\t);\n}\n\nexport default function HomeTemplateDetails() {\n\tconst navigator = useNavigator();\n\tconst {\n\t\tparams: { postType, postId },\n\t} = navigator;\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst {\n\t\tallowCommentsOnNewPosts,\n\t\ttemplatePartAreas,\n\t\tpostsPerPage,\n\t\tpostsPageTitle,\n\t\tpostsPageId,\n\t\tcurrentTemplateParts,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\t\tconst _currentTemplateParts =\n\t\t\t\tselect( editSiteStore ).getCurrentTemplateTemplateParts();\n\t\t\tconst siteEditorSettings = getSettings();\n\t\t\tconst _postsPageRecord = siteSettings?.page_for_posts\n\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\tsiteSettings?.page_for_posts\n\t\t\t\t )\n\t\t\t\t: EMPTY_OBJECT;\n\n\t\t\treturn {\n\t\t\t\tallowCommentsOnNewPosts:\n\t\t\t\t\tsiteSettings?.default_comment_status === 'open',\n\t\t\t\tpostsPageTitle: _postsPageRecord?.title?.rendered,\n\t\t\t\tpostsPageId: _postsPageRecord?.id,\n\t\t\t\tpostsPerPage: siteSettings?.posts_per_page,\n\t\t\t\ttemplatePartAreas: siteEditorSettings?.defaultTemplatePartAreas,\n\t\t\t\tcurrentTemplateParts: _currentTemplateParts,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst [ commentsOnNewPostsValue, setCommentsOnNewPostsValue ] =\n\t\tuseState( '' );\n\tconst [ postsCountValue, setPostsCountValue ] = useState( 1 );\n\tconst [ postsPageTitleValue, setPostsPageTitleValue ] = useState( '' );\n\n\t/*\n\t * This hook serves to set the server-retrieved values,\n\t * postsPageTitle, allowCommentsOnNewPosts, postsPerPage,\n\t * to local state.\n\t */\n\tuseEffect( () => {\n\t\tsetCommentsOnNewPostsValue( allowCommentsOnNewPosts );\n\t\tsetPostsPageTitleValue( postsPageTitle );\n\t\tsetPostsCountValue( postsPerPage );\n\t}, [ postsPageTitle, allowCommentsOnNewPosts, postsPerPage ] );\n\n\t/*\n\t * Merge data in currentTemplateParts with templatePartAreas,\n\t * which contains the template icon and fallback labels\n\t */\n\tconst templateAreas = useMemo( () => {\n\t\treturn currentTemplateParts.length && templatePartAreas\n\t\t\t? currentTemplateParts.map( ( { templatePart } ) => ( {\n\t\t\t\t\t...templatePartAreas?.find(\n\t\t\t\t\t\t( { area } ) => area === templatePart?.area\n\t\t\t\t\t),\n\t\t\t\t\t...templatePart,\n\t\t\t } ) )\n\t\t\t: [];\n\t}, [ currentTemplateParts, templatePartAreas ] );\n\n\tconst setAllowCommentsOnNewPosts = ( newValue ) => {\n\t\tsetCommentsOnNewPostsValue( newValue );\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tdefault_comment_status: newValue ? 'open' : null,\n\t\t} );\n\t};\n\n\tconst setPostsPageTitle = ( newValue ) => {\n\t\tsetPostsPageTitleValue( newValue );\n\t\teditEntityRecord( 'postType', 'page', postsPageId, {\n\t\t\ttitle: newValue,\n\t\t} );\n\t};\n\n\tconst setPostsPerPage = ( newValue ) => {\n\t\tsetPostsCountValue( newValue );\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tposts_per_page: newValue,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationScreenDetailsPanel spacing={ 6 }>\n\t\t\t\t{ postsPageId && (\n\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t\tvalue={ postsPageTitleValue }\n\t\t\t\t\t\t\tonChange={ debounce( setPostsPageTitle, 300 ) }\n\t\t\t\t\t\t\tlabel={ __( 'Blog title' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the Posts Page title. Appears in search results, and when the page is shared on social media.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t) }\n\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\tplaceholder={ 0 }\n\t\t\t\t\t\tvalue={ postsCountValue }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\tonChange={ setPostsPerPage }\n\t\t\t\t\t\tlabel={ __( 'Posts per page' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\n\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\ttitle={ __( 'Discussion' ) }\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\tlabel=\"Allow comments on new posts\"\n\t\t\t\t\t\thelp=\"Changes will apply to new posts only. Individual posts may override these settings.\"\n\t\t\t\t\t\tchecked={ commentsOnNewPostsValue }\n\t\t\t\t\t\tonChange={ setAllowCommentsOnNewPosts }\n\t\t\t\t\t/>\n\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\ttitle={ __( 'Areas' ) }\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ templateAreas.map(\n\t\t\t\t\t\t( { label, icon, theme, slug, title } ) => (\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow\n\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TemplateAreaButton\n\t\t\t\t\t\t\t\t\tpostId={ `${ theme }//${ slug }` }\n\t\t\t\t\t\t\t\t\ttitle={ title?.rendered || label }\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t\t)\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-template/home-template-details.js"],"names":["EMPTY_OBJECT","TemplateAreaButton","postId","icon","title","icons","header","footer","linkInfo","postType","layout","HomeTemplateDetails","navigator","params","editEntityRecord","coreStore","allowCommentsOnNewPosts","templatePartAreas","postsPerPage","postsPageTitle","postsPageId","currentTemplateParts","select","getEntityRecord","siteSettings","getSettings","editSiteStore","_currentTemplateParts","getCurrentTemplateTemplateParts","siteEditorSettings","_postsPageRecord","page_for_posts","default_comment_status","rendered","id","posts_per_page","defaultTemplatePartAreas","commentsOnNewPostsValue","setCommentsOnNewPostsValue","postsCountValue","setPostsCountValue","postsPageTitleValue","setPostsPageTitleValue","templateAreas","length","map","templatePart","find","area","setAllowCommentsOnNewPosts","newValue","undefined","setPostsPageTitle","setPostsPerPage","label","theme","slug"],"mappings":";;;;;;;;;AAgBA;;AAbA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAEA;;AAKA;;AAIA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAiBA;AACA;AACA;AAUA,MAAMA,YAAY,GAAG,EAArB;;AAEA,SAASC,kBAAT,CAA6B;AAAEC,EAAAA,MAAF;AAAUC,EAAAA,IAAV;AAAgBC,EAAAA;AAAhB,CAA7B,EAAuD;AAAA;;AACtD,QAAMC,KAAK,GAAG;AACbC,IAAAA,MAAM,EAANA,aADa;AAEbC,IAAAA,MAAM,EAANA;AAFa,GAAd;AAIA,QAAMC,QAAQ,GAAG,mBAAS;AACzBC,IAAAA,QAAQ,EAAE,kBADe;AAEzBP,IAAAA;AAFyB,GAAT,CAAjB;AAKA,SACC,4BAAC,8BAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAAA,OAEMM,QAFN;AAGC,IAAA,IAAI,iBAAGH,KAAK,CAAEF,IAAF,CAAR,qDAAoBO,aAHzB;AAIC,IAAA,WAAW;AAJZ,KAMC,4BAAC,kCAAD;AACC,IAAA,KAAK,EAAG,EADT;AAEC,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,gBAAJ,CATT;AAUC,IAAA,IAAI,EAAG,cACN,oIADM;AAVR,IADD,CAhBD,CADD,EAmCC,4BAAC,wEAAD;AACC,IAAA,KAAK,EAAG,cAAI,YAAJ,CADT;AAEC,IAAA,OAAO,EAAG;AAFX,KAIC,4BAAC,2EAAD,QACC,4BAAC,2BAAD;AACC,IAAA,SAAS,EAAC,oDADX;AAEC,IAAA,KAAK,EAAG,cAAI,6BAAJ,CAFT;AAGC,IAAA,IAAI,EAAG,cACN,qFADM,CAHR;AAMC,IAAA,OAAO,EAAGhB,uBANX;AAOC,IAAA,QAAQ,EAAGY;AAPZ,IADD,CAJD,CAnCD,EAmDC,4BAAC,wEAAD;AACC,IAAA,KAAK,EAAG,cAAI,OAAJ,CADT;AAEC,IAAA,OAAO,EAAG;AAFX,KAIC,4BAAC,mCAAD,QACGN,aAAa,CAACE,GAAd,CACD,CAAE;AAAES,IAAAA,KAAF;AAASnD,IAAAA,IAAT;AAAeoD,IAAAA,KAAf;AAAsBC,IAAAA,IAAtB;AAA4BpD,IAAAA;AAA5B,GAAF,KACC,4BAAC,2EAAD;AACC,IAAA,GAAG,EAAGoD;AADP,KAGC,4BAAC,kBAAD;AACC,IAAA,MAAM,EAAI,GAAGD,KAAO,KAAKC,IAAM,EADhC;AAEC,IAAA,KAAK,EAAGpD,KAAK,EAAE6B,QAAP,IAAmBqB,KAF5B;AAGC,IAAA,IAAI,EAAGnD;AAHR,IAHD,CAFA,CADH,CAJD,CAnDD,CADD;AA0EA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { debounce } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tCheckboxControl,\n\t__experimentalUseNavigator as useNavigator,\n\t__experimentalInputControl as InputControl,\n\t__experimentalNumberControl as NumberControl,\n\t__experimentalTruncate as Truncate,\n\t__experimentalItemGroup as ItemGroup,\n} from '@wordpress/components';\nimport { header, footer, layout } from '@wordpress/icons';\nimport { useMemo, useState, useEffect } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport {\n\tSidebarNavigationScreenDetailsPanel,\n\tSidebarNavigationScreenDetailsPanelRow,\n} from '../sidebar-navigation-screen-details-panel';\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport { useLink } from '../routes/link';\nimport SidebarNavigationItem from '../sidebar-navigation-item';\n\nconst EMPTY_OBJECT = {};\n\nfunction TemplateAreaButton( { postId, icon, title } ) {\n\tconst icons = {\n\t\theader,\n\t\tfooter,\n\t};\n\tconst linkInfo = useLink( {\n\t\tpostType: 'wp_template_part',\n\t\tpostId,\n\t} );\n\n\treturn (\n\t\t<SidebarNavigationItem\n\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template__template-area-button\"\n\t\t\t{ ...linkInfo }\n\t\t\ticon={ icons[ icon ] ?? layout }\n\t\t\twithChevron\n\t\t>\n\t\t\t<Truncate\n\t\t\t\tlimit={ 20 }\n\t\t\t\tellipsizeMode=\"tail\"\n\t\t\t\tnumberOfLines={ 1 }\n\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen-template__template-area-label-text\"\n\t\t\t>\n\t\t\t\t{ decodeEntities( title ) }\n\t\t\t</Truncate>\n\t\t</SidebarNavigationItem>\n\t);\n}\n\nexport default function HomeTemplateDetails() {\n\tconst navigator = useNavigator();\n\tconst {\n\t\tparams: { postType, postId },\n\t} = navigator;\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\tconst {\n\t\tallowCommentsOnNewPosts,\n\t\ttemplatePartAreas,\n\t\tpostsPerPage,\n\t\tpostsPageTitle,\n\t\tpostsPageId,\n\t\tcurrentTemplateParts,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecord } = select( coreStore );\n\t\t\tconst siteSettings = getEntityRecord( 'root', 'site' );\n\t\t\tconst { getSettings } = unlock( select( editSiteStore ) );\n\t\t\tconst _currentTemplateParts =\n\t\t\t\tselect( editSiteStore ).getCurrentTemplateTemplateParts();\n\t\t\tconst siteEditorSettings = getSettings();\n\t\t\tconst _postsPageRecord = siteSettings?.page_for_posts\n\t\t\t\t? select( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'page',\n\t\t\t\t\t\tsiteSettings?.page_for_posts\n\t\t\t\t )\n\t\t\t\t: EMPTY_OBJECT;\n\n\t\t\treturn {\n\t\t\t\tallowCommentsOnNewPosts:\n\t\t\t\t\tsiteSettings?.default_comment_status === 'open',\n\t\t\t\tpostsPageTitle: _postsPageRecord?.title?.rendered,\n\t\t\t\tpostsPageId: _postsPageRecord?.id,\n\t\t\t\tpostsPerPage: siteSettings?.posts_per_page,\n\t\t\t\ttemplatePartAreas: siteEditorSettings?.defaultTemplatePartAreas,\n\t\t\t\tcurrentTemplateParts: _currentTemplateParts,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst [ commentsOnNewPostsValue, setCommentsOnNewPostsValue ] =\n\t\tuseState( '' );\n\tconst [ postsCountValue, setPostsCountValue ] = useState( 1 );\n\tconst [ postsPageTitleValue, setPostsPageTitleValue ] = useState( '' );\n\n\t/*\n\t * This hook serves to set the server-retrieved values,\n\t * postsPageTitle, allowCommentsOnNewPosts, postsPerPage,\n\t * to local state.\n\t */\n\tuseEffect( () => {\n\t\tsetCommentsOnNewPostsValue( allowCommentsOnNewPosts );\n\t\tsetPostsPageTitleValue( postsPageTitle );\n\t\tsetPostsCountValue( postsPerPage );\n\t}, [ postsPageTitle, allowCommentsOnNewPosts, postsPerPage ] );\n\n\t/*\n\t * Merge data in currentTemplateParts with templatePartAreas,\n\t * which contains the template icon and fallback labels\n\t */\n\tconst templateAreas = useMemo( () => {\n\t\treturn currentTemplateParts.length && templatePartAreas\n\t\t\t? currentTemplateParts.map( ( { templatePart } ) => ( {\n\t\t\t\t\t...templatePartAreas?.find(\n\t\t\t\t\t\t( { area } ) => area === templatePart?.area\n\t\t\t\t\t),\n\t\t\t\t\t...templatePart,\n\t\t\t } ) )\n\t\t\t: [];\n\t}, [ currentTemplateParts, templatePartAreas ] );\n\n\tconst setAllowCommentsOnNewPosts = ( newValue ) => {\n\t\tsetCommentsOnNewPostsValue( newValue );\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tdefault_comment_status: newValue ? 'open' : null,\n\t\t} );\n\t};\n\n\tconst setPostsPageTitle = ( newValue ) => {\n\t\tsetPostsPageTitleValue( newValue );\n\t\teditEntityRecord( 'postType', 'page', postsPageId, {\n\t\t\ttitle: newValue,\n\t\t} );\n\t};\n\n\tconst setPostsPerPage = ( newValue ) => {\n\t\tsetPostsCountValue( newValue );\n\t\teditEntityRecord( 'root', 'site', undefined, {\n\t\t\tposts_per_page: newValue,\n\t\t} );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<SidebarNavigationScreenDetailsPanel spacing={ 6 }>\n\t\t\t\t{ postsPageId && (\n\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t\t<InputControl\n\t\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\t\tplaceholder={ __( 'No Title' ) }\n\t\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\t\tvalue={ postsPageTitleValue }\n\t\t\t\t\t\t\tonChange={ debounce( setPostsPageTitle, 300 ) }\n\t\t\t\t\t\t\tlabel={ __( 'Blog title' ) }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Set the Posts Page title. Appears in search results, and when the page is shared on social media.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t) }\n\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t<NumberControl\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\tplaceholder={ 0 }\n\t\t\t\t\t\tvalue={ postsCountValue }\n\t\t\t\t\t\tsize={ '__unstable-large' }\n\t\t\t\t\t\tspinControls=\"custom\"\n\t\t\t\t\t\tstep=\"1\"\n\t\t\t\t\t\tmin=\"1\"\n\t\t\t\t\t\tonChange={ setPostsPerPage }\n\t\t\t\t\t\tlabel={ __( 'Posts per page' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\n\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\ttitle={ __( 'Discussion' ) }\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t<CheckboxControl\n\t\t\t\t\t\tclassName=\"edit-site-sidebar-navigation-screen__input-control\"\n\t\t\t\t\t\tlabel={ __( 'Allow comments on new posts' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Changes will apply to new posts only. Individual posts may override these settings.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tchecked={ commentsOnNewPostsValue }\n\t\t\t\t\t\tonChange={ setAllowCommentsOnNewPosts }\n\t\t\t\t\t/>\n\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t\t<SidebarNavigationScreenDetailsPanel\n\t\t\t\ttitle={ __( 'Areas' ) }\n\t\t\t\tspacing={ 3 }\n\t\t\t>\n\t\t\t\t<ItemGroup>\n\t\t\t\t\t{ templateAreas.map(\n\t\t\t\t\t\t( { label, icon, theme, slug, title } ) => (\n\t\t\t\t\t\t\t<SidebarNavigationScreenDetailsPanelRow\n\t\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TemplateAreaButton\n\t\t\t\t\t\t\t\t\tpostId={ `${ theme }//${ slug }` }\n\t\t\t\t\t\t\t\t\ttitle={ title?.rendered || label }\n\t\t\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</SidebarNavigationScreenDetailsPanelRow>\n\t\t\t\t\t\t)\n\t\t\t\t\t) }\n\t\t\t\t</ItemGroup>\n\t\t\t</SidebarNavigationScreenDetailsPanel>\n\t\t</>\n\t);\n}\n"]}
@@ -36,13 +36,23 @@ var _lockUnlock = require("../../lock-unlock");
36
36
  * Internal dependencies
37
37
  */
38
38
  const {
39
+ cleanEmptyObject,
39
40
  GlobalStylesContext,
40
41
  useBlockEditingMode
41
- } = (0, _lockUnlock.unlock)(_blockEditor.privateApis); // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
42
+ } = (0, _lockUnlock.unlock)(_blockEditor.privateApis); // Block Gap is a special case and isn't defined within the blocks
43
+ // style properties config. We'll add it here to allow it to be pushed
44
+ // to global styles as well.
45
+
46
+ const STYLE_PROPERTY = { ..._blocks.__EXPERIMENTAL_STYLE_PROPERTY,
47
+ blockGap: {
48
+ value: ['spacing', 'blockGap']
49
+ }
50
+ }; // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
42
51
  // removed by moving PushChangesToGlobalStylesControl to
43
52
  // @wordpress/block-editor.
44
53
 
45
54
  const STYLE_PATH_TO_CSS_VAR_INFIX = {
55
+ 'border.color': 'color',
46
56
  'color.background': 'color',
47
57
  'color.text': 'color',
48
58
  'elements.link.color.text': 'color',
@@ -84,6 +94,7 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
84
94
  'elements.h6.typography.fontFamily': 'font-family',
85
95
  'elements.h6.color.gradient': 'gradient',
86
96
  'color.gradient': 'gradient',
97
+ blockGap: 'spacing',
87
98
  'typography.fontSize': 'font-size',
88
99
  'typography.fontFamily': 'font-family'
89
100
  }; // TODO: Temporary duplication of constant in @wordpress/block-editor. Can be
@@ -91,6 +102,7 @@ const STYLE_PATH_TO_CSS_VAR_INFIX = {
91
102
  // @wordpress/block-editor.
92
103
 
93
104
  const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
105
+ 'border.color': 'borderColor',
94
106
  'color.background': 'backgroundColor',
95
107
  'color.text': 'textColor',
96
108
  'color.gradient': 'gradient',
@@ -98,25 +110,128 @@ const STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {
98
110
  'typography.fontFamily': 'fontFamily'
99
111
  };
100
112
  const SUPPORTED_STYLES = ['border', 'color', 'spacing', 'typography'];
113
+ const flatBorderProperties = ['borderColor', 'borderWidth', 'borderStyle'];
114
+ const sides = ['top', 'right', 'bottom', 'left'];
115
+
116
+ function getBorderStyleChanges(border, presetColor, userStyle) {
117
+ if (!border && !presetColor) {
118
+ return [];
119
+ }
120
+
121
+ const changes = [...getFallbackBorderStyleChange('top', border, userStyle), ...getFallbackBorderStyleChange('right', border, userStyle), ...getFallbackBorderStyleChange('bottom', border, userStyle), ...getFallbackBorderStyleChange('left', border, userStyle)]; // Handle a flat border i.e. all sides the same, CSS shorthand.
122
+
123
+ const {
124
+ color: customColor,
125
+ style,
126
+ width
127
+ } = border || {};
128
+ const hasColorOrWidth = presetColor || customColor || width;
129
+
130
+ if (hasColorOrWidth && !style) {
131
+ // Global Styles need individual side configurations to overcome
132
+ // theme.json configurations which are per side as well.
133
+ sides.forEach(side => {
134
+ // Only add fallback border-style if global styles don't already
135
+ // have something set.
136
+ if (!userStyle?.[side]?.style) {
137
+ changes.push({
138
+ path: ['border', side, 'style'],
139
+ value: 'solid'
140
+ });
141
+ }
142
+ });
143
+ }
144
+
145
+ return changes;
146
+ }
147
+
148
+ function getFallbackBorderStyleChange(side, border, globalBorderStyle) {
149
+ if (!border?.[side] || globalBorderStyle?.[side]?.style) {
150
+ return [];
151
+ }
152
+
153
+ const {
154
+ color,
155
+ style,
156
+ width
157
+ } = border[side];
158
+ const hasColorOrWidth = color || width;
159
+
160
+ if (!hasColorOrWidth || style) {
161
+ return [];
162
+ }
101
163
 
102
- function useChangesToPush(name, attributes) {
164
+ return [{
165
+ path: ['border', side, 'style'],
166
+ value: 'solid'
167
+ }];
168
+ }
169
+
170
+ function useChangesToPush(name, attributes, userConfig) {
103
171
  const supports = (0, _hooks2.useSupportedStyles)(name);
104
- return (0, _element.useMemo)(() => supports.flatMap(key => {
105
- if (!_blocks.__EXPERIMENTAL_STYLE_PROPERTY[key]) {
106
- return [];
107
- }
172
+ const blockUserConfig = userConfig?.styles?.blocks?.[name];
173
+ return (0, _element.useMemo)(() => {
174
+ const changes = supports.flatMap(key => {
175
+ if (!STYLE_PROPERTY[key]) {
176
+ return [];
177
+ }
108
178
 
109
- const {
110
- value: path
111
- } = _blocks.__EXPERIMENTAL_STYLE_PROPERTY[key];
112
- const presetAttributeKey = path.join('.');
113
- const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
114
- const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : (0, _lodash.get)(attributes.style, path);
115
- return value ? [{
116
- path,
117
- value
118
- }] : [];
119
- }), [supports, name, attributes]);
179
+ const {
180
+ value: path
181
+ } = STYLE_PROPERTY[key];
182
+ const presetAttributeKey = path.join('.');
183
+ const presetAttributeValue = attributes[STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[presetAttributeKey]];
184
+ const value = presetAttributeValue ? `var:preset|${STYLE_PATH_TO_CSS_VAR_INFIX[presetAttributeKey]}|${presetAttributeValue}` : (0, _lodash.get)(attributes.style, path); // Links only have a single support entry but have two element
185
+ // style properties, color and hover color. The following check
186
+ // will add the hover color to the changes if required.
187
+
188
+ if (key === 'linkColor') {
189
+ const linkChanges = value ? [{
190
+ path,
191
+ value
192
+ }] : [];
193
+ const hoverPath = ['elements', 'link', ':hover', 'color', 'text'];
194
+ const hoverValue = (0, _lodash.get)(attributes.style, hoverPath);
195
+
196
+ if (hoverValue) {
197
+ linkChanges.push({
198
+ path: hoverPath,
199
+ value: hoverValue
200
+ });
201
+ }
202
+
203
+ return linkChanges;
204
+ } // The shorthand border styles can't be mapped directly as global
205
+ // styles requires longhand config.
206
+
207
+
208
+ if (flatBorderProperties.includes(key) && value) {
209
+ // The shorthand config path is included to clear the block attribute.
210
+ const borderChanges = [{
211
+ path,
212
+ value
213
+ }];
214
+ sides.forEach(side => {
215
+ const currentPath = [...path];
216
+ currentPath.splice(-1, 0, side);
217
+ borderChanges.push({
218
+ path: currentPath,
219
+ value
220
+ });
221
+ });
222
+ return borderChanges;
223
+ }
224
+
225
+ return value ? [{
226
+ path,
227
+ value
228
+ }] : [];
229
+ }); // To ensure display of a visible border, global styles require a
230
+ // default border style if a border color or width is present.
231
+
232
+ getBorderStyleChanges(attributes.style?.border, attributes.borderColor, blockUserConfig?.border).forEach(change => changes.push(change));
233
+ return changes;
234
+ }, [supports, attributes, blockUserConfig]);
120
235
  }
121
236
 
122
237
  function cloneDeep(object) {
@@ -128,11 +243,11 @@ function PushChangesToGlobalStylesControl({
128
243
  attributes,
129
244
  setAttributes
130
245
  }) {
131
- const changes = useChangesToPush(name, attributes);
132
246
  const {
133
247
  user: userConfig,
134
248
  setUserConfig
135
249
  } = (0, _element.useContext)(GlobalStylesContext);
250
+ const changes = useChangesToPush(name, attributes, userConfig);
136
251
  const {
137
252
  __unstableMarkNextChangeAsNotPersistent
138
253
  } = (0, _data.useDispatch)(_blockEditor.store);
@@ -156,17 +271,24 @@ function PushChangesToGlobalStylesControl({
156
271
  } of changes) {
157
272
  (0, _lodash.set)(newBlockStyles, path, undefined);
158
273
  (0, _lodash.set)(newUserConfig, ['styles', 'blocks', name, ...path], value);
159
- } // @wordpress/core-data doesn't support editing multiple entity types in
274
+ }
275
+
276
+ const newBlockAttributes = {
277
+ borderColor: undefined,
278
+ backgroundColor: undefined,
279
+ textColor: undefined,
280
+ gradient: undefined,
281
+ fontSize: undefined,
282
+ fontFamily: undefined,
283
+ style: cleanEmptyObject(newBlockStyles)
284
+ }; // @wordpress/core-data doesn't support editing multiple entity types in
160
285
  // a single undo level. So for now, we disable @wordpress/core-data undo
161
286
  // tracking and implement our own Undo button in the snackbar
162
287
  // notification.
163
288
 
164
-
165
289
  __unstableMarkNextChangeAsNotPersistent();
166
290
 
167
- setAttributes({
168
- style: newBlockStyles
169
- });
291
+ setAttributes(newBlockAttributes);
170
292
  setUserConfig(() => newUserConfig, {
171
293
  undoIgnore: true
172
294
  });
@@ -179,9 +301,7 @@ function PushChangesToGlobalStylesControl({
179
301
  onClick() {
180
302
  __unstableMarkNextChangeAsNotPersistent();
181
303
 
182
- setAttributes({
183
- style: blockStyles
184
- });
304
+ setAttributes(attributes);
185
305
  setUserConfig(() => userConfig, {
186
306
  undoIgnore: true
187
307
  });
@@ -189,7 +309,7 @@ function PushChangesToGlobalStylesControl({
189
309
 
190
310
  }]
191
311
  });
192
- }, [changes, attributes, userConfig, name]);
312
+ }, [__unstableMarkNextChangeAsNotPersistent, attributes, changes, createSuccessNotice, name, setAttributes, setUserConfig, userConfig]);
193
313
  return (0, _element.createElement)(_components.BaseControl, {
194
314
  className: "edit-site-push-changes-to-global-styles-control",
195
315
  help: (0, _i18n.sprintf)( // translators: %s: Title of the block e.g. 'Heading'.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["GlobalStylesContext","useBlockEditingMode","blockEditorPrivateApis","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","useChangesToPush","name","attributes","supports","flatMap","key","STYLE_PROPERTY","value","path","presetAttributeKey","join","presetAttributeValue","style","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","changes","user","userConfig","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode","supportsStyles","some","feature"],"mappings":";;AAsBA;;AAnBA;;AAKA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AAMA;;AACA;;AAKA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAIA,MAAM;AAAEA,EAAAA,mBAAF;AAAuBC,EAAAA;AAAvB,IAA+C,wBACpDC,wBADoD,CAArD,C,CAIA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG;AACnC,sBAAoB,OADe;AAEnC,gBAAc,OAFqB;AAGnC,8BAA4B,OAHO;AAInC,qCAAmC,OAJA;AAKnC,yCAAuC,aALJ;AAMnC,uCAAqC,WANF;AAOnC,gCAA8B,OAPK;AAQnC,sCAAoC,OARD;AASnC,2CAAyC,aATN;AAUnC,yCAAuC,WAVJ;AAWnC,iCAA+B,OAXI;AAYnC,4BAA0B,OAZS;AAanC,uCAAqC,OAbF;AAcnC,4CAA0C,aAdP;AAenC,+BAA6B,UAfM;AAgBnC,qCAAmC,UAhBA;AAiBnC,uBAAqB,OAjBc;AAkBnC,kCAAgC,OAlBG;AAmBnC,uCAAqC,aAnBF;AAoBnC,gCAA8B,UApBK;AAqBnC,uBAAqB,OArBc;AAsBnC,kCAAgC,OAtBG;AAuBnC,uCAAqC,aAvBF;AAwBnC,gCAA8B,UAxBK;AAyBnC,uBAAqB,OAzBc;AA0BnC,kCAAgC,OA1BG;AA2BnC,uCAAqC,aA3BF;AA4BnC,gCAA8B,UA5BK;AA6BnC,uBAAqB,OA7Bc;AA8BnC,kCAAgC,OA9BG;AA+BnC,uCAAqC,aA/BF;AAgCnC,gCAA8B,UAhCK;AAiCnC,uBAAqB,OAjCc;AAkCnC,kCAAgC,OAlCG;AAmCnC,uCAAqC,aAnCF;AAoCnC,gCAA8B,UApCK;A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,6BAAiBJ,KAAK,CAACzC,IAAvB,EAA6B6C,OAA7B,CADsB,CAAvB;AAIA,SACC,qDACC,4BAAC,SAAD,OAAgBJ;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IAAkCC,cAAlC,IACD,4BAAC,sCAAD,QACC,4BAAC,gCAAD,OAAuCF;AAAvC,IADD,CAHF,CADD;AAUA,CAjBoC,CAAtC;AAoBA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY as STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst { GlobalStylesContext, useBlockEditingMode } = unlock(\n\tblockEditorPrivateApis\n);\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nfunction useChangesToPush( name, attributes ) {\n\tconst supports = useSupportedStyles( name );\n\n\treturn useMemo(\n\t\t() =>\n\t\t\tsupports.flatMap( ( key ) => {\n\t\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\t\treturn [];\n\t\t\t\t}\n\t\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\t\tconst presetAttributeValue =\n\t\t\t\t\tattributes[\n\t\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[\n\t\t\t\t\t\t\tpresetAttributeKey\n\t\t\t\t\t\t]\n\t\t\t\t\t];\n\t\t\t\tconst value = presetAttributeValue\n\t\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t\t: get( attributes.style, path );\n\t\t\t\treturn value ? [ { path, value } ] : [];\n\t\t\t} ),\n\t\t[ supports, name, attributes ]\n\t);\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst changes = useChangesToPush( name, attributes );\n\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { style: newBlockStyles } );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( { style: blockStyles } );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\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}\n\t\t);\n\t}, [ changes, attributes, userConfig, name ] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\t\thasBlockSupport( props.name, feature )\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && supportsStyles && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/hooks/push-changes-to-global-styles/index.js"],"names":["cleanEmptyObject","GlobalStylesContext","useBlockEditingMode","blockEditorPrivateApis","STYLE_PROPERTY","__EXPERIMENTAL_STYLE_PROPERTY","blockGap","value","STYLE_PATH_TO_CSS_VAR_INFIX","STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE","SUPPORTED_STYLES","flatBorderProperties","sides","getBorderStyleChanges","border","presetColor","userStyle","changes","getFallbackBorderStyleChange","color","customColor","style","width","hasColorOrWidth","forEach","side","push","path","globalBorderStyle","useChangesToPush","name","attributes","userConfig","supports","blockUserConfig","styles","blocks","flatMap","key","presetAttributeKey","join","presetAttributeValue","linkChanges","hoverPath","hoverValue","includes","borderChanges","currentPath","splice","borderColor","change","cloneDeep","object","JSON","parse","stringify","PushChangesToGlobalStylesControl","setAttributes","user","setUserConfig","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","createSuccessNotice","noticesStore","pushChanges","length","blockStyles","newBlockStyles","newUserConfig","undefined","newBlockAttributes","backgroundColor","textColor","gradient","fontSize","fontFamily","undoIgnore","title","type","actions","label","onClick","withPushChangesToGlobalStyles","BlockEdit","props","blockEditingMode","supportsStyles","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AF,IAC7C,6BAAiBJ,KAAK,CAACtD,IAAvB,EAA6B0D,OAA7B,CADsB,CAAvB;AAIA,SACC,qDACC,4BAAC,SAAD,OAAgBJ;AAAhB,IADD,EAEGC,gBAAgB,KAAK,SAArB,IAAkCC,cAAlC,IACD,4BAAC,sCAAD,QACC,4BAAC,gCAAD,OAAuCF;AAAvC,IADD,CAHF,CADD;AAUA,CAjBoC,CAAtC;AAoBA,sBACC,kBADD,EAEC,8CAFD,EAGCF,6BAHD","sourcesContent":["/**\n * External dependencies\n */\nimport { get, set } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport {\n\tInspectorAdvancedControls,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { BaseControl, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\t__EXPERIMENTAL_STYLE_PROPERTY,\n\tgetBlockType,\n\thasBlockSupport,\n} from '@wordpress/blocks';\nimport { useContext, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { useSupportedStyles } from '../../components/global-styles/hooks';\nimport { unlock } from '../../lock-unlock';\n\nconst { cleanEmptyObject, GlobalStylesContext, useBlockEditingMode } = unlock(\n\tblockEditorPrivateApis\n);\n\n// Block Gap is a special case and isn't defined within the blocks\n// style properties config. We'll add it here to allow it to be pushed\n// to global styles as well.\nconst STYLE_PROPERTY = {\n\t...__EXPERIMENTAL_STYLE_PROPERTY,\n\tblockGap: { value: [ 'spacing', 'blockGap' ] },\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_CSS_VAR_INFIX = {\n\t'border.color': 'color',\n\t'color.background': 'color',\n\t'color.text': 'color',\n\t'elements.link.color.text': 'color',\n\t'elements.link.:hover.color.text': 'color',\n\t'elements.link.typography.fontFamily': 'font-family',\n\t'elements.link.typography.fontSize': 'font-size',\n\t'elements.button.color.text': 'color',\n\t'elements.button.color.background': 'color',\n\t'elements.button.typography.fontFamily': 'font-family',\n\t'elements.button.typography.fontSize': 'font-size',\n\t'elements.caption.color.text': 'color',\n\t'elements.heading.color': 'color',\n\t'elements.heading.color.background': 'color',\n\t'elements.heading.typography.fontFamily': 'font-family',\n\t'elements.heading.gradient': 'gradient',\n\t'elements.heading.color.gradient': 'gradient',\n\t'elements.h1.color': 'color',\n\t'elements.h1.color.background': 'color',\n\t'elements.h1.typography.fontFamily': 'font-family',\n\t'elements.h1.color.gradient': 'gradient',\n\t'elements.h2.color': 'color',\n\t'elements.h2.color.background': 'color',\n\t'elements.h2.typography.fontFamily': 'font-family',\n\t'elements.h2.color.gradient': 'gradient',\n\t'elements.h3.color': 'color',\n\t'elements.h3.color.background': 'color',\n\t'elements.h3.typography.fontFamily': 'font-family',\n\t'elements.h3.color.gradient': 'gradient',\n\t'elements.h4.color': 'color',\n\t'elements.h4.color.background': 'color',\n\t'elements.h4.typography.fontFamily': 'font-family',\n\t'elements.h4.color.gradient': 'gradient',\n\t'elements.h5.color': 'color',\n\t'elements.h5.color.background': 'color',\n\t'elements.h5.typography.fontFamily': 'font-family',\n\t'elements.h5.color.gradient': 'gradient',\n\t'elements.h6.color': 'color',\n\t'elements.h6.color.background': 'color',\n\t'elements.h6.typography.fontFamily': 'font-family',\n\t'elements.h6.color.gradient': 'gradient',\n\t'color.gradient': 'gradient',\n\tblockGap: 'spacing',\n\t'typography.fontSize': 'font-size',\n\t'typography.fontFamily': 'font-family',\n};\n\n// TODO: Temporary duplication of constant in @wordpress/block-editor. Can be\n// removed by moving PushChangesToGlobalStylesControl to\n// @wordpress/block-editor.\nconst STYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE = {\n\t'border.color': 'borderColor',\n\t'color.background': 'backgroundColor',\n\t'color.text': 'textColor',\n\t'color.gradient': 'gradient',\n\t'typography.fontSize': 'fontSize',\n\t'typography.fontFamily': 'fontFamily',\n};\n\nconst SUPPORTED_STYLES = [ 'border', 'color', 'spacing', 'typography' ];\n\nconst flatBorderProperties = [ 'borderColor', 'borderWidth', 'borderStyle' ];\nconst sides = [ 'top', 'right', 'bottom', 'left' ];\n\nfunction getBorderStyleChanges( border, presetColor, userStyle ) {\n\tif ( ! border && ! presetColor ) {\n\t\treturn [];\n\t}\n\n\tconst changes = [\n\t\t...getFallbackBorderStyleChange( 'top', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'right', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'bottom', border, userStyle ),\n\t\t...getFallbackBorderStyleChange( 'left', border, userStyle ),\n\t];\n\n\t// Handle a flat border i.e. all sides the same, CSS shorthand.\n\tconst { color: customColor, style, width } = border || {};\n\tconst hasColorOrWidth = presetColor || customColor || width;\n\n\tif ( hasColorOrWidth && ! style ) {\n\t\t// Global Styles need individual side configurations to overcome\n\t\t// theme.json configurations which are per side as well.\n\t\tsides.forEach( ( side ) => {\n\t\t\t// Only add fallback border-style if global styles don't already\n\t\t\t// have something set.\n\t\t\tif ( ! userStyle?.[ side ]?.style ) {\n\t\t\t\tchanges.push( {\n\t\t\t\t\tpath: [ 'border', side, 'style' ],\n\t\t\t\t\tvalue: 'solid',\n\t\t\t\t} );\n\t\t\t}\n\t\t} );\n\t}\n\n\treturn changes;\n}\n\nfunction getFallbackBorderStyleChange( side, border, globalBorderStyle ) {\n\tif ( ! border?.[ side ] || globalBorderStyle?.[ side ]?.style ) {\n\t\treturn [];\n\t}\n\n\tconst { color, style, width } = border[ side ];\n\tconst hasColorOrWidth = color || width;\n\n\tif ( ! hasColorOrWidth || style ) {\n\t\treturn [];\n\t}\n\n\treturn [ { path: [ 'border', side, 'style' ], value: 'solid' } ];\n}\n\nfunction useChangesToPush( name, attributes, userConfig ) {\n\tconst supports = useSupportedStyles( name );\n\tconst blockUserConfig = userConfig?.styles?.blocks?.[ name ];\n\n\treturn useMemo( () => {\n\t\tconst changes = supports.flatMap( ( key ) => {\n\t\t\tif ( ! STYLE_PROPERTY[ key ] ) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tconst { value: path } = STYLE_PROPERTY[ key ];\n\t\t\tconst presetAttributeKey = path.join( '.' );\n\t\t\tconst presetAttributeValue =\n\t\t\t\tattributes[\n\t\t\t\t\tSTYLE_PATH_TO_PRESET_BLOCK_ATTRIBUTE[ presetAttributeKey ]\n\t\t\t\t];\n\t\t\tconst value = presetAttributeValue\n\t\t\t\t? `var:preset|${ STYLE_PATH_TO_CSS_VAR_INFIX[ presetAttributeKey ] }|${ presetAttributeValue }`\n\t\t\t\t: get( attributes.style, path );\n\n\t\t\t// Links only have a single support entry but have two element\n\t\t\t// style properties, color and hover color. The following check\n\t\t\t// will add the hover color to the changes if required.\n\t\t\tif ( key === 'linkColor' ) {\n\t\t\t\tconst linkChanges = value ? [ { path, value } ] : [];\n\t\t\t\tconst hoverPath = [\n\t\t\t\t\t'elements',\n\t\t\t\t\t'link',\n\t\t\t\t\t':hover',\n\t\t\t\t\t'color',\n\t\t\t\t\t'text',\n\t\t\t\t];\n\t\t\t\tconst hoverValue = get( attributes.style, hoverPath );\n\n\t\t\t\tif ( hoverValue ) {\n\t\t\t\t\tlinkChanges.push( { path: hoverPath, value: hoverValue } );\n\t\t\t\t}\n\n\t\t\t\treturn linkChanges;\n\t\t\t}\n\n\t\t\t// The shorthand border styles can't be mapped directly as global\n\t\t\t// styles requires longhand config.\n\t\t\tif ( flatBorderProperties.includes( key ) && value ) {\n\t\t\t\t// The shorthand config path is included to clear the block attribute.\n\t\t\t\tconst borderChanges = [ { path, value } ];\n\t\t\t\tsides.forEach( ( side ) => {\n\t\t\t\t\tconst currentPath = [ ...path ];\n\t\t\t\t\tcurrentPath.splice( -1, 0, side );\n\t\t\t\t\tborderChanges.push( { path: currentPath, value } );\n\t\t\t\t} );\n\t\t\t\treturn borderChanges;\n\t\t\t}\n\n\t\t\treturn value ? [ { path, value } ] : [];\n\t\t} );\n\n\t\t// To ensure display of a visible border, global styles require a\n\t\t// default border style if a border color or width is present.\n\t\tgetBorderStyleChanges(\n\t\t\tattributes.style?.border,\n\t\t\tattributes.borderColor,\n\t\t\tblockUserConfig?.border\n\t\t).forEach( ( change ) => changes.push( change ) );\n\n\t\treturn changes;\n\t}, [ supports, attributes, blockUserConfig ] );\n}\n\nfunction cloneDeep( object ) {\n\treturn ! object ? {} : JSON.parse( JSON.stringify( object ) );\n}\n\nfunction PushChangesToGlobalStylesControl( {\n\tname,\n\tattributes,\n\tsetAttributes,\n} ) {\n\tconst { user: userConfig, setUserConfig } =\n\t\tuseContext( GlobalStylesContext );\n\n\tconst changes = useChangesToPush( name, attributes, userConfig );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst pushChanges = useCallback( () => {\n\t\tif ( changes.length === 0 ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst { style: blockStyles } = attributes;\n\n\t\tconst newBlockStyles = cloneDeep( blockStyles );\n\t\tconst newUserConfig = cloneDeep( userConfig );\n\n\t\tfor ( const { path, value } of changes ) {\n\t\t\tset( newBlockStyles, path, undefined );\n\t\t\tset( newUserConfig, [ 'styles', 'blocks', name, ...path ], value );\n\t\t}\n\n\t\tconst newBlockAttributes = {\n\t\t\tborderColor: undefined,\n\t\t\tbackgroundColor: undefined,\n\t\t\ttextColor: undefined,\n\t\t\tgradient: undefined,\n\t\t\tfontSize: undefined,\n\t\t\tfontFamily: undefined,\n\t\t\tstyle: cleanEmptyObject( newBlockStyles ),\n\t\t};\n\n\t\t// @wordpress/core-data doesn't support editing multiple entity types in\n\t\t// a single undo level. So for now, we disable @wordpress/core-data undo\n\t\t// tracking and implement our own Undo button in the snackbar\n\t\t// notification.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( newBlockAttributes );\n\t\tsetUserConfig( () => newUserConfig, { undoIgnore: true } );\n\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__( '%s styles applied.' ),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tactions: [\n\t\t\t\t\t{\n\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\tonClick() {\n\t\t\t\t\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\t\t\t\t\tsetAttributes( attributes );\n\t\t\t\t\t\t\tsetUserConfig( () => userConfig, {\n\t\t\t\t\t\t\t\tundoIgnore: true,\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}\n\t\t);\n\t}, [\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\tattributes,\n\t\tchanges,\n\t\tcreateSuccessNotice,\n\t\tname,\n\t\tsetAttributes,\n\t\tsetUserConfig,\n\t\tuserConfig,\n\t] );\n\n\treturn (\n\t\t<BaseControl\n\t\t\tclassName=\"edit-site-push-changes-to-global-styles-control\"\n\t\t\thelp={ sprintf(\n\t\t\t\t// translators: %s: Title of the block e.g. 'Heading'.\n\t\t\t\t__(\n\t\t\t\t\t'Apply this block’s typography, spacing, dimensions, and color styles to all %s blocks.'\n\t\t\t\t),\n\t\t\t\tgetBlockType( name ).title\n\t\t\t) }\n\t\t>\n\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t{ __( 'Styles' ) }\n\t\t\t</BaseControl.VisualLabel>\n\t\t\t<Button\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tdisabled={ changes.length === 0 }\n\t\t\t\tonClick={ pushChanges }\n\t\t\t>\n\t\t\t\t{ __( 'Apply globally' ) }\n\t\t\t</Button>\n\t\t</BaseControl>\n\t);\n}\n\nconst withPushChangesToGlobalStyles = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst supportsStyles = SUPPORTED_STYLES.some( ( feature ) =>\n\t\t\thasBlockSupport( props.name, feature )\n\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ blockEditingMode === 'default' && supportsStyles && (\n\t\t\t\t\t<InspectorAdvancedControls>\n\t\t\t\t\t\t<PushChangesToGlobalStylesControl { ...props } />\n\t\t\t\t\t</InspectorAdvancedControls>\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/edit-site/push-changes-to-global-styles',\n\twithPushChangesToGlobalStyles\n);\n"]}