@wordpress/editor 14.45.2-next.v.202605131032.0 → 14.47.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 (326) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/build/components/collab-sidebar/add-note.cjs +6 -0
  3. package/build/components/collab-sidebar/add-note.cjs.map +2 -2
  4. package/build/components/collab-sidebar/hooks.cjs +36 -24
  5. package/build/components/collab-sidebar/hooks.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +19 -10
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/note-byline.cjs +16 -9
  9. package/build/components/collab-sidebar/note-byline.cjs.map +2 -2
  10. package/build/components/collab-sidebar/notes.cjs +20 -11
  11. package/build/components/collab-sidebar/notes.cjs.map +2 -2
  12. package/build/components/collab-sidebar/utils.cjs +42 -2
  13. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  14. package/build/components/collaborators-overlay/compute-selection.cjs +39 -15
  15. package/build/components/collaborators-overlay/compute-selection.cjs.map +3 -3
  16. package/build/components/collaborators-overlay/use-block-highlighting.cjs +10 -2
  17. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +3 -3
  18. package/build/components/collaborators-overlay/use-render-cursors.cjs +15 -7
  19. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  20. package/build/components/collaborators-presence/avatar/component.cjs +5 -1
  21. package/build/components/collaborators-presence/avatar/component.cjs.map +3 -3
  22. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +6 -3
  23. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
  24. package/build/components/editor-interface/index.cjs +17 -16
  25. package/build/components/editor-interface/index.cjs.map +3 -3
  26. package/build/components/editor-notices/index.cjs +6 -1
  27. package/build/components/editor-notices/index.cjs.map +3 -3
  28. package/build/components/global-styles/hooks.cjs +12 -1
  29. package/build/components/global-styles/hooks.cjs.map +2 -2
  30. package/build/components/header/index.cjs +11 -6
  31. package/build/components/header/index.cjs.map +2 -2
  32. package/build/components/media/media-editor-modal.cjs +14 -1
  33. package/build/components/media/media-editor-modal.cjs.map +2 -2
  34. package/build/components/post-card-panel/index.cjs +7 -1
  35. package/build/components/post-card-panel/index.cjs.map +3 -3
  36. package/build/components/post-last-revision/index.cjs +28 -8
  37. package/build/components/post-last-revision/index.cjs.map +2 -2
  38. package/build/components/post-locked-modal/index.cjs +9 -6
  39. package/build/components/post-locked-modal/index.cjs.map +2 -2
  40. package/build/components/post-publish-button/label.cjs +0 -7
  41. package/build/components/post-publish-button/label.cjs.map +2 -2
  42. package/build/components/post-publish-panel/prepublish.cjs +8 -1
  43. package/build/components/post-publish-panel/prepublish.cjs.map +3 -3
  44. package/build/components/post-revisions-panel/index.cjs +7 -0
  45. package/build/components/post-revisions-panel/index.cjs.map +2 -2
  46. package/build/components/post-revisions-preview/diff-markers.cjs +21 -13
  47. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  48. package/build/components/post-revisions-preview/revisions-canvas.cjs +7 -1
  49. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
  50. package/build/components/post-taxonomies/check.cjs +1 -2
  51. package/build/components/post-taxonomies/check.cjs.map +2 -2
  52. package/build/components/post-taxonomies/index.cjs +1 -2
  53. package/build/components/post-taxonomies/index.cjs.map +2 -2
  54. package/build/components/preferences-modal/index.cjs +1 -1
  55. package/build/components/preferences-modal/index.cjs.map +2 -2
  56. package/build/components/preview-dropdown/index.cjs.map +3 -3
  57. package/build/components/provider/index.cjs +5 -21
  58. package/build/components/provider/index.cjs.map +3 -3
  59. package/build/components/provider/use-block-editor-settings.cjs +16 -9
  60. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  61. package/build/components/resizable-editor/resize-handle.cjs +24 -16
  62. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  63. package/build/components/sidebar/header.cjs +16 -21
  64. package/build/components/sidebar/header.cjs.map +3 -3
  65. package/build/components/sidebar/index.cjs +2 -6
  66. package/build/components/sidebar/index.cjs.map +2 -2
  67. package/build/components/start-page-options/index.cjs +14 -4
  68. package/build/components/start-page-options/index.cjs.map +2 -2
  69. package/build/components/start-template-options/index.cjs +8 -6
  70. package/build/components/start-template-options/index.cjs.map +2 -2
  71. package/build/components/styles-canvas/style-book.cjs +59 -2
  72. package/build/components/styles-canvas/style-book.cjs.map +2 -2
  73. package/build/components/sync-connection-error-modal/index.cjs +10 -7
  74. package/build/components/sync-connection-error-modal/index.cjs.map +3 -3
  75. package/build/components/template-actions-panel/block-theme-content.cjs +21 -12
  76. package/build/components/template-actions-panel/block-theme-content.cjs.map +2 -2
  77. package/build/dataviews/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-actions.cjs +17 -1
  79. package/build/store/private-actions.cjs.map +3 -3
  80. package/build/store/private-selectors.cjs +18 -0
  81. package/build/store/private-selectors.cjs.map +2 -2
  82. package/build/store/selectors.cjs +0 -17
  83. package/build/store/selectors.cjs.map +2 -2
  84. package/build/{components/media → utils/media-delete}/index.cjs +12 -13
  85. package/build/utils/media-delete/index.cjs.map +7 -0
  86. package/build/utils/media-finalize/index.cjs +3 -1
  87. package/build/utils/media-finalize/index.cjs.map +2 -2
  88. package/build/utils/sync-error-messages.cjs +9 -0
  89. package/build/utils/sync-error-messages.cjs.map +2 -2
  90. package/build-module/components/collab-sidebar/add-note.mjs +6 -0
  91. package/build-module/components/collab-sidebar/add-note.mjs.map +2 -2
  92. package/build-module/components/collab-sidebar/hooks.mjs +42 -25
  93. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  94. package/build-module/components/collab-sidebar/index.mjs +19 -10
  95. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  96. package/build-module/components/collab-sidebar/note-byline.mjs +17 -10
  97. package/build-module/components/collab-sidebar/note-byline.mjs.map +2 -2
  98. package/build-module/components/collab-sidebar/notes.mjs +26 -13
  99. package/build-module/components/collab-sidebar/notes.mjs.map +2 -2
  100. package/build-module/components/collab-sidebar/utils.mjs +38 -2
  101. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  102. package/build-module/components/collaborators-overlay/compute-selection.mjs +36 -12
  103. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
  104. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +10 -3
  105. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  106. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +11 -6
  107. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  108. package/build-module/components/collaborators-presence/avatar/component.mjs +7 -3
  109. package/build-module/components/collaborators-presence/avatar/component.mjs.map +2 -2
  110. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +6 -3
  111. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  112. package/build-module/components/editor-interface/index.mjs +22 -17
  113. package/build-module/components/editor-interface/index.mjs.map +2 -2
  114. package/build-module/components/editor-notices/index.mjs +6 -1
  115. package/build-module/components/editor-notices/index.mjs.map +2 -2
  116. package/build-module/components/global-styles/hooks.mjs +12 -1
  117. package/build-module/components/global-styles/hooks.mjs.map +2 -2
  118. package/build-module/components/header/index.mjs +11 -6
  119. package/build-module/components/header/index.mjs.map +2 -2
  120. package/build-module/components/media/media-editor-modal.mjs +14 -1
  121. package/build-module/components/media/media-editor-modal.mjs.map +2 -2
  122. package/build-module/components/post-card-panel/index.mjs +8 -2
  123. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  124. package/build-module/components/post-last-revision/index.mjs +29 -9
  125. package/build-module/components/post-last-revision/index.mjs.map +2 -2
  126. package/build-module/components/post-locked-modal/index.mjs +9 -6
  127. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  128. package/build-module/components/post-publish-button/label.mjs +0 -7
  129. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  130. package/build-module/components/post-publish-panel/prepublish.mjs +9 -2
  131. package/build-module/components/post-publish-panel/prepublish.mjs.map +2 -2
  132. package/build-module/components/post-revisions-panel/index.mjs +7 -0
  133. package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
  134. package/build-module/components/post-revisions-preview/diff-markers.mjs +22 -14
  135. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  136. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +7 -1
  137. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  138. package/build-module/components/post-taxonomies/check.mjs +1 -2
  139. package/build-module/components/post-taxonomies/check.mjs.map +2 -2
  140. package/build-module/components/post-taxonomies/index.mjs +1 -2
  141. package/build-module/components/post-taxonomies/index.mjs.map +2 -2
  142. package/build-module/components/preferences-modal/index.mjs +1 -1
  143. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  144. package/build-module/components/preview-dropdown/index.mjs +2 -2
  145. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  146. package/build-module/components/provider/index.mjs +6 -22
  147. package/build-module/components/provider/index.mjs.map +2 -2
  148. package/build-module/components/provider/use-block-editor-settings.mjs +16 -9
  149. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  150. package/build-module/components/resizable-editor/resize-handle.mjs +26 -18
  151. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  152. package/build-module/components/sidebar/header.mjs +11 -16
  153. package/build-module/components/sidebar/header.mjs.map +2 -2
  154. package/build-module/components/sidebar/index.mjs +2 -7
  155. package/build-module/components/sidebar/index.mjs.map +2 -2
  156. package/build-module/components/start-page-options/index.mjs +14 -4
  157. package/build-module/components/start-page-options/index.mjs.map +2 -2
  158. package/build-module/components/start-template-options/index.mjs +8 -6
  159. package/build-module/components/start-template-options/index.mjs.map +2 -2
  160. package/build-module/components/styles-canvas/style-book.mjs +60 -3
  161. package/build-module/components/styles-canvas/style-book.mjs.map +2 -2
  162. package/build-module/components/sync-connection-error-modal/index.mjs +14 -8
  163. package/build-module/components/sync-connection-error-modal/index.mjs.map +2 -2
  164. package/build-module/components/template-actions-panel/block-theme-content.mjs +21 -13
  165. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +2 -2
  166. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  167. package/build-module/store/private-actions.mjs +16 -1
  168. package/build-module/store/private-actions.mjs.map +2 -2
  169. package/build-module/store/private-selectors.mjs +18 -0
  170. package/build-module/store/private-selectors.mjs.map +2 -2
  171. package/build-module/store/selectors.mjs +0 -16
  172. package/build-module/store/selectors.mjs.map +2 -2
  173. package/build-module/utils/media-delete/index.mjs +12 -0
  174. package/build-module/utils/media-delete/index.mjs.map +7 -0
  175. package/build-module/utils/media-finalize/index.mjs +3 -1
  176. package/build-module/utils/media-finalize/index.mjs.map +2 -2
  177. package/build-module/utils/sync-error-messages.mjs +8 -0
  178. package/build-module/utils/sync-error-messages.mjs.map +2 -2
  179. package/build-style/style-rtl.css +462 -408
  180. package/build-style/style.css +462 -408
  181. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -1
  182. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  183. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  184. package/build-types/components/collab-sidebar/note-byline.d.ts +3 -0
  185. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -1
  186. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -1
  187. package/build-types/components/collab-sidebar/utils.d.ts +33 -0
  188. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  189. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -1
  190. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts +3 -0
  191. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  192. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  193. package/build-types/components/collaborators-presence/avatar/component.d.ts.map +1 -1
  194. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  195. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  196. package/build-types/components/editor-notices/index.d.ts.map +1 -1
  197. package/build-types/components/global-styles/hooks.d.ts.map +1 -1
  198. package/build-types/components/media/media-editor-modal.d.ts +6 -2
  199. package/build-types/components/media/media-editor-modal.d.ts.map +1 -1
  200. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  201. package/build-types/components/post-last-revision/index.d.ts.map +1 -1
  202. package/build-types/components/post-locked-modal/index.d.ts +1 -6
  203. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  204. package/build-types/components/post-publish-button/label.d.ts.map +1 -1
  205. package/build-types/components/post-publish-panel/prepublish.d.ts.map +1 -1
  206. package/build-types/components/post-revisions-panel/index.d.ts +1 -1
  207. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -1
  208. package/build-types/components/post-revisions-preview/diff-markers.d.ts.map +1 -1
  209. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  210. package/build-types/components/post-taxonomies/check.d.ts.map +1 -1
  211. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +1 -6
  212. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -6
  213. package/build-types/components/post-taxonomies/index.d.ts.map +1 -1
  214. package/build-types/components/provider/index.d.ts.map +1 -1
  215. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  216. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  217. package/build-types/components/sidebar/index.d.ts.map +1 -1
  218. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  219. package/build-types/components/start-template-options/index.d.ts.map +1 -1
  220. package/build-types/components/styles-canvas/style-book.d.ts.map +1 -1
  221. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -1
  222. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -1
  223. package/build-types/dataviews/store/private-actions.d.ts +0 -1
  224. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  225. package/build-types/store/private-actions.d.ts +15 -0
  226. package/build-types/store/private-actions.d.ts.map +1 -1
  227. package/build-types/store/private-selectors.d.ts +10 -0
  228. package/build-types/store/private-selectors.d.ts.map +1 -1
  229. package/build-types/store/selectors.d.ts +0 -10
  230. package/build-types/store/selectors.d.ts.map +1 -1
  231. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  232. package/build-types/utils/media-delete/index.d.ts +2 -0
  233. package/build-types/utils/media-delete/index.d.ts.map +1 -0
  234. package/build-types/utils/media-finalize/index.d.ts +1 -1
  235. package/build-types/utils/media-finalize/index.d.ts.map +1 -1
  236. package/build-types/utils/sync-error-messages.d.ts +1 -0
  237. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  238. package/package.json +48 -48
  239. package/src/components/collab-sidebar/add-note.js +9 -0
  240. package/src/components/collab-sidebar/hooks.js +53 -29
  241. package/src/components/collab-sidebar/index.js +28 -14
  242. package/src/components/collab-sidebar/note-byline.js +15 -10
  243. package/src/components/collab-sidebar/notes.js +36 -14
  244. package/src/components/collab-sidebar/test/utils.js +375 -1
  245. package/src/components/collab-sidebar/utils.js +70 -1
  246. package/src/components/collaborators-overlay/compute-selection.ts +67 -19
  247. package/src/components/collaborators-overlay/use-block-highlighting.ts +14 -1
  248. package/src/components/collaborators-overlay/use-render-cursors.ts +15 -4
  249. package/src/components/collaborators-presence/avatar/component.tsx +10 -3
  250. package/src/components/collaborators-presence/avatar/test/index.tsx +50 -18
  251. package/src/components/collaborators-presence/styles/collaborators-presence.scss +4 -1
  252. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +2 -1
  253. package/src/components/collaborators-presence/use-collaborator-notifications.ts +6 -4
  254. package/src/components/editor-help/help-topic-row.native.js +2 -2
  255. package/src/components/editor-interface/index.js +22 -23
  256. package/src/components/editor-interface/style.scss +4 -0
  257. package/src/components/editor-notices/index.js +7 -1
  258. package/src/components/error-boundary/index.native.js +2 -2
  259. package/src/components/global-styles/hooks.js +26 -0
  260. package/src/components/global-styles-sidebar/style.scss +0 -9
  261. package/src/components/header/index.js +12 -12
  262. package/src/components/media/media-editor-modal.js +20 -2
  263. package/src/components/offline-status/index.native.js +2 -2
  264. package/src/components/post-card-panel/index.js +5 -2
  265. package/src/components/post-last-revision/index.js +37 -9
  266. package/src/components/post-last-revision/style.scss +0 -3
  267. package/src/components/post-locked-modal/index.js +8 -5
  268. package/src/components/post-panel-row/style.scss +1 -0
  269. package/src/components/post-publish-button/label.js +0 -11
  270. package/src/components/post-publish-panel/prepublish.js +6 -2
  271. package/src/components/post-revisions-panel/index.js +8 -0
  272. package/src/components/post-revisions-preview/diff-markers.js +17 -11
  273. package/src/components/post-revisions-preview/revisions-canvas.js +7 -1
  274. package/src/components/post-revisions-preview/style.scss +4 -4
  275. package/src/components/post-taxonomies/check.js +1 -2
  276. package/src/components/post-taxonomies/index.js +1 -2
  277. package/src/components/preferences-modal/index.js +1 -1
  278. package/src/components/preview-dropdown/index.js +2 -2
  279. package/src/components/provider/index.js +10 -31
  280. package/src/components/provider/use-block-editor-settings.js +19 -12
  281. package/src/components/resizable-editor/resize-handle.js +22 -16
  282. package/src/components/sidebar/header.js +18 -28
  283. package/src/components/sidebar/index.js +5 -14
  284. package/src/components/start-page-options/index.js +19 -4
  285. package/src/components/start-template-options/index.js +13 -6
  286. package/src/components/styles-canvas/style-book.js +75 -13
  287. package/src/components/sync-connection-error-modal/index.tsx +25 -11
  288. package/src/components/template-actions-panel/block-theme-content.js +19 -13
  289. package/src/components/text-editor/style.scss +2 -2
  290. package/src/dataviews/store/private-actions.ts +0 -1
  291. package/src/store/private-actions.js +27 -0
  292. package/src/store/private-selectors.js +26 -0
  293. package/src/store/selectors.js +0 -24
  294. package/src/store/test/actions.js +34 -0
  295. package/src/utils/media-delete/index.js +11 -0
  296. package/src/utils/media-finalize/index.js +6 -1
  297. package/src/utils/media-finalize/test/index.js +32 -2
  298. package/src/utils/sync-error-messages.ts +8 -0
  299. package/src/utils/test/sync-error-messages.js +1 -0
  300. package/build/components/global-styles-provider/index.cjs +0 -181
  301. package/build/components/global-styles-provider/index.cjs.map +0 -7
  302. package/build/components/media/index.cjs.map +0 -7
  303. package/build/components/media/metadata-panel.cjs +0 -96
  304. package/build/components/media/metadata-panel.cjs.map +0 -7
  305. package/build/components/media/preview.cjs +0 -39
  306. package/build/components/media/preview.cjs.map +0 -7
  307. package/build-module/components/global-styles-provider/index.mjs +0 -156
  308. package/build-module/components/global-styles-provider/index.mjs.map +0 -7
  309. package/build-module/components/media/index.mjs +0 -8
  310. package/build-module/components/media/index.mjs.map +0 -7
  311. package/build-module/components/media/metadata-panel.mjs +0 -65
  312. package/build-module/components/media/metadata-panel.mjs.map +0 -7
  313. package/build-module/components/media/preview.mjs +0 -21
  314. package/build-module/components/media/preview.mjs.map +0 -7
  315. package/build-types/components/global-styles-provider/index.d.ts +0 -16
  316. package/build-types/components/global-styles-provider/index.d.ts.map +0 -1
  317. package/build-types/components/media/index.d.ts +0 -3
  318. package/build-types/components/media/index.d.ts.map +0 -1
  319. package/build-types/components/media/metadata-panel.d.ts +0 -12
  320. package/build-types/components/media/metadata-panel.d.ts.map +0 -1
  321. package/build-types/components/media/preview.d.ts +0 -9
  322. package/build-types/components/media/preview.d.ts.map +0 -1
  323. package/src/components/global-styles-provider/index.js +0 -207
  324. package/src/components/media/index.js +0 -2
  325. package/src/components/media/metadata-panel.js +0 -77
  326. package/src/components/media/preview.js +0 -35
