@wordpress/edit-site 3.0.22 → 3.1.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 (274) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/block-editor/resizable-editor.js +1 -0
  4. package/build/components/block-editor/resizable-editor.js.map +1 -1
  5. package/build/components/code-editor/code-editor-text-area.js +95 -0
  6. package/build/components/code-editor/code-editor-text-area.js.map +1 -0
  7. package/build/components/code-editor/index.js +79 -0
  8. package/build/components/code-editor/index.js.map +1 -0
  9. package/build/components/editor/index.js +21 -6
  10. package/build/components/editor/index.js.map +1 -1
  11. package/build/components/global-styles/border-panel.js +81 -22
  12. package/build/components/global-styles/border-panel.js.map +1 -1
  13. package/build/components/global-styles/context-menu.js +4 -6
  14. package/build/components/global-styles/context-menu.js.map +1 -1
  15. package/build/components/global-styles/global-styles-provider.js +1 -0
  16. package/build/components/global-styles/global-styles-provider.js.map +1 -1
  17. package/build/components/global-styles/header.js +2 -7
  18. package/build/components/global-styles/header.js.map +1 -1
  19. package/build/components/global-styles/navigation-button.js +27 -12
  20. package/build/components/global-styles/navigation-button.js.map +1 -1
  21. package/build/components/global-styles/palette.js +2 -2
  22. package/build/components/global-styles/palette.js.map +1 -1
  23. package/build/components/global-styles/preview.js +46 -15
  24. package/build/components/global-styles/preview.js.map +1 -1
  25. package/build/components/global-styles/screen-background-color.js +9 -12
  26. package/build/components/global-styles/screen-background-color.js.map +1 -1
  27. package/build/components/global-styles/screen-block-list.js +2 -3
  28. package/build/components/global-styles/screen-block-list.js.map +1 -1
  29. package/build/components/global-styles/screen-block.js +0 -1
  30. package/build/components/global-styles/screen-block.js.map +1 -1
  31. package/build/components/global-styles/screen-color-palette.js +0 -2
  32. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  33. package/build/components/global-styles/screen-colors.js +5 -6
  34. package/build/components/global-styles/screen-colors.js.map +1 -1
  35. package/build/components/global-styles/screen-layout.js +0 -2
  36. package/build/components/global-styles/screen-layout.js.map +1 -1
  37. package/build/components/global-styles/screen-link-color.js +6 -12
  38. package/build/components/global-styles/screen-link-color.js.map +1 -1
  39. package/build/components/global-styles/screen-root.js +22 -3
  40. package/build/components/global-styles/screen-root.js.map +1 -1
  41. package/build/components/global-styles/screen-style-variations.js +138 -0
  42. package/build/components/global-styles/screen-style-variations.js.map +1 -0
  43. package/build/components/global-styles/screen-text-color.js +6 -12
  44. package/build/components/global-styles/screen-text-color.js.map +1 -1
  45. package/build/components/global-styles/screen-typography-element.js +0 -2
  46. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  47. package/build/components/global-styles/screen-typography.js +2 -3
  48. package/build/components/global-styles/screen-typography.js.map +1 -1
  49. package/build/components/global-styles/ui.js +31 -14
  50. package/build/components/global-styles/ui.js.map +1 -1
  51. package/build/components/header/index.js +12 -4
  52. package/build/components/header/index.js.map +1 -1
  53. package/build/components/header/mode-switcher/index.js +78 -0
  54. package/build/components/header/mode-switcher/index.js.map +1 -0
  55. package/build/components/header/more-menu/copy-content-menu-item.js +74 -0
  56. package/build/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  57. package/build/components/header/more-menu/index.js +72 -39
  58. package/build/components/header/more-menu/index.js.map +1 -1
  59. package/build/{plugins → components/header/more-menu}/site-export.js +0 -0
  60. package/build/components/header/more-menu/site-export.js.map +1 -0
  61. package/build/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  62. package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  63. package/build/components/header/tools-more-menu-group/index.js +1 -5
  64. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  65. package/build/components/keyboard-shortcut-help-modal/config.js +45 -0
  66. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  67. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +56 -0
  68. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  69. package/build/components/keyboard-shortcut-help-modal/index.js +137 -0
  70. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  71. package/build/components/keyboard-shortcut-help-modal/shortcut.js +65 -0
  72. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  73. package/build/components/keyboard-shortcuts/index.js +26 -1
  74. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  75. package/build/components/list/actions/index.js +5 -4
  76. package/build/components/list/actions/index.js.map +1 -1
  77. package/build/components/list/actions/rename-menu-item.js +3 -3
  78. package/build/components/list/actions/rename-menu-item.js.map +1 -1
  79. package/build/components/list/added-by.js +51 -50
  80. package/build/components/list/added-by.js.map +1 -1
  81. package/build/components/routes/redirect-to-homepage.js +87 -0
  82. package/build/components/routes/redirect-to-homepage.js.map +1 -0
  83. package/build/components/secondary-sidebar/inserter-sidebar.js +13 -3
  84. package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  85. package/build/components/secondary-sidebar/list-view-sidebar.js +7 -5
  86. package/build/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  87. package/build/components/sidebar/default-sidebar.js +4 -2
  88. package/build/components/sidebar/default-sidebar.js.map +1 -1
  89. package/build/components/sidebar/global-styles-sidebar.js +1 -0
  90. package/build/components/sidebar/global-styles-sidebar.js.map +1 -1
  91. package/build/components/url-query-controller/index.js +1 -38
  92. package/build/components/url-query-controller/index.js.map +1 -1
  93. package/build/index.js +9 -4
  94. package/build/index.js.map +1 -1
  95. package/build/store/actions.js +26 -25
  96. package/build/store/actions.js.map +1 -1
  97. package/build/store/defaults.js +2 -1
  98. package/build/store/defaults.js.map +1 -1
  99. package/build/store/reducer.js +11 -0
  100. package/build/store/reducer.js.map +1 -1
  101. package/build/store/selectors.js +13 -0
  102. package/build/store/selectors.js.map +1 -1
  103. package/build-module/components/block-editor/resizable-editor.js +1 -0
  104. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  105. package/build-module/components/code-editor/code-editor-text-area.js +83 -0
  106. package/build-module/components/code-editor/code-editor-text-area.js.map +1 -0
  107. package/build-module/components/code-editor/index.js +62 -0
  108. package/build-module/components/code-editor/index.js.map +1 -0
  109. package/build-module/components/editor/index.js +20 -6
  110. package/build-module/components/editor/index.js.map +1 -1
  111. package/build-module/components/global-styles/border-panel.js +82 -23
  112. package/build-module/components/global-styles/border-panel.js.map +1 -1
  113. package/build-module/components/global-styles/context-menu.js +1 -1
  114. package/build-module/components/global-styles/context-menu.js.map +1 -1
  115. package/build-module/components/global-styles/global-styles-provider.js +1 -1
  116. package/build-module/components/global-styles/global-styles-provider.js.map +1 -1
  117. package/build-module/components/global-styles/header.js +2 -5
  118. package/build-module/components/global-styles/header.js.map +1 -1
  119. package/build-module/components/global-styles/navigation-button.js +27 -10
  120. package/build-module/components/global-styles/navigation-button.js.map +1 -1
  121. package/build-module/components/global-styles/palette.js +1 -1
  122. package/build-module/components/global-styles/palette.js.map +1 -1
  123. package/build-module/components/global-styles/preview.js +45 -15
  124. package/build-module/components/global-styles/preview.js.map +1 -1
  125. package/build-module/components/global-styles/screen-background-color.js +9 -13
  126. package/build-module/components/global-styles/screen-background-color.js.map +1 -1
  127. package/build-module/components/global-styles/screen-block-list.js +1 -2
  128. package/build-module/components/global-styles/screen-block-list.js.map +1 -1
  129. package/build-module/components/global-styles/screen-block.js +0 -1
  130. package/build-module/components/global-styles/screen-block.js.map +1 -1
  131. package/build-module/components/global-styles/screen-color-palette.js +0 -2
  132. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  133. package/build-module/components/global-styles/screen-colors.js +2 -3
  134. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  135. package/build-module/components/global-styles/screen-layout.js +0 -2
  136. package/build-module/components/global-styles/screen-layout.js.map +1 -1
  137. package/build-module/components/global-styles/screen-link-color.js +7 -13
  138. package/build-module/components/global-styles/screen-link-color.js.map +1 -1
  139. package/build-module/components/global-styles/screen-root.js +21 -4
  140. package/build-module/components/global-styles/screen-root.js.map +1 -1
  141. package/build-module/components/global-styles/screen-style-variations.js +119 -0
  142. package/build-module/components/global-styles/screen-style-variations.js.map +1 -0
  143. package/build-module/components/global-styles/screen-text-color.js +7 -13
  144. package/build-module/components/global-styles/screen-text-color.js.map +1 -1
  145. package/build-module/components/global-styles/screen-typography-element.js +0 -2
  146. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  147. package/build-module/components/global-styles/screen-typography.js +1 -2
  148. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  149. package/build-module/components/global-styles/ui.js +29 -14
  150. package/build-module/components/global-styles/ui.js.map +1 -1
  151. package/build-module/components/header/index.js +13 -5
  152. package/build-module/components/header/index.js.map +1 -1
  153. package/build-module/components/header/mode-switcher/index.js +65 -0
  154. package/build-module/components/header/mode-switcher/index.js.map +1 -0
  155. package/build-module/components/header/more-menu/copy-content-menu-item.js +59 -0
  156. package/build-module/components/header/more-menu/copy-content-menu-item.js.map +1 -0
  157. package/build-module/components/header/more-menu/index.js +67 -40
  158. package/build-module/components/header/more-menu/index.js.map +1 -1
  159. package/build-module/{plugins → components/header/more-menu}/site-export.js +0 -0
  160. package/build-module/components/header/more-menu/site-export.js.map +1 -0
  161. package/build-module/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  162. package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
  163. package/build-module/components/header/tools-more-menu-group/index.js +2 -5
  164. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  165. package/build-module/components/keyboard-shortcut-help-modal/config.js +36 -0
  166. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -0
  167. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +44 -0
  168. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -0
  169. package/build-module/components/keyboard-shortcut-help-modal/index.js +120 -0
  170. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -0
  171. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +58 -0
  172. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -0
  173. package/build-module/components/keyboard-shortcuts/index.js +26 -1
  174. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  175. package/build-module/components/list/actions/index.js +5 -4
  176. package/build-module/components/list/actions/index.js.map +1 -1
  177. package/build-module/components/list/actions/rename-menu-item.js +3 -3
  178. package/build-module/components/list/actions/rename-menu-item.js.map +1 -1
  179. package/build-module/components/list/added-by.js +52 -51
  180. package/build-module/components/list/added-by.js.map +1 -1
  181. package/build-module/components/routes/redirect-to-homepage.js +75 -0
  182. package/build-module/components/routes/redirect-to-homepage.js.map +1 -0
  183. package/build-module/components/secondary-sidebar/inserter-sidebar.js +14 -4
  184. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
  185. package/build-module/components/secondary-sidebar/list-view-sidebar.js +7 -5
  186. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +1 -1
  187. package/build-module/components/sidebar/default-sidebar.js +4 -2
  188. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  189. package/build-module/components/sidebar/global-styles-sidebar.js +1 -0
  190. package/build-module/components/sidebar/global-styles-sidebar.js.map +1 -1
  191. package/build-module/components/url-query-controller/index.js +3 -40
  192. package/build-module/components/url-query-controller/index.js.map +1 -1
  193. package/build-module/index.js +8 -3
  194. package/build-module/index.js.map +1 -1
  195. package/build-module/store/actions.js +22 -23
  196. package/build-module/store/actions.js.map +1 -1
  197. package/build-module/store/defaults.js +2 -1
  198. package/build-module/store/defaults.js.map +1 -1
  199. package/build-module/store/reducer.js +11 -0
  200. package/build-module/store/reducer.js.map +1 -1
  201. package/build-module/store/selectors.js +11 -0
  202. package/build-module/store/selectors.js.map +1 -1
  203. package/build-style/style-rtl.css +202 -72
  204. package/build-style/style.css +202 -72
  205. package/package.json +29 -28
  206. package/src/components/block-editor/resizable-editor.js +1 -0
  207. package/src/components/block-editor/style.scss +15 -23
  208. package/src/components/code-editor/code-editor-text-area.js +79 -0
  209. package/src/components/code-editor/index.js +65 -0
  210. package/src/components/code-editor/style.scss +100 -0
  211. package/src/components/editor/index.js +30 -7
  212. package/src/components/global-styles/border-panel.js +106 -42
  213. package/src/components/global-styles/context-menu.js +1 -1
  214. package/src/components/global-styles/global-styles-provider.js +1 -2
  215. package/src/components/global-styles/header.js +3 -5
  216. package/src/components/global-styles/navigation-button.js +14 -10
  217. package/src/components/global-styles/palette.js +1 -1
  218. package/src/components/global-styles/preview.js +46 -18
  219. package/src/components/global-styles/screen-background-color.js +7 -12
  220. package/src/components/global-styles/screen-block-list.js +1 -2
  221. package/src/components/global-styles/screen-block.js +1 -1
  222. package/src/components/global-styles/screen-color-palette.js +0 -2
  223. package/src/components/global-styles/screen-colors.js +2 -3
  224. package/src/components/global-styles/screen-layout.js +1 -5
  225. package/src/components/global-styles/screen-link-color.js +6 -16
  226. package/src/components/global-styles/screen-root.js +32 -3
  227. package/src/components/global-styles/screen-style-variations.js +130 -0
  228. package/src/components/global-styles/screen-text-color.js +6 -16
  229. package/src/components/global-styles/screen-typography-element.js +0 -4
  230. package/src/components/global-styles/screen-typography.js +2 -3
  231. package/src/components/global-styles/style.scss +24 -25
  232. package/src/components/global-styles/ui.js +55 -25
  233. package/src/components/header/document-actions/style.scss +1 -9
  234. package/src/components/header/index.js +10 -2
  235. package/src/components/header/mode-switcher/index.js +67 -0
  236. package/src/components/header/more-menu/copy-content-menu-item.js +53 -0
  237. package/src/components/header/more-menu/index.js +107 -44
  238. package/src/{plugins → components/header/more-menu}/site-export.js +0 -0
  239. package/src/{plugins → components/header/more-menu}/welcome-guide-menu-item.js +1 -1
  240. package/src/components/header/style.scss +2 -1
  241. package/src/components/header/tools-more-menu-group/index.js +2 -7
  242. package/src/components/keyboard-shortcut-help-modal/config.js +27 -0
  243. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +41 -0
  244. package/src/components/keyboard-shortcut-help-modal/index.js +135 -0
  245. package/src/components/keyboard-shortcut-help-modal/shortcut.js +73 -0
  246. package/src/components/keyboard-shortcut-help-modal/style.scss +66 -0
  247. package/src/components/keyboard-shortcuts/index.js +27 -1
  248. package/src/components/list/actions/index.js +5 -4
  249. package/src/components/list/actions/rename-menu-item.js +3 -3
  250. package/src/components/list/added-by.js +57 -63
  251. package/src/components/routes/redirect-to-homepage.js +71 -0
  252. package/src/components/secondary-sidebar/inserter-sidebar.js +14 -3
  253. package/src/components/secondary-sidebar/list-view-sidebar.js +12 -5
  254. package/src/components/secondary-sidebar/style.scss +0 -4
  255. package/src/components/sidebar/default-sidebar.js +2 -0
  256. package/src/components/sidebar/global-styles-sidebar.js +1 -0
  257. package/src/components/sidebar/style.scss +21 -14
  258. package/src/components/url-query-controller/index.js +3 -35
  259. package/src/index.js +9 -2
  260. package/src/store/actions.js +22 -35
  261. package/src/store/defaults.js +1 -0
  262. package/src/store/reducer.js +6 -0
  263. package/src/store/selectors.js +11 -0
  264. package/src/store/test/actions.js +2 -92
  265. package/src/style.scss +2 -0
  266. package/build/plugins/index.js +0 -28
  267. package/build/plugins/index.js.map +0 -1
  268. package/build/plugins/site-export.js.map +0 -1
  269. package/build/plugins/welcome-guide-menu-item.js.map +0 -1
  270. package/build-module/plugins/index.js +0 -20
  271. package/build-module/plugins/index.js.map +0 -1
  272. package/build-module/plugins/site-export.js.map +0 -1
  273. package/build-module/plugins/welcome-guide-menu-item.js.map +0 -1
  274. package/src/plugins/index.js +0 -24
