@wordpress/editor 13.33.0 → 13.34.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 (303) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +132 -20
  3. package/build/components/autosave-monitor/index.js +15 -12
  4. package/build/components/autosave-monitor/index.js.map +1 -1
  5. package/build/components/character-count/index.js +5 -0
  6. package/build/components/character-count/index.js.map +1 -1
  7. package/build/components/collapsible-block-toolbar/index.js +73 -0
  8. package/build/components/collapsible-block-toolbar/index.js.map +1 -0
  9. package/build/components/document-outline/check.js +8 -0
  10. package/build/components/document-outline/check.js.map +1 -1
  11. package/build/components/document-outline/index.js +11 -0
  12. package/build/components/document-outline/index.js.map +1 -1
  13. package/build/components/document-tools/index.js +0 -7
  14. package/build/components/document-tools/index.js.map +1 -1
  15. package/build/components/editor-canvas/edit-template-blocks-notification.js +1 -1
  16. package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  17. package/build/components/editor-history/redo.js +11 -0
  18. package/build/components/editor-history/redo.js.map +1 -1
  19. package/build/components/editor-history/undo.js +11 -0
  20. package/build/components/editor-history/undo.js.map +1 -1
  21. package/build/components/editor-snackbars/index.js +6 -0
  22. package/build/components/editor-snackbars/index.js.map +1 -1
  23. package/build/components/global-keyboard-shortcuts/index.js +7 -0
  24. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  25. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +34 -0
  26. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  27. package/build/components/inserter-sidebar/index.js +1 -4
  28. package/build/components/inserter-sidebar/index.js.map +1 -1
  29. package/build/components/keyboard-shortcut-help-modal/config.js +4 -0
  30. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  31. package/build/components/list-view-sidebar/index.js +1 -1
  32. package/build/components/list-view-sidebar/index.js.map +1 -1
  33. package/build/components/more-menu/copy-content-menu-item.js +59 -0
  34. package/build/components/more-menu/copy-content-menu-item.js.map +1 -0
  35. package/build/components/more-menu/index.js +119 -0
  36. package/build/components/more-menu/index.js.map +1 -0
  37. package/build/components/more-menu/tools-more-menu-group.js +23 -0
  38. package/build/components/more-menu/tools-more-menu-group.js.map +1 -0
  39. package/build/components/more-menu/view-more-menu-group.js +24 -0
  40. package/build/components/more-menu/view-more-menu-group.js.map +1 -0
  41. package/build/components/page-attributes/check.js +8 -0
  42. package/build/components/page-attributes/check.js.map +1 -1
  43. package/build/components/page-attributes/order.js +7 -0
  44. package/build/components/page-attributes/order.js.map +1 -1
  45. package/build/components/page-attributes/panel.js +14 -8
  46. package/build/components/page-attributes/panel.js.map +1 -1
  47. package/build/components/page-attributes/parent.js +7 -0
  48. package/build/components/page-attributes/parent.js.map +1 -1
  49. package/build/components/plugin-post-publish-panel/index.js +1 -1
  50. package/build/components/plugin-post-publish-panel/index.js.map +1 -1
  51. package/build/components/plugin-pre-publish-panel/index.js +1 -1
  52. package/build/components/plugin-pre-publish-panel/index.js.map +1 -1
  53. package/build/components/plugin-sidebar/index.js +1 -1
  54. package/build/components/plugin-sidebar/index.js.map +1 -1
  55. package/build/components/post-actions/actions.js +100 -5
  56. package/build/components/post-actions/actions.js.map +1 -1
  57. package/build/components/post-actions/index.js +30 -7
  58. package/build/components/post-actions/index.js.map +1 -1
  59. package/build/components/post-author/check.js +9 -0
  60. package/build/components/post-author/check.js.map +1 -1
  61. package/build/components/post-author/index.js +6 -0
  62. package/build/components/post-author/index.js.map +1 -1
  63. package/build/components/post-author/panel.js +5 -0
  64. package/build/components/post-author/panel.js.map +1 -1
  65. package/build/components/post-card-panel/index.js +14 -49
  66. package/build/components/post-card-panel/index.js.map +1 -1
  67. package/build/components/post-content-information/index.js +72 -0
  68. package/build/components/post-content-information/index.js.map +1 -0
  69. package/build/components/post-discussion/panel.js +9 -7
  70. package/build/components/post-discussion/panel.js.map +1 -1
  71. package/build/components/post-excerpt/check.js +0 -19
  72. package/build/components/post-excerpt/check.js.map +1 -1
  73. package/build/components/post-excerpt/index.js +52 -12
  74. package/build/components/post-excerpt/index.js.map +1 -1
  75. package/build/components/post-excerpt/panel.js +118 -7
  76. package/build/components/post-excerpt/panel.js.map +1 -1
  77. package/build/components/post-excerpt/plugin.js +2 -2
  78. package/build/components/post-excerpt/plugin.js.map +1 -1
  79. package/build/components/post-featured-image/index.js +1 -1
  80. package/build/components/post-featured-image/index.js.map +1 -1
  81. package/build/components/post-last-edited-panel/index.js +33 -0
  82. package/build/components/post-last-edited-panel/index.js.map +1 -0
  83. package/build/components/post-publish-button/post-publish-button-or-toggle.js +100 -0
  84. package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
  85. package/build/components/post-schedule/panel.js +1 -1
  86. package/build/components/post-schedule/panel.js.map +1 -1
  87. package/build/components/post-status/index.js +9 -9
  88. package/build/components/post-status/index.js.map +1 -1
  89. package/build/components/post-template/block-theme.js +2 -2
  90. package/build/components/post-template/block-theme.js.map +1 -1
  91. package/build/components/post-template/classic-theme.js +0 -1
  92. package/build/components/post-template/classic-theme.js.map +1 -1
  93. package/build/components/post-template/swap-template-button.js +2 -5
  94. package/build/components/post-template/swap-template-button.js.map +1 -1
  95. package/build/components/post-url/index.js +2 -1
  96. package/build/components/post-url/index.js.map +1 -1
  97. package/build/components/post-url/panel.js +1 -1
  98. package/build/components/post-url/panel.js.map +1 -1
  99. package/build/components/preferences-modal/enable-publish-sidebar.js +34 -0
  100. package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
  101. package/build/components/preferences-modal/index.js +8 -2
  102. package/build/components/preferences-modal/index.js.map +1 -1
  103. package/build/components/preview-dropdown/index.js +3 -1
  104. package/build/components/preview-dropdown/index.js.map +1 -1
  105. package/build/components/provider/disable-non-page-content-blocks.js +23 -16
  106. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  107. package/build/components/save-publish-panels/index.js +89 -0
  108. package/build/components/save-publish-panels/index.js.map +1 -0
  109. package/build/components/start-page-options/index.js +5 -1
  110. package/build/components/start-page-options/index.js.map +1 -1
  111. package/build/private-apis.js +18 -2
  112. package/build/private-apis.js.map +1 -1
  113. package/build/store/selectors.js +3 -1
  114. package/build/store/selectors.js.map +1 -1
  115. package/build-module/components/autosave-monitor/index.js +15 -13
  116. package/build-module/components/autosave-monitor/index.js.map +1 -1
  117. package/build-module/components/character-count/index.js +6 -0
  118. package/build-module/components/character-count/index.js.map +1 -1
  119. package/build-module/components/collapsible-block-toolbar/index.js +65 -0
  120. package/build-module/components/collapsible-block-toolbar/index.js.map +1 -0
  121. package/build-module/components/document-outline/check.js +9 -0
  122. package/build-module/components/document-outline/check.js.map +1 -1
  123. package/build-module/components/document-outline/index.js +11 -0
  124. package/build-module/components/document-outline/index.js.map +1 -1
  125. package/build-module/components/document-tools/index.js +1 -8
  126. package/build-module/components/document-tools/index.js.map +1 -1
  127. package/build-module/components/editor-canvas/edit-template-blocks-notification.js +1 -1
  128. package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
  129. package/build-module/components/editor-history/redo.js +11 -0
  130. package/build-module/components/editor-history/redo.js.map +1 -1
  131. package/build-module/components/editor-history/undo.js +11 -0
  132. package/build-module/components/editor-history/undo.js.map +1 -1
  133. package/build-module/components/editor-snackbars/index.js +6 -0
  134. package/build-module/components/editor-snackbars/index.js.map +1 -1
  135. package/build-module/components/global-keyboard-shortcuts/index.js +8 -0
  136. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  137. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +35 -0
  138. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  139. package/build-module/components/inserter-sidebar/index.js +2 -5
  140. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  141. package/build-module/components/keyboard-shortcut-help-modal/config.js +4 -0
  142. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  143. package/build-module/components/list-view-sidebar/index.js +1 -1
  144. package/build-module/components/list-view-sidebar/index.js.map +1 -1
  145. package/build-module/components/more-menu/copy-content-menu-item.js +52 -0
  146. package/build-module/components/more-menu/copy-content-menu-item.js.map +1 -0
  147. package/build-module/components/more-menu/index.js +111 -0
  148. package/build-module/components/more-menu/index.js.map +1 -0
  149. package/build-module/components/more-menu/tools-more-menu-group.js +16 -0
  150. package/build-module/components/more-menu/tools-more-menu-group.js.map +1 -0
  151. package/build-module/components/more-menu/view-more-menu-group.js +17 -0
  152. package/build-module/components/more-menu/view-more-menu-group.js.map +1 -0
  153. package/build-module/components/page-attributes/check.js +9 -0
  154. package/build-module/components/page-attributes/check.js.map +1 -1
  155. package/build-module/components/page-attributes/order.js +7 -0
  156. package/build-module/components/page-attributes/order.js.map +1 -1
  157. package/build-module/components/page-attributes/panel.js +13 -6
  158. package/build-module/components/page-attributes/panel.js.map +1 -1
  159. package/build-module/components/page-attributes/parent.js +7 -0
  160. package/build-module/components/page-attributes/parent.js.map +1 -1
  161. package/build-module/components/plugin-post-publish-panel/index.js +1 -1
  162. package/build-module/components/plugin-post-publish-panel/index.js.map +1 -1
  163. package/build-module/components/plugin-pre-publish-panel/index.js +1 -1
  164. package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -1
  165. package/build-module/components/plugin-sidebar/index.js +1 -1
  166. package/build-module/components/plugin-sidebar/index.js.map +1 -1
  167. package/build-module/components/post-actions/actions.js +100 -6
  168. package/build-module/components/post-actions/actions.js.map +1 -1
  169. package/build-module/components/post-actions/index.js +31 -8
  170. package/build-module/components/post-actions/index.js.map +1 -1
  171. package/build-module/components/post-author/check.js +10 -0
  172. package/build-module/components/post-author/check.js.map +1 -1
  173. package/build-module/components/post-author/index.js +6 -0
  174. package/build-module/components/post-author/index.js.map +1 -1
  175. package/build-module/components/post-author/panel.js +6 -0
  176. package/build-module/components/post-author/panel.js.map +1 -1
  177. package/build-module/components/post-card-panel/index.js +16 -51
  178. package/build-module/components/post-card-panel/index.js.map +1 -1
  179. package/build-module/components/post-content-information/index.js +66 -0
  180. package/build-module/components/post-content-information/index.js.map +1 -0
  181. package/build-module/components/post-discussion/panel.js +8 -6
  182. package/build-module/components/post-discussion/panel.js.map +1 -1
  183. package/build-module/components/post-excerpt/check.js +0 -19
  184. package/build-module/components/post-excerpt/check.js.map +1 -1
  185. package/build-module/components/post-excerpt/index.js +52 -11
  186. package/build-module/components/post-excerpt/index.js.map +1 -1
  187. package/build-module/components/post-excerpt/panel.js +118 -8
  188. package/build-module/components/post-excerpt/panel.js.map +1 -1
  189. package/build-module/components/post-excerpt/plugin.js +2 -2
  190. package/build-module/components/post-excerpt/plugin.js.map +1 -1
  191. package/build-module/components/post-featured-image/index.js +1 -1
  192. package/build-module/components/post-featured-image/index.js.map +1 -1
  193. package/build-module/components/post-last-edited-panel/index.js +26 -0
  194. package/build-module/components/post-last-edited-panel/index.js.map +1 -0
  195. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +91 -0
  196. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -0
  197. package/build-module/components/post-schedule/panel.js +1 -1
  198. package/build-module/components/post-schedule/panel.js.map +1 -1
  199. package/build-module/components/post-status/index.js +9 -9
  200. package/build-module/components/post-status/index.js.map +1 -1
  201. package/build-module/components/post-template/block-theme.js +2 -2
  202. package/build-module/components/post-template/block-theme.js.map +1 -1
  203. package/build-module/components/post-template/classic-theme.js +0 -1
  204. package/build-module/components/post-template/classic-theme.js.map +1 -1
  205. package/build-module/components/post-template/swap-template-button.js +3 -6
  206. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  207. package/build-module/components/post-url/index.js +2 -1
  208. package/build-module/components/post-url/index.js.map +1 -1
  209. package/build-module/components/post-url/panel.js +1 -1
  210. package/build-module/components/post-url/panel.js.map +1 -1
  211. package/build-module/components/preferences-modal/enable-publish-sidebar.js +27 -0
  212. package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +1 -0
  213. package/build-module/components/preferences-modal/index.js +8 -2
  214. package/build-module/components/preferences-modal/index.js.map +1 -1
  215. package/build-module/components/preview-dropdown/index.js +3 -1
  216. package/build-module/components/preview-dropdown/index.js.map +1 -1
  217. package/build-module/components/provider/disable-non-page-content-blocks.js +24 -17
  218. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  219. package/build-module/components/save-publish-panels/index.js +80 -0
  220. package/build-module/components/save-publish-panels/index.js.map +1 -0
  221. package/build-module/components/start-page-options/index.js +5 -1
  222. package/build-module/components/start-page-options/index.js.map +1 -1
  223. package/build-module/private-apis.js +18 -2
  224. package/build-module/private-apis.js.map +1 -1
  225. package/build-module/store/selectors.js +3 -1
  226. package/build-module/store/selectors.js.map +1 -1
  227. package/build-style/style-rtl.css +207 -30
  228. package/build-style/style.css +207 -30
  229. package/package.json +35 -35
  230. package/src/components/autosave-monitor/index.js +15 -12
  231. package/src/components/character-count/index.js +5 -0
  232. package/src/components/collapsible-block-toolbar/index.js +77 -0
  233. package/src/components/collapsible-block-toolbar/style.scss +80 -0
  234. package/src/components/document-outline/check.js +8 -0
  235. package/src/components/document-outline/index.js +10 -0
  236. package/src/components/document-tools/index.js +0 -5
  237. package/src/components/editor-canvas/edit-template-blocks-notification.js +1 -1
  238. package/src/components/editor-history/redo.js +10 -0
  239. package/src/components/editor-history/undo.js +10 -0
  240. package/src/components/editor-snackbars/index.js +5 -0
  241. package/src/components/entities-saved-states/style.scss +7 -0
  242. package/src/components/global-keyboard-shortcuts/index.js +7 -0
  243. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +41 -0
  244. package/src/components/inserter-sidebar/index.js +2 -5
  245. package/src/components/keyboard-shortcut-help-modal/config.js +10 -1
  246. package/src/components/list-view-sidebar/index.js +1 -1
  247. package/src/components/list-view-sidebar/style.scss +2 -2
  248. package/src/components/more-menu/copy-content-menu-item.js +51 -0
  249. package/src/components/more-menu/index.js +158 -0
  250. package/src/components/more-menu/tools-more-menu-group.js +11 -0
  251. package/src/components/more-menu/view-more-menu-group.js +13 -0
  252. package/src/components/page-attributes/check.js +8 -0
  253. package/src/components/page-attributes/order.js +6 -0
  254. package/src/components/page-attributes/panel.js +21 -17
  255. package/src/components/page-attributes/parent.js +6 -0
  256. package/src/components/plugin-post-publish-panel/index.js +1 -1
  257. package/src/components/plugin-pre-publish-panel/index.js +1 -1
  258. package/src/components/plugin-sidebar/index.js +1 -1
  259. package/src/components/post-actions/actions.js +120 -5
  260. package/src/components/post-actions/index.js +41 -7
  261. package/src/components/post-author/check.js +9 -0
  262. package/src/components/post-author/index.js +5 -0
  263. package/src/components/post-author/panel.js +5 -0
  264. package/src/components/post-card-panel/index.js +27 -82
  265. package/src/components/post-card-panel/style.scss +2 -6
  266. package/src/components/post-content-information/index.js +83 -0
  267. package/src/components/post-content-information/style.scss +6 -0
  268. package/src/components/post-discussion/panel.js +24 -20
  269. package/src/components/post-excerpt/check.js +0 -18
  270. package/src/components/post-excerpt/index.js +66 -15
  271. package/src/components/post-excerpt/panel.js +196 -19
  272. package/src/components/post-excerpt/plugin.js +2 -2
  273. package/src/components/post-excerpt/style.scss +24 -0
  274. package/src/components/post-featured-image/index.js +1 -1
  275. package/src/components/post-featured-image/style.scss +2 -8
  276. package/src/components/post-last-edited-panel/index.js +35 -0
  277. package/src/components/post-last-edited-panel/style.scss +6 -0
  278. package/src/components/post-panel-row/style.scss +3 -3
  279. package/src/components/post-publish-button/post-publish-button-or-toggle.js +102 -0
  280. package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +63 -0
  281. package/src/components/post-publish-panel/style.scss +43 -0
  282. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +225 -75
  283. package/src/components/post-schedule/panel.js +1 -1
  284. package/src/components/post-schedule/style.scss +2 -4
  285. package/src/components/post-status/index.js +84 -76
  286. package/src/components/post-status/style.scss +0 -1
  287. package/src/components/post-template/block-theme.js +2 -2
  288. package/src/components/post-template/classic-theme.js +0 -1
  289. package/src/components/post-template/swap-template-button.js +3 -6
  290. package/src/components/post-text-editor/style.scss +1 -1
  291. package/src/components/post-title/style.scss +1 -1
  292. package/src/components/post-url/index.js +1 -0
  293. package/src/components/post-url/panel.js +1 -1
  294. package/src/components/preferences-modal/enable-publish-sidebar.js +28 -0
  295. package/src/components/preferences-modal/index.js +14 -0
  296. package/src/components/preview-dropdown/index.js +3 -1
  297. package/src/components/provider/disable-non-page-content-blocks.js +23 -21
  298. package/src/components/save-publish-panels/index.js +96 -0
  299. package/src/components/save-publish-panels/style.scss +36 -0
  300. package/src/components/start-page-options/index.js +6 -1
  301. package/src/private-apis.js +18 -2
  302. package/src/store/selectors.js +3 -1
  303. package/src/style.scss +4 -0
