@wordpress/edit-post 7.31.0 → 7.33.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 (294) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +9 -323
  3. package/build/components/browser-url/index.js.map +1 -1
  4. package/build/components/editor-initialization/index.js +0 -1
  5. package/build/components/editor-initialization/index.js.map +1 -1
  6. package/build/components/editor-initialization/listener-hooks.js +1 -38
  7. package/build/components/editor-initialization/listener-hooks.js.map +1 -1
  8. package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
  9. package/build/components/header/header-toolbar/index.native.js.map +1 -1
  10. package/build/components/header/index.js +5 -5
  11. package/build/components/header/index.js.map +1 -1
  12. package/build/components/header/index.native.js +1 -1
  13. package/build/components/header/index.native.js.map +1 -1
  14. package/build/components/header/main-dashboard-button/index.js.map +1 -1
  15. package/build/components/header/more-menu/index.js +7 -6
  16. package/build/components/header/more-menu/index.js.map +1 -1
  17. package/build/components/header/post-publish-button-or-toggle.js +11 -13
  18. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  19. package/build/components/header/preferences-menu-item/index.js +12 -4
  20. package/build/components/header/preferences-menu-item/index.js.map +1 -1
  21. package/build/components/header/tools-more-menu-group/index.js.map +1 -1
  22. package/build/components/header/writing-menu/index.js.map +1 -1
  23. package/build/components/init-pattern-modal/index.js.map +1 -1
  24. package/build/components/keyboard-shortcuts/index.js +1 -36
  25. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  26. package/build/components/layout/actions-panel.js +4 -7
  27. package/build/components/layout/actions-panel.js.map +1 -1
  28. package/build/components/layout/index.js +16 -21
  29. package/build/components/layout/index.js.map +1 -1
  30. package/build/components/layout/index.native.js.map +1 -1
  31. package/build/components/meta-boxes/index.js.map +1 -1
  32. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  33. package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  34. package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
  35. package/build/components/preferences-modal/enable-panel.js.map +1 -1
  36. package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
  37. package/build/components/preferences-modal/index.js +1 -21
  38. package/build/components/preferences-modal/index.js.map +1 -1
  39. package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
  40. package/build/components/sidebar/plugin-post-publish-panel/index.js +16 -64
  41. package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  42. package/build/components/sidebar/plugin-pre-publish-panel/index.js +16 -63
  43. package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  44. package/build/components/sidebar/post-format/index.js.map +1 -1
  45. package/build/components/sidebar/post-pending-status/index.js.map +1 -1
  46. package/build/components/sidebar/post-slug/index.js.map +1 -1
  47. package/build/components/sidebar/post-status/index.js +9 -9
  48. package/build/components/sidebar/post-status/index.js.map +1 -1
  49. package/build/components/sidebar/post-sticky/index.js.map +1 -1
  50. package/build/components/sidebar/post-trash/index.js.map +1 -1
  51. package/build/components/sidebar/post-visibility/index.js.map +1 -1
  52. package/build/components/sidebar/settings-header/index.js.map +1 -1
  53. package/build/components/sidebar/settings-sidebar/index.js +42 -40
  54. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  55. package/build/components/text-editor/index.js.map +1 -1
  56. package/build/components/visual-editor/block-inspector-button.js +1 -1
  57. package/build/components/visual-editor/block-inspector-button.js.map +1 -1
  58. package/build/components/visual-editor/header.native.js.map +1 -1
  59. package/build/components/visual-editor/index.js +4 -1
  60. package/build/components/visual-editor/index.js.map +1 -1
  61. package/build/components/visual-editor/index.native.js.map +1 -1
  62. package/build/components/visual-editor/use-padding-appender.js +62 -0
  63. package/build/components/visual-editor/use-padding-appender.js.map +1 -0
  64. package/build/components/welcome-guide/default.js.map +1 -1
  65. package/build/components/welcome-guide/image.js.map +1 -1
  66. package/build/components/welcome-guide/index.js.map +1 -1
  67. package/build/components/welcome-guide/template.js.map +1 -1
  68. package/build/editor.js +9 -4
  69. package/build/editor.js.map +1 -1
  70. package/build/editor.native.js.map +1 -1
  71. package/build/hooks/commands/use-common-commands.js +7 -24
  72. package/build/hooks/commands/use-common-commands.js.map +1 -1
  73. package/build/hooks/components/index.js.map +1 -1
  74. package/build/hooks/index.js.map +1 -1
  75. package/build/hooks/use-navigate-to-entity-record.js +36 -19
  76. package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
  77. package/build/hooks/validate-multiple-use/index.js.map +1 -1
  78. package/build/index.js +7 -12
  79. package/build/index.js.map +1 -1
  80. package/build/index.native.js +2 -4
  81. package/build/index.native.js.map +1 -1
  82. package/build/lock-unlock.js.map +1 -1
  83. package/build/plugins/copy-content-menu-item/index.js.map +1 -1
  84. package/build/plugins/index.js.map +1 -1
  85. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +7 -4
  86. package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  87. package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
  88. package/build/store/actions.js +46 -31
  89. package/build/store/actions.js.map +1 -1
  90. package/build/store/constants.js.map +1 -1
  91. package/build/store/index.js +1 -1
  92. package/build/store/index.js.map +1 -1
  93. package/build/store/reducer.js +1 -15
  94. package/build/store/reducer.js.map +1 -1
  95. package/build/store/selectors.js +44 -24
  96. package/build/store/selectors.js.map +1 -1
  97. package/build/utils/meta-boxes.js.map +1 -1
  98. package/build-module/components/browser-url/index.js.map +1 -1
  99. package/build-module/components/editor-initialization/index.js +1 -2
  100. package/build-module/components/editor-initialization/index.js.map +1 -1
  101. package/build-module/components/editor-initialization/listener-hooks.js +2 -38
  102. package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
  103. package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
  104. package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
  105. package/build-module/components/header/index.js +4 -4
  106. package/build-module/components/header/index.js.map +1 -1
  107. package/build-module/components/header/index.native.js +1 -1
  108. package/build-module/components/header/index.native.js.map +1 -1
  109. package/build-module/components/header/main-dashboard-button/index.js.map +1 -1
  110. package/build-module/components/header/more-menu/index.js +5 -4
  111. package/build-module/components/header/more-menu/index.js.map +1 -1
  112. package/build-module/components/header/post-publish-button-or-toggle.js +11 -13
  113. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  114. package/build-module/components/header/preferences-menu-item/index.js +11 -3
  115. package/build-module/components/header/preferences-menu-item/index.js.map +1 -1
  116. package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
  117. package/build-module/components/header/writing-menu/index.js.map +1 -1
  118. package/build-module/components/init-pattern-modal/index.js.map +1 -1
  119. package/build-module/components/keyboard-shortcuts/index.js +1 -36
  120. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  121. package/build-module/components/layout/actions-panel.js +4 -5
  122. package/build-module/components/layout/actions-panel.js.map +1 -1
  123. package/build-module/components/layout/index.js +15 -20
  124. package/build-module/components/layout/index.js.map +1 -1
  125. package/build-module/components/layout/index.native.js.map +1 -1
  126. package/build-module/components/meta-boxes/index.js.map +1 -1
  127. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  128. package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
  129. package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
  130. package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
  131. package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
  132. package/build-module/components/preferences-modal/index.js +1 -20
  133. package/build-module/components/preferences-modal/index.js.map +1 -1
  134. package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
  135. package/build-module/components/sidebar/plugin-post-publish-panel/index.js +14 -62
  136. package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  137. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js +14 -61
  138. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  139. package/build-module/components/sidebar/post-format/index.js.map +1 -1
  140. package/build-module/components/sidebar/post-pending-status/index.js.map +1 -1
  141. package/build-module/components/sidebar/post-slug/index.js.map +1 -1
  142. package/build-module/components/sidebar/post-status/index.js +9 -10
  143. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  144. package/build-module/components/sidebar/post-sticky/index.js.map +1 -1
  145. package/build-module/components/sidebar/post-trash/index.js.map +1 -1
  146. package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
  147. package/build-module/components/sidebar/settings-header/index.js.map +1 -1
  148. package/build-module/components/sidebar/settings-sidebar/index.js +43 -41
  149. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  150. package/build-module/components/text-editor/index.js.map +1 -1
  151. package/build-module/components/visual-editor/block-inspector-button.js +1 -1
  152. package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
  153. package/build-module/components/visual-editor/header.native.js.map +1 -1
  154. package/build-module/components/visual-editor/index.js +4 -1
  155. package/build-module/components/visual-editor/index.js.map +1 -1
  156. package/build-module/components/visual-editor/index.native.js.map +1 -1
  157. package/build-module/components/visual-editor/use-padding-appender.js +55 -0
  158. package/build-module/components/visual-editor/use-padding-appender.js.map +1 -0
  159. package/build-module/components/welcome-guide/default.js.map +1 -1
  160. package/build-module/components/welcome-guide/image.js.map +1 -1
  161. package/build-module/components/welcome-guide/index.js.map +1 -1
  162. package/build-module/components/welcome-guide/template.js.map +1 -1
  163. package/build-module/editor.js +9 -4
  164. package/build-module/editor.js.map +1 -1
  165. package/build-module/editor.native.js.map +1 -1
  166. package/build-module/hooks/commands/use-common-commands.js +9 -26
  167. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  168. package/build-module/hooks/components/index.js.map +1 -1
  169. package/build-module/hooks/index.js.map +1 -1
  170. package/build-module/hooks/use-navigate-to-entity-record.js +37 -20
  171. package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
  172. package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
  173. package/build-module/index.js +8 -8
  174. package/build-module/index.js.map +1 -1
  175. package/build-module/index.native.js +2 -4
  176. package/build-module/index.native.js.map +1 -1
  177. package/build-module/lock-unlock.js.map +1 -1
  178. package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
  179. package/build-module/plugins/index.js.map +1 -1
  180. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +6 -3
  181. package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
  182. package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
  183. package/build-module/store/actions.js +38 -22
  184. package/build-module/store/actions.js.map +1 -1
  185. package/build-module/store/constants.js.map +1 -1
  186. package/build-module/store/index.js.map +1 -1
  187. package/build-module/store/reducer.js +1 -13
  188. package/build-module/store/reducer.js.map +1 -1
  189. package/build-module/store/selectors.js +42 -21
  190. package/build-module/store/selectors.js.map +1 -1
  191. package/build-module/utils/meta-boxes.js.map +1 -1
  192. package/build-style/classic-rtl.css +2 -2
  193. package/build-style/classic.css +2 -2
  194. package/build-style/style-rtl.css +12 -454
  195. package/build-style/style.css +12 -454
  196. package/package.json +32 -34
  197. package/src/classic.scss +2 -1
  198. package/src/components/editor-initialization/index.js +1 -5
  199. package/src/components/editor-initialization/listener-hooks.js +1 -40
  200. package/src/components/editor-initialization/test/listener-hooks.js +1 -96
  201. package/src/components/header/index.js +3 -4
  202. package/src/components/header/index.native.js +1 -1
  203. package/src/components/header/more-menu/index.js +3 -4
  204. package/src/components/header/post-publish-button-or-toggle.js +10 -11
  205. package/src/components/header/preferences-menu-item/index.js +9 -3
  206. package/src/components/header/style.scss +5 -3
  207. package/src/components/header/test/index.js +13 -1
  208. package/src/components/keyboard-shortcuts/index.js +3 -44
  209. package/src/components/layout/actions-panel.js +5 -4
  210. package/src/components/layout/index.js +20 -42
  211. package/src/components/meta-boxes/meta-boxes-area/style.scss +1 -1
  212. package/src/components/preferences-modal/index.js +1 -24
  213. package/src/components/sidebar/plugin-post-publish-panel/index.js +12 -67
  214. package/src/components/sidebar/plugin-pre-publish-panel/index.js +12 -66
  215. package/src/components/sidebar/post-status/index.js +6 -9
  216. package/src/components/sidebar/settings-sidebar/index.js +64 -56
  217. package/src/components/visual-editor/block-inspector-button.js +1 -1
  218. package/src/components/visual-editor/index.js +4 -0
  219. package/src/components/visual-editor/use-padding-appender.js +66 -0
  220. package/src/editor.js +14 -4
  221. package/src/hooks/commands/use-common-commands.js +13 -28
  222. package/src/hooks/use-navigate-to-entity-record.js +37 -24
  223. package/src/index.js +11 -6
  224. package/src/index.native.js +1 -4
  225. package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +5 -3
  226. package/src/store/actions.js +37 -24
  227. package/src/store/reducer.js +0 -13
  228. package/src/store/selectors.js +52 -36
  229. package/src/store/test/actions.js +11 -10
  230. package/src/style.scss +1 -20
  231. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -107
  232. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  233. package/build/components/header/plugin-more-menu-item/index.js +0 -78
  234. package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
  235. package/build/components/header/plugin-sidebar-more-menu-item/index.js +0 -71
  236. package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  237. package/build/components/keyboard-shortcut-help-modal/config.js +0 -78
  238. package/build/components/keyboard-shortcut-help-modal/config.js.map +0 -1
  239. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -49
  240. package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
  241. package/build/components/keyboard-shortcut-help-modal/index.js +0 -129
  242. package/build/components/keyboard-shortcut-help-modal/index.js.map +0 -1
  243. package/build/components/keyboard-shortcut-help-modal/shortcut.js +0 -55
  244. package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
  245. package/build/components/sidebar/plugin-post-status-info/index.js +0 -73
  246. package/build/components/sidebar/plugin-post-status-info/index.js.map +0 -1
  247. package/build/components/sidebar/plugin-sidebar/index.js +0 -104
  248. package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
  249. package/build/components/sidebar/template-summary/index.js +0 -36
  250. package/build/components/sidebar/template-summary/index.js.map +0 -1
  251. package/build/components/start-page-options/index.js +0 -107
  252. package/build/components/start-page-options/index.js.map +0 -1
  253. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -100
  254. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  255. package/build-module/components/header/plugin-more-menu-item/index.js +0 -73
  256. package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
  257. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +0 -65
  258. package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
  259. package/build-module/components/keyboard-shortcut-help-modal/config.js +0 -71
  260. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +0 -1
  261. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -41
  262. package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
  263. package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -119
  264. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +0 -1
  265. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -48
  266. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
  267. package/build-module/components/sidebar/plugin-post-status-info/index.js +0 -66
  268. package/build-module/components/sidebar/plugin-post-status-info/index.js.map +0 -1
  269. package/build-module/components/sidebar/plugin-sidebar/index.js +0 -98
  270. package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
  271. package/build-module/components/sidebar/template-summary/index.js +0 -29
  272. package/build-module/components/sidebar/template-summary/index.js.map +0 -1
  273. package/build-module/components/start-page-options/index.js +0 -100
  274. package/build-module/components/start-page-options/index.js.map +0 -1
  275. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -108
  276. package/src/components/header/plugin-more-menu-item/index.js +0 -73
  277. package/src/components/header/plugin-sidebar-more-menu-item/index.js +0 -64
  278. package/src/components/keyboard-shortcut-help-modal/config.js +0 -53
  279. package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -43
  280. package/src/components/keyboard-shortcut-help-modal/index.js +0 -159
  281. package/src/components/keyboard-shortcut-help-modal/shortcut.js +0 -67
  282. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -61
  283. package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -36
  284. package/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +0 -39
  285. package/src/components/sidebar/plugin-post-publish-panel/test/index.js +0 -33
  286. package/src/components/sidebar/plugin-post-status-info/index.js +0 -63
  287. package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +0 -11
  288. package/src/components/sidebar/plugin-post-status-info/test/index.js +0 -29
  289. package/src/components/sidebar/plugin-pre-publish-panel/test/index.js +0 -33
  290. package/src/components/sidebar/plugin-sidebar/index.js +0 -94
  291. package/src/components/sidebar/template-summary/index.js +0 -37
  292. package/src/components/sidebar/template-summary/style.scss +0 -5
  293. package/src/components/start-page-options/index.js +0 -108
  294. package/src/components/start-page-options/style.scss +0 -26
