@wordpress/editor 14.18.0 → 14.19.0

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 (141) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/build/components/document-outline/index.js +16 -16
  4. package/build/components/document-outline/index.js.map +1 -1
  5. package/build/components/entities-saved-states/entity-record-item.js +2 -1
  6. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  7. package/build/components/entities-saved-states/entity-type-list.js +2 -1
  8. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  9. package/build/components/entities-saved-states/index.js +66 -42
  10. package/build/components/entities-saved-states/index.js.map +1 -1
  11. package/build/components/post-actions/index.js +19 -28
  12. package/build/components/post-actions/index.js.map +1 -1
  13. package/build/components/post-card-panel/index.js +2 -2
  14. package/build/components/post-card-panel/index.js.map +1 -1
  15. package/build/components/post-featured-image/index.js +4 -2
  16. package/build/components/post-featured-image/index.js.map +1 -1
  17. package/build/components/post-template/block-theme.js +68 -48
  18. package/build/components/post-template/block-theme.js.map +1 -1
  19. package/build/components/post-template/classic-theme.js +30 -18
  20. package/build/components/post-template/classic-theme.js.map +1 -1
  21. package/build/components/post-template/create-new-template-modal.js +3 -1
  22. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  23. package/build/components/post-template/panel.js +3 -11
  24. package/build/components/post-template/panel.js.map +1 -1
  25. package/build/components/preferences-modal/block-visibility.js +2 -1
  26. package/build/components/preferences-modal/block-visibility.js.map +1 -1
  27. package/build/components/preferences-modal/index.js +1 -1
  28. package/build/components/preferences-modal/index.js.map +1 -1
  29. package/build/components/preview-dropdown/index.js +6 -3
  30. package/build/components/preview-dropdown/index.js.map +1 -1
  31. package/build/components/provider/index.js +19 -18
  32. package/build/components/provider/index.js.map +1 -1
  33. package/build/components/sidebar/header.js +1 -1
  34. package/build/components/sidebar/header.js.map +1 -1
  35. package/build/components/sidebar/index.js +1 -1
  36. package/build/components/sidebar/index.js.map +1 -1
  37. package/build/components/start-page-options/index.js +148 -23
  38. package/build/components/start-page-options/index.js.map +1 -1
  39. package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
  40. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  41. package/build/store/private-actions.js +29 -2
  42. package/build/store/private-actions.js.map +1 -1
  43. package/build/store/private-selectors.js +44 -0
  44. package/build/store/private-selectors.js.map +1 -1
  45. package/build/utils/media-upload/index.js +5 -2
  46. package/build/utils/media-upload/index.js.map +1 -1
  47. package/build-module/components/document-outline/index.js +17 -17
  48. package/build-module/components/document-outline/index.js.map +1 -1
  49. package/build-module/components/entities-saved-states/entity-record-item.js +2 -1
  50. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  51. package/build-module/components/entities-saved-states/entity-type-list.js +2 -1
  52. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  53. package/build-module/components/entities-saved-states/index.js +67 -43
  54. package/build-module/components/entities-saved-states/index.js.map +1 -1
  55. package/build-module/components/post-actions/index.js +19 -28
  56. package/build-module/components/post-actions/index.js.map +1 -1
  57. package/build-module/components/post-card-panel/index.js +2 -2
  58. package/build-module/components/post-card-panel/index.js.map +1 -1
  59. package/build-module/components/post-featured-image/index.js +4 -2
  60. package/build-module/components/post-featured-image/index.js.map +1 -1
  61. package/build-module/components/post-template/block-theme.js +68 -48
  62. package/build-module/components/post-template/block-theme.js.map +1 -1
  63. package/build-module/components/post-template/classic-theme.js +30 -18
  64. package/build-module/components/post-template/classic-theme.js.map +1 -1
  65. package/build-module/components/post-template/create-new-template-modal.js +3 -1
  66. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  67. package/build-module/components/post-template/panel.js +3 -11
  68. package/build-module/components/post-template/panel.js.map +1 -1
  69. package/build-module/components/preferences-modal/block-visibility.js +2 -1
  70. package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
  71. package/build-module/components/preferences-modal/index.js +1 -1
  72. package/build-module/components/preferences-modal/index.js.map +1 -1
  73. package/build-module/components/preview-dropdown/index.js +6 -3
  74. package/build-module/components/preview-dropdown/index.js.map +1 -1
  75. package/build-module/components/provider/index.js +19 -18
  76. package/build-module/components/provider/index.js.map +1 -1
  77. package/build-module/components/sidebar/header.js +1 -1
  78. package/build-module/components/sidebar/header.js.map +1 -1
  79. package/build-module/components/sidebar/index.js +1 -1
  80. package/build-module/components/sidebar/index.js.map +1 -1
  81. package/build-module/components/start-page-options/index.js +148 -24
  82. package/build-module/components/start-page-options/index.js.map +1 -1
  83. package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
  84. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  85. package/build-module/store/private-actions.js +25 -0
  86. package/build-module/store/private-actions.js.map +1 -1
  87. package/build-module/store/private-selectors.js +43 -0
  88. package/build-module/store/private-selectors.js.map +1 -1
  89. package/build-module/utils/media-upload/index.js +5 -2
  90. package/build-module/utils/media-upload/index.js.map +1 -1
  91. package/build-style/style-rtl.css +49 -8
  92. package/build-style/style.css +49 -8
  93. package/build-types/components/document-outline/index.d.ts.map +1 -1
  94. package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
  95. package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
  96. package/build-types/components/entities-saved-states/index.d.ts +6 -2
  97. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  98. package/build-types/components/post-actions/index.d.ts.map +1 -1
  99. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  100. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  101. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  102. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  103. package/build-types/components/post-template/panel.d.ts.map +1 -1
  104. package/build-types/components/preferences-modal/block-visibility.d.ts.map +1 -1
  105. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  106. package/build-types/components/provider/index.d.ts.map +1 -1
  107. package/build-types/components/start-page-options/index.d.ts +2 -1
  108. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  109. package/build-types/store/private-actions.d.ts +4 -0
  110. package/build-types/store/private-actions.d.ts.map +1 -1
  111. package/build-types/store/private-selectors.d.ts +13 -0
  112. package/build-types/store/private-selectors.d.ts.map +1 -1
  113. package/build-types/utils/media-upload/index.d.ts +3 -1
  114. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  115. package/package.json +37 -37
  116. package/src/components/document-outline/index.js +22 -16
  117. package/src/components/entities-saved-states/entity-record-item.js +1 -0
  118. package/src/components/entities-saved-states/entity-type-list.js +6 -2
  119. package/src/components/entities-saved-states/index.js +98 -58
  120. package/src/components/entities-saved-states/style.scss +40 -5
  121. package/src/components/post-actions/index.js +19 -37
  122. package/src/components/post-card-panel/index.js +7 -5
  123. package/src/components/post-featured-image/index.js +2 -0
  124. package/src/components/post-template/block-theme.js +76 -56
  125. package/src/components/post-template/classic-theme.js +31 -15
  126. package/src/components/post-template/create-new-template-modal.js +1 -0
  127. package/src/components/post-template/panel.js +2 -12
  128. package/src/components/post-text-editor/style.scss +0 -2
  129. package/src/components/preferences-modal/block-visibility.js +2 -1
  130. package/src/components/preferences-modal/index.js +1 -1
  131. package/src/components/preview-dropdown/index.js +8 -6
  132. package/src/components/provider/index.js +21 -30
  133. package/src/components/sidebar/header.js +1 -1
  134. package/src/components/sidebar/index.js +1 -1
  135. package/src/components/start-page-options/index.js +149 -23
  136. package/src/components/start-page-options/style.scss +27 -0
  137. package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
  138. package/src/store/private-actions.js +33 -0
  139. package/src/store/private-selectors.js +57 -0
  140. package/src/utils/media-upload/index.js +3 -0
  141. package/tsconfig.tsbuildinfo +1 -1
