@wordpress/edit-site 5.12.1 → 5.12.3

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 (153) hide show
  1. package/build/components/add-new-pattern/index.js +9 -9
  2. package/build/components/add-new-pattern/index.js.map +1 -1
  3. package/build/components/add-new-template/new-template.js +69 -14
  4. package/build/components/add-new-template/new-template.js.map +1 -1
  5. package/build/components/create-pattern-modal/index.js +1 -1
  6. package/build/components/create-pattern-modal/index.js.map +1 -1
  7. package/build/components/create-template-part-modal/index.js +1 -1
  8. package/build/components/create-template-part-modal/index.js.map +1 -1
  9. package/build/components/editor/index.js +1 -0
  10. package/build/components/editor/index.js.map +1 -1
  11. package/build/components/global-styles/ui.js +7 -2
  12. package/build/components/global-styles/ui.js.map +1 -1
  13. package/build/components/header-edit-mode/index.js +36 -9
  14. package/build/components/header-edit-mode/index.js.map +1 -1
  15. package/build/components/header-edit-mode/more-menu/index.js +36 -2
  16. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  17. package/build/components/keyboard-shortcuts/edit-mode.js +32 -1
  18. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  19. package/build/components/keyboard-shortcuts/register.js +9 -0
  20. package/build/components/keyboard-shortcuts/register.js.map +1 -1
  21. package/build/components/layout/index.js +86 -12
  22. package/build/components/layout/index.js.map +1 -1
  23. package/build/components/page-content-focus-manager/back-to-page-notification.js +9 -3
  24. package/build/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
  25. package/build/components/page-library/grid-item.js +11 -7
  26. package/build/components/page-library/grid-item.js.map +1 -1
  27. package/build/components/preferences-modal/enable-feature.js +5 -1
  28. package/build/components/preferences-modal/enable-feature.js.map +1 -1
  29. package/build/components/preferences-modal/index.js +30 -0
  30. package/build/components/preferences-modal/index.js.map +1 -1
  31. package/build/components/sidebar-edit-mode/index.js +4 -2
  32. package/build/components/sidebar-edit-mode/index.js.map +1 -1
  33. package/build/components/sidebar-navigation-screen/index.js +7 -3
  34. package/build/components/sidebar-navigation-screen/index.js.map +1 -1
  35. package/build/components/sidebar-navigation-screen-global-styles/index.js +15 -3
  36. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  37. package/build/components/sidebar-navigation-screen-library/category-item.js +1 -1
  38. package/build/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
  39. package/build/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  40. package/build/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  41. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +10 -1
  42. package/build/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  43. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  44. package/build/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  45. package/build/components/sidebar-navigation-screen-navigation-menus/index.js +14 -3
  46. package/build/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  47. package/build/hooks/commands/use-common-commands.js +22 -0
  48. package/build/hooks/commands/use-common-commands.js.map +1 -1
  49. package/build/hooks/commands/use-edit-mode-commands.js +170 -42
  50. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  51. package/build/index.js +1 -0
  52. package/build/index.js.map +1 -1
  53. package/build/store/selectors.js +2 -1
  54. package/build/store/selectors.js.map +1 -1
  55. package/build-module/components/add-new-pattern/index.js +8 -8
  56. package/build-module/components/add-new-pattern/index.js.map +1 -1
  57. package/build-module/components/add-new-template/new-template.js +72 -17
  58. package/build-module/components/add-new-template/new-template.js.map +1 -1
  59. package/build-module/components/create-pattern-modal/index.js +1 -1
  60. package/build-module/components/create-pattern-modal/index.js.map +1 -1
  61. package/build-module/components/create-template-part-modal/index.js +1 -1
  62. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  63. package/build-module/components/editor/index.js +1 -0
  64. package/build-module/components/editor/index.js.map +1 -1
  65. package/build-module/components/global-styles/ui.js +8 -3
  66. package/build-module/components/global-styles/ui.js.map +1 -1
  67. package/build-module/components/header-edit-mode/index.js +38 -11
  68. package/build-module/components/header-edit-mode/index.js.map +1 -1
  69. package/build-module/components/header-edit-mode/more-menu/index.js +35 -3
  70. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  71. package/build-module/components/keyboard-shortcuts/edit-mode.js +29 -1
  72. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  73. package/build-module/components/keyboard-shortcuts/register.js +9 -0
  74. package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
  75. package/build-module/components/layout/index.js +86 -12
  76. package/build-module/components/layout/index.js.map +1 -1
  77. package/build-module/components/page-content-focus-manager/back-to-page-notification.js +9 -3
  78. package/build-module/components/page-content-focus-manager/back-to-page-notification.js.map +1 -1
  79. package/build-module/components/page-library/grid-item.js +11 -7
  80. package/build-module/components/page-library/grid-item.js.map +1 -1
  81. package/build-module/components/preferences-modal/enable-feature.js +5 -1
  82. package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
  83. package/build-module/components/preferences-modal/index.js +27 -0
  84. package/build-module/components/preferences-modal/index.js.map +1 -1
  85. package/build-module/components/sidebar-edit-mode/index.js +4 -2
  86. package/build-module/components/sidebar-edit-mode/index.js.map +1 -1
  87. package/build-module/components/sidebar-navigation-screen/index.js +7 -3
  88. package/build-module/components/sidebar-navigation-screen/index.js.map +1 -1
  89. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +14 -3
  90. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  91. package/build-module/components/sidebar-navigation-screen-library/category-item.js +1 -1
  92. package/build-module/components/sidebar-navigation-screen-library/category-item.js.map +1 -1
  93. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  94. package/build-module/components/sidebar-navigation-screen-navigation-menu/index.js.map +1 -1
  95. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +11 -1
  96. package/build-module/components/sidebar-navigation-screen-navigation-menu/rename-modal.js.map +1 -1
  97. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  98. package/build-module/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js.map +1 -1
  99. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js +14 -4
  100. package/build-module/components/sidebar-navigation-screen-navigation-menus/index.js.map +1 -1
  101. package/build-module/hooks/commands/use-common-commands.js +23 -1
  102. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  103. package/build-module/hooks/commands/use-edit-mode-commands.js +170 -44
  104. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  105. package/build-module/index.js +1 -0
  106. package/build-module/index.js.map +1 -1
  107. package/build-module/store/selectors.js +2 -1
  108. package/build-module/store/selectors.js.map +1 -1
  109. package/build-style/style-rtl.css +110 -18
  110. package/build-style/style.css +110 -18
  111. package/package.json +15 -15
  112. package/src/components/add-new-pattern/index.js +8 -10
  113. package/src/components/add-new-template/new-template.js +120 -24
  114. package/src/components/add-new-template/style.scss +30 -2
  115. package/src/components/create-pattern-modal/index.js +1 -1
  116. package/src/components/create-template-part-modal/index.js +1 -1
  117. package/src/components/editor/index.js +1 -0
  118. package/src/components/editor/style.scss +4 -0
  119. package/src/components/global-styles/ui.js +34 -24
  120. package/src/components/header-edit-mode/index.js +96 -54
  121. package/src/components/header-edit-mode/more-menu/index.js +52 -7
  122. package/src/components/keyboard-shortcuts/edit-mode.js +35 -2
  123. package/src/components/keyboard-shortcuts/register.js +10 -0
  124. package/src/components/layout/index.js +115 -46
  125. package/src/components/layout/style.scss +58 -1
  126. package/src/components/page-content-focus-manager/back-to-page-notification.js +7 -2
  127. package/src/components/page-library/grid-item.js +9 -9
  128. package/src/components/page-library/style.scss +2 -2
  129. package/src/components/preferences-modal/enable-feature.js +5 -2
  130. package/src/components/preferences-modal/index.js +25 -0
  131. package/src/components/sidebar-button/style.scss +1 -1
  132. package/src/components/sidebar-edit-mode/index.js +4 -2
  133. package/src/components/sidebar-navigation-item/style.scss +1 -1
  134. package/src/components/sidebar-navigation-screen/index.js +4 -2
  135. package/src/components/sidebar-navigation-screen/style.scss +2 -1
  136. package/src/components/sidebar-navigation-screen-details-panel/style.scss +1 -1
  137. package/src/components/sidebar-navigation-screen-global-styles/index.js +15 -3
  138. package/src/components/sidebar-navigation-screen-library/category-item.js +1 -1
  139. package/src/components/sidebar-navigation-screen-library/style.scss +0 -4
  140. package/src/components/sidebar-navigation-screen-navigation-menu/index.js +1 -1
  141. package/src/components/sidebar-navigation-screen-navigation-menu/rename-modal.js +12 -1
  142. package/src/components/sidebar-navigation-screen-navigation-menu/style.scss +2 -2
  143. package/src/components/sidebar-navigation-screen-navigation-menu/use-navigation-menu-handlers.js +5 -1
  144. package/src/components/sidebar-navigation-screen-navigation-menus/index.js +31 -8
  145. package/src/components/sidebar-navigation-screen-pattern/style.scss +25 -0
  146. package/src/components/sidebar-navigation-screen-template/style.scss +15 -15
  147. package/src/components/site-hub/style.scss +4 -3
  148. package/src/hooks/commands/use-common-commands.js +20 -1
  149. package/src/hooks/commands/use-edit-mode-commands.js +155 -36
  150. package/src/index.js +1 -0
  151. package/src/store/selectors.js +5 -0
  152. package/src/store/test/selectors.js +2 -0
  153. package/src/style.scss +1 -0
