@wordpress/editor 14.44.0 → 14.45.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 (363) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/collab-sidebar/{comment-menu-item.cjs → add-note-menu-item.cjs} +17 -14
  3. package/build/components/collab-sidebar/add-note-menu-item.cjs.map +7 -0
  4. package/build/components/collab-sidebar/add-note.cjs +100 -0
  5. package/build/components/collab-sidebar/add-note.cjs.map +7 -0
  6. package/build/components/collab-sidebar/board-store.cjs +106 -0
  7. package/build/components/collab-sidebar/board-store.cjs.map +7 -0
  8. package/build/components/collab-sidebar/floating-container.cjs +63 -0
  9. package/build/components/collab-sidebar/floating-container.cjs.map +7 -0
  10. package/build/components/collab-sidebar/hooks.cjs +105 -140
  11. package/build/components/collab-sidebar/hooks.cjs.map +3 -3
  12. package/build/components/collab-sidebar/index.cjs +28 -90
  13. package/build/components/collab-sidebar/index.cjs.map +3 -3
  14. package/build/components/collab-sidebar/{comment-author-info.cjs → note-byline.cjs} +13 -9
  15. package/build/components/collab-sidebar/note-byline.cjs.map +7 -0
  16. package/build/components/collab-sidebar/note-card.cjs +58 -0
  17. package/build/components/collab-sidebar/note-card.cjs.map +7 -0
  18. package/build/components/collab-sidebar/{comment-form.cjs → note-form.cjs} +46 -45
  19. package/build/components/collab-sidebar/note-form.cjs.map +7 -0
  20. package/build/components/collab-sidebar/{comment-indicator-toolbar.cjs → note-indicator-toolbar.cjs} +31 -27
  21. package/build/components/collab-sidebar/note-indicator-toolbar.cjs.map +7 -0
  22. package/build/components/collab-sidebar/note-thread.cjs +321 -0
  23. package/build/components/collab-sidebar/note-thread.cjs.map +7 -0
  24. package/build/components/collab-sidebar/note.cjs +207 -0
  25. package/build/components/collab-sidebar/note.cjs.map +7 -0
  26. package/build/components/collab-sidebar/notes.cjs +237 -0
  27. package/build/components/collab-sidebar/notes.cjs.map +7 -0
  28. package/build/components/collab-sidebar/utils.cjs +80 -14
  29. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  30. package/build/components/collaborators-presence/avatar/component.cjs.map +1 -1
  31. package/build/components/collaborators-presence/index.cjs +3 -3
  32. package/build/components/collaborators-presence/index.cjs.map +2 -2
  33. package/build/components/collaborators-presence/list.cjs +3 -3
  34. package/build/components/collaborators-presence/list.cjs.map +2 -2
  35. package/build/components/document-bar/index.cjs.map +3 -3
  36. package/build/components/error-boundary/index.cjs.map +3 -3
  37. package/build/components/list-view-sidebar/list-view-outline.cjs.map +3 -3
  38. package/build/components/media/media-editor-modal.cjs +93 -0
  39. package/build/components/media/media-editor-modal.cjs.map +7 -0
  40. package/build/components/media-categories/index.cjs +1 -1
  41. package/build/components/media-categories/index.cjs.map +1 -1
  42. package/build/components/more-menu/index.cjs +4 -3
  43. package/build/components/more-menu/index.cjs.map +2 -2
  44. package/build/components/post-actions/set-as-homepage.cjs.map +3 -3
  45. package/build/components/post-actions/set-as-posts-page.cjs.map +3 -3
  46. package/build/components/post-card-panel/index.cjs +2 -2
  47. package/build/components/post-card-panel/index.cjs.map +3 -3
  48. package/build/components/post-content-information/index.cjs.map +3 -3
  49. package/build/components/post-excerpt/panel.cjs.map +3 -3
  50. package/build/components/post-last-edited-panel/index.cjs.map +3 -3
  51. package/build/components/post-preview-button/index.cjs +3 -2
  52. package/build/components/post-preview-button/index.cjs.map +2 -2
  53. package/build/components/post-publish-button/index.cjs +2 -2
  54. package/build/components/post-publish-button/index.cjs.map +2 -2
  55. package/build/components/post-publish-button/label.cjs +4 -2
  56. package/build/components/post-publish-button/label.cjs.map +2 -2
  57. package/build/components/post-publish-panel/maybe-upload-media.cjs +1 -1
  58. package/build/components/post-publish-panel/maybe-upload-media.cjs.map +1 -1
  59. package/build/components/post-publish-panel/postpublish.cjs +3 -2
  60. package/build/components/post-publish-panel/postpublish.cjs.map +2 -2
  61. package/build/components/post-revisions-panel/index.cjs +2 -2
  62. package/build/components/post-revisions-panel/index.cjs.map +2 -2
  63. package/build/components/post-revisions-preview/diff-markers.cjs +1 -1
  64. package/build/components/post-revisions-preview/diff-markers.cjs.map +2 -2
  65. package/build/components/post-revisions-preview/revisions-slider.cjs +1 -0
  66. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  67. package/build/components/post-saved-state/index.cjs +4 -1
  68. package/build/components/post-saved-state/index.cjs.map +2 -2
  69. package/build/components/post-text-editor/index.cjs +3 -4
  70. package/build/components/post-text-editor/index.cjs.map +2 -2
  71. package/build/components/preview-dropdown/index.cjs +3 -2
  72. package/build/components/preview-dropdown/index.cjs.map +2 -2
  73. package/build/components/provider/index.cjs +3 -1
  74. package/build/components/provider/index.cjs.map +3 -3
  75. package/build/components/provider/use-block-editor-settings.cjs +7 -1
  76. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  77. package/build/components/provider/use-upload-save-lock.cjs +2 -12
  78. package/build/components/provider/use-upload-save-lock.cjs.map +2 -2
  79. package/build/components/resizable-editor/resize-handle.cjs +2 -1
  80. package/build/components/resizable-editor/resize-handle.cjs.map +2 -2
  81. package/build/components/revision-created-panel/index.cjs.map +3 -3
  82. package/build/components/site-discussion/index.cjs.map +2 -2
  83. package/build/components/style-book/constants.cjs +1 -1
  84. package/build/components/style-book/constants.cjs.map +1 -1
  85. package/build/components/style-book/index.cjs +1 -1
  86. package/build/components/style-book/index.cjs.map +1 -1
  87. package/build/components/template-actions-panel/classic-theme-content.cjs.map +2 -2
  88. package/build/components/template-part-menu-items/convert-to-regular.cjs +54 -11
  89. package/build/components/template-part-menu-items/convert-to-regular.cjs.map +3 -3
  90. package/build/components/visual-editor/index.cjs +5 -22
  91. package/build/components/visual-editor/index.cjs.map +2 -2
  92. package/build/store/private-actions.cjs +0 -8
  93. package/build/store/private-actions.cjs.map +2 -2
  94. package/build/store/private-selectors.cjs +0 -5
  95. package/build/store/private-selectors.cjs.map +2 -2
  96. package/build/store/reducer.cjs +0 -10
  97. package/build/store/reducer.cjs.map +2 -2
  98. package/build/utils/media-finalize/index.cjs +3 -2
  99. package/build/utils/media-finalize/index.cjs.map +2 -2
  100. package/build/utils/media-upload/index.cjs +14 -25
  101. package/build/utils/media-upload/index.cjs.map +2 -2
  102. package/build-module/components/collab-sidebar/{comment-menu-item.mjs → add-note-menu-item.mjs} +10 -11
  103. package/build-module/components/collab-sidebar/add-note-menu-item.mjs.map +7 -0
  104. package/build-module/components/collab-sidebar/add-note.mjs +78 -0
  105. package/build-module/components/collab-sidebar/add-note.mjs.map +7 -0
  106. package/build-module/components/collab-sidebar/board-store.mjs +81 -0
  107. package/build-module/components/collab-sidebar/board-store.mjs.map +7 -0
  108. package/build-module/components/collab-sidebar/floating-container.mjs +28 -0
  109. package/build-module/components/collab-sidebar/floating-container.mjs.map +7 -0
  110. package/build-module/components/collab-sidebar/hooks.mjs +105 -144
  111. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  112. package/build-module/components/collab-sidebar/index.mjs +29 -95
  113. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  114. package/build-module/components/collab-sidebar/{comment-author-info.mjs → note-byline.mjs} +7 -7
  115. package/build-module/components/collab-sidebar/note-byline.mjs.map +7 -0
  116. package/build-module/components/collab-sidebar/note-card.mjs +33 -0
  117. package/build-module/components/collab-sidebar/note-card.mjs.map +7 -0
  118. package/build-module/components/collab-sidebar/note-form.mjs +84 -0
  119. package/build-module/components/collab-sidebar/note-form.mjs.map +7 -0
  120. package/build-module/components/collab-sidebar/{comment-indicator-toolbar.mjs → note-indicator-toolbar.mjs} +25 -29
  121. package/build-module/components/collab-sidebar/note-indicator-toolbar.mjs.map +7 -0
  122. package/build-module/components/collab-sidebar/note-thread.mjs +289 -0
  123. package/build-module/components/collab-sidebar/note-thread.mjs.map +7 -0
  124. package/build-module/components/collab-sidebar/note.mjs +176 -0
  125. package/build-module/components/collab-sidebar/note.mjs.map +7 -0
  126. package/build-module/components/collab-sidebar/notes.mjs +215 -0
  127. package/build-module/components/collab-sidebar/notes.mjs.map +7 -0
  128. package/build-module/components/collab-sidebar/utils.mjs +76 -10
  129. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  130. package/build-module/components/collaborators-presence/avatar/component.mjs.map +1 -1
  131. package/build-module/components/collaborators-presence/index.mjs +3 -3
  132. package/build-module/components/collaborators-presence/index.mjs.map +2 -2
  133. package/build-module/components/collaborators-presence/list.mjs +3 -3
  134. package/build-module/components/collaborators-presence/list.mjs.map +2 -2
  135. package/build-module/components/document-bar/index.mjs +3 -3
  136. package/build-module/components/document-bar/index.mjs.map +2 -2
  137. package/build-module/components/error-boundary/index.mjs +2 -2
  138. package/build-module/components/error-boundary/index.mjs.map +2 -2
  139. package/build-module/components/list-view-sidebar/list-view-outline.mjs +5 -5
  140. package/build-module/components/list-view-sidebar/list-view-outline.mjs.map +2 -2
  141. package/build-module/components/media/media-editor-modal.mjs +62 -0
  142. package/build-module/components/media/media-editor-modal.mjs.map +7 -0
  143. package/build-module/components/media-categories/index.mjs +1 -1
  144. package/build-module/components/media-categories/index.mjs.map +1 -1
  145. package/build-module/components/more-menu/index.mjs +4 -8
  146. package/build-module/components/more-menu/index.mjs.map +2 -2
  147. package/build-module/components/post-actions/set-as-homepage.mjs +2 -2
  148. package/build-module/components/post-actions/set-as-homepage.mjs.map +2 -2
  149. package/build-module/components/post-actions/set-as-posts-page.mjs +2 -2
  150. package/build-module/components/post-actions/set-as-posts-page.mjs.map +2 -2
  151. package/build-module/components/post-card-panel/index.mjs +5 -5
  152. package/build-module/components/post-card-panel/index.mjs.map +2 -2
  153. package/build-module/components/post-content-information/index.mjs +2 -2
  154. package/build-module/components/post-content-information/index.mjs.map +2 -2
  155. package/build-module/components/post-excerpt/panel.mjs +2 -2
  156. package/build-module/components/post-excerpt/panel.mjs.map +2 -2
  157. package/build-module/components/post-last-edited-panel/index.mjs +2 -2
  158. package/build-module/components/post-last-edited-panel/index.mjs.map +2 -2
  159. package/build-module/components/post-preview-button/index.mjs +3 -2
  160. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  161. package/build-module/components/post-publish-button/index.mjs +2 -2
  162. package/build-module/components/post-publish-button/index.mjs.map +2 -2
  163. package/build-module/components/post-publish-button/label.mjs +4 -2
  164. package/build-module/components/post-publish-button/label.mjs.map +2 -2
  165. package/build-module/components/post-publish-panel/maybe-upload-media.mjs +1 -1
  166. package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +1 -1
  167. package/build-module/components/post-publish-panel/postpublish.mjs +3 -3
  168. package/build-module/components/post-publish-panel/postpublish.mjs.map +2 -2
  169. package/build-module/components/post-revisions-panel/index.mjs +2 -2
  170. package/build-module/components/post-revisions-panel/index.mjs.map +2 -2
  171. package/build-module/components/post-revisions-preview/diff-markers.mjs +1 -1
  172. package/build-module/components/post-revisions-preview/diff-markers.mjs.map +2 -2
  173. package/build-module/components/post-revisions-preview/revisions-slider.mjs +1 -0
  174. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  175. package/build-module/components/post-saved-state/index.mjs +4 -1
  176. package/build-module/components/post-saved-state/index.mjs.map +2 -2
  177. package/build-module/components/post-text-editor/index.mjs +2 -3
  178. package/build-module/components/post-text-editor/index.mjs.map +2 -2
  179. package/build-module/components/preview-dropdown/index.mjs +2 -2
  180. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  181. package/build-module/components/provider/index.mjs +3 -1
  182. package/build-module/components/provider/index.mjs.map +2 -2
  183. package/build-module/components/provider/use-block-editor-settings.mjs +7 -1
  184. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  185. package/build-module/components/provider/use-upload-save-lock.mjs +2 -12
  186. package/build-module/components/provider/use-upload-save-lock.mjs.map +2 -2
  187. package/build-module/components/resizable-editor/resize-handle.mjs +2 -5
  188. package/build-module/components/resizable-editor/resize-handle.mjs.map +2 -2
  189. package/build-module/components/revision-created-panel/index.mjs +2 -2
  190. package/build-module/components/revision-created-panel/index.mjs.map +2 -2
  191. package/build-module/components/site-discussion/index.mjs +2 -2
  192. package/build-module/components/site-discussion/index.mjs.map +2 -2
  193. package/build-module/components/style-book/constants.mjs +1 -1
  194. package/build-module/components/style-book/constants.mjs.map +1 -1
  195. package/build-module/components/style-book/index.mjs +1 -1
  196. package/build-module/components/style-book/index.mjs.map +1 -1
  197. package/build-module/components/template-actions-panel/classic-theme-content.mjs +2 -2
  198. package/build-module/components/template-actions-panel/classic-theme-content.mjs.map +2 -2
  199. package/build-module/components/template-part-menu-items/convert-to-regular.mjs +60 -14
  200. package/build-module/components/template-part-menu-items/convert-to-regular.mjs.map +2 -2
  201. package/build-module/components/visual-editor/index.mjs +5 -22
  202. package/build-module/components/visual-editor/index.mjs.map +2 -2
  203. package/build-module/store/private-actions.mjs +0 -7
  204. package/build-module/store/private-actions.mjs.map +2 -2
  205. package/build-module/store/private-selectors.mjs +0 -4
  206. package/build-module/store/private-selectors.mjs.map +2 -2
  207. package/build-module/store/reducer.mjs +0 -9
  208. package/build-module/store/reducer.mjs.map +2 -2
  209. package/build-module/utils/media-finalize/index.mjs +3 -2
  210. package/build-module/utils/media-finalize/index.mjs.map +2 -2
  211. package/build-module/utils/media-upload/index.mjs +14 -25
  212. package/build-module/utils/media-upload/index.mjs.map +2 -2
  213. package/build-style/style-rtl.css +397 -171
  214. package/build-style/style.css +397 -171
  215. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts +5 -0
  216. package/build-types/components/collab-sidebar/add-note-menu-item.d.ts.map +1 -0
  217. package/build-types/components/collab-sidebar/add-note.d.ts +6 -0
  218. package/build-types/components/collab-sidebar/add-note.d.ts.map +1 -0
  219. package/build-types/components/collab-sidebar/board-store.d.ts +9 -0
  220. package/build-types/components/collab-sidebar/board-store.d.ts.map +1 -0
  221. package/build-types/components/collab-sidebar/floating-container.d.ts +8 -0
  222. package/build-types/components/collab-sidebar/floating-container.d.ts.map +1 -0
  223. package/build-types/components/collab-sidebar/hooks.d.ts +13 -22
  224. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  225. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  226. package/build-types/components/collab-sidebar/note-byline.d.ts +7 -0
  227. package/build-types/components/collab-sidebar/note-byline.d.ts.map +1 -0
  228. package/build-types/components/collab-sidebar/note-card.d.ts +8 -0
  229. package/build-types/components/collab-sidebar/note-card.d.ts.map +1 -0
  230. package/build-types/components/collab-sidebar/note-form.d.ts +7 -0
  231. package/build-types/components/collab-sidebar/note-form.d.ts.map +1 -0
  232. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts +5 -0
  233. package/build-types/components/collab-sidebar/note-indicator-toolbar.d.ts.map +1 -0
  234. package/build-types/components/collab-sidebar/note-thread.d.ts +11 -0
  235. package/build-types/components/collab-sidebar/note-thread.d.ts.map +1 -0
  236. package/build-types/components/collab-sidebar/note.d.ts +9 -0
  237. package/build-types/components/collab-sidebar/note.d.ts.map +1 -0
  238. package/build-types/components/collab-sidebar/notes.d.ts +7 -0
  239. package/build-types/components/collab-sidebar/notes.d.ts.map +1 -0
  240. package/build-types/components/collab-sidebar/utils.d.ts +41 -17
  241. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  242. package/build-types/components/media/media-editor-modal.d.ts +11 -0
  243. package/build-types/components/media/media-editor-modal.d.ts.map +1 -0
  244. package/build-types/components/more-menu/index.d.ts.map +1 -1
  245. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  246. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  247. package/build-types/components/post-publish-button/label.d.ts.map +1 -1
  248. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  249. package/build-types/components/post-saved-state/index.d.ts.map +1 -1
  250. package/build-types/components/provider/index.d.ts.map +1 -1
  251. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  252. package/build-types/components/provider/use-upload-save-lock.d.ts +0 -2
  253. package/build-types/components/provider/use-upload-save-lock.d.ts.map +1 -1
  254. package/build-types/components/resizable-editor/resize-handle.d.ts.map +1 -1
  255. package/build-types/components/style-book/constants.d.ts +1 -1
  256. package/build-types/components/style-book/constants.d.ts.map +1 -1
  257. package/build-types/components/template-part-menu-items/convert-to-regular.d.ts.map +1 -1
  258. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  259. package/build-types/store/private-actions.d.ts +0 -7
  260. package/build-types/store/private-actions.d.ts.map +1 -1
  261. package/build-types/store/private-selectors.d.ts +0 -7
  262. package/build-types/store/private-selectors.d.ts.map +1 -1
  263. package/build-types/store/reducer.d.ts +0 -10
  264. package/build-types/store/reducer.d.ts.map +1 -1
  265. package/build-types/utils/media-finalize/index.d.ts +1 -1
  266. package/build-types/utils/media-finalize/index.d.ts.map +1 -1
  267. package/build-types/utils/media-upload/index.d.ts.map +1 -1
  268. package/package.json +46 -46
  269. package/src/components/collab-sidebar/README.md +117 -0
  270. package/src/components/collab-sidebar/{comment-menu-item.js → add-note-menu-item.js} +8 -10
  271. package/src/components/collab-sidebar/{add-comment.js → add-note.js} +26 -49
  272. package/src/components/collab-sidebar/board-store.js +85 -0
  273. package/src/components/collab-sidebar/floating-container.js +30 -0
  274. package/src/components/collab-sidebar/hooks.js +130 -178
  275. package/src/components/collab-sidebar/index.js +35 -106
  276. package/src/components/collab-sidebar/{comment-author-info.js → note-byline.js} +5 -6
  277. package/src/components/collab-sidebar/note-card.js +36 -0
  278. package/src/components/collab-sidebar/{comment-form.js → note-form.js} +29 -40
  279. package/src/components/collab-sidebar/{comment-indicator-toolbar.js → note-indicator-toolbar.js} +29 -32
  280. package/src/components/collab-sidebar/note-thread.js +331 -0
  281. package/src/components/collab-sidebar/note.js +209 -0
  282. package/src/components/collab-sidebar/notes.js +276 -0
  283. package/src/components/collab-sidebar/style.scss +21 -11
  284. package/src/components/collab-sidebar/test/utils.js +155 -0
  285. package/src/components/collab-sidebar/utils.js +125 -19
  286. package/src/components/collaborators-presence/avatar/component.tsx +1 -1
  287. package/src/components/collaborators-presence/styles/collaborators-list.scss +1 -1
  288. package/src/components/collaborators-presence/styles/collaborators-presence.scss +1 -1
  289. package/src/components/document-bar/index.js +4 -4
  290. package/src/components/document-outline/style.scss +1 -1
  291. package/src/components/error-boundary/index.js +3 -3
  292. package/src/components/list-view-sidebar/list-view-outline.js +6 -6
  293. package/src/components/media/media-editor-modal.js +95 -0
  294. package/src/components/media-categories/index.js +1 -1
  295. package/src/components/more-menu/index.js +4 -8
  296. package/src/components/post-actions/set-as-homepage.js +2 -2
  297. package/src/components/post-actions/set-as-posts-page.js +2 -2
  298. package/src/components/post-card-panel/index.js +7 -7
  299. package/src/components/post-content-information/index.js +3 -3
  300. package/src/components/post-excerpt/panel.js +3 -3
  301. package/src/components/post-last-edited-panel/index.js +3 -3
  302. package/src/components/post-preview-button/index.js +3 -2
  303. package/src/components/post-publish-button/index.js +6 -5
  304. package/src/components/post-publish-button/label.js +3 -1
  305. package/src/components/post-publish-panel/maybe-upload-media.js +1 -1
  306. package/src/components/post-publish-panel/postpublish.js +2 -2
  307. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +10 -16
  308. package/src/components/post-revisions-panel/index.js +3 -3
  309. package/src/components/post-revisions-preview/diff-markers.js +1 -1
  310. package/src/components/post-revisions-preview/revisions-slider.js +1 -0
  311. package/src/components/post-revisions-preview/style.scss +1 -1
  312. package/src/components/post-saved-state/index.js +4 -1
  313. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +0 -1
  314. package/src/components/post-text-editor/index.js +3 -3
  315. package/src/components/preview-dropdown/index.js +2 -2
  316. package/src/components/provider/index.js +4 -0
  317. package/src/components/provider/use-block-editor-settings.js +10 -0
  318. package/src/components/provider/use-upload-save-lock.js +2 -17
  319. package/src/components/resizable-editor/resize-handle.js +2 -5
  320. package/src/components/revision-created-panel/index.js +3 -3
  321. package/src/components/site-discussion/index.js +3 -3
  322. package/src/components/style-book/constants.ts +1 -1
  323. package/src/components/style-book/index.js +1 -1
  324. package/src/components/template-actions-panel/classic-theme-content.js +3 -3
  325. package/src/components/template-actions-panel/style.scss +1 -1
  326. package/src/components/template-part-menu-items/convert-to-regular.js +74 -12
  327. package/src/components/visual-editor/index.js +2 -29
  328. package/src/store/private-actions.js +0 -13
  329. package/src/store/private-selectors.js +0 -10
  330. package/src/store/reducer.js +0 -16
  331. package/src/utils/media-finalize/index.js +2 -1
  332. package/src/utils/media-finalize/test/index.js +25 -1
  333. package/src/utils/media-upload/index.js +26 -29
  334. package/build/components/collab-sidebar/add-comment.cjs +0 -129
  335. package/build/components/collab-sidebar/add-comment.cjs.map +0 -7
  336. package/build/components/collab-sidebar/comment-author-info.cjs.map +0 -7
  337. package/build/components/collab-sidebar/comment-form.cjs.map +0 -7
  338. package/build/components/collab-sidebar/comment-indicator-toolbar.cjs.map +0 -7
  339. package/build/components/collab-sidebar/comment-menu-item.cjs.map +0 -7
  340. package/build/components/collab-sidebar/comments.cjs +0 -816
  341. package/build/components/collab-sidebar/comments.cjs.map +0 -7
  342. package/build-module/components/collab-sidebar/add-comment.mjs +0 -100
  343. package/build-module/components/collab-sidebar/add-comment.mjs.map +0 -7
  344. package/build-module/components/collab-sidebar/comment-author-info.mjs.map +0 -7
  345. package/build-module/components/collab-sidebar/comment-form.mjs +0 -90
  346. package/build-module/components/collab-sidebar/comment-form.mjs.map +0 -7
  347. package/build-module/components/collab-sidebar/comment-indicator-toolbar.mjs.map +0 -7
  348. package/build-module/components/collab-sidebar/comment-menu-item.mjs.map +0 -7
  349. package/build-module/components/collab-sidebar/comments.mjs +0 -799
  350. package/build-module/components/collab-sidebar/comments.mjs.map +0 -7
  351. package/build-types/components/collab-sidebar/add-comment.d.ts +0 -10
  352. package/build-types/components/collab-sidebar/add-comment.d.ts.map +0 -1
  353. package/build-types/components/collab-sidebar/comment-author-info.d.ts +0 -8
  354. package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +0 -1
  355. package/build-types/components/collab-sidebar/comment-form.d.ts +0 -11
  356. package/build-types/components/collab-sidebar/comment-form.d.ts.map +0 -1
  357. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts +0 -6
  358. package/build-types/components/collab-sidebar/comment-indicator-toolbar.d.ts.map +0 -1
  359. package/build-types/components/collab-sidebar/comment-menu-item.d.ts +0 -6
  360. package/build-types/components/collab-sidebar/comment-menu-item.d.ts.map +0 -1
  361. package/build-types/components/collab-sidebar/comments.d.ts +0 -12
  362. package/build-types/components/collab-sidebar/comments.d.ts.map +0 -1
  363. package/src/components/collab-sidebar/comments.js +0 -985
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.44.0",
3
+ "version": "14.45.0",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -60,50 +60,50 @@
60
60
  "build-module/bindings/**"
