@wordpress/editor 14.42.0 → 14.43.1-next.v.202604091042.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 (276) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +8 -0
  3. package/build/components/autocompleters/index.cjs +3 -0
  4. package/build/components/autocompleters/index.cjs.map +2 -2
  5. package/build/components/autocompleters/link.cjs +71 -0
  6. package/build/components/autocompleters/link.cjs.map +7 -0
  7. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +1 -1
  8. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +2 -2
  9. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  10. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  11. package/build/components/collaborators-overlay/index.cjs +7 -2
  12. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  13. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  14. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  15. package/build/components/collaborators-overlay/overlay.cjs +31 -1
  16. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  17. package/build/components/collaborators-overlay/timing-utils.cjs +1 -1
  18. package/build/components/collaborators-overlay/timing-utils.cjs.map +2 -2
  19. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  20. package/build/components/collaborators-presence/index.cjs +14 -4
  21. package/build/components/collaborators-presence/index.cjs.map +2 -2
  22. package/build/components/collaborators-presence/list.cjs +20 -4
  23. package/build/components/collaborators-presence/list.cjs.map +2 -2
  24. package/build/components/error-boundary/index.cjs +1 -1
  25. package/build/components/error-boundary/index.cjs.map +2 -2
  26. package/build/components/post-card-panel/index.cjs +4 -15
  27. package/build/components/post-card-panel/index.cjs.map +2 -2
  28. package/build/components/post-content-information/index.cjs +10 -13
  29. package/build/components/post-content-information/index.cjs.map +2 -2
  30. package/build/components/post-revisions-panel/index.cjs +164 -0
  31. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  32. package/build/components/post-revisions-preview/revisions-slider.cjs +23 -12
  33. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  34. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  35. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  36. package/build/components/post-template/hooks.cjs +52 -6
  37. package/build/components/post-template/hooks.cjs.map +2 -2
  38. package/build/components/post-template/swap-template-button.cjs +31 -20
  39. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  40. package/build/components/post-title/index.cjs +2 -2
  41. package/build/components/post-title/index.cjs.map +2 -2
  42. package/build/components/preferences-modal/index.cjs +35 -27
  43. package/build/components/preferences-modal/index.cjs.map +2 -2
  44. package/build/components/revision-block-diff/index.cjs +9 -32
  45. package/build/components/revision-block-diff/index.cjs.map +3 -3
  46. package/build/components/revision-diff-panel/index.cjs +68 -0
  47. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  48. package/build/components/revision-fields-diff/index.cjs +96 -0
  49. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  50. package/build/components/sidebar/dataform-post-summary.cjs +8 -53
  51. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  52. package/build/components/sidebar/index.cjs +25 -22
  53. package/build/components/sidebar/index.cjs.map +3 -3
  54. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  55. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  56. package/build/components/sidebar/post-summary.cjs +35 -42
  57. package/build/components/sidebar/post-summary.cjs.map +3 -3
  58. package/build/components/style-book/index.cjs +4 -3
  59. package/build/components/style-book/index.cjs.map +2 -2
  60. package/build/components/styles-canvas/revisions.cjs +2 -2
  61. package/build/components/styles-canvas/revisions.cjs.map +1 -1
  62. package/build/components/sync-connection-error-modal/index.cjs +58 -75
  63. package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
  64. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs +32 -9
  65. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +2 -2
  66. package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
  67. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  68. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  69. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  70. package/build/components/template-actions-panel/index.cjs +59 -0
  71. package/build/components/template-actions-panel/index.cjs.map +7 -0
  72. package/build/dataviews/store/private-actions.cjs +2 -0
  73. package/build/dataviews/store/private-actions.cjs.map +2 -2
  74. package/build/hooks/default-autocompleters.cjs +1 -1
  75. package/build/hooks/default-autocompleters.cjs.map +2 -2
  76. package/build/store/private-actions.cjs +15 -1
  77. package/build/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-selectors.cjs +42 -19
  79. package/build/store/private-selectors.cjs.map +2 -2
  80. package/build/store/reducer.cjs +1 -1
  81. package/build/store/reducer.cjs.map +2 -2
  82. package/build-module/components/autocompleters/index.mjs +4 -2
  83. package/build-module/components/autocompleters/index.mjs.map +2 -2
  84. package/build-module/components/autocompleters/link.mjs +40 -0
  85. package/build-module/components/autocompleters/link.mjs.map +7 -0
  86. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +1 -1
  87. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +2 -2
  88. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  89. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  90. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  91. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  92. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  93. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  94. package/build-module/components/collaborators-overlay/overlay.mjs +32 -2
  95. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/timing-utils.mjs +1 -1
  97. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +2 -2
  98. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  99. package/build-module/components/collaborators-presence/index.mjs +14 -4
  100. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  101. package/build-module/components/collaborators-presence/list.mjs +20 -4
  102. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  103. package/build-module/components/error-boundary/index.mjs +1 -1
  104. package/build-module/components/error-boundary/index.mjs.map +2 -2
  105. package/build-module/components/post-card-panel/index.mjs +6 -17
  106. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  107. package/build-module/components/post-content-information/index.mjs +6 -13
  108. package/build-module/components/post-content-information/index.mjs.map +2 -2
  109. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  110. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  111. package/build-module/components/post-revisions-preview/revisions-slider.mjs +23 -12
  112. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  113. package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
  114. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  115. package/build-module/components/post-template/hooks.mjs +53 -7
  116. package/build-module/components/post-template/hooks.mjs.map +2 -2
  117. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  118. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  119. package/build-module/components/post-title/index.mjs +2 -2
  120. package/build-module/components/post-title/index.mjs.map +2 -2
  121. package/build-module/components/preferences-modal/index.mjs +35 -27
  122. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  123. package/build-module/components/revision-block-diff/index.mjs +9 -32
  124. package/build-module/components/revision-block-diff/index.mjs.map +2 -2
  125. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  126. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  127. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  128. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  129. package/build-module/components/sidebar/dataform-post-summary.mjs +8 -53
  130. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  131. package/build-module/components/sidebar/index.mjs +25 -22
  132. package/build-module/components/sidebar/index.mjs.map +2 -2
  133. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  134. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  135. package/build-module/components/sidebar/post-summary.mjs +31 -42
  136. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  137. package/build-module/components/style-book/index.mjs +4 -3
  138. package/build-module/components/style-book/index.mjs.map +2 -2
  139. package/build-module/components/styles-canvas/revisions.mjs +2 -2
  140. package/build-module/components/styles-canvas/revisions.mjs.map +1 -1
  141. package/build-module/components/sync-connection-error-modal/index.mjs +58 -76
  142. package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
  143. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +33 -10
  144. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +2 -2
  145. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  146. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  147. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  148. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  149. package/build-module/components/template-actions-panel/index.mjs +28 -0
  150. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  151. package/build-module/dataviews/store/private-actions.mjs +5 -1
  152. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  153. package/build-module/hooks/default-autocompleters.mjs +2 -2
  154. package/build-module/hooks/default-autocompleters.mjs.map +2 -2
  155. package/build-module/store/private-actions.mjs +15 -1
  156. package/build-module/store/private-actions.mjs.map +2 -2
  157. package/build-module/store/private-selectors.mjs +42 -19
  158. package/build-module/store/private-selectors.mjs.map +2 -2
  159. package/build-module/store/reducer.mjs +1 -1
  160. package/build-module/store/reducer.mjs.map +2 -2
  161. package/build-style/style-rtl.css +124 -44
  162. package/build-style/style.css +124 -44
  163. package/build-types/bindings/post-data.d.ts +3 -3
  164. package/build-types/bindings/term-data.d.ts +14 -14
  165. package/build-types/components/autocompleters/index.d.ts +1 -0
  166. package/build-types/components/autocompleters/link.d.ts +12 -0
  167. package/build-types/components/autocompleters/link.d.ts.map +1 -0
  168. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  169. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  170. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  171. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  172. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  173. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  174. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  175. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  176. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  177. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  178. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  179. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  180. package/build-types/components/keyboard-shortcut-help-modal/config.d.ts +11 -11
  181. package/build-types/components/post-actions/set-as-homepage.d.ts +1 -1
  182. package/build-types/components/post-actions/set-as-posts-page.d.ts +1 -1
  183. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  184. package/build-types/components/post-content-information/index.d.ts +4 -1
  185. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  186. package/build-types/components/post-format/index.d.ts +10 -10
  187. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  188. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  189. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  190. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  191. package/build-types/components/post-status/index.d.ts +10 -10
  192. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  193. package/build-types/components/post-template/hooks.d.ts +1 -1
  194. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  195. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  196. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  197. package/build-types/components/post-visibility/utils.d.ts +6 -6
  198. package/build-types/components/revision-block-diff/index.d.ts.map +1 -1
  199. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  200. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  201. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  202. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  203. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  204. package/build-types/components/sidebar/index.d.ts.map +1 -1
  205. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  206. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  207. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  208. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  209. package/build-types/components/style-book/index.d.ts +2 -1
  210. package/build-types/components/style-book/index.d.ts.map +1 -1
  211. package/build-types/components/sync-connection-error-modal/index.d.ts +0 -14
  212. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
  213. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -1
  214. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  215. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  216. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  217. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  218. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  219. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  220. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  221. package/build-types/store/private-actions.d.ts.map +1 -1
  222. package/build-types/store/private-selectors.d.ts.map +1 -1
  223. package/build-types/store/reducer.d.ts +10 -10
  224. package/build-types/store/reducer.d.ts.map +1 -1
  225. package/build-types/utils/pageTypeBadge.d.ts +1 -1
  226. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  227. package/package.json +45 -44
  228. package/src/components/autocompleters/index.js +1 -0
  229. package/src/components/autocompleters/link.js +47 -0
  230. package/src/components/autocompleters/style.scss +6 -0
  231. package/src/components/collaborators-overlay/cursor-dom-utils.ts +1 -1
  232. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  233. package/src/components/collaborators-overlay/index.tsx +12 -4
  234. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  235. package/src/components/collaborators-overlay/overlay.tsx +45 -1
  236. package/src/components/collaborators-overlay/timing-utils.ts +1 -1
  237. package/src/components/collaborators-overlay/use-render-cursors.ts +4 -2
  238. package/src/components/collaborators-presence/index.tsx +9 -1
  239. package/src/components/collaborators-presence/list.tsx +25 -1
  240. package/src/components/error-boundary/index.js +1 -1
  241. package/src/components/error-boundary/index.native.js +1 -1
  242. package/src/components/post-card-panel/index.js +7 -21
  243. package/src/components/post-content-information/index.js +5 -16
  244. package/src/components/post-revisions-panel/index.js +151 -0
  245. package/src/components/post-revisions-panel/style.scss +16 -0
  246. package/src/components/post-revisions-preview/revisions-slider.js +23 -19
  247. package/src/components/post-template/create-new-template-modal.js +1 -4
  248. package/src/components/post-template/hooks.js +65 -9
  249. package/src/components/post-template/style.scss +0 -6
  250. package/src/components/post-template/swap-template-button.js +30 -21
  251. package/src/components/post-title/index.js +3 -3
  252. package/src/components/preferences-modal/index.js +37 -25
  253. package/src/components/revision-block-diff/index.js +8 -43
  254. package/src/components/revision-diff-panel/index.js +59 -0
  255. package/src/components/revision-fields-diff/index.js +91 -0
  256. package/src/components/sidebar/dataform-post-summary.js +8 -55
  257. package/src/components/sidebar/index.js +33 -22
  258. package/src/components/sidebar/post-revision-summary.js +50 -0
  259. package/src/components/sidebar/post-summary.js +22 -40
  260. package/src/components/sidebar/style.scss +7 -0
  261. package/src/components/style-book/index.js +4 -2
  262. package/src/components/styles-canvas/revisions.js +2 -2
  263. package/src/components/sync-connection-error-modal/index.tsx +128 -155
  264. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +46 -10
  265. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  266. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  267. package/src/components/template-actions-panel/index.js +32 -0
  268. package/src/components/template-actions-panel/style.scss +39 -0
  269. package/src/dataviews/store/private-actions.ts +6 -0
  270. package/src/hooks/default-autocompleters.js +2 -2
  271. package/src/hooks/test/default-autocompleters.js +2 -2
  272. package/src/store/private-actions.js +18 -2
  273. package/src/store/private-selectors.js +43 -22
  274. package/src/store/reducer.js +9 -8
  275. package/src/style.scss +3 -1
  276. /package/src/components/{revision-block-diff → revision-diff-panel}/style.scss +0 -0