@@ -1,8 +1,13 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useEffect } from '@wordpress/element';
4
+ import { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';
5
+ import { __ } from '@wordpress/i18n';
6
+ import { useState, useMemo, useEffect } from '@wordpress/element';
7
+ import { store as blockEditorStore, __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
5
8
  import { useSelect, useDispatch } from '@wordpress/data';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { __unstableSerializeAndClean } from '@wordpress/blocks';
6
11
  import { store as preferencesStore } from '@wordpress/preferences';
7
12
  import { store as interfaceStore } from '@wordpress/interface';
8
13
 
@@ -10,44 +15,163 @@ import { store as interfaceStore } from '@wordpress/interface';
10
15
  * Internal dependencies
11
16
  */
12
17
  import { store as editorStore } from '../../store';
13
- export default function StartPageOptions() {
18
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
+ export function useStartPatterns() {
20
+ // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
21
+ // and it has no postTypes declared and the current post type is page or if
22
+ // the current post type is part of the postTypes declared.
14
23
  const {
15
- postId,
16
- enabled
24
+ blockPatternsWithPostContentBlockType,
25
+ postType
17
26
  } = useSelect(select => {
18
27
  const {
19
- getCurrentPostId,
20
- getCurrentPostType
28
+ getPatternsByBlockTypes,
29
+ getBlocksByName
30
+ } = select(blockEditorStore);
31
+ const {
32
+ getCurrentPostType,
33
+ getRenderingMode
21
34
  } = select(editorStore);
22
- const preferencesModalActive = select(interfaceStore).isModalActive('editor/preferences');
23
- const choosePatternModalEnabled = select(preferencesStore).get('core', 'enableChoosePatternModal');
35
+ const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
24
36
  return {
25
- postId: getCurrentPostId(),
26
- enabled: choosePatternModalEnabled && !preferencesModalActive && 'page' === getCurrentPostType()
37
+ blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
38
+ postType: getCurrentPostType()
39
+ };
40
+ }, []);
41
+ return useMemo(() => {
42
+ if (!blockPatternsWithPostContentBlockType?.length) {
43
+ return [];
44
+ }
45
+
46
+ /*
47
+ * Filter patterns without postTypes declared if the current postType is page
48
+ * or patterns that declare the current postType in its post type array.
49
+ */
50
+ return blockPatternsWithPostContentBlockType.filter(pattern => {
51
+ return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
52
+ });
53
+ }, [postType, blockPatternsWithPostContentBlockType]);
54
+ }
55
+ function PatternSelection({
56
+ blockPatterns,
57
+ onChoosePattern
58
+ }) {
59
+ const {
60
+ editEntityRecord
61
+ } = useDispatch(coreStore);
62
+ const {
63
+ postType,
64
+ postId
65
+ } = useSelect(select => {
66
+ const {
67
+ getCurrentPostType,
68
+ getCurrentPostId
69
+ } = select(editorStore);
70
+ return {
71
+ postType: getCurrentPostType(),
72
+ postId: getCurrentPostId()
27
73
  };
28
74
  }, []);
75
+ return /*#__PURE__*/_jsx(BlockPatternsList, {
76
+ blockPatterns: blockPatterns,
77
+ onClickPattern: (_pattern, blocks) => {
78
+ editEntityRecord('postType', postType, postId, {
79
+ blocks,
80
+ content: ({
81
+ blocks: blocksForSerialization = []
82
+ }) => __unstableSerializeAndClean(blocksForSerialization)
83
+ });
84
+ onChoosePattern();
85
+ }
86
+ });
87
+ }
88
+ function StartPageOptionsModal({
89
+ onClose
90
+ }) {
91
+ const [showStartPatterns, setShowStartPatterns] = useState(true);
92
+ const {
93
+ set: setPreference
94
+ } = useDispatch(preferencesStore);
95
+ const startPatterns = useStartPatterns();
96
+ const hasStartPattern = startPatterns.length > 0;
97
+ if (!hasStartPattern) {
98
+ return null;
99
+ }
100
+ function handleClose() {
101
+ onClose();
102
+ setPreference('core', 'enableChoosePatternModal', showStartPatterns);
103
+ }
104
+ return /*#__PURE__*/_jsxs(Modal, {
105
+ className: "editor-start-page-options__modal",
106
+ title: __('Choose a pattern'),
107
+ isFullScreen: true,
108
+ onRequestClose: handleClose,
109
+ children: [/*#__PURE__*/_jsx("div", {
110
+ className: "editor-start-page-options__modal-content",
111
+ children: /*#__PURE__*/_jsx(PatternSelection, {
112
+ blockPatterns: startPatterns,
113
+ onChoosePattern: handleClose
114
+ })
115
+ }), /*#__PURE__*/_jsx(Flex, {
116
+ className: "editor-start-page-options__modal__actions",
117
+ justify: "flex-end",
118
+ expanded: false,
119
+ children: /*#__PURE__*/_jsx(FlexItem, {
120
+ children: /*#__PURE__*/_jsx(ToggleControl, {
121
+ __nextHasNoMarginBottom: true,
122
+ checked: showStartPatterns,
123
+ label: __('Show starter patterns'),
124
+ help: __('Shows starter patterns when creating a new page.'),
125
+ onChange: newValue => {
126
+ setShowStartPatterns(newValue);
127
+ }
128
+ })
129
+ })
130
+ })]
131
+ });
132
+ }
133
+ export default function StartPageOptions() {
134
+ const [isOpen, setIsOpen] = useState(false);
29
135
  const {
30
136
  isEditedPostDirty,
31
137
  isEditedPostEmpty
32
138
  } = useSelect(editorStore);
33
139
  const {
34
- setIsInserterOpened
35
- } = useDispatch(editorStore);
140
+ isModalActive
141
+ } = useSelect(interfaceStore);
142
+ const {
143
+ enabled,
144
+ postId
145
+ } = useSelect(select => {
146
+ const {
147
+ getCurrentPostId,
148
+ getCurrentPostType
149
+ } = select(editorStore);
150
+ const choosePatternModalEnabled = select(preferencesStore).get('core', 'enableChoosePatternModal');
151
+ return {
152
+ postId: getCurrentPostId(),
153
+ enabled: choosePatternModalEnabled && 'page' === getCurrentPostType()
154
+ };
155
+ }, []);
156
+
157
+ // Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.
158
+ // Examples: changing pages in the List View, creating a new page via Command Palette.
36
159
  useEffect(() => {
37
- if (!enabled) {
38
- return;
39
- }
40
160
  const isFreshPage = !isEditedPostDirty() && isEditedPostEmpty();
41
- if (isFreshPage) {
42
- setIsInserterOpened({
43
- tab: 'patterns',
44
- category: 'core/starter-content'
45
- });
161
+ // Prevents immediately opening when features is enabled via preferences modal.
162
+ const isPreferencesModalActive = isModalActive('editor/preferences');
163
+ if (!enabled || !isFreshPage || isPreferencesModalActive) {
164
+ return;
46
165
  }
47
166
 
48
- // Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.
49
- // Examples: changing pages in the List View, creating a new page via Command Palette.
50
- }, [postId, enabled, setIsInserterOpened, isEditedPostDirty, isEditedPostEmpty]);
51
- return null;
167
+ // Open the modal after the initial render for a new page.
168
+ setIsOpen(true);
169
+ }, [enabled, postId, isEditedPostDirty, isEditedPostEmpty, isModalActive]);
170
+ if (!isOpen) {
171
+ return null;
172
+ }
173
+ return /*#__PURE__*/_jsx(StartPageOptionsModal, {
174
+ onClose: () => setIsOpen(false)
175
+ });
52
176
  }
53
177
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useSelect","useDispatch","store","preferencesStore","interfaceStore","editorStore","StartPageOptions","postId","enabled","select","getCurrentPostId","getCurrentPostType","preferencesModalActive","isModalActive","choosePatternModalEnabled","get","isEditedPostDirty","isEditedPostEmpty","setIsInserterOpened","isFreshPage","tab","category"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function StartPageOptions() {\n\tconst { postId, enabled } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst preferencesModalActive =\n\t\t\tselect( interfaceStore ).isModalActive( 'editor/preferences' );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled &&\n\t\t\t\t! preferencesModalActive &&\n\t\t\t\t'page' === getCurrentPostType(),\n\t\t};\n\t}, [] );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { setIsInserterOpened } = useDispatch( editorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! enabled ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\tif ( isFreshPage ) {\n\t\t\tsetIsInserterOpened( {\n\t\t\t\ttab: 'patterns',\n\t\t\t\tcategory: 'core/starter-content',\n\t\t\t} );\n\t\t}\n\n\t\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\t}, [\n\t\tpostId,\n\t\tenabled,\n\t\tsetIsInserterOpened,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t] );\n\n\treturn null;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASF,KAAK,IAAIG,WAAW,QAAQ,aAAa;AAElD,eAAe,SAASC,gBAAgBA,CAAA,EAAG;EAC1C,MAAM;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACpD,MAAM;MAAEC,gBAAgB;MAAEC;IAAmB,CAAC,GAAGF,MAAM,CAAEJ,WAAY,CAAC;IACtE,MAAMO,sBAAsB,GAC3BH,MAAM,CAAEL,cAAe,CAAC,CAACS,aAAa,CAAE,oBAAqB,CAAC;IAC/D,MAAMC,yBAAyB,GAAGL,MAAM,CAAEN,gBAAiB,CAAC,CAACY,GAAG,CAC/D,MAAM,EACN,0BACD,CAAC;IACD,OAAO;MACNR,MAAM,EAAEG,gBAAgB,CAAC,CAAC;MAC1BF,OAAO,EACNM,yBAAyB,IACzB,CAAEF,sBAAsB,IACxB,MAAM,KAAKD,kBAAkB,CAAC;IAChC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IAAEK,iBAAiB;IAAEC;EAAkB,CAAC,GAAGjB,SAAS,CAAEK,WAAY,CAAC;EACzE,MAAM;IAAEa;EAAoB,CAAC,GAAGjB,WAAW,CAAEI,WAAY,CAAC;EAE1DN,SAAS,CAAE,MAAM;IAChB,IAAK,CAAES,OAAO,EAAG;MAChB;IACD;IAEA,MAAMW,WAAW,GAAG,CAAEH,iBAAiB,CAAC,CAAC,IAAIC,iBAAiB,CAAC,CAAC;IAChE,IAAKE,WAAW,EAAG;MAClBD,mBAAmB,CAAE;QACpBE,GAAG,EAAE,UAAU;QACfC,QAAQ,EAAE;MACX,CAAE,CAAC;IACJ;;IAEA;IACA;EACD,CAAC,EAAE,CACFd,MAAM,EACNC,OAAO,EACPU,mBAAmB,EACnBF,iBAAiB,EACjBC,iBAAiB,CAChB,CAAC;EAEH,OAAO,IAAI;AACZ","ignoreList":[]}
1
+ {"version":3,"names":["Flex","FlexItem","Modal","ToggleControl","__","useState","useMemo","useEffect","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","coreStore","__unstableSerializeAndClean","preferencesStore","interfaceStore","editorStore","jsx","_jsx","jsxs","_jsxs","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getBlocksByName","getCurrentPostType","getRenderingMode","rootClientId","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","postId","getCurrentPostId","onClickPattern","_pattern","blocks","content","blocksForSerialization","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","set","setPreference","startPatterns","hasStartPattern","handleClose","className","title","isFullScreen","onRequestClose","children","justify","expanded","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","enabled","choosePatternModalEnabled","get","isFreshPage","isPreferencesModalActive"],"sources":["@wordpress/editor/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Flex, FlexItem, Modal, ToggleControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo, useEffect } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport function useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes, getBlocksByName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getCurrentPostType, getRenderingMode } =\n\t\t\t\tselect( editorStore );\n\t\t\tconst rootClientId =\n\t\t\t\tgetRenderingMode() === 'post-only'\n\t\t\t\t\t? ''\n\t\t\t\t\t: getBlocksByName( 'core/post-content' )?.[ 0 ];\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType: getPatternsByBlockTypes(\n\t\t\t\t\t'core/post-content',\n\t\t\t\t\trootClientId\n\t\t\t\t),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\tif ( ! blockPatternsWithPostContentBlockType?.length ) {\n\t\t\treturn [];\n\t\t}\n\n\t\t/*\n\t\t * Filter patterns without postTypes declared if the current postType is page\n\t\t * or patterns that declare the current postType in its post type array.\n\t\t */\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\tconst { postType, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId } = select( editorStore );\n\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t\tpostId: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\teditEntityRecord( 'postType', postType, postId, {\n\t\t\t\t\tblocks,\n\t\t\t\t\tcontent: ( { blocks: blocksForSerialization = [] } ) =>\n\t\t\t\t\t\t__unstableSerializeAndClean( blocksForSerialization ),\n\t\t\t\t} );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst [ showStartPatterns, setShowStartPatterns ] = useState( true );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\tfunction handleClose() {\n\t\tonClose();\n\t\tsetPreference( 'core', 'enableChoosePatternModal', showStartPatterns );\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ handleClose }\n\t\t>\n\t\t\t<div className=\"editor-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ handleClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<Flex\n\t\t\t\tclassName=\"editor-start-page-options__modal__actions\"\n\t\t\t\tjustify=\"flex-end\"\n\t\t\t\texpanded={ false }\n\t\t\t>\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tchecked={ showStartPatterns }\n\t\t\t\t\t\tlabel={ __( 'Show starter patterns' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows starter patterns when creating a new page.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ ( newValue ) => {\n\t\t\t\t\t\t\tsetShowStartPatterns( newValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</FlexItem>\n\t\t\t</Flex>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isOpen, setIsOpen ] = useState( false );\n\tconst { isEditedPostDirty, isEditedPostEmpty } = useSelect( editorStore );\n\tconst { isModalActive } = useSelect( interfaceStore );\n\tconst { enabled, postId } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostId, getCurrentPostType } = select( editorStore );\n\t\tconst choosePatternModalEnabled = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'enableChoosePatternModal'\n\t\t);\n\t\treturn {\n\t\t\tpostId: getCurrentPostId(),\n\t\t\tenabled:\n\t\t\t\tchoosePatternModalEnabled && 'page' === getCurrentPostType(),\n\t\t};\n\t}, [] );\n\n\t// Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.\n\t// Examples: changing pages in the List View, creating a new page via Command Palette.\n\tuseEffect( () => {\n\t\tconst isFreshPage = ! isEditedPostDirty() && isEditedPostEmpty();\n\t\t// Prevents immediately opening when features is enabled via preferences modal.\n\t\tconst isPreferencesModalActive = isModalActive( 'editor/preferences' );\n\t\tif ( ! enabled || ! isFreshPage || isPreferencesModalActive ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Open the modal after the initial render for a new page.\n\t\tsetIsOpen( true );\n\t}, [\n\t\tenabled,\n\t\tpostId,\n\t\tisEditedPostDirty,\n\t\tisEditedPostEmpty,\n\t\tisModalActive,\n\t] );\n\n\tif ( ! isOpen ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsOpen( false ) } />;\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,QAAQ,EAAEC,KAAK,EAAEC,aAAa,QAAQ,uBAAuB;AAC5E,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAQ,oBAAoB;AACjE,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASL,KAAK,IAAIM,SAAS,QAAQ,sBAAsB;AACzD,SAASC,2BAA2B,QAAQ,mBAAmB;AAC/D,SAASP,KAAK,IAAIQ,gBAAgB,QAAQ,wBAAwB;AAClE,SAASR,KAAK,IAAIS,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAAST,KAAK,IAAIU,WAAW,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAEnD,OAAO,SAASC,gBAAgBA,CAAA,EAAG;EAClC;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAGb,SAAS,CAClEc,MAAM,IAAM;IACb,MAAM;MAAEC,uBAAuB;MAAEC;IAAgB,CAAC,GACjDF,MAAM,CAAEjB,gBAAiB,CAAC;IAC3B,MAAM;MAAEoB,kBAAkB;MAAEC;IAAiB,CAAC,GAC7CJ,MAAM,CAAER,WAAY,CAAC;IACtB,MAAMa,YAAY,GACjBD,gBAAgB,CAAC,CAAC,KAAK,WAAW,GAC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wB,EAAG;MAC7D;IACD;;IAEA;IACAR,SAAS,CAAE,IAAK,CAAC;EAClB,CAAC,EAAE,CACFI,OAAO,EACPnC,MAAM,EACNgC,iBAAiB,EACjBC,iBAAiB,EACjBC,aAAa,CACZ,CAAC;EAEH,IAAK,CAAEJ,MAAM,EAAG;IACf,OAAO,IAAI;EACZ;EAEA,oBAAOrD,IAAA,CAAC8B,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMuB,SAAS,CAAE,KAAM;EAAG,CAAE,CAAC;AACtE","ignoreList":[]}
@@ -82,7 +82,7 @@ export default function EditTemplateBlocksNotification({
82
82
  },
83
83
  onCancel: () => setIsDialogOpen(false),
84
84
  size: "medium",
85
- children: __('You’ve tried to select a block that is part of a template, which may be used on other posts and pages. Would you like to edit the template?')
85
+ children: __('You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?')
86
86
  });