@@ -10,8 +10,10 @@ extend( [ a11yPlugin ] );
10
10
  /**
11
11
  * WordPress dependencies
12
12
  */
13
- import { Icon, Tooltip } from '@wordpress/components';
13
+ import { Icon as WCIcon } from '@wordpress/components';
14
14
  import { useMemo } from '@wordpress/element';
15
+ // eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
16
+ import { Tooltip } from '@wordpress/ui';
15
17
 
16
18
  /**
17
19
  * Internal dependencies
@@ -104,7 +106,7 @@ function Avatar( {
104
106
  </span>
105
107
  { dimmed && !! statusIndicator && (
106
108
  <span className="editor-avatar__status-indicator">
107
- <Icon icon={ statusIndicator } />
109
+ <WCIcon icon={ statusIndicator } />
108
110
  </span>
109
111
  ) }
110
112
  { showBadge && (
@@ -114,7 +116,12 @@ function Avatar( {
114
116
  );
115
117
 
116
118
  if ( name && ( ! showBadge || label ) ) {
117
- return <Tooltip text={ name }>{ avatar }</Tooltip>;
119
+ return (
120
+ <Tooltip.Root>
121
+ <Tooltip.Trigger render={ avatar } />
122
+ <Tooltip.Popup>{ name }</Tooltip.Popup>
123
+ </Tooltip.Root>
124
+ );
118
125
  }
119
126
 
120
127
  return avatar;
@@ -2,12 +2,29 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { render, screen, fireEvent } from '@testing-library/react';
5
+ import userEvent from '@testing-library/user-event';
6
+
7
+ /**
8
+ * WordPress dependencies
9
+ */
10
+ // eslint-disable-next-line @wordpress/use-recommended-components -- `Tooltip` is not yet on the recommended `@wordpress/ui` allow-list; landing as a migration step ahead of the wider rollout.
11
+ import { Tooltip } from '@wordpress/ui';
5
12
 
