@wordpress/edit-site 3.0.24 → 4.0.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 (275) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/LICENSE.md +1 -1
  3. package/README.md +7 -1
  4. package/build/components/block-editor/resizable-editor.js +1 -0
  5. package/build/components/block-editor/resizable-editor.js.map +1 -1
  6. package/build/components/code-editor/code-editor-text-area.js +95 -0
  7. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  8. package/build/components/code-editor/index.js +79 -0
  9. package/build/components/code-editor/index.js.map +1 -0
  10. package/build/components/editor/index.js +39 -9
  11. package/build/components/editor/index.js.map +1 -1
  12. package/build/components/global-styles/border-panel.js +81 -22
  13. package/build/components/global-styles/border-panel.js.map +1 -1
  14. package/build/components/global-styles/context-menu.js +4 -6
  15. package/build/components/global-styles/context-menu.js.map +1 -1
  16. package/build/components/global-styles/global-styles-provider.js +1 -0
  17. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  18. package/build/components/global-styles/header.js +2 -7
  19. package/build/components/global-styles/header.js.map +1 -1
  20. package/build/components/global-styles/navigation-button.js +35 -12
  21. package/build/components/global-styles/navigation-button.js.map +1 -1
  22. package/build/components/global-styles/palette.js +3 -3
  23. package/build/components/global-styles/palette.js.map +1 -1
  24. package/build/components/global-styles/preview.js +46 -15
  25. package/build/components/global-styles/preview.js.map +1 -1
  26. package/build/components/global-styles/screen-background-color.js +9 -12
  27. package/build/components/global-styles/screen-background-color.js.map +1 -1
  28. package/build/components/global-styles/screen-block-list.js +2 -3
  29. package/build/components/global-styles/screen-block-list.js.map +1 -1
  30. package/build/components/global-styles/screen-block.js +0 -1
  31. package/build/components/global-styles/screen-block.js.map +1 -1
  32. package/build/components/global-styles/screen-color-palette.js +0 -2
  33. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  34. package/build/components/global-styles/screen-colors.js +5 -6
  35. package/build/components/global-styles/screen-colors.js.map +1 -1
  36. package/build/components/global-styles/screen-layout.js +0 -2
  37. package/build/components/global-styles/screen-layout.js.map +1 -1
  38. package/build/components/global-styles/screen-link-color.js +6 -12
  39. package/build/components/global-styles/screen-link-color.js.map +1 -1
  40. package/build/components/global-styles/screen-root.js +22 -3
  41. package/build/components/global-styles/screen-root.js.map +1 -1
  42. package/build/components/global-styles/screen-style-variations.js +138 -0
  43. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  44. package/build/components/global-styles/screen-text-color.js +6 -12
  45. package/build/components/global-styles/screen-text-color.js.map +1 -1
  46. package/build/components/global-styles/screen-typography-element.js +0 -2
  47. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  48. package/build/components/global-styles/screen-typography.js +2 -3
  49. package/build/components/global-styles/screen-typography.js.map +1 -1
  50. package/build/components/global-styles/ui.js +31 -14
  51. package/build/components/global-styles/ui.js.map +1 -1
  52. package/build/components/header/index.js +12 -4
  53. package/build/components/header/index.js.map +1 -1
  54. package/build/components/header/mode-switcher/index.js +78 -0
  55. package/build/components/header/mode-switcher/index.js.map +1 -0
  56. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  57. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  58. package/build/components/header/more-menu/index.js +72 -39
  59. package/build/components/header/more-menu/index.js.map +1 -1
  60. package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
  61. package/build/components/header/more-menu/site-export.js.map +1 -0
  62. package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  63. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  64. package/build/components/header/tools-more-menu-group/index.js +1 -5
  65. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  66. package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
  67. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  68. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
  69. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  70. package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
  71. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  72. package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
  73. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  74. package/build/components/keyboard-shortcuts/index.js +26 -1
  75. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  76. package/build/components/list/actions/index.js +5 -4
  77. package/build/components/list/actions/index.js.map +1 -1
  78. package/build/components/list/actions/rename-menu-item.js +3 -3
  79. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  80. package/build/components/list/added-by.js +51 -50
  81. package/build/components/list/added-by.js.map +1 -1
  82. package/build/components/routes/redirect-to-homepage.js +87 -0
  83. package/build/components/routes/redirect-to-homepage.js.map +1 -0
  84. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  85. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  86. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  87. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  88. package/build/components/sidebar/default-sidebar.js +4 -2
  89. package/build/components/sidebar/default-sidebar.js.map +1 -1
  90. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  91. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  92. package/build/components/url-query-controller/index.js +1 -38
  93. package/build/components/url-query-controller/index.js.map +1 -1
  94. package/build/index.js +10 -5
  95. package/build/index.js.map +1 -1
  96. package/build/store/actions.js +29 -27
  97. package/build/store/actions.js.map +1 -1
  98. package/build/store/defaults.js +2 -1
  99. package/build/store/defaults.js.map +1 -1
  100. package/build/store/reducer.js +11 -0
  101. package/build/store/reducer.js.map +1 -1
  102. package/build/store/selectors.js +13 -0
  103. package/build/store/selectors.js.map +1 -1
  104. package/build-module/components/block-editor/resizable-editor.js +1 -0
  105. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  106. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  107. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  108. package/build-module/components/code-editor/index.js +62 -0
  109. package/build-module/components/code-editor/index.js.map +1 -0
  110. package/build-module/components/editor/index.js +38 -10
  111. package/build-module/components/editor/index.js.map +1 -1
  112. package/build-module/components/global-styles/border-panel.js +82 -23
  113. package/build-module/components/global-styles/border-panel.js.map +1 -1
  114. package/build-module/components/global-styles/context-menu.js +1 -1
  115. package/build-module/components/global-styles/context-menu.js.map +1 -1
  116. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  117. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  118. package/build-module/components/global-styles/header.js +2 -5
  119. package/build-module/components/global-styles/header.js.map +1 -1
  120. package/build-module/components/global-styles/navigation-button.js +35 -10
  121. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  122. package/build-module/components/global-styles/palette.js +2 -2
  123. package/build-module/components/global-styles/palette.js.map +1 -1
  124. package/build-module/components/global-styles/preview.js +45 -15
  125. package/build-module/components/global-styles/preview.js.map +1 -1
  126. package/build-module/components/global-styles/screen-background-color.js +9 -13
  127. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  128. package/build-module/components/global-styles/screen-block-list.js +1 -2
  129. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  130. package/build-module/components/global-styles/screen-block.js +0 -1
  131. package/build-module/components/global-styles/screen-block.js.map +1 -1
  132. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  133. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  134. package/build-module/components/global-styles/screen-colors.js +2 -3
  135. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  136. package/build-module/components/global-styles/screen-layout.js +0 -2
  137. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  138. package/build-module/components/global-styles/screen-link-color.js +7 -13
  139. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  140. package/build-module/components/global-styles/screen-root.js +21 -4
  141. package/build-module/components/global-styles/screen-root.js.map +1 -1
  142. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  143. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  144. package/build-module/components/global-styles/screen-text-color.js +7 -13
  145. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  146. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  147. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  148. package/build-module/components/global-styles/screen-typography.js +1 -2
  149. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  150. package/build-module/components/global-styles/ui.js +29 -14
  151. package/build-module/components/global-styles/ui.js.map +1 -1
  152. package/build-module/components/header/index.js +13 -5
  153. package/build-module/components/header/index.js.map +1 -1
  154. package/build-module/components/header/mode-switcher/index.js +65 -0
  155. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  156. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  157. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  158. package/build-module/components/header/more-menu/index.js +67 -40
  159. package/build-module/components/header/more-menu/index.js.map +1 -1
  160. package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
  161. package/build-module/components/header/more-menu/site-export.js.map +1 -0
  162. package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  163. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  164. package/build-module/components/header/tools-more-menu-group/index.js +2 -5
  165. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  166. package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
  167. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  168. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
  169. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  170. package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  172. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
  173. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  174. package/build-module/components/keyboard-shortcuts/index.js +26 -1
  175. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  176. package/build-module/components/list/actions/index.js +5 -4
  177. package/build-module/components/list/actions/index.js.map +1 -1
  178. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  179. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  180. package/build-module/components/list/added-by.js +52 -51
  181. package/build-module/components/list/added-by.js.map +1 -1
  182. package/build-module/components/routes/redirect-to-homepage.js +75 -0
  183. package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
  184. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  185. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  186. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  187. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  188. package/build-module/components/sidebar/default-sidebar.js +4 -2
  189. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  190. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  191. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  192. package/build-module/components/url-query-controller/index.js +3 -40
  193. package/build-module/components/url-query-controller/index.js.map +1 -1
  194. package/build-module/index.js +9 -4
  195. package/build-module/index.js.map +1 -1
  196. package/build-module/store/actions.js +25 -25
  197. package/build-module/store/actions.js.map +1 -1
  198. package/build-module/store/defaults.js +2 -1
  199. package/build-module/store/defaults.js.map +1 -1
  200. package/build-module/store/reducer.js +11 -0
  201. package/build-module/store/reducer.js.map +1 -1
  202. package/build-module/store/selectors.js +11 -0
  203. package/build-module/store/selectors.js.map +1 -1
  204. package/build-style/style-rtl.css +202 -72
  205. package/build-style/style.css +202 -72
  206. package/package.json +28 -30
  207. package/src/components/block-editor/resizable-editor.js +1 -0
  208. package/src/components/block-editor/style.scss +15 -23
  209. package/src/components/code-editor/code-editor-text-area.js +79 -0
  210. package/src/components/code-editor/index.js +65 -0
  211. package/src/components/code-editor/style.scss +100 -0
  212. package/src/components/editor/index.js +55 -10
  213. package/src/components/global-styles/border-panel.js +106 -42
  214. package/src/components/global-styles/context-menu.js +1 -1
  215. package/src/components/global-styles/global-styles-provider.js +1 -2
  216. package/src/components/global-styles/header.js +3 -5
  217. package/src/components/global-styles/navigation-button.js +31 -10
  218. package/src/components/global-styles/palette.js +6 -2
  219. package/src/components/global-styles/preview.js +46 -18
  220. package/src/components/global-styles/screen-background-color.js +7 -12
  221. package/src/components/global-styles/screen-block-list.js +1 -2
  222. package/src/components/global-styles/screen-block.js +1 -1
  223. package/src/components/global-styles/screen-color-palette.js +0 -2
  224. package/src/components/global-styles/screen-colors.js +2 -3
  225. package/src/components/global-styles/screen-layout.js +1 -5
  226. package/src/components/global-styles/screen-link-color.js +6 -16
  227. package/src/components/global-styles/screen-root.js +32 -3
  228. package/src/components/global-styles/screen-style-variations.js +130 -0
  229. package/src/components/global-styles/screen-text-color.js +6 -16
  230. package/src/components/global-styles/screen-typography-element.js +0 -4
  231. package/src/components/global-styles/screen-typography.js +2 -3
  232. package/src/components/global-styles/style.scss +24 -25
  233. package/src/components/global-styles/ui.js +55 -25
  234. package/src/components/header/document-actions/style.scss +1 -9
  235. package/src/components/header/index.js +10 -2
  236. package/src/components/header/mode-switcher/index.js +67 -0
  237. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  238. package/src/components/header/more-menu/index.js +107 -44
  239. package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
  240. package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  241. package/src/components/header/style.scss +2 -1
  242. package/src/components/header/tools-more-menu-group/index.js +2 -7
  243. package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
  244. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
  245. package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
  246. package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
  247. package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
  248. package/src/components/keyboard-shortcuts/index.js +27 -1
  249. package/src/components/list/actions/index.js +5 -4
  250. package/src/components/list/actions/rename-menu-item.js +3 -3
  251. package/src/components/list/added-by.js +57 -63
  252. package/src/components/routes/redirect-to-homepage.js +71 -0
  253. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  254. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  255. package/src/components/secondary-sidebar/style.scss +0 -4
  256. package/src/components/sidebar/default-sidebar.js +2 -0
  257. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  258. package/src/components/sidebar/style.scss +21 -14
  259. package/src/components/url-query-controller/index.js +3 -35
  260. package/src/index.js +10 -3
  261. package/src/store/actions.js +24 -37
  262. package/src/store/defaults.js +1 -0
  263. package/src/store/reducer.js +6 -0
  264. package/src/store/selectors.js +11 -0
  265. package/src/store/test/actions.js +2 -92
  266. package/src/style.scss +2 -0
  267. package/build/plugins/index.js +0 -28
  268. package/build/plugins/index.js.map +0 -1
  269. package/build/plugins/site-export.js.map +0 -1
  270. package/build/plugins/welcome-guide-menu-item.js.map +0 -1
  271. package/build-module/plugins/index.js +0 -20
  272. package/build-module/plugins/index.js.map +0 -1
  273. package/build-module/plugins/site-export.js.map +0 -1
  274. package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
  275. package/src/plugins/index.js +0 -24
