@wordpress/edit-site 3.0.27 → 4.0.1-next.f435e9e01b.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (240) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +7 -1
  4. package/build/components/add-new-template/new-template-part.js +1 -4
  5. package/build/components/add-new-template/new-template-part.js.map +1 -1
  6. package/build/components/block-editor/resizable-editor.js +1 -0
  7. package/build/components/block-editor/resizable-editor.js.map +1 -1
  8. package/build/components/code-editor/code-editor-text-area.js +95 -0
  9. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  10. package/build/components/code-editor/index.js +79 -0
  11. package/build/components/code-editor/index.js.map +1 -0
  12. package/build/components/editor/index.js +28 -8
  13. package/build/components/editor/index.js.map +1 -1
  14. package/build/components/error-boundary/index.js +27 -11
  15. package/build/components/error-boundary/index.js.map +1 -1
  16. package/build/components/global-styles/border-panel.js +81 -22
  17. package/build/components/global-styles/border-panel.js.map +1 -1
  18. package/build/components/global-styles/context-menu.js +4 -6
  19. package/build/components/global-styles/context-menu.js.map +1 -1
  20. package/build/components/global-styles/global-styles-provider.js +1 -0
  21. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  22. package/build/components/global-styles/header.js +2 -7
  23. package/build/components/global-styles/header.js.map +1 -1
  24. package/build/components/global-styles/navigation-button.js +35 -12
  25. package/build/components/global-styles/navigation-button.js.map +1 -1
  26. package/build/components/global-styles/palette.js +3 -3
  27. package/build/components/global-styles/palette.js.map +1 -1
  28. package/build/components/global-styles/preview.js +46 -15
  29. package/build/components/global-styles/preview.js.map +1 -1
  30. package/build/components/global-styles/screen-background-color.js +1 -3
  31. package/build/components/global-styles/screen-background-color.js.map +1 -1
  32. package/build/components/global-styles/screen-block-list.js +2 -3
  33. package/build/components/global-styles/screen-block-list.js.map +1 -1
  34. package/build/components/global-styles/screen-block.js +0 -1
  35. package/build/components/global-styles/screen-block.js.map +1 -1
  36. package/build/components/global-styles/screen-color-palette.js +0 -2
  37. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  38. package/build/components/global-styles/screen-colors.js +5 -6
  39. package/build/components/global-styles/screen-colors.js.map +1 -1
  40. package/build/components/global-styles/screen-layout.js +0 -2
  41. package/build/components/global-styles/screen-layout.js.map +1 -1
  42. package/build/components/global-styles/screen-link-color.js +0 -2
  43. package/build/components/global-styles/screen-link-color.js.map +1 -1
  44. package/build/components/global-styles/screen-root.js +22 -3
  45. package/build/components/global-styles/screen-root.js.map +1 -1
  46. package/build/components/global-styles/screen-style-variations.js +138 -0
  47. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  48. package/build/components/global-styles/screen-text-color.js +0 -2
  49. package/build/components/global-styles/screen-text-color.js.map +1 -1
  50. package/build/components/global-styles/screen-typography-element.js +0 -2
  51. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  52. package/build/components/global-styles/screen-typography.js +2 -3
  53. package/build/components/global-styles/screen-typography.js.map +1 -1
  54. package/build/components/global-styles/ui.js +31 -14
  55. package/build/components/global-styles/ui.js.map +1 -1
  56. package/build/components/header/index.js +12 -4
  57. package/build/components/header/index.js.map +1 -1
  58. package/build/components/header/mode-switcher/index.js +78 -0
  59. package/build/components/header/mode-switcher/index.js.map +1 -0
  60. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  61. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  62. package/build/components/header/more-menu/index.js +6 -2
  63. package/build/components/header/more-menu/index.js.map +1 -1
  64. package/build/components/keyboard-shortcuts/index.js +17 -1
  65. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  66. package/build/components/list/actions/index.js +5 -4
  67. package/build/components/list/actions/index.js.map +1 -1
  68. package/build/components/list/actions/rename-menu-item.js +3 -3
  69. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  70. package/build/components/routes/redirect-to-homepage.js +3 -22
  71. package/build/components/routes/redirect-to-homepage.js.map +1 -1
  72. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  73. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  74. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  75. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  76. package/build/components/sidebar/default-sidebar.js +4 -2
  77. package/build/components/sidebar/default-sidebar.js.map +1 -1
  78. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  79. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  80. package/build/components/template-part-converter/convert-to-template-part.js +1 -4
  81. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  82. package/build/index.js +2 -16
  83. package/build/index.js.map +1 -1
  84. package/build/store/actions.js +29 -9
  85. package/build/store/actions.js.map +1 -1
  86. package/build/store/defaults.js +2 -1
  87. package/build/store/defaults.js.map +1 -1
  88. package/build/store/reducer.js +11 -0
  89. package/build/store/reducer.js.map +1 -1
  90. package/build/store/selectors.js +13 -0
  91. package/build/store/selectors.js.map +1 -1
  92. package/build-module/components/add-new-template/new-template-part.js +1 -4
  93. package/build-module/components/add-new-template/new-template-part.js.map +1 -1
  94. package/build-module/components/block-editor/resizable-editor.js +1 -0
  95. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  96. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  97. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  98. package/build-module/components/code-editor/index.js +62 -0
  99. package/build-module/components/code-editor/index.js.map +1 -0
  100. package/build-module/components/editor/index.js +27 -9
  101. package/build-module/components/editor/index.js.map +1 -1
  102. package/build-module/components/error-boundary/index.js +26 -9
  103. package/build-module/components/error-boundary/index.js.map +1 -1
  104. package/build-module/components/global-styles/border-panel.js +82 -23
  105. package/build-module/components/global-styles/border-panel.js.map +1 -1
  106. package/build-module/components/global-styles/context-menu.js +1 -1
  107. package/build-module/components/global-styles/context-menu.js.map +1 -1
  108. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  109. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  110. package/build-module/components/global-styles/header.js +2 -5
  111. package/build-module/components/global-styles/header.js.map +1 -1
  112. package/build-module/components/global-styles/navigation-button.js +35 -10
  113. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  114. package/build-module/components/global-styles/palette.js +2 -2
  115. package/build-module/components/global-styles/palette.js.map +1 -1
  116. package/build-module/components/global-styles/preview.js +45 -15
  117. package/build-module/components/global-styles/preview.js.map +1 -1
  118. package/build-module/components/global-styles/screen-background-color.js +1 -3
  119. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  120. package/build-module/components/global-styles/screen-block-list.js +1 -2
  121. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  122. package/build-module/components/global-styles/screen-block.js +0 -1
  123. package/build-module/components/global-styles/screen-block.js.map +1 -1
  124. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  125. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  126. package/build-module/components/global-styles/screen-colors.js +2 -3
  127. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  128. package/build-module/components/global-styles/screen-layout.js +0 -2
  129. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  130. package/build-module/components/global-styles/screen-link-color.js +0 -2
  131. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  132. package/build-module/components/global-styles/screen-root.js +21 -4
  133. package/build-module/components/global-styles/screen-root.js.map +1 -1
  134. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  135. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  136. package/build-module/components/global-styles/screen-text-color.js +0 -2
  137. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  138. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  139. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  140. package/build-module/components/global-styles/screen-typography.js +1 -2
  141. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  142. package/build-module/components/global-styles/ui.js +29 -14
  143. package/build-module/components/global-styles/ui.js.map +1 -1
  144. package/build-module/components/header/index.js +13 -5
  145. package/build-module/components/header/index.js.map +1 -1
  146. package/build-module/components/header/mode-switcher/index.js +65 -0
  147. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  148. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  149. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  150. package/build-module/components/header/more-menu/index.js +4 -2
  151. package/build-module/components/header/more-menu/index.js.map +1 -1
  152. package/build-module/components/keyboard-shortcuts/index.js +17 -1
  153. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  154. package/build-module/components/list/actions/index.js +5 -4
  155. package/build-module/components/list/actions/index.js.map +1 -1
  156. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  157. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  158. package/build-module/components/routes/redirect-to-homepage.js +3 -22
  159. package/build-module/components/routes/redirect-to-homepage.js.map +1 -1
  160. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  161. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  162. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  163. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  164. package/build-module/components/sidebar/default-sidebar.js +4 -2
  165. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  166. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  167. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  168. package/build-module/components/template-part-converter/convert-to-template-part.js +1 -4
  169. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  170. package/build-module/index.js +2 -14
  171. package/build-module/index.js.map +1 -1
  172. package/build-module/store/actions.js +25 -9
  173. package/build-module/store/actions.js.map +1 -1
  174. package/build-module/store/defaults.js +2 -1
  175. package/build-module/store/defaults.js.map +1 -1
  176. package/build-module/store/reducer.js +11 -0
  177. package/build-module/store/reducer.js.map +1 -1
  178. package/build-module/store/selectors.js +11 -0
  179. package/build-module/store/selectors.js.map +1 -1
  180. package/build-style/style-rtl.css +148 -68
  181. package/build-style/style.css +148 -68
  182. package/package.json +28 -30
  183. package/src/components/add-new-template/new-template-part.js +1 -7
  184. package/src/components/block-editor/resizable-editor.js +1 -0
  185. package/src/components/block-editor/style.scss +10 -18
  186. package/src/components/code-editor/code-editor-text-area.js +79 -0
  187. package/src/components/code-editor/index.js +65 -0
  188. package/src/components/code-editor/style.scss +100 -0
  189. package/src/components/editor/index.js +41 -10
  190. package/src/components/error-boundary/index.js +28 -11
  191. package/src/components/global-styles/border-panel.js +106 -42
  192. package/src/components/global-styles/context-menu.js +1 -1
  193. package/src/components/global-styles/global-styles-provider.js +1 -2
  194. package/src/components/global-styles/header.js +3 -5
  195. package/src/components/global-styles/navigation-button.js +31 -10
  196. package/src/components/global-styles/palette.js +6 -2
  197. package/src/components/global-styles/preview.js +46 -18
  198. package/src/components/global-styles/screen-background-color.js +1 -3
  199. package/src/components/global-styles/screen-block-list.js +1 -2
  200. package/src/components/global-styles/screen-block.js +1 -1
  201. package/src/components/global-styles/screen-color-palette.js +0 -2
  202. package/src/components/global-styles/screen-colors.js +2 -3
  203. package/src/components/global-styles/screen-layout.js +1 -5
  204. package/src/components/global-styles/screen-link-color.js +0 -2
  205. package/src/components/global-styles/screen-root.js +32 -3
  206. package/src/components/global-styles/screen-style-variations.js +130 -0
  207. package/src/components/global-styles/screen-text-color.js +0 -2
  208. package/src/components/global-styles/screen-typography-element.js +0 -4
  209. package/src/components/global-styles/screen-typography.js +2 -3
  210. package/src/components/global-styles/style.scss +24 -25
  211. package/src/components/global-styles/ui.js +55 -25
  212. package/src/components/header/document-actions/style.scss +1 -9
  213. package/src/components/header/index.js +10 -2
  214. package/src/components/header/mode-switcher/index.js +67 -0
  215. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  216. package/src/components/header/more-menu/index.js +4 -0
  217. package/src/components/header/style.scss +2 -1
  218. package/src/components/keyboard-shortcuts/index.js +17 -1
  219. package/src/components/list/actions/index.js +5 -4
  220. package/src/components/list/actions/rename-menu-item.js +3 -3
  221. package/src/components/routes/redirect-to-homepage.js +4 -27
  222. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  223. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  224. package/src/components/secondary-sidebar/style.scss +0 -4
  225. package/src/components/sidebar/default-sidebar.js +2 -0
  226. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  227. package/src/components/sidebar/style.scss +21 -14
  228. package/src/components/template-part-converter/convert-to-template-part.js +1 -6
  229. package/src/index.js +2 -18
  230. package/src/store/actions.js +25 -10
  231. package/src/store/defaults.js +1 -0
  232. package/src/store/reducer.js +6 -0
  233. package/src/store/selectors.js +11 -0
  234. package/src/store/test/actions.js +2 -2
  235. package/src/style.scss +1 -0
  236. package/build/components/error-boundary/warning.js +0 -70
  237. package/build/components/error-boundary/warning.js.map +0 -1
  238. package/build-module/components/error-boundary/warning.js +0 -60
  239. package/build-module/components/error-boundary/warning.js.map +0 -1
  240. package/src/components/error-boundary/warning.js +0 -59
