@wordpress/editor 14.41.2-next.v.202603161435.0 → 14.43.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 (311) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/collaborators-overlay/compute-selection.cjs +10 -10
  3. package/build/components/collaborators-overlay/compute-selection.cjs.map +2 -2
  4. package/build/components/collaborators-overlay/cursor-registry.cjs +86 -0
  5. package/build/components/collaborators-overlay/cursor-registry.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/index.cjs +7 -2
  7. package/build/components/collaborators-overlay/index.cjs.map +2 -2
  8. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +1 -1
  9. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/overlay.cjs +42 -1
  11. package/build/components/collaborators-overlay/overlay.cjs.map +2 -2
  12. package/build/components/collaborators-overlay/timing-utils.cjs +46 -0
  13. package/build/components/collaborators-overlay/timing-utils.cjs.map +7 -0
  14. package/build/components/collaborators-overlay/use-render-cursors.cjs +1 -1
  15. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +2 -2
  16. package/build/components/collaborators-presence/index.cjs +14 -4
  17. package/build/components/collaborators-presence/index.cjs.map +2 -2
  18. package/build/components/collaborators-presence/list.cjs +20 -4
  19. package/build/components/collaborators-presence/list.cjs.map +2 -2
  20. package/build/components/post-card-panel/index.cjs +4 -15
  21. package/build/components/post-card-panel/index.cjs.map +2 -2
  22. package/build/components/post-content-information/index.cjs +10 -13
  23. package/build/components/post-content-information/index.cjs.map +2 -2
  24. package/build/components/post-locked-modal/index.cjs +16 -3
  25. package/build/components/post-locked-modal/index.cjs.map +2 -2
  26. package/build/components/post-revisions-panel/index.cjs +164 -0
  27. package/build/components/post-revisions-panel/index.cjs.map +7 -0
  28. package/build/components/post-revisions-preview/block-diff.cjs +39 -11
  29. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  30. package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
  31. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  32. package/build/components/post-revisions-preview/revisions-canvas.cjs +1 -1
  33. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +2 -2
  34. package/build/components/post-revisions-preview/revisions-slider.cjs +24 -5
  35. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  36. package/build/components/post-template/block-theme.cjs +7 -4
  37. package/build/components/post-template/block-theme.cjs.map +2 -2
  38. package/build/components/post-template/create-new-template-modal.cjs +39 -46
  39. package/build/components/post-template/create-new-template-modal.cjs.map +2 -2
  40. package/build/components/post-template/hooks.cjs +91 -8
  41. package/build/components/post-template/hooks.cjs.map +2 -2
  42. package/build/components/post-template/panel.cjs +5 -42
  43. package/build/components/post-template/panel.cjs.map +3 -3
  44. package/build/components/post-template/swap-template-button.cjs +31 -20
  45. package/build/components/post-template/swap-template-button.cjs.map +2 -2
  46. package/build/components/preferences-modal/index.cjs +35 -27
  47. package/build/components/preferences-modal/index.cjs.map +2 -2
  48. package/build/components/provider/use-block-editor-settings.cjs +2 -0
  49. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  50. package/build/components/revision-block-diff/index.cjs +61 -0
  51. package/build/components/revision-block-diff/index.cjs.map +7 -0
  52. package/build/components/revision-diff-panel/index.cjs +68 -0
  53. package/build/components/revision-diff-panel/index.cjs.map +7 -0
  54. package/build/components/revision-fields-diff/index.cjs +96 -0
  55. package/build/components/revision-fields-diff/index.cjs.map +7 -0
  56. package/build/components/sidebar/dataform-post-summary.cjs +25 -55
  57. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  58. package/build/components/sidebar/index.cjs +30 -23
  59. package/build/components/sidebar/index.cjs.map +3 -3
  60. package/build/components/sidebar/post-revision-summary.cjs +74 -0
  61. package/build/components/sidebar/post-revision-summary.cjs.map +7 -0
  62. package/build/components/sidebar/post-summary.cjs +35 -42
  63. package/build/components/sidebar/post-summary.cjs.map +3 -3
  64. package/build/components/style-book/index.cjs +4 -3
  65. package/build/components/style-book/index.cjs.map +2 -2
  66. package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +89 -80
  67. package/build/components/sync-connection-error-modal/index.cjs.map +7 -0
  68. package/build/components/{sync-connection-modal → sync-connection-error-modal}/use-retry-countdown.cjs +14 -27
  69. package/build/components/sync-connection-error-modal/use-retry-countdown.cjs.map +7 -0
  70. package/build/components/template-actions-panel/block-theme-content.cjs +188 -0
  71. package/build/components/template-actions-panel/block-theme-content.cjs.map +7 -0
  72. package/build/components/template-actions-panel/classic-theme-content.cjs +159 -0
  73. package/build/components/template-actions-panel/classic-theme-content.cjs.map +7 -0
  74. package/build/components/template-actions-panel/index.cjs +59 -0
  75. package/build/components/template-actions-panel/index.cjs.map +7 -0
  76. package/build/components/visual-editor/index.cjs +2 -2
  77. package/build/components/visual-editor/index.cjs.map +2 -2
  78. package/build/dataviews/store/private-actions.cjs +2 -0
  79. package/build/dataviews/store/private-actions.cjs.map +2 -2
  80. package/build/store/actions.cjs +1 -3
  81. package/build/store/actions.cjs.map +2 -2
  82. package/build/store/private-actions.cjs +21 -2
  83. package/build/store/private-actions.cjs.map +2 -2
  84. package/build/store/private-selectors.cjs +40 -15
  85. package/build/store/private-selectors.cjs.map +2 -2
  86. package/build/utils/media-finalize/index.cjs +43 -0
  87. package/build/utils/media-finalize/index.cjs.map +7 -0
  88. package/build/utils/sync-error-messages.cjs +29 -16
  89. package/build/utils/sync-error-messages.cjs.map +3 -3
  90. package/build-module/components/collaborators-overlay/compute-selection.mjs +10 -10
  91. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +2 -2
  92. package/build-module/components/collaborators-overlay/cursor-registry.mjs +61 -0
  93. package/build-module/components/collaborators-overlay/cursor-registry.mjs.map +7 -0
  94. package/build-module/components/collaborators-overlay/index.mjs +7 -2
  95. package/build-module/components/collaborators-overlay/index.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +1 -1
  97. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  98. package/build-module/components/collaborators-overlay/overlay.mjs +43 -2
  99. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  101. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  102. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +1 -1
  103. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  104. package/build-module/components/collaborators-presence/index.mjs +14 -4
  105. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  106. package/build-module/components/collaborators-presence/list.mjs +20 -4
  107. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  108. package/build-module/components/post-card-panel/index.mjs +6 -17
  109. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  110. package/build-module/components/post-content-information/index.mjs +6 -13
  111. package/build-module/components/post-content-information/index.mjs.map +2 -2
  112. package/build-module/components/post-locked-modal/index.mjs +16 -3
  113. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  114. package/build-module/components/post-revisions-panel/index.mjs +139 -0
  115. package/build-module/components/post-revisions-panel/index.mjs.map +7 -0
  116. package/build-module/components/post-revisions-preview/block-diff.mjs +39 -11
  117. package/build-module/components/post-revisions-preview/block-diff.mjs.map +2 -2
  118. package/build-module/components/post-revisions-preview/diff-markers.mjs +2 -2
  119. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  120. package/build-module/components/post-revisions-preview/revisions-canvas.mjs +1 -1
  121. package/build-module/components/post-revisions-preview/revisions-canvas.mjs.map +2 -2
  122. package/build-module/components/post-revisions-preview/revisions-slider.mjs +24 -5
  123. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  124. package/build-module/components/post-template/block-theme.mjs +7 -4
  125. package/build-module/components/post-template/block-theme.mjs.map +2 -2
  126. package/build-module/components/post-template/create-new-template-modal.mjs +39 -46
  127. package/build-module/components/post-template/create-new-template-modal.mjs.map +2 -2
  128. package/build-module/components/post-template/hooks.mjs +90 -8
  129. package/build-module/components/post-template/hooks.mjs.map +2 -2
  130. package/build-module/components/post-template/panel.mjs +5 -42
  131. package/build-module/components/post-template/panel.mjs.map +2 -2
  132. package/build-module/components/post-template/swap-template-button.mjs +27 -20
  133. package/build-module/components/post-template/swap-template-button.mjs.map +2 -2
  134. package/build-module/components/preferences-modal/index.mjs +35 -27
  135. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  136. package/build-module/components/provider/use-block-editor-settings.mjs +2 -0
  137. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  138. package/build-module/components/revision-block-diff/index.mjs +30 -0
  139. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  140. package/build-module/components/revision-diff-panel/index.mjs +37 -0
  141. package/build-module/components/revision-diff-panel/index.mjs.map +7 -0
  142. package/build-module/components/revision-fields-diff/index.mjs +65 -0
  143. package/build-module/components/revision-fields-diff/index.mjs.map +7 -0
  144. package/build-module/components/sidebar/dataform-post-summary.mjs +25 -55
  145. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  146. package/build-module/components/sidebar/index.mjs +30 -23
  147. package/build-module/components/sidebar/index.mjs.map +2 -2
  148. package/build-module/components/sidebar/post-revision-summary.mjs +43 -0
  149. package/build-module/components/sidebar/post-revision-summary.mjs.map +7 -0
  150. package/build-module/components/sidebar/post-summary.mjs +31 -42
  151. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  152. package/build-module/components/style-book/index.mjs +4 -3
  153. package/build-module/components/style-book/index.mjs.map +2 -2
  154. package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
  155. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  156. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
  157. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  158. package/build-module/components/template-actions-panel/block-theme-content.mjs +167 -0
  159. package/build-module/components/template-actions-panel/block-theme-content.mjs.map +7 -0
  160. package/build-module/components/template-actions-panel/classic-theme-content.mjs +138 -0
  161. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +7 -0
  162. package/build-module/components/template-actions-panel/index.mjs +28 -0
  163. package/build-module/components/template-actions-panel/index.mjs.map +7 -0
  164. package/build-module/components/visual-editor/index.mjs +2 -2
  165. package/build-module/components/visual-editor/index.mjs.map +2 -2
  166. package/build-module/dataviews/store/private-actions.mjs +5 -1
  167. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  168. package/build-module/store/actions.mjs +1 -3
  169. package/build-module/store/actions.mjs.map +2 -2
  170. package/build-module/store/private-actions.mjs +21 -2
  171. package/build-module/store/private-actions.mjs.map +2 -2
  172. package/build-module/store/private-selectors.mjs +40 -15
  173. package/build-module/store/private-selectors.mjs.map +2 -2
  174. package/build-module/utils/media-finalize/index.mjs +12 -0
  175. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  176. package/build-module/utils/sync-error-messages.mjs +24 -16
  177. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  178. package/build-style/style-rtl.css +135 -50
  179. package/build-style/style.css +135 -50
  180. package/build-types/components/collaborators-overlay/cursor-registry.d.ts +36 -0
  181. package/build-types/components/collaborators-overlay/cursor-registry.d.ts.map +1 -0
  182. package/build-types/components/collaborators-overlay/index.d.ts +7 -4
  183. package/build-types/components/collaborators-overlay/index.d.ts.map +1 -1
  184. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  185. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  186. package/build-types/components/collaborators-overlay/overlay.d.ts +4 -1
  187. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  188. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  189. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  190. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  191. package/build-types/components/collaborators-presence/list.d.ts +4 -1
  192. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  193. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  194. package/build-types/components/post-content-information/index.d.ts +4 -1
  195. package/build-types/components/post-content-information/index.d.ts.map +1 -1
  196. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  197. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  198. package/build-types/components/post-revisions-panel/index.d.ts +2 -0
  199. package/build-types/components/post-revisions-panel/index.d.ts.map +1 -0
  200. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  201. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  202. package/build-types/components/post-template/block-theme.d.ts +1 -3
  203. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  204. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  205. package/build-types/components/post-template/hooks.d.ts +2 -1
  206. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  207. package/build-types/components/post-template/panel.d.ts.map +1 -1
  208. package/build-types/components/post-template/swap-template-button.d.ts +4 -0
  209. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  210. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  211. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  212. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  213. package/build-types/components/revision-diff-panel/index.d.ts +14 -0
  214. package/build-types/components/revision-diff-panel/index.d.ts.map +1 -0
  215. package/build-types/components/revision-fields-diff/index.d.ts +6 -0
  216. package/build-types/components/revision-fields-diff/index.d.ts.map +1 -0
  217. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  218. package/build-types/components/sidebar/index.d.ts.map +1 -1
  219. package/build-types/components/sidebar/post-revision-summary.d.ts +2 -0
  220. package/build-types/components/sidebar/post-revision-summary.d.ts.map +1 -0
  221. package/build-types/components/sidebar/post-summary.d.ts +3 -0
  222. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  223. package/build-types/components/style-book/index.d.ts +2 -1
  224. package/build-types/components/style-book/index.d.ts.map +1 -1
  225. package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
  226. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  227. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  228. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  229. package/build-types/components/template-actions-panel/block-theme-content.d.ts +2 -0
  230. package/build-types/components/template-actions-panel/block-theme-content.d.ts.map +1 -0
  231. package/build-types/components/template-actions-panel/classic-theme-content.d.ts +2 -0
  232. package/build-types/components/template-actions-panel/classic-theme-content.d.ts.map +1 -0
  233. package/build-types/components/template-actions-panel/index.d.ts +2 -0
  234. package/build-types/components/template-actions-panel/index.d.ts.map +1 -0
  235. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  236. package/build-types/store/actions.d.ts.map +1 -1
  237. package/build-types/store/private-actions.d.ts.map +1 -1
  238. package/build-types/store/private-selectors.d.ts.map +1 -1
  239. package/build-types/utils/media-finalize/index.d.ts +2 -0
  240. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  241. package/build-types/utils/sync-error-messages.d.ts +17 -3
  242. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  243. package/package.json +45 -44
  244. package/src/components/collaborators-overlay/compute-selection.ts +13 -13
  245. package/src/components/collaborators-overlay/cursor-registry.ts +96 -0
  246. package/src/components/collaborators-overlay/index.tsx +12 -4
  247. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +1 -1
  248. package/src/components/collaborators-overlay/overlay.tsx +64 -1
  249. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  250. package/src/components/collaborators-overlay/use-render-cursors.ts +1 -1
  251. package/src/components/collaborators-presence/index.tsx +9 -1
  252. package/src/components/collaborators-presence/list.tsx +25 -1
  253. package/src/components/post-card-panel/index.js +7 -21
  254. package/src/components/post-content-information/index.js +5 -16
  255. package/src/components/post-locked-modal/index.js +21 -3
  256. package/src/components/post-revisions-panel/index.js +151 -0
  257. package/src/components/post-revisions-panel/style.scss +16 -0
  258. package/src/components/post-revisions-preview/block-diff.js +59 -20
  259. package/src/components/post-revisions-preview/diff-markers.js +2 -2
  260. package/src/components/post-revisions-preview/revisions-canvas.js +1 -1
  261. package/src/components/post-revisions-preview/revisions-slider.js +29 -7
  262. package/src/components/post-revisions-preview/test/block-diff.js +69 -31
  263. package/src/components/post-template/block-theme.js +4 -1
  264. package/src/components/post-template/create-new-template-modal.js +1 -4
  265. package/src/components/post-template/hooks.js +107 -9
  266. package/src/components/post-template/panel.js +5 -59
  267. package/src/components/post-template/style.scss +0 -6
  268. package/src/components/post-template/swap-template-button.js +30 -21
  269. package/src/components/preferences-modal/index.js +37 -25
  270. package/src/components/provider/use-block-editor-settings.js +2 -0
  271. package/src/components/revision-block-diff/index.js +39 -0
  272. package/src/components/revision-diff-panel/index.js +59 -0
  273. package/src/components/revision-diff-panel/style.scss +13 -0
  274. package/src/components/revision-fields-diff/index.js +91 -0
  275. package/src/components/sidebar/dataform-post-summary.js +45 -68
  276. package/src/components/sidebar/index.js +35 -22
  277. package/src/components/sidebar/post-revision-summary.js +50 -0
  278. package/src/components/sidebar/post-summary.js +22 -40
  279. package/src/components/sidebar/style.scss +7 -0
  280. package/src/components/style-book/index.js +4 -2
  281. package/src/components/sync-connection-error-modal/index.tsx +265 -0
  282. package/src/components/sync-connection-error-modal/style.scss +14 -0
  283. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
  284. package/src/components/template-actions-panel/block-theme-content.js +196 -0
  285. package/src/components/template-actions-panel/classic-theme-content.js +170 -0
  286. package/src/components/template-actions-panel/index.js +32 -0
  287. package/src/components/template-actions-panel/style.scss +39 -0
  288. package/src/components/visual-editor/index.js +2 -2
  289. package/src/dataviews/store/private-actions.ts +6 -0
  290. package/src/store/actions.js +1 -4
  291. package/src/store/private-actions.js +24 -3
  292. package/src/store/private-selectors.js +46 -16
  293. package/src/style.scss +4 -1
  294. package/src/utils/media-finalize/index.js +11 -0
  295. package/src/utils/media-finalize/test/index.js +34 -0
  296. package/src/utils/sync-error-messages.ts +72 -0
  297. package/src/utils/test/sync-error-messages.js +9 -32
  298. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  299. package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
  300. package/build-module/components/sync-connection-modal/index.mjs +0 -170
  301. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  302. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
  303. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
  304. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  305. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  306. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
  307. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
  308. package/src/components/sync-connection-modal/index.js +0 -206
  309. package/src/components/sync-connection-modal/style.scss +0 -14
  310. package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
  311. package/src/utils/sync-error-messages.js +0 -58
