@wordpress/edit-post 7.25.0 → 7.26.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 (199) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/browser-url/index.js +3 -2
  4. package/build/components/browser-url/index.js.map +1 -1
  5. package/build/components/header/index.js +25 -25
  6. package/build/components/header/index.js.map +1 -1
  7. package/build/components/header/writing-menu/index.js +11 -8
  8. package/build/components/header/writing-menu/index.js.map +1 -1
  9. package/build/components/keyboard-shortcuts/index.js +1 -20
  10. package/build/components/keyboard-shortcuts/index.js.map +1 -1
  11. package/build/components/layout/index.js +33 -26
  12. package/build/components/layout/index.js.map +1 -1
  13. package/build/components/layout/index.native.js +3 -1
  14. package/build/components/layout/index.native.js.map +1 -1
  15. package/build/components/meta-boxes/meta-box-visibility.js +2 -6
  16. package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
  17. package/build/components/preferences-modal/index.js +25 -8
  18. package/build/components/preferences-modal/index.js.map +1 -1
  19. package/build/components/preferences-modal/options/enable-feature.js +23 -23
  20. package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
  21. package/build/components/preferences-modal/options/enable-panel.js +3 -6
  22. package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
  23. package/build/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  24. package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
  25. package/build/components/sidebar/plugin-sidebar/index.js +2 -10
  26. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  27. package/build/components/sidebar/post-status/index.js +2 -3
  28. package/build/components/sidebar/post-status/index.js.map +1 -1
  29. package/build/components/sidebar/settings-sidebar/index.js +1 -7
  30. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  31. package/build/editor.js +19 -28
  32. package/build/editor.js.map +1 -1
  33. package/build/editor.native.js +3 -10
  34. package/build/editor.native.js.map +1 -1
  35. package/build/hooks/commands/use-common-commands.js +16 -12
  36. package/build/hooks/commands/use-common-commands.js.map +1 -1
  37. package/build/hooks/use-post-history.js +79 -0
  38. package/build/hooks/use-post-history.js.map +1 -0
  39. package/build/index.js +19 -16
  40. package/build/index.js.map +1 -1
  41. package/build/index.native.js +7 -1
  42. package/build/index.native.js.map +1 -1
  43. package/build/store/actions.js +59 -73
  44. package/build/store/actions.js.map +1 -1
  45. package/build/store/reducer.js +1 -62
  46. package/build/store/reducer.js.map +1 -1
  47. package/build/store/selectors.js +66 -38
  48. package/build/store/selectors.js.map +1 -1
  49. package/build-module/components/browser-url/index.js +3 -2
  50. package/build-module/components/browser-url/index.js.map +1 -1
  51. package/build-module/components/header/index.js +25 -25
  52. package/build-module/components/header/index.js.map +1 -1
  53. package/build-module/components/header/writing-menu/index.js +11 -8
  54. package/build-module/components/header/writing-menu/index.js.map +1 -1
  55. package/build-module/components/keyboard-shortcuts/index.js +1 -20
  56. package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
  57. package/build-module/components/layout/index.js +33 -25
  58. package/build-module/components/layout/index.js.map +1 -1
  59. package/build-module/components/layout/index.native.js +4 -2
  60. package/build-module/components/layout/index.native.js.map +1 -1
  61. package/build-module/components/meta-boxes/meta-box-visibility.js +2 -6
  62. package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
  63. package/build-module/components/preferences-modal/index.js +25 -8
  64. package/build-module/components/preferences-modal/index.js.map +1 -1
  65. package/build-module/components/preferences-modal/options/enable-feature.js +22 -23
  66. package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
  67. package/build-module/components/preferences-modal/options/enable-panel.js +3 -7
  68. package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
  69. package/build-module/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  70. package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
  71. package/build-module/components/sidebar/plugin-sidebar/index.js +2 -10
  72. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  73. package/build-module/components/sidebar/post-status/index.js +3 -4
  74. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  75. package/build-module/components/sidebar/settings-sidebar/index.js +2 -8
  76. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  77. package/build-module/editor.js +19 -28
  78. package/build-module/editor.js.map +1 -1
  79. package/build-module/editor.native.js +3 -10
  80. package/build-module/editor.native.js.map +1 -1
  81. package/build-module/hooks/commands/use-common-commands.js +16 -12
  82. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  83. package/build-module/hooks/use-post-history.js +73 -0
  84. package/build-module/hooks/use-post-history.js.map +1 -0
  85. package/build-module/index.js +17 -11
  86. package/build-module/index.js.map +1 -1
  87. package/build-module/index.native.js +7 -1
  88. package/build-module/index.native.js.map +1 -1
  89. package/build-module/store/actions.js +55 -69
  90. package/build-module/store/actions.js.map +1 -1
  91. package/build-module/store/reducer.js +1 -60
  92. package/build-module/store/reducer.js.map +1 -1
  93. package/build-module/store/selectors.js +58 -29
  94. package/build-module/store/selectors.js.map +1 -1
  95. package/build-style/style-rtl.css +13 -284
  96. package/build-style/style.css +13 -284
  97. package/package.json +32 -32
  98. package/src/components/browser-url/index.js +4 -2
  99. package/src/components/header/index.js +24 -40
  100. package/src/components/header/style.scss +3 -3
  101. package/src/components/header/writing-menu/index.js +10 -8
  102. package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -15
  103. package/src/components/keyboard-shortcuts/index.js +1 -23
  104. package/src/components/layout/index.js +18 -27
  105. package/src/components/layout/index.native.js +9 -1
  106. package/src/components/meta-boxes/meta-box-visibility.js +2 -8
  107. package/src/components/preferences-modal/index.js +27 -9
  108. package/src/components/preferences-modal/options/enable-feature.js +26 -21
  109. package/src/components/preferences-modal/options/enable-panel.js +3 -7
  110. package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +187 -175
  111. package/src/components/sidebar/plugin-document-setting-panel/index.js +3 -3
  112. package/src/components/sidebar/plugin-sidebar/index.js +1 -9
  113. package/src/components/sidebar/post-status/index.js +3 -3
  114. package/src/components/sidebar/settings-sidebar/index.js +15 -13
  115. package/src/components/text-editor/style.scss +0 -6
  116. package/src/editor.js +34 -33
  117. package/src/editor.native.js +2 -17
  118. package/src/hooks/commands/use-common-commands.js +14 -16
  119. package/src/hooks/use-post-history.js +73 -0
  120. package/src/index.js +22 -12
  121. package/src/index.native.js +8 -1
  122. package/src/store/actions.js +48 -85
  123. package/src/store/reducer.js +0 -60
  124. package/src/store/selectors.js +74 -46
  125. package/src/store/test/actions.js +10 -103
  126. package/src/store/test/reducer.js +1 -108
  127. package/src/store/test/selectors.js +0 -50
  128. package/src/style.scss +1 -5
  129. package/src/test/editor.native.js +17 -0
  130. package/build/components/header/header-toolbar/index.js +0 -160
  131. package/build/components/header/header-toolbar/index.js.map +0 -1
  132. package/build/components/secondary-sidebar/inserter-sidebar.js +0 -73
  133. package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  134. package/build/components/secondary-sidebar/list-view-outline.js +0 -112
  135. package/build/components/secondary-sidebar/list-view-outline.js.map +0 -1
  136. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -148
  137. package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  138. package/build/components/sidebar/discussion-panel/index.js +0 -59
  139. package/build/components/sidebar/discussion-panel/index.js.map +0 -1
  140. package/build/components/sidebar/featured-image/index.js +0 -70
  141. package/build/components/sidebar/featured-image/index.js.map +0 -1
  142. package/build/components/sidebar/last-revision/index.js +0 -21
  143. package/build/components/sidebar/last-revision/index.js.map +0 -1
  144. package/build/components/sidebar/page-attributes/index.js +0 -65
  145. package/build/components/sidebar/page-attributes/index.js.map +0 -1
  146. package/build/components/sidebar/plugin-post-excerpt/index.js +0 -72
  147. package/build/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
  148. package/build/components/sidebar/post-excerpt/index.js +0 -54
  149. package/build/components/sidebar/post-excerpt/index.js.map +0 -1
  150. package/build/components/sidebar/post-taxonomies/index.js +0 -30
  151. package/build/components/sidebar/post-taxonomies/index.js.map +0 -1
  152. package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -56
  153. package/build/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
  154. package/build/components/view-link/index.js +0 -53
  155. package/build/components/view-link/index.js.map +0 -1
  156. package/build-module/components/header/header-toolbar/index.js +0 -152
  157. package/build-module/components/header/header-toolbar/index.js.map +0 -1
  158. package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -66
  159. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  160. package/build-module/components/secondary-sidebar/list-view-outline.js +0 -105
  161. package/build-module/components/secondary-sidebar/list-view-outline.js.map +0 -1
  162. package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -140
  163. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  164. package/build-module/components/sidebar/discussion-panel/index.js +0 -52
  165. package/build-module/components/sidebar/discussion-panel/index.js.map +0 -1
  166. package/build-module/components/sidebar/featured-image/index.js +0 -63
  167. package/build-module/components/sidebar/featured-image/index.js.map +0 -1
  168. package/build-module/components/sidebar/last-revision/index.js +0 -13
  169. package/build-module/components/sidebar/last-revision/index.js.map +0 -1
  170. package/build-module/components/sidebar/page-attributes/index.js +0 -57
  171. package/build-module/components/sidebar/page-attributes/index.js.map +0 -1
  172. package/build-module/components/sidebar/plugin-post-excerpt/index.js +0 -64
  173. package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
  174. package/build-module/components/sidebar/post-excerpt/index.js +0 -47
  175. package/build-module/components/sidebar/post-excerpt/index.js.map +0 -1
  176. package/build-module/components/sidebar/post-taxonomies/index.js +0 -21
  177. package/build-module/components/sidebar/post-taxonomies/index.js.map +0 -1
  178. package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
  179. package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
  180. package/build-module/components/view-link/index.js +0 -46
  181. package/build-module/components/view-link/index.js.map +0 -1
  182. package/src/components/header/header-toolbar/index.js +0 -186
  183. package/src/components/header/header-toolbar/style.scss +0 -116
  184. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +0 -929
  185. package/src/components/secondary-sidebar/inserter-sidebar.js +0 -71
  186. package/src/components/secondary-sidebar/list-view-outline.js +0 -98
  187. package/src/components/secondary-sidebar/list-view-sidebar.js +0 -170
  188. package/src/components/secondary-sidebar/style.scss +0 -120
  189. package/src/components/sidebar/discussion-panel/index.js +0 -62
  190. package/src/components/sidebar/featured-image/index.js +0 -67
  191. package/src/components/sidebar/last-revision/index.js +0 -17
  192. package/src/components/sidebar/last-revision/style.scss +0 -10
  193. package/src/components/sidebar/page-attributes/index.js +0 -65
  194. package/src/components/sidebar/plugin-post-excerpt/index.js +0 -61
  195. package/src/components/sidebar/plugin-post-excerpt/test/index.js +0 -36
  196. package/src/components/sidebar/post-excerpt/index.js +0 -59
  197. package/src/components/sidebar/post-taxonomies/index.js +0 -30
  198. package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
  199. package/src/components/view-link/index.js +0 -48