@@ -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
+ }
@@ -2,15 +2,28 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { __, _x } from '@wordpress/i18n';
5
- import { moreVertical } from '@wordpress/icons';
6
- import { DropdownMenu, MenuGroup } from '@wordpress/components';
5
+ import { useReducer } from '@wordpress/element';
6
+ import { useShortcut } from '@wordpress/keyboard-shortcuts';
7
+ import { displayShortcut } from '@wordpress/keycodes';
8
+ import { external, moreVertical } from '@wordpress/icons';
9
+ import {
10
+ DropdownMenu,
11
+ MenuGroup,
12
+ MenuItem,
13
+ VisuallyHidden,
14
+ } from '@wordpress/components';
7
15
  import { ActionItem } from '@wordpress/interface';
8
16
 
9
17
  /**
10
18
  * Internal dependencies
11
19
  */
20
+ import KeyboardShortcutHelpModal from '../../keyboard-shortcut-help-modal';
12
21
  import FeatureToggle from '../feature-toggle';
13
22
  import ToolsMoreMenuGroup from '../tools-more-menu-group';
23
+ import SiteExport from './site-export';
24
+ import WelcomeGuideMenuItem from './welcome-guide-menu-item';
25
+ import CopyContentMenuItem from './copy-content-menu-item';
26
+ import ModeSwitcher from '../mode-switcher';
14
27
 
