@wordpress/edit-site 5.19.3 → 5.19.4

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 (65) hide show
  1. package/build/components/add-new-pattern/index.js +1 -1
  2. package/build/components/add-new-pattern/index.js.map +1 -1
  3. package/build/components/global-styles/font-library-modal/resolvers.js +1 -1
  4. package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  5. package/build/components/global-styles/font-library-modal/utils/index.js +1 -1
  6. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  7. package/build/components/sidebar-edit-mode/template-panel/hooks.js +71 -0
  8. package/build/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -0
  9. package/build/components/sidebar-edit-mode/template-panel/replace-template-button.js +82 -0
  10. package/build/components/sidebar-edit-mode/template-panel/replace-template-button.js.map +1 -0
  11. package/build/components/sidebar-edit-mode/template-panel/template-actions.js +10 -3
  12. package/build/components/sidebar-edit-mode/template-panel/template-actions.js.map +1 -1
  13. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +5 -3
  14. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
  15. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +5 -4
  16. package/build/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  17. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +8 -1
  18. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  19. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +29 -0
  20. package/build/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js.map +1 -0
  21. package/build/store/selectors.js +4 -5
  22. package/build/store/selectors.js.map +1 -1
  23. package/build/utils/constants.js +1 -1
  24. package/build/utils/constants.js.map +1 -1
  25. package/build-module/components/add-new-pattern/index.js +2 -2
  26. package/build-module/components/add-new-pattern/index.js.map +1 -1
  27. package/build-module/components/global-styles/font-library-modal/resolvers.js +1 -1
  28. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  29. package/build-module/components/global-styles/font-library-modal/utils/index.js +1 -1
  30. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  31. package/build-module/components/sidebar-edit-mode/template-panel/hooks.js +64 -0
  32. package/build-module/components/sidebar-edit-mode/template-panel/hooks.js.map +1 -0
  33. package/build-module/components/sidebar-edit-mode/template-panel/replace-template-button.js +76 -0
  34. package/build-module/components/sidebar-edit-mode/template-panel/replace-template-button.js.map +1 -0
  35. package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js +10 -3
  36. package/build-module/components/sidebar-edit-mode/template-panel/template-actions.js.map +1 -1
  37. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +5 -3
  38. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js.map +1 -1
  39. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +5 -4
  40. package/build-module/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js.map +1 -1
  41. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +7 -1
  42. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js.map +1 -1
  43. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +22 -0
  44. package/build-module/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js.map +1 -0
  45. package/build-module/store/selectors.js +4 -5
  46. package/build-module/store/selectors.js.map +1 -1
  47. package/build-module/utils/constants.js +1 -1
  48. package/build-module/utils/constants.js.map +1 -1
  49. package/build-style/style-rtl.css +19 -0
  50. package/build-style/style.css +19 -0
  51. package/package.json +40 -40
  52. package/src/components/add-new-pattern/index.js +2 -2
  53. package/src/components/global-styles/font-library-modal/resolvers.js +1 -1
  54. package/src/components/global-styles/font-library-modal/utils/index.js +1 -1
  55. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamilies.spec.js +1 -1
  56. package/src/components/sidebar-edit-mode/template-panel/hooks.js +97 -0
  57. package/src/components/sidebar-edit-mode/template-panel/replace-template-button.js +89 -0
  58. package/src/components/sidebar-edit-mode/template-panel/style.scss +18 -0
  59. package/src/components/sidebar-edit-mode/template-panel/template-actions.js +27 -12
  60. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu-list-item.js +5 -8
  61. package/src/components/sidebar-navigation-screen-pattern/template-part-navigation-menu.js +5 -9
  62. package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js +11 -5
  63. package/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js +32 -0
  64. package/src/store/selectors.js +9 -10
  65. package/src/utils/constants.js +1 -1
@@ -10,6 +10,12 @@ import { parse } from '@wordpress/blocks';
10
10
  import TemplatePartNavigationMenus from './template-part-navigation-menus';
11
11
  import useEditedEntityRecord from '../use-edited-entity-record';
12
12
  import { TEMPLATE_PART_POST_TYPE } from '../../utils/constants';
13
+ function getBlocksFromRecord(record) {
14
+ if (record?.blocks) {
15
+ return record?.blocks;
16
+ }
17
+ return record?.content && typeof record.content !== 'function' ? parse(record.content) : [];
18
+ }
13
19
 