@@ -1,100 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { Modal } from '@wordpress/components';
6
- import { __ } from '@wordpress/i18n';
7
- import { useState, useMemo } from '@wordpress/element';
8
- import { store as blockEditorStore, __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
9
- import { useSelect, useDispatch } from '@wordpress/data';
10
- import { useAsyncList } from '@wordpress/compose';
11
- import { store as editorStore } from '@wordpress/editor';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { store as editPostStore } from '../../store';
17
- function useStartPatterns() {
18
- // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
19
- // and it has no postTypes declared and the current post type is page or if
20
- // the current post type is part of the postTypes declared.
21
- const {
22
- blockPatternsWithPostContentBlockType,
23
- postType
24
- } = useSelect(select => {
25
- const {
26
- getPatternsByBlockTypes
27
- } = select(blockEditorStore);
28
- const {
29
- getCurrentPostType
30
- } = select(editorStore);
31
- return {
32
- blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content'),
33
- postType: getCurrentPostType()
34
- };
35
- }, []);
36
- return useMemo(() => {
37
- // filter patterns without postTypes declared if the current postType is page
38
- // or patterns that declare the current postType in its post type array.
39
- return blockPatternsWithPostContentBlockType.filter(pattern => {
40
- return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
41
- });
42
- }, [postType, blockPatternsWithPostContentBlockType]);
43
- }
44
- function PatternSelection({
45
- blockPatterns,
46
- onChoosePattern
47
- }) {
48
- const shownBlockPatterns = useAsyncList(blockPatterns);
49
- const {
50
- resetEditorBlocks
51
- } = useDispatch(editorStore);
52
- return createElement(BlockPatternsList, {
53
- blockPatterns: blockPatterns,
54
- shownPatterns: shownBlockPatterns,
55
- onClickPattern: (_pattern, blocks) => {
56
- resetEditorBlocks(blocks);
57
- onChoosePattern();
58
- }
59
- });
60
- }
61
- function StartPageOptionsModal({
62
- onClose
63
- }) {
64
- const startPatterns = useStartPatterns();
65
- const hasStartPattern = startPatterns.length > 0;
66
- if (!hasStartPattern) {
67
- return null;
68
- }
69
- return createElement(Modal, {
70
- className: "edit-post-start-page-options__modal",
71
- title: __('Choose a pattern'),
72
- isFullScreen: true,
73
- onRequestClose: onClose
74
- }, createElement("div", {
75
- className: "edit-post-start-page-options__modal-content"
76
- }, createElement(PatternSelection, {
77
- blockPatterns: startPatterns,
78
- onChoosePattern: onClose
79
- })));
80
- }
81
- export default function StartPageOptions() {
82
- const [isClosed, setIsClosed] = useState(false);
83
- const shouldEnableModal = useSelect(select => {
84
- const {
85
- isCleanNewPost,
86
- getRenderingMode
87
- } = select(editorStore);
88
- const {
89
- isFeatureActive
90
- } = select(editPostStore);
91
- return getRenderingMode() === 'post-only' && !isFeatureActive('welcomeGuide') && isCleanNewPost();
92
- }, []);
93
- if (!shouldEnableModal || isClosed) {
94
- return null;
95
- }
96
- return createElement(StartPageOptionsModal, {
97
- onClose: () => setIsClosed(true)
98
- });
99
- }
100
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Modal","__","useState","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","resetEditorBlocks","createElement","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","className","title","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","shouldEnableModal","isCleanNewPost","getRenderingMode","isFeatureActive"],"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ onClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst shouldEnableModal = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost, getRenderingMode } = select( editorStore );\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn (\n\t\t\tgetRenderingMode() === 'post-only' &&\n\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\tisCleanNewPost()\n\t\t);\n\t}, [] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsClosed( true ) } />;\n}\n"],"mappings":"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"}
@@ -1,108 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { BlockSettingsMenuControls } from '@wordpress/block-editor';
5
- import { MenuItem } from '@wordpress/components';
6
- import { compose } from '@wordpress/compose';
7
-
8
- const isEverySelectedBlockAllowed = ( selected, allowed ) =>
9
- selected.filter( ( id ) => ! allowed.includes( id ) ).length === 0;
10
-
11
- /**
12
- * Plugins may want to add an item to the menu either for every block
13
- * or only for the specific ones provided in the `allowedBlocks` component property.
14
- *
15
- * If there are multiple blocks selected the item will be rendered if every block
16
- * is of one allowed type (not necessarily the same).
17
- *
18
- * @param {string[]} selectedBlocks Array containing the names of the blocks selected
19
- * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
20
- * @return {boolean} Whether the item will be rendered or not.
21
- */
22
- const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
23
- ! Array.isArray( allowedBlocks ) ||
24
- isEverySelectedBlockAllowed( selectedBlocks, allowedBlocks );
25
-
26
- /**
27
- * Renders a new item in the block settings menu.
28
- *
29
- * @param {Object} props Component props.
30
- * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
31
- * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
32
- * @param {string} props.label The menu item text.
33
- * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
34
- * @param {boolean} [props.small] Whether to render the label or not.
35
- * @param {string} [props.role] The ARIA role for the menu item.
36
- *
37
- * @example
38
- * ```js
39
- * // Using ES5 syntax
40
- * var __ = wp.i18n.__;
41
- * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
42
- *
43
- * function doOnClick(){
44
- * // To be called when the user clicks the menu item.
45
- * }
46
- *
47
- * function MyPluginBlockSettingsMenuItem() {
48
- * return React.createElement(
49
- * PluginBlockSettingsMenuItem,
50
- * {
51
- * allowedBlocks: [ 'core/paragraph' ],
52
- * icon: 'dashicon-name',
53
- * label: __( 'Menu item text' ),
54
- * onClick: doOnClick,
55
- * }
56
- * );
57
- * }
58
- * ```
59
- *
60
- * @example
61
- * ```jsx
62
- * // Using ESNext syntax
63
- * import { __ } from '@wordpress/i18n';
64
- * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
65
- *
66
- * const doOnClick = ( ) => {
67
- * // To be called when the user clicks the menu item.
68
- * };
69
- *
70
- * const MyPluginBlockSettingsMenuItem = () => (
71
- * <PluginBlockSettingsMenuItem
72
- * allowedBlocks={ [ 'core/paragraph' ] }
73
- * icon='dashicon-name'
74
- * label={ __( 'Menu item text' ) }
75
- * onClick={ doOnClick } />
76
- * );
77
- * ```
78
- *
79
- * @return {Component} The component to be rendered.
80
- */
81
- const PluginBlockSettingsMenuItem = ( {
82
- allowedBlocks,
83
- icon,
84
- label,
85
- onClick,
86
- small,
87
- role,
88
- } ) => (
89
- <BlockSettingsMenuControls>
90
- { ( { selectedBlocks, onClose } ) => {
91
- if ( ! shouldRenderItem( selectedBlocks, allowedBlocks ) ) {
92
- return null;
93
- }
94
- return (
95
- <MenuItem
96
- onClick={ compose( onClick, onClose ) }
97
- icon={ icon }
98
- label={ small ? label : undefined }
99
- role={ role }
100
- >
101
- { ! small && label }
102
- </MenuItem>
103
- );
104
- } }
105
- </BlockSettingsMenuControls>
106
- );
107
-
108
- export default PluginBlockSettingsMenuItem;
@@ -1,73 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { ActionItem } from '@wordpress/interface';
5
- import { compose } from '@wordpress/compose';
6
- import { MenuItem } from '@wordpress/components';
7
- import { withPluginContext } from '@wordpress/plugins';
8
-
9
- /**
10
- * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
11
- * The text within the component appears as the menu item label.
12
- *
13
- * @param {Object} props Component properties.
14
- * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
15
- * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
16
- * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
17
- * @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.
18
- *
19
- * @example
20
- * ```js
21
- * // Using ES5 syntax
22
- * var __ = wp.i18n.__;
23
- * var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
24
- * var moreIcon = React.createElement( 'svg' ); //... svg element.
25
- *
26
- * function onButtonClick() {
27
- * alert( 'Button clicked.' );
28
- * }
29
- *
30
- * function MyButtonMoreMenuItem() {
31
- * return React.createElement(
32
- * PluginMoreMenuItem,
33
- * {
34
- * icon: moreIcon,
35
- * onClick: onButtonClick,
36
- * },
37
- * __( 'My button title' )
38
- * );
39
- * }
40
- * ```
41
- *
42
- * @example
43
- * ```jsx
44
- * // Using ESNext syntax
45
- * import { __ } from '@wordpress/i18n';
46
- * import { PluginMoreMenuItem } from '@wordpress/edit-post';
47
- * import { more } from '@wordpress/icons';
48
- *
49
- * function onButtonClick() {
50
- * alert( 'Button clicked.' );
51
- * }
52
- *
53
- * const MyButtonMoreMenuItem = () => (
54
- * <PluginMoreMenuItem
55
- * icon={ more }
56
- * onClick={ onButtonClick }
57
- * >
58
- * { __( 'My button title' ) }
59
- * </PluginMoreMenuItem>
60
- * );
61
- * ```
62
- *
63
- * @return {Component} The component to be rendered.
64
- */
65
- export default compose(
66
- withPluginContext( ( context, ownProps ) => {
67
- return {
68
- as: ownProps.as ?? MenuItem,
69
- icon: ownProps.icon || context.icon,
70
- name: 'core/edit-post/plugin-more-menu',
71
- };
72
- } )
73
- )( ActionItem );
@@ -1,64 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
5
-
6
- /**
7
- * Renders a menu item in `Plugins` group in `More Menu` drop down,
8
- * and can be used to activate the corresponding `PluginSidebar` component.
9
- * The text within the component appears as the menu item label.
10
- *
11
- * @param {Object} props Component props.
12
- * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
13
- * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
14
- *
15
- * @example
16
- * ```js
17
- * // Using ES5 syntax
18
- * var __ = wp.i18n.__;
19
- * var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
20
- * var moreIcon = React.createElement( 'svg' ); //... svg element.
21
- *
22
- * function MySidebarMoreMenuItem() {
23
- * return React.createElement(
24
- * PluginSidebarMoreMenuItem,
25
- * {
26
- * target: 'my-sidebar',
27
- * icon: moreIcon,
28
- * },
29
- * __( 'My sidebar title' )
30
- * )
31
- * }
32
- * ```
33
- *
34
- * @example
35
- * ```jsx
36
- * // Using ESNext syntax
37
- * import { __ } from '@wordpress/i18n';
38
- * import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
39
- * import { more } from '@wordpress/icons';
40
- *
41
- * const MySidebarMoreMenuItem = () => (
42
- * <PluginSidebarMoreMenuItem
43
- * target="my-sidebar"
44
- * icon={ more }
45
- * >
46
- * { __( 'My sidebar title' ) }
47
- * </PluginSidebarMoreMenuItem>
48
- * );
49
- * ```
50
- *
51
- * @return {Component} The component to be rendered.
52
- */
53
-
54
- export default function PluginSidebarMoreMenuItem( props ) {
55
- return (
56
- <ComplementaryAreaMoreMenuItem
57
- // Menu item is marked with unstable prop for backward compatibility.
58
- // @see https://github.com/WordPress/gutenberg/issues/14457
59
- __unstableExplicitMenuItem
60
- scope="core/edit-post"
61
- { ...props }
62
- />
63
- );
64
- }
@@ -1,53 +0,0 @@
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: { character: '[[' },
25
- description: __( 'Insert a link to a post or page.' ),
26
- },
27
- {
28
- keyCombination: { modifier: 'primary', character: 'u' },
29
- description: __( 'Underline the selected text.' ),
30
- },
31
- {
32
- keyCombination: { modifier: 'access', character: 'd' },
33
- description: __( 'Strikethrough the selected text.' ),
34
- },
35
- {
36
- keyCombination: { modifier: 'access', character: 'x' },
37
- description: __( 'Make the selected text inline code.' ),
38
- },
39
- {
40
- keyCombination: { modifier: 'access', character: '0' },
41
- description: __( 'Convert the current heading to a paragraph.' ),
42
- },
43
- {
44
- keyCombination: { modifier: 'access', character: '1-6' },
45
- description: __(
46
- 'Convert the current paragraph or heading to a heading of level 1 to 6.'
47
- ),
48
- },
49
- {
50
- keyCombination: { modifier: 'primaryShift', character: '\u00a0' },
51
- description: __( 'Add non breaking space.' ),
52
- },
53
- ];
@@ -1,43 +0,0 @@
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
- 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
- }
42
-
43
- export default DynamicShortcut;
@@ -1,159 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import classnames from 'classnames';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { Modal } from '@wordpress/components';
10
- import { __ } from '@wordpress/i18n';
11
- import {
12
- useShortcut,
13
- store as keyboardShortcutsStore,
14
- } from '@wordpress/keyboard-shortcuts';
15
- import { withSelect, withDispatch, useSelect } from '@wordpress/data';
16
- import { compose } from '@wordpress/compose';
17
- import { store as interfaceStore } from '@wordpress/interface';
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
- import { textFormattingShortcuts } from './config';
23
- import Shortcut from './shortcut';
24
- import DynamicShortcut from './dynamic-shortcut';
25
-
26
- export const KEYBOARD_SHORTCUT_HELP_MODAL_NAME =
27
- 'edit-post/keyboard-shortcut-help';
28
-
29
- const ShortcutList = ( { shortcuts } ) => (
30
- /*
31
- * Disable reason: The `list` ARIA role is redundant but
32
- * Safari+VoiceOver won't announce the list otherwise.
33
- */
34
- /* eslint-disable jsx-a11y/no-redundant-roles */
35
- <ul
36
- className="edit-post-keyboard-shortcut-help-modal__shortcut-list"
37
- role="list"
38
- >
39
- { shortcuts.map( ( shortcut, index ) => (
40
- <li
41
- className="edit-post-keyboard-shortcut-help-modal__shortcut"
42
- key={ index }
43
- >
44
- { typeof shortcut === 'string' ? (
45
- <DynamicShortcut name={ shortcut } />
46
- ) : (
47
- <Shortcut { ...shortcut } />
48
- ) }
49
- </li>
50
- ) ) }
51
- </ul>
52
- /* eslint-enable jsx-a11y/no-redundant-roles */
53
- );
54
-
55
- const ShortcutSection = ( { title, shortcuts, className } ) => (
56
- <section
57
- className={ classnames(
58
- 'edit-post-keyboard-shortcut-help-modal__section',
59
- className
60
- ) }
61
- >
62
- { !! title && (
63
- <h2 className="edit-post-keyboard-shortcut-help-modal__section-title">
64
- { title }
65
- </h2>
66
- ) }
67
- <ShortcutList shortcuts={ shortcuts } />
68
- </section>
69
- );
70
-
71
- const ShortcutCategorySection = ( {
72
- title,
73
- categoryName,
74
- additionalShortcuts = [],
75
- } ) => {
76
- const categoryShortcuts = useSelect(
77
- ( select ) => {
78
- return select( keyboardShortcutsStore ).getCategoryShortcuts(
79
- categoryName
80
- );
81
- },
82
- [ categoryName ]
83
- );
84
-
85
- return (
86
- <ShortcutSection
87
- title={ title }
88
- shortcuts={ categoryShortcuts.concat( additionalShortcuts ) }
89
- />
90
- );
91
- };
92
-
93
- export function KeyboardShortcutHelpModal( { isModalActive, toggleModal } ) {
94
- useShortcut( 'core/edit-post/keyboard-shortcuts', toggleModal );
95
-
96
- if ( ! isModalActive ) {
97
- return null;
98
- }
99
-
100
- return (
101
- <Modal
102
- className="edit-post-keyboard-shortcut-help-modal"
103
- title={ __( 'Keyboard shortcuts' ) }
104
- closeButtonLabel={ __( 'Close' ) }
105
- onRequestClose={ toggleModal }
106
- >
107
- <ShortcutSection
108
- className="edit-post-keyboard-shortcut-help-modal__main-shortcuts"
109
- shortcuts={ [ 'core/edit-post/keyboard-shortcuts' ] }
110
- />
111
- <ShortcutCategorySection
112
- title={ __( 'Global shortcuts' ) }
113
- categoryName="global"
114
- />
115
-
116
- <ShortcutCategorySection
117
- title={ __( 'Selection shortcuts' ) }
118
- categoryName="selection"
119
- />
120
-
121
- <ShortcutCategorySection
122
- title={ __( 'Block shortcuts' ) }
123
- categoryName="block"
124
- additionalShortcuts={ [
125
- {
126
- keyCombination: { character: '/' },
127
- description: __(
128
- 'Change the block type after adding a new paragraph.'
129
- ),
130
- /* translators: The forward-slash character. e.g. '/'. */
131
- ariaLabel: __( 'Forward-slash' ),
132
- },
133
- ] }
134
- />
135
- <ShortcutSection
136
- title={ __( 'Text formatting' ) }
137
- shortcuts={ textFormattingShortcuts }
138
- />
139
- </Modal>
140
- );
141
- }
142
-
143
- export default compose( [
144
- withSelect( ( select ) => ( {
145
- isModalActive: select( interfaceStore ).isModalActive(
146
- KEYBOARD_SHORTCUT_HELP_MODAL_NAME
147
- ),
148
- } ) ),
149
- withDispatch( ( dispatch, { isModalActive } ) => {
150
- const { openModal, closeModal } = dispatch( interfaceStore );
151
-
152
- return {
153
- toggleModal: () =>
154
- isModalActive
155
- ? closeModal()
156
- : openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME ),
157
- };
158
- } ),
159
- ] )( KeyboardShortcutHelpModal );
@@ -1,67 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Fragment } from '@wordpress/element';
5
- import { displayShortcutList, shortcutAriaLabel } from '@wordpress/keycodes';
6
-
7
- function KeyCombination( { keyCombination, forceAriaLabel } ) {
8
- const shortcut = keyCombination.modifier
9
- ? displayShortcutList[ keyCombination.modifier ](
10
- keyCombination.character
11
- )
12
- : keyCombination.character;
13
- const ariaLabel = keyCombination.modifier
14
- ? shortcutAriaLabel[ keyCombination.modifier ](
15
- keyCombination.character
16
- )
17
- : keyCombination.character;
18
-
19
- return (
20
- <kbd
21
- className="edit-post-keyboard-shortcut-help-modal__shortcut-key-combination"
22
- aria-label={ forceAriaLabel || ariaLabel }
23
- >
24
- { ( Array.isArray( shortcut ) ? shortcut : [ shortcut ] ).map(
25
- ( character, index ) => {
26
- if ( character === '+' ) {
27
- return <Fragment key={ index }>{ character }</Fragment>;
28
- }
29
-
30
- return (
31
- <kbd
32
- key={ index }
33
- className="edit-post-keyboard-shortcut-help-modal__shortcut-key"
34
- >
35
- { character }
36
- </kbd>
37
- );
38
- }
39
- ) }
40
- </kbd>
41
- );
42
- }
43
-
44
- function Shortcut( { description, keyCombination, aliases = [], ariaLabel } ) {
45
- return (
46
- <>
47
- <div className="edit-post-keyboard-shortcut-help-modal__shortcut-description">
48
- { description }
49
- </div>
50
- <div className="edit-post-keyboard-shortcut-help-modal__shortcut-term">
51
- <KeyCombination
52
- keyCombination={ keyCombination }
53
- forceAriaLabel={ ariaLabel }
54
- />
55
- { aliases.map( ( alias, index ) => (
56
- <KeyCombination
57
- keyCombination={ alias }
58
- forceAriaLabel={ ariaLabel }
59
- key={ index }
60
- />
61
- ) ) }
62
- </div>
63
- </>
64
- );
65
- }
66
-
67
- export default Shortcut;