6
13
  /**
7
14
  * Internal dependencies
8
15
  */
9
16
  import Avatar from '..';
10
17
 
18
+ /**
19
+ * Wraps the avatar in a `Tooltip.Provider` with `delay={ 0 }` so hover-based
20
+ * tooltip-presence assertions don't have to wait for the real-world delay.
21
+ *
22
+ * @param ui The avatar element (or anything else) to render.
23
+ */
24
+ function renderAvatar( ui: React.ReactElement ): ReturnType< typeof render > {
25
+ return render( <Tooltip.Provider delay={ 0 }>{ ui }</Tooltip.Provider> );
26
+ }
27
+
11
28
  /**
12
29
  * In JSDOM, `<img>` elements never fire `load` or `error` events on their
13
30
  * own. We simulate them using `fireEvent` on the `<img>` element, which we
@@ -190,12 +207,13 @@ describe( 'Avatar', () => {
190
207
  expect( avatar ).toBeInTheDocument();
191
208
  } );
192
209
 
193
- it( 'should wrap in tooltip when label differs from name', () => {
194
- render( <Avatar name="Jane Doe" label="You" variant="badge" /> );
195
- const avatar = screen.getByRole( 'img', { name: 'Jane Doe' } );
196
- // The Tooltip's Ariakit.TooltipAnchor makes the element
197
- // focusable so the tooltip can be triggered via keyboard.
198
- expect( avatar ).toHaveAttribute( 'tabindex', '0' );
210
+ it( 'should wrap in tooltip when label differs from name', async () => {
211
+ const user = userEvent.setup();
212
+ renderAvatar(
213
+ <Avatar name="Jane Doe" label="You" variant="badge" />
214
+ );
215
+ await user.hover( screen.getByRole( 'img', { name: 'Jane Doe' } ) );
216
+ expect( await screen.findByText( 'Jane Doe' ) ).toBeVisible();
199
217
  } );
200
218
  } );
201
219
 
@@ -367,23 +385,37 @@ describe( 'Avatar', () => {
367
385
  } );
368
386
 
369
387
  describe( 'tooltip', () => {
370
- it( 'should wrap in tooltip when name is provided without badge', () => {
371
- render( <Avatar name="Jane Doe" /> );
372
- const avatar = screen.getByRole( 'img', { name: 'Jane Doe' } );
373
- expect( avatar ).toHaveAttribute( 'tabindex', '0' );
388
+ it( 'should wrap in tooltip when name is provided without badge', async () => {
389
+ const user = userEvent.setup();
390
+ renderAvatar( <Avatar name="Jane Doe" /> );
391
+ await user.hover( screen.getByRole( 'img', { name: 'Jane Doe' } ) );
392
+ expect( await screen.findByText( 'Jane Doe' ) ).toBeVisible();
374
393
  } );
375
394
 
376
- it( 'should not wrap in tooltip for badge without label', () => {
377
- render( <Avatar name="Jane Doe" variant="badge" /> );
378
- const avatar = screen.getByRole( 'img', { name: 'Jane Doe' } );
379
- // Badge shows the name visibly, so no tooltip needed.
380
- expect( avatar ).not.toHaveAttribute( 'tabindex' );
395
+ it( 'should not wrap in tooltip for badge without label', async () => {
396
+ const user = userEvent.setup();
397
+ renderAvatar( <Avatar name="Jane Doe" variant="badge" /> );
398
+ // Before hovering: the single "Jane Doe" occurrence is the
399
+ // badge text — that's what the next assertion is allowed to
400
+ // match. Hovering should not add a second occurrence.
401
+ expect( screen.getAllByText( 'Jane Doe' ) ).toHaveLength( 1 );
402
+ await user.hover( screen.getByRole( 'img', { name: 'Jane Doe' } ) );
403
+ expect( screen.getAllByText( 'Jane Doe' ) ).toHaveLength( 1 );
381
404
  } );
382
405
 
383
- it( 'should not wrap in tooltip when name is not provided', () => {
384
- render( <Avatar data-testid="avatar" /> );
406
+ it( 'should not wrap in tooltip when name is not provided', async () => {
407
+ const user = userEvent.setup();
408
+ renderAvatar( <Avatar data-testid="avatar" /> );
385
409
  const avatar = screen.getByTestId( 'avatar' );
386
- expect( avatar ).not.toHaveAttribute( 'tabindex' );
410
+ const bodyTextBefore = document.body.textContent;
411
+ await user.hover( avatar );
412
+ // No name → no `Tooltip.Root` wrapper at all, so hovering
413
+ // cannot reveal any additional text content anywhere in the
414
+ // document (no popup mounts). Strict equality is what we
415
+ // want here — a substring `toHaveTextContent` would still
416
+ // pass if the popup added text.
417
+ // eslint-disable-next-line jest-dom/prefer-to-have-text-content -- intentional, see comment above.
418
+ expect( document.body.textContent ).toBe( bodyTextBefore );
387
419
  } );
388
420
  } );
389
421
  } );
@@ -8,7 +8,6 @@
8
8
  height: $button-size-compact;
9
9
  background: $gray-100;
10
10
  border-radius: $grid-unit-05;
11
- margin-right: $grid-unit-10;
12
11
 
13
12
  &:hover {
14
13
  background-color: $gray-200;
@@ -19,6 +18,10 @@
19
18
  }
20
19
  }
21
20
 
21
+ .editor-header__center .editor-collaborators-presence {
22
+ margin-right: $grid-unit-10;
23
+ }
24
+
22
25
  .editor-collaborators-presence__button.editor-collaborators-presence__button.components-button {
23
26
  display: flex;
24
27
  align-items: center;
@@ -52,7 +52,8 @@ jest.mock( '@wordpress/core-data', () => ( {
52
52
  } ) );
53
53
 
54
54
  jest.mock( '../../../lock-unlock', () => ( {
55
- unlock: jest.fn( () => ( {
55
+ unlock: jest.fn( ( value: unknown ) => ( {
56
+ ...( value as object ),
56
57
  useOnCollaboratorJoin: jest.fn(
57
58
  ( postId: unknown, _postType: unknown, callback: Function ) => {
58
59
  lastJoinPostId = postId;
@@ -70,13 +70,15 @@ export function useCollaboratorNotifications(
70
70
  ): void {
71
71
  const { postStatus, isCollaborationEnabled, showNotifications } = useSelect(
72
72
  ( select ) => {
73
- const editorSel = select( editorStore );
73
+ const {
74
+ getCurrentPostAttribute,
75
+ isCollaborationEnabledForCurrentPost,
76
+ } = unlock( select( editorStore ) );
74
77
  return {
75
- postStatus: editorSel.getCurrentPostAttribute( 'status' ) as
78
+ postStatus: getCurrentPostAttribute( 'status' ) as
76
79
  | string
77
80
  | undefined,
78
- isCollaborationEnabled:
79
- editorSel.isCollaborationEnabledForCurrentPost(),
81
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
80
82
  showNotifications:
81
83
  select( preferencesStore ).get(
82
84
  'core',
@@ -6,7 +6,7 @@ import { useNavigation } from '@react-navigation/native';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
9
- import { TextControl, Icon } from '@wordpress/components';
9
+ import { TextControl, Icon as WCIcon } from '@wordpress/components';
10
10
  import { chevronRight } from '@wordpress/icons';
11
11
 
12
12
  const HelpTopicRow = ( { label, icon, screenName, isLastItem } ) => {
@@ -25,7 +25,7 @@ const HelpTopicRow = ( { label, icon, screenName, isLastItem } ) => {
25
25
  label={ label }
26
26
  icon={ icon }
27
27
  >
28
- <Icon icon={ chevronRight } />
28
+ <WCIcon icon={ chevronRight } />
29
29
  </TextControl>
30
30
  );
31
31
  };
@@ -10,7 +10,11 @@ import { InterfaceSkeleton, ComplementaryArea } from '@wordpress/interface';
10
10
  import { useSelect, useDispatch } from '@wordpress/data';
11
11
  import { __ } from '@wordpress/i18n';
12
12
  import { store as preferencesStore } from '@wordpress/preferences';
13
- import { BlockBreadcrumb, BlockToolbar } from '@wordpress/block-editor';
13
+ import {
14
+ BlockBreadcrumb,
15
+ BlockToolbar,
16
+ store as blockEditorStore,
17
+ } from '@wordpress/block-editor';
14
18
  import { useViewportMatch } from '@wordpress/compose';
15
19
  import { useState, useCallback } from '@wordpress/element';
16
20
  import { decodeEntities } from '@wordpress/html-entities';
@@ -32,7 +36,6 @@ import SavePublishPanels from '../save-publish-panels';
32
36
  import TextEditor from '../text-editor';
33
37
  import VisualEditor from '../visual-editor';
34
38
  import StylesCanvas from '../styles-canvas';
35
- import { MediaPreview } from '../media';
36
39
 
37
40
  const interfaceLabels = {
38
41
  /* translators: accessibility text for the editor top bar landmark region. */