61
61
  ],
62
62
  "dependencies": {
63
- "@floating-ui/react-dom": "2.0.8",
64
- "@wordpress/a11y": "^4.44.0",
65
- "@wordpress/api-fetch": "^7.44.0",
66
- "@wordpress/base-styles": "^6.20.0",
67
- "@wordpress/blob": "^4.44.0",
68
- "@wordpress/block-editor": "^15.17.0",
69
- "@wordpress/block-serialization-default-parser": "^5.44.0",
70
- "@wordpress/blocks": "^15.17.0",
71
- "@wordpress/commands": "^1.44.0",
72
- "@wordpress/components": "^32.6.0",
73
- "@wordpress/compose": "^7.44.0",
74
- "@wordpress/core-data": "^7.44.0",
75
- "@wordpress/data": "^10.44.0",
76
- "@wordpress/dataviews": "^14.1.0",
77
- "@wordpress/date": "^5.44.0",
78
- "@wordpress/deprecated": "^4.44.0",
79
- "@wordpress/dom": "^4.44.0",
80
- "@wordpress/element": "^6.44.0",
81
- "@wordpress/fields": "^0.36.0",
82
- "@wordpress/global-styles-engine": "^1.11.0",
83
- "@wordpress/global-styles-ui": "^1.11.0",
84
- "@wordpress/hooks": "^4.44.0",
85
- "@wordpress/html-entities": "^4.44.0",
86
- "@wordpress/i18n": "^6.17.0",
87
- "@wordpress/icons": "^12.2.0",
88
- "@wordpress/interface": "^9.29.0",
89
- "@wordpress/keyboard-shortcuts": "^5.44.0",
90
- "@wordpress/keycodes": "^4.44.0",
91
- "@wordpress/media-editor": "^0.7.0",
92
- "@wordpress/media-fields": "^0.9.0",
93
- "@wordpress/media-utils": "^5.44.0",
94
- "@wordpress/notices": "^5.44.0",
95
- "@wordpress/patterns": "^2.44.0",
96
- "@wordpress/plugins": "^7.44.0",
97
- "@wordpress/preferences": "^4.44.0",
98
- "@wordpress/private-apis": "^1.44.0",
99
- "@wordpress/reusable-blocks": "^5.44.0",
100
- "@wordpress/rich-text": "^7.44.0",
101
- "@wordpress/server-side-render": "^6.20.0",
102
- "@wordpress/upload-media": "^0.29.0",
103
- "@wordpress/url": "^4.44.0",
104
- "@wordpress/views": "^1.11.0",
105
- "@wordpress/warning": "^3.44.0",
106
- "@wordpress/wordcount": "^4.44.0",
63
+ "@wordpress/a11y": "^4.45.0",
64
+ "@wordpress/api-fetch": "^7.45.0",
65
+ "@wordpress/base-styles": "^7.0.0",
66
+ "@wordpress/blob": "^4.45.0",
67
+ "@wordpress/block-editor": "^15.18.0",
68
+ "@wordpress/block-serialization-default-parser": "^5.45.0",
69
+ "@wordpress/blocks": "^15.18.0",
70
+ "@wordpress/commands": "^1.45.0",
71
+ "@wordpress/components": "^33.0.0",
72
+ "@wordpress/compose": "^7.45.0",
73
+ "@wordpress/core-data": "^7.45.0",
74
+ "@wordpress/data": "^10.45.0",
75
+ "@wordpress/dataviews": "^14.2.0",
76
+ "@wordpress/date": "^5.45.0",
77
+ "@wordpress/deprecated": "^4.45.0",
78
+ "@wordpress/dom": "^4.45.0",
79
+ "@wordpress/element": "^6.45.0",
80
+ "@wordpress/fields": "^0.37.0",
81
+ "@wordpress/global-styles-engine": "^1.12.0",
82
+ "@wordpress/global-styles-ui": "^1.12.0",
83
+ "@wordpress/hooks": "^4.45.0",
84
+ "@wordpress/html-entities": "^4.45.0",
85
+ "@wordpress/i18n": "^6.18.0",
86
+ "@wordpress/icons": "^13.0.0",
87
+ "@wordpress/interface": "^9.30.0",
88
+ "@wordpress/keyboard-shortcuts": "^5.45.0",
89
+ "@wordpress/keycodes": "^4.45.0",
90
+ "@wordpress/media-editor": "^0.8.0",
91
+ "@wordpress/media-fields": "^0.10.0",
92
+ "@wordpress/media-utils": "^5.45.0",
93
+ "@wordpress/notices": "^5.45.0",
94
+ "@wordpress/patterns": "^2.45.0",
95
+ "@wordpress/plugins": "^7.45.0",
96
+ "@wordpress/preferences": "^4.45.0",
97
+ "@wordpress/private-apis": "^1.45.0",
98
+ "@wordpress/reusable-blocks": "^5.45.0",
99
+ "@wordpress/rich-text": "^7.45.0",
100
+ "@wordpress/server-side-render": "^6.21.0",
101
+ "@wordpress/ui": "^0.12.0",
102
+ "@wordpress/upload-media": "^0.30.0",
103
+ "@wordpress/url": "^4.45.0",
104
+ "@wordpress/views": "^1.12.0",
105
+ "@wordpress/warning": "^3.45.0",
106
+ "@wordpress/wordcount": "^4.45.0",
107
107
  "change-case": "^4.1.2",
108
108
  "client-zip": "^2.4.5",
109
109
  "clsx": "^2.1.1",
@@ -126,5 +126,5 @@
126
126
  "publishConfig": {
127
127
  "access": "public"
128
128
  },
129
- "gitHead": "b862d8c84121a47bbeff882f6c87e61681ce2e0d"
129
+ "gitHead": "8c229eaed0e88c9827e2da3d73a78f9ddd77714b"
130
130
  }
