@wordpress/editor 14.18.0 → 14.19.1

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 (160) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +2 -0
  3. package/build/components/document-bar/index.js +3 -2
  4. package/build/components/document-bar/index.js.map +1 -1
  5. package/build/components/document-outline/index.js +37 -17
  6. package/build/components/document-outline/index.js.map +1 -1
  7. package/build/components/document-outline/item.js +32 -20
  8. package/build/components/document-outline/item.js.map +1 -1
  9. package/build/components/entities-saved-states/entity-record-item.js +4 -3
  10. package/build/components/entities-saved-states/entity-record-item.js.map +1 -1
  11. package/build/components/entities-saved-states/entity-type-list.js +2 -1
  12. package/build/components/entities-saved-states/entity-type-list.js.map +1 -1
  13. package/build/components/entities-saved-states/index.js +66 -42
  14. package/build/components/entities-saved-states/index.js.map +1 -1
  15. package/build/components/post-actions/index.js +19 -28
  16. package/build/components/post-actions/index.js.map +1 -1
  17. package/build/components/post-card-panel/index.js +5 -5
  18. package/build/components/post-card-panel/index.js.map +1 -1
  19. package/build/components/post-featured-image/index.js +4 -2
  20. package/build/components/post-featured-image/index.js.map +1 -1
  21. package/build/components/post-template/block-theme.js +68 -48
  22. package/build/components/post-template/block-theme.js.map +1 -1
  23. package/build/components/post-template/classic-theme.js +30 -18
  24. package/build/components/post-template/classic-theme.js.map +1 -1
  25. package/build/components/post-template/create-new-template-modal.js +3 -1
  26. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  27. package/build/components/post-template/panel.js +3 -11
  28. package/build/components/post-template/panel.js.map +1 -1
  29. package/build/components/preferences-modal/block-visibility.js +2 -1
  30. package/build/components/preferences-modal/block-visibility.js.map +1 -1
  31. package/build/components/preferences-modal/index.js +1 -1
  32. package/build/components/preferences-modal/index.js.map +1 -1
  33. package/build/components/preview-dropdown/index.js +6 -3
  34. package/build/components/preview-dropdown/index.js.map +1 -1
  35. package/build/components/provider/index.js +19 -18
  36. package/build/components/provider/index.js.map +1 -1
  37. package/build/components/sidebar/header.js +1 -1
  38. package/build/components/sidebar/header.js.map +1 -1
  39. package/build/components/sidebar/index.js +1 -1
  40. package/build/components/sidebar/index.js.map +1 -1
  41. package/build/components/start-page-options/index.js +148 -23
  42. package/build/components/start-page-options/index.js.map +1 -1
  43. package/build/components/visual-editor/edit-template-blocks-notification.js +1 -1
  44. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  45. package/build/store/private-actions.js +29 -2
  46. package/build/store/private-actions.js.map +1 -1
  47. package/build/store/private-selectors.js +45 -1
  48. package/build/store/private-selectors.js.map +1 -1
  49. package/build/store/selectors.js +8 -7
  50. package/build/store/selectors.js.map +1 -1
  51. package/build/utils/media-upload/index.js +5 -2
  52. package/build/utils/media-upload/index.js.map +1 -1
  53. package/build-module/components/document-bar/index.js +3 -2
  54. package/build-module/components/document-bar/index.js.map +1 -1
  55. package/build-module/components/document-outline/index.js +38 -18
  56. package/build-module/components/document-outline/index.js.map +1 -1
  57. package/build-module/components/document-outline/item.js +32 -20
  58. package/build-module/components/document-outline/item.js.map +1 -1
  59. package/build-module/components/entities-saved-states/entity-record-item.js +4 -3
  60. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  61. package/build-module/components/entities-saved-states/entity-type-list.js +2 -1
  62. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  63. package/build-module/components/entities-saved-states/index.js +67 -43
  64. package/build-module/components/entities-saved-states/index.js.map +1 -1
  65. package/build-module/components/post-actions/index.js +19 -28
  66. package/build-module/components/post-actions/index.js.map +1 -1
  67. package/build-module/components/post-card-panel/index.js +5 -5
  68. package/build-module/components/post-card-panel/index.js.map +1 -1
  69. package/build-module/components/post-featured-image/index.js +4 -2
  70. package/build-module/components/post-featured-image/index.js.map +1 -1
  71. package/build-module/components/post-template/block-theme.js +68 -48
  72. package/build-module/components/post-template/block-theme.js.map +1 -1
  73. package/build-module/components/post-template/classic-theme.js +30 -18
  74. package/build-module/components/post-template/classic-theme.js.map +1 -1
  75. package/build-module/components/post-template/create-new-template-modal.js +3 -1
  76. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  77. package/build-module/components/post-template/panel.js +3 -11
  78. package/build-module/components/post-template/panel.js.map +1 -1
  79. package/build-module/components/preferences-modal/block-visibility.js +2 -1
  80. package/build-module/components/preferences-modal/block-visibility.js.map +1 -1
  81. package/build-module/components/preferences-modal/index.js +1 -1
  82. package/build-module/components/preferences-modal/index.js.map +1 -1
  83. package/build-module/components/preview-dropdown/index.js +6 -3
  84. package/build-module/components/preview-dropdown/index.js.map +1 -1
  85. package/build-module/components/provider/index.js +19 -18
  86. package/build-module/components/provider/index.js.map +1 -1
  87. package/build-module/components/sidebar/header.js +1 -1
  88. package/build-module/components/sidebar/header.js.map +1 -1
  89. package/build-module/components/sidebar/index.js +1 -1
  90. package/build-module/components/sidebar/index.js.map +1 -1
  91. package/build-module/components/start-page-options/index.js +148 -24
  92. package/build-module/components/start-page-options/index.js.map +1 -1
  93. package/build-module/components/visual-editor/edit-template-blocks-notification.js +1 -1
  94. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  95. package/build-module/store/private-actions.js +25 -0
  96. package/build-module/store/private-actions.js.map +1 -1
  97. package/build-module/store/private-selectors.js +44 -1
  98. package/build-module/store/private-selectors.js.map +1 -1
  99. package/build-module/store/selectors.js +8 -7
  100. package/build-module/store/selectors.js.map +1 -1
  101. package/build-module/utils/media-upload/index.js +5 -2
  102. package/build-module/utils/media-upload/index.js.map +1 -1
  103. package/build-style/style-rtl.css +51 -9
  104. package/build-style/style.css +51 -9
  105. package/build-types/components/document-outline/index.d.ts.map +1 -1
  106. package/build-types/components/document-outline/item.d.ts +2 -1
  107. package/build-types/components/document-outline/item.d.ts.map +1 -1
  108. package/build-types/components/entities-saved-states/entity-record-item.d.ts.map +1 -1
  109. package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
  110. package/build-types/components/entities-saved-states/index.d.ts +6 -2
  111. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  112. package/build-types/components/post-actions/index.d.ts.map +1 -1
  113. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  114. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  115. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  116. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  117. package/build-types/components/post-template/panel.d.ts.map +1 -1
  118. package/build-types/components/preferences-modal/block-visibility.d.ts.map +1 -1
  119. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  120. package/build-types/components/provider/index.d.ts.map +1 -1
  121. package/build-types/components/start-page-options/index.d.ts +2 -1
  122. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  123. package/build-types/store/private-actions.d.ts +4 -0
  124. package/build-types/store/private-actions.d.ts.map +1 -1
  125. package/build-types/store/private-selectors.d.ts +13 -0
  126. package/build-types/store/private-selectors.d.ts.map +1 -1
  127. package/build-types/store/selectors.d.ts.map +1 -1
  128. package/build-types/utils/media-upload/index.d.ts +3 -1
  129. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  130. package/package.json +37 -37
  131. package/src/components/document-bar/index.js +2 -2
  132. package/src/components/document-outline/index.js +49 -17
  133. package/src/components/document-outline/item.js +38 -23
  134. package/src/components/document-outline/style.scss +2 -0
  135. package/src/components/entities-saved-states/entity-record-item.js +2 -4
  136. package/src/components/entities-saved-states/entity-type-list.js +6 -2
  137. package/src/components/entities-saved-states/index.js +98 -58
  138. package/src/components/entities-saved-states/style.scss +40 -5
  139. package/src/components/post-actions/index.js +19 -37
  140. package/src/components/post-card-panel/index.js +9 -7
  141. package/src/components/post-featured-image/index.js +2 -0
  142. package/src/components/post-template/block-theme.js +76 -56
  143. package/src/components/post-template/classic-theme.js +31 -15
  144. package/src/components/post-template/create-new-template-modal.js +1 -0
  145. package/src/components/post-template/panel.js +2 -12
  146. package/src/components/post-text-editor/style.scss +0 -2
  147. package/src/components/preferences-modal/block-visibility.js +2 -1
  148. package/src/components/preferences-modal/index.js +1 -1
  149. package/src/components/preview-dropdown/index.js +8 -6
  150. package/src/components/provider/index.js +21 -30
  151. package/src/components/sidebar/header.js +1 -1
  152. package/src/components/sidebar/index.js +1 -1
  153. package/src/components/start-page-options/index.js +149 -23
  154. package/src/components/start-page-options/style.scss +27 -0
  155. package/src/components/visual-editor/edit-template-blocks-notification.js +1 -1
  156. package/src/store/private-actions.js +33 -0
  157. package/src/store/private-selectors.js +59 -4
  158. package/src/store/selectors.js +9 -14
  159. package/src/utils/media-upload/index.js +3 -0
  160. package/tsconfig.tsbuildinfo +1 -1