15
28
  const POPOVER_PROPS = {
16
29
  className: 'edit-site-more-menu__content',
@@ -20,46 +33,96 @@ const TOGGLE_PROPS = {
20
33
  tooltipPosition: 'bottom',
21
34
  };
22
35
 
23
- const MoreMenu = () => (
24
- <DropdownMenu
25
- className="edit-site-more-menu"
26
- icon={ moreVertical }
27
- label={ __( 'More tools & options' ) }
28
- popoverProps={ POPOVER_PROPS }
29
- toggleProps={ TOGGLE_PROPS }
30
- >
31
- { ( { onClose } ) => (
32
- <>
33
- <MenuGroup label={ _x( 'View', 'noun' ) }>
34
- <FeatureToggle
35
- feature="fixedToolbar"
36
- label={ __( 'Top toolbar' ) }
37
- info={ __(
38
- 'Access all block and document tools in a single place'
39
- ) }
40
- messageActivated={ __( 'Top toolbar activated' ) }
41
- messageDeactivated={ __( 'Top toolbar deactivated' ) }
42
- />
43
- <FeatureToggle
44
- feature="focusMode"
45
- label={ __( 'Spotlight mode' ) }
46
- info={ __( 'Focus on one block at a time' ) }
47
- messageActivated={ __( 'Spotlight mode activated' ) }
48
- messageDeactivated={ __(
49
- 'Spotlight mode deactivated'
50
- ) }
51
- />
52
- <ActionItem.Slot
53
- name="core/edit-site/plugin-more-menu"
54
- label={ __( 'Plugins' ) }
55
- as={ MenuGroup }
56
- fillProps={ { onClick: onClose } }
57
- />
58
- </MenuGroup>
59
- <ToolsMoreMenuGroup.Slot fillProps={ { onClose } } />
60
- </>
61
- ) }
62
- </DropdownMenu>
63
- );
36
+ export default function MoreMenu() {
37
+ const [ isModalActive, toggleModal ] = useReducer(
38
+ ( isActive ) => ! isActive,
39
+ false
40
+ );
64
41
 
65
- export default MoreMenu;
42
+ useShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );
43
+
44
+ return (
45
+ <>
46
+ <DropdownMenu
47
+ className="edit-site-more-menu"
48
+ icon={ moreVertical }
49
+ label={ __( 'More tools & options' ) }
50
+ popoverProps={ POPOVER_PROPS }
51
+ toggleProps={ TOGGLE_PROPS }
52
+ >
53
+ { ( { onClose } ) => (
54
+ <>
55
+ <MenuGroup label={ _x( 'View', 'noun' ) }>
56
+ <FeatureToggle
57
+ feature="fixedToolbar"
58
+ label={ __( 'Top toolbar' ) }
59
+ info={ __(
60
+ 'Access all block and document tools in a single place'
61
+ ) }
62
+ messageActivated={ __(
63
+ 'Top toolbar activated'
64
+ ) }
65
+ messageDeactivated={ __(
66
+ 'Top toolbar deactivated'
67
+ ) }
68
+ />
69
+ <FeatureToggle
70
+ feature="focusMode"
71
+ label={ __( 'Spotlight mode' ) }
72
+ info={ __( 'Focus on one block at a time' ) }
73
+ messageActivated={ __(
74
+ 'Spotlight mode activated'
75
+ ) }
76
+ messageDeactivated={ __(
77
+ 'Spotlight mode deactivated'
78
+ ) }
79
+ />
80
+ <ModeSwitcher />
81
+ <ActionItem.Slot
82
+ name="core/edit-site/plugin-more-menu"
83
+ label={ __( 'Plugins' ) }
84
+ as={ MenuGroup }
85
+ fillProps={ { onClick: onClose } }
86
+ />
87
+ </MenuGroup>
88
+ <MenuGroup label={ __( 'Tools' ) }>
89
+ <SiteExport />
90
+ <MenuItem
91
+ onClick={ toggleModal }
92
+ shortcut={ displayShortcut.access( 'h' ) }
93
+ >
94
+ { __( 'Keyboard shortcuts' ) }
95
+ </MenuItem>
96
+ <WelcomeGuideMenuItem />
97
+ <CopyContentMenuItem />
98
+ <MenuItem
99
+ icon={ external }
100
+ role="menuitem"
101
+ href={ __(
102
+ 'https://wordpress.org/support/article/site-editor/'
103
+ ) }
104
+ target="_blank"
105
+ rel="noopener noreferrer"
106
+ >
107
+ { __( 'Help' ) }
108
+ <VisuallyHidden as="span">
109
+ {
110
+ /* translators: accessibility text */
111
+ __( '(opens in a new tab)' )
112
+ }
113
+ </VisuallyHidden>
114
+ </MenuItem>
115
+ <ToolsMoreMenuGroup.Slot
116
+ fillProps={ { onClose } }
117
+ />
118
+ </MenuGroup>
119
+ </>
120
+ ) }
121
+ </DropdownMenu>
122
+ <KeyboardShortcutHelpModal
123
+ isModalActive={ isModalActive }
124
+ toggleModal={ toggleModal }
125
+ />
126
+ </>
127
+ );
128
+ }
@@ -8,7 +8,7 @@ import { MenuItem } from '@wordpress/components';
8
8
  /**
9
9
  * Internal dependencies
10
10
  */