87
87
  }
88
88
  //# sourceMappingURL=edit-template-blocks-notification.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","store","coreStore","useEffect","useState","__","__experimentalConfirmDialog","ConfirmDialog","editorStore","jsx","_jsx","EditTemplateBlocksNotification","contentRef","onNavigateToEntityRecord","templateId","select","getEditorSettings","getCurrentTemplateId","canEditTemplate","canUser","kind","name","isDialogOpen","setIsDialogOpen","handleDblClick","event","target","classList","contains","dataset","type","defaultPrevented","preventDefault","canvas","current","addEventListener","removeEventListener","isOpen","confirmButtonText","onConfirm","postId","postType","onCancel","size","children"],"sources":["@wordpress/editor/src/components/visual-editor/edit-template-blocks-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page content and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst { onNavigateToEntityRecord, templateId } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\n\t\treturn {\n\t\t\tonNavigateToEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t};\n\t}, [] );\n\n\tconst canEditTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( ! canEditTemplate ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! event.target.classList.contains( 'is-root-container' ) ||\n\t\t\t\tevent.target.dataset?.type === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDialogOpen( true );\n\t\t\t}\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ contentRef, canEditTemplate ] );\n\n\tif ( ! canEditTemplate ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\tpostId: templateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ __(\n\t\t\t\t'You’ve tried to select a block that is part of a template, which may be used on other posts and pages. Would you like to edit the template?'\n\t\t\t) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,2BAA2B,IAAIC,aAAa,QAAQ,uBAAuB;;AAEpF;AACA;AACA;AACA,SAASN,KAAK,IAAIO,WAAW,QAAQ,aAAa;;AAElD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAbA,SAAAC,GAAA,IAAAC,IAAA;AAcA,eAAe,SAASC,8BAA8BA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACxE,MAAM;IAAEC,wBAAwB;IAAEC;EAAW,CAAC,GAAGd,SAAS,CAAIe,MAAM,IAAM;IACzE,MAAM;MAAEC,iBAAiB;MAAEC;IAAqB,CAAC,GAChDF,MAAM,CAAEP,WAAY,CAAC;IAEtB,OAAO;MACNK,wBAAwB,EACvBG,iBAAiB,CAAC,CAAC,CAACH,wBAAwB;MAC7CC,UAAU,EAAEG,oBAAoB,CAAC;IAClC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMC,eAAe,GAAGlB,SAAS,CAC9Be,MAAM,IACP,CAAC,CAAEA,MAAM,CAAEb,SAAU,CAAC,CAACiB,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C3CoB,IAAI,EAAC,QAAQ;IAAAC,QAAA,EAEXvC,EAAE,CACH,6IACD;EAAC,CACa,CAAC;AAElB","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","store","coreStore","useEffect","useState","__","__experimentalConfirmDialog","ConfirmDialog","editorStore","jsx","_jsx","EditTemplateBlocksNotification","contentRef","onNavigateToEntityRecord","templateId","select","getEditorSettings","getCurrentTemplateId","canEditTemplate","canUser","kind","name","isDialogOpen","setIsDialogOpen","handleDblClick","event","target","classList","contains","dataset","type","defaultPrevented","preventDefault","canvas","current","addEventListener","removeEventListener","isOpen","confirmButtonText","onConfirm","postId","postType","onCancel","size","children"],"sources":["@wordpress/editor/src/components/visual-editor/edit-template-blocks-notification.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { __experimentalConfirmDialog as ConfirmDialog } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Component that:\n *\n * - Displays a 'Edit your template to edit this block' notification when the\n * user is focusing on editing page content and clicks on a disabled template\n * block.\n * - Displays a 'Edit your template to edit this block' dialog when the user\n * is focusing on editing page content and double clicks on a disabled\n * template block.\n *\n * @param {Object} props\n * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block\n * editor iframe canvas.\n */\nexport default function EditTemplateBlocksNotification( { contentRef } ) {\n\tconst { onNavigateToEntityRecord, templateId } = useSelect( ( select ) => {\n\t\tconst { getEditorSettings, getCurrentTemplateId } =\n\t\t\tselect( editorStore );\n\n\t\treturn {\n\t\t\tonNavigateToEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToEntityRecord,\n\t\t\ttemplateId: getCurrentTemplateId(),\n\t\t};\n\t}, [] );\n\n\tconst canEditTemplate = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( coreStore ).canUser( 'create', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: 'wp_template',\n\t\t\t} ),\n\t\t[]\n\t);\n\n\tconst [ isDialogOpen, setIsDialogOpen ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst handleDblClick = ( event ) => {\n\t\t\tif ( ! canEditTemplate ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t! event.target.classList.contains( 'is-root-container' ) ||\n\t\t\t\tevent.target.dataset?.type === 'core/template-part'\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDialogOpen( true );\n\t\t\t}\n\t\t};\n\n\t\tconst canvas = contentRef.current;\n\t\tcanvas?.addEventListener( 'dblclick', handleDblClick );\n\t\treturn () => {\n\t\t\tcanvas?.removeEventListener( 'dblclick', handleDblClick );\n\t\t};\n\t}, [ contentRef, canEditTemplate ] );\n\n\tif ( ! canEditTemplate ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ConfirmDialog\n\t\t\tisOpen={ isDialogOpen }\n\t\t\tconfirmButtonText={ __( 'Edit template' ) }\n\t\t\tonConfirm={ () => {\n\t\t\t\tsetIsDialogOpen( false );\n\t\t\t\tonNavigateToEntityRecord( {\n\t\t\t\t\tpostId: templateId,\n\t\t\t\t\tpostType: 'wp_template',\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonCancel={ () => setIsDialogOpen( false ) }\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t{ __(\n\t\t\t\t'You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?'\n\t\t\t) }\n\t\t</ConfirmDialog>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,EAAEC,QAAQ,QAAQ,oBAAoB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Ac,CAAC,CAAC;QACtBT,eAAe,CAAE,IAAK,CAAC;MACxB;IACD,CAAC;IAED,MAAMU,MAAM,GAAGrB,UAAU,CAACsB,OAAO;IACjCD,MAAM,EAAEE,gBAAgB,CAAE,UAAU,EAAEX,cAAe,CAAC;IACtD,OAAO,MAAM;MACZS,MAAM,EAAEG,mBAAmB,CAAE,UAAU,EAAEZ,cAAe,CAAC;IAC1D,CAAC;EACF,CAAC,EAAE,CAAEZ,UAAU,EAAEM,eAAe,CAAG,CAAC;EAEpC,IAAK,CAAEA,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,oBACCR,IAAA,CAACH,aAAa;IACb8B,MAAM,EAAGf,YAAc;IACvBgB,iBAAiB,EAAGjC,EAAE,CAAE,eAAgB,CAAG;IAC3CkC,SAAS,EAAGA,CAAA,KAAM;MACjBhB,eAAe,CAAE,KAAM,CAAC;MACxBV,wBAAwB,CAAE;QACzB2B,MAAM,EAAE1B,UAAU;QAClB2B,QAAQ,EAAE;MACX,CAAE,CAAC;IACJ,CAAG;IACHC,QAAQ,EAAGA,CAAA,KAAMnB,eAAe,CAAE,KAAM,CAAG;IAC3CoB,IAAI,EAAC,QAAQ;IAAAC,QAAA,EAEXvC,EAAE,CACH,yIACD;EAAC,CACa,CAAC;AAElB","ignoreList":[]}