@@ -4,11 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = StartPageOptions;
7
+ exports.useStartPatterns = useStartPatterns;
8
+ var _components = require("@wordpress/components");
9
+ var _i18n = require("@wordpress/i18n");
7
10
  var _element = require("@wordpress/element");
11
+ var _blockEditor = require("@wordpress/block-editor");
8
12
  var _data = require("@wordpress/data");
13
+ var _coreData = require("@wordpress/core-data");
14
+ var _blocks = require("@wordpress/blocks");
9
15
  var _preferences = require("@wordpress/preferences");
10
16
  var _interface = require("@wordpress/interface");
11
17
  var _store = require("../../store");
18
+ var _jsxRuntime = require("react/jsx-runtime");
12
19
  /**
13
20
  * WordPress dependencies
14
21
  */
@@ -17,44 +24,162 @@ var _store = require("../../store");
17
24
  * Internal dependencies
18
25
  */
19
26
 
20
- function StartPageOptions() {
27
+ function useStartPatterns() {
28
+ // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
29
+ // and it has no postTypes declared and the current post type is page or if
30
+ // the current post type is part of the postTypes declared.
21
31
  const {
22
- postId,
23
- enabled
32
+ blockPatternsWithPostContentBlockType,
33
+ postType
24
34
  } = (0, _data.useSelect)(select => {
25
35
  const {
26
- getCurrentPostId,
27
- getCurrentPostType
36
+ getPatternsByBlockTypes,
37
+ getBlocksByName
38
+ } = select(_blockEditor.store);
39
+ const {
40
+ getCurrentPostType,
41
+ getRenderingMode
28
42
  } = select(_store.store);
29
- const preferencesModalActive = select(_interface.store).isModalActive('editor/preferences');
30
- const choosePatternModalEnabled = select(_preferences.store).get('core', 'enableChoosePatternModal');
43
+ const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
31
44
  return {
32
- postId: getCurrentPostId(),
33
- enabled: choosePatternModalEnabled && !preferencesModalActive && 'page' === getCurrentPostType()
45
+ blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
46
+ postType: getCurrentPostType()
47
+ };
48
+ }, []);
49
+ return (0, _element.useMemo)(() => {
50
+ if (!blockPatternsWithPostContentBlockType?.length) {
51
+ return [];
52
+ }
53
+
54
+ /*
55
+ * Filter patterns without postTypes declared if the current postType is page
56
+ * or patterns that declare the current postType in its post type array.
57
+ */
58
+ return blockPatternsWithPostContentBlockType.filter(pattern => {
59
+ return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
60
+ });
61
+ }, [postType, blockPatternsWithPostContentBlockType]);
62
+ }
63
+ function PatternSelection({
64
+ blockPatterns,
65
+ onChoosePattern
66
+ }) {
67
+ const {
68
+ editEntityRecord
69
+ } = (0, _data.useDispatch)(_coreData.store);
70
+ const {
71
+ postType,
72
+ postId
73
+ } = (0, _data.useSelect)(select => {
74
+ const {
75
+ getCurrentPostType,
76
+ getCurrentPostId
77
+ } = select(_store.store);
78
+ return {
79
+ postType: getCurrentPostType(),
80
+ postId: getCurrentPostId()
34
81
  };
35
82
  }, []);
83
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_blockEditor.__experimentalBlockPatternsList, {
84
+ blockPatterns: blockPatterns,
85
+ onClickPattern: (_pattern, blocks) => {
86
+ editEntityRecord('postType', postType, postId, {
87
+ blocks,
88
+ content: ({
89
+ blocks: blocksForSerialization = []
90
+ }) => (0, _blocks.__unstableSerializeAndClean)(blocksForSerialization)
91
+ });
92
+ onChoosePattern();
93
+ }
94
+ });
95
+ }
96
+ function StartPageOptionsModal({
97
+ onClose
98
+ }) {
99
+ const [showStartPatterns, setShowStartPatterns] = (0, _element.useState)(true);
100
+ const {
101
+ set: setPreference
102
+ } = (0, _data.useDispatch)(_preferences.store);
103
+ const startPatterns = useStartPatterns();
104
+ const hasStartPattern = startPatterns.length > 0;
105
+ if (!hasStartPattern) {
106
+ return null;
107
+ }
108
+ function handleClose() {
109
+ onClose();
110
+ setPreference('core', 'enableChoosePatternModal', showStartPatterns);
111
+ }
112
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Modal, {
113
+ className: "editor-start-page-options__modal",
114
+ title: (0, _i18n.__)('Choose a pattern'),
115
+ isFullScreen: true,
116
+ onRequestClose: handleClose,
117
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
+ className: "editor-start-page-options__modal-content",
119
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PatternSelection, {
120
+ blockPatterns: startPatterns,
121
+ onChoosePattern: handleClose
122
+ })
123
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Flex, {
124
+ className: "editor-start-page-options__modal__actions",
125
+ justify: "flex-end",
126
+ expanded: false,
127
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.FlexItem, {
128
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.ToggleControl, {
129
+ __nextHasNoMarginBottom: true,
130
+ checked: showStartPatterns,
131
+ label: (0, _i18n.__)('Show starter patterns'),
132
+ help: (0, _i18n.__)('Shows starter patterns when creating a new page.'),
133
+ onChange: newValue => {
134
+ setShowStartPatterns(newValue);
135
+ }
136
+ })
137
+ })
138
+ })]
139
+ });
140
+ }
141
+ function StartPageOptions() {
142
+ const [isOpen, setIsOpen] = (0, _element.useState)(false);
36
143
  const {
37
144
  isEditedPostDirty,
38
145
  isEditedPostEmpty
39
146
  } = (0, _data.useSelect)(_store.store);
40
147
  const {
41
- setIsInserterOpened
42
- } = (0, _data.useDispatch)(_store.store);
148
+ isModalActive
149
+ } = (0, _data.useSelect)(_interface.store);
150
+ const {
151
+ enabled,
152
+ postId
153
+ } = (0, _data.useSelect)(select => {
154
+ const {
155
+ getCurrentPostId,
156
+ getCurrentPostType
157
+ } = select(_store.store);
158
+ const choosePatternModalEnabled = select(_preferences.store).get('core', 'enableChoosePatternModal');
159
+ return {
160
+ postId: getCurrentPostId(),
161
+ enabled: choosePatternModalEnabled && 'page' === getCurrentPostType()
162
+ };
163
+ }, []);
164
+
165
+ // Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.
166
+ // Examples: changing pages in the List View, creating a new page via Command Palette.
43
167
  (0, _element.useEffect)(() => {
44
- if (!enabled) {
45
- return;
46
- }
47
168
  const isFreshPage = !isEditedPostDirty() && isEditedPostEmpty();
48
- if (isFreshPage) {
49
- setIsInserterOpened({
50
- tab: 'patterns',
51
- category: 'core/starter-content'
52
- });
169
+ // Prevents immediately opening when features is enabled via preferences modal.
170
+ const isPreferencesModalActive = isModalActive('editor/preferences');
171
+ if (!enabled || !isFreshPage || isPreferencesModalActive) {
172
+ return;
53
173
  }
54
174
 
55
- // Note: The `postId` ensures the effect re-runs when pages are switched without remounting the component.
56
- // Examples: changing pages in the List View, creating a new page via Command Palette.
57
- }, [postId, enabled, setIsInserterOpened, isEditedPostDirty, isEditedPostEmpty]);
58
- return null;
175
+ // Open the modal after the initial render for a new page.
176
+ setIsOpen(true);
177
+ }, [enabled, postId, isEditedPostDirty, isEditedPostEmpty, isModalActive]);
178
+ if (!isOpen) {
179
+ return null;
180
+ }
181
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(StartPageOptionsModal, {
182
+ onClose: () => setIsOpen(false)
183
+ });
59
184
  }