@@ -0,0 +1,151 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ PanelBody,
6
+ Button,
7
+ __experimentalHStack as HStack,
8
+ __experimentalVStack as VStack,
9
+ privateApis as componentsPrivateApis,
10
+ } from '@wordpress/components';
11
+ import { store as coreStore } from '@wordpress/core-data';
12
+ import { DataViews } from '@wordpress/dataviews';
13
+ import { dateI18n, getDate, humanTimeDiff, getSettings } from '@wordpress/date';
14
+ import { useSelect, useDispatch } from '@wordpress/data';
15
+ import { __ } from '@wordpress/i18n';
16
+ import { authorField } from '@wordpress/fields';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import PostLastRevisionCheck from '../post-last-revision/check';
22
+ import { store as editorStore } from '../../store';
23
+ import { unlock } from '../../lock-unlock';
24
+
25
+ const { Badge } = unlock( componentsPrivateApis );
26
+ const DAY_IN_MILLISECONDS = 86400000;
27
+ const EMPTY_ARRAY = [];
28
+
29
+ const REVISIONS_QUERY = {
30
+ per_page: 3,
31
+ orderby: 'date',
32
+ order: 'desc',
33
+ context: 'embed',
34
+ _fields: 'id,date,author',
35
+ };
36
+ const defaultLayouts = { activity: {} };
37
+ const view = {
38
+ type: 'activity',
39
+ titleField: 'date',
40
+ fields: [ 'author' ],
41
+ layout: {
42
+ density: 'compact',
43
+ },
44
+ };
45
+ const fields = [
46
+ {
47
+ id: 'date',
48
+ label: __( 'Date' ),
49
+ render: ( { item } ) => {
50
+ const dateNowInMs = getDate( null ).getTime();
51
+ const date = getDate( item.date ?? null );
52
+ const displayDate =
53
+ dateNowInMs - date.getTime() > DAY_IN_MILLISECONDS
54
+ ? dateI18n(
55
+ getSettings().formats.datetimeAbbreviated,
56
+ date
57
+ )
58
+ : humanTimeDiff( date );
59
+ return (
60
+ <time
61
+ className="editor-post-revisions-panel__revision-date"
62
+ dateTime={ item.date }
63
+ >
64
+ { displayDate }
65
+ </time>
66
+ );
67
+ },
68
+ enableSorting: false,
69
+ enableHiding: false,
70
+ },
71
+ authorField,
72
+ ];
73
+ const noop = () => {};
74
+ const paginationInfo = {};
75
+
76
+ function PostRevisionsPanelContent() {
77
+ const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
78
+ const { revisionsCount, revisions, isLoading, lastRevisionId } = useSelect(
79
+ ( select ) => {
80
+ const { getCurrentPostId, getCurrentPostType } =
81
+ select( editorStore );
82
+ const {
83
+ getCurrentPostRevisionsCount,
84
+ getCurrentPostLastRevisionId,
85
+ } = select( editorStore );
86
+ const { getRevisions, isResolving } = select( coreStore );
87
+ const query = [
88
+ 'postType',
89
+ getCurrentPostType(),
90
+ getCurrentPostId(),
91
+ REVISIONS_QUERY,
92
+ ];
93
+ const _revisions = getRevisions( ...query );
94
+ return {
95
+ revisionsCount: getCurrentPostRevisionsCount(),
96
+ lastRevisionId: getCurrentPostLastRevisionId(),
97
+ revisions: _revisions,
98
+ isLoading: isResolving( 'getRevisions', query ),
99
+ };
100
+ },
101
+ []
102
+ );
103
+ return (
104
+ <PanelBody
105
+ title={
106
+ <HStack justify="space-between" align="center" as="span">
107
+ <span>{ __( 'Revisions' ) }</span>
108
+ <Badge className="editor-post-revisions-panel__revisions-count">
109
+ { revisionsCount }
110
+ </Badge>
111
+ </HStack>
112
+ }
113
+ initialOpen={ false }
114
+ >
115
+ <VStack className="editor-post-revisions-panel">
116
+ <DataViews
117
+ view={ view }
118
+ onChangeView={ noop }
119
+ fields={ fields }
120
+ data={ revisions || EMPTY_ARRAY }
121
+ isLoading={ isLoading }
122
+ paginationInfo={ paginationInfo }
123
+ defaultLayouts={ defaultLayouts }
124
+ getItemId={ ( item ) => item.id }
125
+ isItemClickable={ () => true }
126
+ onClickItem={ ( item ) => {
127
+ setCurrentRevisionId( item.id );
128
+ } }
129
+ >
130
+ <DataViews.Layout />
131
+ </DataViews>
132
+ <Button
133
+ className="editor-post-revisions-panel__view-all"
134
+ __next40pxDefaultSize
135
+ variant="secondary"
136
+ onClick={ () => setCurrentRevisionId( lastRevisionId ) }
137
+ >
138
+ { __( 'View all revisions' ) }
139
+ </Button>
140
+ </VStack>
141
+ </PanelBody>
142
+ );
143
+ }
144
+
145
+ export default function PostRevisionsPanel() {
146
+ return (
147
+ <PostLastRevisionCheck>
148
+ <PostRevisionsPanelContent />
149
+ </PostLastRevisionCheck>
150
+ );
151
+ }
@@ -0,0 +1,16 @@
1
+ .editor-post-revisions-panel {
2
+ .editor-post-revisions-panel__view-all {
3
+ justify-content: center;
4
+ }
5
+
6
+ .editor-post-revisions-panel__revision-date {
7
+ text-transform: uppercase;
8
+ font-weight: 600;
9
+ font-size: 12px;
10
+ }
11
+ }
12
+
13
+ .editor-post-revisions-panel__revisions-count {
14
+ margin-top: -4.5px;
15
+ margin-bottom: -4.5px;
16
+ }
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { useMemo } from '@wordpress/element';
5
4
  import { useSelect, useDispatch } from '@wordpress/data';
