@wordpress/editor 14.41.1-next.v.202603102151.0 → 14.42.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 (301) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs +12 -4
  3. package/build/components/collaborators-overlay/avatar-iframe-styles.cjs.map +2 -2
  4. package/build/components/collaborators-overlay/compute-selection.cjs +181 -0
  5. package/build/components/collaborators-overlay/compute-selection.cjs.map +7 -0
  6. package/build/components/collaborators-overlay/cursor-dom-utils.cjs +243 -0
  7. package/build/components/collaborators-overlay/cursor-dom-utils.cjs.map +7 -0
  8. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs +6 -0
  9. package/build/components/collaborators-overlay/overlay-iframe-styles.cjs.map +2 -2
  10. package/build/components/collaborators-overlay/overlay.cjs +61 -37
  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-block-highlighting.cjs +5 -6
  15. package/build/components/collaborators-overlay/use-block-highlighting.cjs.map +2 -2
  16. package/build/components/collaborators-overlay/use-render-cursors.cjs +50 -140
  17. package/build/components/collaborators-overlay/use-render-cursors.cjs.map +3 -3
  18. package/build/components/collaborators-presence/index.cjs +38 -12
  19. package/build/components/collaborators-presence/index.cjs.map +2 -2
  20. package/build/components/collaborators-presence/list.cjs +27 -24
  21. package/build/components/collaborators-presence/list.cjs.map +2 -2
  22. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +79 -107
  23. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +3 -3
  24. package/build/components/editor-interface/index.cjs +9 -6
  25. package/build/components/editor-interface/index.cjs.map +2 -2
  26. package/build/components/inserter-sidebar/index.cjs +2 -1
  27. package/build/components/inserter-sidebar/index.cjs.map +2 -2
  28. package/build/components/page-attributes/parent.cjs +1 -1
  29. package/build/components/page-attributes/parent.cjs.map +2 -2
  30. package/build/components/post-locked-modal/index.cjs +16 -3
  31. package/build/components/post-locked-modal/index.cjs.map +2 -2
  32. package/build/components/post-revisions-preview/block-diff.cjs +39 -11
  33. package/build/components/post-revisions-preview/block-diff.cjs.map +2 -2
  34. package/build/components/post-revisions-preview/diff-markers.cjs +2 -2
  35. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  36. package/build/components/post-revisions-preview/revisions-canvas.cjs +12 -75
  37. package/build/components/post-revisions-preview/revisions-canvas.cjs.map +3 -3
  38. package/build/components/post-revisions-preview/revisions-slider.cjs +5 -1
  39. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  40. package/build/components/post-template/block-theme.cjs +7 -4
  41. package/build/components/post-template/block-theme.cjs.map +2 -2
  42. package/build/components/post-template/hooks.cjs +39 -2
  43. package/build/components/post-template/hooks.cjs.map +2 -2
  44. package/build/components/post-template/panel.cjs +5 -42
  45. package/build/components/post-template/panel.cjs.map +3 -3
  46. package/build/components/preferences-modal/index.cjs +24 -0
  47. package/build/components/preferences-modal/index.cjs.map +2 -2
  48. package/build/components/provider/disable-non-page-content-blocks.cjs +31 -28
  49. package/build/components/provider/disable-non-page-content-blocks.cjs.map +3 -3
  50. package/build/components/provider/index.cjs +17 -5
  51. package/build/components/provider/index.cjs.map +2 -2
  52. package/build/components/provider/use-block-editor-settings.cjs +19 -5
  53. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  54. package/build/components/provider/{use-post-content-blocks.cjs → use-post-content-block-types.cjs} +8 -19
  55. package/build/components/provider/use-post-content-block-types.cjs.map +7 -0
  56. package/build/components/provider/use-revision-blocks.cjs +106 -0
  57. package/build/components/provider/use-revision-blocks.cjs.map +7 -0
  58. package/build/components/revision-block-diff/index.cjs +84 -0
  59. package/build/components/revision-block-diff/index.cjs.map +7 -0
  60. package/build/components/sidebar/dataform-post-summary.cjs +36 -6
  61. package/build/components/sidebar/dataform-post-summary.cjs.map +2 -2
  62. package/build/components/sidebar/header.cjs +1 -1
  63. package/build/components/sidebar/header.cjs.map +2 -2
  64. package/build/components/sidebar/index.cjs +5 -1
  65. package/build/components/sidebar/index.cjs.map +3 -3
  66. package/build/components/{sync-connection-modal → sync-connection-error-modal}/index.cjs +90 -78
  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-content-panel/index.cjs +35 -31
  71. package/build/components/template-content-panel/index.cjs.map +3 -3
  72. package/build/components/visual-editor/index.cjs +2 -2
  73. package/build/components/visual-editor/index.cjs.map +2 -2
  74. package/build/store/actions.cjs +1 -3
  75. package/build/store/actions.cjs.map +2 -2
  76. package/build/store/private-actions.cjs +11 -2
  77. package/build/store/private-actions.cjs.map +2 -2
  78. package/build/store/private-selectors.cjs +52 -13
  79. package/build/store/private-selectors.cjs.map +2 -2
  80. package/build/store/reducer.cjs +12 -0
  81. package/build/store/reducer.cjs.map +2 -2
  82. package/build/utils/media-finalize/index.cjs +43 -0
  83. package/build/utils/media-finalize/index.cjs.map +7 -0
  84. package/build/utils/sync-error-messages.cjs +29 -16
  85. package/build/utils/sync-error-messages.cjs.map +3 -3
  86. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs +12 -4
  87. package/build-module/components/collaborators-overlay/avatar-iframe-styles.mjs.map +2 -2
  88. package/build-module/components/collaborators-overlay/compute-selection.mjs +162 -0
  89. package/build-module/components/collaborators-overlay/compute-selection.mjs.map +7 -0
  90. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs +213 -0
  91. package/build-module/components/collaborators-overlay/cursor-dom-utils.mjs.map +7 -0
  92. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs +6 -0
  93. package/build-module/components/collaborators-overlay/overlay-iframe-styles.mjs.map +2 -2
  94. package/build-module/components/collaborators-overlay/overlay.mjs +61 -37
  95. package/build-module/components/collaborators-overlay/overlay.mjs.map +2 -2
  96. package/build-module/components/collaborators-overlay/timing-utils.mjs +21 -0
  97. package/build-module/components/collaborators-overlay/timing-utils.mjs.map +7 -0
  98. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs +5 -6
  99. package/build-module/components/collaborators-overlay/use-block-highlighting.mjs.map +2 -2
  100. package/build-module/components/collaborators-overlay/use-render-cursors.mjs +50 -140
  101. package/build-module/components/collaborators-overlay/use-render-cursors.mjs.map +2 -2
  102. package/build-module/components/collaborators-presence/index.mjs +39 -13
  103. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  104. package/build-module/components/collaborators-presence/list.mjs +27 -24
  105. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  106. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +80 -108
  107. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  108. package/build-module/components/editor-interface/index.mjs +10 -7
  109. package/build-module/components/editor-interface/index.mjs.map +2 -2
  110. package/build-module/components/inserter-sidebar/index.mjs +2 -1
  111. package/build-module/components/inserter-sidebar/index.mjs.map +2 -2
  112. package/build-module/components/page-attributes/parent.mjs +1 -1
  113. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  114. package/build-module/components/post-locked-modal/index.mjs +16 -3
  115. package/build-module/components/post-locked-modal/index.mjs.map +2 -2
  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 +14 -80
  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 +5 -1
  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/hooks.mjs +37 -1
  127. package/build-module/components/post-template/hooks.mjs.map +2 -2
  128. package/build-module/components/post-template/panel.mjs +5 -42
  129. package/build-module/components/post-template/panel.mjs.map +2 -2
  130. package/build-module/components/preferences-modal/index.mjs +24 -0
  131. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  132. package/build-module/components/provider/disable-non-page-content-blocks.mjs +31 -28
  133. package/build-module/components/provider/disable-non-page-content-blocks.mjs.map +2 -2
  134. package/build-module/components/provider/index.mjs +17 -5
  135. package/build-module/components/provider/index.mjs.map +2 -2
  136. package/build-module/components/provider/use-block-editor-settings.mjs +19 -5
  137. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  138. package/build-module/components/provider/use-post-content-block-types.mjs +23 -0
  139. package/build-module/components/provider/use-post-content-block-types.mjs.map +7 -0
  140. package/build-module/components/provider/use-revision-blocks.mjs +81 -0
  141. package/build-module/components/provider/use-revision-blocks.mjs.map +7 -0
  142. package/build-module/components/revision-block-diff/index.mjs +53 -0
  143. package/build-module/components/revision-block-diff/index.mjs.map +7 -0
  144. package/build-module/components/sidebar/dataform-post-summary.mjs +36 -6
  145. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  146. package/build-module/components/sidebar/header.mjs +1 -1
  147. package/build-module/components/sidebar/header.mjs.map +2 -2
  148. package/build-module/components/sidebar/index.mjs +5 -1
  149. package/build-module/components/sidebar/index.mjs.map +2 -2
  150. package/build-module/components/sync-connection-error-modal/index.mjs +177 -0
  151. package/build-module/components/sync-connection-error-modal/index.mjs.map +7 -0
  152. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs +36 -0
  153. package/build-module/components/sync-connection-error-modal/use-retry-countdown.mjs.map +7 -0
  154. package/build-module/components/template-content-panel/index.mjs +25 -31
  155. package/build-module/components/template-content-panel/index.mjs.map +2 -2
  156. package/build-module/components/visual-editor/index.mjs +2 -2
  157. package/build-module/components/visual-editor/index.mjs.map +2 -2
  158. package/build-module/store/actions.mjs +1 -3
  159. package/build-module/store/actions.mjs.map +2 -2
  160. package/build-module/store/private-actions.mjs +10 -2
  161. package/build-module/store/private-actions.mjs.map +2 -2
  162. package/build-module/store/private-selectors.mjs +50 -12
  163. package/build-module/store/private-selectors.mjs.map +2 -2
  164. package/build-module/store/reducer.mjs +11 -0
  165. package/build-module/store/reducer.mjs.map +2 -2
  166. package/build-module/utils/media-finalize/index.mjs +12 -0
  167. package/build-module/utils/media-finalize/index.mjs.map +7 -0
  168. package/build-module/utils/sync-error-messages.mjs +24 -16
  169. package/build-module/utils/sync-error-messages.mjs.map +3 -3
  170. package/build-style/style-rtl.css +95 -16
  171. package/build-style/style.css +95 -16
  172. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts +1 -1
  173. package/build-types/components/collaborators-overlay/avatar-iframe-styles.d.ts.map +1 -1
  174. package/build-types/components/collaborators-overlay/compute-selection.d.ts +24 -0
  175. package/build-types/components/collaborators-overlay/compute-selection.d.ts.map +1 -0
  176. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts +72 -0
  177. package/build-types/components/collaborators-overlay/cursor-dom-utils.d.ts.map +1 -0
  178. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts +1 -1
  179. package/build-types/components/collaborators-overlay/overlay-iframe-styles.d.ts.map +1 -1
  180. package/build-types/components/collaborators-overlay/overlay.d.ts.map +1 -1
  181. package/build-types/components/collaborators-overlay/timing-utils.d.ts +11 -0
  182. package/build-types/components/collaborators-overlay/timing-utils.d.ts.map +1 -0
  183. package/build-types/components/collaborators-overlay/use-block-highlighting.d.ts.map +1 -1
  184. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts +4 -0
  185. package/build-types/components/collaborators-overlay/use-render-cursors.d.ts.map +1 -1
  186. package/build-types/components/collaborators-presence/index.d.ts.map +1 -1
  187. package/build-types/components/collaborators-presence/list.d.ts +2 -1
  188. package/build-types/components/collaborators-presence/list.d.ts.map +1 -1
  189. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  190. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  191. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  192. package/build-types/components/post-locked-modal/index.d.ts +2 -2
  193. package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
  194. package/build-types/components/post-revisions-preview/block-diff.d.ts.map +1 -1
  195. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts +2 -5
  196. package/build-types/components/post-revisions-preview/revisions-canvas.d.ts.map +1 -1
  197. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  198. package/build-types/components/post-template/block-theme.d.ts +1 -3
  199. package/build-types/components/post-template/block-theme.d.ts.map +1 -1
  200. package/build-types/components/post-template/hooks.d.ts +1 -0
  201. package/build-types/components/post-template/hooks.d.ts.map +1 -1
  202. package/build-types/components/post-template/panel.d.ts.map +1 -1
  203. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  204. package/build-types/components/provider/index.d.ts.map +1 -1
  205. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  206. package/build-types/components/provider/use-post-content-block-types.d.ts +9 -0
  207. package/build-types/components/provider/use-post-content-block-types.d.ts.map +1 -0
  208. package/build-types/components/provider/use-revision-blocks.d.ts +10 -0
  209. package/build-types/components/provider/use-revision-blocks.d.ts.map +1 -0
  210. package/build-types/components/revision-block-diff/index.d.ts +6 -0
  211. package/build-types/components/revision-block-diff/index.d.ts.map +1 -0
  212. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  213. package/build-types/components/sidebar/index.d.ts.map +1 -1
  214. package/build-types/components/sync-connection-error-modal/index.d.ts +22 -0
  215. package/build-types/components/sync-connection-error-modal/index.d.ts.map +1 -0
  216. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts +11 -0
  217. package/build-types/components/sync-connection-error-modal/use-retry-countdown.d.ts.map +1 -0
  218. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  219. package/build-types/store/actions.d.ts.map +1 -1
  220. package/build-types/store/private-actions.d.ts +7 -0
  221. package/build-types/store/private-actions.d.ts.map +1 -1
  222. package/build-types/store/private-selectors.d.ts +7 -0
  223. package/build-types/store/private-selectors.d.ts.map +1 -1
  224. package/build-types/store/reducer.d.ts +14 -3
  225. package/build-types/store/reducer.d.ts.map +1 -1
  226. package/build-types/utils/media-finalize/index.d.ts +2 -0
  227. package/build-types/utils/media-finalize/index.d.ts.map +1 -0
  228. package/build-types/utils/sync-error-messages.d.ts +17 -3
  229. package/build-types/utils/sync-error-messages.d.ts.map +1 -1
  230. package/package.json +44 -44
  231. package/src/components/collaborators-overlay/avatar-iframe-styles.ts +12 -4
  232. package/src/components/collaborators-overlay/compute-selection.ts +307 -0
  233. package/src/components/collaborators-overlay/cursor-dom-utils.ts +382 -0
  234. package/src/components/collaborators-overlay/overlay-iframe-styles.ts +6 -0
  235. package/src/components/collaborators-overlay/overlay.tsx +59 -27
  236. package/src/components/collaborators-overlay/timing-utils.ts +30 -0
  237. package/src/components/collaborators-overlay/use-block-highlighting.ts +11 -10
  238. package/src/components/collaborators-overlay/use-render-cursors.ts +70 -242
  239. package/src/components/collaborators-presence/avatar/styles.scss +20 -4
  240. package/src/components/collaborators-presence/index.tsx +30 -5
  241. package/src/components/collaborators-presence/list.tsx +38 -24
  242. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +188 -246
  243. package/src/components/collaborators-presence/use-collaborator-notifications.ts +109 -166
  244. package/src/components/document-bar/style.scss +1 -1
  245. package/src/components/editor-interface/index.js +8 -6
  246. package/src/components/inserter-sidebar/index.js +4 -1
  247. package/src/components/page-attributes/parent.js +1 -1
  248. package/src/components/post-locked-modal/index.js +21 -3
  249. package/src/components/post-revisions-preview/block-diff.js +59 -20
  250. package/src/components/post-revisions-preview/diff-markers.js +2 -2
  251. package/src/components/post-revisions-preview/revisions-canvas.js +20 -98
  252. package/src/components/post-revisions-preview/revisions-slider.js +6 -1
  253. package/src/components/post-revisions-preview/test/block-diff.js +69 -31
  254. package/src/components/post-template/block-theme.js +4 -1
  255. package/src/components/post-template/hooks.js +42 -0
  256. package/src/components/post-template/panel.js +5 -59
  257. package/src/components/preferences-modal/index.js +18 -0
  258. package/src/components/provider/disable-non-page-content-blocks.js +42 -40
  259. package/src/components/provider/index.js +20 -2
  260. package/src/components/provider/use-block-editor-settings.js +21 -8
  261. package/src/components/provider/use-post-content-block-types.js +30 -0
  262. package/src/components/provider/use-revision-blocks.js +105 -0
  263. package/src/components/revision-block-diff/index.js +74 -0
  264. package/src/components/revision-block-diff/style.scss +13 -0
  265. package/src/components/sidebar/dataform-post-summary.js +61 -16
  266. package/src/components/sidebar/header.js +1 -1
  267. package/src/components/sidebar/index.js +2 -0
  268. package/src/components/sync-connection-error-modal/index.tsx +265 -0
  269. package/src/components/sync-connection-error-modal/style.scss +14 -0
  270. package/src/components/sync-connection-error-modal/use-retry-countdown.ts +57 -0
  271. package/src/components/template-content-panel/index.js +30 -38
  272. package/src/components/visual-editor/index.js +2 -2
  273. package/src/store/actions.js +1 -4
  274. package/src/store/private-actions.js +21 -2
  275. package/src/store/private-selectors.js +75 -10
  276. package/src/store/reducer.js +19 -0
  277. package/src/style.scss +2 -1
  278. package/src/utils/media-finalize/index.js +11 -0
  279. package/src/utils/media-finalize/test/index.js +34 -0
  280. package/src/utils/sync-error-messages.ts +72 -0
  281. package/src/utils/test/sync-error-messages.js +9 -32
  282. package/build/components/provider/use-post-content-blocks.cjs.map +0 -7
  283. package/build/components/sync-connection-modal/index.cjs.map +0 -7
  284. package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +0 -7
  285. package/build-module/components/provider/use-post-content-blocks.mjs +0 -34
  286. package/build-module/components/provider/use-post-content-blocks.mjs.map +0 -7
  287. package/build-module/components/sync-connection-modal/index.mjs +0 -167
  288. package/build-module/components/sync-connection-modal/index.mjs.map +0 -7
  289. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +0 -49
  290. package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +0 -7
  291. package/build-types/components/provider/use-post-content-blocks.d.ts +0 -2
  292. package/build-types/components/provider/use-post-content-blocks.d.ts.map +0 -1
  293. package/build-types/components/sync-connection-modal/index.d.ts +0 -8
  294. package/build-types/components/sync-connection-modal/index.d.ts.map +0 -1
  295. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +0 -9
  296. package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +0 -1
  297. package/src/components/provider/use-post-content-blocks.js +0 -42
  298. package/src/components/sync-connection-modal/index.js +0 -200
  299. package/src/components/sync-connection-modal/style.scss +0 -9
  300. package/src/components/sync-connection-modal/use-retry-countdown.js +0 -70
  301. package/src/utils/sync-error-messages.js +0 -58