@@ -1,71 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useDispatch, useSelect } from '@wordpress/data';
5
- import { Button, VisuallyHidden } from '@wordpress/components';
6
- import { __experimentalLibrary as Library } from '@wordpress/block-editor';
7
- import { close } from '@wordpress/icons';
8
- import {
9
- useViewportMatch,
10
- __experimentalUseDialog as useDialog,
11
- } from '@wordpress/compose';
12
- import { __ } from '@wordpress/i18n';
13
- import { useEffect, useRef } from '@wordpress/element';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import { store as editPostStore } from '../../store';
19
-
20
- export default function InserterSidebar() {
21
- const { insertionPoint, showMostUsedBlocks } = useSelect( ( select ) => {
22
- const { isFeatureActive, __experimentalGetInsertionPoint } =
23
- select( editPostStore );
24
- return {
25
- insertionPoint: __experimentalGetInsertionPoint(),
26
- showMostUsedBlocks: isFeatureActive( 'mostUsedBlocks' ),
27
- };
28
- }, [] );
29
- const { setIsInserterOpened } = useDispatch( editPostStore );
30
-
31
- const isMobileViewport = useViewportMatch( 'medium', '<' );
32
- const TagName = ! isMobileViewport ? VisuallyHidden : 'div';
33
- const [ inserterDialogRef, inserterDialogProps ] = useDialog( {
34
- onClose: () => setIsInserterOpened( false ),
35
- focusOnMount: null,
36
- } );
37
-
38
- const libraryRef = useRef();
39
- useEffect( () => {
40
- libraryRef.current.focusSearch();
41
- }, [] );
42
-
43
- return (
44
- <div
45
- ref={ inserterDialogRef }
46
- { ...inserterDialogProps }
47
- className="edit-post-editor__inserter-panel"
48
- >
49
- <TagName className="edit-post-editor__inserter-panel-header">
50
- <Button
51
- icon={ close }
52
- label={ __( 'Close block inserter' ) }
53
- onClick={ () => setIsInserterOpened( false ) }
54
- />
55
- </TagName>
56
- <div className="edit-post-editor__inserter-panel-content">
57
- <Library
58
- showMostUsedBlocks={ showMostUsedBlocks }
59
- showInserterHelpPanel
60
- shouldFocusBlock={ isMobileViewport }
61
- rootClientId={ insertionPoint.rootClientId }
62
- __experimentalInsertionIndex={
63
- insertionPoint.insertionIndex
64
- }
65
- __experimentalFilterValue={ insertionPoint.filterValue }
66
- ref={ libraryRef }
67
- />
68
- </div>
69
- </div>
70
- );
71
- }
@@ -1,98 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
- import {
6
- DocumentOutline,
7
- WordCount,
8
- TimeToRead,
9
- CharacterCount,
10
- } from '@wordpress/editor';
11
- import { store as blockEditorStore } from '@wordpress/block-editor';
12
- import {
13
- __experimentalText as Text,
14
- Path,
15
- SVG,
16
- Line,
17
- Rect,
18
- } from '@wordpress/components';
19
- import { __ } from '@wordpress/i18n';
20
-
21
- function EmptyOutlineIllustration() {
22
- return (
23
- <SVG
24
- width="138"
25
- height="148"
26
- viewBox="0 0 138 148"
27
- fill="none"
28
- xmlns="http://www.w3.org/2000/svg"
29
- >
30
- <Rect width="138" height="148" rx="4" fill="#F0F6FC" />
31
- <Line x1="44" y1="28" x2="24" y2="28" stroke="#DDDDDD" />
32
- <Rect x="48" y="16" width="27" height="23" rx="4" fill="#DDDDDD" />
33
- <Path
34
- d="M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z"
35
- fill="black"
36
- />
37
- <Line x1="55" y1="59" x2="24" y2="59" stroke="#DDDDDD" />
38
- <Rect x="59" y="47" width="29" height="23" rx="4" fill="#DDDDDD" />
39
- <Path
40
- d="M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z"
41
- fill="black"
42
- />
43
- <Line x1="80" y1="90" x2="24" y2="90" stroke="#DDDDDD" />
44
- <Rect x="84" y="78" width="30" height="23" rx="4" fill="#F0B849" />
45
- <Path
46
- d="M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z"
47
- fill="black"
48
- />
49
- <Line x1="66" y1="121" x2="24" y2="121" stroke="#DDDDDD" />
50
- <Rect x="70" y="109" width="29" height="23" rx="4" fill="#DDDDDD" />
51
- <Path
52
- d="M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z"
53
- fill="black"
54
- />
55
- </SVG>
56
- );
57
- }
58
-
59
- export default function ListViewOutline() {
60
- const { headingCount } = useSelect( ( select ) => {
61
- const { getGlobalBlockCount } = select( blockEditorStore );
62
- return {
63
- headingCount: getGlobalBlockCount( 'core/heading' ),
64
- };
65
- }, [] );
66
- return (
67
- <>
68
- <div className="edit-post-editor__list-view-overview">
69
- <div>
70
- <Text>{ __( 'Characters:' ) }</Text>
71
- <Text>
72
- <CharacterCount />
73
- </Text>
74
- </div>
75
- <div>
76
- <Text>{ __( 'Words:' ) }</Text>
77
- <WordCount />
78
- </div>
79
- <div>
80
- <Text>{ __( 'Time to read:' ) }</Text>
81
- <TimeToRead />
82
- </div>
83
- </div>
84
- { headingCount > 0 ? (
85
- <DocumentOutline />
86
- ) : (
87
- <div className="edit-post-editor__list-view-empty-headings">
88
- <EmptyOutlineIllustration />
89
- <p>
90
- { __(
91
- 'Navigate the structure of your document and address issues like empty or incorrect heading levels.'
92
- ) }
93
- </p>
94
- </div>
95
- ) }
96
- </>
97
- );
98
- }
@@ -1,170 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __experimentalListView as ListView } from '@wordpress/block-editor';
5
- import { Button, TabPanel } from '@wordpress/components';
6
- import { useFocusOnMount, useMergeRefs } from '@wordpress/compose';
7
- import { useDispatch } from '@wordpress/data';
8
- import { focus } from '@wordpress/dom';
9
- import { useCallback, useRef, useState } from '@wordpress/element';
10
- import { __, _x } from '@wordpress/i18n';
11
- import { closeSmall } from '@wordpress/icons';
12
- import { useShortcut } from '@wordpress/keyboard-shortcuts';
13
- import { ESCAPE } from '@wordpress/keycodes';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import { store as editPostStore } from '../../store';
19
- import ListViewOutline from './list-view-outline';
20
-
21
- export default function ListViewSidebar( { listViewToggleElement } ) {
22
- const { setIsListViewOpened } = useDispatch( editPostStore );
23
-
24
- // This hook handles focus when the sidebar first renders.
25
- const focusOnMountRef = useFocusOnMount( 'firstElement' );
26
-
27
- // When closing the list view, focus should return to the toggle button.
28
- const closeListView = useCallback( () => {
29
- setIsListViewOpened( false );
30
- listViewToggleElement?.focus();
31
- }, [ listViewToggleElement, setIsListViewOpened ] );
32
-
33
- const closeOnEscape = useCallback(
34
- ( event ) => {
35
- if ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {
36
- event.preventDefault();
37
- closeListView();
38
- }
39
- },
40
- [ closeListView ]
41
- );
42
-
43
- // Use internal state instead of a ref to make sure that the component
44
- // re-renders when the dropZoneElement updates.
45
- const [ dropZoneElement, setDropZoneElement ] = useState( null );
46
- // Tracks our current tab.
47
- const [ tab, setTab ] = useState( 'list-view' );
48
-
49
- // This ref refers to the sidebar as a whole.
50
- const sidebarRef = useRef();
51
- // This ref refers to the tab panel.
52
- const tabPanelRef = useRef();
53
- // This ref refers to the list view application area.
54
- const listViewRef = useRef();
55
-
56
- // Must merge the refs together so focus can be handled properly in the next function.
57
- const listViewContainerRef = useMergeRefs( [
58
- focusOnMountRef,
59
- listViewRef,
60
- setDropZoneElement,
61
- ] );
62
-
63
- /*
64
- * Callback function to handle list view or outline focus.
65
- *
66
- * @param {string} currentTab The current tab. Either list view or outline.
67
- *
68
- * @return void
69
- */
70
- function handleSidebarFocus( currentTab ) {
71
- // Tab panel focus.
72
- const tabPanelFocus = focus.tabbable.find( tabPanelRef.current )[ 0 ];
73
- // List view tab is selected.
74
- if ( currentTab === 'list-view' ) {
75
- // Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
76
- const listViewApplicationFocus = focus.tabbable.find(
77
- listViewRef.current
78
- )[ 0 ];
79
- const listViewFocusArea = sidebarRef.current.contains(
80
- listViewApplicationFocus
81
- )
82
- ? listViewApplicationFocus
83
- : tabPanelFocus;
84
- listViewFocusArea.focus();
85
- // Outline tab is selected.
86
- } else {
87
- tabPanelFocus.focus();
88
- }
89
- }
90
-
91
- const handleToggleListViewShortcut = useCallback( () => {
92
- // If the sidebar has focus, it is safe to close.
93
- if (
94
- sidebarRef.current.contains(
95
- sidebarRef.current.ownerDocument.activeElement
96
- )
97
- ) {
98
- closeListView();
99
- } else {
100
- // If the list view or outline does not have focus, focus should be moved to it.
101
- handleSidebarFocus( tab );
102
- }
103
- }, [ closeListView, tab ] );
104
-
105
- // This only fires when the sidebar is open because of the conditional rendering.
106
- // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
107
- useShortcut(
108
- 'core/edit-post/toggle-list-view',
109
- handleToggleListViewShortcut
110
- );
111
-
112
- /**
113
- * Render tab content for a given tab name.
114
- *
115
- * @param {string} tabName The name of the tab to render.
116
- */
117
- function renderTabContent( tabName ) {
118
- if ( tabName === 'list-view' ) {
119
- return (
120
- <div className="edit-post-editor__list-view-panel-content">
121
- <ListView dropZoneElement={ dropZoneElement } />
122
- </div>
123
- );
124
- }
125
- return <ListViewOutline />;
126
- }
127
-
128
- return (
129
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
130
- <div
131
- className="edit-post-editor__document-overview-panel"
132
- onKeyDown={ closeOnEscape }
133
- ref={ sidebarRef }
134
- >
135
- <Button
136
- className="edit-post-editor__document-overview-panel__close-button"
137
- icon={ closeSmall }
138
- label={ __( 'Close' ) }
139
- onClick={ closeListView }
140
- />
141
- <TabPanel
142
- className="edit-post-editor__document-overview-panel__tab-panel"
143
- ref={ tabPanelRef }
144
- onSelect={ ( tabName ) => setTab( tabName ) }
145
- selectOnMove={ false }
146
- tabs={ [
147
- {
148
- name: 'list-view',
149
- title: _x( 'List View', 'Post overview' ),
150
- className: 'edit-post-sidebar__panel-tab',
151
- },
152
- {
153
- name: 'outline',
154
- title: _x( 'Outline', 'Post overview' ),
155
- className: 'edit-post-sidebar__panel-tab',
156
- },
157
- ] }
158
- >
159
- { ( currentTab ) => (
160
- <div
161
- className="edit-post-editor__list-view-container"
162
- ref={ listViewContainerRef }
163
- >
164
- { renderTabContent( currentTab.name ) }
165
- </div>
166
- ) }
167
- </TabPanel>
168
- </div>
169
- );
170
- }
@@ -1,120 +0,0 @@
1
- /**
2
- * Note that this CSS file should be in sync with its counterpart in the other editor:
3
- * packages/edit-site/src/components/secondary-sidebar/style.scss
4
- */
5
-
6
- .edit-post-editor__inserter-panel,
7
- .edit-post-editor__document-overview-panel {
8
- height: 100%;
9
- display: flex;
10
- flex-direction: column;
11
- }
12
-
13
- .edit-post-editor__document-overview-panel {
14
- @include break-medium() {
15
- // Same width as the Inserter.
16
- // @see packages/block-editor/src/components/inserter/style.scss
17
- width: 350px;
18
- }
19
-
20
- .edit-post-editor__document-overview-panel__close-button {
21
- position: absolute;
22
- right: $grid-unit-10;
23
- top: math.div($grid-unit-60 - $button-size, 2); // ( tab height - button size ) / 2
24
- z-index: 1;
25
- background: $white;
26
- }
27
-
28
- // The TabPanel style overrides in the following blocks should be removed when the new TabPanel is available.
29
- .components-tab-panel__tabs {
30
- border-bottom: $border-width solid $gray-300;
31
- box-sizing: border-box;
32
- display: flex;
33
- width: 100%;
34
- padding-right: $grid-unit-70;
35
-
36
- .edit-post-sidebar__panel-tab {
37
- width: 50%;
38
- margin-bottom: -$border-width;
39
- }
40
- }
41
-
42
- .components-tab-panel__tab-content {
43
- height: calc(100% - #{$grid-unit-60 - $border-width});
44
- }
45
- }
46
-
47
- .edit-post-editor__inserter-panel-header {
48
- padding-top: $grid-unit-10;
49
- padding-right: $grid-unit-10;
50
- display: flex;
51
- justify-content: flex-end;
52
- }
53
-
54
- .edit-post-editor__inserter-panel-content {
55
- // Leave space for the close button
56
- height: calc(100% - #{$button-size} - #{$grid-unit-10});
57
- @include break-medium() {
58
- height: 100%;
59
- }
60
- }
61
-
62
- .edit-post-editor__list-view-panel-content,
63
- .edit-post-editor__list-view-container > .document-outline,
64
- .edit-post-editor__list-view-empty-headings {
65
- height: 100%;
66
-
67
- // Include custom scrollbars, invisible until hovered.
68
- @include custom-scrollbars-on-hover(transparent, $gray-600);
69
- overflow: auto;
70
-
71
- // Only reserve space for scrollbars when there is content to scroll.
72
- // This allows items in the list view to have equidistant padding left and right
73
- // right up until a scrollbar is present.
74
- scrollbar-gutter: auto;
75
-
76
- // The table cells use an extra pixels of space left and right. We compensate for that here.
77
- padding: $grid-unit-10 ($grid-unit-10 - $border-width - $border-width);
78
- }
79
-
80
- .edit-post-editor__list-view-empty-headings {
81
- & > svg {
82
- margin-top: $grid-unit-30 + $grid-unit-05;
83
- }
84
- & > p {
85
- padding-left: $grid-unit-40;
86
- padding-right: $grid-unit-40;
87
- }
88
- text-align: center;
89
- color: $gray-700;
90
- }
91
-
92
- .edit-post-editor__list-view-overview {
93
- display: flex;
94
- flex-direction: column;
95
- gap: $grid-unit-10;
96
- border-bottom: $border-width solid $gray-300;
97
- padding: $grid-unit-20;
98
-
99
- & > div > span:first-child {
100
- // Width of the text information fields.
101
- width: 90px;
102
- display: inline-block;
103
- }
104
-
105
- & > div > span {
106
- font-size: $helptext-font-size;
107
- line-height: $default-line-height;
108
- color: $gray-700;
109
- }
110
- }
111
-
112
- .edit-post-editor__list-view-container {
113
- display: flex;
114
- flex-direction: column;
115
- height: 100%;
116
- }
117
-
118
- .edit-post-editor__document-overview-panel__tab-panel {
119
- height: 100%;
120
- }
@@ -1,62 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { PanelBody, PanelRow } from '@wordpress/components';
6
- import {
7
- PostComments,
8
- PostPingbacks,
9
- PostTypeSupportCheck,
10
- } from '@wordpress/editor';
11
- import { useDispatch, useSelect } from '@wordpress/data';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { store as editPostStore } from '../../../store';
17
-
18
- /**
19
- * Module Constants
20
- */
21
- const PANEL_NAME = 'discussion-panel';
22
-
23
- function DiscussionPanel() {
24
- const { isEnabled, isOpened } = useSelect( ( select ) => {
25
- const { isEditorPanelEnabled, isEditorPanelOpened } =
26
- select( editPostStore );
27
- return {
28
- isEnabled: isEditorPanelEnabled( PANEL_NAME ),
29
- isOpened: isEditorPanelOpened( PANEL_NAME ),
30
- };
31
- }, [] );
32
-
33
- const { toggleEditorPanelOpened } = useDispatch( editPostStore );
34
-
35
- if ( ! isEnabled ) {
36
- return null;
37
- }
38
-
39
- return (
40
- <PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
41
- <PanelBody
42
- title={ __( 'Discussion' ) }
43
- opened={ isOpened }
44
- onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
45
- >
46
- <PostTypeSupportCheck supportKeys="comments">
47
- <PanelRow>
48
- <PostComments />
49
- </PanelRow>
50
- </PostTypeSupportCheck>
51
-
52
- <PostTypeSupportCheck supportKeys="trackbacks">
53
- <PanelRow>
54
- <PostPingbacks />
55
- </PanelRow>
56
- </PostTypeSupportCheck>
57
- </PanelBody>
58
- </PostTypeSupportCheck>
59
- );
60
- }
61
-
62
- export default DiscussionPanel;
@@ -1,67 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { PanelBody } from '@wordpress/components';
6
- import {
7
- PostFeaturedImage,
8
- PostFeaturedImageCheck,
9
- store as editorStore,
10
- } from '@wordpress/editor';
11
- import { compose } from '@wordpress/compose';
12
- import { withSelect, withDispatch } from '@wordpress/data';
13
- import { store as coreStore } from '@wordpress/core-data';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import { store as editPostStore } from '../../../store';
19
-
20
- /**
21
- * Module Constants
22
- */
23
- const PANEL_NAME = 'featured-image';
24
-
25
- function FeaturedImage( { isEnabled, isOpened, postType, onTogglePanel } ) {
26
- if ( ! isEnabled ) {
27
- return null;
28
- }
29
-
30
- return (
31
- <PostFeaturedImageCheck>
32
- <PanelBody
33
- title={
34
- postType?.labels?.featured_image ?? __( 'Featured image' )
35
- }
36
- opened={ isOpened }
37
- onToggle={ onTogglePanel }
38
- >
39
- <PostFeaturedImage />
40
- </PanelBody>
41
- </PostFeaturedImageCheck>
42
- );
43
- }
44
-
45
- const applyWithSelect = withSelect( ( select ) => {
46
- const { getEditedPostAttribute } = select( editorStore );
47
- const { getPostType } = select( coreStore );
48
- const { isEditorPanelEnabled, isEditorPanelOpened } =
49
- select( editPostStore );
50
-
51
- return {
52
- postType: getPostType( getEditedPostAttribute( 'type' ) ),
53
- isEnabled: isEditorPanelEnabled( PANEL_NAME ),
54
- isOpened: isEditorPanelOpened( PANEL_NAME ),
55
- };
56
- } );
57
-
58
- const applyWithDispatch = withDispatch( ( dispatch ) => {
59
- const { toggleEditorPanelOpened } = dispatch( editPostStore );
60
-
61
- return {
62
- onTogglePanel: ( ...args ) =>
63
- toggleEditorPanelOpened( PANEL_NAME, ...args ),
64
- };
65
- } );
66
-
67
- export default compose( applyWithSelect, applyWithDispatch )( FeaturedImage );
@@ -1,17 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { PanelBody } from '@wordpress/components';
5
- import { PostLastRevision, PostLastRevisionCheck } from '@wordpress/editor';
6
-
7
- function LastRevision() {
8
- return (
9
- <PostLastRevisionCheck>
10
- <PanelBody className="edit-post-last-revision__panel">
11
- <PostLastRevision />
12
- </PanelBody>
13
- </PostLastRevisionCheck>
14
- );
15
- }
16
-
17
- export default LastRevision;
@@ -1,10 +0,0 @@
1
- // Needs specificity, because this panel is just a button
2
- .components-panel__body.is-opened.edit-post-last-revision__panel {
3
- padding: 0;
4
- height: $grid-unit-60;
5
- }
6
-
7
- // Needs specificity to override button styles.
8
- .editor-post-last-revision__title.components-button.components-button {
9
- padding: $grid-unit-20;
10
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
- import { PanelBody, PanelRow } from '@wordpress/components';
6
- import {
7
- store as editorStore,
8
- PageAttributesCheck,
9
- PageAttributesOrder,
10
- PageAttributesParent,
11
- } from '@wordpress/editor';
12
- import { useSelect, useDispatch } from '@wordpress/data';
13
- import { store as coreStore } from '@wordpress/core-data';
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
- import { store as editPostStore } from '../../../store';
19
-
20
- /**
21
- * Module Constants
22
- */
23
- const PANEL_NAME = 'page-attributes';
24
-
25
- export function PageAttributes() {
26
- const { isEnabled, isOpened, postType } = useSelect( ( select ) => {
27
- const { getEditedPostAttribute } = select( editorStore );
28
- const { isEditorPanelEnabled, isEditorPanelOpened } =
29
- select( editPostStore );
30
- const { getPostType } = select( coreStore );
31
- return {
32
- isEnabled: isEditorPanelEnabled( PANEL_NAME ),
33
- isOpened: isEditorPanelOpened( PANEL_NAME ),
34
- postType: getPostType( getEditedPostAttribute( 'type' ) ),
35
- };
36
- }, [] );
37
-
38
- const { toggleEditorPanelOpened } = useDispatch( editPostStore );
39
-
40
- if ( ! isEnabled || ! postType ) {
41
- return null;
42
- }
43
-
44
- const onTogglePanel = ( ...args ) =>
45
- toggleEditorPanelOpened( PANEL_NAME, ...args );
46
-
47
- return (
48
- <PageAttributesCheck>
49
- <PanelBody
50
- title={
51
- postType?.labels?.attributes ?? __( 'Page attributes' )
52
- }
53
- opened={ isOpened }
54
- onToggle={ onTogglePanel }
55
- >
56
- <PageAttributesParent />
57
- <PanelRow>
58
- <PageAttributesOrder />
59
- </PanelRow>
60
- </PanelBody>
61
- </PageAttributesCheck>
62
- );
63
- }
64
-
65
- export default PageAttributes;