@@ -47,14 +50,21 @@ const interfaceLabels = {
47
50
  footer: __( 'Editor footer' ),
48
51
  };
49
52
 
50
- const Notices = () => (
51
- <InlineNotices
52
- pinnedNoticesClassName="editor-notices__pinned"
53
- dismissibleNoticesClassName="editor-notices__dismissible"
54
- >
55
- <TemplateValidationNotice />
56
- </InlineNotices>
57
- );
53
+ function Notices() {
54
+ const isValidTemplate = useSelect( ( select ) => {
55
+ return select( blockEditorStore ).isValidTemplate();
56
+ }, [] );
57
+
58
+ return (
59
+ <InlineNotices
60
+ className="editor-notices"
61
+ pinnedNoticesClassName="editor-notices__pinned"
62
+ dismissibleNoticesClassName="editor-notices__dismissible"
63
+ >
64
+ { ! isValidTemplate && <TemplateValidationNotice /> }
65
+ </InlineNotices>
66
+ );
67
+ }
58
68
 
59
69
  export default function EditorInterface( {
60
70
  className,
@@ -72,7 +82,6 @@ export default function EditorInterface( {
72
82
  mode,
73
83
  postId,
74
84
  postType,
75
- isAttachment,
76
85
  isInserterOpened,
77
86
  isListViewOpened,
78
87
  isDistractionFree,
@@ -119,9 +128,6 @@ export default function EditorInterface( {
119
128
  postTypeLabel: getPostTypeLabel(),
120
129
  stylesPath: getStylesPath(),
121
130
  showStylebook: getShowStylebook(),
122
- isAttachment:
123
- getCurrentPostType() === 'attachment' &&
124
- window?.__experimentalMediaEditor,
125
131
  isRevisionsMode: _isRevisionsMode(),
126
132
  showDiff: isShowingRevisionDiff(),
127
133
  };
@@ -136,12 +142,9 @@ export default function EditorInterface( {
136
142
  const secondarySidebarLabel = isListViewOpened
137
143
  ? __( 'Document Overview' )
138
144
  : __( 'Block Library' );
139
- const shouldShowMediaEditor = !! isAttachment;
140
145
  const shouldShowStylesCanvas =
141
- ! isAttachment &&
142
- ( showStylebook || stylesPath?.startsWith( '/revisions' ) );
143
- const shouldShowBlockEditor =
144
- ! shouldShowMediaEditor && ! shouldShowStylesCanvas;
146
+ showStylebook || stylesPath?.startsWith( '/revisions' );
147
+ const shouldShowBlockEditor = ! shouldShowStylesCanvas;
145
148
 
146
149
  // Local state for save panel.
147
150
  // Note 'truthy' callback implies an open panel.
@@ -200,7 +203,6 @@ export default function EditorInterface( {
200
203
  }
201
204
  editorNotices={ <Notices /> }
202
205
  secondarySidebar={
203
- ! isAttachment &&
204
206
  ! isPreviewMode &&
205
207
  mode === 'visual' &&
206
208
  ( ( isInserterOpened && <InserterSidebar /> ) ||
@@ -213,9 +215,6 @@ export default function EditorInterface( {
213
215
  content={
214
216
  <>
215
217
  { ! isDistractionFree && ! isPreviewMode && <Notices /> }
216
- { shouldShowMediaEditor && (
217
- <MediaPreview { ...iframeProps } />
218
- ) }
219
218
  { shouldShowStylesCanvas && <StylesCanvas /> }
220
219
  { shouldShowBlockEditor && (
221
220
  <>
@@ -9,6 +9,10 @@
9
9
  isolation: isolate;
10
10
  }
11
11
 
12
+ .editor-editor-interface .editor-notices {
13
+ padding: var(--wpds-dimension-padding-md);
14
+ }
15
+
12
16
  .editor-visual-editor {
13
17
  flex: 1 0 auto;
14
18
  }
@@ -2,6 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import deprecated from '@wordpress/deprecated';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { store as blockEditorStore } from '@wordpress/block-editor';
5
7
  import { InlineNotices } from '@wordpress/notices';
6
8
 
7
9
  /**
@@ -19,12 +21,16 @@ export function EditorNotices() {
19
21
  alternative: 'wp.notices.InlineNotices',
20
22
  } );
21
23
 
24
+ const isValidTemplate = useSelect( ( select ) => {
25
+ return select( blockEditorStore ).isValidTemplate();
26
+ }, [] );
27
+
22
28
  return (
23
29
  <InlineNotices
24
30
  pinnedNoticesClassName="components-editor-notices__pinned"
25
31
  dismissibleNoticesClassName="components-editor-notices__dismissible"
26
32
  >
27
- <TemplateValidationNotice />
33
+ { ! isValidTemplate && <TemplateValidationNotice /> }
28
34
  </InlineNotices>
29
35
  );
30
36
  }
@@ -17,7 +17,7 @@ import {
17
17
  withPreferredColorScheme,
18
18
  } from '@wordpress/compose';
19
19
  import { cautionFilled } from '@wordpress/icons';
20
- import { Icon } from '@wordpress/components';
20
+ import { Icon as WCIcon } from '@wordpress/components';
21
21
 
22
22
  /**
23
23
  * Internal dependencies
@@ -140,7 +140,7 @@ class ErrorBoundary extends Component {
140
140
  >
141
141
  <View style={ styles[ 'error-boundary__container' ] }>
142
142
  <View style={ iconContainerStyle }>
143
- <Icon
143
+ <WCIcon
144
144
  icon={ cautionFilled }
145
145
  { ...styles[ 'error-boundary__icon' ] }
146
146
  />
@@ -35,6 +35,13 @@ function useGlobalStylesUserConfig() {
35
35
 
36
36
  let record;
37
37
 
38
+ /*
39
+ * Ensure that the global styles ID request is complete by testing `_globalStylesId`,
40
+ * before firing off the `canUser` OPTIONS request for user capabilities, otherwise it will
41
+ * fetch `/wp/v2/global-styles` instead of `/wp/v2/global-styles/{id}`.
42
+ * NOTE: Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,
43
+ * or set using the `block_editor_rest_api_preload_paths` filter, if this changes.
44
+ */
38
45
  const userCanEditGlobalStyles = _globalStylesId
39
46
  ? canUser( 'update', {
40
47
  kind: 'root',
@@ -45,8 +52,21 @@ function useGlobalStylesUserConfig() {
45
52
 
46
53
  if (
47
54
  _globalStylesId &&
55
+ /*
56
+ * Test that the OPTIONS request for user capabilities is complete
57
+ * before fetching the global styles entity record.
58
+ * This is to avoid fetching the global styles entity unnecessarily.
59
+ */
48
60
  typeof userCanEditGlobalStyles === 'boolean'
49
61
  ) {
62
+ /*
63
+ * Fetch the global styles entity record based on the user's capabilities.
64
+ * The default context is `edit` for users who can edit global styles.
65
+ * Otherwise, the context is `view`.
66
+ * NOTE: There is an equivalent conditional check using `current_user_can()` in the backend
67
+ * to preload the global styles entity. Please keep in sync any preload paths sent to `block_editor_rest_api_preload()`,
68
+ * or set using `block_editor_rest_api_preload_paths` filter, if this changes.
69
+ */
50
70
  if ( userCanEditGlobalStyles ) {
51
71
  record = getEditedEntityRecord(
52
72
  'root',
@@ -110,6 +130,12 @@ function useGlobalStylesUserConfig() {
110
130
  }, [ settings, styles, _links ] );
111
131
 
112
132
  const setConfig = useCallback(
133
+ /**
134
+ * Set the global styles config.
135
+ * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
136
+ * Otherwise, overwrite the current config with the incoming object.
137
+ * @param {Object} options Options for editEntityRecord Core selector.
138
+ */
113
139
  ( callbackOrObject, options = {} ) => {
114
140
  const record = getEditedEntityRecord(
115
141
  'root',
@@ -19,15 +19,6 @@
19
19
  flex: 1;
20
20
  }
21
21
 
22
- .editor-global-styles-sidebar .components-navigation__menu-title-heading {
23
- font-size: $default-font-size * 1.2;
24
- font-weight: $font-weight-medium;
25
- }
26
-
27
- .editor-global-styles-sidebar .components-navigation__item > button span {
28
- font-weight: $font-weight-medium;
29
- }
30
-
31
22
  .editor-global-styles-sidebar .block-editor-panel-color-gradient-settings {
32
23
  border: 0;
33
24
  }
@@ -50,7 +50,6 @@ function Header( {
50
50
  hasBlockSelection,
51
51
  hasSectionRootClientId,
52
52
  isStylesCanvasActive,
53
- isAttachment,
54
53
  } = useSelect( ( select ) => {
55
54
  const { get: getPreference } = select( preferencesStore );
56
55
  const {
@@ -78,9 +77,6 @@ function Header( {
78
77
  isStylesCanvasActive:
79
78
  !! getStylesPath()?.startsWith( '/revisions' ) ||
80
79
  getShowStylebook(),
81
- isAttachment:
82
- getCurrentPostType() === ATTACHMENT_POST_TYPE &&
83
- window?.__experimentalMediaEditor,
84
80
  };
85
81
  }, [] );
86
82
 
@@ -109,13 +105,11 @@ function Header( {
109
105
  <HeaderSkeleton
110
106
  toolbar={
111
107
  <>
112
- { ! isAttachment && (
113
- <DocumentTools
114
- disableBlockTools={
115
- isStylesCanvasActive || isTextEditor
116
- }
117
- />
118
- ) }
108
+ <DocumentTools
109
+ disableBlockTools={
110
+ isStylesCanvasActive || isTextEditor
111
+ }
112
+ />
119
113
  { hasFixedToolbar && isLargeViewport && (
120
114
  <CollapsibleBlockToolbar
121
115
  isCollapsed={ isBlockToolsCollapsed }
@@ -137,6 +131,12 @@ function Header( {
137
131
  }
138
132
  settings={
139
133
  <>
134
+ { ! hasCenter && ! isTooNarrowForDocumentBar && (
135
+ <CollaboratorsPresence
136
+ postType={ postType }
137
+ postId={ postId }
138
+ />
139
+ ) }
140
140
  { ! customSaveButton && ! isPublishSidebarOpened && (
141
141
  /*
142
142
  * This button isn't completely hidden by the publish sidebar.
@@ -177,7 +177,7 @@ function Header( {
177
177
  />
178
178
  ) }
179
179
  { customSaveButton }
180
- { ! isAttachment && <MoreMenu /> }
180
+ <MoreMenu />
181
181
  </>
182
182
  }
183
183
  />
@@ -2,6 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import { useSettings } from '@wordpress/block-editor';
5
+ import { useSelect } from '@wordpress/data';
5
6
  import { useMemo } from '@wordpress/element';
6
7
  import { privateApis as mediaEditorPrivateApis } from '@wordpress/media-editor';
7
8
 
@@ -11,7 +12,9 @@ import { privateApis as mediaEditorPrivateApis } from '@wordpress/media-editor';
11
12
  import { unlock } from '../../lock-unlock';
12
13
  import usePostFields from '../post-fields';
13
14
 
14
- const { MediaEditorModal } = unlock( mediaEditorPrivateApis );
15
+ const { MediaEditorModal, store: mediaEditorStore } = unlock(
16
+ mediaEditorPrivateApis
17
+ );
15
18
 
16
19
  function ratioToNumber( ratio ) {
17
20
  if ( ratio === undefined || ratio === null ) {
@@ -48,9 +51,24 @@ function aspectRatioPresetFromSettings( { name, ratio } = {} ) {
48
51
  * into the modal, since `@wordpress/media-editor` cannot depend on
49
52
  * `@wordpress/editor`.
50
53
  *
51
- * @return {Element} The MediaEditorModal component wired with attachment fields.
54
+ * Defers the attachment fields and settings reads until the modal
55
+ * actually opens, so editor startup doesn't pay for them on every
56
+ * page load.
57
+ *
58
+ * @return {Element|null} The MediaEditorModal component wired with attachment fields, or null when closed.
52
59
  */
53
60
  export default function MediaEditorModalMount() {
61
+ const isOpen = useSelect(
62
+ ( select ) => select( mediaEditorStore ).isOpen(),
63
+ []
64
+ );
65
+ if ( ! isOpen ) {
66
+ return null;
67
+ }
68
+ return <MediaEditorModalContent />;
69
+ }
70
+
71
+ function MediaEditorModalContent() {
54
72
  const fields = usePostFields( { postType: 'attachment' } );
55
73
  const [ defaultRatios, themeRatios, showDefaultRatios ] = useSettings(
56
74
  'dimensions.aspectRatios.default',
@@ -11,7 +11,7 @@ import {
11
11
  useNetworkConnectivity,
12
12
  usePrevious,
13
13
  } from '@wordpress/compose';
14
- import { Icon } from '@wordpress/components';
14
+ import { Icon as WCIcon } from '@wordpress/components';
15
15
  import { offline as offlineIcon } from '@wordpress/icons';
16
16
  import { __ } from '@wordpress/i18n';
17
17
  import { useEffect } from '@wordpress/element';
@@ -90,7 +90,7 @@ const OfflineStatus = () => {
90
90
  ) }
91
91
  style={ containerStyle }
92
92
  >
93
- <Icon fill={ iconStyle.fill } icon={ offlineIcon } />
93
+ <WCIcon fill={ iconStyle.fill } icon={ offlineIcon } />
94
94
  <Text style={ textStyle }>{ __( 'Working Offline' ) } </Text>
95
95
  </View>
96
96
  ) : null;
@@ -2,7 +2,7 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- Icon,
5
+ Icon as WCIcon,
6
6
  Button,
7
7
  __experimentalHStack as HStack,
8
8
  __experimentalVStack as VStack,
@@ -130,7 +130,10 @@ export default function PostCardPanel( {
130
130
  className="editor-post-card-panel__header"
131
131
  alignment="flex-start"
132
132
  >
133
- <Icon className="editor-post-card-panel__icon" icon={ icon } />
133
+ <WCIcon
134
+ className="editor-post-card-panel__icon"
135
+ icon={ icon }
136
+ />
134
137
  <WCText
135
138
  numberOfLines={ 2 }
136
139
  truncate
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { sprintf, __ } from '@wordpress/i18n';
4
+ import { sprintf, __, _n } from '@wordpress/i18n';
5
5
  import { Button } from '@wordpress/components';
6
6
  import { useSelect, useDispatch } from '@wordpress/data';
7
7
  import { backup } from '@wordpress/icons';
8
+ import { addQueryArgs } from '@wordpress/url';
8
9
 
9
10
  /**
10
11
  * Internal dependencies
@@ -16,11 +17,16 @@ import { unlock } from '../../lock-unlock';
16
17
 
17
18
  function usePostLastRevisionInfo() {
18
19
  return useSelect( ( select ) => {
19
- const { getCurrentPostLastRevisionId, getCurrentPostRevisionsCount } =
20
- select( editorStore );
20
+ const {
21
+ getCurrentPostLastRevisionId,
22
+ getCurrentPostRevisionsCount,
23
+ getEditorSettings,
24
+ } = select( editorStore );
21
25
  return {
22
26
  lastRevisionId: getCurrentPostLastRevisionId(),
23
27
  revisionsCount: getCurrentPostRevisionsCount(),
28
+ disableVisualRevisions:
29
+ !! getEditorSettings().disableVisualRevisions,
24
30
  };
25
31
  }, [] );
26
32
  }
@@ -31,14 +37,23 @@ function usePostLastRevisionInfo() {
31
37
  * @return {React.ReactNode} The rendered component.
32
38
  */
33
39
  function PostLastRevision() {
34
- const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
40
+ const { lastRevisionId, revisionsCount, disableVisualRevisions } =
41
+ usePostLastRevisionInfo();
35
42
  const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
36
43
 
44
+ const buttonProps = disableVisualRevisions
45
+ ? {
46
+ href: addQueryArgs( 'revision.php', {
47
+ revision: lastRevisionId,
48
+ } ),
49
+ }
50
+ : { onClick: () => setCurrentRevisionId( lastRevisionId ) };
51
+
37
52
  return (
38
53
  <PostLastRevisionCheck>
39
54
  <Button
40
55
  __next40pxDefaultSize
41
- onClick={ () => setCurrentRevisionId( lastRevisionId ) }
56
+ { ...buttonProps }
42
57
  className="editor-post-last-revision__title"
43
58
  icon={ backup }
44
59
  iconPosition="right"
@@ -53,19 +68,32 @@ function PostLastRevision() {
53
68
  }
54
69
 
55
70
  export function PrivatePostLastRevision() {
56
- const { lastRevisionId, revisionsCount } = usePostLastRevisionInfo();
71
+ const { lastRevisionId, revisionsCount, disableVisualRevisions } =
72
+ usePostLastRevisionInfo();
57
73
  const { setCurrentRevisionId } = unlock( useDispatch( editorStore ) );
58
74
 
75
+ const buttonProps = disableVisualRevisions
76
+ ? {
77
+ href: addQueryArgs( 'revision.php', {
78
+ revision: lastRevisionId,
79
+ } ),
80
+ }
81
+ : { onClick: () => setCurrentRevisionId( lastRevisionId ) };
82
+
59
83
  return (
60
84
  <PostLastRevisionCheck>
61
85
  <PostPanelRow label={ __( 'Revisions' ) }>
62
86
  <Button
63
- onClick={ () => setCurrentRevisionId( lastRevisionId ) }
87
+ { ...buttonProps }
64
88
  className="editor-private-post-last-revision__button"
65
89
  text={ revisionsCount }
66
90
  aria-label={ sprintf(
67
- /* translators: %s: number of revisions. */
68
- __( 'Open revisions screen: %s revisions' ),
91
+ /* translators: %d: number of revisions. */
92
+ _n(
93
+ 'Open revisions screen: %d revision',
94
+ 'Open revisions screen: %d revisions',
95
+ revisionsCount
96
+ ),
69
97
  revisionsCount
70
98
  ) }
71
99
  variant="tertiary"