14
20
  /**
15
21
  * Retrieves a list of specific blocks from a given tree of blocks.
@@ -54,7 +60,7 @@ export default function useNavigationMenuContent(postType, postId) {
54
60
  if (postType !== TEMPLATE_PART_POST_TYPE) {
55
61
  return;
56
62
  }
57
- const blocks = record?.content && typeof record.content !== 'function' ? parse(record.content) : [];
63
+ const blocks = getBlocksFromRecord(record);
58
64
  const navigationBlocks = getBlocksOfTypeFromBlocks('core/navigation', blocks);
59
65
  if (!navigationBlocks.length) {
60
66
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["parse","TemplatePartNavigationMenus","useEditedEntityRecord","TEMPLATE_PART_POST_TYPE","getBlocksOfTypeFromBlocks","targetBlockType","blocks","length","findInBlocks","_blocks","navigationBlocks","block","name","push","innerBlocks","innerNavigationBlocks","useNavigationMenuContent","postType","postId","record","content","navigationMenuIds","map","attributes","ref","uniqueNavigationMenuIds","Set","filter","menuId","createElement","menus"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartNavigationMenus from './template-part-navigation-menus';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { TEMPLATE_PART_POST_TYPE } from '../../utils/constants';\n\n/**\n * Retrieves a list of specific blocks from a given tree of blocks.\n *\n * @param {string} targetBlockType The name of the block type to find.\n * @param {Array} blocks A list of blocks from a template part entity.\n *\n * @return {Array} A list of any navigation blocks found in the blocks.\n */\nfunction getBlocksOfTypeFromBlocks( targetBlockType, blocks ) {\n\tif ( ! targetBlockType || ! blocks?.length ) {\n\t\treturn [];\n\t}\n\n\tconst findInBlocks = ( _blocks ) => {\n\t\tif ( ! _blocks ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst navigationBlocks = [];\n\n\t\tfor ( const block of _blocks ) {\n\t\t\tif ( block.name === targetBlockType ) {\n\t\t\t\tnavigationBlocks.push( block );\n\t\t\t}\n\n\t\t\tif ( block?.innerBlocks ) {\n\t\t\t\tconst innerNavigationBlocks = findInBlocks( block.innerBlocks );\n\n\t\t\t\tif ( innerNavigationBlocks.length ) {\n\t\t\t\t\tnavigationBlocks.push( ...innerNavigationBlocks );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn navigationBlocks;\n\t};\n\n\treturn findInBlocks( blocks );\n}\n\nexport default function useNavigationMenuContent( postType, postId ) {\n\tconst { record } = useEditedEntityRecord( postType, postId );\n\n\t// Only managing navigation menus in template parts is supported\n\t// to match previous behaviour. This could potentially be expanded\n\t// to patterns as well.\n\tif ( postType !== TEMPLATE_PART_POST_TYPE ) {\n\t\treturn;\n\t}\n\n\tconst blocks =\n\t\trecord?.content && typeof record.content !== 'function'\n\t\t\t? parse( record.content )\n\t\t\t: [];\n\n\tconst navigationBlocks = getBlocksOfTypeFromBlocks(\n\t\t'core/navigation',\n\t\tblocks\n\t);\n\n\tif ( ! navigationBlocks.length ) {\n\t\treturn;\n\t}\n\n\tconst navigationMenuIds = navigationBlocks?.map(\n\t\t( block ) => block.attributes.ref\n\t);\n\n\t// Dedupe the Navigation blocks, as you can have multiple navigation blocks in the template.\n\t// Also, filter out undefined values, as blocks don't have an id when initially added.\n\tconst uniqueNavigationMenuIds = [ ...new Set( navigationMenuIds ) ].filter(\n\t\t( menuId ) => menuId\n\t);\n\n\tif ( ! uniqueNavigationMenuIds?.length ) {\n\t\treturn;\n\t}\n\n\treturn <TemplatePartNavigationMenus menus={ uniqueNavigationMenuIds } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;;AAEzC;AACA;AACA;AACA,OAAOC,2BAA2B,MAAM,kCAAkC;AAC1E,OAAOC,qBAAqB,MAAM,6BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,uBAAuB;;AAE/D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAEC,eAAe,EAAEC,MAAM,EAAG;EAC7D,IAAK,CAAED,eAAe,IAAI,CAAEC,MAAM,EAAEC,MAAM,EAAG;IAC5C,OAAO,EAAE;EACV;EAEA,MAAMC,YAAY,GAAKC,OAAO,IAAM;IACnC,IAAK,CAAEA,OAAO,EAAG;MAChB,OAAO,EAAE;IACV;IAEA,MAAMC,gBAAgB,GAAG,EAAE;IAE3B,KAAM,MAAMC,KAAK,IAAIF,OAAO,EAAG;MAC9B,IAAKE,KAAK,CAACC,IAAI,KAAKP,eAAe,EAAG;QACrCK,gBAAgB,CAACG,IAAI,CAAEF,KAAM,CAAC;MAC/B;MAEA,IAAKA,KAAK,EAAEG,WAAW,EAAG;QACzB,MAAMC,qBAAqB,GAAGP,YAAY,CAAEG,KAAK,CAACG,WAAY,CAAC;QAE/D,IAAKC,qBAAqB,CAACR,MAAM,EAAG;UACnCG,gBAAgB,CAACG,IAAI,CAAE,GAAGE,qBAAsB,CAAC;QAClD;MACD;IACD;IAEA,OAAOL,gBAAgB;EACxB,CAAC;EAED,OAAOF,YAAY,CAAEF,MAAO,CAAC;AAC9B;AAEA,eAAe,SAASU,wBAAwBA,CAAEC,QAAQ,EAAEC,MAAM,EAAG;EACpE,MAAM;IAAEC;EAAO,CAAC,GAAGjB,qBAAqB,CAAEe,QAAQ,EAAEC,MAAO,CAAC;;EAE5D;EACA;EACA;EACA,IAAKD,QAAQ,KAAKd,uBAAuB,EAAG;IAC3C;EACD;EAEA,MAAMG,MAAM,GACXa,MAAM,EAAEC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,KAAK,UAAU,GACpDpB,KAAK,CAAEmB,MAAM,CAACC,OAAQ,CAAC,GACvB,EAAE;EAEN,MAAMV,gBAAgB,GAAGN,yBAAyB,CACjD,iBAAiB,EACjBE,MACD,CAAC;EAED,IAAK,CAAEI,gBAAgB,CAACH,MAAM,EAAG;IAChC;EACD;EAEA,MAAMc,iBAAiB,GAAGX,gBAAgB,EAAEY,GAAG,CAC5CX,KAAK,IAAMA,KAAK,CAACY,UAAU,CAACC,GAC/B,CAAC;;EAED;EACA;EACA,MAAMC,uBAAuB,GAAG,CAAE,GAAG,IAAIC,GAAG,CAAEL,iBAAkB,CAAC,CAAE,CAACM,MAAM,CACvEC,MAAM,IAAMA,MACf,CAAC;EAED,IAAK,CAAEH,uBAAuB,EAAElB,MAAM,EAAG;IACxC;EACD;EAEA,OAAOsB,aAAA,CAAC5B,2BAA2B;IAAC6B,KAAK,EAAGL;EAAyB,CAAE,CAAC;AACzE"}
1
+ {"version":3,"names":["parse","TemplatePartNavigationMenus","useEditedEntityRecord","TEMPLATE_PART_POST_TYPE","getBlocksFromRecord","record","blocks","content","getBlocksOfTypeFromBlocks","targetBlockType","length","findInBlocks","_blocks","navigationBlocks","block","name","push","innerBlocks","innerNavigationBlocks","useNavigationMenuContent","postType","postId","navigationMenuIds","map","attributes","ref","uniqueNavigationMenuIds","Set","filter","menuId","createElement","menus"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-content.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartNavigationMenus from './template-part-navigation-menus';\nimport useEditedEntityRecord from '../use-edited-entity-record';\nimport { TEMPLATE_PART_POST_TYPE } from '../../utils/constants';\n\nfunction getBlocksFromRecord( record ) {\n\tif ( record?.blocks ) {\n\t\treturn record?.blocks;\n\t}\n\n\treturn record?.content && typeof record.content !== 'function'\n\t\t? parse( record.content )\n\t\t: [];\n}\n\n/**\n * Retrieves a list of specific blocks from a given tree of blocks.\n *\n * @param {string} targetBlockType The name of the block type to find.\n * @param {Array} blocks A list of blocks from a template part entity.\n *\n * @return {Array} A list of any navigation blocks found in the blocks.\n */\nfunction getBlocksOfTypeFromBlocks( targetBlockType, blocks ) {\n\tif ( ! targetBlockType || ! blocks?.length ) {\n\t\treturn [];\n\t}\n\n\tconst findInBlocks = ( _blocks ) => {\n\t\tif ( ! _blocks ) {\n\t\t\treturn [];\n\t\t}\n\n\t\tconst navigationBlocks = [];\n\n\t\tfor ( const block of _blocks ) {\n\t\t\tif ( block.name === targetBlockType ) {\n\t\t\t\tnavigationBlocks.push( block );\n\t\t\t}\n\n\t\t\tif ( block?.innerBlocks ) {\n\t\t\t\tconst innerNavigationBlocks = findInBlocks( block.innerBlocks );\n\n\t\t\t\tif ( innerNavigationBlocks.length ) {\n\t\t\t\t\tnavigationBlocks.push( ...innerNavigationBlocks );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn navigationBlocks;\n\t};\n\n\treturn findInBlocks( blocks );\n}\n\nexport default function useNavigationMenuContent( postType, postId ) {\n\tconst { record } = useEditedEntityRecord( postType, postId );\n\n\t// Only managing navigation menus in template parts is supported\n\t// to match previous behaviour. This could potentially be expanded\n\t// to patterns as well.\n\tif ( postType !== TEMPLATE_PART_POST_TYPE ) {\n\t\treturn;\n\t}\n\n\tconst blocks = getBlocksFromRecord( record );\n\tconst navigationBlocks = getBlocksOfTypeFromBlocks(\n\t\t'core/navigation',\n\t\tblocks\n\t);\n\n\tif ( ! navigationBlocks.length ) {\n\t\treturn;\n\t}\n\n\tconst navigationMenuIds = navigationBlocks?.map(\n\t\t( block ) => block.attributes.ref\n\t);\n\n\t// Dedupe the Navigation blocks, as you can have multiple navigation blocks in the template.\n\t// Also, filter out undefined values, as blocks don't have an id when initially added.\n\tconst uniqueNavigationMenuIds = [ ...new Set( navigationMenuIds ) ].filter(\n\t\t( menuId ) => menuId\n\t);\n\n\tif ( ! uniqueNavigationMenuIds?.length ) {\n\t\treturn;\n\t}\n\n\treturn <TemplatePartNavigationMenus menus={ uniqueNavigationMenuIds } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;;AAEzC;AACA;AACA;AACA,OAAOC,2BAA2B,MAAM,kCAAkC;AAC1E,OAAOC,qBAAqB,MAAM,6BAA6B;AAC/D,SAASC,uBAAuB,QAAQ,uBAAuB;AAE/D,SAASC,mBAAmBA,CAAEC,MAAM,EAAG;EACtC,IAAKA,MAAM,EAAEC,MAAM,EAAG;IACrB,OAAOD,MAAM,EAAEC,MAAM;EACtB;EAEA,OAAOD,MAAM,EAAEE,OAAO,IAAI,OAAOF,MAAM,CAACE,OAAO,KAAK,UAAU,GAC3DP,KAAK,CAAEK,MAAM,CAACE,OAAQ,CAAC,GACvB,EAAE;AACN;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,yBAAyBA,CAAEC,eAAe,EAAEH,MAAM,EAAG;EAC7D,IAAK,CAAEG,eAAe,IAAI,CAAEH,MAAM,EAAEI,MAAM,EAAG;IAC5C,OAAO,EAAE;EACV;EAEA,MAAMC,YAAY,GAAKC,OAAO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xC;EACD;EAEA,OAAOoB,aAAA,CAAC7B,2BAA2B;IAAC8B,KAAK,EAAGL;EAAyB,CAAE,CAAC;AACzE"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import { NAVIGATION_POST_TYPE } from '../../utils/constants';
11
+ export default function useNavigationMenuTitle(id) {
12
+ return useSelect(select => {
13
+ if (!id) {
14
+ return undefined;
15
+ }
16
+ const editedRecord = select(coreStore).getEditedEntityRecord('postType', NAVIGATION_POST_TYPE, id);
17
+
18
+ // Do not display a 'trashed' navigation menu.
19
+ return editedRecord.status === 'trash' ? undefined : editedRecord.title;
20
+ }, [id]);
21
+ }
22
+ //# sourceMappingURL=use-navigation-menu-title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useSelect","store","coreStore","NAVIGATION_POST_TYPE","useNavigationMenuTitle","id","select","undefined","editedRecord","getEditedEntityRecord","status","title"],"sources":["@wordpress/edit-site/src/components/sidebar-navigation-screen-pattern/use-navigation-menu-title.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { NAVIGATION_POST_TYPE } from '../../utils/constants';\n\nexport default function useNavigationMenuTitle( id ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! id ) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst editedRecord = select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tNAVIGATION_POST_TYPE,\n\t\t\t\tid\n\t\t\t);\n\n\t\t\t// Do not display a 'trashed' navigation menu.\n\t\t\treturn editedRecord.status === 'trash'\n\t\t\t\t? undefined\n\t\t\t\t: editedRecord.title;\n\t\t},\n\t\t[ id ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,oBAAoB,QAAQ,uBAAuB;AAE5D,eAAe,SAASC,sBAAsBA,CAAEC,EAAE,EAAG;EACpD,OAAOL,SAAS,CACbM,MAAM,IAAM;IACb,IAAK,CAAED,EAAE,EAAG;MACX,OAAOE,SAAS;IACjB;IAEA,MAAMC,YAAY,GAAGF,MAAM,CAAEJ,SAAU,CAAC,CAACO,qBAAqB,CAC7D,UAAU,EACVN,oBAAoB,EACpBE,EACD,CAAC;;IAED;IACA,OAAOG,YAAY,CAACE,MAAM,KAAK,OAAO,GACnCH,SAAS,GACTC,YAAY,CAACG,KAAK;EACtB,CAAC,EACD,CAAEN,EAAE,CACL,CAAC;AACF"}
@@ -259,14 +259,13 @@ export function isSaveViewOpened(state) {
259
259
  * @param {Object} state Global application state.
260
260
  * @return {Array} Template parts and their blocks in an array.
261
261
  */
262
- export const getCurrentTemplateTemplateParts = createRegistrySelector(select => state => {
263
- const templateType = getEditedPostType(state);
264
- const templateId = getEditedPostId(state);
265
- const template = select(coreDataStore).getEditedEntityRecord('postType', templateType, templateId);
262
+ export const getCurrentTemplateTemplateParts = createRegistrySelector(select => () => {
266
263
  const templateParts = select(coreDataStore).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
267
264
  per_page: -1
268
265
  });
269
- return getFilteredTemplatePartBlocks(template.blocks, templateParts);
266
+ const clientIds = select(blockEditorStore).__experimentalGetGlobalBlocksByName('core/template-part');
267
+ const blocks = select(blockEditorStore).getBlocksByClientId(clientIds);
268
+ return getFilteredTemplatePartBlocks(blocks, templateParts);
270
269
  });
271
270
 
272
271
  /**
@@ -1 +1 @@
1
- {"version":3,"names":["createSelector","store","coreDataStore","createRegistrySelector","deprecated","uploadMedia","Platform","preferencesStore","blockEditorStore","getFilteredTemplatePartBlocks","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","__unstableGetPreference","select","state","name","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","isDistractionFree","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","hasPageContentFocus","postContentClientId","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","isPage","postId"],"sources":["@wordpress/edit-site/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../utils/constants';\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\tisDistractionFree: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\tTEMPLATE_POST_TYPE === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'distractionFree' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif ( hasPageContentFocus( state ) ) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus( state ) {\n\treturn isPage( state ) ? state.hasPageContentFocus : false;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAc,MAAM,QAAQ;;AAEnC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;AAC7D,SAASC,sBAAsB,QAAQ,iBAAiB;AACxD,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,WAAW,QAAQ,wBAAwB;AACpD,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASL,KAAK,IAAIM,gBAAgB,QAAQ,wBAAwB;AAClE,SAASN,KAAK,IAAIO,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SAASC,6BAA6B,QAAQ,SAAS;AACvD,SACCC,kBAAkB,EAClBC,uBAAuB,QACjB,oBAAoB;AAC3B;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,uBAAuB,GAAGT,sBAAsB,CAC1DU,MAAM,IAAM,CAAEC,KAAK,EAAEC,IAAI,KAC1BF,MAAM,CAAEN,gBAAiB,CAAC,CAACS,GAAG,CAAE,gBAAgB,EAAED,IAAK,CACzD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,eAAeA,CAAEH,KAAK,EAAEI,WAAW,EAAG;EACrDd,UAAU,CAAG,4CAA2C,EAAE;IACzDe,KAAK,EAAE,KAAK;IACZC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A,EAAG;EAC1D7E,UAAU,CACT,uEAAuE,EACvE;IACCe,KAAK,EAAE,KAAK;IACZgC,OAAO,EAAE;EACV,CACD,CAAC;AACF;;AAEA;AACA;AACA;AACA,OAAO,SAAS+B,4BAA4BA,CAAA,EAAG;EAC9C9E,UAAU,CAAE,2DAA2D,EAAE;IACxEe,KAAK,EAAE,KAAK;IACZgC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA,OAAO,SAASgC,kBAAkBA,CAAA,EAAG;EACpC/E,UAAU,CAAE,iDAAiD,EAAE;IAC9De,KAAK,EAAE,KAAK;IACZgC,OAAO,EAAE;EACV,CAAE,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASiC,MAAMA,CAAEtE,KAAK,EAAG;EAC/B,OAAO,CAAC,CAAEA,KAAK,CAACsC,UAAU,CAACK,OAAO,EAAE4B,MAAM;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASpB,mBAAmBA,CAAEnD,KAAK,EAAG;EAC5C,OAAOsE,MAAM,CAAEtE,KAAM,CAAC,GAAGA,KAAK,CAACmD,mBAAmB,GAAG,KAAK;AAC3D"}
1
+ {"version":3,"names":["createSelector","store","coreDataStore","createRegistrySelector","deprecated","uploadMedia","Platform","preferencesStore","blockEditorStore","getFilteredTemplatePartBlocks","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","__unstableGetPreference","select","state","name","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","canUser","getReusableBlocks","isWeb","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","isDistractionFree","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","hasPageContentFocus","postContentClientId","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateParts","clientIds","blocks","getBlocksByClientId","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","isPage","postId"],"sources":["@wordpress/edit-site/src/store/selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\nimport {\n\tTEMPLATE_POST_TYPE,\n\tTEMPLATE_PART_POST_TYPE,\n} from '../utils/constants';\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\tisDistractionFree: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\tTEMPLATE_POST_TYPE === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'distractionFree' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif ( hasPageContentFocus( state ) ) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\tconst clientIds =\n\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t'core/template-part'\n\t\t\t);\n\t\tconst blocks =\n\t\t\tselect( blockEditorStore ).getBlocksByClientId( clientIds );\n\n\t\treturn getFilteredTemplatePartBlocks( blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus( state ) {\n\treturn isPage( state ) ? state.hasPage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,CAAC;AACJ;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS+B,MAAMA,CAAEpE,KAAK,EAAG;EAC/B,OAAO,CAAC,CAAEA,KAAK,CAACsC,UAAU,CAACK,OAAO,EAAE0B,MAAM;AAC3C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASlB,mBAAmBA,CAAEnD,KAAK,EAAG;EAC5C,OAAOoE,MAAM,CAAEpE,KAAM,CAAC,GAAGA,KAAK,CAACmD,mBAAmB,GAAG,KAAK;AAC3D"}
@@ -45,7 +45,7 @@ export const PAGE_CONTENT_BLOCK_TYPES = {
45
45
  };
46
46
  export const POST_TYPE_LABELS = {
47
47
  [TEMPLATE_POST_TYPE]: __('Template'),
48
- [TEMPLATE_PART_POST_TYPE]: __('Template Part'),
48
+ [TEMPLATE_PART_POST_TYPE]: __('Template part'),
49
49
  [PATTERN_TYPES.user]: __('Pattern'),
50
50
  [NAVIGATION_POST_TYPE]: __('Navigation')
51
51
  };
@@ -1 +1 @@
1
- {"version":3,"names":["__","privateApis","patternPrivateApis","unlock","NAVIGATION_POST_TYPE","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","PATTERN_CORE_SOURCES","PATTERN_SYNC_TYPES","FOCUSABLE_ENTITIES","user","PAGE_CONTENT_BLOCK_TYPES","POST_TYPE_LABELS"],"sources":["@wordpress/edit-site/src/utils/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// Navigation\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\n\n// Templates.\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\n\n// Patterns.\nexport const {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tPATTERN_CORE_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternPrivateApis );\n\n// Entities that are editable in focus mode.\nexport const FOCUSABLE_ENTITIES = [\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\n/**\n * Block types that are considered to be page content. These are the only blocks\n * editable when hasPageContentFocus() is true.\n */\nexport const PAGE_CONTENT_BLOCK_TYPES = {\n\t'core/post-title': true,\n\t'core/post-featured-image': true,\n\t'core/post-content': true,\n};\n\nexport const POST_TYPE_LABELS = {\n\t[ TEMPLATE_POST_TYPE ]: __( 'Template' ),\n\t[ TEMPLATE_PART_POST_TYPE ]: __( 'Template Part' ),\n\t[ PATTERN_TYPES.user ]: __( 'Pattern' ),\n\t[ NAVIGATION_POST_TYPE ]: __( 'Navigation' ),\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,IAAIC,kBAAkB,QAAQ,qBAAqB;;AAEvE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA,OAAO,MAAMC,oBAAoB,GAAG,eAAe;;AAEnD;AACA,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C,OAAO,MAAMC,uBAAuB,GAAG,kBAAkB;AACzD,OAAO,MAAMC,gBAAgB,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AACD,OAAO,MAAMC,mCAAmC,GAAG,eAAe;;AAElE;AACA,OAAO,MAAM;EACZC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,oBAAoB;EACpBC;AACD,CAAC,GAAGb,MAAM,CAAED,kBAAmB,CAAC;;AAEhC;AACA,OAAO,MAAMe,kBAAkB,GAAG,CACjCX,uBAAuB,EACvBF,oBAAoB,EACpBQ,aAAa,CAACM,IAAI,CAClB;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG;EACvC,iBAAiB,EAAE,IAAI;EACvB,0BAA0B,EAAE,IAAI;EAChC,mBAAmB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC/B,CAAEf,kBAAkB,GAAIL,EAAE,CAAE,UAAW,CAAC;EACxC,CAAEM,uBAAuB,GAAIN,EAAE,CAAE,eAAgB,CAAC;EAClD,CAAEY,aAAa,CAACM,IAAI,GAAIlB,EAAE,CAAE,SAAU,CAAC;EACvC,CAAEI,oBAAoB,GAAIJ,EAAE,CAAE,YAAa;AAC5C,CAAC"}
1
+ {"version":3,"names":["__","privateApis","patternPrivateApis","unlock","NAVIGATION_POST_TYPE","TEMPLATE_POST_TYPE","TEMPLATE_PART_POST_TYPE","TEMPLATE_ORIGINS","custom","theme","plugin","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","PATTERN_TYPES","PATTERN_DEFAULT_CATEGORY","PATTERN_USER_CATEGORY","PATTERN_CORE_SOURCES","PATTERN_SYNC_TYPES","FOCUSABLE_ENTITIES","user","PAGE_CONTENT_BLOCK_TYPES","POST_TYPE_LABELS"],"sources":["@wordpress/edit-site/src/utils/constants.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as patternPrivateApis } from '@wordpress/patterns';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\n\n// Navigation\nexport const NAVIGATION_POST_TYPE = 'wp_navigation';\n\n// Templates.\nexport const TEMPLATE_POST_TYPE = 'wp_template';\nexport const TEMPLATE_PART_POST_TYPE = 'wp_template_part';\nexport const TEMPLATE_ORIGINS = {\n\tcustom: 'custom',\n\ttheme: 'theme',\n\tplugin: 'plugin',\n};\nexport const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';\n\n// Patterns.\nexport const {\n\tPATTERN_TYPES,\n\tPATTERN_DEFAULT_CATEGORY,\n\tPATTERN_USER_CATEGORY,\n\tPATTERN_CORE_SOURCES,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternPrivateApis );\n\n// Entities that are editable in focus mode.\nexport const FOCUSABLE_ENTITIES = [\n\tTEMPLATE_PART_POST_TYPE,\n\tNAVIGATION_POST_TYPE,\n\tPATTERN_TYPES.user,\n];\n\n/**\n * Block types that are considered to be page content. These are the only blocks\n * editable when hasPageContentFocus() is true.\n */\nexport const PAGE_CONTENT_BLOCK_TYPES = {\n\t'core/post-title': true,\n\t'core/post-featured-image': true,\n\t'core/post-content': true,\n};\n\nexport const POST_TYPE_LABELS = {\n\t[ TEMPLATE_POST_TYPE ]: __( 'Template' ),\n\t[ TEMPLATE_PART_POST_TYPE ]: __( 'Template part' ),\n\t[ PATTERN_TYPES.user ]: __( 'Pattern' ),\n\t[ NAVIGATION_POST_TYPE ]: __( 'Navigation' ),\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,IAAIC,kBAAkB,QAAQ,qBAAqB;;AAEvE;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA,OAAO,MAAMC,oBAAoB,GAAG,eAAe;;AAEnD;AACA,OAAO,MAAMC,kBAAkB,GAAG,aAAa;AAC/C,OAAO,MAAMC,uBAAuB,GAAG,kBAAkB;AACzD,OAAO,MAAMC,gBAAgB,GAAG;EAC/BC,MAAM,EAAE,QAAQ;EAChBC,KAAK,EAAE,OAAO;EACdC,MAAM,EAAE;AACT,CAAC;AACD,OAAO,MAAMC,mCAAmC,GAAG,eAAe;;AAElE;AACA,OAAO,MAAM;EACZC,aAAa;EACbC,wBAAwB;EACxBC,qBAAqB;EACrBC,oBAAoB;EACpBC;AACD,CAAC,GAAGb,MAAM,CAAED,kBAAmB,CAAC;;AAEhC;AACA,OAAO,MAAMe,kBAAkB,GAAG,CACjCX,uBAAuB,EACvBF,oBAAoB,EACpBQ,aAAa,CAACM,IAAI,CAClB;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAG;EACvC,iBAAiB,EAAE,IAAI;EACvB,0BAA0B,EAAE,IAAI;EAChC,mBAAmB,EAAE;AACtB,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAG;EAC/B,CAAEf,kBAAkB,GAAIL,EAAE,CAAE,UAAW,CAAC;EACxC,CAAEM,uBAAuB,GAAIN,EAAE,CAAE,eAAgB,CAAC;EAClD,CAAEY,aAAa,CAACM,IAAI,GAAIlB,EAAE,CAAE,SAAU,CAAC;EACvC,CAAEI,oBAAoB,GAAIJ,EAAE,CAAE,YAAa;AAC5C,CAAC"}
@@ -2476,6 +2476,25 @@ h3.edit-site-template-card__template-areas-title {
2476
2476
  margin: 0 0 8px;
2477
2477
  }
2478
2478
 
2479
+ .edit-site-template-panel__replace-template-modal {
2480
+ z-index: 1000001;
2481
+ }
2482
+
2483
+ .edit-site-template-panel__replace-template-modal__content {
2484
+ column-count: 2;
2485
+ column-gap: 24px;
2486
+ }
2487
+ @media (min-width: 782px) {
2488
+ .edit-site-template-panel__replace-template-modal__content {
2489
+ column-count: 3;
2490
+ }
2491
+ }
2492
+ @media (min-width: 1280px) {
2493
+ .edit-site-template-panel__replace-template-modal__content {
2494
+ column-count: 4;
2495
+ }
2496
+ }
2497
+
2479
2498
  .edit-site-editor__interface-skeleton {
2480
2499
  opacity: 1;
2481
2500
  transition: opacity 0.1s ease-out;
@@ -2477,6 +2477,25 @@ h3.edit-site-template-card__template-areas-title {
2477
2477
  margin: 0 0 8px;
2478
2478
  }
2479
2479
 
2480
+ .edit-site-template-panel__replace-template-modal {
2481
+ z-index: 1000001;
2482
+ }
2483
+
2484
+ .edit-site-template-panel__replace-template-modal__content {
2485
+ column-count: 2;
2486
+ column-gap: 24px;
2487
+ }
2488
+ @media (min-width: 782px) {
2489
+ .edit-site-template-panel__replace-template-modal__content {
2490
+ column-count: 3;
2491
+ }
2492
+ }
2493
+ @media (min-width: 1280px) {
2494
+ .edit-site-template-panel__replace-template-modal__content {
2495
+ column-count: 4;
2496
+ }
2497
+ }
2498
+
2480
2499
  .edit-site-editor__interface-skeleton {
2481
2500
  opacity: 1;
2482
2501
  transition: opacity 0.1s ease-out;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "5.19.3",
3
+ "version": "5.19.4",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,44 +27,44 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.42.3",
31
- "@wordpress/api-fetch": "^6.39.3",
32
- "@wordpress/block-editor": "^12.10.3",
33
- "@wordpress/block-library": "^8.19.3",
34
- "@wordpress/blocks": "^12.19.3",
35
- "@wordpress/commands": "^0.13.3",
36
- "@wordpress/components": "^25.8.3",
37
- "@wordpress/compose": "^6.19.3",
38
- "@wordpress/core-commands": "^0.11.3",
39
- "@wordpress/core-data": "^6.19.3",
40
- "@wordpress/data": "^9.12.3",
41
- "@wordpress/date": "^4.42.3",
42
- "@wordpress/deprecated": "^3.42.3",
43
- "@wordpress/dom": "^3.42.3",
44
- "@wordpress/editor": "^13.19.3",
45
- "@wordpress/element": "^5.19.3",
46
- "@wordpress/escape-html": "^2.42.3",
47
- "@wordpress/hooks": "^3.42.3",
48
- "@wordpress/html-entities": "^3.42.3",
49
- "@wordpress/i18n": "^4.42.3",
50
- "@wordpress/icons": "^9.33.3",
51
- "@wordpress/interface": "^5.19.3",
52
- "@wordpress/keyboard-shortcuts": "^4.19.3",
53
- "@wordpress/keycodes": "^3.42.3",
54
- "@wordpress/media-utils": "^4.33.3",
55
- "@wordpress/notices": "^4.10.3",
56
- "@wordpress/patterns": "^1.3.3",
57
- "@wordpress/plugins": "^6.10.3",
58
- "@wordpress/preferences": "^3.19.3",
59
- "@wordpress/primitives": "^3.40.3",
60
- "@wordpress/private-apis": "^0.24.3",
61
- "@wordpress/reusable-blocks": "^4.19.3",
62
- "@wordpress/router": "^0.11.3",
63
- "@wordpress/style-engine": "^1.25.3",
64
- "@wordpress/url": "^3.43.3",
65
- "@wordpress/viewport": "^5.19.3",
66
- "@wordpress/widgets": "^3.19.3",
67
- "@wordpress/wordcount": "^3.42.3",
30
+ "@wordpress/a11y": "^3.42.4",
31
+ "@wordpress/api-fetch": "^6.39.4",
32
+ "@wordpress/block-editor": "^12.10.4",
33
+ "@wordpress/block-library": "^8.19.4",
34
+ "@wordpress/blocks": "^12.19.4",
35
+ "@wordpress/commands": "^0.13.4",
36
+ "@wordpress/components": "^25.8.4",
37
+ "@wordpress/compose": "^6.19.4",
38
+ "@wordpress/core-commands": "^0.11.4",
39
+ "@wordpress/core-data": "^6.19.4",
40
+ "@wordpress/data": "^9.12.4",
41
+ "@wordpress/date": "^4.42.4",
42
+ "@wordpress/deprecated": "^3.42.4",
43
+ "@wordpress/dom": "^3.42.4",
44
+ "@wordpress/editor": "^13.19.4",
45
+ "@wordpress/element": "^5.19.4",
46
+ "@wordpress/escape-html": "^2.42.4",
47
+ "@wordpress/hooks": "^3.42.4",
48
+ "@wordpress/html-entities": "^3.42.4",
49
+ "@wordpress/i18n": "^4.42.4",
50
+ "@wordpress/icons": "^9.33.4",
51
+ "@wordpress/interface": "^5.19.4",
52
+ "@wordpress/keyboard-shortcuts": "^4.19.4",
53
+ "@wordpress/keycodes": "^3.42.4",
54
+ "@wordpress/media-utils": "^4.33.4",
55
+ "@wordpress/notices": "^4.10.4",
56
+ "@wordpress/patterns": "^1.3.4",
57
+ "@wordpress/plugins": "^6.10.4",
58
+ "@wordpress/preferences": "^3.19.4",
59
+ "@wordpress/primitives": "^3.40.4",
60
+ "@wordpress/private-apis": "^0.24.4",
61
+ "@wordpress/reusable-blocks": "^4.19.4",
62
+ "@wordpress/router": "^0.11.4",
63
+ "@wordpress/style-engine": "^1.25.4",
64
+ "@wordpress/url": "^3.43.4",
65
+ "@wordpress/viewport": "^5.19.4",
66
+ "@wordpress/widgets": "^3.19.4",
67
+ "@wordpress/wordcount": "^3.42.4",
68
68
  "change-case": "^4.1.2",
69
69
  "classnames": "^2.3.1",
70
70
  "colord": "^2.9.2",
@@ -84,5 +84,5 @@
84
84
  "publishConfig": {
85
85
  "access": "public"
86
86
  },
87
- "gitHead": "6256f93c37705d142f75a99f1fc808540ca7dca8"
87
+ "gitHead": "d1072bbcaf037a18d414da7865ebaf366a0e7062"
88
88
  }
@@ -4,7 +4,7 @@
4
4
  import { DropdownMenu } from '@wordpress/components';
5
5
  import { useState, useRef } from '@wordpress/element';
6
6
  import { __, sprintf } from '@wordpress/i18n';
7
- import { plus, symbol, symbolFilled } from '@wordpress/icons';
7
+ import { plus, symbol, symbolFilled, upload } from '@wordpress/icons';
8
8
  import { useSelect, useDispatch } from '@wordpress/data';
9
9
  import { privateApis as routerPrivateApis } from '@wordpress/router';
10
10
  import {
@@ -90,7 +90,7 @@ export default function AddNewPattern() {
90
90
  }
91
91
 
92
92
  controls.push( {
93
- icon: symbol,
93
+ icon: upload,
94
94
  onClick: () => {
95
95
  patternUploadInputRef.current.click();
96
96
  },
@@ -18,7 +18,7 @@ export async function fetchInstallFonts( data ) {
18
18
 
19
19
  export async function fetchUninstallFonts( fonts ) {
20
20
  const data = {
21
- fontFamilies: fonts,
21
+ font_families: fonts,
22
22
  };
23
23
  const config = {
24
24
  path: '/wp/v2/fonts',
@@ -152,6 +152,6 @@ export function makeFormDataFromFontFamilies( fontFamilies ) {
152
152
  }
153
153
  return family;
154
154
  } );
155
- formData.append( 'fontFamilies', JSON.stringify( newFontFamilies ) );
155
+ formData.append( 'font_families', JSON.stringify( newFontFamilies ) );
156
156
  return formData;
157
157
  }
@@ -55,7 +55,7 @@ describe( 'makeFormDataFromFontFamilies', () => {
55
55
  fontFamily: 'Bebas',
56
56
  },
57
57
  ];
58
- expect( JSON.parse( formData.get( 'fontFamilies' ) ) ).toEqual(
58
+ expect( JSON.parse( formData.get( 'font_families' ) ) ).toEqual(
59
59
  expectedFontFamilies
60
60
  );
61
61
  } );
@@ -0,0 +1,97 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { useMemo } from '@wordpress/element';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+ import { parse } from '@wordpress/blocks';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editSiteStore } from '../../../store';
13
+ import { PATTERN_CORE_SOURCES, PATTERN_TYPES } from '../../../utils/constants';
14
+ import { unlock } from '../../../lock-unlock';
15
+
16
+ function injectThemeAttributeInBlockTemplateContent(
17
+ block,
18
+ currentThemeStylesheet
19
+ ) {
20
+ block.innerBlocks = block.innerBlocks.map( ( innerBlock ) => {
21
+ return injectThemeAttributeInBlockTemplateContent(
22
+ innerBlock,
23
+ currentThemeStylesheet
24
+ );
25
+ } );
26
+
27
+ if (
28
+ block.name === 'core/template-part' &&
29
+ block.attributes.theme === undefined
30
+ ) {
31
+ block.attributes.theme = currentThemeStylesheet;
32
+ }
33
+ return block;
34
+ }
35
+
36
+ function preparePatterns( patterns, template, currentThemeStylesheet ) {
37
+ // Filter out duplicates.
38
+ const filterOutDuplicatesByName = ( currentItem, index, items ) =>
39
+ index === items.findIndex( ( item ) => currentItem.name === item.name );
40
+
41
+ // Filter out core patterns.
42
+ const filterOutCorePatterns = ( pattern ) =>
43
+ ! PATTERN_CORE_SOURCES.includes( pattern.source );
44
+
45
+ // Filter only the patterns that are compatible with the current template.
46
+ const filterCompatiblePatterns = ( pattern ) =>
47
+ pattern.templateTypes?.includes( template.slug );
48
+
49
+ return patterns
50
+ .filter(
51
+ filterOutCorePatterns &&
52
+ filterOutDuplicatesByName &&
53
+ filterCompatiblePatterns
54
+ )
55
+ .map( ( pattern ) => ( {
56
+ ...pattern,
57
+ keywords: pattern.keywords || [],
58
+ type: PATTERN_TYPES.theme,
59
+ blocks: parse( pattern.content, {
60
+ __unstableSkipMigrationLogs: true,
61
+ } ).map( ( block ) =>
62
+ injectThemeAttributeInBlockTemplateContent(
63
+ block,
64
+ currentThemeStylesheet
65
+ )
66
+ ),
67
+ } ) );
68
+ }
69
+
70
+ export function useAvailablePatterns( template ) {
71
+ const { blockPatterns, restBlockPatterns, currentThemeStylesheet } =
72
+ useSelect( ( select ) => {
73
+ const { getSettings } = unlock( select( editSiteStore ) );
74
+ const settings = getSettings();
75
+
76
+ return {
77
+ blockPatterns:
78
+ settings.__experimentalAdditionalBlockPatterns ??
79
+ settings.__experimentalBlockPatterns,
80
+ restBlockPatterns: select( coreStore ).getBlockPatterns(),
81
+ currentThemeStylesheet:
82
+ select( coreStore ).getCurrentTheme().stylesheet,
83
+ };
84
+ }, [] );
85
+
86
+ return useMemo( () => {
87
+ const mergedPatterns = [
88
+ ...( blockPatterns || [] ),
89
+ ...( restBlockPatterns || [] ),
90
+ ];
91
+ return preparePatterns(
92
+ mergedPatterns,
93
+ template,
94
+ currentThemeStylesheet
95
+ );
96
+ }, [ blockPatterns, restBlockPatterns, template, currentThemeStylesheet ] );
97
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect, useDispatch } from '@wordpress/data';
5
+ import { useState } from '@wordpress/element';
6
+ import { __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
7
+ import { MenuItem, Modal } from '@wordpress/components';
8
+ import { __ } from '@wordpress/i18n';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { useAsyncList } from '@wordpress/compose';
11
+ import { serialize } from '@wordpress/blocks';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { store as editSiteStore } from '../../../store';
17
+
18
+ export default function ReplaceTemplateButton( {
19
+ onClick,
20
+ availableTemplates,
21
+ } ) {
22
+ const { editEntityRecord } = useDispatch( coreStore );
23
+ const [ showModal, setShowModal ] = useState( false );
24
+ const onClose = () => {
25
+ setShowModal( false );
26
+ };
27
+
28
+ const { postId, postType } = useSelect( ( select ) => {
29
+ return {
30
+ postId: select( editSiteStore ).getEditedPostId(),
31
+ postType: select( editSiteStore ).getEditedPostType(),
32
+ };
33
+ }, [] );
34
+
35
+ const onTemplateSelect = async ( selectedTemplate ) => {
36
+ onClose(); // Close the template suggestions modal first.
37
+ onClick();
38
+ await editEntityRecord( 'postType', postType, postId, {
39
+ blocks: selectedTemplate.blocks,
40
+ content: serialize( selectedTemplate.blocks ),
41
+ } );
42
+ };
43
+
44
+ if ( ! availableTemplates.length || availableTemplates.length < 1 ) {
45
+ return null;
46
+ }
47
+
48
+ return (
49
+ <>
50
+ <MenuItem
51
+ info={ __(
52
+ 'Replace the contents of this template with another.'
53
+ ) }
54
+ onClick={ () => setShowModal( true ) }
55
+ >
56
+ { __( 'Replace template' ) }
57
+ </MenuItem>
58
+
59
+ { showModal && (
60
+ <Modal
61
+ title={ __( 'Choose a template' ) }
62
+ onRequestClose={ onClose }
63
+ overlayClassName="edit-site-template-panel__replace-template-modal"
64
+ isFullScreen
65
+ >
66
+ <div className="edit-site-template-panel__replace-template-modal__content">
67
+ <TemplatesList
68
+ availableTemplates={ availableTemplates }
69
+ onSelect={ onTemplateSelect }
70
+ />
71
+ </div>
72
+ </Modal>
73
+ ) }
74
+ </>
75
+ );
76
+ }
77
+
78
+ function TemplatesList( { availableTemplates, onSelect } ) {
79
+ const shownTemplates = useAsyncList( availableTemplates );
80
+
81
+ return (
82
+ <BlockPatternsList
83
+ label={ __( 'Templates' ) }
84
+ blockPatterns={ availableTemplates }
85
+ shownPatterns={ shownTemplates }
86
+ onClickPattern={ onSelect }
87
+ />
88
+ );
89
+ }
@@ -37,3 +37,21 @@ h3.edit-site-template-card__template-areas-title {
37
37
  font-weight: 500;
38
38
  margin: 0 0 $grid-unit-10;
39
39
  }
40
+
41
+
42
+ .edit-site-template-panel__replace-template-modal {
43
+ z-index: z-index(".edit-site-template-panel__replace-template-modal");
44
+ }
45
+
46
+ .edit-site-template-panel__replace-template-modal__content {
47
+ column-count: 2;
48
+ column-gap: $grid-unit-30;
49
+
50
+ @include break-medium() {
51
+ column-count: 3;
52
+ }
53
+
54
+ @include break-wide() {
55
+ column-count: 4;
56
+ }
57
+ }