60
185
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_preferences","_interface","_store","StartPageOptions","postId","enabled","useSelect","select","getCurrentPostId","getCurrentPostType","editorStore","preferencesModalActive","interfaceStore","isModalActive","choosePatternModalEnabled","preferencesStore","get","isEditedPostDirty","isEditedPostEmpty","setIsInserterOpened","useDispatch","useEffect","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"],"m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,CACFpB,MAAM,EACNC,OAAO,EACPc,mBAAmB,EACnBF,iBAAiB,EACjBC,iBAAiB,CAChB,CAAC;EAEH,OAAO,IAAI;AACZ","ignoreList":[]}
1
+ {"version":3,"names":["_components","require","_i18n","_element","_blockEditor","_data","_coreData","_blocks","_preferences","_interface","_store","_jsxRuntime","useStartPatterns","blockPatternsWithPostContentBlockType","postType","useSelect","select","getPatternsByBlockTypes","getBlocksByName","blockEditorStore","getCurrentPostType","getRenderingMode","editorStore","rootClientId","useMemo","length","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","editEntityRecord","useDispatch","coreStore","postId","getCurrentPostId","jsx","__experimentalBlockPatternsList","onClickPattern","_pattern","blocks","content","blocksForSerialization","__unstableSerializeAndClean","StartPageOptionsModal","onClose","showStartPatterns","setShowStartPatterns","useState","set","setPreference","preferencesStore","startPatterns","hasStartPattern","handleClose","jsxs","Modal","className","title","__","isFullScreen","onRequestClose","children","Flex","justify","expanded","FlexItem","ToggleControl","__nextHasNoMarginBottom","checked","label","help","onChange","newValue","StartPageOptions","isOpen","setIsOpen","isEditedPostDirty","isEditedPostEmpty","isModalActive","interfaceStore","enabled","choosePatternModalEnabled","get","useEffect","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":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAIA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IA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}
@@ -87,7 +87,7 @@ var _jsxRuntime = require("react/jsx-runtime");
87
87
  },
