@wordpress/editor 14.10.0 → 14.12.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 (366) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -10
  3. package/build/bindings/post-meta.js +2 -1
  4. package/build/bindings/post-meta.js.map +1 -1
  5. package/build/components/collab-sidebar/add-comment.js +119 -0
  6. package/build/components/collab-sidebar/add-comment.js.map +1 -0
  7. package/build/components/collab-sidebar/comment-button-toolbar.js +37 -0
  8. package/build/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
  9. package/build/components/collab-sidebar/comment-button.js +37 -0
  10. package/build/components/collab-sidebar/comment-button.js.map +1 -0
  11. package/build/components/collab-sidebar/comments.js +321 -0
  12. package/build/components/collab-sidebar/comments.js.map +1 -0
  13. package/build/components/collab-sidebar/constants.js +8 -0
  14. package/build/components/collab-sidebar/constants.js.map +1 -0
  15. package/build/components/collab-sidebar/index.js +274 -0
  16. package/build/components/collab-sidebar/index.js.map +1 -0
  17. package/build/components/collab-sidebar/utils.js +16 -0
  18. package/build/components/collab-sidebar/utils.js.map +1 -0
  19. package/build/components/commands/index.js +148 -40
  20. package/build/components/commands/index.js.map +1 -1
  21. package/build/components/create-template-part-modal/index.js +1 -0
  22. package/build/components/create-template-part-modal/index.js.map +1 -1
  23. package/build/components/document-bar/index.js +17 -10
  24. package/build/components/document-bar/index.js.map +1 -1
  25. package/build/components/document-tools/index.js +7 -7
  26. package/build/components/document-tools/index.js.map +1 -1
  27. package/build/components/editor-interface/index.js +4 -4
  28. package/build/components/editor-interface/index.js.map +1 -1
  29. package/build/components/entities-saved-states/index.js +1 -1
  30. package/build/components/entities-saved-states/index.js.map +1 -1
  31. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  32. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  33. package/build/components/global-styles-provider/index.js +25 -3
  34. package/build/components/global-styles-provider/index.js.map +1 -1
  35. package/build/components/header/index.js +12 -11
  36. package/build/components/header/index.js.map +1 -1
  37. package/build/components/inserter-sidebar/index.js +2 -2
  38. package/build/components/inserter-sidebar/index.js.map +1 -1
  39. package/build/components/more-menu/index.js +9 -7
  40. package/build/components/more-menu/index.js.map +1 -1
  41. package/build/components/page-attributes/parent.js +5 -5
  42. package/build/components/page-attributes/parent.js.map +1 -1
  43. package/build/components/plugin-more-menu-item/index.js +13 -11
  44. package/build/components/plugin-more-menu-item/index.js.map +1 -1
  45. package/build/components/plugin-preview-menu-item/index.js +15 -13
  46. package/build/components/plugin-preview-menu-item/index.js.map +1 -1
  47. package/build/components/plugin-sidebar/index.js +0 -15
  48. package/build/components/plugin-sidebar/index.js.map +1 -1
  49. package/build/components/post-actions/index.js +5 -5
  50. package/build/components/post-actions/index.js.map +1 -1
  51. package/build/components/post-author/panel.js +4 -4
  52. package/build/components/post-author/panel.js.map +1 -1
  53. package/build/components/post-card-panel/index.js +7 -36
  54. package/build/components/post-card-panel/index.js.map +1 -1
  55. package/build/components/post-content-information/index.js +1 -2
  56. package/build/components/post-content-information/index.js.map +1 -1
  57. package/build/components/post-featured-image/index.js +26 -7
  58. package/build/components/post-featured-image/index.js.map +1 -1
  59. package/build/components/post-last-revision/index.js +1 -1
  60. package/build/components/post-last-revision/index.js.map +1 -1
  61. package/build/components/post-schedule/label.js +1 -1
  62. package/build/components/post-schedule/label.js.map +1 -1
  63. package/build/components/post-taxonomies/flat-term-selector.js +11 -1
  64. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  65. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  66. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  67. package/build/components/post-template/swap-template-button.js +0 -3
  68. package/build/components/post-template/swap-template-button.js.map +1 -1
  69. package/build/components/post-transform-panel/index.js +0 -3
  70. package/build/components/post-transform-panel/index.js.map +1 -1
  71. package/build/components/post-url/index.js +1 -1
  72. package/build/components/post-url/index.js.map +1 -1
  73. package/build/components/post-url/panel.js +3 -3
  74. package/build/components/post-url/panel.js.map +1 -1
  75. package/build/components/preferences-modal/index.js +26 -22
  76. package/build/components/preferences-modal/index.js.map +1 -1
  77. package/build/components/preview-dropdown/index.js +23 -8
  78. package/build/components/preview-dropdown/index.js.map +1 -1
  79. package/build/components/provider/index.js +10 -12
  80. package/build/components/provider/index.js.map +1 -1
  81. package/build/components/provider/use-block-editor-settings.js +11 -10
  82. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  83. package/build/components/sidebar/header.js +2 -1
  84. package/build/components/sidebar/header.js.map +1 -1
  85. package/build/components/sidebar/index.js +3 -3
  86. package/build/components/sidebar/index.js.map +1 -1
  87. package/build/components/sidebar/post-summary.js +2 -2
  88. package/build/components/sidebar/post-summary.js.map +1 -1
  89. package/build/components/start-page-options/index.js +0 -3
  90. package/build/components/start-page-options/index.js.map +1 -1
  91. package/build/components/start-template-options/index.js +0 -3
  92. package/build/components/start-template-options/index.js.map +1 -1
  93. package/build/components/time-to-read/index.js +2 -2
  94. package/build/components/time-to-read/index.js.map +1 -1
  95. package/build/components/visual-editor/index.js +30 -29
  96. package/build/components/visual-editor/index.js.map +1 -1
  97. package/build/components/visual-editor/use-zoom-out-mode-exit.js +52 -0
  98. package/build/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
  99. package/build/components/zoom-out-toggle/index.js +37 -5
  100. package/build/components/zoom-out-toggle/index.js.map +1 -1
  101. package/build/dataviews/actions/duplicate-template-part.js +2 -2
  102. package/build/dataviews/actions/duplicate-template-part.js.map +1 -1
  103. package/build/store/actions.js +68 -18
  104. package/build/store/actions.js.map +1 -1
  105. package/build/store/constants.js +0 -2
  106. package/build/store/constants.js.map +1 -1
  107. package/build/store/index.js +0 -4
  108. package/build/store/index.js.map +1 -1
  109. package/build/store/private-actions.js +2 -2
  110. package/build/store/private-actions.js.map +1 -1
  111. package/build/store/selectors.js +5 -4
  112. package/build/store/selectors.js.map +1 -1
  113. package/build/utils/pageTypeBadge.js +51 -0
  114. package/build/utils/pageTypeBadge.js.map +1 -0
  115. package/build/utils/terms.js +2 -2
  116. package/build/utils/terms.js.map +1 -1
  117. package/build-module/bindings/post-meta.js +2 -1
  118. package/build-module/bindings/post-meta.js.map +1 -1
  119. package/build-module/components/collab-sidebar/add-comment.js +113 -0
  120. package/build-module/components/collab-sidebar/add-comment.js.map +1 -0
  121. package/build-module/components/collab-sidebar/comment-button-toolbar.js +30 -0
  122. package/build-module/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
  123. package/build-module/components/collab-sidebar/comment-button.js +30 -0
  124. package/build-module/components/collab-sidebar/comment-button.js.map +1 -0
  125. package/build-module/components/collab-sidebar/comments.js +314 -0
  126. package/build-module/components/collab-sidebar/comments.js.map +1 -0
  127. package/build-module/components/collab-sidebar/constants.js +2 -0
  128. package/build-module/components/collab-sidebar/constants.js.map +1 -0
  129. package/build-module/components/collab-sidebar/index.js +266 -0
  130. package/build-module/components/collab-sidebar/index.js.map +1 -0
  131. package/build-module/components/collab-sidebar/utils.js +10 -0
  132. package/build-module/components/collab-sidebar/utils.js.map +1 -0
  133. package/build-module/components/commands/index.js +151 -44
  134. package/build-module/components/commands/index.js.map +1 -1
  135. package/build-module/components/create-template-part-modal/index.js +1 -0
  136. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  137. package/build-module/components/document-bar/index.js +19 -12
  138. package/build-module/components/document-bar/index.js.map +1 -1
  139. package/build-module/components/document-tools/index.js +8 -8
  140. package/build-module/components/document-tools/index.js.map +1 -1
  141. package/build-module/components/editor-interface/index.js +4 -4
  142. package/build-module/components/editor-interface/index.js.map +1 -1
  143. package/build-module/components/entities-saved-states/index.js +1 -1
  144. package/build-module/components/entities-saved-states/index.js.map +1 -1
  145. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  146. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  147. package/build-module/components/global-styles-provider/index.js +25 -3
  148. package/build-module/components/global-styles-provider/index.js.map +1 -1
  149. package/build-module/components/header/index.js +12 -11
  150. package/build-module/components/header/index.js.map +1 -1
  151. package/build-module/components/inserter-sidebar/index.js +2 -2
  152. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  153. package/build-module/components/more-menu/index.js +9 -7
  154. package/build-module/components/more-menu/index.js.map +1 -1
  155. package/build-module/components/page-attributes/parent.js +5 -5
  156. package/build-module/components/page-attributes/parent.js.map +1 -1
  157. package/build-module/components/plugin-more-menu-item/index.js +12 -10
  158. package/build-module/components/plugin-more-menu-item/index.js.map +1 -1
  159. package/build-module/components/plugin-preview-menu-item/index.js +14 -12
  160. package/build-module/components/plugin-preview-menu-item/index.js.map +1 -1
  161. package/build-module/components/plugin-sidebar/index.js +0 -15
  162. package/build-module/components/plugin-sidebar/index.js.map +1 -1
  163. package/build-module/components/post-actions/index.js +5 -5
  164. package/build-module/components/post-actions/index.js.map +1 -1
  165. package/build-module/components/post-author/panel.js +4 -4
  166. package/build-module/components/post-author/panel.js.map +1 -1
  167. package/build-module/components/post-card-panel/index.js +8 -36
  168. package/build-module/components/post-card-panel/index.js.map +1 -1
  169. package/build-module/components/post-content-information/index.js +1 -2
  170. package/build-module/components/post-content-information/index.js.map +1 -1
  171. package/build-module/components/post-featured-image/index.js +26 -7
  172. package/build-module/components/post-featured-image/index.js.map +1 -1
  173. package/build-module/components/post-last-revision/index.js +1 -1
  174. package/build-module/components/post-last-revision/index.js.map +1 -1
  175. package/build-module/components/post-schedule/label.js +1 -1
  176. package/build-module/components/post-schedule/label.js.map +1 -1
  177. package/build-module/components/post-taxonomies/flat-term-selector.js +14 -4
  178. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  179. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  180. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  181. package/build-module/components/post-template/swap-template-button.js +0 -3
  182. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  183. package/build-module/components/post-transform-panel/index.js +0 -3
  184. package/build-module/components/post-transform-panel/index.js.map +1 -1
  185. package/build-module/components/post-url/index.js +1 -1
  186. package/build-module/components/post-url/index.js.map +1 -1
  187. package/build-module/components/post-url/panel.js +3 -3
  188. package/build-module/components/post-url/panel.js.map +1 -1
  189. package/build-module/components/preferences-modal/index.js +26 -22
  190. package/build-module/components/preferences-modal/index.js.map +1 -1
  191. package/build-module/components/preview-dropdown/index.js +24 -9
  192. package/build-module/components/preview-dropdown/index.js.map +1 -1
  193. package/build-module/components/provider/index.js +10 -12
  194. package/build-module/components/provider/index.js.map +1 -1
  195. package/build-module/components/provider/use-block-editor-settings.js +12 -11
  196. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  197. package/build-module/components/sidebar/header.js +2 -1
  198. package/build-module/components/sidebar/header.js.map +1 -1
  199. package/build-module/components/sidebar/index.js +4 -4
  200. package/build-module/components/sidebar/index.js.map +1 -1
  201. package/build-module/components/sidebar/post-summary.js +2 -2
  202. package/build-module/components/sidebar/post-summary.js.map +1 -1
  203. package/build-module/components/start-page-options/index.js +0 -3
  204. package/build-module/components/start-page-options/index.js.map +1 -1
  205. package/build-module/components/start-template-options/index.js +0 -3
  206. package/build-module/components/start-template-options/index.js.map +1 -1
  207. package/build-module/components/time-to-read/index.js +2 -2
  208. package/build-module/components/time-to-read/index.js.map +1 -1
  209. package/build-module/components/visual-editor/index.js +31 -30
  210. package/build-module/components/visual-editor/index.js.map +1 -1
  211. package/build-module/components/visual-editor/use-zoom-out-mode-exit.js +46 -0
  212. package/build-module/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
  213. package/build-module/components/zoom-out-toggle/index.js +37 -5
  214. package/build-module/components/zoom-out-toggle/index.js.map +1 -1
  215. package/build-module/dataviews/actions/duplicate-template-part.js +3 -3
  216. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -1
  217. package/build-module/store/actions.js +64 -16
  218. package/build-module/store/actions.js.map +1 -1
  219. package/build-module/store/constants.js +0 -2
  220. package/build-module/store/constants.js.map +1 -1
  221. package/build-module/store/index.js +0 -4
  222. package/build-module/store/index.js.map +1 -1
  223. package/build-module/store/private-actions.js +3 -3
  224. package/build-module/store/private-actions.js.map +1 -1
  225. package/build-module/store/selectors.js +5 -4
  226. package/build-module/store/selectors.js.map +1 -1
  227. package/build-module/utils/pageTypeBadge.js +45 -0
  228. package/build-module/utils/pageTypeBadge.js.map +1 -0
  229. package/build-module/utils/terms.js +2 -2
  230. package/build-module/utils/terms.js.map +1 -1
  231. package/build-style/style-rtl.css +118 -60
  232. package/build-style/style.css +118 -60
  233. package/build-types/bindings/post-meta.d.ts.map +1 -1
  234. package/build-types/components/collab-sidebar/add-comment.d.ts +15 -0
  235. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
  236. package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts +5 -0
  237. package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts.map +1 -0
  238. package/build-types/components/collab-sidebar/comment-button.d.ts +5 -0
  239. package/build-types/components/collab-sidebar/comment-button.d.ts.map +1 -0
  240. package/build-types/components/collab-sidebar/comments.d.ts +19 -0
  241. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
  242. package/build-types/components/collab-sidebar/constants.d.ts +2 -0
  243. package/build-types/components/collab-sidebar/constants.d.ts.map +1 -0
  244. package/build-types/components/collab-sidebar/index.d.ts +5 -0
  245. package/build-types/components/collab-sidebar/index.d.ts.map +1 -0
  246. package/build-types/components/collab-sidebar/utils.d.ts +8 -0
  247. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -0
  248. package/build-types/components/commands/index.d.ts.map +1 -1
  249. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  250. package/build-types/components/document-bar/index.d.ts.map +1 -1
  251. package/build-types/components/document-tools/index.d.ts.map +1 -1
  252. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  253. package/build-types/components/header/index.d.ts +1 -2
  254. package/build-types/components/header/index.d.ts.map +1 -1
  255. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  256. package/build-types/components/more-menu/index.d.ts.map +1 -1
  257. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  258. package/build-types/components/plugin-more-menu-item/index.d.ts +62 -2
  259. package/build-types/components/plugin-more-menu-item/index.d.ts.map +1 -1
  260. package/build-types/components/plugin-preview-menu-item/index.d.ts +41 -2
  261. package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -1
  262. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  263. package/build-types/components/post-author/panel.d.ts.map +1 -1
  264. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  265. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  266. package/build-types/components/post-template/hooks.d.ts +2 -2
  267. package/build-types/components/post-template/swap-template-button.d.ts.map +1 -1
  268. package/build-types/components/post-transform-panel/index.d.ts.map +1 -1
  269. package/build-types/components/preferences-modal/index.d.ts.map +1 -1
  270. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  271. package/build-types/components/provider/index.d.ts.map +1 -1
  272. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  273. package/build-types/components/sidebar/index.d.ts.map +1 -1
  274. package/build-types/components/start-page-options/index.d.ts.map +1 -1
  275. package/build-types/components/start-template-options/index.d.ts.map +1 -1
  276. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  277. package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts +5 -0
  278. package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts.map +1 -0
  279. package/build-types/components/zoom-out-toggle/index.d.ts +3 -1
  280. package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
  281. package/build-types/dataviews/store/reducer.d.ts +5 -2
  282. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  283. package/build-types/lock-unlock.d.ts +2 -2
  284. package/build-types/store/actions.d.ts +9 -1
  285. package/build-types/store/actions.d.ts.map +1 -1
  286. package/build-types/store/constants.d.ts +0 -2
  287. package/build-types/store/constants.d.ts.map +1 -1
  288. package/build-types/store/index.d.ts +9 -11
  289. package/build-types/store/index.d.ts.map +1 -1
  290. package/build-types/store/reducer.d.ts +24 -4
  291. package/build-types/store/reducer.d.ts.map +1 -1
  292. package/build-types/store/selectors.d.ts +3 -3
  293. package/build-types/store/selectors.d.ts.map +1 -1
  294. package/build-types/utils/pageTypeBadge.d.ts +5 -0
  295. package/build-types/utils/pageTypeBadge.d.ts.map +1 -0
  296. package/build-types/utils/terms.d.ts.map +1 -1
  297. package/package.json +39 -37
  298. package/src/bindings/post-meta.js +1 -0
  299. package/src/components/collab-sidebar/add-comment.js +121 -0
  300. package/src/components/collab-sidebar/comment-button-toolbar.js +29 -0
  301. package/src/components/collab-sidebar/comment-button.js +31 -0
  302. package/src/components/collab-sidebar/comments.js +404 -0
  303. package/src/components/collab-sidebar/constants.js +1 -0
  304. package/src/components/collab-sidebar/index.js +298 -0
  305. package/src/components/collab-sidebar/style.scss +111 -0
  306. package/src/components/collab-sidebar/utils.js +9 -0
  307. package/src/components/commands/index.js +390 -268
  308. package/src/components/create-template-part-modal/index.js +1 -0
  309. package/src/components/document-bar/index.js +25 -8
  310. package/src/components/document-bar/style.scss +13 -4
  311. package/src/components/document-tools/index.js +8 -8
  312. package/src/components/editor-interface/index.js +4 -4
  313. package/src/components/entities-saved-states/index.js +2 -2
  314. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  315. package/src/components/global-styles-provider/index.js +32 -6
  316. package/src/components/header/index.js +20 -10
  317. package/src/components/inserter-sidebar/index.js +3 -6
  318. package/src/components/more-menu/index.js +12 -7
  319. package/src/components/page-attributes/parent.js +6 -4
  320. package/src/components/plugin-more-menu-item/index.js +12 -11
  321. package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +1 -1
  322. package/src/components/plugin-preview-menu-item/index.js +14 -13
  323. package/src/components/plugin-sidebar/index.js +0 -13
  324. package/src/components/post-actions/index.js +8 -11
  325. package/src/components/post-author/panel.js +4 -2
  326. package/src/components/post-card-panel/index.js +9 -43
  327. package/src/components/post-card-panel/style.scss +1 -9
  328. package/src/components/post-content-information/index.js +1 -1
  329. package/src/components/post-featured-image/index.js +31 -16
  330. package/src/components/post-featured-image/style.scss +5 -2
  331. package/src/components/post-last-revision/index.js +1 -1
  332. package/src/components/post-schedule/label.js +1 -1
  333. package/src/components/post-sticky/test/index.js +6 -6
  334. package/src/components/post-taxonomies/flat-term-selector.js +15 -4
  335. package/src/components/post-taxonomies/hierarchical-term-selector.js +2 -2
  336. package/src/components/post-template/swap-template-button.js +0 -3
  337. package/src/components/post-transform-panel/index.js +0 -3
  338. package/src/components/post-url/index.js +1 -1
  339. package/src/components/post-url/panel.js +4 -2
  340. package/src/components/preferences-modal/index.js +26 -19
  341. package/src/components/preferences-modal/test/index.js +1 -1
  342. package/src/components/preview-dropdown/index.js +45 -18
  343. package/src/components/provider/index.js +31 -24
  344. package/src/components/provider/use-block-editor-settings.js +11 -10
  345. package/src/components/sidebar/header.js +3 -2
  346. package/src/components/sidebar/index.js +5 -3
  347. package/src/components/sidebar/post-summary.js +1 -1
  348. package/src/components/sidebar/style.scss +1 -3
  349. package/src/components/start-page-options/index.js +0 -3
  350. package/src/components/start-template-options/index.js +0 -3
  351. package/src/components/time-to-read/index.js +3 -3
  352. package/src/components/visual-editor/index.js +39 -42
  353. package/src/components/visual-editor/style.scss +11 -0
  354. package/src/components/visual-editor/use-zoom-out-mode-exit.js +49 -0
  355. package/src/components/zoom-out-toggle/index.js +39 -5
  356. package/src/dataviews/actions/duplicate-template-part.tsx +3 -3
  357. package/src/store/actions.js +113 -34
  358. package/src/store/constants.ts +0 -2
  359. package/src/store/index.js +0 -4
  360. package/src/store/private-actions.js +3 -3
  361. package/src/store/selectors.js +5 -4
  362. package/src/style.scss +1 -0
  363. package/src/utils/pageTypeBadge.js +41 -0
  364. package/src/utils/terms.js +4 -2
  365. package/src/utils/test/terms.js +3 -3
  366. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,121 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __, _x } from '@wordpress/i18n';