@@ -0,0 +1,117 @@
1
+ # Notes Sidebar
2
+
3
+ The Notes sidebar (a.k.a. collab sidebar) lets users attach threaded notes to individual blocks. It renders in two modes:
4
+
5
+ - **All notes** - a full sidebar (opened from the editor's More menu) listing every note thread on the current post.
6
+ - **Floating notes** - on larger viewports, unresolved notes also float next to their associated blocks in the canvas, positioned to track scroll and avoid overlap.
7
+
8
+ Notes are stored as WordPress comments (`type: 'note'`) attached to the post. A block references its thread via `metadata.noteId` on block attributes. Each thread has a top-level note plus replies; threads can be resolved (stored as status `approved`) or reopened.
9
+
10
+ ## File structure
11
+
12
+ ```
13
+ collab-sidebar/
14
+ ├── README.md this file
15
+ ├── index.js NotesSidebarContainer → NotesSidebar (entry, toolbar slot fills)
16
+ ├── notes.js Notes - coordinator (outer Stack, actions, keyboard nav)
17
+ ├── note-thread.js NoteThread - per-thread (selection, floating registration, reply form)
18
+ ├── note.js Note - per-card state (edit/delete mode, menu, dialog)
19
+ ├── note-card.js NoteCard - presentational shell (byline + actions slot + children)
20
+ ├── note-byline.js NoteByline - avatar + name + relative date
21
+ ├── note-form.js NoteForm - autosizing textarea + submit/cancel
22
+ ├── add-note.js AddNote - new-note surface (floating + template-locked cases)
23
+ ├── add-note-menu-item.js AddNoteMenuItem - block-toolbar "Add note" trigger
24
+ ├── note-indicator-toolbar.js NoteAvatarIndicator - toolbar participants avatars
25
+ ├── floating-container.js FloatingContainer - stack wrapper that applies `top` in floating mode
26
+
27
+ ├── hooks.js useNoteThreads, useNoteActions, useFloatingBoard, useEnableFloatingSidebar
28
+ ├── utils.js focusNoteThread, getNoteExcerpt, sanitizeNoteContent, calculateNotePositions, getAvatarBorderColor
29
+ ├── board-store.js createBoardStore - ResizeObserver + ref registry for floating layout
30
+ ├── constants.js sidebar identifier strings
31
+ ├── style.scss
32
+ └── test/
33
+ └── utils.js
34
+ ```
35
+
36
+ ## Component hierarchy
37
+
38
+ ```
39
+ NotesSidebarContainer (index.js) - gates on post type support
40
+ └── NotesSidebar (index.js) - owns sidebarRef + useNoteThreads + sidebar registration
41
+ ├── AddNoteMenuItem - slot fill in the block toolbar
42
+ ├── NoteAvatarIndicator - slot fill in the block toolbar (per-thread avatars)
43
+ ├── PluginSidebar (all-notes) - full sidebar
44
+ │ └── Notes (notes.js) - owns outer Stack + aria-label + useNoteActions + keyboard nav
45
+ │ ├── AddNote - rendered when no threads (template-locked) or selectedNote === 'new'
46
+ │ └── NoteThread[] - per thread
47
+ │ └── <FloatingContainer>
48
+ │ ├── Note - top-level note (own state: edit/delete/dialog)
49
+ │ │ └── NoteCard
50
+ │ │ └── NoteByline + actions slot + body children
51
+ │ ├── Note[] - replies (when selected)
52
+ │ └── NoteCard + NoteForm - inline reply form (when selected)
53
+ └── PluginSidebar (floating) - floating sidebar (large viewport, unresolved notes)
54
+ └── Notes (same) - isFloating
55
+ ```
56
+
57
+ `Notes` is reused for both sidebar surfaces. The only visual difference is driven by `isFloating` (whether to layer threads over the canvas or stack them in a panel).
58
+
59
+ ## Floating board
60
+
61
+ Goal: in the floating sidebar, each unresolved note appears beside its associated block, tracks canvas scroll, and shifts up/down to avoid overlapping with neighbors - all without re-rendering threads as the canvas scrolls.
62
+
63
+ Three layers cooperate:
64
+
65
+ ### 1. `board-store.js` - imperative DOM registry
66
+
67
+ A plain JS module returning a store created via `createBoardStore()` (one per mounted `Notes`). Holds:
68
+
69
+ - `blockRefs: Map<noteId, HTMLElement>` - each note's associated block element.
70
+ - `floatingRefs: Map<noteId, HTMLElement>` - each note's floating DOM node.
71
+ - `idByElement: WeakMap<HTMLElement, noteId>` - reverse lookup for the `ResizeObserver`.
72
+ - `heights: { [noteId]: number }` - observed heights of floating elements.
73
+ - `snapshot: { ... }` - frozen shallow copy of `heights` (for `useSyncExternalStore`).
74
+
75
+ A single shared `ResizeObserver` watches every registered floating element; when a floating note changes height, it updates `heights`, snapshots, and calls every `listener` in the store's `Set`.
76
+
77
+ API:
78
+ - `subscribe(listener)` / `getSnapshot()` - wired to React via `useSyncExternalStore`. Disconnects the observer when the last subscriber leaves.
79
+ - `registerThread(id, blockEl, floatingEl)` - called by each `NoteThread` once mounted. Adds the block ref, swaps the floating ref (unobserving the previous one), starts observing the new one, emits.
80
+ - `unregisterThread(id)` - inverse; called on unmount.
81
+ - `getBlockRects()` - returns a batched snapshot of block `getBoundingClientRect()` values. Batches reads so subsequent CSS writes don't trigger layout thrash.
82
+ - `getFirstBlockElement()` - the first registered block, used to locate the canvas scroll container.
83
+
84
+ The store owns DOM references directly, not through React - floating note height changes must update layout without re-rendering the thread list.
85
+
86
+ ### 2. `useFloatingBoard` - the React bridge (in `hooks.js`)
87
+
88
+ Lives inside `Notes`. Holds one store instance (`useState(createBoardStore)`) and:
89
+
90
+ 1. Subscribes to `heights` via `useSyncExternalStore(store.subscribe, store.getSnapshot)`.
91
+ 2. In a `useEffect` keyed on `threads + heights + selectedNoteId + isFloating + sidebarRef`:
92
+ - Resolves the canvas scroll container by climbing from the first registered block to `.is-root-container` and calling `getScrollContainer()` on it.
93
+ - Schedules a single `requestAnimationFrame` that calls `calculateNotePositions({ threads, selectedNoteId, blockRects: store.getBlockRects(), heights, scrollTop })` (pure function in `utils.js`) and stores the result in React state (`notePositions`).
94
+ - Attaches a capture-phase `scroll` listener on the canvas's `defaultView` that writes a CSS variable `--canvas-scroll` to the sidebar panel. (`window` capture catches scrolls on the document root, which don't bubble.)
95
+ 3. Returns `{ notePositions, registerThread, unregisterThread }` - the positions flow down as props; the two register callbacks flow to each `NoteThread`.
96
+
97
+ ### 3. `calculateNotePositions` - pure layout math (in `utils.js`)
98
+
99
+ Given the list of threads, the currently selected note id, the block rects, the floating heights, and the canvas scroll offset, returns `{ positions: { [noteId]: top } }` where `top` is the final canvas-space y-coordinate for each floating thread.
100
+
101
+ Algorithm, keyed on the selected note as an **anchor**:
102
+
103
+ 1. Anchor the selected note at `blockRect.top + THREAD_ALIGN_OFFSET` (−16). If no selected note, anchor the first thread.
104
+ 2. Walk forward from the anchor: each subsequent thread starts at its block's top; if it would overlap the previous thread's bottom (plus `THREAD_GAP` of 16), push it further down by `OVERLAP_MARGIN` (20).
105
+ 3. Walk backward from the anchor: mirror - push upward into any overlap.
106
+ 4. Convert each final offset into content-space by adding `blockRect.top + scrollTop`.
107
+
108
+ ### 4. `FloatingContainer` - the render shell
109
+
110
+ Renders a `Stack` with `top: floating.y` when in floating mode. CSS uses the `--canvas-scroll` custom property to translate the whole panel in sync with the canvas, so per-thread `top` values stay stable while scrolling.
111
+
112
+ ### Why this shape
113
+
114
+ - `ResizeObserver` is canonical for height changes that must drive layout without polling.
115
+ - `useSyncExternalStore` is the right React 18 primitive for "external mutable source with snapshot" - gives concurrent-mode-safe subscriptions without a provider.
116
+ - The scroll listener updates a CSS variable rather than React state, so scrolling doesn't re-render. Per-note `top` only recomputes when threads, heights, selection, or structural inputs change.
117
+ - Batching `getBoundingClientRect` reads inside the `rAF` and separating them from style writes avoids forced layout.
@@ -16,9 +16,9 @@ import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
16
16
  */