11
- import { store as editSiteStore } from '../store';
11
+ import { store as editSiteStore } from '../../../store';
12
12
 
13
13
  export default function WelcomeGuideMenuItem() {
14
14
  const { toggleFeature } = useDispatch( editSiteStore );
@@ -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 {
@@ -6,8 +6,7 @@ import { isEmpty } from 'lodash';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { createSlotFill, MenuGroup } from '@wordpress/components';
10
- import { __ } from '@wordpress/i18n';
9
+ import { createSlotFill } from '@wordpress/components';
11
10
 
12
11
  const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill(
13
12
  'EditSiteToolsMoreMenuGroup'
@@ -15,11 +14,7 @@ const { Fill: ToolsMoreMenuGroup, Slot } = createSlotFill(
15
14
 
16
15
  ToolsMoreMenuGroup.Slot = ( { fillProps } ) => (
17
16
  <Slot fillProps={ fillProps }>
18
- { ( fills ) =>
19
- ! isEmpty( fills ) && (
20
- <MenuGroup label={ __( 'Tools' ) }>{ fills }</MenuGroup>
21
- )
22
- }
17
+ { ( fills ) => ! isEmpty( fills ) && fills }
23
18
  </Slot>
24
19
  );
25
20
 
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ export const textFormattingShortcuts = [
7
+ {
8
+ keyCombination: { modifier: 'primary', character: 'b' },
9
+ description: __( 'Make the selected text bold.' ),
10
+ },
11
+ {
12
+ keyCombination: { modifier: 'primary', character: 'i' },
13
+ description: __( 'Make the selected text italic.' ),
14
+ },
15
+ {
16
+ keyCombination: { modifier: 'primary', character: 'k' },
17
+ description: __( 'Convert the selected text into a link.' ),
18
+ },
19
+ {
20
+ keyCombination: { modifier: 'primaryShift', character: 'k' },
21
+ description: __( 'Remove a link.' ),
22
+ },
23
+ {
24
+ keyCombination: { modifier: 'primary', character: 'u' },
25
+ description: __( 'Underline the selected text.' ),
26
+ },
27
+ ];
@@ -0,0 +1,41 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useSelect } from '@wordpress/data';
5
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
6
+
7
+ /**
8
+ * Internal dependencies
9
+ */
10
+ import Shortcut from './shortcut';
11
+
12
+ export default function DynamicShortcut( { name } ) {
13
+ const { keyCombination, description, aliases } = useSelect(
14
+ ( select ) => {
15
+ const {
16
+ getShortcutKeyCombination,
17
+ getShortcutDescription,
18
+ getShortcutAliases,
19
+ } = select( keyboardShortcutsStore );
20
+
21
+ return {
22
+ keyCombination: getShortcutKeyCombination( name ),
23
+ aliases: getShortcutAliases( name ),
24
+ description: getShortcutDescription( name ),
25
+ };
26
+ },
27
+ [ name ]
28
+ );
29
+
30
+ if ( ! keyCombination ) {
31
+ return null;
32
+ }
33
+
34
+ return (
35
+ <Shortcut
36
+ keyCombination={ keyCombination }
37
+ description={ description }
38
+ aliases={ aliases }
39
+ />
40
+ );
41
+ }
@@ -0,0 +1,135 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+ import { isString } from 'lodash';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ import { Modal } from '@wordpress/components';
11
+ import { __ } from '@wordpress/i18n';
12
+ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
13
+ import { useSelect } from '@wordpress/data';
14
+
15
+ /**
16
+ * Internal dependencies
17
+ */
18
+ import { textFormattingShortcuts } from './config';
19
+ import Shortcut from './shortcut';
20
+ import DynamicShortcut from './dynamic-shortcut';
21
+
22
+ const ShortcutList = ( { shortcuts } ) => (
23
+ /*
24
+ * Disable reason: The `list` ARIA role is redundant but
25
+ * Safari+VoiceOver won't announce the list otherwise.
26
+ */
27
+ /* eslint-disable jsx-a11y/no-redundant-roles */
28
+ <ul
29
+ className="edit-site-keyboard-shortcut-help-modal__shortcut-list"
30
+ role="list"
31
+ >
32
+ { shortcuts.map( ( shortcut, index ) => (
33
+ <li
34
+ className="edit-site-keyboard-shortcut-help-modal__shortcut"
35
+ key={ index }
36
+ >
37
+ { isString( shortcut ) ? (
38
+ <DynamicShortcut name={ shortcut } />
39
+ ) : (
40
+ <Shortcut { ...shortcut } />
41
+ ) }
42
+ </li>
43
+ ) ) }
44
+ </ul>
45
+ /* eslint-enable jsx-a11y/no-redundant-roles */
46
+ );
47
+
48
+ const ShortcutSection = ( { title, shortcuts, className } ) => (
49
+ <section
50
+ className={ classnames(
51
+ 'edit-site-keyboard-shortcut-help-modal__section',
52
+ className
53
+ ) }
54
+ >
55
+ { !! title && (
56
+ <h2 className="edit-site-keyboard-shortcut-help-modal__section-title">
57
+ { title }
58
+ </h2>
59
+ ) }
60
+ <ShortcutList shortcuts={ shortcuts } />
61
+ </section>
62
+ );
63
+
64
+ const ShortcutCategorySection = ( {
65
+ title,
66
+ categoryName,
67
+ additionalShortcuts = [],
68
+ } ) => {
69
+ const categoryShortcuts = useSelect(
70
+ ( select ) => {
71
+ return select( keyboardShortcutsStore ).getCategoryShortcuts(
72
+ categoryName
73
+ );
74
+ },
75
+ [ categoryName ]
76
+ );
77
+
78
+ return (
79
+ <ShortcutSection
80
+ title={ title }
81
+ shortcuts={ categoryShortcuts.concat( additionalShortcuts ) }
82
+ />
83
+ );
84
+ };
85
+
86
+ export default function KeyboardShortcutHelpModal( {
87
+ isModalActive,
88
+ toggleModal,
89
+ } ) {
90
+ if ( ! isModalActive ) {
91
+ return null;
92
+ }
93
+
94
+ return (
95
+ <Modal
96
+ className="edit-site-keyboard-shortcut-help-modal"
97
+ title={ __( 'Keyboard shortcuts' ) }
98
+ closeLabel={ __( 'Close' ) }
99
+ onRequestClose={ toggleModal }
100
+ >
101
+ <ShortcutSection
102
+ className="edit-site-keyboard-shortcut-help-modal__main-shortcuts"
103
+ shortcuts={ [ 'core/edit-site/keyboard-shortcuts' ] }
104
+ />
105
+ <ShortcutCategorySection
106
+ title={ __( 'Global shortcuts' ) }
107
+ categoryName="global"
108
+ />
109
+
110
+ <ShortcutCategorySection
111
+ title={ __( 'Selection shortcuts' ) }
112
+ categoryName="selection"
113
+ />
114
+
115
+ <ShortcutCategorySection
116
+ title={ __( 'Block shortcuts' ) }
117
+ categoryName="block"
118
+ additionalShortcuts={ [
119
+ {
120
+ keyCombination: { character: '/' },
121
+ description: __(
122
+ 'Change the block type after adding a new paragraph.'
123
+ ),
124
+ /* translators: The forward-slash character. e.g. '/'. */
125
+ ariaLabel: __( 'Forward-slash' ),
126
+ },
127
+ ] }
128
+ />
129
+ <ShortcutSection
130
+ title={ __( 'Text formatting' ) }
131
+ shortcuts={ textFormattingShortcuts }
132
+ />
133
+ </Modal>
134
+ );
135
+ }