@@ -327,4 +327,29 @@ export const removeTemplates = items => async ({
327
327
  });
328
328
  }
329
329
  };
330
+
331
+ /**
332
+ * Set the default rendering mode preference for the current post type.
333
+ *
334
+ * @param {string} mode The rendering mode to set as default.
335
+ */
336
+ export const setDefaultRenderingMode = mode => ({
337
+ select,
338
+ registry
339
+ }) => {
340
+ var _registry$select$get$;
341
+ const postType = select.getCurrentPostType();
342
+ const theme = registry.select(coreStore).getCurrentTheme()?.stylesheet;
343
+ const renderingModes = (_registry$select$get$ = registry.select(preferencesStore).get('core', 'renderingModes')?.[theme]) !== null && _registry$select$get$ !== void 0 ? _registry$select$get$ : {};
344
+ if (renderingModes[postType] === mode) {
345
+ return;
346
+ }
347
+ const newModes = {
348
+ [theme]: {
349
+ ...renderingModes,
350
+ [postType]: mode
351
+ }
352
+ };
353
+ registry.dispatch(preferencesStore).set('core', 'renderingModes', newModes);
354
+ };
330
355
  //# sourceMappingURL=private-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreStore","__","_x","sprintf","noticesStore","blockEditorStore","preferencesStore","addQueryArgs","apiFetch","parse","__unstableSerializeAndClean","decodeEntities","isTemplateRevertable","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","createSuccessNotice","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","get","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getEntityRecord","home","removeNotice","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","context","source","origin","fileTemplate","path","serializeBlocks","blocks","blocksForSerialization","edited","getEditedEntityRecord","content","undoIgnore","raw","undoRevert","errorMessage","message","code","removeTemplates","items","isResetting","every","item","has_theme_file","promiseResult","allSettled","map","deleteEntityRecord","force","throwOnError","successMessage","title","rendered","reason","errorMessages","failedPromises","failedPromise","add","size","join"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\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\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE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YAAY,GAAG3G,EAAE,CAChB,6CACD,CAAC;MACF,CAAC,MAAM,IAAK8H,aAAa,CAACI,IAAI,KAAK,CAAC,EAAG;QACtCvB,YAAY,GAAGK,WAAW,GACvB9G,OAAO,CACP;QACAF,EAAE,CACD,iDACD,CAAC,EACD,CAAE,GAAG8H,aAAa,CAAE,CAAE,CAAC,CACvB,CAAC,GACD5H,OAAO,CACP;QACAF,EAAE,CACD,gDACD,CAAC,EACD,CAAE,GAAG8H,aAAa,CAAE,CAAE,CAAC,CACvB,CAAC;MACL,CAAC,MAAM;QACNnB,YAAY,GAAGK,WAAW,GACvB9G,OAAO,CACP;QACAF,EAAE,CACD,oDACD,CAAC,EACD,CAAE,GAAG8H,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC,GACDjI,OAAO,CACP;QACAF,EAAE,CACD,mDACD,CAAC,EACD,CAAE,GAAG8H,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC;MACL;IACD;IACAhH,QAAQ,CACND,QAAQ,CAAEf,YAAa,CAAC,CACxB+E,iBAAiB,CAAEyB,YAAY,EAAE;MAAE7F,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","coreStore","__","_x","sprintf","noticesStore","blockEditorStore","preferencesStore","addQueryArgs","apiFetch","parse","__unstableSerializeAndClean","decodeEntities","isTemplateRevertable","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","createSuccessNotice","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","get","newBlockNames","filter","Array","isArray","includes","set","hideBlockTypes","_registry$select$get2","mergedBlockNames","Set","saveDirtyEntities","onSave","dirtyEntityRecords","entitiesToSkip","close","PUBLISH_ON_SAVE_ENTITIES","kind","name","saveNoticeId","homeUrl","getEntityRecord","home","removeNotice","entitiesToSave","key","property","some","elt","siteItemsToSave","pendingSavedRecords","forEach","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","templateEntityConfig","getEntityConfig","fileTemplatePath","baseURL","context","source","origin","fileTemplate","path","serializeBlocks","blocks","blocksForSerialization","edited","getEditedEntityRecord","content","undoIgnore","raw","undoRevert","errorMessage","message","code","removeTemplates","items","isResetting","every","item","has_theme_file","promiseResult","allSettled","map","deleteEntityRecord","force","throwOnError","successMessage","title","rendered","reason","errorMessages","failedPromises","failedPromise","add","size","join","setDefaultRenderingMode","mode","_registry$select$get$","postType","theme","getCurrentTheme","stylesheet","renderingModes","newModes"],"sources":["@wordpress/editor/src/store/private-actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreStore } from '@wordpress/core-data';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\nimport { parse, __unstableSerializeAndClean } from '@wordpress/blocks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport isTemplateRevertable from './utils/is-template-revertable';\nexport * from '../dataviews/store/private-actions';\n\n/**\n * Returns an action object used to set which template is currently being used/edited.\n *\n * @param {string} id Template Id.\n *\n * @return {Object} Action object.\n */\nexport function setCurrentTemplateId( id ) {\n\treturn {\n\t\ttype: 'SET_CURRENT_TEMPLATE_ID',\n\t\tid,\n\t};\n}\n\n/**\n * Create a block based template.\n *\n * @param {?Object} template Template to create and assign.\n */\nexport const createTemplate =\n\t( template ) =>\n\tasync ( { select, dispatch, registry } ) => {\n\t\tconst savedTemplate = await registry\n\t\t\t.dispatch( coreStore )\n\t\t\t.saveEntityRecord( 'postType', 'wp_template', template );\n\t\tregistry\n\t\t\t.dispatch( coreStore )\n\t\t\t.editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tselect.getCurrentPostType(),\n\t\t\t\tselect.getCurrentPostId(),\n\t\t\t\t{\n\t\t\t\t\ttemplate: savedTemplate.slug,\n\t\t\t\t}\n\t\t\t);\n\t\tregistry\n\t\t\t.dispatch( noticesStore )\n\t\t\t.createSuccessNotice(\n\t\t\t\t__( \"Custom template created. You're in template mode now.\" ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Go back' ),\n\t\t\t\t\t\t\tonClick: () =>\n\t\t\t\t\t\t\t\tdispatch.setRenderingMode(\n\t\t\t\t\t\t\t\t\tselect.getEditorSettings()\n\t\t\t\t\t\t\t\t\t\t.defaultRenderingMode\n\t\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\treturn savedTemplate;\n\t};\n\n/**\n * Update the provided block types to be visible.\n *\n * @param {string[]} blockNames Names of block types to show.\n */\nexport const showBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst newBlockNames = existingBlockNames.filter(\n\t\t\t( type ) =>\n\t\t\t\t! (\n\t\t\t\t\tArray.isArray( blockNames ) ? blockNames : [ blockNames ]\n\t\t\t\t).includes( type )\n\t\t);\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', newBlockNames );\n\t};\n\n/**\n * Update the provided block types to be hidden.\n *\n * @param {string[]} blockNames Names of block types to hide.\n */\nexport const hideBlockTypes =\n\t( blockNames ) =>\n\t( { registry } ) => {\n\t\tconst existingBlockNames =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'hiddenBlockTypes' ) ?? [];\n\n\t\tconst mergedBlockNames = new Set( [\n\t\t\t...existingBlockNames,\n\t\t\t...( Array.isArray( blockNames ) ? blockNames : [ blockNames ] ),\n\t\t] );\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'hiddenBlockTypes', [ ...mergedBlockNames ] );\n\t};\n\n/**\n * Save entity records marked as dirty.\n *\n * @param {Object} options Options for the action.\n * @param {Function} [options.onSave] Callback when saving happens.\n * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.\n * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.\n * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.\n */\nexport const saveDirtyEntities =\n\t( { onSave, dirtyEntityRecords = [], entitiesToSkip = [], close } = {} ) =>\n\t( { registry } ) => {\n\t\tconst PUBLISH_ON_SAVE_ENTITIES = [\n\t\t\t{ kind: 'postType', name: 'wp_navigation' },\n\t\t];\n\t\tconst saveNoticeId = 'site-editor-save-success';\n\t\tconst homeUrl = registry\n\t\t\t.select( coreStore )\n\t\t\t.getEntityRecord( 'root', '__unstableBase' )?.home;\n\t\tregistry.dispatch( noticesStore ).removeNotice( saveNoticeId );\n\t\tconst entitiesToSave = dirtyEntityRecords.filter(\n\t\t\t( { kind, name, key, property } ) => {\n\t\t\t\treturn ! entitiesToSkip.some(\n\t\t\t\t\t( elt ) =>\n\t\t\t\t\t\telt.kind === kind &&\n\t\t\t\t\t\telt.name === name &&\n\t\t\t\t\t\telt.key === key &&\n\t\t\t\t\t\telt.property === property\n\t\t\t\t);\n\t\t\t}\n\t\t);\n\t\tclose?.( entitiesToSave );\n\t\tconst siteItemsToSave = [];\n\t\tconst pendingSavedRecords = [];\n\t\tentitiesToSave.forEach( ( { kind, name, key, property } ) => {\n\t\t\tif ( 'root' === kind && 'site' === name ) {\n\t\t\t\tsiteItemsToSave.push( property );\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tPUBLISH_ON_SAVE_ENTITIES.some(\n\t\t\t\t\t\t( typeToPublish ) =>\n\t\t\t\t\t\t\ttypeToPublish.kind === kind &&\n\t\t\t\t\t\t\ttypeToPublish.name === name\n\t\t\t\t\t)\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord( kind, name, key, {\n\t\t\t\t\t\t\tstatus: 'publish',\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\n\t\t\t\tpendingSavedRecords.push(\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.saveEditedEntityRecord( kind, name, key )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\t\tif ( siteItemsToSave.length ) {\n\t\t\tpendingSavedRecords.push(\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.__experimentalSaveSpecifiedEntityEdits(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'site',\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tsiteItemsToSave\n\t\t\t\t\t)\n\t\t\t);\n\t\t}\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.__unstableMarkLastChangeAsPersistent();\n\t\tPromise.all( pendingSavedRecords )\n\t\t\t.then( ( values ) => {\n\t\t\t\treturn onSave ? onSave( values ) : values;\n\t\t\t} )\n\t\t\t.then( ( values ) => {\n\t\t\t\tif (\n\t\t\t\t\tvalues.some( ( value ) => typeof value === 'undefined' )\n\t\t\t\t) {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createErrorNotice( __( 'Saving failed.' ) );\n\t\t\t\t} else {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t\t.createSuccessNotice( __( 'Site updated.' ), {\n\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\tid: saveNoticeId,\n\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tlabel: __( 'View site' ),\n\t\t\t\t\t\t\t\t\turl: homeUrl,\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( ( error ) =>\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t`${ __( 'Saving failed.' ) } ${ error }`\n\t\t\t\t\t)\n\t\t\t);\n\t};\n\n/**\n * Reverts a template to its original theme-provided file.\n *\n * @param {Object} template The template to revert.\n * @param {Object} [options]\n * @param {boolean} [options.allowUndo] Whether to allow the user to undo\n * reverting the template. Default true.\n */\nexport const revertTemplate =\n\t( template, { allowUndo = true } = {} ) =>\n\tasync ( { registry } ) => {\n\t\tconst noticeId = 'edit-site-template-reverted';\n\t\tregistry.dispatch( noticesStore ).removeNotice( noticeId );\n\t\tif ( ! isTemplateRevertable( template ) ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( __( 'This template is not revertable.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst templateEntityConfig = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEntityConfig( 'postType', template.type );\n\n\t\t\tif ( ! templateEntityConfig ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst fileTemplatePath = addQueryArgs(\n\t\t\t\t`${ templateEntityConfig.baseURL }/${ template.id }`,\n\t\t\t\t{ context: 'edit', source: template.origin }\n\t\t\t);\n\n\t\t\tconst fileTemplate = await apiFetch( { path: fileTemplatePath } );\n\t\t\tif ( ! fileTemplate ) {\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'The editor has encountered an unexpected error. Please reload.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst serializeBlocks = ( {\n\t\t\t\tblocks: blocksForSerialization = [],\n\t\t\t} ) => __unstableSerializeAndClean( blocksForSerialization );\n\n\t\t\tconst edited = registry\n\t\t\t\t.select( coreStore )\n\t\t\t\t.getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\ttemplate.type,\n\t\t\t\t\ttemplate.id\n\t\t\t\t);\n\n\t\t\t// We are fixing up the undo level here to make sure we can undo\n\t\t\t// the revert in the header toolbar correctly.\n\t\t\tregistry.dispatch( coreStore ).editEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\ttemplate.type,\n\t\t\t\ttemplate.id,\n\t\t\t\t{\n\t\t\t\t\tcontent: serializeBlocks, // Required to make the `undo` behave correctly.\n\t\t\t\t\tblocks: edited.blocks, // Required to revert the blocks in the editor.\n\t\t\t\t\tsource: 'custom', // required to avoid turning the editor into a dirty state\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tundoIgnore: true, // Required to merge this edit with the last undo level.\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tconst blocks = parse( fileTemplate?.content?.raw );\n\t\t\tregistry\n\t\t\t\t.dispatch( coreStore )\n\t\t\t\t.editEntityRecord( 'postType', template.type, fileTemplate.id, {\n\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\tblocks,\n\t\t\t\t\tsource: 'theme',\n\t\t\t\t} );\n\n\t\t\tif ( allowUndo ) {\n\t\t\t\tconst undoRevert = () => {\n\t\t\t\t\tregistry\n\t\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t\t.editEntityRecord(\n\t\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t\ttemplate.type,\n\t\t\t\t\t\t\tedited.id,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tcontent: serializeBlocks,\n\t\t\t\t\t\t\t\tblocks: edited.blocks,\n\t\t\t\t\t\t\t\tsource: 'custom',\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\tregistry\n\t\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t\t.createSuccessNotice( __( 'Template reset.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tid: noticeId,\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: undoRevert,\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}\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'Template revert failed. Please reload.' );\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Action that removes an array of templates, template parts or patterns.\n *\n * @param {Array} items An array of template,template part or pattern objects to remove.\n */\nexport const removeTemplates =\n\t( items ) =>\n\tasync ( { registry } ) => {\n\t\tconst isResetting = items.every( ( item ) => item?.has_theme_file );\n\n\t\tconst promiseResult = await Promise.allSettled(\n\t\t\titems.map( ( item ) => {\n\t\t\t\treturn registry\n\t\t\t\t\t.dispatch( coreStore )\n\t\t\t\t\t.deleteEntityRecord(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\titem.type,\n\t\t\t\t\t\titem.id,\n\t\t\t\t\t\t{ force: true },\n\t\t\t\t\t\t{ throwOnError: true }\n\t\t\t\t\t);\n\t\t\t} )\n\t\t);\n\n\t\t// If all the promises were fulfilled with success.\n\t\tif ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {\n\t\t\tlet successMessage;\n\n\t\t\tif ( items.length === 1 ) {\n\t\t\t\t// Depending on how the entity was retrieved its title might be\n\t\t\t\t// an object or simple string.\n\t\t\t\tlet title;\n\t\t\t\tif ( typeof items[ 0 ].title === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.rendered === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.rendered;\n\t\t\t\t} else if ( typeof items[ 0 ].title?.raw === 'string' ) {\n\t\t\t\t\ttitle = items[ 0 ].title?.raw;\n\t\t\t\t}\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: The template/part's name. */\n\t\t\t\t\t\t\t__( '\"%s\" reset.' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: The template/part's name. */\n\t\t\t\t\t\t\t_x( '\"%s\" deleted.', 'template part' ),\n\t\t\t\t\t\t\tdecodeEntities( title )\n\t\t\t\t\t );\n\t\t\t} else {\n\t\t\t\tsuccessMessage = isResetting\n\t\t\t\t\t? __( 'Items reset.' )\n\t\t\t\t\t: __( 'Items deleted.' );\n\t\t\t}\n\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createSuccessNotice( successMessage, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tid: 'editor-template-deleted-success',\n\t\t\t\t} );\n\t\t} else {\n\t\t\t// If there was at lease one failure.\n\t\t\tlet errorMessage;\n\t\t\t// If we were trying to delete a single template.\n\t\t\tif ( promiseResult.length === 1 ) {\n\t\t\t\tif ( promiseResult[ 0 ].reason?.message ) {\n\t\t\t\t\terrorMessage = promiseResult[ 0 ].reason.message;\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? __( 'An error occurred while reverting the item.' )\n\t\t\t\t\t\t: __( 'An error occurred while deleting the item.' );\n\t\t\t\t}\n\t\t\t\t// If we were trying to delete a multiple templates\n\t\t\t} else {\n\t\t\t\tconst errorMessages = new Set();\n\t\t\t\tconst failedPromises = promiseResult.filter(\n\t\t\t\t\t( { status } ) => status === 'rejected'\n\t\t\t\t);\n\t\t\t\tfor ( const failedPromise of failedPromises ) {\n\t\t\t\t\tif ( failedPromise.reason?.message ) {\n\t\t\t\t\t\terrorMessages.add( failedPromise.reason.message );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif ( errorMessages.size === 0 ) {\n\t\t\t\t\terrorMessage = __(\n\t\t\t\t\t\t'An error occurred while deleting the items.'\n\t\t\t\t\t);\n\t\t\t\t} else if ( errorMessages.size === 1 ) {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: an error message */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'An error occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ][ 0 ]\n\t\t\t\t\t\t );\n\t\t\t\t} else {\n\t\t\t\t\terrorMessage = isResetting\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while reverting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: a list of comma separated error messages */\n\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t'Some errors occurred while deleting the items: %s'\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t[ ...errorMessages ].join( ',' )\n\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t}\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n/**\n * Set the default rendering mode preference for the current post type.\n *\n * @param {string} mode The rendering mode to set as default.\n */\nexport const setDefaultRenderingMode =\n\t( mode ) =>\n\t( { select, registry } ) => {\n\t\tconst postType = select.getCurrentPostType();\n\t\tconst theme = registry\n\t\t\t.select( coreStore )\n\t\t\t.getCurrentTheme()?.stylesheet;\n\t\tconst renderingModes =\n\t\t\tregistry\n\t\t\t\t.select( preferencesStore )\n\t\t\t\t.get( 'core', 'renderingModes' )?.[ theme ] ?? {};\n\n\t\tif ( renderingModes[ postType ] === mode ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst newModes = {\n\t\t\t[ theme ]: {\n\t\t\t\t...renderingModes,\n\t\t\t\t[ postType ]: mode,\n\t\t\t},\n\t\t};\n\n\t\tregistry\n\t\t\t.dispatch( preferencesStore )\n\t\t\t.set( 'core', 'renderingModes', newModes );\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ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AAC;EAEnD,IAAKK,cAAc,CAAEJ,QAAQ,CAAE,KAAKF,IAAI,EAAG;IAC1C;EACD;EAEA,MAAMO,QAAQ,GAAG;IAChB,CAAEJ,KAAK,GAAI;MACV,GAAGG,cAAc;MACjB,CAAEJ,QAAQ,GAAIF;IACf;EACD,CAAC;EAEDlH,QAAQ,CACND,QAAQ,CAAEb,gBAAiB,CAAC,CAC5BsC,GAAG,CAAE,MAAM,EAAE,gBAAgB,EAAEiG,QAAS,CAAC;AAC5C,CAAC","ignoreList":[]}