5
+ import { useSelect } from '@wordpress/data';
6
+ import { useState, useEffect } from '@wordpress/element';
7
+ import {
8
+ __experimentalHStack as HStack,
9
+ __experimentalVStack as VStack,
10
+ Button,
11
+ TextControl,
12
+ } from '@wordpress/components';
13
+ import { store as blockEditorStore } from '@wordpress/block-editor';
14
+ import { store as coreStore } from '@wordpress/core-data';
15
+
16
+ /**
17
+ * Internal dependencies
18
+ */
19
+ import { sanitizeCommentString } from './utils';
20
+
21
+ /**
22
+ * Renders the UI for adding a comment in the Gutenberg editor's collaboration sidebar.
23
+ *
24
+ * @param {Object} props - The component props.
25
+ * @param {Function} props.onSubmit - A callback function to be called when the user submits a comment.
26
+ * @param {boolean} props.showCommentBoard - The function to edit the comment.
27
+ * @param {Function} props.setShowCommentBoard - The function to delete the comment.
28
+ * @return {JSX.Element} The rendered comment input UI.
29
+ */
30
+ export function AddComment( {
31
+ onSubmit,
32
+ showCommentBoard,
33
+ setShowCommentBoard,
34
+ } ) {
35
+ // State to manage the comment thread.
36
+ const [ inputComment, setInputComment ] = useState( '' );
37
+
38
+ const { defaultAvatar, clientId, blockCommentId, currentUser } = useSelect(
39
+ ( select ) => {
40
+ const { getSettings, getSelectedBlock } =
41
+ select( blockEditorStore );
42
+ const { __experimentalDiscussionSettings } = getSettings();
43
+ const selectedBlock = getSelectedBlock();
44
+ const userData = select( coreStore ).getCurrentUser();
45
+ return {
46
+ defaultAvatar: __experimentalDiscussionSettings?.avatarURL,
47
+ clientId: selectedBlock?.clientId,
48
+ blockCommentId: selectedBlock?.attributes?.blockCommentId,
49
+ currentUser: userData,
50
+ };
51
+ },
52
+ []
53
+ );
54
+
55
+ const userAvatar =
56
+ currentUser && currentUser.avatar_urls && currentUser.avatar_urls[ 48 ]
57
+ ? currentUser.avatar_urls[ 48 ]
58
+ : defaultAvatar;
59
+
60
+ useEffect( () => {
61
+ setInputComment( '' );
62
+ }, [ clientId ] );
63
+
64
+ const handleCancel = () => {
65
+ setShowCommentBoard( false );
66
+ setInputComment( '' );
67
+ };
68
+
69
+ if ( ! showCommentBoard || ! clientId || undefined !== blockCommentId ) {
70
+ return null;
71
+ }
72
+
73
+ return (
74
+ <VStack
75
+ spacing="3"
76
+ className="editor-collab-sidebar-panel__thread editor-collab-sidebar-panel__active-thread"
77
+ >
78
+ <HStack alignment="left" spacing="3">
79
+ <img
80
+ src={ userAvatar }
81
+ // translators: alt text for user avatar image
82
+ alt={ __( 'User Avatar' ) }
83
+ className="editor-collab-sidebar-panel__user-avatar"
84
+ width={ 32 }
85
+ height={ 32 }
86
+ />
87
+ <span className="editor-collab-sidebar-panel__user-name">
88
+ { currentUser?.name ?? '' }
89
+ </span>
90
+ </HStack>
91
+ <TextControl
92
+ __next40pxDefaultSize
93
+ __nextHasNoMarginBottom
94
+ value={ inputComment }
95
+ onChange={ setInputComment }
96
+ placeholder={ _x( 'Comment', 'noun' ) }
97
+ />
98
+ <HStack alignment="right" spacing="3">
99
+ <Button
100
+ __next40pxDefaultSize
101
+ variant="tertiary"
102
+ text={ _x( 'Cancel', 'Cancel comment button' ) }
103
+ onClick={ handleCancel }
104
+ />
105
+ <Button
106
+ __next40pxDefaultSize
107
+ accessibleWhenDisabled
108
+ variant="primary"
109
+ text={ _x( 'Comment', 'Add comment button' ) }
110
+ disabled={
111
+ 0 === sanitizeCommentString( inputComment ).length
112
+ }
113
+ onClick={ () => {
114
+ onSubmit( inputComment );
115
+ setInputComment( '' );
116
+ } }
117
+ />
118
+ </HStack>
119
+ </VStack>
120
+ );
121
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { ToolbarButton } from '@wordpress/components';
5
+ import { _x } from '@wordpress/i18n';
6
+ import { comment as commentIcon } from '@wordpress/icons';
7
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { unlock } from '../../lock-unlock';
13
+
14
+ const { __unstableCommentIconToolbarFill } = unlock( blockEditorPrivateApis );
15
+
16
+ const AddCommentToolbarButton = ( { onClick } ) => {
17
+ return (
18
+ <__unstableCommentIconToolbarFill>
19
+ <ToolbarButton
20
+ accessibleWhenDisabled
21
+ icon={ commentIcon }
22
+ label={ _x( 'Comment', 'View comment' ) }
23
+ onClick={ onClick }
24
+ />
25
+ </__unstableCommentIconToolbarFill>
26
+ );
27
+ };
28
+
29
+ export default AddCommentToolbarButton;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { MenuItem } from '@wordpress/components';
5
+ import { _x } from '@wordpress/i18n';
6
+ import { comment as commentIcon } from '@wordpress/icons';
7
+
8
+ import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
9
+
10
+ /**
11
+ * Internal dependencies
12
+ */
13
+ import { unlock } from '../../lock-unlock';
14
+
15
+ const { __unstableCommentIconFill } = unlock( blockEditorPrivateApis );
16
+
17
+ const AddCommentButton = ( { onClick } ) => {
18
+ return (
19
+ <__unstableCommentIconFill>
20
+ <MenuItem
21
+ icon={ commentIcon }
22
+ onClick={ onClick }
23
+ aria-haspopup="dialog"
24
+ >
25
+ { _x( 'Comment', 'Add comment button' ) }
26
+ </MenuItem>
27
+ </__unstableCommentIconFill>
28
+ );
29
+ };
30
+
31
+ export default AddCommentButton;
@@ -0,0 +1,404 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import clsx from 'clsx';
5
+
6
+ /**
7
+ * WordPress dependencies
8
+ */
9
+ import { useState, RawHTML } from '@wordpress/element';
10
+ import {
11
+ __experimentalHStack as HStack,
12
+ __experimentalVStack as VStack,
13
+ __experimentalConfirmDialog as ConfirmDialog,
14
+ Button,
15
+ DropdownMenu,
16
+ TextareaControl,
17
+ Tooltip,
18
+ } from '@wordpress/components';
19
+ import {
20
+ dateI18n,
21
+ format,
22
+ getSettings as getDateSettings,
23
+ } from '@wordpress/date';
24
+ import { Icon, check, published, moreVertical } from '@wordpress/icons';
25
+ import { __, _x } from '@wordpress/i18n';
26
+ import { useSelect } from '@wordpress/data';
27
+ import { useEntityProp } from '@wordpress/core-data';
28
+ import { store as blockEditorStore } from '@wordpress/block-editor';
29
+
30
+ /**
31
+ * Internal dependencies
32
+ */
33
+ import { sanitizeCommentString } from './utils';
34
+
35
+ /**
36
+ * Renders the Comments component.
37
+ *
38
+ * @param {Object} props - The component props.
39
+ * @param {Array} props.threads - The array of comment threads.
40
+ * @param {Function} props.onEditComment - The function to handle comment editing.
41
+ * @param {Function} props.onAddReply - The function to add a reply to a comment.
42
+ * @param {Function} props.onCommentDelete - The function to delete a comment.
43
+ * @param {Function} props.onCommentResolve - The function to mark a comment as resolved.
44
+ * @return {JSX.Element} The rendered Comments component.
45
+ */
46
+ export function Comments( {
47
+ threads,
48
+ onEditComment,
49
+ onAddReply,
50
+ onCommentDelete,
51
+ onCommentResolve,
52
+ } ) {
53
+ const [ actionState, setActionState ] = useState( false );
54
+ const [ isConfirmDialogOpen, setIsConfirmDialogOpen ] = useState( false );
55
+
56
+ const handleConfirmDelete = () => {
57
+ onCommentDelete( actionState.id );
58
+ setActionState( false );
59
+ setIsConfirmDialogOpen( false );
60
+ };
61
+
62
+ const handleConfirmResolve = () => {
63
+ onCommentResolve( actionState.id );
64
+ setActionState( false );
65
+ setIsConfirmDialogOpen( false );
66
+ };
67
+
68
+ const handleCancelDelete = () => {
69
+ setActionState( false );
70
+ setIsConfirmDialogOpen( false );
71
+ };
72
+
73
+ const blockCommentId = useSelect( ( select ) => {
74
+ const clientID = select( blockEditorStore ).getSelectedBlockClientId();
75
+ return (
76
+ select( blockEditorStore ).getBlock( clientID )?.attributes
77
+ ?.blockCommentId ?? false
78
+ );
79
+ }, [] );
80
+
81
+ const CommentBoard = ( { thread, parentThread } ) => {
82
+ return (
83
+ <>
84
+ <CommentHeader
85
+ thread={ thread }
86
+ onResolve={ () => {
87
+ setActionState( {
88
+ action: 'resolve',
89
+ id: parentThread?.id ?? thread.id,
90
+ } );
91
+ setIsConfirmDialogOpen( true );
92
+ } }
93
+ onEdit={ () =>
94
+ setActionState( { action: 'edit', id: thread.id } )
95
+ }
96
+ onDelete={ () => {
97
+ setActionState( { action: 'delete', id: thread.id } );
98
+ setIsConfirmDialogOpen( true );
99
+ } }
100
+ onReply={
101
+ ! parentThread
102
+ ? () =>
103
+ setActionState( {
104
+ action: 'reply',
105
+ id: thread.id,
106
+ } )
107
+ : undefined
108
+ }
109
+ status={ parentThread?.status ?? thread.status }
110
+ />
111
+ <HStack
112
+ alignment="left"
113
+ spacing="3"
114
+ justify="flex-start"
115
+ className="editor-collab-sidebar-panel__user-comment"
116
+ >
117
+ <VStack
118
+ spacing="3"
119
+ className="editor-collab-sidebar-panel__comment-field"
120
+ >
121
+ { 'edit' === actionState?.action &&
122
+ thread.id === actionState?.id && (
123
+ <CommentForm
124
+ onSubmit={ ( value ) => {
125
+ onEditComment( thread.id, value );
126
+ setActionState( false );
127
+ } }
128
+ onCancel={ () => setActionState( false ) }
129
+ thread={ thread }
130
+ />
131
+ ) }
132
+ { ( ! actionState ||
133
+ 'edit' !== actionState?.action ) && (
134
+ <RawHTML>{ thread?.content?.raw }</RawHTML>
135
+ ) }
136
+ </VStack>
137
+ </HStack>
138
+ { 'resolve' === actionState?.action &&
139
+ thread.id === actionState?.id && (
140
+ <ConfirmDialog
141
+ isOpen={ isConfirmDialogOpen }
142
+ onConfirm={ handleConfirmResolve }
143
+ onCancel={ handleCancelDelete }
144
+ confirmButtonText="Yes"
145
+ cancelButtonText="No"
146
+ >
147
+ {
148
+ // translators: message displayed when confirming an action
149
+ __(
150
+ 'Are you sure you want to mark this comment as resolved?'
151
+ )
152
+ }
153
+ </ConfirmDialog>
154
+ ) }
155
+ { 'delete' === actionState?.action &&
156
+ thread.id === actionState?.id && (
157
+ <ConfirmDialog
158
+ isOpen={ isConfirmDialogOpen }
159
+ onConfirm={ handleConfirmDelete }
160
+ onCancel={ handleCancelDelete }
161
+ confirmButtonText="Yes"
162
+ cancelButtonText="No"
163
+ >
164
+ {
165
+ // translators: message displayed when confirming an action
166
+ __(
167
+ 'Are you sure you want to delete this comment?'
168
+ )
169
+ }
170
+ </ConfirmDialog>
171
+ ) }
172
+ </>
173
+ );
174
+ };
175
+
176
+ return (
177
+ <>
178
+ {
179
+ // If there are no comments, show a message indicating no comments are available.
180
+ ( ! Array.isArray( threads ) || threads.length === 0 ) && (
181
+ <VStack
182
+ alignment="left"
183
+ className="editor-collab-sidebar-panel__thread"
184
+ justify="flex-start"
185
+ spacing="3"
186
+ >
187
+ {
188
+ // translators: message displayed when there are no comments available
189
+ __( 'No comments available' )
190
+ }
191
+ </VStack>
192
+ )
193
+ }
194
+
195
+ { Array.isArray( threads ) &&
196
+ threads.length > 0 &&
197
+ threads.map( ( thread ) => (
198
+ <VStack
199
+ key={ thread.id }
200
+ className={ clsx(
201
+ 'editor-collab-sidebar-panel__thread',
202
+ {
203
+ 'editor-collab-sidebar-panel__active-thread':
204
+ blockCommentId &&
205
+ blockCommentId === thread.id,
206
+ }
207
+ ) }
208
+ id={ thread.id }
209
+ spacing="3"
210
+ >
211
+ <CommentBoard thread={ thread } />
212
+ { 'reply' === actionState?.action &&
213
+ thread.id === actionState?.id && (
214
+ <HStack
215
+ alignment="left"
216
+ spacing="3"
217
+ justify="flex-start"
218
+ className="editor-collab-sidebar-panel__user-comment"
219
+ >
220
+ <VStack
221
+ spacing="3"
222
+ className="editor-collab-sidebar-panel__comment-field"
223
+ >
224
+ <CommentForm
225
+ onSubmit={ ( inputComment ) => {
226
+ onAddReply(
227
+ inputComment,
228
+ thread.id
229
+ );
230
+ setActionState( false );
231
+ } }
232
+ onCancel={ () =>
233
+ setActionState( false )
234
+ }
235
+ />
236
+ </VStack>
237
+ </HStack>
238
+ ) }
239
+ { 0 < thread?.reply?.length &&
240
+ thread.reply.map( ( reply ) => (
241
+ <VStack
242
+ key={ reply.id }
243
+ className="editor-collab-sidebar-panel__child-thread"
244
+ id={ reply.id }
245
+ spacing="2"
246
+ >
247
+ <CommentBoard
248
+ thread={ reply }
249
+ parentThread={ thread }
250
+ />
251
+ </VStack>
252
+ ) ) }
253
+ </VStack>
254
+ ) ) }
255
+ </>
256
+ );
257
+ }
258
+
259
+ /**
260
+ * EditComment component.
261
+ *
262
+ * @param {Object} props - The component props.
263
+ * @param {Function} props.onSubmit - The function to call when updating the comment.
264
+ * @param {Function} props.onCancel - The function to call when canceling the comment update.
265
+ * @param {Object} props.thread - The comment thread object.
266
+ * @return {JSX.Element} The CommentForm component.
267
+ */
268
+ function CommentForm( { onSubmit, onCancel, thread } ) {
269
+ const [ inputComment, setInputComment ] = useState(
270
+ thread?.content?.raw ?? ''
271
+ );
272
+
273
+ return (
274
+ <>
275
+ <TextareaControl
276
+ __nextHasNoMarginBottom
277
+ value={ inputComment ?? '' }
278
+ onChange={ setInputComment }
279
+ />
280
+ <VStack alignment="left" spacing="3" justify="flex-start">
281
+ <HStack alignment="left" spacing="3" justify="flex-start">
282
+ <Button
283
+ __next40pxDefaultSize
284
+ accessibleWhenDisabled
285
+ variant="primary"
286
+ onClick={ () => onSubmit( inputComment ) }
287
+ disabled={
288
+ 0 === sanitizeCommentString( inputComment ).length
289
+ }
290
+ >
291
+ { thread
292
+ ? _x( 'Update', 'verb' )
293
+ : _x( 'Reply', 'Add reply comment' ) }
294
+ </Button>
295
+ <Button __next40pxDefaultSize onClick={ onCancel }>
296
+ { _x( 'Cancel', 'Cancel comment edit' ) }
297
+ </Button>
298
+ </HStack>
299
+ </VStack>
300
+ </>
301
+ );
302
+ }
303
+
304
+ /**
305
+ * Renders the header of a comment in the collaboration sidebar.
306
+ *
307
+ * @param {Object} props - The component props.
308
+ * @param {Object} props.thread - The comment thread object.
309
+ * @param {Function} props.onResolve - The function to resolve the comment.
310
+ * @param {Function} props.onEdit - The function to edit the comment.
311
+ * @param {Function} props.onDelete - The function to delete the comment.
312
+ * @param {Function} props.onReply - The function to reply to the comment.
313
+ * @param {string} props.status - The status of the comment.
314
+ * @return {JSX.Element} The rendered comment header.
315
+ */
316
+ function CommentHeader( {
317
+ thread,
318
+ onResolve,
319
+ onEdit,
320
+ onDelete,
321
+ onReply,
322
+ status,
323
+ } ) {
324
+ const dateSettings = getDateSettings();
325
+ const [ dateTimeFormat = dateSettings.formats.time ] = useEntityProp(
326
+ 'root',
327
+ 'site',
328
+ 'time_format'
329
+ );
330
+
331
+ const actions = [
332
+ {
333
+ title: _x( 'Edit', 'Edit comment' ),
334
+ onClick: onEdit,
335
+ },
336
+ {
337
+ title: _x( 'Delete', 'Delete comment' ),
338
+ onClick: onDelete,
339
+ },
340
+ {
341
+ title: _x( 'Reply', 'Reply on a comment' ),
342
+ onClick: onReply,
343
+ },
344
+ ];
345
+
346
+ const moreActions = actions.filter( ( item ) => item.onClick );
347
+
348
+ return (
349
+ <HStack alignment="left" spacing="3" justify="flex-start">
350
+ <img
351
+ src={ thread?.author_avatar_urls?.[ 48 ] }
352
+ className="editor-collab-sidebar-panel__user-avatar"
353
+ // translators: alt text for user avatar image
354
+ alt={ __( 'User avatar' ) }
355
+ width={ 32 }
356
+ height={ 32 }
357
+ />
358
+ <VStack spacing="0">
359
+ <span className="editor-collab-sidebar-panel__user-name">
360
+ { thread.author_name }
361
+ </span>
362
+ <time
363
+ dateTime={ format( 'h:i A', thread.date ) }
364
+ className="editor-collab-sidebar-panel__user-time"
365
+ >
366
+ { dateI18n( dateTimeFormat, thread.date ) }
367
+ </time>
368
+ </VStack>
369
+ <span className="editor-collab-sidebar-panel__comment-status">
370
+ { status !== 'approved' && (
371
+ <HStack alignment="right" justify="flex-end" spacing="0">
372
+ { 0 === thread.parent && onResolve && (
373
+ <Button
374
+ label={ _x(
375
+ 'Resolve',
376
+ 'Mark comment as resolved'
377
+ ) }
378
+ __next40pxDefaultSize
379
+ icon={ published }
380
+ onClick={ onResolve }
381
+ showTooltip
382
+ />
383
+ ) }
384
+ <DropdownMenu
385
+ icon={ moreVertical }
386
+ label={ _x(
387
+ 'Select an action',
388
+ 'Select comment action'
389
+ ) }
390
+ className="editor-collab-sidebar-panel__comment-dropdown-menu"
391
+ controls={ moreActions }
392
+ />
393
+ </HStack>
394
+ ) }
395
+ { status === 'approved' && (
396
+ // translators: tooltip for resolved comment
397
+ <Tooltip text={ __( 'Resolved' ) }>
398
+ <Icon icon={ check } />
399
+ </Tooltip>
400
+ ) }
401
+ </span>
402
+ </HStack>
403
+ );
404
+ }
@@ -0,0 +1 @@
1
+ export const collabSidebarName = 'edit-post/collab-sidebar';