6
5
  import { RangeControl, Spinner } from '@wordpress/components';
7
6
  import { store as coreStore } from '@wordpress/core-data';
@@ -35,11 +34,25 @@ function RevisionsSlider() {
35
34
  }
36
35
 
37
36
  const entityConfig = getEntityConfig( 'postType', postType );
37
+ const _revisionKey = entityConfig?.revisionKey || 'id';
38
38
  const query = {
39
39
  per_page: -1,
40
40
  context: 'edit',
41
- _fields:
42
- 'id,date,author,meta,title.raw,excerpt.raw,content.raw',
41
+ orderby: 'date',
42
+ order: 'asc',
43
+ _fields: [
44
+ ...new Set( [
45
+ 'id',
46
+ 'date',
47
+ 'modified',
48
+ 'author',
49
+ 'meta',
50
+ 'title.raw',
51
+ 'excerpt.raw',
52
+ 'content.raw',
53
+ _revisionKey,
54
+ ] ),
55
+ ].join(),
43
56
  };
44
57
  return {
45
58
  revisions: getRevisions( 'postType', postType, postId, query ),
@@ -52,7 +65,7 @@ function RevisionsSlider() {
52
65
  currentRevisionId: unlock(
53
66
  select( editorStore )
54
67
  ).getCurrentRevisionId(),
55
- revisionKey: entityConfig?.revisionKey || 'id',
68
+ revisionKey: _revisionKey,
56
69
  };
57
70
  },
