@wordpress/edit-site 5.12.10 → 5.12.11

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 (51) hide show
  1. package/build/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
  2. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  3. package/build/components/layout/index.js +8 -3
  4. package/build/components/layout/index.js.map +1 -1
  5. package/build/components/page-patterns/patterns-list.js +2 -1
  6. package/build/components/page-patterns/patterns-list.js.map +1 -1
  7. package/build/components/page-patterns/use-patterns.js +1 -1
  8. package/build/components/page-patterns/use-patterns.js.map +1 -1
  9. package/build/components/resizable-frame/index.js +3 -4
  10. package/build/components/resizable-frame/index.js.map +1 -1
  11. package/build/components/sidebar-edit-mode/page-panels/page-status.js +2 -7
  12. package/build/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  13. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
  14. package/build/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  15. package/build/components/site-hub/index.js +16 -7
  16. package/build/components/site-hub/index.js.map +1 -1
  17. package/build/hooks/commands/use-common-commands.js +78 -20
  18. package/build/hooks/commands/use-common-commands.js.map +1 -1
  19. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +10 -22
  20. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  21. package/build-module/components/layout/index.js +8 -3
  22. package/build-module/components/layout/index.js.map +1 -1
  23. package/build-module/components/page-patterns/patterns-list.js +3 -2
  24. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  25. package/build-module/components/page-patterns/use-patterns.js +1 -1
  26. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  27. package/build-module/components/resizable-frame/index.js +3 -4
  28. package/build-module/components/resizable-frame/index.js.map +1 -1
  29. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js +2 -7
  30. package/build-module/components/sidebar-edit-mode/page-panels/page-status.js.map +1 -1
  31. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +1 -1
  32. package/build-module/components/sidebar-navigation-screen-patterns/use-theme-patterns.js.map +1 -1
  33. package/build-module/components/site-hub/index.js +16 -7
  34. package/build-module/components/site-hub/index.js.map +1 -1
  35. package/build-module/hooks/commands/use-common-commands.js +74 -20
  36. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  37. package/build-style/style-rtl.css +9 -11
  38. package/build-style/style.css +9 -11
  39. package/package.json +10 -10
  40. package/src/components/global-styles/screen-revisions/revisions-buttons.js +17 -31
  41. package/src/components/layout/index.js +16 -2
  42. package/src/components/layout/style.scss +1 -1
  43. package/src/components/page-patterns/patterns-list.js +5 -2
  44. package/src/components/page-patterns/use-patterns.js +1 -0
  45. package/src/components/resizable-frame/index.js +2 -3
  46. package/src/components/resizable-frame/style.scss +0 -17
  47. package/src/components/sidebar-edit-mode/page-panels/page-status.js +1 -4
  48. package/src/components/sidebar-navigation-screen-patterns/use-theme-patterns.js +2 -1
  49. package/src/components/site-hub/index.js +21 -7
  50. package/src/components/site-hub/style.scss +9 -2
  51. package/src/hooks/commands/use-common-commands.js +56 -23
@@ -11,17 +11,20 @@ import { privateApis as routerPrivateApis } from '@wordpress/router';
11
11
  import { store as preferencesStore } from '@wordpress/preferences';
12
12
  import { store as coreStore } from '@wordpress/core-data';
13
13
  import { store as noticesStore } from '@wordpress/notices';
14
+ import { useViewportMatch } from '@wordpress/compose';
14
15
  /**
15
16
  * Internal dependencies
16
17
  */
17
18
 
18
19
  import { unlock } from '../../lock-unlock';
19
20
  import { store as editSiteStore } from '../../store';
21
+ import getIsListPage from '../../utils/get-is-list-page';
20
22
  const {
21
23
  useGlobalStylesReset
22
24
  } = unlock(blockEditorPrivateApis);
23
25
  const {
24
- useHistory
26
+ useHistory,
27
+ useLocation
25
28
  } = unlock(routerPrivateApis);
26
29
 