@@ -10,6 +10,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
10
10
  import { createSelector, createRegistrySelector } from '@wordpress/data';
11
11
  import { layout, symbol, navigation, page as pageIcon, verse } from '@wordpress/icons';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
+ import { store as preferencesStore } from '@wordpress/preferences';
13
14
 
14
15
  /**
15
16
  * Internal dependencies
@@ -23,6 +24,11 @@ const EMPTY_INSERTION_POINT = {
23
24
  filterValue: undefined
24
25
  };
25
26
 
27
+ /**
28
+ * These are rendering modes that the editor supports.
29
+ */
30
+ const RENDERING_MODES = ['post-only', 'template-locked'];
31
+
26
32
  /**
27
33
  * Get the inserter.
28
34
  *
@@ -152,4 +158,41 @@ export const getPostBlocksByName = createRegistrySelector(select => createSelect
152
158
  );
153
159
  }));
154
160
  }, () => [select(blockEditorStore).getBlocks()]));
161
+
162
+ /**
163
+ * Returns the default rendering mode for a post type by user preference or post type configuration.
164
+ *
165
+ * @param {Object} state Global application state.
166
+ * @param {string} postType The post type.
167
+ *
168
+ * @return {string} The default rendering mode. Returns `undefined` while resolving value.
169
+ */
170
+ export const getDefaultRenderingMode = createRegistrySelector(select => (state, postType) => {
171
+ const {
172
+ getPostType,
173
+ getCurrentTheme,
174
+ hasFinishedResolution
175
+ } = select(coreStore);
176
+
177
+ // This needs to be called before `hasFinishedResolution`.
178
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
179
+ const currentTheme = getCurrentTheme();
180
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
181
+ const postTypeEntity = getPostType(postType);
182
+
183
+ // Wait for the post type and theme resolution.
184
+ if (!hasFinishedResolution('getPostType', [postType]) || !hasFinishedResolution('getCurrentTheme')) {
185
+ return undefined;
186
+ }
187
+ const theme = currentTheme?.stylesheet;
188
+ const defaultModePreference = select(preferencesStore).get('core', 'renderingModes')?.[theme]?.[postType];
189
+ const postTypeDefaultMode = Array.isArray(postTypeEntity?.supports?.editor) ? postTypeEntity.supports.editor.find(features => 'default-mode' in features)?.['default-mode'] : undefined;
190
+ const defaultMode = defaultModePreference || postTypeDefaultMode;
191
+
192
+ // Fallback gracefully to 'post-only' when rendering mode is not supported.
193
+ if (!RENDERING_MODES.includes(defaultMode)) {
194
+ return 'post-only';
195
+ }
196
+ return defaultMode;
197
+ });
155
198
  //# sourceMappingURL=private-selectors.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["fastDeepEqual","store","blockEditorStore","createSelector","createRegistrySelector","layout","symbol","navigation","page","pageIcon","verse","coreStore","getRenderingMode","getCurrentPost","getEntityActions","_getEntityActions","getEntityFields","_getEntityFields","isEntityReady","_isEntityReady","getTemplatePartIcon","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","getInserter","select","state","blockInserterPanel","postContentClientId","getBlocksByName","getListViewToggleRef","listViewToggleRef","getInserterSidebarToggleRef","inserterSidebarToggleRef","CARD_ICONS","wp_block","wp_navigation","post","getPostIcon","postType","options","templateAreas","getEntityRecord","default_template_part_areas","areaData","find","item","area","icon","postTypeEntity","getPostType","startsWith","slice","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","footnotes","args","dataviews","getPostBlocksByName","blockNames","Array","isArray","getBlockParents","getBlockName","filter","clientId","every","parentClientId","parentBlockName","includes","getBlocks"],"sources":["@wordpress/editor/src/store/private-selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * Get 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 getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t\t'core/post-content'\n\t\t\t\t\t);\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t)?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t() => [ select( blockEditorStore ).getBlocks() ]\n\t)\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,iBAAiB;AACxE,SACCC,MAAM,EACNC,MAAM,EACNC,UAAU,EACVC,IAAI,IAAIC,QAAQ,EAChBC,KAAK,QACC,kBAAkB;AACzB,SAAST,KAAK,IAAIU,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,gBAAgB,EAAEC,cAAc,QAAQ,aAAa;AAC9D,SACCC,gBAAgB,IAAIC,iBAAiB,EACrCC,eAAe,IAAIC,gBAAgB,EACnCC,aAAa,IAAIC,cAAc,QACzB,sCAAsC;AAC7C,SAASC,mBAAmB,QAAQ,UAAU;AAE9C,MAAMC,qBAAqB,GAAG;EAC7BC,YAAY,EAAEC,SAAS;EACvBC,cAAc,EAAED,SAAS;EACzBE,WAAW,EAAEF;AACd,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,WAAW,GAAGtB,sBAAsB,CAAIuB,MAAM,IAC1DxB,cAAc,CACXyB,KAAK,IAAM;EACZ,IAAK,OAAOA,KAAK,CAACC,kBAAkB,KAAK,QAAQ,EAAG;IACnD,OAAOD,KAAK,CAACC,kBAAkB;EAChC;EAEA,IAAKjB,gBAAgB,CAAEgB,KAAM,CAAC,KAAK,iBAAiB,EAAG;IACtD,MAAM,CAAEE,mBAAmB,CAAE,GAC5BH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CAAEzB,gBAAiB,CAAC,CAAC8E,SAAS,CAAC,CAAC,CAC/C,CACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["fastDeepEqual","store","blockEditorStore","createSelector","createRegistrySelector","layout","symbol","navigation","page","pageIcon","verse","coreStore","preferencesStore","getRenderingMode","getCurrentPost","getEntityActions","_getEntityActions","getEntityFields","_getEntityFields","isEntityReady","_isEntityReady","getTemplatePartIcon","EMPTY_INSERTION_POINT","rootClientId","undefined","insertionIndex","filterValue","RENDERING_MODES","getInserter","select","state","blockInserterPanel","postContentClientId","getBlocksByName","getListViewToggleRef","listViewToggleRef","getInserterSidebarToggleRef","inserterSidebarToggleRef","CARD_ICONS","wp_block","wp_navigation","post","getPostIcon","postType","options","templateAreas","getEntityRecord","default_template_part_areas","areaData","find","item","area","icon","postTypeEntity","getPostType","startsWith","slice","hasPostMetaChanges","postId","type","currentPostType","id","currentPostId","edits","getEntityRecordNonTransientEdits","meta","originalPostMeta","footnotes","args","dataviews","getPostBlocksByName","blockNames","Array","isArray","getBlockParents","getBlockName","filter","clientId","every","parentClientId","parentBlockName","includes","getBlocks","getDefaultRenderingMode","getCurrentTheme","hasFinishedResolution","currentTheme","theme","stylesheet","defaultModePreference","get","postTypeDefaultMode","supports","editor","features","defaultMode"],"sources":["@wordpress/editor/src/store/private-selectors.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport {\n\tlayout,\n\tsymbol,\n\tnavigation,\n\tpage as pageIcon,\n\tverse,\n} from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { getRenderingMode, getCurrentPost } from './selectors';\nimport {\n\tgetEntityActions as _getEntityActions,\n\tgetEntityFields as _getEntityFields,\n\tisEntityReady as _isEntityReady,\n} from '../dataviews/store/private-selectors';\nimport { getTemplatePartIcon } from '../utils';\n\nconst EMPTY_INSERTION_POINT = {\n\trootClientId: undefined,\n\tinsertionIndex: undefined,\n\tfilterValue: undefined,\n};\n\n/**\n * These are rendering modes that the editor supports.\n */\nconst RENDERING_MODES = [ 'post-only', 'template-locked' ];\n\n/**\n * Get 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 getInserter = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\t\treturn state.blockInserterPanel;\n\t\t\t}\n\n\t\t\tif ( getRenderingMode( state ) === 'template-locked' ) {\n\t\t\t\tconst [ postContentClientId ] =\n\t\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t\t'core/post-content'\n\t\t\t\t\t);\n\t\t\t\tif ( postContentClientId ) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn EMPTY_INSERTION_POINT;\n\t\t},\n\t\t( state ) => {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).getBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tstate.blockInserterPanel,\n\t\t\t\tgetRenderingMode( state ),\n\t\t\t\tpostContentClientId,\n\t\t\t];\n\t\t}\n\t)\n);\n\nexport function getListViewToggleRef( state ) {\n\treturn state.listViewToggleRef;\n}\nexport function getInserterSidebarToggleRef( state ) {\n\treturn state.inserterSidebarToggleRef;\n}\nconst CARD_ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigation,\n\tpage: pageIcon,\n\tpost: verse,\n};\n\nexport const getPostIcon = createRegistrySelector(\n\t( select ) => ( state, postType, options ) => {\n\t\t{\n\t\t\tif (\n\t\t\t\tpostType === 'wp_template_part' ||\n\t\t\t\tpostType === 'wp_template'\n\t\t\t) {\n\t\t\t\tconst templateAreas =\n\t\t\t\t\tselect( coreStore ).getEntityRecord(\n\t\t\t\t\t\t'root',\n\t\t\t\t\t\t'__unstableBase'\n\t\t\t\t\t)?.default_template_part_areas || [];\n\n\t\t\t\tconst areaData = templateAreas.find(\n\t\t\t\t\t( item ) => options.area === item.area\n\t\t\t\t);\n\n\t\t\t\tif ( areaData?.icon ) {\n\t\t\t\t\treturn getTemplatePartIcon( areaData.icon );\n\t\t\t\t}\n\n\t\t\t\treturn layout;\n\t\t\t}\n\t\t\tif ( CARD_ICONS[ postType ] ) {\n\t\t\t\treturn CARD_ICONS[ postType ];\n\t\t\t}\n\t\t\tconst postTypeEntity = select( coreStore ).getPostType( postType );\n\t\t\t// `icon` is the `menu_icon` property of a post type. We\n\t\t\t// only handle `dashicons` for now, even if the `menu_icon`\n\t\t\t// also supports urls and svg as values.\n\t\t\tif (\n\t\t\t\ttypeof postTypeEntity?.icon === 'string' &&\n\t\t\t\tpostTypeEntity.icon.startsWith( 'dashicons-' )\n\t\t\t) {\n\t\t\t\treturn postTypeEntity.icon.slice( 10 );\n\t\t\t}\n\t\t\treturn pageIcon;\n\t\t}\n\t}\n);\n\n/**\n * Returns true if there are unsaved changes to the\n * post's meta fields, and false otherwise.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type of the post.\n * @param {number} postId The ID of the post.\n *\n * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.\n */\nexport const hasPostMetaChanges = createRegistrySelector(\n\t( select ) => ( state, postType, postId ) => {\n\t\tconst { type: currentPostType, id: currentPostId } =\n\t\t\tgetCurrentPost( state );\n\t\t// If no postType or postId is passed, use the current post.\n\t\tconst edits = select( coreStore ).getEntityRecordNonTransientEdits(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t);\n\n\t\tif ( ! edits?.meta ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Compare if anything apart from `footnotes` has changed.\n\t\tconst originalPostMeta = select( coreStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\tpostType || currentPostType,\n\t\t\tpostId || currentPostId\n\t\t)?.meta;\n\n\t\treturn ! fastDeepEqual(\n\t\t\t{ ...originalPostMeta, footnotes: undefined },\n\t\t\t{ ...edits.meta, footnotes: undefined }\n\t\t);\n\t}\n);\n\nexport function getEntityActions( state, ...args ) {\n\treturn _getEntityActions( state.dataviews, ...args );\n}\n\nexport function isEntityReady( state, ...args ) {\n\treturn _isEntityReady( state.dataviews, ...args );\n}\n\nexport function getEntityFields( state, ...args ) {\n\treturn _getEntityFields( state.dataviews, ...args );\n}\n\n/**\n * Similar to getBlocksByName in @wordpress/block-editor, but only returns the top-most\n * blocks that aren't descendants of the query block.\n *\n * @param {Object} state Global application state.\n * @param {Array|string} blockNames Block names of the blocks to retrieve.\n *\n * @return {Array} Block client IDs.\n */\nexport const getPostBlocksByName = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state, blockNames ) => {\n\t\t\tblockNames = Array.isArray( blockNames )\n\t\t\t\t? blockNames\n\t\t\t\t: [ blockNames ];\n\t\t\tconst { getBlocksByName, getBlockParents, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\treturn getBlocksByName( blockNames ).filter( ( clientId ) =>\n\t\t\t\tgetBlockParents( clientId ).every( ( parentClientId ) => {\n\t\t\t\t\tconst parentBlockName = getBlockName( parentClientId );\n\t\t\t\t\treturn (\n\t\t\t\t\t\t// Ignore descendents of the query block.\n\t\t\t\t\t\tparentBlockName !== 'core/query' &&\n\t\t\t\t\t\t// Enable only the top-most block.\n\t\t\t\t\t\t! blockNames.includes( parentBlockName )\n\t\t\t\t\t);\n\t\t\t\t} )\n\t\t\t);\n\t\t},\n\t\t() => [ select( blockEditorStore ).getBlocks() ]\n\t)\n);\n\n/**\n * Returns the default rendering mode for a post type by user preference or post type configuration.\n *\n * @param {Object} state Global application state.\n * @param {string} postType The post type.\n *\n * @return {string} The default rendering mode. Returns `undefined` while resolving value.\n */\nexport const getDefaultRenderingMode = createRegistrySelector(\n\t( select ) => ( state, postType ) => {\n\t\tconst { getPostType, getCurrentTheme, hasFinishedResolution } =\n\t\t\tselect( coreStore );\n\n\t\t// This needs to be called before `hasFinishedResolution`.\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst currentTheme = getCurrentTheme();\n\t\t// eslint-disable-next-line @wordpress/no-unused-vars-before-return\n\t\tconst postTypeEntity = getPostType( postType );\n\n\t\t// Wait for the post type and theme resolution.\n\t\tif (\n\t\t\t! hasFinishedResolution( 'getPostType', [ postType ] ) ||\n\t\t\t! hasFinishedResolution( 'getCurrentTheme' )\n\t\t) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst theme = currentTheme?.stylesheet;\n\t\tconst defaultModePreference = select( preferencesStore ).get(\n\t\t\t'core',\n\t\t\t'renderingModes'\n\t\t)?.[ theme ]?.[ postType ];\n\t\tconst postTypeDefaultMode = Array.isArray(\n\t\t\tpostTypeEntity?.supports?.editor\n\t\t)\n\t\t\t? postTypeEntity.supports.editor.find(\n\t\t\t\t\t( features ) => 'default-mode' in features\n\t\t\t )?.[ 'default-mode' ]\n\t\t\t: undefined;\n\n\t\tconst defaultMode = defaultModePreference || postTypeDefaultMode;\n\n\t\t// Fallback gracefully to 'post-only' when rendering mode is not supported.\n\t\tif ( ! RENDERING_MODES.includes( defaultMode ) ) {\n\t\t\treturn 'post-only';\n\t\t}\n\n\t\treturn defaultMode;\n\t}\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,cAAc,EAAEC,sBAAsB,QAAQ,iBAAiB;AACxE,SACCC,MAAM,E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AAe,CAAC,CAAC;EACtC;EACA,MAAM/B,cAAc,GAAGC,WAAW,CAAEX,QAAS,CAAC;;EAE9C;EACA,IACC,CAAE0C,qBAAqB,CAAE,aAAa,EAAE,CAAE1C,QAAQ,CAAG,CAAC,IACtD,CAAE0C,qBAAqB,CAAE,iBAAkB,CAAC,EAC3C;IACD,OAAO7D,SAAS;EACjB;EAEA,MAAM+D,KAAK,GAAGD,YAAY,EAAEE,UAAU;EACtC,MAAMC,qBAAqB,GAAG5D,MAAM,CAAEjB,gBAAiB,CAAC,CAAC8E,GAAG,CAC3D,MAAM,EACN,gBACD,CAAC,GAAIH,KAAK,CAAE,GAAI5C,QAAQ,CAAE;EAC1B,MAAMgD,mBAAmB,GAAGnB,KAAK,CAACC,OAAO,CACxCpB,cAAc,EAAEuC,QAAQ,EAAEC,MAC3B,CAAC,GACExC,cAAc,CAACuC,QAAQ,CAACC,MAAM,CAAC5C,IAAI,CACjC6C,QAAQ,IAAM,cAAc,IAAIA,QAClC,CAAC,GAAI,cAAc,CAAE,GACrBtE,SAAS;EAEZ,MAAMuE,WAAW,GAAGN,qBAAqB,IAAIE,mBAAmB;;EAEhE;EACA,IAAK,CAAEhE,eAAe,CAACsD,QAAQ,CAAEc,WAAY,CAAC,EAAG;IAChD,OAAO,WAAW;EACnB;EAEA,OAAOA,WAAW;AACnB,CACD,CAAC","ignoreList":[]}
@@ -27,6 +27,7 @@ const noop = () => {};
27
27
  * @param {Function} $0.onError Function called when an error happens.
28
28
  * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
29
29
  * @param {Function} $0.onSuccess Function called after the final representation of the file is available.
30
+ * @param {boolean} $0.multiple Whether to allow multiple files to be uploaded.
30
31
  */
31
32
  export default function mediaUpload({
32
33
  additionalData = {},
@@ -35,7 +36,8 @@ export default function mediaUpload({
35
36
  maxUploadFileSize,
36
37
  onError = noop,
37
38
  onFileChange,
38
- onSuccess
39
+ onSuccess,
40
+ multiple = true
39
41
  }) {
40
42
  const {
41
43
  getCurrentPost,
@@ -90,7 +92,8 @@ export default function mediaUpload({
90
92
  clearSaveLock();
91
93
  onError(message);
92
94
  },
93
- wpAllowedMimeTypes
95
+ wpAllowedMimeTypes,
96
+ multiple
94
97
  });
95
98
  }
96
99
  //# sourceMappingURL=index.js.map