@@ -15,7 +15,7 @@ import PostPingbacks from '../post-pingbacks';
15
15
 
16
16
  const PANEL_NAME = 'discussion-panel';
17
17
 
18
- function PostDiscussionPanel() {
18
+ function DiscussionPanel() {
19
19
  const { isEnabled, isOpened } = useSelect( ( select ) => {
20
20
  const { isEditorPanelEnabled, isEditorPanelOpened } =
21
21
  select( editorStore );
@@ -31,27 +31,31 @@ function PostDiscussionPanel() {
31
31
  return null;
32
32
  }
33
33
 
34
+ return (
35
+ <PanelBody
36
+ title={ __( 'Discussion' ) }
37
+ opened={ isOpened }
38
+ onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
39
+ >
40
+ <PostTypeSupportCheck supportKeys="comments">
41
+ <PanelRow>
42
+ <PostComments />
43
+ </PanelRow>
44
+ </PostTypeSupportCheck>
45
+
46
+ <PostTypeSupportCheck supportKeys="trackbacks">
47
+ <PanelRow>
48
+ <PostPingbacks />
49
+ </PanelRow>
50
+ </PostTypeSupportCheck>
51
+ </PanelBody>
52
+ );
53
+ }
54
+
55
+ export default function PostDiscussionPanel() {
34
56
  return (
35
57
  <PostTypeSupportCheck supportKeys={ [ 'comments', 'trackbacks' ] }>
36
- <PanelBody
37
- title={ __( 'Discussion' ) }
38
- opened={ isOpened }
39
- onToggle={ () => toggleEditorPanelOpened( PANEL_NAME ) }
40
- >
41
- <PostTypeSupportCheck supportKeys="comments">
42
- <PanelRow>
43
- <PostComments />
44
- </PanelRow>
45
- </PostTypeSupportCheck>
46
-
47
- <PostTypeSupportCheck supportKeys="trackbacks">
48
- <PanelRow>
49
- <PostPingbacks />
50
- </PanelRow>
51
- </PostTypeSupportCheck>
52
- </PanelBody>
58
+ <DiscussionPanel />
53
59
  </PostTypeSupportCheck>
54
60
  );
55
61
  }
56
-
57
- export default PostDiscussionPanel;
@@ -1,13 +1,7 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect } from '@wordpress/data';
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
9
4
  import PostTypeSupportCheck from '../post-type-support-check';
10
- import { store as editorStore } from '../../store';
11
5
 
12
6
  /**
13
7
  * Component for checking if the post type supports the excerpt field.
@@ -18,18 +12,6 @@ import { store as editorStore } from '../../store';
18
12
  * @return {Component} The component to be rendered.
19
13
  */
20
14
  function PostExcerptCheck( { children } ) {
21
- const postType = useSelect( ( select ) => {
22
- const { getEditedPostAttribute } = select( editorStore );
23
- return getEditedPostAttribute( 'type' );
24
- }, [] );
25
-
26
- // This special case is unfortunate, but the REST API of wp_template and wp_template_part
27
- // support the excerpt field throught the "description" field rather than "excerpt" which means
28
- // the default ExcerptPanel won't work for these.
29
- if ( [ 'wp_template', 'wp_template_part' ].includes( postType ) ) {
30
- return null;
31
- }
32
-
33
15
  return (
34
16
  <PostTypeSupportCheck supportKeys="excerpt">
35
17
  { children }
@@ -4,37 +4,88 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { ExternalLink, TextareaControl } from '@wordpress/components';
6
6
  import { useDispatch, useSelect } from '@wordpress/data';
7
+ import { useState } from '@wordpress/element';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
12
  import { store as editorStore } from '../../store';
12
13
 
13
- function PostExcerpt() {
14
- const excerpt = useSelect(
15
- ( select ) => select( editorStore ).getEditedPostAttribute( 'excerpt' ),
14
+ /**
15
+ * Renders an editable textarea for the post excerpt.
16
+ * Templates, template parts and patterns use the `excerpt` field as a description semantically.
17
+ * Additionally templates and template parts override the `excerpt` field as `description` in
18
+ * REST API. So this component handles proper labeling and updating the edited entity.
19
+ *
20
+ * @param {Object} props - Component props.
21
+ * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
22
+ * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
23
+ */
24
+ export default function PostExcerpt( {
25
+ hideLabelFromVision = false,
26
+ updateOnBlur = false,
27
+ } ) {
28
+ const { excerpt, shouldUseDescriptionLabel, usedAttribute } = useSelect(
29
+ ( select ) => {
30
+ const { getCurrentPostType, getEditedPostAttribute } =
31
+ select( editorStore );
32
+ const postType = getCurrentPostType();
33
+ // This special case is unfortunate, but the REST API of wp_template and wp_template_part
34
+ // support the excerpt field throught the "description" field rather than "excerpt".
35
+ const _usedAttribute = [
36
+ 'wp_template',
37
+ 'wp_template_part',
38
+ ].includes( postType )
39
+ ? 'description'
40
+ : 'excerpt';
41
+ return {
42
+ excerpt: getEditedPostAttribute( _usedAttribute ),
43
+ // There are special cases where we want to label the excerpt as a description.
44
+ shouldUseDescriptionLabel: [
45
+ 'wp_template',
46
+ 'wp_template_part',
47
+ 'wp_block',
48
+ ].includes( postType ),
49
+ usedAttribute: _usedAttribute,
50
+ };
51
+ },
16
52
  []
17
53
  );
18
54
  const { editPost } = useDispatch( editorStore );
55
+ const [ localExcerpt, setLocalExcerpt ] = useState( excerpt );
56
+ const updatePost = ( value ) => {
57
+ editPost( { [ usedAttribute ]: value } );
58
+ };
59
+ const label = shouldUseDescriptionLabel
60
+ ? __( 'Write a description (optional)' )
61
+ : __( 'Write an excerpt (optional)' );
19
62
 
20
63
  return (
21
64
  <div className="editor-post-excerpt">
22
65
  <TextareaControl
23
66
  __nextHasNoMarginBottom
24
- label={ __( 'Write an excerpt (optional)' ) }
67
+ label={ label }
68
+ hideLabelFromVision={ hideLabelFromVision }
25
69
  className="editor-post-excerpt__textarea"
26
- onChange={ ( value ) => editPost( { excerpt: value } ) }
27
- value={ excerpt }
70
+ onChange={ updateOnBlur ? setLocalExcerpt : updatePost }
71
+ onBlur={
72
+ updateOnBlur ? () => updatePost( localExcerpt ) : undefined
73
+ }
74
+ value={ updateOnBlur ? localExcerpt : excerpt }
75
+ help={
76
+ ! shouldUseDescriptionLabel ? (
77
+ <ExternalLink
78
+ href={ __(
79
+ 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
80
+ ) }
81
+ >
82
+ { __( 'Learn more about manual excerpts' ) }
83
+ </ExternalLink>
84
+ ) : (
85
+ __( 'Write a description' )
86
+ )
87
+ }
28
88
  />
29
- <ExternalLink
30
- href={ __(
31
- 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'
32
- ) }
33
- >
34
- { __( 'Learn more about manual excerpts' ) }
35
- </ExternalLink>
36
89
  </div>
37
90
  );
38
91
  }
39
-
40
- export default PostExcerpt;
@@ -1,9 +1,23 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import classnames from 'classnames';
5
+
1
6
  /**
2
7
  * WordPress dependencies
3
8
  */
4
9
  import { __ } from '@wordpress/i18n';
5
- import { PanelBody } from '@wordpress/components';
10
+ import {
11
+ PanelBody,
12
+ __experimentalText as Text,
13
+ Dropdown,
14
+ Button,
15
+ __experimentalVStack as VStack,
16
+ } from '@wordpress/components';
6
17
  import { useDispatch, useSelect } from '@wordpress/data';
18
+ import { useMemo, useState } from '@wordpress/element';
19
+ import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
20
+ import { store as coreStore } from '@wordpress/core-data';
7
21
 
8
22
  /**
9
23
  * Internal dependencies
@@ -11,6 +25,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
11
25
  import PostExcerptForm from './index';
12
26
  import PostExcerptCheck from './check';
13
27
  import PluginPostExcerpt from './plugin';
28
+ import { TEMPLATE_ORIGINS } from '../../store/constants';
14
29
  import { store as editorStore } from '../../store';
15
30
 
16
31
  /**
@@ -18,14 +33,18 @@ import { store as editorStore } from '../../store';
18
33
  */
19
34
  const PANEL_NAME = 'post-excerpt';
20
35
 
21
- export default function PostExcerptPanel() {
22
- const { isOpened, isEnabled } = useSelect( ( select ) => {
23
- const { isEditorPanelOpened, isEditorPanelEnabled } =
24
- select( editorStore );
36
+ function ExcerptPanel() {
37
+ const { isOpened, isEnabled, postType } = useSelect( ( select ) => {
38
+ const {
39
+ isEditorPanelOpened,
40
+ isEditorPanelEnabled,
41
+ getCurrentPostType,
42
+ } = select( editorStore );
25
43
 
26
44
  return {
27
45
  isOpened: isEditorPanelOpened( PANEL_NAME ),
28
46
  isEnabled: isEditorPanelEnabled( PANEL_NAME ),
47
+ postType: getCurrentPostType(),
29
48
  };
30
49
  }, [] );
31
50
 
@@ -36,22 +55,180 @@ export default function PostExcerptPanel() {
36
55
  return null;
37
56
  }
38
57
 
58
+ // There are special cases where we want to label the excerpt as a description.
59
+ const shouldUseDescriptionLabel = [
60
+ 'wp_template',
61
+ 'wp_template_part',
62
+ 'wp_block',
63
+ ].includes( postType );
64
+
65
+ return (
66
+ <PanelBody
67
+ title={
68
+ shouldUseDescriptionLabel
69
+ ? __( 'Description' )
70
+ : __( 'Excerpt' )
71
+ }
72
+ opened={ isOpened }
73
+ onToggle={ toggleExcerptPanel }
74
+ >
75
+ <PluginPostExcerpt.Slot>
76
+ { ( fills ) => (
77
+ <>
78
+ <PostExcerptForm />
79
+ { fills }
80
+ </>
81
+ ) }
82
+ </PluginPostExcerpt.Slot>
83
+ </PanelBody>
84
+ );
85
+ }
86
+
87
+ export default function PostExcerptPanel() {
39
88
  return (
40
89
  <PostExcerptCheck>
41
- <PanelBody
42
- title={ __( 'Excerpt' ) }
43
- opened={ isOpened }
44
- onToggle={ toggleExcerptPanel }
45
- >
46
- <PluginPostExcerpt.Slot>
47
- { ( fills ) => (
48
- <>
49
- <PostExcerptForm />
50
- { fills }
51
- </>
52
- ) }
53
- </PluginPostExcerpt.Slot>
54
- </PanelBody>
90
+ <ExcerptPanel />
55
91
  </PostExcerptCheck>
56
92
  );
57
93
  }
94
+
95
+ export function PrivatePostExcerptPanel() {
96
+ return (
97
+ <PostExcerptCheck>
98
+ <PrivateExcerpt />
99
+ </PostExcerptCheck>
100
+ );
101
+ }
102
+
103
+ function PrivateExcerpt() {
104
+ const { shouldRender, excerpt, shouldBeUsedAsDescription, allowEditing } =
105
+ useSelect( ( select ) => {
106
+ const {
107
+ getCurrentPostType,
108
+ getCurrentPostId,
109
+ getEditedPostAttribute,
110
+ isEditorPanelEnabled,
111
+ } = select( editorStore );
112
+ const postType = getCurrentPostType();
113
+ const isTemplateOrTemplatePart = [
114
+ 'wp_template',
115
+ 'wp_template_part',
116
+ ].includes( postType );
117
+ const isPattern = postType === 'wp_block';
118
+ // These post types use the `excerpt` field as a description semantically, so we need to
119
+ // handle proper labeling and some flows where we should always render them as text.
120
+ const _shouldBeUsedAsDescription =
121
+ isTemplateOrTemplatePart || isPattern;
122
+ const _usedAttribute = isTemplateOrTemplatePart
123
+ ? 'description'
124
+ : 'excerpt';
125
+ // We need to fetch the entity in this case to check if we'll allow editing.
126
+ const template =
127
+ isTemplateOrTemplatePart &&
128
+ select( coreStore ).getEntityRecord(
129
+ 'postType',
130
+ postType,
131
+ getCurrentPostId()
132
+ );
133
+ // For post types that use excerpt as description, we do not abide
134
+ // by the `isEnabled` panel flag in order to render them as text.
135
+ const _shouldRender =
136
+ isEditorPanelEnabled( PANEL_NAME ) ||
137
+ _shouldBeUsedAsDescription;
138
+ return {
139
+ excerpt: getEditedPostAttribute( _usedAttribute ),
140
+ shouldRender: _shouldRender,
141
+ shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
142
+ // If we should render, allow editing for all post types that are not used as description.
143
+ // For the rest allow editing only for user generated entities.
144
+ allowEditing:
145
+ _shouldRender &&
146
+ ( ! _shouldBeUsedAsDescription ||
147
+ isPattern ||
148
+ ( template &&
149
+ template.source === TEMPLATE_ORIGINS.custom &&
150
+ ! template.has_theme_file ) ),
151
+ };
152
+ }, [] );
153
+ const [ popoverAnchor, setPopoverAnchor ] = useState( null );
154
+ const label = shouldBeUsedAsDescription
155
+ ? __( 'Description' )
156
+ : __( 'Excerpt' );
157
+ // Memoize popoverProps to avoid returning a new object every time.
158
+ const popoverProps = useMemo(
159
+ () => ( {
160
+ // Anchor the popover to the middle of the entire row so that it doesn't
161
+ // move around when the label changes.
162
+ anchor: popoverAnchor,
163
+ 'aria-label': label,
164
+ headerTitle: label,
165
+ placement: 'left-start',
166
+ offset: 36,
167
+ shift: true,
168
+ } ),
169
+ [ popoverAnchor, label ]
170
+ );
171
+ if ( ! shouldRender ) {
172
+ return false;
173
+ }
174
+ const excerptText = !! excerpt && (
175
+ <Text align="left" numberOfLines={ 4 } truncate>
176
+ { excerpt }
177
+ </Text>
178
+ );
179
+ if ( ! allowEditing ) {
180
+ return excerptText;
181
+ }
182
+ const excerptPlaceholder = shouldBeUsedAsDescription
183
+ ? __( 'Add a description…' )
184
+ : __( 'Add an excerpt…' );
185
+ const triggerEditLabel = shouldBeUsedAsDescription
186
+ ? __( 'Edit description' )
187
+ : __( 'Edit excerpt' );
188
+ return (
189
+ <Dropdown
190
+ className="editor-post-excerpt__dropdown"
191
+ contentClassName="editor-post-excerpt__dropdown__content"
192
+ popoverProps={ popoverProps }
193
+ focusOnMount
194
+ ref={ setPopoverAnchor }
195
+ renderToggle={ ( { onToggle } ) => (
196
+ <Button
197
+ className={ classnames(
198
+ 'editor-post-excerpt__dropdown__trigger',
199
+ { 'has-excerpt': !! excerpt }
200
+ ) }
201
+ onClick={ onToggle }
202
+ label={
203
+ !! excerptText ? triggerEditLabel : excerptPlaceholder
204
+ }
205
+ showTooltip={ !! excerptText }
206
+ >
207
+ { excerptText || excerptPlaceholder }
208
+ </Button>
209
+ ) }
210
+ renderContent={ ( { onClose } ) => (
211
+ <>
212
+ <InspectorPopoverHeader
213
+ title={ label }
214
+ onClose={ onClose }
215
+ />
216
+
217
+ <VStack spacing={ 4 }>
218
+ <PluginPostExcerpt.Slot>
219
+ { ( fills ) => (
220
+ <>
221
+ <PostExcerptForm
222
+ hideLabelFromVision
223
+ updateOnBlur
224
+ />
225
+ { fills }
226
+ </>
227
+ ) }
228
+ </PluginPostExcerpt.Slot>
229
+ </VStack>
230
+ </>
231
+ ) }
232
+ />
233
+ );
234
+ }
@@ -20,7 +20,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
20
20
  * ```js
21
21
  * // Using ES5 syntax
22
22
  * var __ = wp.i18n.__;
23
- * var PluginPostExcerpt = wp.editPost.PluginPostExcerpt;
23
+ * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
24
24
  *
25
25
  * function MyPluginPostExcerpt() {
26
26
  * return React.createElement(
@@ -37,7 +37,7 @@ const { Fill, Slot } = createSlotFill( 'PluginPostExcerpt' );
37
37
  * ```jsx
38
38
  * // Using ESNext syntax
39
39
  * import { __ } from '@wordpress/i18n';
40
- * import { PluginPostExcerpt } from '@wordpress/edit-post';
40
+ * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
41
41
  *
42
42
  * const MyPluginPostExcerpt = () => (
43
43
  * <PluginPostExcerpt className="my-plugin-post-excerpt">
@@ -2,3 +2,27 @@
2
2
  width: 100%;
3
3
  margin-bottom: 10px;
4
4
  }
5
+
6
+ .editor-post-excerpt__dropdown__trigger {
7
+ height: auto;
8
+ padding: 0;
9
+
10
+ &:not(.has-excerpt) {
11
+ color: $gray-700;
12
+ }
13
+
14
+ &:hover {
15
+ color: $gray-900;
16
+ }
17
+ }
18
+
19
+ .editor-post-excerpt__dropdown {
20
+ display: block;
21
+ }
22
+
23
+ .editor-post-excerpt__dropdown__content {
24
+ .components-popover__content {
25
+ min-width: 320px;
26
+ padding: $grid-unit-20;
27
+ }
28
+ }
@@ -32,7 +32,7 @@ const ALLOWED_MEDIA_TYPES = [ 'image' ];
32
32
 
33
33
  // Used when labels from post type were not yet loaded or when they are not present.
34
34
  const DEFAULT_FEATURE_IMAGE_LABEL = __( 'Featured image' );
35
- const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Set featured image' );
35
+ const DEFAULT_SET_FEATURE_IMAGE_LABEL = __( 'Add a featured image' );
36
36
 
37
37
  const instructions = (
38
38
  <p>
@@ -31,8 +31,7 @@
31
31
  box-shadow: 0 0 0 0 var(--wp-admin-theme-color);
32
32
  overflow: hidden; // Ensure the focus style properly encapsulates the image.
33
33
  outline-offset: -#{$border-width};
34
- min-height: $grid-unit-50 * 2;
35
- margin-bottom: $grid-unit-20;
34
+ min-height: $grid-unit-50;
36
35
 
37
36
  display: flex;
38
37
  justify-content: center;
@@ -52,16 +51,11 @@
52
51
 
53
52
  .editor-post-featured-image__toggle {
54
53
  border-radius: $radius-block-ui;
55
- background-color: $gray-100;
56
54
  height: 100%;
57
55
  line-height: 20px;
58
56
  padding: $grid-unit-10 0;
59
57
  text-align: center;
60
-
61
- &:hover {
62
- background: $gray-300;
63
- color: $gray-900;
64
- }
58
+ box-shadow: inset 0 0 0 $border-width $gray-400;
65
59
  }
66
60
 
67
61
  .editor-post-featured-image__actions {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __experimentalText as Text } from '@wordpress/components';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { __, sprintf } from '@wordpress/i18n';
7
+ import { humanTimeDiff } from '@wordpress/date';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { store as editorStore } from '../../store';
13
+
14
+ export default function PostLastEditedPanel() {
15
+ const modified = useSelect(
16
+ ( select ) =>
17
+ select( editorStore ).getEditedPostAttribute( 'modified' ),
18
+ []
19
+ );
20
+ const lastEditedText =
21
+ modified &&
22
+ sprintf(
23
+ // translators: %s: Human-readable time difference, e.g. "2 days ago".
24
+ __( 'Last edited %s.' ),
25
+ humanTimeDiff( modified )
26
+ );
27
+ if ( ! lastEditedText ) {
28
+ return null;
29
+ }
30
+ return (
31
+ <div className="editor-post-last-edited-panel">
32
+ <Text>{ lastEditedText }</Text>
33
+ </div>
34
+ );
35
+ }
@@ -0,0 +1,6 @@
1
+ .editor-post-last-edited-panel {
2
+ color: $gray-700;
3
+ & .components-text {
4
+ color: inherit;
5
+ }
6
+ }
@@ -1,6 +1,6 @@
1
1
  .editor-post-panel__row {
2
2
  width: 100%;
3
- min-height: $button-size-next-default-40px;
3
+ min-height: $grid-unit-40;
4
4
  justify-content: flex-start !important;
5
5
  align-items: flex-start !important;
6
6
  }
@@ -8,14 +8,14 @@
8
8
  .editor-post-panel__row-label {
9
9
  width: 30%;
10
10
  flex-shrink: 0;
11
- min-height: $button-size-next-default-40px;
11
+ min-height: $grid-unit-40;
12
12
  display: flex;
13
13
  align-items: center;
14
14
  }
15
15
 
16
16
  .editor-post-panel__row-control {
17
17
  flex-grow: 1;
18
- min-height: $button-size-next-default-40px;
18
+ min-height: $grid-unit-40;
19
19
  display: flex;
20
20
  align-items: center;
21
21
  }