@@ -0,0 +1,130 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { isEqual } from 'lodash';
5
+ import classnames from 'classnames';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+ import { useSelect } from '@wordpress/data';
12
+ import { useMemo, useContext } from '@wordpress/element';
13
+ import { ENTER } from '@wordpress/keycodes';
14
+ import {
15
+ __experimentalGrid as Grid,
16
+ Card,
17
+ CardBody,
18
+ } from '@wordpress/components';
19
+ import { __ } from '@wordpress/i18n';
20
+
21
+ /**
22
+ * Internal dependencies
23
+ */
24
+ import { mergeBaseAndUserConfigs } from './global-styles-provider';
25
+ import { GlobalStylesContext } from './context';
26
+ import StylesPreview from './preview';
27
+ import ScreenHeader from './header';
28
+
29
+ function compareVariations( a, b ) {
30
+ return isEqual( a.styles, b.styles ) && isEqual( a.settings, b.settings );
31
+ }
32
+
33
+ function Variation( { variation } ) {
34
+ const { base, user, setUserConfig } = useContext( GlobalStylesContext );
35
+ const context = useMemo( () => {
36
+ return {
37
+ user: {
38
+ settings: variation.settings ?? {},
39
+ styles: variation.styles ?? {},
40
+ },
41
+ base,
42
+ merged: mergeBaseAndUserConfigs( base, variation ),
43
+ setUserConfig: () => {},
44
+ };
45
+ }, [ variation, base ] );
46
+
47
+ const selectVariation = () => {
48
+ setUserConfig( () => {
49
+ return {
50
+ settings: variation.settings,
51
+ styles: variation.styles,
52
+ };
53
+ } );
54
+ };
55
+
56
+ const selectOnEnter = ( event ) => {
57
+ if ( event.keyCode === ENTER ) {
58
+ event.preventDefault();
59
+ selectVariation();
60
+ }
61
+ };
62
+
63
+ const isActive = useMemo( () => {
64
+ return compareVariations( user, variation );
65
+ }, [ user, variation ] );
66
+
67
+ return (
68
+ <GlobalStylesContext.Provider value={ context }>
69
+ <div
70
+ className={ classnames(
71
+ 'edit-site-global-styles-variations_item',
72
+ {
73
+ 'is-active': isActive,
74
+ }
75
+ ) }
76
+ role="button"
77
+ onClick={ selectVariation }
78
+ onKeyDown={ selectOnEnter }
79
+ tabIndex="0"
80
+ >
81
+ <StylesPreview height={ 100 } />
82
+ </div>
83
+ </GlobalStylesContext.Provider>
84
+ );
85
+ }
86
+
87
+ function ScreenStyleVariations() {
88
+ const { variations } = useSelect( ( select ) => {
89
+ return {
90
+ variations: select(
91
+ coreStore
92
+ ).__experimentalGetCurrentThemeGlobalStylesVariations(),
93
+ };
94
+ }, [] );
95
+
96
+ const withEmptyVariation = useMemo( () => {
97
+ return [
98
+ {
99
+ name: __( 'Default' ),
100
+ settings: {},
101
+ styles: {},
102
+ },
103
+ ...variations,
104
+ ];
105
+ }, [ variations ] );
106
+
107
+ return (
108
+ <>
109
+ <ScreenHeader
110
+ back="/"
111
+ title={ __( 'Other styles' ) }
112
+ description={ __(
113
+ 'Choose a different style combination for the theme styles'
114
+ ) }
115
+ />
116
+
117
+ <Card size="small" isBorderless>
118
+ <CardBody>
119
+ <Grid columns={ 2 }>
120
+ { withEmptyVariation?.map( ( variation, index ) => (
121
+ <Variation key={ index } variation={ variation } />
122
+ ) ) }
123
+ </Grid>
124
+ </CardBody>
125
+ </Card>
126
+ </>
127
+ );
128
+ }
129
+
130
+ export default ScreenStyleVariations;
@@ -16,7 +16,6 @@ import {
16
16
  } from './hooks';