@@ -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
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { castArray } from 'lodash';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Fragment } from '@wordpress/element';
10
+ import { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';
11
+
12
+ function KeyCombination( { keyCombination, forceAriaLabel } ) {
13
+ const shortcut = keyCombination.modifier
14
+ ? displayShortcutList[ keyCombination.modifier ](
15
+ keyCombination.character
16
+ )
17
+ : keyCombination.character;
18
+ const ariaLabel = keyCombination.modifier
19
+ ? shortcutAriaLabel[ keyCombination.modifier ](
20
+ keyCombination.character
21
+ )
22
+ : keyCombination.character;
23
+
24
+ return (
25
+ <kbd
26
+ className="edit-site-keyboard-shortcut-help-modal__shortcut-key-combination"
27
+ aria-label={ forceAriaLabel || ariaLabel }
28
+ >
29
+ { castArray( shortcut ).map( ( character, index ) => {
30
+ if ( character === '+' ) {
31
+ return <Fragment key={ index }>{ character }</Fragment>;
32
+ }
33
+
34
+ return (
35
+ <kbd
36
+ key={ index }
37
+ className="edit-site-keyboard-shortcut-help-modal__shortcut-key"
38
+ >
39
+ { character }
40
+ </kbd>
41
+ );
42
+ } ) }
43
+ </kbd>
44
+ );
45
+ }
46
+
47
+ export default function Shortcut( {
48
+ description,
49
+ keyCombination,
50
+ aliases = [],
51
+ ariaLabel,
52
+ } ) {
53
+ return (
54
+ <>
55
+ <div className="edit-site-keyboard-shortcut-help-modal__shortcut-description">
56
+ { description }
57
+ </div>
58
+ <div className="edit-site-keyboard-shortcut-help-modal__shortcut-term">
59
+ <KeyCombination
60
+ keyCombination={ keyCombination }
61
+ forceAriaLabel={ ariaLabel }
62
+ />
63
+ { aliases.map( ( alias, index ) => (
64
+ <KeyCombination
65
+ keyCombination={ alias }
66
+ forceAriaLabel={ ariaLabel }
67
+ key={ index }
68
+ />
69
+ ) ) }
70
+ </div>
71
+ </>
72
+ );
73
+ }
@@ -0,0 +1,66 @@
1
+ .edit-site-keyboard-shortcut-help-modal {
2
+ &__section {
3
+ margin: 0 0 2rem 0;
4
+ }
5
+
6
+ &__main-shortcuts .edit-site-keyboard-shortcut-help-modal__shortcut-list {
7
+ // Push the shortcut to be flush with top modal header.
8
+ margin-top: -$grid-unit-30 -$border-width;
9
+ }
10
+
11
+ &__section-title {
12
+ font-size: 0.9rem;
13
+ font-weight: 600;
14
+ }
15
+
16
+ &__shortcut {
17
+ display: flex;
18
+ align-items: baseline;
19
+ padding: 0.6rem 0;
20
+ border-top: 1px solid $gray-300;
21
+ margin-bottom: 0;
22
+
23
+ &:last-child {
24
+ border-bottom: 1px solid $gray-300;
25
+ }
26
+
27
+ &:empty {
28
+ display: none;
29
+ }
30
+ }
31
+
32
+ &__shortcut-term {
33
+ font-weight: 600;
34
+ margin: 0 0 0 1rem;
35
+ text-align: right;
36
+ }
37
+
38
+ &__shortcut-description {
39
+ flex: 1;
40
+ margin: 0;
41
+
42
+ // IE 11 flex item fix - ensure the item does not collapse.
43
+ flex-basis: auto;
44
+ }
45
+
46
+ &__shortcut-key-combination {
47
+ display: block;
48
+ background: none;
49
+ margin: 0;
50
+ padding: 0;
51
+
52
+ & + .edit-site-keyboard-shortcut-help-modal__shortcut-key-combination {
53
+ margin-top: 10px;
54
+ }
55
+ }
56
+
57
+ &__shortcut-key {
58
+ padding: 0.25rem 0.5rem;
59
+ border-radius: 8%;
60
+ margin: 0 0.2rem 0 0.2rem;
61
+
62
+ &:last-child {
63
+ margin: 0 0 0 0.2rem;
64
+ }
65
+ }
66
+ }