@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,298 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { useSelect, useDispatch, resolveSelect } from '@wordpress/data';
6
+ import { useState, useMemo } from '@wordpress/element';
7
+ import { comment as commentIcon } from '@wordpress/icons';
8
+ import { addFilter } from '@wordpress/hooks';
9
+ import { store as noticesStore } from '@wordpress/notices';
10
+ import { store as coreStore } from '@wordpress/core-data';
11
+ import { store as blockEditorStore } from '@wordpress/block-editor';
12
+ import { store as interfaceStore } from '@wordpress/interface';
13
+
14
+ /**
15
+ * Internal dependencies
16
+ */
17
+ import PluginSidebar from '../plugin-sidebar';
18
+ import { collabSidebarName } from './constants';
19
+ import { Comments } from './comments';
20
+ import { AddComment } from './add-comment';
21
+ import { store as editorStore } from '../../store';
22
+ import AddCommentButton from './comment-button';
23
+ import AddCommentToolbarButton from './comment-button-toolbar';
24
+
25
+ const isBlockCommentExperimentEnabled =
26
+ window?.__experimentalEnableBlockComment;
27
+ const modifyBlockCommentAttributes = ( settings ) => {
28
+ if ( ! settings.attributes.blockCommentId ) {
29
+ settings.attributes = {
30
+ ...settings.attributes,
31
+ blockCommentId: {
32
+ type: 'number',
33
+ },
34
+ };
35
+ }
36
+
37
+ return settings;
38
+ };
39
+
40
+ // Apply the filter to all core blocks
41
+ addFilter(
42
+ 'blocks.registerBlockType',
43
+ 'block-comment/modify-core-block-attributes',
44
+ modifyBlockCommentAttributes
45
+ );
46
+
47
+ function CollabSidebarContent( { showCommentBoard, setShowCommentBoard } ) {
48
+ const { createNotice } = useDispatch( noticesStore );
49
+ const { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );
50
+ const { getEntityRecord } = resolveSelect( coreStore );
51
+
52
+ const { postId, threads } = useSelect( ( select ) => {
53
+ const { getCurrentPostId } = select( editorStore );
54
+ const _postId = getCurrentPostId();
55
+ const data = !! _postId
56
+ ? select( coreStore ).getEntityRecords( 'root', 'comment', {
57
+ post: _postId,
58
+ type: 'block_comment',
59
+ status: 'any',
60
+ per_page: 100,
61
+ } )
62
+ : null;
63
+
64
+ return {
65
+ postId: _postId,
66
+ threads: data,
67
+ };
68
+ }, [] );
69
+
70
+ const { getSelectedBlockClientId } = useSelect( blockEditorStore );
71
+ const { updateBlockAttributes } = useDispatch( blockEditorStore );
72
+
73
+ // Process comments to build the tree structure
74
+ const resultComments = useMemo( () => {
75
+ // Create a compare to store the references to all objects by id
76
+ const compare = {};
77
+ const result = [];
78
+
79
+ const filteredComments = ( threads ?? [] ).filter(
80
+ ( comment ) => comment.status !== 'trash'
81
+ );
82
+
83
+ // Initialize each object with an empty `reply` array
84
+ filteredComments.forEach( ( item ) => {
85
+ compare[ item.id ] = { ...item, reply: [] };
86
+ } );
87
+
88
+ // Iterate over the data to build the tree structure
89
+ filteredComments.forEach( ( item ) => {
90
+ if ( item.parent === 0 ) {
91
+ // If parent is 0, it's a root item, push it to the result array
92
+ result.push( compare[ item.id ] );
93
+ } else if ( compare[ item.parent ] ) {
94
+ // Otherwise, find its parent and push it to the parent's `reply` array
95
+ compare[ item.parent ].reply.push( compare[ item.id ] );
96
+ }
97
+ } );
98
+
99
+ return result;
100
+ }, [ threads ] );
101
+
102
+ // Function to save the comment.
103
+ const addNewComment = async ( comment, parentCommentId ) => {
104
+ const args = {
105
+ post: postId,
106
+ content: comment,
107
+ comment_type: 'block_comment',
108
+ comment_approved: 0,
109
+ };
110
+
111
+ // Create a new object, conditionally including the parent property
112
+ const updatedArgs = {
113
+ ...args,
114
+ ...( parentCommentId ? { parent: parentCommentId } : {} ),
115
+ };
116
+
117
+ const savedRecord = await saveEntityRecord(
118
+ 'root',
119
+ 'comment',
120
+ updatedArgs
121
+ );
122
+
123
+ if ( savedRecord ) {
124
+ // If it's a main comment, update the block attributes with the comment id.
125
+ if ( ! parentCommentId ) {
126
+ updateBlockAttributes( getSelectedBlockClientId(), {
127
+ blockCommentId: savedRecord?.id,
128
+ } );
129
+ }
130
+
131
+ createNotice(
132
+ 'snackbar',
133
+ parentCommentId
134
+ ? // translators: Reply added successfully
135
+ __( 'Reply added successfully.' )
136
+ : // translators: Comment added successfully
137
+ __( 'Comment added successfully.' ),
138
+ {
139
+ type: 'snackbar',
140
+ isDismissible: true,
141
+ }
142
+ );
143
+ } else {
144
+ onError();
145
+ }
146
+ };
147
+
148
+ const onCommentResolve = async ( commentId ) => {
149
+ const savedRecord = await saveEntityRecord( 'root', 'comment', {
150
+ id: commentId,
151
+ status: 'approved',
152
+ } );
153
+
154
+ if ( savedRecord ) {
155
+ // translators: Comment resolved successfully
156
+ createNotice( 'snackbar', __( 'Comment marked as resolved.' ), {
157
+ type: 'snackbar',
158
+ isDismissible: true,
159
+ } );
160
+ } else {
161
+ onError();
162
+ }
163
+ };
164
+
165
+ const onEditComment = async ( commentId, comment ) => {
166
+ const savedRecord = await saveEntityRecord( 'root', 'comment', {
167
+ id: commentId,
168
+ content: comment,
169
+ } );
170
+
171
+ if ( savedRecord ) {
172
+ createNotice(
173
+ 'snackbar',
174
+ // translators: Comment edited successfully
175
+ __( 'Comment edited successfully.' ),
176
+ {
177
+ type: 'snackbar',
178
+ isDismissible: true,
179
+ }
180
+ );
181
+ } else {
182
+ onError();
183
+ }
184
+ };
185
+
186
+ const onError = () => {
187
+ createNotice(
188
+ 'error',
189
+ // translators: Error message when comment submission fails
190
+ __(
191
+ 'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'
192
+ ),
193
+ {
194
+ isDismissible: true,
195
+ }
196
+ );
197
+ };
198
+
199
+ const onCommentDelete = async ( commentId ) => {
200
+ const childComment = await getEntityRecord(
201
+ 'root',
202
+ 'comment',
203
+ commentId
204
+ );
205
+ await deleteEntityRecord( 'root', 'comment', commentId );
206
+
207
+ if ( childComment && ! childComment.parent ) {
208
+ updateBlockAttributes( getSelectedBlockClientId(), {
209
+ blockCommentId: undefined,
210
+ } );
211
+ }
212
+
213
+ createNotice(
214
+ 'snackbar',
215
+ // translators: Comment deleted successfully
216
+ __( 'Comment deleted successfully.' ),
217
+ {
218
+ type: 'snackbar',
219
+ isDismissible: true,
220
+ }
221
+ );
222
+ };
223
+
224
+ return (
225
+ <div className="editor-collab-sidebar-panel">
226
+ <AddComment
227
+ onSubmit={ addNewComment }
228
+ showCommentBoard={ showCommentBoard }
229
+ setShowCommentBoard={ setShowCommentBoard }
230
+ />
231
+ <Comments
232
+ threads={ resultComments }
233
+ onEditComment={ onEditComment }
234
+ onAddReply={ addNewComment }
235
+ onCommentDelete={ onCommentDelete }
236
+ onCommentResolve={ onCommentResolve }
237
+ />
238
+ </div>
239
+ );
240
+ }
241
+
242
+ /**
243
+ * Renders the Collab sidebar.
244
+ */
245
+ export default function CollabSidebar() {
246
+ const [ showCommentBoard, setShowCommentBoard ] = useState( false );
247
+ const { enableComplementaryArea } = useDispatch( interfaceStore );
248
+
249
+ const { postStatus } = useSelect( ( select ) => {
250
+ return {
251
+ postStatus:
252
+ select( editorStore ).getEditedPostAttribute( 'status' ),
253
+ };
254
+ }, [] );
255
+
256
+ const { blockCommentId } = useSelect( ( select ) => {
257
+ const { getBlockAttributes, getSelectedBlockClientId } =
258
+ select( blockEditorStore );
259
+ const _clientId = getSelectedBlockClientId();
260
+
261
+ return {
262
+ blockCommentId: _clientId
263
+ ? getBlockAttributes( _clientId )?.blockCommentId
264
+ : null,
265
+ };
266
+ }, [] );
267
+
268
+ const openCollabBoard = () => {
269
+ setShowCommentBoard( true );
270
+ enableComplementaryArea( 'core', 'edit-post/collab-sidebar' );
271
+ };
272
+
273
+ // Check if the experimental flag is enabled.
274
+ if ( ! isBlockCommentExperimentEnabled || postStatus === 'publish' ) {
275
+ return null; // or maybe return some message indicating no threads are available.
276
+ }
277
+
278
+ const AddCommentComponent = blockCommentId
279
+ ? AddCommentToolbarButton
280
+ : AddCommentButton;
281
+
282
+ return (
283
+ <>
284
+ <AddCommentComponent onClick={ openCollabBoard } />
285
+ <PluginSidebar
286
+ identifier={ collabSidebarName }
287
+ // translators: Comments sidebar title
288
+ title={ __( 'Comments' ) }
289
+ icon={ commentIcon }
290
+ >
291
+ <CollabSidebarContent
292
+ showCommentBoard={ showCommentBoard }
293
+ setShowCommentBoard={ setShowCommentBoard }
294
+ />
295
+ </PluginSidebar>
296
+ </>
297
+ );
298
+ }
@@ -0,0 +1,111 @@
1
+ .editor-collab-sidebar-panel {
2
+ padding: $grid-unit-20;
3
+
4
+ &__thread {
5
+ position: relative;
6
+ padding: $grid-unit-20;
7
+ border-radius: $radius-large;
8
+ border: 1px solid $gray-300;
9
+ background-color: $gray-100;
10
+ margin-bottom: $grid-unit-20;
11
+ }
12
+
13
+ &__active-thread {
14
+ border: 1.5px solid #3858e9;
15
+ background-color: $white;
16
+ box-shadow: 0 5.5px 7.8px -0.3px rgba(0, 0, 0, 0.102);
17
+ }
18
+
19
+ &__comment-field {
20
+ flex: 1;
21
+ }
22
+
23
+ &__child-thread {
24
+ margin-top: 15px;
25
+ }
26
+
27
+ &__user-name {
28
+ font-size: 12px;
29
+ font-weight: 400;
30
+ line-height: 16px;
31
+ text-align: left;
32
+ color: $gray-700;
33
+ text-transform: capitalize;
34
+ }
35
+
36
+ &__user-time {
37
+ font-size: 12px;
38
+ font-weight: 400;
39
+ line-height: 16px;
40
+ text-align: left;
41
+ color: $gray-700;
42
+ }
43
+
44
+ &__user-comment {
45
+ font-size: 13px;
46
+ font-weight: 400;
47
+ line-height: 20px;
48
+ text-align: left;
49
+ color: $gray-900;
50
+
51
+ p {
52
+ margin-bottom: 0;
53
+ }
54
+ }
55
+
56
+ &__user-avatar {
57
+ border-radius: $radius-round;
58
+ flex-shrink: 0;
59
+ }
60
+
61
+ &__thread-overlay {
62
+ background-color: rgba(0, 0, 0, 0.7);
63
+ width: 100%;
64
+ height: 100%;
65
+ text-align: center;
66
+ position: absolute;
67
+ top: 0;
68
+ left: 0;
69
+ z-index: 1;
70
+ padding: 15px;
71
+ border-radius: $radius-large;
72
+ color: $white;
73
+
74
+ p {
75
+ margin-bottom: 15px;
76
+ }
77
+
78
+ button {
79
+ padding: 4px 10px;
80
+ color: $white;
81
+ }
82
+ }
83
+
84
+ &__comment-status {
85
+ margin-left: auto;
86
+
87
+ button {
88
+ &.has-icon:not(.has-text) {
89
+ min-width: 24px;
90
+ padding: 0;
91
+ width: 24px;
92
+ height: 24px;
93
+ flex-shrink: 0;
94
+ }
95
+ }
96
+ }
97
+
98
+ &__comment-dropdown-menu {
99
+ flex-shrink: 0;
100
+
101
+ button {
102
+ &.has-icon {
103
+ min-width: 24px;
104
+ padding: 0;
105
+ width: 24px;
106
+ height: 24px;
107
+ }
108
+ }
109
+ }
110
+
111
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Sanitizes a comment string by removing non-printable ASCII characters.
3
+ *
4
+ * @param {string} str - The comment string to sanitize.
5
+ * @return {string} - The sanitized comment string.
6
+ */
7
+ export function sanitizeCommentString( str ) {
8
+ return str.trim();
9
+ }