@@ -1,206 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect, select } from '@wordpress/data';
5
- import { useCopyToClipboard } from '@wordpress/compose';
6
- import { serialize } from '@wordpress/blocks';
7
- import {
8
- store as coreDataStore,
9
- privateApis as coreDataPrivateApis,
10
- } from '@wordpress/core-data';
11
- import {
12
- privateApis,
13
- store as blockEditorStore,
14
- } from '@wordpress/block-editor';
15
- import {
16
- Button,
17
- Modal,
18
- __experimentalHStack as HStack,
19
- __experimentalVStack as VStack,
20
- } from '@wordpress/components';
21
- import { useState, useEffect, useRef } from '@wordpress/element';
22
- import { __, sprintf, _n } from '@wordpress/i18n';
23
-
24
- /**
25
- * Internal dependencies
26
- */
27
- import { getSyncErrorMessages } from '../../utils/sync-error-messages';
28
- import { store as editorStore } from '../../store';
29
- import { unlock } from '../../lock-unlock';
30
- import { useRetryCountdown } from './use-retry-countdown';
31
-
32
- const { BlockCanvasCover } = unlock( privateApis );
33
- const { retrySyncConnection } = unlock( coreDataPrivateApis );
34
-
35
- // Debounce time for initial disconnected status to allow connection to establish.
36
- const INITIAL_DISCONNECTED_DEBOUNCE_MS = 5000;
37
-
38
- // Debounce time for showing the disconnect dialog after the intial connection,
39
- // allowing brief network interruptions to resolve.
40
- const DISCONNECTED_DEBOUNCE_MS = 2000;
41
-
42
- /**
43
- * Sync connection modal that displays when any entity reports a disconnection.
44
- * Uses BlockCanvasCover.Fill to render in the block canvas.
45
- *
46
- * @return {Element|null} The modal component or null if not disconnected.
47
- */
48
- export function SyncConnectionModal() {
49
- const { connectionState, postType } = useSelect( ( selectFn ) => {
50
- const currentPostType = selectFn( editorStore ).getCurrentPostType();
51
- return {
52
- connectionState:
53
- selectFn( coreDataStore ).getSyncConnectionStatus() || null,
54
- postType: currentPostType
55
- ? selectFn( coreDataStore ).getPostType( currentPostType )
56
- : null,
57
- };
58
- }, [] );
59
-
60
- const { secondsRemaining, markRetrying } = useRetryCountdown(
61
- connectionState?.retryInMs,
62
- connectionState?.status
63
- );
64
-
65
- const copyButtonRef = useCopyToClipboard( () => {
66
- const blocks = select( blockEditorStore ).getBlocks();
67
- return serialize( blocks );
68
- } );
69
- const [ syncConnectionMessage, setSyncConnectionMessage ] =
70
- useState( null );
71
- const debounceTimerRef = useRef( null );
72
- // Track whether we've passed the initial load phase.
73
- const hasInitializedRef = useRef( false );
74
-
75
- const connectionStatus = connectionState?.status;
76
- const connectionErrorCode = connectionState?.error?.code;
77
-
78
- useEffect( () => {
79
- // Clear any pending debounce timer when status changes.
80
- if ( debounceTimerRef.current ) {
81
- clearTimeout( debounceTimerRef.current );
82
- debounceTimerRef.current = null;
83
- }
84
-
85
- if ( connectionStatus === 'connected' ) {
86
- hasInitializedRef.current = true;
87
- setSyncConnectionMessage( null );
88
- } else if ( connectionStatus === 'disconnected' ) {
89
- const showModal = () => {
90
- hasInitializedRef.current = true;
91
- setSyncConnectionMessage(
92
- getSyncErrorMessages( { code: connectionErrorCode } )
93
- );
94
- };
95
-
96
- // Debounce on first load and after connection is established to allow
97
- // brief network interruptions to resolve.
98
- if ( hasInitializedRef.current ) {
99
- debounceTimerRef.current = setTimeout(
100
- showModal,
101
- DISCONNECTED_DEBOUNCE_MS
102
- );
103
- } else {
104
- debounceTimerRef.current = setTimeout(
105
- showModal,
106
- INITIAL_DISCONNECTED_DEBOUNCE_MS
107
- );
108
- }
109
- }
110
-
111
- return () => {
112
- if ( debounceTimerRef.current ) {
113
- clearTimeout( debounceTimerRef.current );
114
- }
115
- };
116
- }, [ connectionStatus, connectionErrorCode ] );
117
-
118
- if ( ! syncConnectionMessage ) {
119
- return null;
120
- }
121
-
122
- const { title, description, canRetry } = syncConnectionMessage;
123
-
124
- let retryCountdownText;
125
- if ( secondsRemaining > 0 ) {
126
- retryCountdownText = sprintf(
127
- /* translators: %d: number of seconds until retry */
128
- _n(
129
- 'Retrying connection in %d second\u2026',
130
- 'Retrying connection in %d seconds\u2026',
131
- secondsRemaining
132
- ),
133
- secondsRemaining
134
- );
135
- } else if ( secondsRemaining === 0 ) {
136
- retryCountdownText = __( 'Retrying\u2026' );
137
- }
138
-
139
- let editPostHref = 'edit.php';
140
- if ( postType?.slug ) {
141
- editPostHref = `edit.php?post_type=${ postType.slug }`;
142
- }
143
-
144
- const isRetrying = secondsRemaining === 0;
145
-
146
- return (
147
- <BlockCanvasCover.Fill>
148
- <Modal
149
- overlayClassName="editor-sync-connection-modal"
150
- isDismissible={ false }
151
- onRequestClose={ () => {} }
152
- shouldCloseOnClickOutside={ false }
153
- shouldCloseOnEsc={ false }
154
- size="medium"
155
- title={ title }
156
- >
157
- <VStack spacing={ 6 }>
158
- <p>{ description }</p>
159
- { retryCountdownText && (
160
- <p className="editor-sync-connection-modal__retry-countdown">
161
- { retryCountdownText }
162
- </p>
163
- ) }
164
- <HStack justify="right">
165
- <Button
166
- __next40pxDefaultSize
167
- href={ editPostHref }
168
- isDestructive
169
- variant="tertiary"
170
- >
171
- { sprintf(
172
- /* translators: %s: Post type name (e.g., "Posts", "Pages"). */
173
- __( 'Back to %s' ),
174
- postType?.labels?.name ?? __( 'Posts' )
175
- ) }
176
- </Button>
177
- <Button
178
- __next40pxDefaultSize
179
- ref={ copyButtonRef }
180
- variant={ canRetry ? 'secondary' : 'primary' }
181
- >
182
- { __( 'Copy Post Content' ) }
183
- </Button>
184
- { canRetry && (
185
- <Button
186
- __next40pxDefaultSize
187
- aria-disabled={ isRetrying }
188
- isBusy={ isRetrying }
189
- variant="primary"
190
- onClick={ () => {
191
- if ( isRetrying ) {
192
- return;
193
- }
194
- markRetrying();
195
- retrySyncConnection();
196
- } }
197
- >
198
- { __( 'Retry' ) }
199
- </Button>
200
- ) }
201
- </HStack>
202
- </VStack>
203
- </Modal>
204
- </BlockCanvasCover.Fill>
205
- );
206
- }
@@ -1,14 +0,0 @@
1
- @use "@wordpress/base-styles/colors" as *;
2
- @use "@wordpress/base-styles/z-index" as *;
3
-
4
- .editor-sync-connection-modal {
5
- z-index: z-index(".editor-sync-connection-modal");
6
- }
7
-
8
- .editor-sync-connection-modal p {
9
- margin: 0;
10
- }
11
-
12
- .editor-sync-connection-modal__retry-countdown {
13
- color: $gray-700;
14
- }
@@ -1,70 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useState, useEffect, useRef } from '@wordpress/element';
5
-
6
- const MIN_RETRYING_DISPLAY_MS = 600;
7
-
8
- /**
9
- * Hook that computes a countdown in seconds from a retryInMs value.
10
- *
11
- * @param {number|undefined} retryInMs Milliseconds until next retry.
12
- * @param {string|undefined} status Current connection status.
13
- * @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.
14
- */
15
- export function useRetryCountdown( retryInMs, status ) {
16
- const [ secondsRemaining, setSecondsRemaining ] = useState( null );
17
- const [ isRetrying, setIsRetrying ] = useState( false );
18
- const retryAtRef = useRef( null );
19
-
20
- // Show "Retrying…" for a minimum duration when manually triggered.
21
- const markRetrying = () => setIsRetrying( true );
22
-
23
- useEffect( () => {
24
- if ( ! isRetrying ) {
25
- return;
26
- }
27
- const id = setTimeout(
28
- () => setIsRetrying( false ),
29
- MIN_RETRYING_DISPLAY_MS
30
- );
31
- return () => clearTimeout( id );
32
- }, [ isRetrying ] );
33
-
34
- useEffect( () => {
35
- // Only clear countdown when explicitly connected.
36
- if ( status === 'connected' ) {
37
- setSecondsRemaining( null );
38
- retryAtRef.current = null;
39
- return;
40
- }
41
-
42
- // For transient states (e.g. 'connecting' during a retry attempt)
43
- // or when retryInMs is not yet available, keep the previous
44
- // countdown value to avoid a brief flash.
45
- if ( status !== 'disconnected' || ! retryInMs ) {
46
- return;
47
- }
48
-
49
- const retryAt = Date.now() + retryInMs;
50
- retryAtRef.current = retryAt;
51
- setSecondsRemaining( Math.ceil( retryInMs / 1000 ) );
52
-
53
- const intervalId = setInterval( () => {
54
- const remaining = Math.ceil(
55
- ( retryAtRef.current - Date.now() ) / 1000
56
- );
57
- setSecondsRemaining( Math.max( 0, remaining ) );
58
- if ( remaining <= 0 ) {
59
- clearInterval( intervalId );
60
- setIsRetrying( true );
61
- }
62
- }, 1000 );
63
-
64
- return () => clearInterval( intervalId );
65
- }, [ retryInMs, status ] );
66
-
67
- const displaySeconds = isRetrying ? 0 : secondsRemaining;
68
-
69
- return { secondsRemaining: displaySeconds, markRetrying };
70
- }
@@ -1,58 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __ } from '@wordpress/i18n';
5
-
6
- /**
7
- * Default error messages for known error codes.
8
- */
9
- const ERROR_MESSAGES = {
10
- 'authentication-failed': {
11
- title: __( 'Unable to connect' ),
12
- description: __(
13
- "Real-time collaboration couldn't verify your permissions. " +
14
- 'Check that you have access to edit this post, or contact your site administrator.'
15
- ),
16
- canRetry: false,
17
- },
18
- 'connection-expired': {
19
- title: __( 'Connection expired' ),
20
- description: __(
21
- 'Your connection to real-time collaboration has timed out. ' +
22
- 'Editing is paused to prevent conflicts with other editors.'
23
- ),
24
- canRetry: true,
25
- },
26
- 'connection-limit-exceeded': {
27
- title: __( 'Too many editors connected' ),
28
- description: __(
29
- 'Real-time collaboration has reached its connection limit. ' +
30
- 'Try again later or contact your site administrator.'
31
- ),
32
- canRetry: true,
33
- },
34
- 'unknown-error': {
35
- title: __( 'Connection lost' ),
36
- description: __(
37
- 'The connection to real-time collaboration was interrupted. ' +
38
- 'Editing is paused to prevent conflicts with other editors.'
39
- ),
40
- canRetry: true,
41
- },
42
- };
43
-
44
- /**
45
- * Get user-facing title and description from a sync connection error.
46
- *
47
- * Provides default messages based on error.code.
48
- *
49
- * @param {Object} error - Connection error object.
50
- * @return {Object} Object with title, description, and canRetry flag.
51
- */
52
- export function getSyncErrorMessages( error ) {
53
- if ( ERROR_MESSAGES[ error?.code ] ) {
54
- return ERROR_MESSAGES[ error.code ];
55
- }
56
-
57
- return ERROR_MESSAGES[ 'unknown-error' ];
58
- }