88
88
  onCancel: () => setIsDialogOpen(false),
89
89
  size: "medium",
90
- children: (0, _i18n.__)('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?')
90
+ children: (0, _i18n.__)('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?')
91
91
  });
92
92
  }
93
93
  //# sourceMappingURL=edit-template-blocks-notification.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_store","_jsxRuntime","EditTemplateBlocksNotification","contentRef","onNavigateToEntityRecord","templateId","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","canEditTemplate","coreStore","canUser","kind","name","isDialogOpen","setIsDialogOpen","useState","useEffect","handleDblClick","event","target","classList","contains","dataset","type","defaultPrevented","preventDefault","canvas","current","addEventListener","removeEventListener","jsx","__experimentalConfirmDialog","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":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAZnD;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,SAASO,8BAA8BA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACxE,MAAM;IAAEC,wBAAwB;IAAEC;EAAW,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACzE,MAAM;MAAEC,iBAAiB;MAAEC;IAAqB,CAAC,GAChDF,MAAM,CAAEG,YAAY,CAAC;IAEtB,OAAO;MACNN,wBAAwB,EACvBI,iBAAiB,CAAC,CAAC,CAACJ,wBAAwB;MAC7CC,UAAU,EAAEI,oBAAoB,CAAC;IAClC,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAME,eAAe,GAAG,IAAAL,eAAS,EAC9BC,MAAM,IACP,CAAC,CAAEA,MAAM,CAAEK,eAAU,CAAC,CAACC,OAAO,CAAE,QAAQ,EAAE;IACzCC,IAAI,EAAE,UAAU;IAChBC,IAAI,EAAE;EACP,CAAE,CAAC,EACJ,EACD,CAAC;EAED,MAAM,CAAEC,YAAY,EAAEC,eAAe,CAAE,GAAG,IAAAC,iBAAQ,EAAE,KAAM,CAAC;EAE3D,IAAAC,kBAAS,EAAE,MAAM;IAChB,MAAMC,cAAc,GAAKC,KAAK,IAAM;MACnC,IAAK,CAAEV,eAAe,EAAG;QACxB;MACD;MAEA,IACC,CAAEU,KAAK,CAACC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAAE,mBAAoB,CAAC,IACxDH,KAAK,CAACC,MAAM,CAACG,OAAO,EAAEC,IAAI,KAAK,oBAAoB,EAClD;QACD;MACD;MAEA,IAAK,CAAEL,KAAK,CAACM,gBAAgB,EAAG;QAC/BN,KAAK,CAACO,cAAc,CAAC,CAAC;QACtBX,eAAe,CAAE,IAAK,CAAC;MACxB;IACD,CAAC;IAED,MAAMY,MAAM,GAAG1B,UAAU,CAAC2B,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,CAAEjB,UAAU,EAAEQ,eAAe,CAAG,CAAC;EAEpC,IAAK,CAAEA,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAV,WAAA,CAAAgC,GAAA,EAAClC,WAAA,CAAAmC,2BAAa;IACbC,MAAM,EAAGnB,YAAc;IACvBoB,iBAAiB,EAAG,IAAAC,QAAE,EAAE,eAAgB,CAAG;IAC3CC,SAAS,EAAGA,CAAA,KAAM;MACjBrB,eAAe,CAAE,KAAM,CAAC;MACxBb,wBAAwB,CAAE;QACzBmC,MAAM,EAAElC,UAAU;QAClBmC,QAAQ,EAAE;MACX,CAAE,CAAC;IACJ,CAAG;IACHC,QAAQ,EAAGA,CAAA,KAAMxB,eAAe,CAAE,KAAM,CAAG;IAC3CyB,IAAI,EAAC,QAAQ;IAAAC,QAAA,EAEX,IAAAN,QAAE,EACH,6IACD;EAAC,CACa,CAAC;AAElB","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_coreData","_element","_i18n","_components","_store","_jsxRuntime","EditTemplateBlocksNotification","contentRef","onNavigateToEntityRecord","templateId","useSelect","select","getEditorSettings","getCurrentTemplateId","editorStore","canEditTemplate","coreStore","canUser","kind","name","isDialogOpen","setIsDialogOpen","useState","useEffect","handleDblClick","event","target","classList","contains","dataset","type","defaultPrevented","preventDefault","canvas","current","addEventListener","removeEventListener","jsx","__experimentalConfirmDialog","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":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAAmD,IAAAM,WAAA,GAAAN,OAAA;AAZnD;AACA;AACA;;AAOA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,GACe,SAASO,8BAA8BA,CAAE;EAAEC;AAAW,CAAC,EAAG;EACxE,MAAM;IAAEC,wB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,CAAG,CAAC;EAEpC,IAAK,CAAEA,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAV,WAAA,CAAAgC,GAAA,EAAClC,WAAA,CAAAmC,2BAAa;IACbC,MAAM,EAAGnB,YAAc;IACvBoB,iBAAiB,EAAG,IAAAC,QAAE,EAAE,eAAgB,CAAG;IAC3CC,SAAS,EAAGA,CAAA,KAAM;MACjBrB,eAAe,CAAE,KAAM,CAAC;MACxBb,wBAAwB,CAAE;QACzBmC,MAAM,EAAElC,UAAU;QAClBmC,QAAQ,EAAE;MACX,CAAE,CAAC;IACJ,CAAG;IACHC,QAAQ,EAAGA,CAAA,KAAMxB,eAAe,CAAE,KAAM,CAAG;IAC3CyB,IAAI,EAAC,QAAQ;IAAAC,QAAA,EAEX,IAAAN,QAAE,EACH,yIACD;EAAC,CACa,CAAC;AAElB","ignoreList":[]}