17
17
  import { unlock } from '../../lock-unlock';
18
18
 
19
- const { CommentIconSlotFill } = unlock( blockEditorPrivateApis );
19
+ const { NoteIconSlotFill } = unlock( blockEditorPrivateApis );
20
20
 
21
- const AddCommentMenuItem = ( { clientId, onClick, isDistractionFree } ) => {
21
+ function NoteMenuItem( { clientId, onClick, isDistractionFree } ) {
22
22
  const block = useSelect(
23
23
  ( select ) => {
24
24
  return select( blockEditorStore ).getBlock( clientId );
@@ -61,13 +61,13 @@ const AddCommentMenuItem = ( { clientId, onClick, isDistractionFree } ) => {
61
61
  { __( 'Add note' ) }
62
62
  </MenuItem>
63
63
  );
64
- };
64
+ }
65
65
 
66
- const AddCommentMenuItemFill = ( { onClick, isDistractionFree } ) => {
66
+ export function AddNoteMenuItem( { onClick, isDistractionFree } ) {
67
67
  return (
68
- <CommentIconSlotFill.Fill>
68
+ <NoteIconSlotFill.Fill>
69
69
  { ( { clientId, onClose } ) => (
70
- <AddCommentMenuItem
70
+ <NoteMenuItem
71
71
  clientId={ clientId }
72
72
  isDistractionFree={ isDistractionFree }
73
73
  onClick={ () => {
@@ -76,8 +76,6 @@ const AddCommentMenuItemFill = ( { onClick, isDistractionFree } ) => {
76
76
  } }
77
77
  />
78
78
  ) }
79
- </CommentIconSlotFill.Fill>
79
+ </NoteIconSlotFill.Fill>
80
80
  );
81
- };
82
-
83
- export default AddCommentMenuItemFill;
81
+ }
@@ -1,16 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- import clsx from 'clsx';
5
1
  /**
6
2
  * WordPress dependencies
7
3
  */
8
4
  import { __ } from '@wordpress/i18n';
9
5
  import { useSelect, useDispatch } from '@wordpress/data';
10
- import {
11
- __experimentalHStack as HStack,
12
- __experimentalVStack as VStack,
13
- } from '@wordpress/components';
14
6
  import {
15
7
  store as blockEditorStore,
16
8
  privateApis as blockEditorPrivateApis,
@@ -19,22 +11,16 @@ import {
19
11
  /**
20
12
  * Internal dependencies
21
13
  */
22
- import { unlock } from '../../lock-unlock';
23
- import CommentAuthorInfo from './comment-author-info';
24
- import CommentForm from './comment-form';
25
- import { focusCommentThread, noop } from './utils';
14
+ import { NoteCard } from './note-card';
15
+ import { NoteForm } from './note-form';
16
+ import { FloatingContainer } from './floating-container';
17
+ import { focusNoteThread } from './utils';
26
18
  import { store as editorStore } from '../../store';
19
+ import { unlock } from '../../lock-unlock';
27
20
 
28
21
  const { useBlockElement } = unlock( blockEditorPrivateApis );
29
22
 
30
- export function AddComment( {
31
- onSubmit,
32
- commentSidebarRef,
33
- reflowComments = noop,
34
- isFloating = false,
35
- y,
36
- refs,
37
- } ) {
23
+ export function AddNote( { onSubmit, sidebarRef, floating } ) {
38
24
  const { clientId } = useSelect( ( select ) => {
39
25
  const { getSelectedBlockClientId } = select( blockEditorStore );
40
26
  return {
@@ -49,7 +35,7 @@ export function AddComment( {
49
35
  const { toggleBlockSpotlight } = unlock( useDispatch( blockEditorStore ) );
50
36
  const { selectNote } = unlock( useDispatch( editorStore ) );
51
37
 
52
- const unselectThread = () => {
38
+ const unselectNote = () => {
53
39
  selectNote( undefined );
54
40
  blockElement?.focus();
55
41
  toggleBlockSpotlight( clientId, false );
@@ -60,23 +46,15 @@ export function AddComment( {
60
46
  }
61
47
 
62
48
  return (
63
- <VStack
64
- className={ clsx(
65
- 'editor-collab-sidebar-panel__thread is-selected',
66
- {
67
- 'is-floating': isFloating,
68
- }
69
- ) }
70
- spacing="3"
49
+ <FloatingContainer
50
+ floating={ floating }
51
+ className="editor-collab-sidebar-panel__thread is-selected"
52
+ gap="md"
71
53
  tabIndex={ 0 }
72
54
  aria-label={ __( 'New note' ) }
73
55
  role="treeitem"
74
- ref={ isFloating ? refs.setFloating : undefined }
75
56
  style={
76
- isFloating
77
- ? // Delay showing the floating note box until a Y position is known to prevent blink.
78
- { top: y, opacity: ! y ? 0 : undefined }
79
- : undefined
57
+ floating ? { opacity: ! floating.y ? 0 : undefined } : undefined
80
58
  }
81
59
  onBlur={ ( event ) => {
82
60
  // Don't deselect notes when the browser window/tab loses focus.
@@ -90,20 +68,19 @@ export function AddComment( {
90
68
  selectNote( undefined );
91
69
  } }
92
70
  >
93
- <HStack alignment="left" spacing="3">
94
- <CommentAuthorInfo />
95
- </HStack>
96
- <CommentForm
97
- onSubmit={ async ( inputComment ) => {
98
- const { id } = await onSubmit( { content: inputComment } );
99
- selectNote( id );
100
- focusCommentThread( id, commentSidebarRef.current );
101
- } }
102
- onCancel={ unselectThread }
103
- reflowComments={ reflowComments }
104
- submitButtonText={ __( 'Add note' ) }
105
- labelText={ __( 'New note' ) }
106
- />
107
- </VStack>
71
+ <NoteCard>
72
+ <NoteForm
73
+ onSubmit={ async ( inputComment ) => {
74
+ const { id } = await onSubmit( {
75
+ content: inputComment,
76
+ } );
77
+ selectNote( id );
78
+ focusNoteThread( id, sidebarRef.current );
79
+ } }
80
+ onCancel={ unselectNote }
81
+ labels={ { input: __( 'New note' ) } }
82
+ />
83
+ </NoteCard>
84
+ </FloatingContainer>
108
85
  );
109
86
  }
@@ -0,0 +1,85 @@
1
+ export function createBoardStore() {
2
+ const listeners = new Set();
3
+ const blockRefs = new Map();
4
+ const floatingRefs = new Map();
5
+ const idByElement = new WeakMap();
6
+ const heights = {};
7
+ let snapshot = {};
8
+
9
+ function emit() {
10
+ snapshot = { ...heights };
11
+ for ( const listener of listeners ) {
12
+ listener();
13
+ }
14
+ }
15
+
16
+ const observer = new window.ResizeObserver( ( entries ) => {
17
+ let changed = false;
18
+ for ( const entry of entries ) {
19
+ const id = idByElement.get( entry.target );
20
+ const newHeight = entry.borderBoxSize[ 0 ].blockSize;
21
+ if ( heights[ id ] !== newHeight ) {
22
+ heights[ id ] = newHeight;
23
+ changed = true;
24
+ }
25
+ }
26
+ if ( changed ) {
27
+ emit();
28
+ }
29
+ } );
30
+
31
+ return {
32
+ subscribe( listener ) {
33
+ listeners.add( listener );
34
+ return () => {
35
+ listeners.delete( listener );
36
+ if ( listeners.size === 0 ) {
37
+ observer.disconnect();
38
+ }
39
+ };
40
+ },
41
+
42
+ getSnapshot() {
43
+ return snapshot;
44
+ },
45
+
46
+ registerThread( id, blockEl, floatingEl ) {
47
+ blockRefs.set( id, blockEl );
48
+ const prev = floatingRefs.get( id );
49
+ if ( prev && prev !== floatingEl ) {
50
+ observer.unobserve( prev );
51
+ idByElement.delete( prev );
52
+ }
53
+ if ( floatingEl ) {
54
+ floatingRefs.set( id, floatingEl );
55
+ idByElement.set( floatingEl, id );
56
+ observer.observe( floatingEl );
57
+ }
58
+ emit();
59
+ },
60
+
61
+ unregisterThread( id ) {
62
+ blockRefs.delete( id );
63
+ const prev = floatingRefs.get( id );
64
+ if ( prev ) {
65
+ observer.unobserve( prev );
66
+ idByElement.delete( prev );
67
+ floatingRefs.delete( id );
68
+ }
69
+ delete heights[ id ];
70
+ },
71
+
72
+ getBlockRects() {
73
+ // Batch all rect reads before any writes to avoid layout thrashing.
74
+ return Object.fromEntries(
75
+ Array.from( blockRefs ).flatMap( ( [ id, el ] ) =>
76
+ el ? [ [ id, el.getBoundingClientRect() ] ] : []
77
+ )
78
+ );
79
+ },
80
+
81
+ getFirstBlockElement() {
82
+ return blockRefs.values().next().value ?? null;
83
+ },
84
+ };
85
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { Stack } from '@wordpress/ui';
10
+
11
+ export function FloatingContainer( {
12
+ floating,
13
+ className,
14
+ style,
15
+ children,
16
+ ...props
17
+ } ) {
18
+ const isFloating = !! floating;
19
+ return (
20
+ <Stack
21
+ direction="column"
22
+ className={ clsx( className, { 'is-floating': isFloating } ) }
23
+ ref={ isFloating ? floating.ref : undefined }
24
+ style={ isFloating ? { top: floating.y, ...style } : style }
25
+ { ...props }
26
+ >
27
+ { children }
28
+ </Stack>
29
+ );
30
+ }