27
30
  function useGlobalStylesResetCommands() {
@@ -52,8 +55,15 @@ function useGlobalStylesResetCommands() {
52
55
  function useGlobalStylesOpenCssCommands() {
53
56
  const {
54
57
  openGeneralSidebar,
55
- setEditorCanvasContainerView
58
+ setEditorCanvasContainerView,
59
+ setCanvasMode
56
60
  } = unlock(useDispatch(editSiteStore));
61
+ const {
62
+ params
63
+ } = useLocation();
64
+ const isMobileViewport = useViewportMatch('medium', '<');
65
+ const isListPage = getIsListPage(params, isMobileViewport);
66
+ const isEditorPage = !isListPage;
57
67
  const history = useHistory();
58
68
  const {
59
69
  canEditCSS
@@ -72,6 +82,9 @@ function useGlobalStylesOpenCssCommands() {
72
82
  canEditCSS: (_globalStyles$_links$ = !!globalStyles?._links?.['wp:action-edit-css']) !== null && _globalStyles$_links$ !== void 0 ? _globalStyles$_links$ : false
73
83
  };
74
84
  }, []);
85
+ const {
86
+ getCanvasMode
87
+ } = unlock(useSelect(editSiteStore));
75
88
  const commands = useMemo(() => {
76
89
  if (!canEditCSS) {
77
90
  return [];
@@ -85,15 +98,23 @@ function useGlobalStylesOpenCssCommands() {
85
98
  close
86
99
  }) => {
87
100
  close();
88
- history.push({
89
- path: '/wp_global_styles',
90
- canvas: 'edit'
91
- });
101
+
102
+ if (!isEditorPage) {
103
+ history.push({
104
+ path: '/wp_global_styles',
105
+ canvas: 'edit'
106
+ });
107
+ }
108
+
109
+ if (isEditorPage && getCanvasMode() !== 'edit') {
110
+ setCanvasMode('edit');
111
+ }
112
+
92
113
  openGeneralSidebar('edit-site/global-styles');
93
114
  setEditorCanvasContainerView('global-styles-css');
94
115
  }
95
116
  }];
96
- }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS]);
117
+ }, [history, openGeneralSidebar, setEditorCanvasContainerView, canEditCSS, isEditorPage, getCanvasMode, setCanvasMode]);
97
118
  return {
98
119
  isLoading: false,
99
120
  commands
@@ -103,8 +124,18 @@ function useGlobalStylesOpenCssCommands() {
103
124
  export function useCommonCommands() {
104
125
  const {
105
126
  openGeneralSidebar,
106
- setEditorCanvasContainerView
127
+ setEditorCanvasContainerView,
128
+ setCanvasMode
107
129
  } = unlock(useDispatch(editSiteStore));
130
+ const {
131
+ params
132
+ } = useLocation();
133
+ const isMobileViewport = useViewportMatch('medium', '<');
134
+ const isListPage = getIsListPage(params, isMobileViewport);
135
+ const isEditorPage = !isListPage;
136
+ const {
137
+ getCanvasMode
138
+ } = unlock(useSelect(editSiteStore));
108
139
  const {
109
140
  set
110
141
  } = useDispatch(preferencesStore);
@@ -133,10 +164,18 @@ export function useCommonCommands() {
133
164
  close
134
165
  }) => {
135
166
  close();
136
- history.push({
137
- path: '/wp_global_styles',
138
- canvas: 'edit'
139
- });
167
+
168
+ if (!isEditorPage) {
169
+ history.push({
170
+ path: '/wp_global_styles',
171
+ canvas: 'edit'
172
+ });
173
+ }
174
+
175
+ if (isEditorPage && getCanvasMode() !== 'edit') {
176
+ setCanvasMode('edit');
177
+ }
178
+
140
179
  openGeneralSidebar('edit-site/global-styles');
141
180
  setEditorCanvasContainerView('global-styles-revisions');
142
181
  }
@@ -148,10 +187,17 @@ export function useCommonCommands() {
148
187
  close
149
188
  }) => {
150
189
  close();
151
- history.push({
152
- path: '/wp_global_styles',
153
- canvas: 'edit'
154
- });
190
+
191
+ if (!isEditorPage) {
192
+ history.push({
193
+ path: '/wp_global_styles',
194
+ canvas: 'edit'
195
+ });
196
+ }
197
+
198
+ if (isEditorPage && getCanvasMode() !== 'edit') {
199
+ setCanvasMode('edit');
200
+ }
155
201
 
156
202
  if (isDistractionFree) {
157
203
  set(editSiteStore.name, 'distractionFree', false);
@@ -171,10 +217,18 @@ export function useCommonCommands() {
171
217
  close
172
218
  }) => {
173
219
  close();
174
- history.push({
175
- path: '/wp_global_styles',
176
- canvas: 'edit'
177
- });
220
+
221
+ if (!isEditorPage) {
222
+ history.push({
223
+ path: '/wp_global_styles',
224
+ canvas: 'edit'
225
+ });
226
+ }
227
+
228
+ if (isEditorPage && getCanvasMode() !== 'edit') {
229
+ setCanvasMode('edit');
230
+ }
231
+
178
232
  openGeneralSidebar('edit-site/global-styles');
179
233
  set('core/edit-site', 'welcomeGuideStyles', true); // sometimes there's a focus loss that happens after some time
180
234
  // that closes the modal, we need to force reopening it.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-common-commands.js"],"names":["useMemo","useDispatch","useSelect","__","trash","backup","help","styles","external","useCommandLoader","useCommand","privateApis","blockEditorPrivateApis","routerPrivateApis","store","preferencesStore","coreStore","noticesStore","unlock","editSiteStore","useGlobalStylesReset","useHistory","useGlobalStylesResetCommands","canReset","onReset","commands","name","label","icon","callback","close","isLoading","useGlobalStylesOpenCssCommands","openGeneralSidebar","setEditorCanvasContainerView","history","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","push","path","canvas","useCommonCommands","set","createInfoNotice","homeUrl","isDistractionFree","getUnstableBase","home","get","type","setTimeout","window","open","hook"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,EAAgBC,MAAhB,EAAwBC,IAAxB,EAA8BC,MAA9B,EAAsCC,QAAtC,QAAsD,kBAAtD;AACA,SAASC,gBAAT,EAA2BC,UAA3B,QAA6C,qBAA7C;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASD,WAAW,IAAIE,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AACA,SAASF,KAAK,IAAIG,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,mBAAvB;AACA,SAASJ,KAAK,IAAIK,aAAlB,QAAuC,aAAvC;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAA2BF,MAAM,C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,gBAAgB,CAAE;AACjBiB,IAAAA,IAAI,EAAE,gCADW;AAEjBiC,IAAAA,IAAI,EAAE3B;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { trash, backup, help, styles, external } from '@wordpress/icons';\nimport { useCommandLoader, useCommand } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\n\nconst { useGlobalStylesReset } = unlock( blockEditorPrivateApis );\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction useGlobalStylesResetCommands() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst commands = useMemo( () => {\n\t\tif ( ! canReset ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/reset-global-styles',\n\t\t\t\tlabel: __( 'Reset styles to defaults' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tonReset();\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ canReset, onReset ] );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nfunction useGlobalStylesOpenCssCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst history = useHistory();\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\n\tconst commands = useMemo( () => {\n\t\tif ( ! canEditCSS ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/open-styles-css',\n\t\t\t\tlabel: __( 'Open CSS' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\thistory.push( {\n\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t} );\n\t\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t\t\tsetEditorCanvasContainerView( 'global-styles-css' );\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [\n\t\thistory,\n\t\topenGeneralSidebar,\n\t\tsetEditorCanvasContainerView,\n\t\tcanEditCSS,\n\t] );\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useCommonCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView } = unlock(\n\t\tuseDispatch( editSiteStore )\n\t);\n\tconst { set } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst { homeUrl, isDistractionFree } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tisDistractionFree: select( preferencesStore ).get(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-global-styles-revisions',\n\t\tlabel: __( 'Open styles revisions' ),\n\t\ticon: backup,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tsetEditorCanvasContainerView( 'global-styles-revisions' );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-styles',\n\t\tlabel: __( 'Open styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\tset( editSiteStore.name, 'distractionFree', false );\n\t\t\t\tcreateInfoNotice( __( 'Distraction free mode turned off.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t},\n\t\ticon: styles,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/toggle-styles-welcome-guide',\n\t\tlabel: __( 'Learn about styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\thistory.push( {\n\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\tcanvas: 'edit',\n\t\t\t} );\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t// sometimes there's a focus loss that happens after some time\n\t\t\t// that closes the modal, we need to force reopening it.\n\t\t\tsetTimeout( () => {\n\t\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t}, 500 );\n\t\t},\n\t\ticon: help,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/view-site',\n\t\tlabel: __( 'View site' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\twindow.open( homeUrl, '_blank' );\n\t\t},\n\t\ticon: external,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/reset-global-styles',\n\t\thook: useGlobalStylesResetCommands,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/open-styles-css',\n\t\thook: useGlobalStylesOpenCssCommands,\n\t} );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-common-commands.js"],"names":["useMemo","useDispatch","useSelect","__","trash","backup","help","styles","external","useCommandLoader","useCommand","privateApis","blockEditorPrivateApis","routerPrivateApis","store","preferencesStore","coreStore","noticesStore","useViewportMatch","unlock","editSiteStore","getIsListPage","useGlobalStylesReset","useHistory","useLocation","useGlobalStylesResetCommands","canReset","onReset","commands","name","label","icon","callback","close","isLoading","useGlobalStylesOpenCssCommands","openGeneralSidebar","setEditorCanvasContainerView","setCanvasMode","params","isMobileViewport","isListPage","isEditorPage","history","canEditCSS","select","getEntityRecord","__experimentalGetCurrentGlobalStylesId","globalStylesId","globalStyles","undefined","_links","getCanvasMode","push","path","canvas","useCommonCommands","set","createInfoNotice","homeUrl","isDistractionFree","getUnstableBase","home","get","type","setTimeout","window","open","hook"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,EAAgBC,MAAhB,EAAwBC,IAAxB,EAA8BC,MAA9B,EAAsCC,QAAtC,QAAsD,kBAAtD;AACA,SAASC,gBAAT,EAA2BC,UAA3B,QAA6C,qBAA7C;AACA,SAASC,WAAW,IAAIC,sBAAxB,QAAsD,yBAAtD;AACA,SAASD,WAAW,IAAIE,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC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AA,QAAQ,EAAE,CAAE;AAAEC,MAAAA;AAAF,KAAF,KAAiB;AAC1BA,MAAAA,KAAK;AACLiC,MAAAA,MAAM,CAACC,IAAP,CAAaR,OAAb,EAAsB,QAAtB;AACA,KANU;AAOX5B,IAAAA,IAAI,EAAEvB;AAPK,GAAF,CAAV;AAUAC,EAAAA,gBAAgB,CAAE;AACjBoB,IAAAA,IAAI,EAAE,oCADW;AAEjBuC,IAAAA,IAAI,EAAE3C;AAFW,GAAF,CAAhB;AAKAhB,EAAAA,gBAAgB,CAAE;AACjBoB,IAAAA,IAAI,EAAE,gCADW;AAEjBuC,IAAAA,IAAI,EAAEjC;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { trash, backup, help, styles, external } from '@wordpress/icons';\nimport { useCommandLoader, useCommand } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editSiteStore } from '../../store';\nimport getIsListPage from '../../utils/get-is-list-page';\n\nconst { useGlobalStylesReset } = unlock( blockEditorPrivateApis );\nconst { useHistory, useLocation } = unlock( routerPrivateApis );\n\nfunction useGlobalStylesResetCommands() {\n\tconst [ canReset, onReset ] = useGlobalStylesReset();\n\tconst commands = useMemo( () => {\n\t\tif ( ! canReset ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/reset-global-styles',\n\t\t\t\tlabel: __( 'Reset styles to defaults' ),\n\t\t\t\ticon: trash,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tonReset();\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [ canReset, onReset ] );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nfunction useGlobalStylesOpenCssCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView, setCanvasMode } =\n\t\tunlock( useDispatch( editSiteStore ) );\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isListPage = getIsListPage( params, isMobileViewport );\n\tconst isEditorPage = ! isListPage;\n\tconst history = useHistory();\n\tconst { canEditCSS } = useSelect( ( select ) => {\n\t\tconst { getEntityRecord, __experimentalGetCurrentGlobalStylesId } =\n\t\t\tselect( coreStore );\n\n\t\tconst globalStylesId = __experimentalGetCurrentGlobalStylesId();\n\t\tconst globalStyles = globalStylesId\n\t\t\t? getEntityRecord( 'root', 'globalStyles', globalStylesId )\n\t\t\t: undefined;\n\n\t\treturn {\n\t\t\tcanEditCSS:\n\t\t\t\t!! globalStyles?._links?.[ 'wp:action-edit-css' ] ?? false,\n\t\t};\n\t}, [] );\n\tconst { getCanvasMode } = unlock( useSelect( editSiteStore ) );\n\n\tconst commands = useMemo( () => {\n\t\tif ( ! canEditCSS ) {\n\t\t\treturn [];\n\t\t}\n\n\t\treturn [\n\t\t\t{\n\t\t\t\tname: 'core/edit-site/open-styles-css',\n\t\t\t\tlabel: __( 'Open CSS' ),\n\t\t\t\ticon: styles,\n\t\t\t\tcallback: ( { close } ) => {\n\t\t\t\t\tclose();\n\t\t\t\t\tif ( ! isEditorPage ) {\n\t\t\t\t\t\thistory.push( {\n\t\t\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t\t\t}\n\t\t\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\t\t\tsetEditorCanvasContainerView( 'global-styles-css' );\n\t\t\t\t},\n\t\t\t},\n\t\t];\n\t}, [\n\t\thistory,\n\t\topenGeneralSidebar,\n\t\tsetEditorCanvasContainerView,\n\t\tcanEditCSS,\n\t\tisEditorPage,\n\t\tgetCanvasMode,\n\t\tsetCanvasMode,\n\t] );\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useCommonCommands() {\n\tconst { openGeneralSidebar, setEditorCanvasContainerView, setCanvasMode } =\n\t\tunlock( useDispatch( editSiteStore ) );\n\tconst { params } = useLocation();\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst isListPage = getIsListPage( params, isMobileViewport );\n\tconst isEditorPage = ! isListPage;\n\tconst { getCanvasMode } = unlock( useSelect( editSiteStore ) );\n\tconst { set } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst history = useHistory();\n\tconst { homeUrl, isDistractionFree } = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetUnstableBase, // Site index.\n\t\t} = select( coreStore );\n\n\t\treturn {\n\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\tisDistractionFree: select( preferencesStore ).get(\n\t\t\t\teditSiteStore.name,\n\t\t\t\t'distractionFree'\n\t\t\t),\n\t\t};\n\t}, [] );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-global-styles-revisions',\n\t\tlabel: __( 'Open styles revisions' ),\n\t\ticon: backup,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tsetEditorCanvasContainerView( 'global-styles-revisions' );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/open-styles',\n\t\tlabel: __( 'Open styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\tset( editSiteStore.name, 'distractionFree', false );\n\t\t\t\tcreateInfoNotice( __( 'Distraction free mode turned off.' ), {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t},\n\t\ticon: styles,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/toggle-styles-welcome-guide',\n\t\tlabel: __( 'Learn about styles' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( ! isEditorPage ) {\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/wp_global_styles',\n\t\t\t\t\tcanvas: 'edit',\n\t\t\t\t} );\n\t\t\t}\n\t\t\tif ( isEditorPage && getCanvasMode() !== 'edit' ) {\n\t\t\t\tsetCanvasMode( 'edit' );\n\t\t\t}\n\t\t\topenGeneralSidebar( 'edit-site/global-styles' );\n\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t// sometimes there's a focus loss that happens after some time\n\t\t\t// that closes the modal, we need to force reopening it.\n\t\t\tsetTimeout( () => {\n\t\t\t\tset( 'core/edit-site', 'welcomeGuideStyles', true );\n\t\t\t}, 500 );\n\t\t},\n\t\ticon: help,\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/edit-site/view-site',\n\t\tlabel: __( 'View site' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\twindow.open( homeUrl, '_blank' );\n\t\t},\n\t\ticon: external,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/reset-global-styles',\n\t\thook: useGlobalStylesResetCommands,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/open-styles-css',\n\t\thook: useGlobalStylesOpenCssCommands,\n\t} );\n}\n"]}
@@ -2732,7 +2732,7 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
2732
2732
  justify-content: center;
2733
2733
  align-items: center;
2734
2734
  }
2735
- .edit-site-layout__canvas:has(.edit-site-layout__resizable-frame-oversized) {
2735
+ .edit-site-layout__canvas.is-right-aligned {
2736
2736
  justify-content: flex-end;
2737
2737
  }
2738
2738
  .edit-site-layout__canvas > div {
@@ -3364,8 +3364,13 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3364
3364
  .edit-site-site-hub .edit-site-site-hub_toggle-command-center {
3365
3365
  transition: opacity ease 0.1s;
3366
3366
  }
3367
+ .edit-site-site-hub .edit-site-site-hub__site-title.is-transparent,
3368
+ .edit-site-site-hub .edit-site-site-hub_toggle-command-center.is-transparent {
3369
+ opacity: 0 !important;
3370
+ }
3367
3371
  .edit-site-site-hub .edit-site-site-hub__site-view-link {
3368
3372
  flex-grow: 0;
3373
+ margin-left: var(--wp-admin-border-width-focus);
3369
3374
  }
3370
3375
  @media (min-width: 480px) {
3371
3376
  .edit-site-site-hub .edit-site-site-hub__site-view-link {
@@ -3374,8 +3379,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3374
3379
  }
3375
3380
  }
3376
3381
  .edit-site-site-hub .edit-site-site-hub__site-view-link:focus {
3377
- outline: none;
3378
- box-shadow: none;
3379
3382
  opacity: 1;
3380
3383
  }
3381
3384
  .edit-site-site-hub .edit-site-site-hub__site-view-link svg {
@@ -3395,6 +3398,9 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3395
3398
  flex-shrink: 0;
3396
3399
  background: #1e1e1e;
3397
3400
  }
3401
+ .edit-site-site-hub__view-mode-toggle-container.has-transparent-background {
3402
+ background: transparent;
3403
+ }
3398
3404
 
3399
3405
  .edit-site-site-hub__text-content {
3400
3406
  overflow: hidden;
@@ -3563,14 +3569,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3563
3569
  .edit-site-resizable-frame__inner {
3564
3570
  position: relative;
3565
3571
  }
3566
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub__site-title,
3567
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub_toggle-command-center {
3568
- opacity: 0 !important;
3569
- }
3570
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub__view-mode-toggle-container {
3571
- background-color: transparent;
3572
- }
3573
-
3574
3572
  body:has(.edit-site-resizable-frame__inner.is-resizing) {
3575
3573
  cursor: col-resize;
3576
3574
  user-select: none;
@@ -2733,7 +2733,7 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
2733
2733
  justify-content: center;
2734
2734
  align-items: center;
2735
2735
  }
2736
- .edit-site-layout__canvas:has(.edit-site-layout__resizable-frame-oversized) {
2736
+ .edit-site-layout__canvas.is-right-aligned {
2737
2737
  justify-content: flex-end;
2738
2738
  }
2739
2739
  .edit-site-layout__canvas > div {
@@ -3365,8 +3365,13 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3365
3365
  .edit-site-site-hub .edit-site-site-hub_toggle-command-center {
3366
3366
  transition: opacity ease 0.1s;
3367
3367
  }
3368
+ .edit-site-site-hub .edit-site-site-hub__site-title.is-transparent,
3369
+ .edit-site-site-hub .edit-site-site-hub_toggle-command-center.is-transparent {
3370
+ opacity: 0 !important;
3371
+ }
3368
3372
  .edit-site-site-hub .edit-site-site-hub__site-view-link {
3369
3373
  flex-grow: 0;
3374
+ margin-right: var(--wp-admin-border-width-focus);
3370
3375
  }
3371
3376
  @media (min-width: 480px) {
3372
3377
  .edit-site-site-hub .edit-site-site-hub__site-view-link {
@@ -3375,8 +3380,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3375
3380
  }
3376
3381
  }
3377
3382
  .edit-site-site-hub .edit-site-site-hub__site-view-link:focus {
3378
- outline: none;
3379
- box-shadow: none;
3380
3383
  opacity: 1;
3381
3384
  }
3382
3385
  .edit-site-site-hub .edit-site-site-hub__site-view-link svg {
@@ -3396,6 +3399,9 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3396
3399
  flex-shrink: 0;
3397
3400
  background: #1e1e1e;
3398
3401
  }
3402
+ .edit-site-site-hub__view-mode-toggle-container.has-transparent-background {
3403
+ background: transparent;
3404
+ }
3399
3405
 
3400
3406
  .edit-site-site-hub__text-content {
3401
3407
  overflow: hidden;
@@ -3564,14 +3570,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
3564
3570
  .edit-site-resizable-frame__inner {
3565
3571
  position: relative;
3566
3572
  }
3567
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub__site-title,
3568
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub_toggle-command-center {
3569
- opacity: 0 !important;
3570
- }
3571
- body:has(.edit-site-resizable-frame__inner.edit-site-layout__resizable-frame-oversized) .edit-site-site-hub .edit-site-site-hub__view-mode-toggle-container {
3572
- background-color: transparent;
3573
- }
3574
-
3575
3573
  body:has(.edit-site-resizable-frame__inner.is-resizing) {
3576
3574
  cursor: col-resize;
3577
3575
  user-select: none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "5.12.10",
3
+ "version": "5.12.11",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -29,19 +29,19 @@
29
29
  "@babel/runtime": "^7.16.0",
30
30
  "@wordpress/a11y": "^3.35.1",
31
31
  "@wordpress/api-fetch": "^6.32.1",
32
- "@wordpress/block-editor": "^12.3.8",
33
- "@wordpress/block-library": "^8.12.10",
34
- "@wordpress/blocks": "^12.12.4",
32
+ "@wordpress/block-editor": "^12.3.9",
33
+ "@wordpress/block-library": "^8.12.11",
34
+ "@wordpress/blocks": "^12.12.5",
35
35
  "@wordpress/commands": "^0.6.8",
36
36
  "@wordpress/components": "^25.1.8",
37
37
  "@wordpress/compose": "^6.12.1",
38
- "@wordpress/core-commands": "^0.4.8",
39
- "@wordpress/core-data": "^6.12.8",
38
+ "@wordpress/core-commands": "^0.4.9",
39
+ "@wordpress/core-data": "^6.12.9",
40
40
  "@wordpress/data": "^9.5.4",
41
41
  "@wordpress/date": "^4.35.1",
42
42
  "@wordpress/deprecated": "^3.35.1",
43
43
  "@wordpress/dom": "^3.35.1",
44
- "@wordpress/editor": "^13.12.8",
44
+ "@wordpress/editor": "^13.12.9",
45
45
  "@wordpress/element": "^5.12.1",
46
46
  "@wordpress/escape-html": "^2.35.1",
47
47
  "@wordpress/hooks": "^3.35.1",
@@ -57,12 +57,12 @@
57
57
  "@wordpress/preferences": "^3.12.8",
58
58
  "@wordpress/primitives": "^3.33.1",
59
59
  "@wordpress/private-apis": "^0.17.2",
60
- "@wordpress/reusable-blocks": "^4.12.8",
60
+ "@wordpress/reusable-blocks": "^4.12.9",
61
61
  "@wordpress/router": "^0.4.2",
62
62
  "@wordpress/style-engine": "^1.18.1",
63
63
  "@wordpress/url": "^3.36.1",
64
64
  "@wordpress/viewport": "^5.12.4",
65
- "@wordpress/widgets": "^3.12.8",
65
+ "@wordpress/widgets": "^3.12.9",
66
66
  "@wordpress/wordcount": "^3.35.1",
67
67
  "change-case": "^4.1.2",
68
68
  "classnames": "^2.3.1",
@@ -84,5 +84,5 @@
84
84
  "publishConfig": {
85
85
  "access": "public"
86
86
  },
87
- "gitHead": "cedb8caa943db47c16bdb4fa8880d506ce938fab"
87
+ "gitHead": "ec0ed708e46a598ab2cf8e18bf2591b0102b5bb3"
88
88
  }
@@ -21,11 +21,9 @@ function getRevisionLabel( revision ) {
21
21
 
22
22
  if ( 'unsaved' === revision?.id ) {
23
23
  return sprintf(
24
- /* translators: %(name)s author display name */
25
- __( 'Unsaved changes by %(name)s' ),
26
- {
27
- name: authorDisplayName,
28
- }
24
+ /* translators: %s author display name */
25
+ __( 'Unsaved changes by %s' ),
26
+ authorDisplayName
29
27
  );
30
28
  }
31
29
  const formattedDate = dateI18n(
@@ -35,20 +33,16 @@ function getRevisionLabel( revision ) {
35
33
 
36
34
  return revision?.isLatest
37
35
  ? sprintf(
38
- /* translators: %(name)s author display name, %(date)s: revision creation date */
39
- __( 'Changes saved by %(name)s on %(date)s (current)' ),
40
- {
41
- name: authorDisplayName,
42
- date: formattedDate,
43
- }
36
+ /* translators: %1$s author display name, %2$s: revision creation date */
37
+ __( 'Changes saved by %1$s on %2$s (current)' ),
38
+ authorDisplayName,
39
+ formattedDate
44
40
  )
45
41
  : sprintf(
46
- /* translators: %(name)s author display name, %(date)s: revision creation date */
47
- __( 'Changes saved by %(name)s on %(date)s' ),
48
- {
49
- name: authorDisplayName,
50
- date: formattedDate,
51
- }
42
+ /* translators: %1$s author display name, %2$s: revision creation date */
43
+ __( 'Changes saved by %1$s on %2$s' ),
44
+ authorDisplayName,
45
+ formattedDate
52
46
  );
53
47
  }
54
48
 
@@ -104,22 +98,14 @@ function RevisionsButtons( { userRevisions, selectedRevisionId, onChange } ) {
104
98
  <span className="edit-site-global-styles-screen-revisions__meta">
105
99
  { isUnsaved
106
100
  ? sprintf(
107
- /* translators: %(name)s author display name */
108
- __(
109
- 'Unsaved changes by %(name)s'
110
- ),
111
- {
112
- name: authorDisplayName,
113
- }
101
+ /* translators: %s author display name */
102
+ __( 'Unsaved changes by %s' ),
103
+ authorDisplayName
114
104
  )
115
105
  : sprintf(
116
- /* translators: %(name)s author display name */
117
- __(
118
- 'Changes saved by %(name)s'
119
- ),
120
- {
121
- name: authorDisplayName,
122
- }
106
+ /* translators: %s author display name */
107
+ __( 'Changes saved by %s' ),
108
+ authorDisplayName
123
109
  ) }
124
110
 
125
111
  <img
@@ -121,6 +121,8 @@ export default function Layout() {
121
121
  const [ fullResizer ] = useResizeObserver();
122
122
  const [ isResizing ] = useState( false );
123
123
  const isEditorLoading = useIsSiteEditorLoading();
124
+ const [ isResizableFrameOversized, setIsResizableFrameOversized ] =
125
+ useState( false );
124
126
 
125
127
  // This determines which animation variant should apply to the header.
126
128
  // There is also a `isDistractionFreeHovering` state that gets priority
@@ -218,6 +220,7 @@ export default function Layout() {
218
220
  edit: { x: 0 },
219
221
  } }
220
222
  ref={ hubRef }
223
+ isTransparent={ isResizableFrameOversized }
221
224
  className="edit-site-layout__hub"
222
225
  />
223
226
 
@@ -315,7 +318,13 @@ export default function Layout() {
315
318
  }
316
319
  initial={ false }
317
320
  layout="position"
318
- className="edit-site-layout__canvas"
321
+ className={ classnames(
322
+ 'edit-site-layout__canvas',
323
+ {
324
+ 'is-right-aligned':
325
+ isResizableFrameOversized,
326
+ }
327
+ ) }
319
328
  transition={ {
320
329
  type: 'tween',
321
330
  duration:
@@ -331,7 +340,12 @@ export default function Layout() {
331
340
  ! isEditorLoading
332
341
  }
333
342
  isFullWidth={ isEditing }
334
- oversizedClassName="edit-site-layout__resizable-frame-oversized"
343
+ isOversized={
344
+ isResizableFrameOversized
345
+ }
346
+ setIsOversized={
347
+ setIsResizableFrameOversized
348
+ }
335
349
  innerContentStyle={ {
336
350
  background:
337
351
  gradientValue ??
@@ -121,7 +121,7 @@
121
121
  justify-content: center;
122
122
  align-items: center;
123
123
 
124
- &:has(.edit-site-layout__resizable-frame-oversized) {
124
+ &.is-right-aligned {
125
125
  justify-content: flex-end;
126
126
  }
127
127
 
@@ -27,7 +27,7 @@ import usePatterns from './use-patterns';
27
27
  import SidebarButton from '../sidebar-button';
28
28
  import useDebouncedInput from '../../utils/use-debounced-input';
29
29
  import { unlock } from '../../lock-unlock';
30
- import { SYNC_TYPES, USER_PATTERN_CATEGORY } from './utils';
30
+ import { SYNC_TYPES, USER_PATTERN_CATEGORY, PATTERNS } from './utils';
31
31
 
32
32
  const { useLocation, useHistory } = unlock( routerPrivateApis );
33
33
 
@@ -58,9 +58,12 @@ export default function PatternsList( { categoryId, type } ) {
58
58
  const [ syncFilter, setSyncFilter ] = useState( 'all' );
59
59
  const deferredSyncedFilter = useDeferredValue( syncFilter );
60
60
 
61
+ const isUncategorizedThemePatterns =
62
+ type === PATTERNS && categoryId === 'uncategorized';
63
+
61
64
  const { patterns, isResolving } = usePatterns(
62
65
  type,
63
- categoryId !== 'uncategorized' ? categoryId : '',
66
+ isUncategorizedThemePatterns ? '' : categoryId,
64
67
  {
65
68
  search: deferredFilterValue,
66
69
  syncStatus:
@@ -86,6 +86,7 @@ const selectThemePatterns = ( select, { categoryId, search = '' } = {} ) => {
86
86
  ( pattern ) => ! CORE_PATTERN_SOURCES.includes( pattern.source )
87
87
  )
88
88
  .filter( filterOutDuplicatesByName )
89
+ .filter( ( pattern ) => pattern.inserter !== false )
89
90
  .map( ( pattern ) => ( {
90
91
  ...pattern,
91
92
  keywords: pattern.keywords || [],
@@ -78,9 +78,10 @@ function calculateNewHeight( width, initialAspectRatio ) {
78
78
 
79
79
  function ResizableFrame( {
80
80
  isFullWidth,
81
+ isOversized,
82
+ setIsOversized,
81
83
  isReady,
82
84
  children,
83
- oversizedClassName,
84
85
  innerContentStyle,
85
86
  } ) {
86
87
  const [ frameSize, setFrameSize ] = useState( INITIAL_FRAME_SIZE );
@@ -88,7 +89,6 @@ function ResizableFrame( {
88
89
  const [ startingWidth, setStartingWidth ] = useState();
89
90
  const [ isResizing, setIsResizing ] = useState( false );
90
91
  const [ shouldShowHandle, setShouldShowHandle ] = useState( false );
91
- const [ isOversized, setIsOversized ] = useState( false );
92
92
  const [ resizeRatio, setResizeRatio ] = useState( 1 );
93
93
  const canvasMode = useSelect(
94
94
  ( select ) => unlock( select( editSiteStore ) ).getCanvasMode(),
@@ -314,7 +314,6 @@ function ResizableFrame( {
314
314
  onResizeStop={ handleResizeStop }
315
315
  className={ classnames( 'edit-site-resizable-frame__inner', {
316
316
  'is-resizing': isResizing,
317
- [ oversizedClassName ]: isOversized,
318
317
  } ) }
319
318
  >
320
319
  <motion.div
@@ -1,23 +1,6 @@
1
1
  .edit-site-resizable-frame__inner {
2
2
  position: relative;
3
3
 
4
- &.edit-site-layout__resizable-frame-oversized {
5
- @at-root {
6
- body:has(&) {
7
- .edit-site-site-hub {
8
- .edit-site-site-hub__site-title,
9
- .edit-site-site-hub_toggle-command-center {
10
- opacity: 0 !important;
11
- }
12
-
13
- .edit-site-site-hub__view-mode-toggle-container {
14
- background-color: transparent;
15
- }
16
- }
17
- }
18
- }
19
- }
20
-
21
4
  &.is-resizing {
22
5
  @at-root {
23
6
  body:has(&) {
@@ -212,11 +212,8 @@ export default function PageStatus( {
212
212
  } )
213
213
  }
214
214
  value={ password }
215
- /* eslint-disable jsx-a11y/no-autofocus */
216
- autoFocus={ ! password }
217
- /* eslint-enable jsx-a11y/no-autofocus */
218
215
  placeholder={ __(
219
- 'Enter a secure password'
216
+ 'Use a secure password'
220
217
  ) }
221
218
  type="text"
222
219
  />
@@ -36,7 +36,8 @@ export default function useThemePatterns() {
36
36
  ( pattern ) =>
37
37
  ! CORE_PATTERN_SOURCES.includes( pattern.source )
38
38
  )
39
- .filter( filterOutDuplicatesByName ),
39
+ .filter( filterOutDuplicatesByName )
40
+ .filter( ( pattern ) => pattern.inserter !== false ),
40
41
  [ blockPatterns, restBlockPatterns ]
41
42
  );
42
43