@@ -11,11 +11,12 @@ var _exportNames = {
11
11
  hideBlockTypes: true,
12
12
  saveDirtyEntities: true,
13
13
  revertTemplate: true,
14
- removeTemplates: true
14
+ removeTemplates: true,
15
+ setDefaultRenderingMode: true
15
16
  };
16
17
  exports.saveDirtyEntities = exports.revertTemplate = exports.removeTemplates = exports.hideBlockTypes = exports.createTemplate = void 0;
17
18
  exports.setCurrentTemplateId = setCurrentTemplateId;
18
- exports.showBlockTypes = void 0;
19
+ exports.showBlockTypes = exports.setDefaultRenderingMode = void 0;
19
20
  var _coreData = require("@wordpress/core-data");
20
21
  var _i18n = require("@wordpress/i18n");
21
22
  var _notices = require("@wordpress/notices");
@@ -361,5 +362,31 @@ const removeTemplates = items => async ({
361
362
  });
362
363
  }
363
364
  };
365
+
366
+ /**
367
+ * Set the default rendering mode preference for the current post type.
368
+ *
369
+ * @param {string} mode The rendering mode to set as default.
370
+ */
364
371
  exports.removeTemplates = removeTemplates;
372
+ const setDefaultRenderingMode = mode => ({
373
+ select,
374
+ registry
375
+ }) => {
376
+ var _registry$select$get$;
377
+ const postType = select.getCurrentPostType();
378
+ const theme = registry.select(_coreData.store).getCurrentTheme()?.stylesheet;
379
+ const renderingModes = (_registry$select$get$ = registry.select(_preferences.store).get('core', 'renderingModes')?.[theme]) !== null && _registry$select$get$ !== void 0 ? _registry$select$get$ : {};
380
+ if (renderingModes[postType] === mode) {
381
+ return;
382
+ }
383
+ const newModes = {
384
+ [theme]: {
385
+ ...renderingModes,
386
+ [postType]: mode
387
+ }
388
+ };
389
+ registry.dispatch(_preferences.store).set('core', 'renderingModes', newModes);
390
+ };
391
+ exports.setDefaultRenderingMode = setDefaultRenderingMode;
365
392
  //# sourceMappingURL=private-actions.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_i18n","_notices","_blockEditor","_preferences","_url","_apiFetch","_interopRequireDefault","_blocks","_htmlEntities","_isTemplateRevertable","_privateActions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","noticesStore","createSuccessNotice","__","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","preferencesStore","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","property","some","elt","siteItemsToSave","pendingSavedRecords","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","blockEditorStore","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","isTemplateRevertable","templateEntityConfig","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","context","source","origin","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","content","undoIgnore","parse","raw","undoRevert","errorMessage","message","code","removeTemplates","items","isResetting","every","item","has_theme_file","promiseResult","allSettled","map","deleteEntityRecord","force","throwOnError","successMessage","title","rendered","sprintf","decodeEntities","_x","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":";;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,aAAA,GAAAT,OAAA;AAKA,IAAAU,qBAAA,GAAAH,sBAAA,CAAAP,OAAA;AACA,IAAAW,eAAA,GAAAX,OAAA;AAAAY,MAAA,CAAAC,IAAA,CAAAF,eAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,eAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,eAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAjBA;AACA;AACA;;AAWA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASS,oBAAoBA,CAAEC,EAAE,EAAG;EAC1C,OAAO;IACNC,IA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AAE,CAAE,CAAC,CACvB,CAAC,GACD,IAAAJ,aAAO,EACP;QACA,IAAAvG,QAAE,EACD,gDACD,CAAC,EACD,CAAE,GAAG2G,aAAa,CAAE,CAAE,CAAC,CACvB,CAAC;MACL,CAAC,MAAM;QACNtB,YAAY,GAAGK,WAAW,GACvB,IAAAa,aAAO,EACP;QACA,IAAAvG,QAAE,EACD,oDACD,CAAC,EACD,CAAE,GAAG2G,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC,GACD,IAAAT,aAAO,EACP;QACA,IAAAvG,QAAE,EACD,mDACD,CAAC,EACD,CAAE,GAAG2G,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC;MACL;IACD;IACA1H,QAAQ,CACND,QAAQ,CAAES,cAAa,CAAC,CACxByD,iBAAiB,CAAE8B,YAAY,EAAE;MAAEpG,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC;AAACN,OAAA,CAAA6G,eAAA,GAAAA,eAAA","ignoreList":[]}