@@ -1,200 +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
- const noop = () => {};
38
-
39
- /**
40
- * Sync connection modal that displays when any entity reports a disconnection.
41
- * Uses BlockCanvasCover.Fill to render in the block canvas.
42
- *
43
- * @return {Element|null} The modal component or null if not disconnected.
44
- */
45
- export function SyncConnectionModal() {
46
- const { connectionState, postType } = useSelect( ( selectFn ) => {
47
- const currentPostType = selectFn( editorStore ).getCurrentPostType();
48
- return {
49
- connectionState:
50
- selectFn( coreDataStore ).getSyncConnectionStatus() || null,
51
- postType: currentPostType
52
- ? selectFn( coreDataStore ).getPostType( currentPostType )
53
- : null,
54
- };
55
- }, [] );
56
-
57
- const { secondsRemaining, markRetrying } = useRetryCountdown(
58
- connectionState?.retryInMs,
59
- connectionState?.status
60
- );
61
-
62
- const copyButtonRef = useCopyToClipboard( () => {
63
- const blocks = select( blockEditorStore ).getBlocks();
64
- return serialize( blocks );
65
- } );
66
- const [ syncConnectionMessage, setSyncConnectionMessage ] =
67
- useState( null );
68
- const debounceTimerRef = useRef( null );
69
- // Track whether we've passed the initial load phase.
70
- // Once true, disconnected status will show immediately without debounce.
71
- const hasInitializedRef = useRef( false );
72
-
73
- const connectionStatus = connectionState?.status;
74
- const connectionErrorCode = connectionState?.error?.code;
75
-
76
- useEffect( () => {
77
- // Clear any pending debounce timer when status changes.
78
- if ( debounceTimerRef.current ) {
79
- clearTimeout( debounceTimerRef.current );
80
- debounceTimerRef.current = null;
81
- }
82
-
83
- if ( connectionStatus === 'connected' ) {
84
- hasInitializedRef.current = true;
85
- setSyncConnectionMessage( null );
86
- } else if ( connectionStatus === 'disconnected' ) {
87
- const showModal = () => {
88
- hasInitializedRef.current = true;
89
- setSyncConnectionMessage(
90
- getSyncErrorMessages( { code: connectionErrorCode } )
91
- );
92
- };
93
-
94
- // Debounce only on first load to allow connection to establish.
95
- if ( hasInitializedRef.current ) {
96
- showModal();
97
- } else {
98
- debounceTimerRef.current = setTimeout(
99
- showModal,
100
- INITIAL_DISCONNECTED_DEBOUNCE_MS
101
- );
102
- }
103
- }
104
-
105
- return () => {
106
- if ( debounceTimerRef.current ) {
107
- clearTimeout( debounceTimerRef.current );
108
- }
109
- };
110
- }, [ connectionStatus, connectionErrorCode ] );
111
-
112
- if ( ! syncConnectionMessage ) {
113
- return null;
114
- }
115
-
116
- const { title, description, canRetry } = syncConnectionMessage;
117
-
118
- let retryCountdownText;
119
- if ( secondsRemaining > 0 ) {
120
- retryCountdownText = sprintf(
121
- /* translators: %d: number of seconds until retry */
122
- _n(
123
- 'Retrying connection in %d second\u2026',
124
- 'Retrying connection in %d seconds\u2026',
125
- secondsRemaining
126
- ),
127
- secondsRemaining
128
- );
129
- } else if ( secondsRemaining === 0 ) {
130
- retryCountdownText = __( 'Retrying\u2026' );
131
- }
132
-
133
- let editPostHref = 'edit.php';
134
- if ( postType?.slug ) {
135
- editPostHref = `edit.php?post_type=${ postType.slug }`;
136
- }
137
-
138
- const isRetrying = secondsRemaining === 0;
139
-
140
- return (
141
- <BlockCanvasCover.Fill>
142
- <Modal
143
- className="editor-sync-connection-modal"
144
- isDismissible={ false }
145
- onRequestClose={ noop }
146
- shouldCloseOnClickOutside={ false }
147
- shouldCloseOnEsc={ false }
148
- size="medium"
149
- title={ title }
150
- >
151
- <VStack spacing={ 6 }>
152
- <p>{ description }</p>
153
- { retryCountdownText && (
154
- <p className="editor-sync-connection-modal__retry-countdown">
155
- { retryCountdownText }
156
- </p>
157
- ) }
158
- <HStack justify="right">
159
- <Button
160
- __next40pxDefaultSize
161
- href={ editPostHref }
162
- isDestructive
163
- variant="tertiary"
164
- >
165
- { sprintf(
166
- /* translators: %s: Post type name (e.g., "Posts", "Pages"). */
167
- __( 'Back to %s' ),
168
- postType?.labels?.name ?? __( 'Posts' )
169
- ) }
170
- </Button>
171
- <Button
172
- __next40pxDefaultSize
173
- ref={ copyButtonRef }
174
- variant={ canRetry ? 'secondary' : 'primary' }
175
- >
176
- { __( 'Copy Post Content' ) }
177
- </Button>
178
- { canRetry && (
179
- <Button
180
- __next40pxDefaultSize
181
- aria-disabled={ isRetrying }
182
- isBusy={ isRetrying }
183
- variant="primary"
184
- onClick={ () => {
185
- if ( isRetrying ) {
186
- return;
187
- }
188
- markRetrying();
189
- retrySyncConnection();
190
- } }
191
- >
192
- { __( 'Retry' ) }
193
- </Button>
194
- ) }
195
- </HStack>
196
- </VStack>
197
- </Modal>
198
- </BlockCanvasCover.Fill>
199
- );
200
- }
@@ -1,9 +0,0 @@
1
- @use "@wordpress/base-styles/colors" as *;
2
-
3
- .editor-sync-connection-modal p {
4
- margin: 0;
5
- }
6
-
7
- .editor-sync-connection-modal__retry-countdown {
8
- color: $gray-700;
9
- }
@@ -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
- }