58
71
  []
@@ -60,21 +73,12 @@ function RevisionsSlider() {
60
73
 
61
74
  const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
62
75
 
63
- const sortedRevisions = useMemo( () => {
64
- return (
65
- revisions
66
- ?.slice()
67
- .sort( ( a, b ) => new Date( a.date ) - new Date( b.date ) ) ??
68
- []
69
- );
70
- }, [ revisions ] );
71
-
72
- const selectedIndex = sortedRevisions.findIndex(
76
+ const selectedIndex = revisions?.findIndex(
73
77
  ( r ) => r[ revisionKey ] === currentRevisionId
74
78
  );
75
79
 
76
80
  const handleSliderChange = ( index ) => {
77
- const revision = sortedRevisions[ index ];
81
+ const revision = revisions?.[ index ];
78
82
  if ( revision ) {
79
83
  setCurrentRevisionId( revision[ revisionKey ] );
80
84
  }
@@ -83,7 +87,7 @@ function RevisionsSlider() {
83
87
  // Format date for tooltip.
84
88
  const dateSettings = getDateSettings();
85
89
  const renderTooltipContent = ( index ) => {
86
- const revision = sortedRevisions[ index ];
90
+ const revision = revisions?.[ index ];
87
91
  if ( ! revision ) {
88
92
  return index;
89
93
  }
@@ -94,7 +98,7 @@ function RevisionsSlider() {
94
98
  return <Spinner />;
95
99
  }
96
100
 
97
- if ( ! sortedRevisions.length ) {
101
+ if ( ! revisions?.length ) {
98
102
  return (
99
103
  <span className="editor-revisions-header__no-revisions">
100
104
  { __( 'No revisions found.' ) }
@@ -102,7 +106,7 @@ function RevisionsSlider() {
102
106
  );
103
107
  }
104
108
 
105
- if ( sortedRevisions.length === 1 ) {
109
+ if ( revisions?.length === 1 ) {
106
110
  return (
107
111
  <span className="editor-revisions-header__no-revisions">
108
112
  { __( 'Only one revision found.' ) }
@@ -116,7 +120,7 @@ function RevisionsSlider() {
116
120
  className="editor-revisions-header__slider"
117
121
  hideLabelFromVision
118
122
  label={ __( 'Revision' ) }
119
- max={ sortedRevisions.length - 1 }
123
+ max={ revisions?.length - 1 }
120
124
  min={ 0 }
121
125
  marks
122
126
  onChange={ handleSliderChange }
@@ -118,10 +118,7 @@ export default function CreateNewTemplateModal( { onClose } ) {
118
118
  size="small"
119
119
  overlayClassName="editor-post-template__create-template-modal"
120
120
  >
121
- <form
122
- className="editor-post-template__create-form"
123
- onSubmit={ submit }
124
- >
121
+ <form onSubmit={ submit }>
125
122
  <VStack spacing="3">
126
123
  <TextControl
127
124
  __next40pxDefaultSize
@@ -3,7 +3,8 @@
3
3
  */
4
4
  import { useSelect } from '@wordpress/data';
5
5
  import { useMemo } from '@wordpress/element';
6
- import { store as coreStore } from '@wordpress/core-data';
6
+ import { useEntityProp, store as coreStore } from '@wordpress/core-data';
7
+ import { __, sprintf } from '@wordpress/i18n';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -64,20 +65,75 @@ function useTemplates( postType ) {
64
65
  );
65
66
  }
66
67
 
67
- export function useAvailableTemplates( postType ) {
68
+ export function useAvailableTemplates() {
69
+ const { postType, postId } = useEditedPostContext();
70
+ const [ postSlug ] = useEntityProp( 'postType', postType, 'slug', postId );
68
71
  const currentTemplateSlug = useCurrentTemplateSlug();
69
72
  const allowSwitchingTemplate = useAllowSwitchingTemplates();
70
73
  const templates = useTemplates( postType );
74
+ // Add the default template to the available ones. We don't care about
75
+ // possible assignment to postspage/homepage because it's guarded by
76
+ // `allowSwitchingTemplate` above.
77
+ const defaultTemplate = useSelect(
78
+ ( select ) => {
79
+ // Only append the default template if the experiment is enabled.
80
+ if ( ! window?.__experimentalDataFormInspector ) {
81
+ return null;
82
+ }
83
+ // If the default template is already assigned, no need
84
+ // to add it to the available templates.
85
+ if ( ! currentTemplateSlug ) {
86
+ return null;
87
+ }
88
+ const { getDefaultTemplateId, getEntityRecord } =
89
+ select( coreStore );
90
+ let slug;
91
+ if ( postSlug ) {
92
+ slug =
93
+ postType === 'page'
94
+ ? `${ postType }-${ postSlug }`
95
+ : `single-${ postType }-${ postSlug }`;
96
+ } else {
97
+ slug = postType === 'page' ? 'page' : `single-${ postType }`;
98
+ }
99
+ const templateId = getDefaultTemplateId( { slug } );
100
+ if ( ! templateId ) {
101
+ return null;
102
+ }
103
+ return getEntityRecord( 'postType', 'wp_template', templateId );
104
+ },
105
+ [ currentTemplateSlug, postSlug, postType ]
106
+ );
71
107
  return useMemo(
72
108
  () =>
73
109
  allowSwitchingTemplate &&
74
- templates?.filter(
75
- ( template ) =>
76
- template.is_custom &&
77
- template.slug !== currentTemplateSlug &&
78
- !! template.content.raw // Skip empty templates.
79
- ),
80
- [ templates, currentTemplateSlug, allowSwitchingTemplate ]
110
+ [
111
+ ...( templates || [] ).filter(
112
+ ( template ) =>
113
+ template.is_custom &&
114
+ template.slug !== currentTemplateSlug &&
115
+ !! template.content.raw // Skip empty templates.
116
+ ),
117
+ defaultTemplate && {
118
+ ...defaultTemplate,
119
+ title: {
120
+ rendered: sprintf(
121
+ // translators: %s: Template name
122
+ __( '%s (default)' ),
123
+ defaultTemplate.title.rendered
124
+ ),
125
+ },
126
+ // That's extra custom prop in order to update to an empty template
127
+ // when we select the default template.
128
+ isDefault: true,
129
+ },
130
+ ].filter( Boolean ),
131
+ [
132
+ templates,
133
+ defaultTemplate,
134
+ currentTemplateSlug,
135
+ allowSwitchingTemplate,
136
+ ]
81
137
  );
82
138
  }
83
139
 
@@ -52,12 +52,6 @@
52
52
  }
53
53
  }
54
54
 
55
- .editor-post-template__create-form {
56
- @include break-medium() {
57
- width: $grid-unit * 40;
58
- }
59
- }
60
-
61
55
  .editor-post-template__classic-theme-dropdown {
62
56
  padding: $grid-unit-10;
63
57
  }
@@ -16,23 +16,40 @@ import { parse } from '@wordpress/blocks';
16
16
  import { useAvailableTemplates, useEditedPostContext } from './hooks';
17
17
  import { searchTemplates } from '../../utils/search-templates';
18
18
 
19
- export default function SwapTemplateButton( { onClick } ) {
20
- const [ showModal, setShowModal ] = useState( false );
19
+ export function SwapTemplateModal( { onRequestClose, onSelect } ) {
21
20
  const { postType, postId } = useEditedPostContext();
22
- const availableTemplates = useAvailableTemplates( postType );
23
21
  const { editEntityRecord } = useDispatch( coreStore );
24
-
25
22
  const onTemplateSelect = async ( template ) => {
26
23
  editEntityRecord(
27
24
  'postType',
28
25
  postType,
29
26
  postId,
30
- { template: template.name },
27
+ // Since we append the default template we need to properly
28
+ // update to an empty string.
29
+ { template: template.isDefault ? '' : template.name },
31
30
  { undoIgnore: true }
32
31
  );
33
- setShowModal( false ); // Close the template suggestions modal first.
34
- onClick();
32
+ onRequestClose();
33
+ onSelect?.();
35
34
  };
35
+ return (
36
+ <Modal
37
+ title={ __( 'Choose a template' ) }
38
+ onRequestClose={ onRequestClose }
39
+ overlayClassName="editor-post-template__swap-template-modal"
40
+ isFullScreen
41
+ >
42
+ <div className="editor-post-template__swap-template-modal-content">
43
+ <TemplatesList onSelect={ onTemplateSelect } />
44
+ </div>
45
+ </Modal>
46
+ );
47
+ }
48
+
49
+ export default function SwapTemplateButton( { onClick } ) {
50
+ const [ showModal, setShowModal ] = useState( false );
51
+ const availableTemplates = useAvailableTemplates();
52
+
36
53
  return (
37
54
  <>
38
55
  <MenuItem
@@ -43,27 +60,18 @@ export default function SwapTemplateButton( { onClick } ) {
43
60
  { __( 'Change template' ) }
44
61
  </MenuItem>
45
62
  { showModal && (
46
- <Modal
47
- title={ __( 'Choose a template' ) }
63
+ <SwapTemplateModal
48
64
  onRequestClose={ () => setShowModal( false ) }
49
- overlayClassName="editor-post-template__swap-template-modal"
50
- isFullScreen
51
- >
52
- <div className="editor-post-template__swap-template-modal-content">
53
- <TemplatesList
54
- postType={ postType }
55
- onSelect={ onTemplateSelect }
56
- />
57
- </div>
58
- </Modal>
65
+ onSelect={ onClick }
66
+ />
59
67
  ) }
60
68
  </>
61
69
  );
62
70
  }
63
71
 
64
- function TemplatesList( { postType, onSelect } ) {
72
+ function TemplatesList( { onSelect } ) {
65
73
  const [ searchValue, setSearchValue ] = useState( '' );
66
- const availableTemplates = useAvailableTemplates( postType );
74
+ const availableTemplates = useAvailableTemplates();
67
75
  const templatesAsPatterns = useMemo(
68
76
  () =>
69
77
  availableTemplates.map( ( template ) => ( {
@@ -71,6 +79,7 @@ function TemplatesList( { postType, onSelect } ) {
71
79
  blocks: parse( template.content.raw ),
72
80
  title: decodeEntities( template.title.rendered ),
73
81
  id: template.id,
82
+ isDefault: template.isDefault,
74
83
  } ) ),
75
84
  [ availableTemplates ]
76
85
  );
@@ -124,7 +124,7 @@ const PostTitle = forwardRef( ( _, forwardedRef ) => {
124
124
  try {
125
125
  plainText = clipboardData.getData( 'text/plain' );
126
126
  html = clipboardData.getData( 'text/html' );
127
- } catch ( error ) {
127
+ } catch {
128
128
  // Some browsers like UC Browser paste plain text by default and
129
129
  // don't support clipboardData at all, so allow default
130
130
  // behaviour.
@@ -181,7 +181,7 @@ const PostTitle = forwardRef( ( _, forwardedRef ) => {
181
181
  const style = isEditingContentOnlySection ? { opacity: 0.2 } : undefined;
182
182
 
183
183
  return (
184
- /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
184
+ /* eslint-disable jsx-a11y/no-noninteractive-element-to-interactive-role */
185
185
  <h1
186
186
  ref={ useMergeRefs( [ richTextRef, focusRef ] ) }
187
187
  contentEditable={ ! isEditingContentOnlySection && ! isPreview }
@@ -195,7 +195,7 @@ const PostTitle = forwardRef( ( _, forwardedRef ) => {
195
195
  onPaste={ onPaste }
196
196
  style={ style }
197
197
  />
198
- /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
198
+ /* eslint-enable jsx-a11y/no-noninteractive-element-to-interactive-role */
199
199
  );
200
200
  } );
201
201
 
@@ -55,20 +55,25 @@ export default function EditorPreferencesModal( { extraSections = {} } ) {
55
55
 
56
56
  function PreferencesModalContents( { extraSections = {} } ) {
57
57
  const isLargeViewport = useViewportMatch( 'medium' );
58
- const showBlockBreadcrumbsOption = useSelect(
58
+ const { showBlockBreadcrumbsOption, showCollaborationOptions } = useSelect(
59
59
  ( select ) => {
60
- const { getEditorSettings } = select( editorStore );
60
+ const { getEditorSettings, isCollaborationEnabledForCurrentPost } =
61
+ select( editorStore );
61
62
  const { get } = select( preferencesStore );
62
63
  const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
63
64
  const isDistractionFreeEnabled = get( 'core', 'distractionFree' );
64
- return (
65
- ! isDistractionFreeEnabled &&
66
- isLargeViewport &&
67
- isRichEditingEnabled
68
- );
65
+ return {
66
+ showBlockBreadcrumbsOption:
67
+ ! isDistractionFreeEnabled &&
68
+ isLargeViewport &&
69
+ isRichEditingEnabled,
70
+ showCollaborationOptions:
71
+ isCollaborationEnabledForCurrentPost(),
72
+ };
69
73
  },
70
74
  [ isLargeViewport ]
71
75
  );
76
+
72
77
  const { setIsListViewOpened, setIsInserterOpened } =
73
78
  useDispatch( editorStore );
74
79
  const { set: setPreference } = useDispatch( preferencesStore );
@@ -120,24 +125,30 @@ function PreferencesModalContents( { extraSections = {} } ) {
120
125
  ) }
121
126
  label={ __( 'Show starter patterns' ) }
122
127
  />
123
- <PreferenceToggleControl
124
- scope="core"
125
- featureName="showCollaborationCursor"
126
- help={ __(
127
- 'Show your own avatar inside blocks during collaborative editing sessions.'
128
- ) }
129
- label={ __( 'Show avatar in blocks' ) }
130
- />
131
- <PreferenceToggleControl
132
- scope="core"
133
- featureName="showCollaborationNotifications"
134
- help={ __(
135
- 'Show notifications when collaborators join, leave, or save the post.'
136
- ) }
137
- label={ __(
138
- 'Show collaboration notifications'
139
- ) }
140
- />
128
+ { showCollaborationOptions && (
129
+ <>
130
+ <PreferenceToggleControl
131
+ scope="core"
132
+ featureName="showCollaborationCursor"
133
+ help={ __(
134
+ 'Show your own avatar inside blocks during collaborative editing sessions.'
135
+ ) }
136
+ label={ __(
137
+ 'Show avatar in blocks'
138
+ ) }
139
+ />
140
+ <PreferenceToggleControl
141
+ scope="core"
142
+ featureName="showCollaborationNotifications"
143
+ help={ __(
144
+ 'Show notifications when collaborators join, leave, or save the post.'
145
+ ) }
146
+ label={ __(
147
+ 'Show collaboration notifications'
148
+ ) }
149
+ />
150
+ </>
151
+ ) }
141
152
  </PreferencesModalSection>
142
153
  <PreferencesModalSection
143
154
  title={ __( 'Document settings' ) }
@@ -350,6 +361,7 @@ function PreferencesModalContents( { extraSections = {} } ) {
350
361
  ].filter( Boolean ),
351
362
  [
352
363
  showBlockBreadcrumbsOption,
364
+ showCollaborationOptions,
353
365
  extraSections,
354
366
  setIsInserterOpened,
355
367
  setIsListViewOpened,
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { PanelBody } from '@wordpress/components';
5
4
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
5
  import { useSelect } from '@wordpress/data';
7
6
  import { __ } from '@wordpress/i18n';
@@ -9,7 +8,7 @@ import { __ } from '@wordpress/i18n';
9
8
  /**
10
9
  * Internal dependencies
11
10
  */
12
- import PostPanelRow from '../post-panel-row';
11
+ import RevisionDiffPanel from '../revision-diff-panel';
13
12
 
14
13
  /**
15
14
  * Panel that shows changed block attributes for the selected block
@@ -27,48 +26,14 @@ export default function RevisionBlockDiffPanel() {
27
26
  return null;
28
27
  }
29
28
 
30
- const diffInfo = block.attributes?.__revisionDiffStatus;
31
- const changedAttributes = diffInfo?.changedAttributes;
32
-
33
- if ( ! changedAttributes ) {
34
- return null;
35
- }
36
-
37
- const fields = Object.entries( changedAttributes ).map(
38
- ( [ key, parts ] ) => (
39
- <PostPanelRow key={ key } label={ key }>
40
- <span className="editor-revision-fields-diff__value">
41
- { parts.map( ( part, index ) => {
42
- if ( part.added ) {
43
- return (
44
- <ins
45
- key={ index }
46
- className="editor-revision-fields-diff__added"
47
- >
48
- { part.value }
49
- </ins>
50
- );
51
- }
52
- if ( part.removed ) {
53
- return (
54
- <del
55
- key={ index }
56
- className="editor-revision-fields-diff__removed"
57
- >
58
- { part.value }
59
- </del>
60
- );
61
- }
62
- return <span key={ index }>{ part.value }</span>;
63
- } ) }
64
- </span>
65
- </PostPanelRow>
66
- )
67
- );
29
+ const changedAttributes =
30
+ block.attributes?.__revisionDiffStatus?.changedAttributes;
68
31
 
69
32
  return (
70
- <PanelBody title={ __( 'Changed attributes' ) } initialOpen>
71
- { fields }
72
- </PanelBody>
33
+ <RevisionDiffPanel
34
+ title={ __( 'Changed attributes' ) }
35
+ entries={ changedAttributes }
36
+ initialOpen
37
+ />
73
38
  );
74
39
  }