@@ -17,6 +17,10 @@ var _commands = require("@wordpress/commands");
17
17
 
18
18
  var _router = require("@wordpress/router");
19
19
 
20
+ var _preferences = require("@wordpress/preferences");
21
+
22
+ var _interface = require("@wordpress/interface");
23
+
20
24
  var _store = require("../../store");
21
25
 
22
26
  var _useEditedEntityRecord = _interopRequireDefault(require("../../components/use-edited-entity-record"));
@@ -38,24 +42,72 @@ const {
38
42
  useHistory
39
43
  } = (0, _lockUnlock.unlock)(_router.privateApis);
40
44
 
41
- function useEditModeCommandLoader() {
45
+ function usePageContentFocusCommands() {
46
+ const {
47
+ isPage,
48
+ canvasMode,
49
+ hasPageContentFocus
50
+ } = (0, _data.useSelect)(select => ({
51
+ isPage: select(_store.store).isPage(),
52
+ canvasMode: (0, _lockUnlock.unlock)(select(_store.store)).getCanvasMode(),
53
+ hasPageContentFocus: select(_store.store).hasPageContentFocus()
54
+ }), []);
55
+ const {
56
+ setHasPageContentFocus
57
+ } = (0, _data.useDispatch)(_store.store);
58
+
59
+ if (!isPage || canvasMode !== 'edit') {
60
+ return {
61
+ isLoading: false,
62
+ commands: []
63
+ };
64
+ }
65
+
66
+ const commands = [];
67
+
68
+ if (hasPageContentFocus) {
69
+ commands.push({
70
+ name: 'core/switch-to-template-focus',
71
+ label: (0, _i18n.__)('Edit template'),
72
+ icon: _icons.layout,
73
+ callback: ({
74
+ close
75
+ }) => {
76
+ setHasPageContentFocus(false);
77
+ close();
78
+ }
79
+ });
80
+ } else {
81
+ commands.push({
82
+ name: 'core/switch-to-page-focus',
83
+ label: (0, _i18n.__)('Back to page'),
84
+ icon: _icons.page,
85
+ callback: ({
86
+ close
87
+ }) => {
88
+ setHasPageContentFocus(true);
89
+ close();
90
+ }
91
+ });
92
+ }
93
+
94
+ return {
95
+ isLoading: false,
96
+ commands
97
+ };
98
+ }
99
+
100
+ function useManipulateDocumentCommands() {
42
101
  const {
43
102
  isLoaded,
44
103
  record: template
45
104
  } = (0, _useEditedEntityRecord.default)();
46
105
  const {
47
106
  removeTemplate,
48
- revertTemplate,
49
- setHasPageContentFocus
107
+ revertTemplate
50
108
  } = (0, _data.useDispatch)(_store.store);
51
109
  const history = useHistory();
52
- const {
53
- isPage,
54
- hasPageContentFocus
55
- } = (0, _data.useSelect)(select => ({
56
- isPage: select(_store.store).isPage(),
57
- hasPageContentFocus: select(_store.store).hasPageContentFocus()
58
- }), []);
110
+ const hasPageContentFocus = (0, _data.useSelect)(select => select(_store.store).hasPageContentFocus(), []);
59
111
 
60
112
  if (!isLoaded) {
61
113
  return {
@@ -66,36 +118,6 @@ function useEditModeCommandLoader() {
66
118
 
67
119
  const commands = [];
68
120
 
69
- if (isPage) {
70
- if (hasPageContentFocus) {
71
- commands.push({
72
- name: 'core/switch-to-template-focus',
73
- label: (0, _i18n.__)('Edit template'),
74
- icon: _icons.layout,
75
- context: 'site-editor-edit',
76
- callback: ({
77
- close
78
- }) => {
79
- setHasPageContentFocus(false);
80
- close();
81
- }
82
- });
83
- } else {
84
- commands.push({
85
- name: 'core/switch-to-page-focus',
86
- label: (0, _i18n.__)('Back to page'),
87
- icon: _icons.page,
88
- context: 'site-editor-edit',
89
- callback: ({
90
- close
91
- }) => {
92
- setHasPageContentFocus(true);
93
- close();
94
- }
95
- });
96
- }
97
- }
98
-
99
121
  if ((0, _isTemplateRevertable.default)(template) && !hasPageContentFocus) {
100
122
  const label = template.type === 'wp_template' ? (0, _i18n.__)('Reset template') : (0, _i18n.__)('Reset template part');
101
123
  commands.push({
@@ -117,7 +139,6 @@ function useEditModeCommandLoader() {
117
139
  name: 'core/remove-template',
118
140
  label,
119
141
  icon: _icons.trash,
120
- context: 'site-editor-edit',
121
142
  callback: ({
122
143
  close
123
144
  }) => {
@@ -137,11 +158,118 @@ function useEditModeCommandLoader() {
137
158
  };
138
159
  }
139
160
 
161
+ function useEditUICommands() {
162
+ const {
163
+ openGeneralSidebar,
164
+ closeGeneralSidebar,
165
+ switchEditorMode
166
+ } = (0, _data.useDispatch)(_store.store);
167
+ const {
168
+ canvasMode,
169
+ editorMode,
170
+ activeSidebar
171
+ } = (0, _data.useSelect)(select => ({
172
+ canvasMode: (0, _lockUnlock.unlock)(select(_store.store)).getCanvasMode(),
173
+ editorMode: select(_store.store).getEditorMode(),
174
+ activeSidebar: select(_interface.store).getActiveComplementaryArea(_store.store.name)
175
+ }), []);
176
+ const {
177
+ toggle
178
+ } = (0, _data.useDispatch)(_preferences.store);
179
+
180
+ if (canvasMode !== 'edit') {
181
+ return {
182
+ isLoading: false,
183
+ commands: []
184
+ };
185
+ }
186
+
187
+ const commands = [];
188
+ commands.push({
189
+ name: 'core/open-settings-sidebar',
190
+ label: (0, _i18n.__)('Toggle settings sidebar'),
191
+ icon: (0, _i18n.isRTL)() ? _icons.drawerLeft : _icons.drawerRight,
192
+ callback: ({
193
+ close
194
+ }) => {
195
+ close();
196
+
197
+ if (activeSidebar === 'edit-site/template') {
198
+ closeGeneralSidebar();
199
+ } else {
200
+ openGeneralSidebar('edit-site/template');
201
+ }
202
+ }
203
+ });
204
+ commands.push({
205
+ name: 'core/open-block-inspector',
206
+ label: (0, _i18n.__)('Toggle block inspector'),
207
+ icon: _icons.blockDefault,
208
+ callback: ({
209
+ close
210
+ }) => {
211
+ close();
212
+
213
+ if (activeSidebar === 'edit-site/block-inspector') {
214
+ closeGeneralSidebar();
215
+ } else {
216
+ openGeneralSidebar('edit-site/block-inspector');
217
+ }
218
+ }
219
+ });
220
+ commands.push({
221
+ name: 'core/toggle-spotlight-mode',
222
+ label: (0, _i18n.__)('Toggle spotlight mode'),
223
+ icon: _icons.cog,
224
+ callback: ({
225
+ close
226
+ }) => {
227
+ toggle('core/edit-site', 'focusMode');
228
+ close();
229
+ }
230
+ });
231
+ commands.push({
232
+ name: 'core/toggle-top-toolbar',
233
+ label: (0, _i18n.__)('Toggle top toolbar'),
234
+ icon: _icons.cog,
235
+ callback: ({
236
+ close
237
+ }) => {
238
+ toggle('core/edit-site', 'fixedToolbar');
239
+ close();
240
+ }
241
+ });
242
+ commands.push({
243
+ name: 'core/toggle-code-editor',
244
+ label: (0, _i18n.__)('Toggle code editor'),
245
+ icon: _icons.code,
246
+ callback: ({
247
+ close
248
+ }) => {
249
+ switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
250
+ close();
251
+ }
252
+ });
253
+ return {
254
+ isLoading: false,
255
+ commands
256
+ };
257
+ }
258
+
140
259
  function useEditModeCommands() {
260
+ (0, _commands.useCommandLoader)({
261
+ name: 'core/edit-site/page-content-focus',
262
+ hook: usePageContentFocusCommands,
263
+ context: 'site-editor-edit'
264
+ });
141
265
  (0, _commands.useCommandLoader)({
142
266
  name: 'core/edit-site/manipulate-document',
143
- hook: useEditModeCommandLoader,
267
+ hook: useManipulateDocumentCommands,
144
268
  context: 'site-editor-edit'
145
269
  });
270
+ (0, _commands.useCommandLoader)({
271
+ name: 'core/edit-site/edit-ui',
272
+ hook: useEditUICommands
273
+ });
146
274
  }
147
275
  //# sourceMappingURL=use-edit-mode-commands.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"names":["useHistory","routerPrivateApis","useEditModeCommandLoader","isLoaded","record","template","removeTemplate","revertTemplate","setHasPageContentFocus","editSiteStore","history","isPage","hasPageContentFocus","select","isLoading","commands","push","name","label","icon","layout","context","callback","close","page","type","backup","trash","path","useEditModeCommands","hook"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAhBA;AACA;AACA;;AAOA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;;AAEA,SAASC,wBAAT,GAAoC;AACnC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA,MAAM,EAAEC;AAApB,MAAiC,qCAAvC;AACA,QAAM;AAAEC,IAAAA,cAAF;AAAkBC,IAAAA,cAAlB;AAAkCC,IAAAA;AAAlC,MACL,uBAAaC,YAAb,CADD;AAEA,QAAMC,OAAO,GAAGV,UAAU,EAA1B;AACA,QAAM;AAAEW,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAkC,qBACrCC,MAAF,KAAgB;AACfF,IAAAA,MAAM,EAAEE,MAAM,CAAEJ,YAAF,CAAN,CAAwBE,MAAxB,EADO;AAEfC,IAAAA,mBAAmB,EAAEC,MAAM,CAAEJ,YAAF,CAAN,CAAwBG,mBAAxB;AAFN,GAAhB,CADuC,EAKvC,EALuC,CAAxC;;AAQA,MAAK,CAAET,QAAP,EAAkB;AACjB,WAAO;AAAEW,MAAAA,SAAS,EAAE,IAAb;AAAmBC,MAAAA,QAAQ,EAAE;AAA7B,KAAP;AACA;;AAED,QAAMA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AK,kCAAqBlB,QAArB,KAAmC,CAAEO,mBAA1C,EAAgE;AAC/D,UAAMM,KAAK,GACVb,QAAQ,CAACoB,IAAT,KAAkB,aAAlB,GACG,cAAI,iBAAJ,CADH,GAEG,cAAI,sBAAJ,CAHJ;AAIAV,IAAAA,QAAQ,CAACC,IAAT,CAAe;AACdC,MAAAA,IAAI,EAAE,sBADQ;AAEdC,MAAAA,KAFc;AAGdC,MAAAA,IAAI,EAAEQ,YAHQ;AAIdN,MAAAA,OAAO,EAAE,kBAJK;AAKdC,MAAAA,QAAQ,EAAE,CAAE;AAAEC,QAAAA;AAAF,OAAF,KAAiB;AAC1BjB,QAAAA,cAAc,CAAED,QAAF,CAAd,CAD0B,CAE1B;;AACAK,QAAAA,OAAO,CAACM,IAAR,CAAc;AACbY,UAAAA,IAAI,EAAE,MAAMvB,QAAQ,CAACoB;AADR,SAAd;AAGAF,QAAAA,KAAK;AACL;AAZa,KAAf;AAcA;;AAED,SAAO;AACNT,IAAAA,SAAS,EAAE,CAAEX,QADP;AAENY,IAAAA;AAFM,GAAP;AAIA;;AAEM,SAASc,mBAAT,GAA+B;AACrC,kCAAkB;AACjBZ,IAAAA,IAAI,EAAE,oCADW;AAEjBa,IAAAA,IAAI,EAAE5B,wBAFW;AAGjBmB,IAAAA,OAAO,EAAE;AAHQ,GAAlB;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { trash, backup, layout, page } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction useEditModeCommandLoader() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate, setHasPageContentFocus } =\n\t\tuseDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst { isPage, hasPageContentFocus } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisPage: select( editSiteStore ).isPage(),\n\t\t\thasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isPage ) {\n\t\tif ( hasPageContentFocus ) {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'core/switch-to-template-focus',\n\t\t\t\tlabel: __( 'Edit template' ),\n\t\t\t\ticon: layout,\n\t\t\t\tcontext: 'site-editor-edit',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tsetHasPageContentFocus( false );\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t} else {\n\t\t\tcommands.push( {\n\t\t\t\tname: 'core/switch-to-page-focus',\n\t\t\t\tlabel: __( 'Back to page' ),\n\t\t\t\ticon: page,\n\t\t\t\tcontext: 'site-editor-edit',\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tsetHasPageContentFocus( true );\n\t\t\t\t\tclose();\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}\n\n\tif ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Reset template' )\n\t\t\t\t: __( 'Reset template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: backup,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Delete template' )\n\t\t\t\t: __( 'Delete template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcontext: 'site-editor-edit',\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/' + template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useEditModeCommandLoader,\n\t\tcontext: 'site-editor-edit',\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"names":["useHistory","routerPrivateApis","usePageContentFocusCommands","isPage","canvasMode","hasPageContentFocus","select","editSiteStore","getCanvasMode","setHasPageContentFocus","isLoading","commands","push","name","label","icon","layout","callback","close","page","useManipulateDocumentCommands","isLoaded","record","template","removeTemplate","revertTemplate","history","type","backup","trash","path","useEditUICommands","openGeneralSidebar","closeGeneralSidebar","switchEditorMode","editorMode","activeSidebar","getEditorMode","interfaceStore","getActiveComplementaryArea","toggle","preferencesStore","drawerLeft","drawerRight","blockDefault","cog","code","useEditModeCommands","hook","context"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AAWA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AA5BA;AACA;AACA;;AAmBA;AACA;AACA;AAOA,MAAM;AAAEA,EAAAA;AAAF,IAAiB,wBAAQC,mBAAR,CAAvB;;AAEA,SAASC,2BAAT,GAAuC;AACtC,QAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,UAAV;AAAsBC,IAAAA;AAAtB,MAA8C,qBAC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AAAEC,MAAAA;AAAF,KAAF,KAAiB;AAC1BsB,MAAAA,MAAM,CAAE,gBAAF,EAAoB,cAApB,CAAN;AACAtB,MAAAA,KAAK;AACL;AAPa,GAAf;AAUAP,EAAAA,QAAQ,CAACC,IAAT,CAAe;AACdC,IAAAA,IAAI,EAAE,yBADQ;AAEdC,IAAAA,KAAK,EAAE,cAAI,oBAAJ,CAFO;AAGdC,IAAAA,IAAI,EAAE+B,WAHQ;AAId7B,IAAAA,QAAQ,EAAE,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiB;AAC1BgB,MAAAA,gBAAgB,CAAEC,UAAU,KAAK,QAAf,GAA0B,MAA1B,GAAmC,QAArC,CAAhB;AACAjB,MAAAA,KAAK;AACL;AAPa,GAAf;AAUA,SAAO;AACNR,IAAAA,SAAS,EAAE,KADL;AAENC,IAAAA;AAFM,GAAP;AAIA;;AAEM,SAASoC,mBAAT,GAA+B;AACrC,kCAAkB;AACjBlC,IAAAA,IAAI,EAAE,mCADW;AAEjBmC,IAAAA,IAAI,EAAE9C,2BAFW;AAGjB+C,IAAAA,OAAO,EAAE;AAHQ,GAAlB;AAMA,kCAAkB;AACjBpC,IAAAA,IAAI,EAAE,oCADW;AAEjBmC,IAAAA,IAAI,EAAE5B,6BAFW;AAGjB6B,IAAAA,OAAO,EAAE;AAHQ,GAAlB;AAMA,kCAAkB;AACjBpC,IAAAA,IAAI,EAAE,wBADW;AAEjBmC,IAAAA,IAAI,EAAEjB;AAFW,GAAlB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tcode,\n\tcog,\n\ttrash,\n\tbackup,\n\tlayout,\n\tpage,\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n} from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { isPage, canvasMode, hasPageContentFocus } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisPage: select( editSiteStore ).isPage(),\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\thasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setHasPageContentFocus } = useDispatch( editSiteStore );\n\n\tif ( ! isPage || canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( hasPageContentFocus ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: __( 'Edit template' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( false );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( true );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst hasPageContentFocus = useSelect(\n\t\t( select ) => select( editSiteStore ).hasPageContentFocus(),\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Reset template' )\n\t\t\t\t: __( 'Reset template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: backup,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Delete template' )\n\t\t\t\t: __( 'Delete template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/' + template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nfunction useEditUICommands() {\n\tconst { openGeneralSidebar, closeGeneralSidebar, switchEditorMode } =\n\t\tuseDispatch( editSiteStore );\n\tconst { canvasMode, editorMode, activeSidebar } = useSelect(\n\t\t( select ) => ( {\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\teditorMode: select( editSiteStore ).getEditorMode(),\n\t\t\tactiveSidebar: select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tif ( canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/template' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/template' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/block-inspector' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/block-inspector' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight mode' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'focusMode' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'fixedToolbar' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel: __( 'Toggle code editor' ),\n\t\ticon: code,\n\t\tcallback: ( { close } ) => {\n\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/edit-ui',\n\t\thook: useEditUICommands,\n\t} );\n}\n"]}
package/build/index.js CHANGED
@@ -114,6 +114,7 @@ function initializeEditor(id, settings) {
114
114
  editorMode: 'visual',
115
115
  fixedToolbar: false,
116
116
  focusMode: false,
117
+ distractionFree: false,
117
118
  keepCaretInsideBlock: false,
118
119
  welcomeGuide: true,
119
120
  welcomeGuideStyles: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["initializeEditor","id","settings","target","document","getElementById","root","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","showListViewByDefault","showBlockBreadcrumbs","interfaceStore","setDefaultComplementaryArea","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AA2EA;;AACA;;AACA;;AACA;;AA3GA;AACA;AACA;;AAsBA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,EAA3B,EAA+BC,QAA/B,EAA0C;AAChD,QAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAT,CAAyBJ,EAAzB,CAAf;AACA,QA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xB,CAA8C;AAC7CC,IAAAA,oBAAoB,EAAErC,QAAQ,CAACqC,oBADc;AAE7CC,IAAAA,wBAAwB,EAAEtC,QAAQ,CAACsC;AAFU,GAA9C,EA9CgD,CAmDhD;;AACAC,EAAAA,MAAM,CAACC,gBAAP,CAAyB,UAAzB,EAAuCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAH,EAAAA,MAAM,CAACC,gBAAP,CAAyB,MAAzB,EAAmCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEAtC,EAAAA,IAAI,CAACuC,MAAL,CAAa,4BAAC,YAAD,OAAb;AAEA,SAAOvC,IAAP;AACA;;AAEM,SAASwC,kBAAT,GAA8B;AACpC,2BAAY,gCAAZ,EAA8C;AAC7CC,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAA9C;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tkeepCaretInsideBlock: false,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\tshowListViewByDefault: false,\n\t\tshowBlockBreadcrumbs: true,\n\t} );\n\n\tdispatch( interfaceStore ).setDefaultComplementaryArea(\n\t\t'core/edit-site',\n\t\t'edit-site/template'\n\t);\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header-edit-mode/plugin-more-menu-item';\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/index.js"],"names":["initializeEditor","id","settings","target","document","getElementById","root","__experimentalFetchLinkSuggestions","search","searchOptions","__experimentalFetchRichUrlData","fetchUrlData","blocksStore","__experimentalReapplyBlockTypeFilters","coreBlocks","filter","name","setFreeformFallbackBlockName","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","preferencesStore","setDefaults","editorMode","fixedToolbar","focusMode","distractionFree","keepCaretInsideBlock","welcomeGuide","welcomeGuideStyles","showListViewByDefault","showBlockBreadcrumbs","interfaceStore","setDefaultComplementaryArea","editSiteStore","updateSettings","editorStore","updateEditorSettings","defaultTemplateTypes","defaultTemplatePartAreas","window","addEventListener","e","preventDefault","render","reinitializeEditor","since","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;AARA;;AACA;;AAKA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAQA;;AACA;;AACA;;AA4EA;;AACA;;AACA;;AACA;;AA5GA;AACA;AACA;;AAsBA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,gBAAT,CAA2BC,EAA3B,EAA+BC,QAA/B,EAA0C;AAChD,QAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAT,CAAyBJ,EAAzB,CAAf;AACA,QAAMK,IAAI,GA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C,aAAV,EAAwBC,oBAAxB,CAA8C;AAC7CC,IAAAA,oBAAoB,EAAEtC,QAAQ,CAACsC,oBADc;AAE7CC,IAAAA,wBAAwB,EAAEvC,QAAQ,CAACuC;AAFU,GAA9C,EA/CgD,CAoDhD;;AACAC,EAAAA,MAAM,CAACC,gBAAP,CAAyB,UAAzB,EAAuCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA9C,EAAkE,KAAlE;AACAH,EAAAA,MAAM,CAACC,gBAAP,CAAyB,MAAzB,EAAmCC,CAAF,IAASA,CAAC,CAACC,cAAF,EAA1C,EAA8D,KAA9D;AAEAvC,EAAAA,IAAI,CAACwC,MAAL,CAAa,4BAAC,YAAD,OAAb;AAEA,SAAOxC,IAAP;AACA;;AAEM,SAASyC,kBAAT,GAA8B;AACpC,2BAAY,gCAAZ,EAA8C;AAC7CC,IAAAA,KAAK,EAAE,KADsC;AAE7CC,IAAAA,OAAO,EAAE;AAFoC,GAA9C;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalGetCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport { dispatch } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport {\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport { store as editSiteStore } from './store';\nimport App from './components/app';\n\n/**\n * Initializes the site editor screen.\n *\n * @param {string} id ID of the root element to render the screen in.\n * @param {Object} settings Editor settings.\n */\nexport function initializeEditor( id, settings ) {\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tsettings.__experimentalFetchLinkSuggestions = ( search, searchOptions ) =>\n\t\tfetchLinkSuggestions( search, searchOptions, settings );\n\tsettings.__experimentalFetchRichUrlData = fetchUrlData;\n\n\tdispatch( blocksStore ).__experimentalReapplyBlockTypeFilters();\n\tconst coreBlocks = __experimentalGetCoreBlocks().filter(\n\t\t( { name } ) => name !== 'core/freeform'\n\t);\n\tregisterCoreBlocks( coreBlocks );\n\tdispatch( blocksStore ).setFreeformFallbackBlockName( 'core/html' );\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: true,\n\t\t} );\n\t}\n\n\t// We dispatch actions and update the store synchronously before rendering\n\t// so that we won't trigger unnecessary re-renders with useEffect.\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-site', {\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\tfocusMode: false,\n\t\tdistractionFree: false,\n\t\tkeepCaretInsideBlock: false,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideStyles: true,\n\t\tshowListViewByDefault: false,\n\t\tshowBlockBreadcrumbs: true,\n\t} );\n\n\tdispatch( interfaceStore ).setDefaultComplementaryArea(\n\t\t'core/edit-site',\n\t\t'edit-site/template'\n\t);\n\n\tdispatch( editSiteStore ).updateSettings( settings );\n\n\t// Keep the defaultTemplateTypes in the core/editor settings too,\n\t// so that they can be selected with core/editor selectors in any editor.\n\t// This is needed because edit-site doesn't initialize with EditorProvider,\n\t// which internally uses updateEditorSettings as well.\n\tdispatch( editorStore ).updateEditorSettings( {\n\t\tdefaultTemplateTypes: settings.defaultTemplateTypes,\n\t\tdefaultTemplatePartAreas: settings.defaultTemplatePartAreas,\n\t} );\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render( <App /> );\n\n\treturn root;\n}\n\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editSite.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginSidebar } from './components/sidebar-edit-mode/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header-edit-mode/plugin-sidebar-more-menu-item';\nexport { default as PluginMoreMenuItem } from './components/header-edit-mode/plugin-more-menu-item';\nexport { default as PluginTemplateSettingPanel } from './components/plugin-template-setting-panel';\n"]}
@@ -141,6 +141,7 @@ const getSettings = (0, _rememo.default)((state, setIsInserterOpen) => {
141
141
  const settings = { ...state.settings,
142
142
  outlineMode: true,
143
143
  focusMode: !!__unstableGetPreference(state, 'focusMode'),
144
+ isDistractionFree: !!__unstableGetPreference(state, 'distractionFree'),
144
145
  hasFixedToolbar: !!__unstableGetPreference(state, 'fixedToolbar'),
145
146
  keepCaretInsideBlock: !!__unstableGetPreference(state, 'keepCaretInsideBlock'),
146
147
  showIconLabels: !!__unstableGetPreference(state, 'showIconLabels'),
@@ -168,7 +169,7 @@ const getSettings = (0, _rememo.default)((state, setIsInserterOpen) => {
168
169
  };
169
170
 
170
171
  return settings;
171
- }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
172
+ }, state => [getCanUserCreateMedia(state), state.settings, __unstableGetPreference(state, 'focusMode'), __unstableGetPreference(state, 'distractionFree'), __unstableGetPreference(state, 'fixedToolbar'), __unstableGetPreference(state, 'keepCaretInsideBlock'), __unstableGetPreference(state, 'showIconLabels'), getReusableBlocks(state), getEditedPostType(state)]);
172
173
  /**
173
174
  * @deprecated
174
175
  */
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","hasPageContentFocus","postContentClientId","blockEditorStore","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","isPage","postId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,uBAAuB,GAAG,kCACpCC,MAAF,IAAc,CAAEC,KAAF,EAASC,IAAT,KACbF,MAAM,CAAEG,kBAAF,CAAN,CAA2BC,GAA3B,CAAgC,gBAAhC,EAAkDF,IAAlD,CAFqC,CAAhC;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASG,eAAT,CAA0BJ,KAA1B,EAAiCK,W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AAOF,uBAAuB,CAAEE,KAAF,EAAS,YAAT,CAA9B;AACA;AAED;AACA;AACA;;;AACO,SAASsE,wCAAT,GAAoD;AAC1D,2BACC,uEADD,EAEC;AACChE,IAAAA,KAAK,EAAE,KADR;AAECiC,IAAAA,OAAO,EAAE;AAFV,GAFD;AAOA;AAED;AACA;AACA;;;AACO,SAASgC,4BAAT,GAAwC;AAC9C,2BAAY,2DAAZ,EAAyE;AACxEjE,IAAAA,KAAK,EAAE,KADiE;AAExEiC,IAAAA,OAAO,EAAE;AAF+D,GAAzE;AAIA;AAED;AACA;AACA;;;AACO,SAASiC,kBAAT,GAA8B;AACpC,2BAAY,iDAAZ,EAA+D;AAC9DlE,IAAAA,KAAK,EAAE,KADuD;AAE9DiC,IAAAA,OAAO,EAAE;AAFqD,GAA/D;AAIA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASkC,MAAT,CAAiBzE,KAAjB,EAAyB;AAC/B,SAAO,CAAC,CAAEA,KAAK,CAACwC,UAAN,CAAiBK,OAAjB,EAA0B6B,MAApC;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;;AACO,SAASrB,mBAAT,CAA8BrD,KAA9B,EAAsC;AAC5C,SAAOyE,MAAM,CAAEzE,KAAF,CAAN,GAAkBA,KAAK,CAACqD,mBAAxB,GAA8C,KAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif ( hasPageContentFocus( state ) ) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus( state ) {\n\treturn isPage( state ) ? state.hasPageContentFocus : false;\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/store/selectors.js"],"names":["__unstableGetPreference","select","state","name","preferencesStore","get","isFeatureActive","featureName","since","alternative","__experimentalGetPreviewDeviceType","deviceType","getCanUserCreateMedia","coreDataStore","canUser","getReusableBlocks","isWeb","Platform","OS","getEntityRecords","per_page","getSettings","setIsInserterOpen","settings","outlineMode","focusMode","isDistractionFree","hasFixedToolbar","keepCaretInsideBlock","showIconLabels","__experimentalSetIsInserterOpened","__experimentalReusableBlocks","__experimentalPreferPatternsOnRoot","getEditedPostType","canUserCreateMedia","mediaUpload","onError","rest","wpAllowedMimeTypes","allowedMimeTypes","message","getHomeTemplateId","version","editedPost","postType","getEditedPostId","id","getEditedPostContext","context","getPage","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","hasPageContentFocus","postContentClientId","blockEditorStore","__experimentalGetGlobalBlocksByName","undefined","isListViewOpened","listViewPanel","isSaveViewOpened","saveViewPanel","getCurrentTemplateTemplateParts","templateType","templateId","template","getEditedEntityRecord","templateParts","blocks","getEditorMode","getCurrentTemplateNavigationPanelSubMenu","getNavigationPanelActiveMenu","isNavigationOpened","isPage","postId"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AASA;AACA;AACA;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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xB,GAA8C,KAArD;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { createRegistrySelector } from '@wordpress/data';\nimport deprecated from '@wordpress/deprecated';\nimport { uploadMedia } from '@wordpress/media-utils';\nimport { Platform } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { getFilteredTemplatePartBlocks } from './utils';\n\n/**\n * @typedef {'template'|'template_type'} TemplateType Template type.\n */\n\n/**\n * Helper for getting a preference from the preferences store.\n *\n * This is only present so that `getSettings` doesn't need to be made a\n * registry selector.\n *\n * It's unstable because the selector needs to be exported and so part of the\n * public API to work.\n */\nexport const __unstableGetPreference = createRegistrySelector(\n\t( select ) => ( state, name ) =>\n\t\tselect( preferencesStore ).get( 'core/edit-site', name )\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @deprecated\n * @param {Object} state Global application state.\n * @param {string} featureName Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport function isFeatureActive( state, featureName ) {\n\tdeprecated( `select( 'core/edit-site' ).isFeatureActive`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\treturn !! __unstableGetPreference( state, featureName );\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns whether the current user can create media or not.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Whether the current user can create media or not.\n */\nexport const getCanUserCreateMedia = createRegistrySelector(\n\t( select ) => () => select( coreDataStore ).canUser( 'create', 'media' )\n);\n\n/**\n * Returns any available Reusable blocks.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} The available reusable blocks.\n */\nexport const getReusableBlocks = createRegistrySelector( ( select ) => () => {\n\tconst isWeb = Platform.OS === 'web';\n\treturn isWeb\n\t\t? select( coreDataStore ).getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\tper_page: -1,\n\t\t } )\n\t\t: [];\n} );\n\n/**\n * Returns the settings, taking into account active features and permissions.\n *\n * @param {Object} state Global application state.\n * @param {Function} setIsInserterOpen Setter for the open state of the global inserter.\n *\n * @return {Object} Settings.\n */\nexport const getSettings = createSelector(\n\t( state, setIsInserterOpen ) => {\n\t\tconst settings = {\n\t\t\t...state.settings,\n\t\t\toutlineMode: true,\n\t\t\tfocusMode: !! __unstableGetPreference( state, 'focusMode' ),\n\t\t\tisDistractionFree: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t\thasFixedToolbar: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'fixedToolbar'\n\t\t\t),\n\t\t\tkeepCaretInsideBlock: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'keepCaretInsideBlock'\n\t\t\t),\n\t\t\tshowIconLabels: !! __unstableGetPreference(\n\t\t\t\tstate,\n\t\t\t\t'showIconLabels'\n\t\t\t),\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpen,\n\t\t\t__experimentalReusableBlocks: getReusableBlocks( state ),\n\t\t\t__experimentalPreferPatternsOnRoot:\n\t\t\t\t'wp_template' === getEditedPostType( state ),\n\t\t};\n\n\t\tconst canUserCreateMedia = getCanUserCreateMedia( state );\n\t\tif ( ! canUserCreateMedia ) {\n\t\t\treturn settings;\n\t\t}\n\n\t\tsettings.mediaUpload = ( { onError, ...rest } ) => {\n\t\t\tuploadMedia( {\n\t\t\t\twpAllowedMimeTypes: state.settings.allowedMimeTypes,\n\t\t\t\tonError: ( { message } ) => onError( message ),\n\t\t\t\t...rest,\n\t\t\t} );\n\t\t};\n\t\treturn settings;\n\t},\n\t( state ) => [\n\t\tgetCanUserCreateMedia( state ),\n\t\tstate.settings,\n\t\t__unstableGetPreference( state, 'focusMode' ),\n\t\t__unstableGetPreference( state, 'distractionFree' ),\n\t\t__unstableGetPreference( state, 'fixedToolbar' ),\n\t\t__unstableGetPreference( state, 'keepCaretInsideBlock' ),\n\t\t__unstableGetPreference( state, 'showIconLabels' ),\n\t\tgetReusableBlocks( state ),\n\t\tgetEditedPostType( state ),\n\t]\n);\n\n/**\n * @deprecated\n */\nexport function getHomeTemplateId() {\n\tdeprecated( \"select( 'core/edit-site' ).getHomeTemplateId\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Returns the current edited post type (wp_template or wp_template_part).\n *\n * @param {Object} state Global application state.\n *\n * @return {TemplateType?} Template type.\n */\nexport function getEditedPostType( state ) {\n\treturn state.editedPost.postType;\n}\n\n/**\n * Returns the ID of the currently edited template or template part.\n *\n * @param {Object} state Global application state.\n *\n * @return {string?} Post ID.\n */\nexport function getEditedPostId( state ) {\n\treturn state.editedPost.id;\n}\n\n/**\n * Returns the edited post's context object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getEditedPostContext( state ) {\n\treturn state.editedPost.context;\n}\n\n/**\n * Returns the current page object.\n *\n * @deprecated\n * @param {Object} state Global application state.\n *\n * @return {Object} Page.\n */\nexport function getPage( state ) {\n\treturn { context: state.editedPost.context };\n}\n\n/**\n * Returns the current opened/closed state of the inserter panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the inserter panel should be open; false if closed.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tif ( typeof state.blockInserterPanel === 'object' ) {\n\t\t\tconst { rootClientId, insertionIndex, filterValue } =\n\t\t\t\tstate.blockInserterPanel;\n\t\t\treturn { rootClientId, insertionIndex, filterValue };\n\t\t}\n\n\t\tif ( hasPageContentFocus( state ) ) {\n\t\t\tconst [ postContentClientId ] =\n\t\t\t\tselect( blockEditorStore ).__experimentalGetGlobalBlocksByName(\n\t\t\t\t\t'core/post-content'\n\t\t\t\t);\n\t\t\tif ( postContentClientId ) {\n\t\t\t\treturn {\n\t\t\t\t\trootClientId: postContentClientId,\n\t\t\t\t\tinsertionIndex: undefined,\n\t\t\t\t\tfilterValue: undefined,\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\trootClientId: undefined,\n\t\t\tinsertionIndex: undefined,\n\t\t\tfilterValue: undefined,\n\t\t};\n\t}\n);\n\n/**\n * Returns the current opened/closed state of the list view panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the list view panel should be open; false if closed.\n */\nexport function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns the current opened/closed state of the save panel.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} True if the save panel should be open; false if closed.\n */\nexport function isSaveViewOpened( state ) {\n\treturn state.saveViewPanel;\n}\n\n/**\n * Returns the template parts and their blocks for the current edited template.\n *\n * @param {Object} state Global application state.\n * @return {Array} Template parts and their blocks in an array.\n */\nexport const getCurrentTemplateTemplateParts = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst templateType = getEditedPostType( state );\n\t\tconst templateId = getEditedPostId( state );\n\t\tconst template = select( coreDataStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\ttemplateType,\n\t\t\ttemplateId\n\t\t);\n\n\t\tconst templateParts = select( coreDataStore ).getEntityRecords(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\t{ per_page: -1 }\n\t\t);\n\n\t\treturn getFilteredTemplatePartBlocks( template.blocks, templateParts );\n\t}\n);\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport function getEditorMode( state ) {\n\treturn __unstableGetPreference( state, 'editorMode' );\n}\n\n/**\n * @deprecated\n */\nexport function getCurrentTemplateNavigationPanelSubMenu() {\n\tdeprecated(\n\t\t\"dispatch( 'core/edit-site' ).getCurrentTemplateNavigationPanelSubMenu\",\n\t\t{\n\t\t\tsince: '6.2',\n\t\t\tversion: '6.4',\n\t\t}\n\t);\n}\n\n/**\n * @deprecated\n */\nexport function getNavigationPanelActiveMenu() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).getNavigationPanelActiveMenu\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * @deprecated\n */\nexport function isNavigationOpened() {\n\tdeprecated( \"dispatch( 'core/edit-site' ).isNavigationOpened\", {\n\t\tsince: '6.2',\n\t\tversion: '6.4',\n\t} );\n}\n\n/**\n * Whether or not the editor has a page loaded into it.\n *\n * @see setPage\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not the editor has a page loaded into it.\n */\nexport function isPage( state ) {\n\treturn !! state.editedPost.context?.postId;\n}\n\n/**\n * Whether or not the editor allows only page content to be edited.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether or not focus is on editing page content.\n */\nexport function hasPageContentFocus( state ) {\n\treturn isPage( state ) ? state.hasPageContentFocus : false;\n}\n"]}
@@ -14,8 +14,8 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
14
14
 
15
15
  import CreatePatternModal from '../create-pattern-modal';
16
16
  import CreateTemplatePartModal from '../create-template-part-modal';
17
- import { unlock } from '../../lock-unlock';
18
17
  import SidebarButton from '../sidebar-button';
18
+ import { unlock } from '../../lock-unlock';
19
19
  const {
20
20
  useHistory
21
21
  } = unlock(routerPrivateApis);
@@ -57,17 +57,17 @@ export default function AddNewPattern() {
57
57
  controls: [{
58
58
  icon: header,
59
59
  onClick: () => setShowTemplatePartModal(true),
60
- title: 'Create a template part'
60
+ title: __('Create template part')
61
61
  }, {
62
62
  icon: file,
63
63
  onClick: () => setShowPatternModal(true),
64
- title: 'Create a pattern'
64
+ title: __('Create pattern')
65
65
  }],
66
- icon: createElement(SidebarButton, {
67
- icon: plus,
68
- label: __('Create a pattern')
69
- }),
70
- label: "Create a pattern."
66
+ toggleProps: {
67
+ as: SidebarButton
68
+ },
69
+ icon: plus,
70
+ label: __('Create pattern')
71
71
  }), showPatternModal && createElement(CreatePatternModal, {
72
72
  closeModal: () => setShowPatternModal(false),
73
73
  onCreate: handleCreatePattern,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["DropdownMenu","useState","__","plus","header","file","privateApis","routerPrivateApis","CreatePatternModal","CreateTemplatePartModal","unlock","SidebarButton","useHistory","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError","icon","onClick","title"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,uBAA7B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,IAAT,EAAeC,MAAf,EAAuBC,IAAvB,QAAmC,kBAAnC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AACA,OAAOC,uBAAP,MAAoC,+BAApC;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAiBF,MAAM,CAAEH,iBAAF,CAA7B;AAEA,eAAe,SAASM,aAAT,GAAyB;AACvC,QAAMC,OAAO,GAAGF,UAAU,EAA1B;AACA,QAAM,CAAEG,gBAAF,EAAoBC,mBAApB,IAA4Cf,QAAQ,CAAE,KAAF,CAA1D;AACA,QAAM,CAAEgB,qBAAF,EAAyBC,wBAAzB,I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P,IADD,EAsBGa,gBAAgB,IACjB,cAAC,kBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,mBAAmB,CAAE,KAAF,CADvC;AAEC,IAAA,QAAQ,EAAGG,mBAFZ;AAGC,IAAA,OAAO,EAAGW;AAHX,IAvBF,EA6BGb,qBAAqB,IACtB,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,wBAAwB,CAAE,KAAF,CAD5C;AAEC,IAAA,MAAM,EAAG,EAFV;AAGC,IAAA,QAAQ,EAAGU,wBAHZ;AAIC,IAAA,OAAO,EAAGE;AAJX,IA9BF,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus, header, file } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport CreatePatternModal from '../create-pattern-modal';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport { unlock } from '../../lock-unlock';\nimport SidebarButton from '../sidebar-button';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: 'wp_block',\n\t\t\tcategoryType: 'wp_block',\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: 'wp_template_part',\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ [\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: header,\n\t\t\t\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\t\t\t\ttitle: 'Create a template part',\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: file,\n\t\t\t\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\t\t\t\ttitle: 'Create a pattern',\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t\ticon={\n\t\t\t\t\t<SidebarButton\n\t\t\t\t\t\ticon={ plus }\n\t\t\t\t\t\tlabel={ __( 'Create a pattern' ) }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tlabel=\"Create a pattern.\"\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcloseModal={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonCreate={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/components/add-new-pattern/index.js"],"names":["DropdownMenu","useState","__","plus","header","file","privateApis","routerPrivateApis","CreatePatternModal","CreateTemplatePartModal","SidebarButton","unlock","useHistory","AddNewPattern","history","showPatternModal","setShowPatternModal","showTemplatePartModal","setShowTemplatePartModal","handleCreatePattern","pattern","categoryId","push","postId","id","postType","categoryType","canvas","handleCreateTemplatePart","templatePart","handleError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,EAAE,kBAFG;AAGbE,MAAAA,MAAM,EAAE;AAHK,KAAd;AAKA;;AAED,WAASG,WAAT,GAAuB;AACtBd,IAAAA,mBAAmB,CAAE,KAAF,CAAnB;AACAE,IAAAA,wBAAwB,CAAE,KAAF,CAAxB;AACA;;AAED,SACC,8BACC,cAAC,YAAD;AACC,IAAA,QAAQ,EAAG,CACV;AACCa,MAAAA,IAAI,EAAE3B,MADP;AAEC4B,MAAAA,OAAO,EAAE,MAAMd,wBAAwB,CAAE,IAAF,CAFxC;AAGCe,MAAAA,KAAK,EAAE/B,EAAE,CAAE,sBAAF;AAHV,KADU,EAMV;AACC6B,MAAAA,IAAI,EAAE1B,IADP;AAEC2B,MAAAA,OAAO,EAAE,MAAMhB,mBAAmB,CAAE,IAAF,CAFnC;AAGCiB,MAAAA,KAAK,EAAE/B,EAAE,CAAE,gBAAF;AAHV,KANU,CADZ;AAaC,IAAA,WAAW,EAAG;AACbgC,MAAAA,EAAE,EAAExB;AADS,KAbf;AAgBC,IAAA,IAAI,EAAGP,IAhBR;AAiBC,IAAA,KAAK,EAAGD,EAAE,CAAE,gBAAF;AAjBX,IADD,EAoBGa,gBAAgB,IACjB,cAAC,kBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,mBAAmB,CAAE,KAAF,CADvC;AAEC,IAAA,QAAQ,EAAGG,mBAFZ;AAGC,IAAA,OAAO,EAAGW;AAHX,IArBF,EA2BGb,qBAAqB,IACtB,cAAC,uBAAD;AACC,IAAA,UAAU,EAAG,MAAMC,wBAAwB,CAAE,KAAF,CAD5C;AAEC,IAAA,MAAM,EAAG,EAFV;AAGC,IAAA,QAAQ,EAAGU,wBAHZ;AAIC,IAAA,OAAO,EAAGE;AAJX,IA5BF,CADD;AAsCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { DropdownMenu } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { plus, header, file } from '@wordpress/icons';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\n\n/**\n * Internal dependencies\n */\nimport CreatePatternModal from '../create-pattern-modal';\nimport CreateTemplatePartModal from '../create-template-part-modal';\nimport SidebarButton from '../sidebar-button';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nexport default function AddNewPattern() {\n\tconst history = useHistory();\n\tconst [ showPatternModal, setShowPatternModal ] = useState( false );\n\tconst [ showTemplatePartModal, setShowTemplatePartModal ] =\n\t\tuseState( false );\n\n\tfunction handleCreatePattern( { pattern, categoryId } ) {\n\t\tsetShowPatternModal( false );\n\n\t\thistory.push( {\n\t\t\tpostId: pattern.id,\n\t\t\tpostType: 'wp_block',\n\t\t\tcategoryType: 'wp_block',\n\t\t\tcategoryId,\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleCreateTemplatePart( templatePart ) {\n\t\tsetShowTemplatePartModal( false );\n\n\t\t// Navigate to the created template part editor.\n\t\thistory.push( {\n\t\t\tpostId: templatePart.id,\n\t\t\tpostType: 'wp_template_part',\n\t\t\tcanvas: 'edit',\n\t\t} );\n\t}\n\n\tfunction handleError() {\n\t\tsetShowPatternModal( false );\n\t\tsetShowTemplatePartModal( false );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<DropdownMenu\n\t\t\t\tcontrols={ [\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: header,\n\t\t\t\t\t\tonClick: () => setShowTemplatePartModal( true ),\n\t\t\t\t\t\ttitle: __( 'Create template part' ),\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\ticon: file,\n\t\t\t\t\t\tonClick: () => setShowPatternModal( true ),\n\t\t\t\t\t\ttitle: __( 'Create pattern' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t\ttoggleProps={ {\n\t\t\t\t\tas: SidebarButton,\n\t\t\t\t} }\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Create pattern' ) }\n\t\t\t/>\n\t\t\t{ showPatternModal && (\n\t\t\t\t<CreatePatternModal\n\t\t\t\t\tcloseModal={ () => setShowPatternModal( false ) }\n\t\t\t\t\tonCreate={ handleCreatePattern }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ showTemplatePartModal && (\n\t\t\t\t<CreateTemplatePartModal\n\t\t\t\t\tcloseModal={ () => setShowTemplatePartModal( false ) }\n\t\t\t\t\tblocks={ [] }\n\t\t\t\t\tonCreate={ handleCreateTemplatePart }\n\t\t\t\t\tonError={ handleError }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}