1
+ {"version":3,"names":["_coreData","require","_i18n","_notices","_blockEditor","_preferences","_url","_apiFetch","_interopRequireDefault","_blocks","_htmlEntities","_isTemplateRevertable","_privateActions","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","setCurrentTemplateId","id","type","createTemplate","template","select","dispatch","registry","savedTemplate","coreStore","saveEntityRecord","editEntityRecord","getCurrentPostType","getCurrentPostId","slug","noticesStore","createSuccessNotice","__","actions","label","onClick","setRenderingMode","getEditorSettings","defaultRenderingMode","showBlockTypes","blockNames","_registry$select$get","existingBlockNames","preferencesStore","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","property","some","elt","siteItemsToSave","pendingSavedRecords","push","typeToPublish","status","saveEditedEntityRecord","length","__experimentalSaveSpecifiedEntityEdits","undefined","blockEditorStore","__unstableMarkLastChangeAsPersistent","Promise","all","then","values","value","createErrorNotice","url","catch","error","revertTemplate","allowUndo","noticeId","isTemplateRevertable","templateEntityConfig","getEntityConfig","fileTemplatePath","addQueryArgs","baseURL","context","source","origin","fileTemplate","apiFetch","path","serializeBlocks","blocks","blocksForSerialization","__unstableSerializeAndClean","edited","getEditedEntityRecord","content","undoIgnore","parse","raw","undoRevert","errorMessage","message","code","removeTemplates","items","isResetting","every","item","has_theme_file","promiseResult","allSettled","map","deleteEntityRecord","force","throwOnError","successMessage","title","rendered","sprintf","decodeEntities","_x","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":";;;;;;;;;;;;;;;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,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CAAE,GAAG2G,aAAa,CAAE,CAACK,IAAI,CAAE,GAAI,CAC/B,CAAC;MACL;IACD;IACA1H,QAAQ,CACND,QAAQ,CAAES,cAAa,CAAC,CACxByD,iBAAiB,CAAE8B,YAAY,EAAE;MAAEpG,IAAI,EAAE;IAAW,CAAE,CAAC;EAC1D;AACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AAJAN,OAAA,CAAA6G,eAAA,GAAAA,eAAA;AAKO,MAAMyB,uBAAuB,GACjCC,IAAI,IACN,CAAE;EAAE9H,MAAM;EAAEE;AAAS,CAAC,KAAM;EAAA,IAAA6H,qBAAA;EAC3B,MAAMC,QAAQ,GAAGhI,MAAM,CAACO,kBAAkB,CAAC,CAAC;EAC5C,MAAM0H,KAAK,GAAG/H,QAAQ,CACpBF,MAAM,CAAEI,eAAU,CAAC,CACnB8H,eAAe,CAAC,CAAC,EAAEC,UAAU;EAC/B,MAAMC,cAAc,IAAAL,qBAAA,GACnB7H,QAAQ,CACNF,MAAM,CAAEuB,kBAAiB,CAAC,CAC1B7B,GAAG,CAAE,MAAM,EAAE,gBAAiB,CAAC,GAAIuI,KAAK,CAAE,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,CAAC,CAAC;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;EAED5H,QAAQ,CACND,QAAQ,CAAEsB,kBAAiB,CAAC,CAC5BM,GAAG,CAAE,MAAM,EAAE,gBAAgB,EAAEwG,QAAS,CAAC;AAC5C,CAAC;AAAC9I,OAAA,CAAAsI,uBAAA,GAAAA,uBAAA","ignoreList":[]}
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
+ exports.getDefaultRenderingMode = void 0;
7
8
  exports.getEntityActions = getEntityActions;
8
9
  exports.getEntityFields = getEntityFields;
9
10
  exports.getInserter = void 0;
@@ -16,6 +17,7 @@ var _blockEditor = require("@wordpress/block-editor");
16
17
  var _data = require("@wordpress/data");
17
18
  var _icons = require("@wordpress/icons");
18
19
  var _coreData = require("@wordpress/core-data");
20
+ var _preferences = require("@wordpress/preferences");
19
21
  var _selectors = require("./selectors");
20
22
  var _privateSelectors = require("../dataviews/store/private-selectors");
21
23
  var _utils = require("../utils");
@@ -37,6 +39,11 @@ const EMPTY_INSERTION_POINT = {
37
39
  filterValue: undefined
38
40
  };
39
41
 
42
+ /**
43
+ * These are rendering modes that the editor supports.
44
+ */
45
+ const RENDERING_MODES = ['post-only', 'template-locked'];
46
+
40
47
  /**
41
48
  * Get the inserter.
42
49
  *
@@ -78,7 +85,7 @@ const CARD_ICONS = {
78
85
  const getPostIcon = exports.getPostIcon = (0, _data.createRegistrySelector)(select => (state, postType, options) => {
79
86
  {
80
87
  if (postType === 'wp_template_part' || postType === 'wp_template') {
81
- const templateAreas = select(_coreData.store).getEntityRecord('root', '__unstableBase')?.default_template_part_areas || [];
88
+ const templateAreas = select(_coreData.store).getCurrentTheme()?.default_template_part_areas || [];
82
89
  const areaData = templateAreas.find(item => options.area === item.area);
83
90
  if (areaData?.icon) {
84
91
  return (0, _utils.getTemplatePartIcon)(areaData.icon);
@@ -166,4 +173,41 @@ const getPostBlocksByName = exports.getPostBlocksByName = (0, _data.createRegist
166
173
  );
167
174
  }));
168
175
  }, () => [select(_blockEditor.store).getBlocks()]));
176
+
177
+ /**
178
+ * Returns the default rendering mode for a post type by user preference or post type configuration.
179
+ *
180
+ * @param {Object} state Global application state.
181
+ * @param {string} postType The post type.
182
+ *
183
+ * @return {string} The default rendering mode. Returns `undefined` while resolving value.
184
+ */
185
+ const getDefaultRenderingMode = exports.getDefaultRenderingMode = (0, _data.createRegistrySelector)(select => (state, postType) => {
186
+ const {
187
+ getPostType,
188
+ getCurrentTheme,
189
+ hasFinishedResolution
190
+ } = select(_coreData.store);
191
+
192
+ // This needs to be called before `hasFinishedResolution`.
193
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
194
+ const currentTheme = getCurrentTheme();
195
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
196
+ const postTypeEntity = getPostType(postType);
197
+
198
+ // Wait for the post type and theme resolution.
199
+ if (!hasFinishedResolution('getPostType', [postType]) || !hasFinishedResolution('getCurrentTheme')) {
200
+ return undefined;
201
+ }
202
+ const theme = currentTheme?.stylesheet;
203
+ const defaultModePreference = select(_preferences.store).get('core', 'renderingModes')?.[theme]?.[postType];
204
+ const postTypeDefaultMode = Array.isArray(postTypeEntity?.supports?.editor) ? postTypeEntity.supports.editor.find(features => 'default-mode' in features)?.['default-mode'] : undefined;
205
+ const defaultMode = defaultModePreference || postTypeDefaultMode;
206
+
207
+ // Fallback gracefully to 'post-only' when rendering mode is not supported.
208
+ if (!RENDERING_MODES.includes(defaultMode)) {
209
+ return 'post-only';
210
+ }
211
+ return defaultMode;
212
+ });
169
213
  //# sourceMappingURL=private-selectors.js.map