17
17
 
18
18
  function ScreenTextColor( { name } ) {
19
- const parentMenu = name === undefined ? '' : '/blocks/' + name;
20
19
  const supports = getSupportedGlobalStylesPanels( name );
21
20
  const [ solids ] = useSetting( 'color.palette', name );
22
21
  const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name );
@@ -39,7 +38,6 @@ function ScreenTextColor( { name } ) {
39
38
  return (
40
39
  <>
41
40
  <ScreenHeader
42
- back={ parentMenu + '/colors' }
43
41
  title={ __( 'Text' ) }
44
42
  description={ __(
45
43
  'Set the default color used for text across the site.'
@@ -21,13 +21,9 @@ const elements = {
21
21
  };
22
22
 
23
23
  function ScreenTypographyElement( { name, element } ) {
24
- const parentMenu =
25
- name === undefined ? '/typography' : '/blocks/' + name + '/typography';
26
-
27
24
  return (
28
25
  <>
29
26
  <ScreenHeader
30
- back={ parentMenu }
31
27
  title={ elements[ element ].title }
32
28
  description={ elements[ element ].description }
33
29
  />
@@ -13,7 +13,7 @@ import {
13
13
  * Internal dependencies
14
14
  */
15
15
  import ScreenHeader from './header';
16
- import NavigationButton from './navigation-button';
16
+ import { NavigationButton } from './navigation-button';
17
17
  import { useStyle } from './hooks';
18
18
  import Subtitle from './subtitle';
19
19
  import TypographyPanel from './typography-panel';
@@ -72,7 +72,6 @@ function ScreenTypography( { name } ) {
72
72
  return (
73
73
  <>
74
74
  <ScreenHeader
75
- back={ parentMenu ? parentMenu : '/' }
76
75
  title={ __( 'Typography' ) }
77
76
  description={ __(
78
77
  'Manage the typography settings for different elements.'
@@ -101,7 +100,7 @@ function ScreenTypography( { name } ) {
101
100
  </div>
102
101
  ) }
103
102
 
104
- { /* no typogrpahy elements support yet for blocks */ }
103
+ { /* no typography elements support yet for blocks */ }
105
104
  { !! name && <TypographyPanel name={ name } element="text" /> }
106
105
  </>
107
106
  );
@@ -2,17 +2,13 @@
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
5
- min-height: 152px;
6
5
  line-height: 1;
6
+ cursor: pointer;
7
+ }
7
8
 
8
- .component-color-indicator {
9
- border-radius: 50%;
10
- border: 0;
11
- height: 36px;
12
- width: 36px;
13
- margin-left: 0;
14
- padding: 0;
15
- }
9
+ .edit-site-global-styles-preview__iframe {
10
+ max-width: 100%;
11
+ display: block;
16
12
  }
17
13
 
18
14
  .edit-site-typography-panel__preview {
@@ -43,14 +39,6 @@
43
39
  margin: $grid-unit-20;
44
40
 
45
41
  .component-color-indicator {
46
- margin-left: 0;
47
- display: block;
48
- border-radius: 50%;
49
- height: 24px;
50
- width: 24px;
51
- padding: 0;
52
- border: $border-width solid $gray-300;
53
-
54
42
  // Show a diagonal line (crossed out) for empty swatches.
55
43
  background: linear-gradient(-45deg, transparent 48%, $gray-300 48%, $gray-300 52%, transparent 52%);
56
44
  }
@@ -77,16 +65,27 @@
77
65
  }
78
66
  }
79
67
 
80
- h2.edit-site-global-styles-gradient-palette-panel__duotone-heading.components-heading {
81
- text-transform: uppercase;
82
- line-height: $grid-unit-30;
83
- font-weight: 500;
84
- font-size: 11px;
85
- margin-bottom: $grid-unit-10;
86
- }
87
-
88
68
  .edit-site-screen-text-color__control,
89
69
  .edit-site-screen-link-color__control,
90
70
  .edit-site-screen-background-color__control {
91
71
  padding: $grid-unit-20;
92
72
  }
73
+
74
+ .edit-site-global-styles-variations_item {
75
+ box-sizing: border-box;
76
+ padding: $border-width * 2;
77
+ border-radius: $radius-block-ui;
78
+ border: $gray-200 $border-width solid;
79
+
80
+ &.is-active {
81
+ border: $gray-900 $border-width solid;
82
+ }
83
+
84
+ &:hover {
85
+ border: var(--wp-admin-theme-color) $border-width solid;
86
+ }
87
+
88
+ &:focus {
89
+ border: var(--wp-admin-theme-color) $border-width solid;
90
+ }
91
+ }
@@ -21,47 +21,70 @@ import ScreenBackgroundColor from './screen-background-color';
21
21
  import ScreenTextColor from './screen-text-color';
22
22
  import ScreenLinkColor from './screen-link-color';
23
23
  import ScreenLayout from './screen-layout';
24
+ import ScreenStyleVariations from './screen-style-variations';
25
+
26
+ function GlobalStylesNavigationScreen( { className, ...props } ) {
27
+ return (
28
+ <NavigatorScreen
29
+ className={ [
30
+ 'edit-site-global-styles-sidebar__navigator-screen',
31
+ className,
32
+ ]
33
+ .filter( Boolean )
34
+ .join( ' ' ) }
35
+ { ...props }
36
+ />
37
+ );
38
+ }
24
39
 
25
40
  function ContextScreens( { name } ) {
26
41
  const parentMenu = name === undefined ? '' : '/blocks/' + name;
27
42
 
28
43
  return (
29
44
  <>
30
- <NavigatorScreen path={ parentMenu + '/typography' }>
45
+ <GlobalStylesNavigationScreen path={ parentMenu + '/typography' }>
31
46
  <ScreenTypography name={ name } />
32
- </NavigatorScreen>
47
+ </GlobalStylesNavigationScreen>
33
48
 
34
- <NavigatorScreen path={ parentMenu + '/typography/text' }>
49
+ <GlobalStylesNavigationScreen
50
+ path={ parentMenu + '/typography/text' }
51
+ >
35
52
  <ScreenTypographyElement name={ name } element="text" />
36
- </NavigatorScreen>
53
+ </GlobalStylesNavigationScreen>
37
54
 
38
- <NavigatorScreen path={ parentMenu + '/typography/link' }>
55
+ <GlobalStylesNavigationScreen
56
+ path={ parentMenu + '/typography/link' }
57
+ >
39
58
  <ScreenTypographyElement name={ name } element="link" />
40
- </NavigatorScreen>
59
+ </GlobalStylesNavigationScreen>
41
60
 
42
- <NavigatorScreen path={ parentMenu + '/colors' }>
61
+ <GlobalStylesNavigationScreen path={ parentMenu + '/colors' }>
43
62
  <ScreenColors name={ name } />
44
- </NavigatorScreen>
63
+ </GlobalStylesNavigationScreen>
45
64
 
46
- <NavigatorScreen path={ parentMenu + '/colors/palette' }>
65
+ <GlobalStylesNavigationScreen
66
+ path={ parentMenu + '/colors/palette' }
67
+ >
47
68
  <ScreenColorPalette name={ name } />
48
- </NavigatorScreen>
69
+ </GlobalStylesNavigationScreen>
49
70
 
50
- <NavigatorScreen path={ parentMenu + '/colors/background' }>
71
+ <GlobalStylesNavigationScreen
72
+ path={ parentMenu + '/colors/background' }
73
+ >
51
74
  <ScreenBackgroundColor name={ name } />
52
- </NavigatorScreen>
75
+ </GlobalStylesNavigationScreen>
53
76
 
54
- <NavigatorScreen path={ parentMenu + '/colors/text' }>
77
+ <GlobalStylesNavigationScreen path={ parentMenu + '/colors/text' }>
55
78
  <ScreenTextColor name={ name } />
56
- </NavigatorScreen>
79
+ </GlobalStylesNavigationScreen>
57
80
 
58
- <NavigatorScreen path={ parentMenu + '/colors/link' }>
81
+ <GlobalStylesNavigationScreen path={ parentMenu + '/colors/link' }>
59
82
  <ScreenLinkColor name={ name } />
60
- </NavigatorScreen>
83
+ </GlobalStylesNavigationScreen>
61
84
 
62
- <NavigatorScreen path={ parentMenu + '/layout' }>
85
+ <GlobalStylesNavigationScreen path={ parentMenu + '/layout' }>
63
86
  <ScreenLayout name={ name } />
64
- </NavigatorScreen>
87
+ </GlobalStylesNavigationScreen>
65
88
  </>
66
89
  );
67
90
  }
@@ -70,22 +93,29 @@ function GlobalStylesUI() {
70
93
  const blocks = getBlockTypes();
71
94
 
72
95
  return (
73
- <NavigatorProvider initialPath="/">
74
- <NavigatorScreen path="/">
96
+ <NavigatorProvider
97
+ className="edit-site-global-styles-sidebar__navigator-provider"
98
+ initialPath="/"
99
+ >
100
+ <GlobalStylesNavigationScreen path="/">
75
101
  <ScreenRoot />
76
- </NavigatorScreen>
102
+ </GlobalStylesNavigationScreen>
103
+
104
+ <GlobalStylesNavigationScreen path="/variations">
105
+ <ScreenStyleVariations />
106
+ </GlobalStylesNavigationScreen>
77
107
 
78
- <NavigatorScreen path="/blocks">
108
+ <GlobalStylesNavigationScreen path="/blocks">
79
109
  <ScreenBlockList />
80
- </NavigatorScreen>
110
+ </GlobalStylesNavigationScreen>
81
111
 
82
112
  { blocks.map( ( block ) => (
83
- <NavigatorScreen
113
+ <GlobalStylesNavigationScreen
84
114
  key={ 'menu-block-' + block.name }
85
115
  path={ '/blocks/' + block.name }
86
116
  >
87
117
  <ScreenBlock name={ block.name } />
88
- </NavigatorScreen>
118
+ </GlobalStylesNavigationScreen>
89
119
  ) ) }
90
120
 
91
121
  <ContextScreens />
@@ -2,6 +2,7 @@
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  justify-content: center;
5
+ padding: 0 $grid-unit;
5
6
  height: 100%;
6
7
  // Flex items will, by default, refuse to shrink below a minimum
7
8
  // intrinsic width. In order to shrink this flexbox item, and
@@ -40,15 +41,6 @@
40
41
  white-space: nowrap;
41
42
  overflow: hidden;
42
43
  text-overflow: ellipsis;
43
- max-width: 120px;
44
-
45
- @include break-medium() {
46
- max-width: 75px;
47
- }
48
-
49
- @include break-xlarge() {
50
- max-width: 180px;
51
- }
52
44
  }
53
45
 
54
46
  .edit-site-document-actions__secondary-item {
@@ -11,7 +11,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import { PinnedItems } from '@wordpress/interface';
12
12
  import { _x, __ } from '@wordpress/i18n';
13
13
  import { listView, plus } from '@wordpress/icons';
14
- import { Button } from '@wordpress/components';
14
+ import { Button, ToolbarItem } from '@wordpress/components';
15
15
  import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
16
16
  import { store as editorStore } from '@wordpress/editor';
17
17
  import { store as coreStore } from '@wordpress/core-data';
@@ -45,6 +45,7 @@ export default function Header( {
45
45
  isListViewOpen,
46
46
  listViewShortcut,
47
47
  isLoaded,
48
+ isVisualMode,
48
49
  } = useSelect( ( select ) => {
49
50
  const {
50
51
  __experimentalGetPreviewDeviceType,
@@ -52,6 +53,7 @@ export default function Header( {
52
53
  getEditedPostId,
53
54
  isInserterOpened,
54
55
  isListViewOpened,
56
+ getEditorMode,
55
57
  } = select( editSiteStore );
56
58
  const { getEditedEntityRecord } = select( coreStore );
57
59
  const { __experimentalGetTemplateInfo: getTemplateInfo } = select(
@@ -75,6 +77,7 @@ export default function Header( {
75
77
  listViewShortcut: getShortcutRepresentation(
76
78
  'core/edit-site/toggle-list-view'
77
79
  ),
80
+ isVisualMode: getEditorMode() === 'visual',
78
81
  };
79
82
  }, [] );
80
83
 
@@ -111,6 +114,7 @@ export default function Header( {
111
114
  variant="primary"
112
115
  isPressed={ isInserterOpen }
113
116
  className="edit-site-header-toolbar__inserter-toggle"
117
+ disabled={ ! isVisualMode }
114
118
  onMouseDown={ preventDefault }
115
119
  onClick={ openInserter }
116
120
  icon={ plus }
@@ -121,11 +125,15 @@ export default function Header( {
121
125
  />
122
126
  { isLargeViewport && (
123
127
  <>
124
- <ToolSelector />
128
+ <ToolbarItem
129
+ as={ ToolSelector }
130
+ disabled={ ! isVisualMode }
131
+ />
125
132
  <UndoButton />
126
133
  <RedoButton />
127
134
  <Button
128
135
  className="edit-site-header-toolbar__list-view-toggle"
136
+ disabled={ ! isVisualMode }
129
137
  icon={ listView }
130
138
  isPressed={ isListViewOpen }
131
139
  /* translators: button label text should, if possible, be under 16 characters. */
@@ -0,0 +1,67 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { MenuItemsChoice, MenuGroup } from '@wordpress/components';
6
+ import { useSelect, useDispatch } from '@wordpress/data';
7
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { store as editSiteStore } from '../../../store';
16
+
17
+ /**
18
+ * Set of available mode options.
19
+ *
20
+ * @type {Array}
21
+ */
22
+ const MODES = [
23
+ {
24
+ value: 'visual',
25
+ label: __( 'Visual editor' ),
26
+ },
27
+ {
28
+ value: 'text',
29
+ label: __( 'Code editor' ),
30
+ },
31
+ ];
32
+
33
+ function ModeSwitcher() {
34
+ const { shortcut, mode } = useSelect(
35
+ ( select ) => ( {
36
+ shortcut: select(
37
+ keyboardShortcutsStore
38
+ ).getShortcutRepresentation( 'core/edit-site/toggle-mode' ),
39
+ isRichEditingEnabled: select( editSiteStore ).getSettings()
40
+ .richEditingEnabled,
41
+ isCodeEditingEnabled: select( editSiteStore ).getSettings()
42
+ .codeEditingEnabled,
43
+ mode: select( editSiteStore ).getEditorMode(),
44
+ } ),
45
+ []
46
+ );
47
+ const { switchEditorMode } = useDispatch( editSiteStore );
48
+
49
+ const choices = MODES.map( ( choice ) => {
50
+ if ( choice.value !== mode ) {
51
+ return { ...choice, shortcut };
52
+ }
53
+ return choice;
54
+ } );
55
+
56
+ return (
57
+ <MenuGroup label={ __( 'Editor' ) }>
58
+ <MenuItemsChoice
59
+ choices={ choices }
60
+ value={ mode }
61
+ onSelect={ switchEditorMode }
62
+ />
63
+ </MenuGroup>
64
+ );
65
+ }
66
+
67
+ export default ModeSwitcher;
@@ -0,0 +1,53 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { MenuItem } from '@wordpress/components';
5
+ import { useSelect, useDispatch } from '@wordpress/data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useCopyToClipboard } from '@wordpress/compose';
8
+ import { store as noticesStore } from '@wordpress/notices';
9
+ import { store as coreStore } from '@wordpress/core-data';
10
+ import { __unstableSerializeAndClean } from '@wordpress/blocks';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { store as editSiteStore } from '../../../store';
16
+
17
+ export default function CopyContentMenuItem() {
18
+ const { createNotice } = useDispatch( noticesStore );
19
+ const getText = useSelect( ( select ) => {
20
+ return () => {
21
+ const { getEditedPostId, getEditedPostType } = select(
22
+ editSiteStore
23
+ );
24
+ const { getEditedEntityRecord } = select( coreStore );
25
+ const record = getEditedEntityRecord(
26
+ 'postType',
27
+ getEditedPostType(),
28
+ getEditedPostId()
29
+ );
30
+ if ( record ) {
31
+ if ( typeof record.content === 'function' ) {
32
+ return record.content( record );
33
+ } else if ( record.blocks ) {
34
+ return __unstableSerializeAndClean( record.blocks );
35
+ } else if ( record.content ) {
36
+ return record.content;
37
+ }
38
+ }
39
+ return '';
40
+ };
41
+ }, [] );
42
+
43
+ function onSuccess() {
44
+ createNotice( 'info', __( 'All content copied.' ), {
45
+ isDismissible: true,
46
+ type: 'snackbar',
47
+ } );
48
+ }
49
+
50
+ const ref = useCopyToClipboard( getText, onSuccess );
51
+
52
+ return <MenuItem ref={ ref }>{ __( 'Copy all content' ) }</MenuItem>;
53
+ }
@@ -22,6 +22,8 @@ import FeatureToggle from '../feature-toggle';
22
22
  import ToolsMoreMenuGroup from '../tools-more-menu-group';
23
23
  import SiteExport from './site-export';
24
24
  import WelcomeGuideMenuItem from './welcome-guide-menu-item';
25
+ import CopyContentMenuItem from './copy-content-menu-item';
26
+ import ModeSwitcher from '../mode-switcher';
25
27
 
26
28
  const POPOVER_PROPS = {
27
29
  className: 'edit-site-more-menu__content',
@@ -75,6 +77,7 @@ export default function MoreMenu() {
75
77
  'Spotlight mode deactivated'
76
78
  ) }
77
79
  />
80
+ <ModeSwitcher />
78
81
  <ActionItem.Slot
79
82
  name="core/edit-site/plugin-more-menu"
80
83
  label={ __( 'Plugins' ) }
@@ -91,6 +94,7 @@ export default function MoreMenu() {
91
94
  { __( 'Keyboard shortcuts' ) }
92
95
  </MenuItem>
93
96
  <WelcomeGuideMenuItem />
97
+ <CopyContentMenuItem />
94
98
  <MenuItem
95
99
  icon={ external }
96
100
  role="menuitem"
@@ -25,6 +25,8 @@ $header-toolbar-min-width: 335px;
25
25
  display: flex;
26
26
  align-items: center;
27
27
  height: 100%;
28
+ flex-grow: 1;
29
+ justify-content: center;
28
30
  // Flex items will, by default, refuse to shrink below a minimum
29
31
  // intrinsic width. In order to shrink this flexbox item, and
30
32
  // subsequently truncate child text, we set an explicit min-width.
@@ -109,7 +111,6 @@ body.is-navigation-sidebar-open {
109
111
  .edit-site-header__actions {
110
112
  display: inline-flex;
111
113
  align-items: center;
112
- flex-wrap: wrap;
113
114
  padding-right: $grid-unit-05;
114
115
 
115
116
  .interface-pinned-items {
@@ -23,6 +23,7 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
23
23
  __experimentalGetDirtyEntityRecords,
24
24
  isSavingEntityRecord,
25
25
  } = useSelect( coreStore );
26
+ const { getEditorMode } = useSelect( editSiteStore );
26
27
  const isListViewOpen = useSelect(
27
28
  ( select ) => select( editSiteStore ).isListViewOpened(),
28
29
  []
@@ -35,7 +36,9 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
35
36
  []
36
37
  );
37
38
  const { redo, undo } = useDispatch( coreStore );
38
- const { setIsListViewOpened } = useDispatch( editSiteStore );
39
+ const { setIsListViewOpened, switchEditorMode } = useDispatch(
40
+ editSiteStore
41
+ );
39
42
  const { enableComplementaryArea, disableComplementaryArea } = useDispatch(
40
43
  interfaceStore
41
44
  );
@@ -80,6 +83,10 @@ function KeyboardShortcuts( { openEntitiesSavedStates } ) {
80
83
  }
81
84
  } );
82
85
 
86
+ useShortcut( 'core/edit-site/toggle-mode', () => {
87
+ switchEditorMode( getEditorMode() === 'visual' ? 'text' : 'visual' );
88
+ } );
89
+
83
90
  return null;
84
91
  }
85
92
 
@@ -178,6 +185,15 @@ function KeyboardShortcutsRegister() {
178
185
  },
179
186
  ],
180
187
  } );
188
+ registerShortcut( {
189
+ name: 'core/edit-site/toggle-mode',
190
+ category: 'global',
191
+ description: __( 'Switch between visual editor and code editor.' ),
192
+ keyCombination: {
193
+ modifier: 'secondary',
194
+ character: 'm',
195
+ },
196
+ } );
181
197
  }, [ registerShortcut ] );
182
198
 
183
199
  return null;