@wordpress/editor 14.9.0 → 14.11.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 (518) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +2 -2
  3. package/build/bindings/api.js +0 -29
  4. package/build/bindings/api.js.map +1 -1
  5. package/build/bindings/post-meta.js +2 -1
  6. package/build/bindings/post-meta.js.map +1 -1
  7. package/build/components/autocompleters/user.js.map +1 -1
  8. package/build/components/block-manager/index.js +2 -2
  9. package/build/components/block-manager/index.js.map +1 -1
  10. package/build/components/collab-sidebar/add-comment.js +120 -0
  11. package/build/components/collab-sidebar/add-comment.js.map +1 -0
  12. package/build/components/collab-sidebar/comment-button-toolbar.js +37 -0
  13. package/build/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
  14. package/build/components/collab-sidebar/comment-button.js +37 -0
  15. package/build/components/collab-sidebar/comment-button.js.map +1 -0
  16. package/build/components/collab-sidebar/comments.js +321 -0
  17. package/build/components/collab-sidebar/comments.js.map +1 -0
  18. package/build/components/collab-sidebar/constants.js +8 -0
  19. package/build/components/collab-sidebar/constants.js.map +1 -0
  20. package/build/components/collab-sidebar/index.js +272 -0
  21. package/build/components/collab-sidebar/index.js.map +1 -0
  22. package/build/components/collab-sidebar/utils.js +16 -0
  23. package/build/components/collab-sidebar/utils.js.map +1 -0
  24. package/build/components/commands/index.js +6 -6
  25. package/build/components/commands/index.js.map +1 -1
  26. package/build/components/create-template-part-modal/index.js.map +1 -1
  27. package/build/components/create-template-part-modal/utils.js.map +1 -1
  28. package/build/components/document-bar/index.js +8 -7
  29. package/build/components/document-bar/index.js.map +1 -1
  30. package/build/components/document-outline/index.js.map +1 -1
  31. package/build/components/document-outline/item.js.map +1 -1
  32. package/build/components/document-tools/index.js +2 -6
  33. package/build/components/document-tools/index.js.map +1 -1
  34. package/build/components/editor-interface/index.js +4 -14
  35. package/build/components/editor-interface/index.js.map +1 -1
  36. package/build/components/entities-saved-states/index.js +2 -2
  37. package/build/components/entities-saved-states/index.js.map +1 -1
  38. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  39. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  40. package/build/components/global-styles-provider/index.js +13 -3
  41. package/build/components/global-styles-provider/index.js.map +1 -1
  42. package/build/components/header/index.js +5 -2
  43. package/build/components/header/index.js.map +1 -1
  44. package/build/components/inserter-sidebar/index.js +2 -2
  45. package/build/components/inserter-sidebar/index.js.map +1 -1
  46. package/build/components/media-categories/index.js.map +1 -1
  47. package/build/components/page-attributes/parent.js +5 -5
  48. package/build/components/page-attributes/parent.js.map +1 -1
  49. package/build/components/plugin-document-setting-panel/index.js.map +1 -1
  50. package/build/components/plugin-more-menu-item/index.js +13 -11
  51. package/build/components/plugin-more-menu-item/index.js.map +1 -1
  52. package/build/components/plugin-preview-menu-item/index.js +15 -13
  53. package/build/components/plugin-preview-menu-item/index.js.map +1 -1
  54. package/build/components/plugin-sidebar/index.js +0 -15
  55. package/build/components/plugin-sidebar/index.js.map +1 -1
  56. package/build/components/post-actions/index.js +5 -5
  57. package/build/components/post-actions/index.js.map +1 -1
  58. package/build/components/post-author/panel.js +4 -4
  59. package/build/components/post-author/panel.js.map +1 -1
  60. package/build/components/post-card-panel/index.js +7 -36
  61. package/build/components/post-card-panel/index.js.map +1 -1
  62. package/build/components/post-content-information/index.js +2 -3
  63. package/build/components/post-content-information/index.js.map +1 -1
  64. package/build/components/post-featured-image/index.js +26 -7
  65. package/build/components/post-featured-image/index.js.map +1 -1
  66. package/build/components/post-format/index.js +1 -1
  67. package/build/components/post-format/index.js.map +1 -1
  68. package/build/components/post-last-revision/index.js +1 -1
  69. package/build/components/post-last-revision/index.js.map +1 -1
  70. package/build/components/post-locked-modal/index.js +2 -2
  71. package/build/components/post-locked-modal/index.js.map +1 -1
  72. package/build/components/post-preview-button/index.js +1 -1
  73. package/build/components/post-preview-button/index.js.map +1 -1
  74. package/build/components/post-publish-button/index.js.map +1 -1
  75. package/build/components/post-publish-panel/maybe-post-format-panel.js +1 -1
  76. package/build/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  77. package/build/components/post-publish-panel/maybe-upload-media.js +1 -0
  78. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  79. package/build/components/post-publish-panel/media-util.js +1 -0
  80. package/build/components/post-publish-panel/media-util.js.map +1 -1
  81. package/build/components/post-publish-panel/postpublish.js +1 -1
  82. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  83. package/build/components/post-schedule/label.js +1 -1
  84. package/build/components/post-schedule/label.js.map +1 -1
  85. package/build/components/post-taxonomies/flat-term-selector.js +13 -5
  86. package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
  87. package/build/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  88. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  89. package/build/components/post-taxonomies/index.js +1 -1
  90. package/build/components/post-taxonomies/index.js.map +1 -1
  91. package/build/components/post-taxonomies/panel.js.map +1 -1
  92. package/build/components/post-template/classic-theme.js +2 -4
  93. package/build/components/post-template/classic-theme.js.map +1 -1
  94. package/build/components/post-text-editor/index.js.map +1 -1
  95. package/build/components/post-title/index.js +15 -19
  96. package/build/components/post-title/index.js.map +1 -1
  97. package/build/components/post-title/index.native.js +2 -2
  98. package/build/components/post-title/index.native.js.map +1 -1
  99. package/build/components/post-url/index.js +76 -63
  100. package/build/components/post-url/index.js.map +1 -1
  101. package/build/components/post-url/panel.js +49 -29
  102. package/build/components/post-url/panel.js.map +1 -1
  103. package/build/components/post-visibility/index.js.map +1 -1
  104. package/build/components/preferences-modal/index.js.map +1 -1
  105. package/build/components/preview-dropdown/index.js +0 -4
  106. package/build/components/preview-dropdown/index.js.map +1 -1
  107. package/build/components/provider/index.js +10 -12
  108. package/build/components/provider/index.js.map +1 -1
  109. package/build/components/provider/use-block-editor-settings.js +1 -1
  110. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  111. package/build/components/resizable-editor/resize-handle.js.map +1 -1
  112. package/build/components/sidebar/header.js +2 -1
  113. package/build/components/sidebar/header.js.map +1 -1
  114. package/build/components/sidebar/index.js +3 -3
  115. package/build/components/sidebar/index.js.map +1 -1
  116. package/build/components/time-to-read/index.js +2 -2
  117. package/build/components/time-to-read/index.js.map +1 -1
  118. package/build/components/visual-editor/edit-template-blocks-notification.js +4 -1
  119. package/build/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  120. package/build/components/visual-editor/index.js +24 -25
  121. package/build/components/visual-editor/index.js.map +1 -1
  122. package/build/components/visual-editor/use-select-nearest-editable-block.js.map +1 -1
  123. package/build/components/visual-editor/use-zoom-out-mode-exit.js +52 -0
  124. package/build/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
  125. package/build/components/zoom-out-toggle/index.js +37 -5
  126. package/build/components/zoom-out-toggle/index.js.map +1 -1
  127. package/build/dataviews/actions/duplicate-template-part.js +3 -3
  128. package/build/dataviews/actions/duplicate-template-part.js.map +1 -1
  129. package/build/private-apis.js +0 -1
  130. package/build/private-apis.js.map +1 -1
  131. package/build/store/actions.js +30 -4
  132. package/build/store/actions.js.map +1 -1
  133. package/build/store/constants.js +1 -0
  134. package/build/store/constants.js.map +1 -1
  135. package/build/store/local-autosave.js.map +1 -1
  136. package/build/store/private-actions.js +8 -7
  137. package/build/store/private-actions.js.map +1 -1
  138. package/build/store/selectors.js +24 -2
  139. package/build/store/selectors.js.map +1 -1
  140. package/build/utils/media-upload/index.js.map +1 -1
  141. package/build/utils/pageTypeBadge.js +51 -0
  142. package/build/utils/pageTypeBadge.js.map +1 -0
  143. package/build/utils/terms.js +2 -2
  144. package/build/utils/terms.js.map +1 -1
  145. package/build-module/bindings/api.js +1 -29
  146. package/build-module/bindings/api.js.map +1 -1
  147. package/build-module/bindings/post-meta.js +2 -1
  148. package/build-module/bindings/post-meta.js.map +1 -1
  149. package/build-module/components/autocompleters/user.js +1 -3
  150. package/build-module/components/autocompleters/user.js.map +1 -1
  151. package/build-module/components/block-manager/category.js +1 -2
  152. package/build-module/components/block-manager/category.js.map +1 -1
  153. package/build-module/components/block-manager/checklist.js +1 -2
  154. package/build-module/components/block-manager/checklist.js.map +1 -1
  155. package/build-module/components/block-manager/index.js +3 -4
  156. package/build-module/components/block-manager/index.js.map +1 -1
  157. package/build-module/components/block-settings-menu/content-only-settings-menu.js +1 -3
  158. package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -1
  159. package/build-module/components/blog-title/index.js +1 -3
  160. package/build-module/components/blog-title/index.js.map +1 -1
  161. package/build-module/components/collab-sidebar/add-comment.js +114 -0
  162. package/build-module/components/collab-sidebar/add-comment.js.map +1 -0
  163. package/build-module/components/collab-sidebar/comment-button-toolbar.js +30 -0
  164. package/build-module/components/collab-sidebar/comment-button-toolbar.js.map +1 -0
  165. package/build-module/components/collab-sidebar/comment-button.js +30 -0
  166. package/build-module/components/collab-sidebar/comment-button.js.map +1 -0
  167. package/build-module/components/collab-sidebar/comments.js +314 -0
  168. package/build-module/components/collab-sidebar/comments.js.map +1 -0
  169. package/build-module/components/collab-sidebar/constants.js +2 -0
  170. package/build-module/components/collab-sidebar/constants.js.map +1 -0
  171. package/build-module/components/collab-sidebar/index.js +264 -0
  172. package/build-module/components/collab-sidebar/index.js.map +1 -0
  173. package/build-module/components/collab-sidebar/utils.js +10 -0
  174. package/build-module/components/collab-sidebar/utils.js.map +1 -0
  175. package/build-module/components/collapsible-block-toolbar/index.js +1 -3
  176. package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
  177. package/build-module/components/commands/index.js +6 -6
  178. package/build-module/components/commands/index.js.map +1 -1
  179. package/build-module/components/create-template-part-modal/index.js +1 -2
  180. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  181. package/build-module/components/create-template-part-modal/utils.js.map +1 -1
  182. package/build-module/components/document-bar/index.js +10 -10
  183. package/build-module/components/document-bar/index.js.map +1 -1
  184. package/build-module/components/document-outline/index.js +1 -2
  185. package/build-module/components/document-outline/index.js.map +1 -1
  186. package/build-module/components/document-outline/item.js +1 -2
  187. package/build-module/components/document-outline/item.js.map +1 -1
  188. package/build-module/components/document-tools/index.js +4 -10
  189. package/build-module/components/document-tools/index.js.map +1 -1
  190. package/build-module/components/editor/index.js +1 -3
  191. package/build-module/components/editor/index.js.map +1 -1
  192. package/build-module/components/editor-help/add-blocks.native.js +1 -3
  193. package/build-module/components/editor-help/add-blocks.native.js.map +1 -1
  194. package/build-module/components/editor-help/customize-blocks.native.js +1 -3
  195. package/build-module/components/editor-help/customize-blocks.native.js.map +1 -1
  196. package/build-module/components/editor-help/help-detail-navigation-screen.native.js +1 -2
  197. package/build-module/components/editor-help/help-detail-navigation-screen.native.js.map +1 -1
  198. package/build-module/components/editor-help/index.native.js +1 -3
  199. package/build-module/components/editor-help/index.native.js.map +1 -1
  200. package/build-module/components/editor-help/intro-to-blocks.native.js +1 -3
  201. package/build-module/components/editor-help/intro-to-blocks.native.js.map +1 -1
  202. package/build-module/components/editor-help/move-blocks.native.js +1 -3
  203. package/build-module/components/editor-help/move-blocks.native.js.map +1 -1
  204. package/build-module/components/editor-help/remove-blocks.native.js +1 -3
  205. package/build-module/components/editor-help/remove-blocks.native.js.map +1 -1
  206. package/build-module/components/editor-help/view-sections.native.js +1 -2
  207. package/build-module/components/editor-help/view-sections.native.js.map +1 -1
  208. package/build-module/components/editor-interface/index.js +5 -17
  209. package/build-module/components/editor-interface/index.js.map +1 -1
  210. package/build-module/components/editor-notices/index.js +1 -3
  211. package/build-module/components/editor-notices/index.js.map +1 -1
  212. package/build-module/components/entities-saved-states/entity-record-item.js +1 -3
  213. package/build-module/components/entities-saved-states/entity-record-item.js.map +1 -1
  214. package/build-module/components/entities-saved-states/entity-type-list.js +1 -2
  215. package/build-module/components/entities-saved-states/entity-type-list.js.map +1 -1
  216. package/build-module/components/entities-saved-states/index.js +3 -4
  217. package/build-module/components/entities-saved-states/index.js.map +1 -1
  218. package/build-module/components/error-boundary/index.native.js +1 -2
  219. package/build-module/components/error-boundary/index.native.js.map +1 -1
  220. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  221. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  222. package/build-module/components/global-styles-provider/index.js +13 -3
  223. package/build-module/components/global-styles-provider/index.js.map +1 -1
  224. package/build-module/components/header/index.js +6 -4
  225. package/build-module/components/header/index.js.map +1 -1
  226. package/build-module/components/inserter-sidebar/index.js +2 -2
  227. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  228. package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
  229. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  230. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +1 -3
  231. package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
  232. package/build-module/components/list-view-sidebar/list-view-outline.js +1 -3
  233. package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -1
  234. package/build-module/components/media-categories/index.js.map +1 -1
  235. package/build-module/components/more-menu/index.js +1 -3
  236. package/build-module/components/more-menu/index.js.map +1 -1
  237. package/build-module/components/offline-status/index.native.js +1 -2
  238. package/build-module/components/offline-status/index.native.js.map +1 -1
  239. package/build-module/components/page-attributes/parent.js +6 -7
  240. package/build-module/components/page-attributes/parent.js.map +1 -1
  241. package/build-module/components/plugin-document-setting-panel/index.js +1 -3
  242. package/build-module/components/plugin-document-setting-panel/index.js.map +1 -1
  243. package/build-module/components/plugin-more-menu-item/index.js +12 -10
  244. package/build-module/components/plugin-more-menu-item/index.js.map +1 -1
  245. package/build-module/components/plugin-preview-menu-item/index.js +14 -12
  246. package/build-module/components/plugin-preview-menu-item/index.js.map +1 -1
  247. package/build-module/components/plugin-sidebar/index.js +0 -15
  248. package/build-module/components/plugin-sidebar/index.js.map +1 -1
  249. package/build-module/components/post-actions/index.js +6 -8
  250. package/build-module/components/post-actions/index.js.map +1 -1
  251. package/build-module/components/post-author/panel.js +5 -6
  252. package/build-module/components/post-author/panel.js.map +1 -1
  253. package/build-module/components/post-card-panel/index.js +9 -38
  254. package/build-module/components/post-card-panel/index.js.map +1 -1
  255. package/build-module/components/post-content-information/index.js +2 -3
  256. package/build-module/components/post-content-information/index.js.map +1 -1
  257. package/build-module/components/post-discussion/panel.js +1 -2
  258. package/build-module/components/post-discussion/panel.js.map +1 -1
  259. package/build-module/components/post-excerpt/panel.js +1 -3
  260. package/build-module/components/post-excerpt/panel.js.map +1 -1
  261. package/build-module/components/post-featured-image/index.js +27 -9
  262. package/build-module/components/post-featured-image/index.js.map +1 -1
  263. package/build-module/components/post-format/index.js +2 -3
  264. package/build-module/components/post-format/index.js.map +1 -1
  265. package/build-module/components/post-format/panel.js +1 -2
  266. package/build-module/components/post-format/panel.js.map +1 -1
  267. package/build-module/components/post-last-revision/index.js +1 -1
  268. package/build-module/components/post-last-revision/index.js.map +1 -1
  269. package/build-module/components/post-locked-modal/index.js +3 -5
  270. package/build-module/components/post-locked-modal/index.js.map +1 -1
  271. package/build-module/components/post-panel-row/index.js +1 -2
  272. package/build-module/components/post-panel-row/index.js.map +1 -1
  273. package/build-module/components/post-preview-button/index.js +2 -4
  274. package/build-module/components/post-preview-button/index.js.map +1 -1
  275. package/build-module/components/post-publish-button/index.js +1 -2
  276. package/build-module/components/post-publish-button/index.js.map +1 -1
  277. package/build-module/components/post-publish-panel/index.js +1 -3
  278. package/build-module/components/post-publish-panel/index.js.map +1 -1
  279. package/build-module/components/post-publish-panel/maybe-category-panel.js +1 -2
  280. package/build-module/components/post-publish-panel/maybe-category-panel.js.map +1 -1
  281. package/build-module/components/post-publish-panel/maybe-post-format-panel.js +2 -3
  282. package/build-module/components/post-publish-panel/maybe-post-format-panel.js.map +1 -1
  283. package/build-module/components/post-publish-panel/maybe-tags-panel.js +1 -2
  284. package/build-module/components/post-publish-panel/maybe-tags-panel.js.map +1 -1
  285. package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -2
  286. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  287. package/build-module/components/post-publish-panel/media-util.js +1 -0
  288. package/build-module/components/post-publish-panel/media-util.js.map +1 -1
  289. package/build-module/components/post-publish-panel/postpublish.js +2 -4
  290. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  291. package/build-module/components/post-publish-panel/prepublish.js +1 -3
  292. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  293. package/build-module/components/post-saved-state/index.js +1 -2
  294. package/build-module/components/post-saved-state/index.js.map +1 -1
  295. package/build-module/components/post-schedule/label.js +1 -1
  296. package/build-module/components/post-schedule/label.js.map +1 -1
  297. package/build-module/components/post-status/index.js +1 -3
  298. package/build-module/components/post-status/index.js.map +1 -1
  299. package/build-module/components/post-switch-to-draft-button/index.js +1 -3
  300. package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
  301. package/build-module/components/post-taxonomies/flat-term-selector.js +16 -10
  302. package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
  303. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +4 -4
  304. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  305. package/build-module/components/post-taxonomies/index.js +1 -1
  306. package/build-module/components/post-taxonomies/index.js.map +1 -1
  307. package/build-module/components/post-taxonomies/most-used-terms.js +1 -2
  308. package/build-module/components/post-taxonomies/most-used-terms.js.map +1 -1
  309. package/build-module/components/post-taxonomies/panel.js.map +1 -1
  310. package/build-module/components/post-template/block-theme.js +1 -3
  311. package/build-module/components/post-template/block-theme.js.map +1 -1
  312. package/build-module/components/post-template/classic-theme.js +3 -6
  313. package/build-module/components/post-template/classic-theme.js.map +1 -1
  314. package/build-module/components/post-template/create-new-template-modal.js +1 -2
  315. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  316. package/build-module/components/post-template/create-new-template.js +1 -3
  317. package/build-module/components/post-template/create-new-template.js.map +1 -1
  318. package/build-module/components/post-template/swap-template-button.js +1 -3
  319. package/build-module/components/post-template/swap-template-button.js.map +1 -1
  320. package/build-module/components/post-text-editor/index.js +1 -3
  321. package/build-module/components/post-text-editor/index.js.map +1 -1
  322. package/build-module/components/post-title/index.js +15 -19
  323. package/build-module/components/post-title/index.js.map +1 -1
  324. package/build-module/components/post-title/index.native.js +2 -2
  325. package/build-module/components/post-title/index.native.js.map +1 -1
  326. package/build-module/components/post-trash/index.js +1 -2
  327. package/build-module/components/post-trash/index.js.map +1 -1
  328. package/build-module/components/post-url/index.js +78 -66
  329. package/build-module/components/post-url/index.js.map +1 -1
  330. package/build-module/components/post-url/panel.js +51 -31
  331. package/build-module/components/post-url/panel.js.map +1 -1
  332. package/build-module/components/post-visibility/index.js +1 -2
  333. package/build-module/components/post-visibility/index.js.map +1 -1
  334. package/build-module/components/posts-per-page/index.js +1 -3
  335. package/build-module/components/posts-per-page/index.js.map +1 -1
  336. package/build-module/components/preferences-modal/index.js +1 -3
  337. package/build-module/components/preferences-modal/index.js.map +1 -1
  338. package/build-module/components/preview-dropdown/index.js +1 -7
  339. package/build-module/components/preview-dropdown/index.js.map +1 -1
  340. package/build-module/components/provider/index.js +11 -15
  341. package/build-module/components/provider/index.js.map +1 -1
  342. package/build-module/components/provider/index.native.js +1 -3
  343. package/build-module/components/provider/index.native.js.map +1 -1
  344. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  345. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  346. package/build-module/components/resizable-editor/resize-handle.js +1 -3
  347. package/build-module/components/resizable-editor/resize-handle.js.map +1 -1
  348. package/build-module/components/save-publish-panels/index.js +1 -3
  349. package/build-module/components/save-publish-panels/index.js.map +1 -1
  350. package/build-module/components/sidebar/header.js +3 -3
  351. package/build-module/components/sidebar/header.js.map +1 -1
  352. package/build-module/components/sidebar/index.js +5 -6
  353. package/build-module/components/sidebar/index.js.map +1 -1
  354. package/build-module/components/sidebar/post-summary.js +1 -3
  355. package/build-module/components/sidebar/post-summary.js.map +1 -1
  356. package/build-module/components/site-discussion/index.js +1 -3
  357. package/build-module/components/site-discussion/index.js.map +1 -1
  358. package/build-module/components/start-template-options/index.js +1 -2
  359. package/build-module/components/start-template-options/index.js.map +1 -1
  360. package/build-module/components/table-of-contents/panel.js +1 -3
  361. package/build-module/components/table-of-contents/panel.js.map +1 -1
  362. package/build-module/components/template-part-menu-items/convert-to-template-part.js +1 -3
  363. package/build-module/components/template-part-menu-items/convert-to-template-part.js.map +1 -1
  364. package/build-module/components/template-validation-notice/index.js +1 -3
  365. package/build-module/components/template-validation-notice/index.js.map +1 -1
  366. package/build-module/components/text-editor/index.js +1 -2
  367. package/build-module/components/text-editor/index.js.map +1 -1
  368. package/build-module/components/time-to-read/index.js +2 -2
  369. package/build-module/components/time-to-read/index.js.map +1 -1
  370. package/build-module/components/visual-editor/edit-template-blocks-notification.js +4 -1
  371. package/build-module/components/visual-editor/edit-template-blocks-notification.js.map +1 -1
  372. package/build-module/components/visual-editor/index.js +26 -29
  373. package/build-module/components/visual-editor/index.js.map +1 -1
  374. package/build-module/components/visual-editor/use-select-nearest-editable-block.js.map +1 -1
  375. package/build-module/components/visual-editor/use-zoom-out-mode-exit.js +46 -0
  376. package/build-module/components/visual-editor/use-zoom-out-mode-exit.js.map +1 -0
  377. package/build-module/components/zoom-out-toggle/index.js +37 -5
  378. package/build-module/components/zoom-out-toggle/index.js.map +1 -1
  379. package/build-module/dataviews/actions/duplicate-template-part.js +4 -4
  380. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -1
  381. package/build-module/hooks/pattern-overrides.js +1 -3
  382. package/build-module/hooks/pattern-overrides.js.map +1 -1
  383. package/build-module/private-apis.js +1 -2
  384. package/build-module/private-apis.js.map +1 -1
  385. package/build-module/store/actions.js +30 -4
  386. package/build-module/store/actions.js.map +1 -1
  387. package/build-module/store/constants.js +1 -0
  388. package/build-module/store/constants.js.map +1 -1
  389. package/build-module/store/local-autosave.js.map +1 -1
  390. package/build-module/store/private-actions.js +9 -8
  391. package/build-module/store/private-actions.js.map +1 -1
  392. package/build-module/store/selectors.js +24 -2
  393. package/build-module/store/selectors.js.map +1 -1
  394. package/build-module/utils/media-upload/index.js.map +1 -1
  395. package/build-module/utils/pageTypeBadge.js +45 -0
  396. package/build-module/utils/pageTypeBadge.js.map +1 -0
  397. package/build-module/utils/terms.js +2 -2
  398. package/build-module/utils/terms.js.map +1 -1
  399. package/build-style/style-rtl.css +116 -59
  400. package/build-style/style.css +116 -59
  401. package/build-types/bindings/api.d.ts +0 -13
  402. package/build-types/bindings/api.d.ts.map +1 -1
  403. package/build-types/bindings/post-meta.d.ts.map +1 -1
  404. package/build-types/components/collab-sidebar/add-comment.d.ts +15 -0
  405. package/build-types/components/collab-sidebar/add-comment.d.ts.map +1 -0
  406. package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts +5 -0
  407. package/build-types/components/collab-sidebar/comment-button-toolbar.d.ts.map +1 -0
  408. package/build-types/components/collab-sidebar/comment-button.d.ts +5 -0
  409. package/build-types/components/collab-sidebar/comment-button.d.ts.map +1 -0
  410. package/build-types/components/collab-sidebar/comments.d.ts +19 -0
  411. package/build-types/components/collab-sidebar/comments.d.ts.map +1 -0
  412. package/build-types/components/collab-sidebar/constants.d.ts +2 -0
  413. package/build-types/components/collab-sidebar/constants.d.ts.map +1 -0
  414. package/build-types/components/collab-sidebar/index.d.ts +5 -0
  415. package/build-types/components/collab-sidebar/index.d.ts.map +1 -0
  416. package/build-types/components/collab-sidebar/utils.d.ts +8 -0
  417. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -0
  418. package/build-types/components/commands/index.d.ts.map +1 -1
  419. package/build-types/components/document-bar/index.d.ts.map +1 -1
  420. package/build-types/components/document-tools/index.d.ts.map +1 -1
  421. package/build-types/components/editor-interface/index.d.ts +1 -2
  422. package/build-types/components/editor-interface/index.d.ts.map +1 -1
  423. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  424. package/build-types/components/header/index.d.ts.map +1 -1
  425. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  426. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  427. package/build-types/components/plugin-more-menu-item/index.d.ts +62 -2
  428. package/build-types/components/plugin-more-menu-item/index.d.ts.map +1 -1
  429. package/build-types/components/plugin-preview-menu-item/index.d.ts +41 -2
  430. package/build-types/components/plugin-preview-menu-item/index.d.ts.map +1 -1
  431. package/build-types/components/plugin-sidebar/index.d.ts.map +1 -1
  432. package/build-types/components/post-author/panel.d.ts.map +1 -1
  433. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  434. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  435. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  436. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  437. package/build-types/components/post-url/index.d.ts.map +1 -1
  438. package/build-types/components/post-url/panel.d.ts.map +1 -1
  439. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  440. package/build-types/components/provider/index.d.ts.map +1 -1
  441. package/build-types/components/sidebar/index.d.ts.map +1 -1
  442. package/build-types/components/visual-editor/edit-template-blocks-notification.d.ts.map +1 -1
  443. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  444. package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts +5 -0
  445. package/build-types/components/visual-editor/use-zoom-out-mode-exit.d.ts.map +1 -0
  446. package/build-types/components/zoom-out-toggle/index.d.ts +3 -1
  447. package/build-types/components/zoom-out-toggle/index.d.ts.map +1 -1
  448. package/build-types/private-apis.d.ts.map +1 -1
  449. package/build-types/store/actions.d.ts +1 -4
  450. package/build-types/store/actions.d.ts.map +1 -1
  451. package/build-types/store/selectors.d.ts +21 -0
  452. package/build-types/store/selectors.d.ts.map +1 -1
  453. package/build-types/utils/pageTypeBadge.d.ts +5 -0
  454. package/build-types/utils/pageTypeBadge.d.ts.map +1 -0
  455. package/build-types/utils/terms.d.ts.map +1 -1
  456. package/package.json +39 -38
  457. package/src/bindings/api.js +1 -32
  458. package/src/bindings/post-meta.js +1 -0
  459. package/src/components/collab-sidebar/add-comment.js +124 -0
  460. package/src/components/collab-sidebar/comment-button-toolbar.js +29 -0
  461. package/src/components/collab-sidebar/comment-button.js +31 -0
  462. package/src/components/collab-sidebar/comments.js +404 -0
  463. package/src/components/collab-sidebar/constants.js +1 -0
  464. package/src/components/collab-sidebar/index.js +307 -0
  465. package/src/components/collab-sidebar/style.scss +111 -0
  466. package/src/components/collab-sidebar/utils.js +9 -0
  467. package/src/components/commands/index.js +9 -7
  468. package/src/components/document-bar/index.js +15 -7
  469. package/src/components/document-bar/style.scss +0 -4
  470. package/src/components/document-tools/index.js +2 -8
  471. package/src/components/editor-interface/index.js +4 -18
  472. package/src/components/entities-saved-states/index.js +2 -2
  473. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +3 -3
  474. package/src/components/global-styles-provider/index.js +20 -6
  475. package/src/components/header/index.js +3 -1
  476. package/src/components/header/style.scss +1 -0
  477. package/src/components/inserter-sidebar/index.js +3 -6
  478. package/src/components/page-attributes/parent.js +6 -4
  479. package/src/components/plugin-more-menu-item/index.js +12 -11
  480. package/src/components/plugin-preview-menu-item/index.js +14 -13
  481. package/src/components/plugin-sidebar/index.js +0 -13
  482. package/src/components/post-actions/index.js +8 -11
  483. package/src/components/post-author/panel.js +4 -2
  484. package/src/components/post-card-panel/index.js +9 -43
  485. package/src/components/post-card-panel/style.scss +1 -9
  486. package/src/components/post-content-information/index.js +1 -1
  487. package/src/components/post-featured-image/index.js +31 -16
  488. package/src/components/post-featured-image/style.scss +5 -2
  489. package/src/components/post-last-revision/index.js +1 -1
  490. package/src/components/post-saved-state/test/__snapshots__/index.js.snap +1 -1
  491. package/src/components/post-schedule/label.js +1 -1
  492. package/src/components/post-sticky/test/index.js +6 -6
  493. package/src/components/post-taxonomies/flat-term-selector.js +15 -4
  494. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  495. package/src/components/post-template/classic-theme.js +1 -2
  496. package/src/components/post-url/index.js +67 -55
  497. package/src/components/post-url/panel.js +61 -35
  498. package/src/components/post-url/style.scss +21 -3
  499. package/src/components/preview-dropdown/index.js +0 -2
  500. package/src/components/provider/index.js +32 -24
  501. package/src/components/provider/use-block-editor-settings.js +1 -1
  502. package/src/components/sidebar/header.js +3 -2
  503. package/src/components/sidebar/index.js +5 -3
  504. package/src/components/time-to-read/index.js +3 -3
  505. package/src/components/visual-editor/edit-template-blocks-notification.js +5 -1
  506. package/src/components/visual-editor/index.js +32 -39
  507. package/src/components/visual-editor/use-zoom-out-mode-exit.js +49 -0
  508. package/src/components/zoom-out-toggle/index.js +39 -5
  509. package/src/dataviews/actions/duplicate-template-part.tsx +3 -3
  510. package/src/private-apis.js +1 -5
  511. package/src/store/actions.js +33 -4
  512. package/src/store/private-actions.js +3 -3
  513. package/src/store/selectors.js +24 -2
  514. package/src/style.scss +1 -0
  515. package/src/utils/pageTypeBadge.js +41 -0
  516. package/src/utils/terms.js +4 -2
  517. package/src/utils/test/terms.js +3 -3
  518. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,264 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { __ } from '@wordpress/i18n';
5
+ import { useSelect, useDispatch, resolveSelect } from '@wordpress/data';
6
+ import { useState, useEffect, 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
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
25
+ const threadsEmptyArray = [];
26
+ const isBlockCommentExperimentEnabled = 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
+ return settings;
37
+ };
38
+
39
+ // Apply the filter to all core blocks
40
+ addFilter('blocks.registerBlockType', 'block-comment/modify-core-block-attributes', modifyBlockCommentAttributes);
41
+
42
+ /**
43
+ * Renders the Collab sidebar.
44
+ */
45
+ export default function CollabSidebar() {
46
+ const {
47
+ createNotice
48
+ } = useDispatch(noticesStore);
49
+ const {
50
+ saveEntityRecord,
51
+ deleteEntityRecord
52
+ } = useDispatch(coreStore);
53
+ const {
54
+ getEntityRecord
55
+ } = resolveSelect(coreStore);
56
+ const {
57
+ enableComplementaryArea
58
+ } = useDispatch(interfaceStore);
59
+ const [blockCommentID, setBlockCommentID] = useState(null);
60
+ const [showCommentBoard, setShowCommentBoard] = useState(false);
61
+ const {
62
+ postId
63
+ } = useSelect(select => {
64
+ return {
65
+ postId: select(editorStore).getCurrentPostId()
66
+ };
67
+ }, []);
68
+ const postStatus = useSelect(select => {
69
+ const post = select(editorStore).getCurrentPost();
70
+ return {
71
+ postStatus: post?.status
72
+ };
73
+ }, []);
74
+ const threads = useSelect(select => {
75
+ if (!postId) {
76
+ return threadsEmptyArray;
77
+ }
78
+ const {
79
+ getEntityRecords
80
+ } = select(coreStore);
81
+ const data = getEntityRecords('root', 'comment', {
82
+ post: postId,
83
+ type: 'block_comment',
84
+ status: 'any',
85
+ per_page: 100
86
+ });
87
+ return data || threadsEmptyArray;
88
+ }, [postId]);
89
+ const clientId = useSelect(select => {
90
+ const {
91
+ getSelectedBlockClientId
92
+ } = select(blockEditorStore);
93
+ return getSelectedBlockClientId();
94
+ }, []);
95
+ const blockDetails = useSelect(select => {
96
+ return clientId ? select(blockEditorStore).getBlock(clientId) : null;
97
+ }, [clientId]);
98
+
99
+ // Get the dispatch functions to save the comment and update the block attributes.
100
+ const {
101
+ updateBlockAttributes
102
+ } = useDispatch(blockEditorStore);
103
+
104
+ // Process comments to build the tree structure
105
+ const resultComments = useMemo(() => {
106
+ // Create a compare to store the references to all objects by id
107
+ const compare = {};
108
+ const result = [];
109
+ const filteredComments = threads.filter(comment => comment.status !== 'trash');
110
+
111
+ // Initialize each object with an empty `reply` array
112
+ filteredComments.forEach(item => {
113
+ compare[item.id] = {
114
+ ...item,
115
+ reply: []
116
+ };
117
+ });
118
+
119
+ // Iterate over the data to build the tree structure
120
+ filteredComments.forEach(item => {
121
+ if (item.parent === 0) {
122
+ // If parent is 0, it's a root item, push it to the result array
123
+ result.push(compare[item.id]);
124
+ } else if (compare[item.parent]) {
125
+ // Otherwise, find its parent and push it to the parent's `reply` array
126
+ compare[item.parent].reply.push(compare[item.id]);
127
+ }
128
+ });
129
+ return result;
130
+ }, [threads]);
131
+ const openCollabBoard = () => {
132
+ setShowCommentBoard(true);
133
+ enableComplementaryArea('core', 'edit-post/collab-sidebar');
134
+ };
135
+
136
+ // Function to save the comment.
137
+ const addNewComment = async (comment, parentCommentId) => {
138
+ const args = {
139
+ post: postId,
140
+ content: comment,
141
+ comment_type: 'block_comment',
142
+ comment_approved: 0
143
+ };
144
+
145
+ // Create a new object, conditionally including the parent property
146
+ const updatedArgs = {
147
+ ...args,
148
+ ...(parentCommentId ? {
149
+ parent: parentCommentId
150
+ } : {})
151
+ };
152
+ const savedRecord = await saveEntityRecord('root', 'comment', updatedArgs);
153
+ if (savedRecord) {
154
+ // If it's a main comment, update the block attributes with the comment id.
155
+ if (!parentCommentId) {
156
+ updateBlockAttributes(clientId, {
157
+ blockCommentId: savedRecord?.id
158
+ });
159
+ }
160
+ createNotice('snackbar', parentCommentId ?
161
+ // translators: Reply added successfully
162
+ __('Reply added successfully.') :
163
+ // translators: Comment added successfully
164
+ __('Comment added successfully.'), {
165
+ type: 'snackbar',
166
+ isDismissible: true
167
+ });
168
+ } else {
169
+ onError();
170
+ }
171
+ };
172
+ const onCommentResolve = async commentId => {
173
+ const savedRecord = await saveEntityRecord('root', 'comment', {
174
+ id: commentId,
175
+ status: 'approved'
176
+ });
177
+ if (savedRecord) {
178
+ // translators: Comment resolved successfully
179
+ createNotice('snackbar', __('Comment marked as resolved.'), {
180
+ type: 'snackbar',
181
+ isDismissible: true
182
+ });
183
+ } else {
184
+ onError();
185
+ }
186
+ };
187
+ const onEditComment = async (commentId, comment) => {
188
+ const savedRecord = await saveEntityRecord('root', 'comment', {
189
+ id: commentId,
190
+ content: comment
191
+ });
192
+ if (savedRecord) {
193
+ createNotice('snackbar',
194
+ // translators: Comment edited successfully
195
+ __('Comment edited successfully.'), {
196
+ type: 'snackbar',
197
+ isDismissible: true
198
+ });
199
+ } else {
200
+ onError();
201
+ }
202
+ };
203
+ const onError = () => {
204
+ createNotice('error',
205
+ // translators: Error message when comment submission fails
206
+ __('Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'), {
207
+ isDismissible: true
208
+ });
209
+ };
210
+ const onCommentDelete = async commentId => {
211
+ const childComment = await getEntityRecord('root', 'comment', commentId);
212
+ await deleteEntityRecord('root', 'comment', commentId);
213
+ if (childComment && !childComment.parent) {
214
+ updateBlockAttributes(clientId, {
215
+ blockCommentId: undefined
216
+ });
217
+ }
218
+ createNotice('snackbar',
219
+ // translators: Comment deleted successfully
220
+ __('Comment deleted successfully.'), {
221
+ type: 'snackbar',
222
+ isDismissible: true
223
+ });
224
+ };
225
+ useEffect(() => {
226
+ if (blockDetails) {
227
+ setBlockCommentID(blockDetails?.attributes.blockCommentId);
228
+ }
229
+ }, [postId, clientId]);
230
+
231
+ // Check if the experimental flag is enabled.
232
+ if (!isBlockCommentExperimentEnabled || postStatus.postStatus === 'publish') {
233
+ return null; // or maybe return some message indicating no threads are available.
234
+ }
235
+ return /*#__PURE__*/_jsxs(_Fragment, {
236
+ children: [!blockCommentID && /*#__PURE__*/_jsx(AddCommentButton, {
237
+ onClick: openCollabBoard
238
+ }), blockCommentID > 0 && /*#__PURE__*/_jsx(AddCommentToolbarButton, {
239
+ onClick: openCollabBoard
240
+ }), /*#__PURE__*/_jsx(PluginSidebar, {
241
+ identifier: collabSidebarName
242
+ // translators: Comments sidebar title
243
+ ,
244
+ title: __('Comments'),
245
+ icon: commentIcon,
246
+ children: /*#__PURE__*/_jsxs("div", {
247
+ className: "editor-collab-sidebar-panel",
248
+ children: [/*#__PURE__*/_jsx(AddComment, {
249
+ threads: resultComments,
250
+ onSubmit: addNewComment,
251
+ showCommentBoard: showCommentBoard,
252
+ setShowCommentBoard: setShowCommentBoard
253
+ }), /*#__PURE__*/_jsx(Comments, {
254
+ threads: resultComments,
255
+ onEditComment: onEditComment,
256
+ onAddReply: addNewComment,
257
+ onCommentDelete: onCommentDelete,
258
+ onCommentResolve: onCommentResolve
259
+ })]
260
+ })
261
+ })]
262
+ });
263
+ }
264
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__","useSelect","useDispatch","resolveSelect","useState","useEffect","useMemo","comment","commentIcon","addFilter","store","noticesStore","coreStore","blockEditorStore","interfaceStore","PluginSidebar","collabSidebarName","Comments","AddComment","editorStore","AddCommentButton","AddCommentToolbarButton","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","threadsEmptyArray","isBlockCommentExperimentEnabled","window","__experimentalEnableBlockComment","modifyBlockCommentAttributes","settings","attributes","blockCommentId","type","CollabSidebar","createNotice","saveEntityRecord","deleteEntityRecord","getEntityRecord","enableComplementaryArea","blockCommentID","setBlockCommentID","showCommentBoard","setShowCommentBoard","postId","select","getCurrentPostId","postStatus","post","getCurrentPost","status","threads","getEntityRecords","data","per_page","clientId","getSelectedBlockClientId","blockDetails","getBlock","updateBlockAttributes","resultComments","compare","result","filteredComments","filter","forEach","item","id","reply","parent","push","openCollabBoard","addNewComment","parentCommentId","args","content","comment_type","comment_approved","updatedArgs","savedRecord","isDismissible","onError","onCommentResolve","commentId","onEditComment","onCommentDelete","childComment","undefined","children","onClick","identifier","title","icon","className","onSubmit","onAddReply"],"sources":["@wordpress/editor/src/components/collab-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, resolveSelect } from '@wordpress/data';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { comment as commentIcon } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport PluginSidebar from '../plugin-sidebar';\nimport { collabSidebarName } from './constants';\nimport { Comments } from './comments';\nimport { AddComment } from './add-comment';\nimport { store as editorStore } from '../../store';\nimport AddCommentButton from './comment-button';\nimport AddCommentToolbarButton from './comment-button-toolbar';\n\nconst threadsEmptyArray = [];\n\nconst isBlockCommentExperimentEnabled =\n\twindow?.__experimentalEnableBlockComment;\nconst modifyBlockCommentAttributes = ( settings ) => {\n\tif ( ! settings.attributes.blockCommentId ) {\n\t\tsettings.attributes = {\n\t\t\t...settings.attributes,\n\t\t\tblockCommentId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn settings;\n};\n\n// Apply the filter to all core blocks\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-comment/modify-core-block-attributes',\n\tmodifyBlockCommentAttributes\n);\n\n/**\n * Renders the Collab sidebar.\n */\nexport default function CollabSidebar() {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord, deleteEntityRecord } = useDispatch( coreStore );\n\tconst { getEntityRecord } = resolveSelect( coreStore );\n\tconst { enableComplementaryArea } = useDispatch( interfaceStore );\n\tconst [ blockCommentID, setBlockCommentID ] = useState( null );\n\tconst [ showCommentBoard, setShowCommentBoard ] = useState( false );\n\tconst { postId } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostId: select( editorStore ).getCurrentPostId(),\n\t\t};\n\t}, [] );\n\n\tconst postStatus = useSelect( ( select ) => {\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\treturn { postStatus: post?.status };\n\t}, [] );\n\n\tconst threads = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! postId ) {\n\t\t\t\treturn threadsEmptyArray;\n\t\t\t}\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst data = getEntityRecords( 'root', 'comment', {\n\t\t\t\tpost: postId,\n\t\t\t\ttype: 'block_comment',\n\t\t\t\tstatus: 'any',\n\t\t\t\tper_page: 100,\n\t\t\t} );\n\t\t\treturn data || threadsEmptyArray;\n\t\t},\n\t\t[ postId ]\n\t);\n\n\tconst clientId = useSelect( ( select ) => {\n\t\tconst { getSelectedBlockClientId } = select( blockEditorStore );\n\t\treturn getSelectedBlockClientId();\n\t}, [] );\n\n\tconst blockDetails = useSelect(\n\t\t( select ) => {\n\t\t\treturn clientId\n\t\t\t\t? select( blockEditorStore ).getBlock( clientId )\n\t\t\t\t: null;\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Get the dispatch functions to save the comment and update the block attributes.\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\n\t// Process comments to build the tree structure\n\tconst resultComments = useMemo( () => {\n\t\t// Create a compare to store the references to all objects by id\n\t\tconst compare = {};\n\t\tconst result = [];\n\n\t\tconst filteredComments = threads.filter(\n\t\t\t( comment ) => comment.status !== 'trash'\n\t\t);\n\n\t\t// Initialize each object with an empty `reply` array\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tcompare[ item.id ] = { ...item, reply: [] };\n\t\t} );\n\n\t\t// Iterate over the data to build the tree structure\n\t\tfilteredComments.forEach( ( item ) => {\n\t\t\tif ( item.parent === 0 ) {\n\t\t\t\t// If parent is 0, it's a root item, push it to the result array\n\t\t\t\tresult.push( compare[ item.id ] );\n\t\t\t} else if ( compare[ item.parent ] ) {\n\t\t\t\t// Otherwise, find its parent and push it to the parent's `reply` array\n\t\t\t\tcompare[ item.parent ].reply.push( compare[ item.id ] );\n\t\t\t}\n\t\t} );\n\n\t\treturn result;\n\t}, [ threads ] );\n\n\tconst openCollabBoard = () => {\n\t\tsetShowCommentBoard( true );\n\t\tenableComplementaryArea( 'core', 'edit-post/collab-sidebar' );\n\t};\n\n\t// Function to save the comment.\n\tconst addNewComment = async ( comment, parentCommentId ) => {\n\t\tconst args = {\n\t\t\tpost: postId,\n\t\t\tcontent: comment,\n\t\t\tcomment_type: 'block_comment',\n\t\t\tcomment_approved: 0,\n\t\t};\n\n\t\t// Create a new object, conditionally including the parent property\n\t\tconst updatedArgs = {\n\t\t\t...args,\n\t\t\t...( parentCommentId ? { parent: parentCommentId } : {} ),\n\t\t};\n\n\t\tconst savedRecord = await saveEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tupdatedArgs\n\t\t);\n\n\t\tif ( savedRecord ) {\n\t\t\t// If it's a main comment, update the block attributes with the comment id.\n\t\t\tif ( ! parentCommentId ) {\n\t\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\t\tblockCommentId: savedRecord?.id,\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\tparentCommentId\n\t\t\t\t\t? // translators: Reply added successfully\n\t\t\t\t\t __( 'Reply added successfully.' )\n\t\t\t\t\t: // translators: Comment added successfully\n\t\t\t\t\t __( 'Comment added successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onCommentResolve = async ( commentId ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tstatus: 'approved',\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\t// translators: Comment resolved successfully\n\t\t\tcreateNotice( 'snackbar', __( 'Comment marked as resolved.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onEditComment = async ( commentId, comment ) => {\n\t\tconst savedRecord = await saveEntityRecord( 'root', 'comment', {\n\t\t\tid: commentId,\n\t\t\tcontent: comment,\n\t\t} );\n\n\t\tif ( savedRecord ) {\n\t\t\tcreateNotice(\n\t\t\t\t'snackbar',\n\t\t\t\t// translators: Comment edited successfully\n\t\t\t\t__( 'Comment edited successfully.' ),\n\t\t\t\t{\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tisDismissible: true,\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tonError();\n\t\t}\n\t};\n\n\tconst onError = () => {\n\t\tcreateNotice(\n\t\t\t'error',\n\t\t\t// translators: Error message when comment submission fails\n\t\t\t__(\n\t\t\t\t'Something went wrong. Please try publishing the post, or you may have already submitted your comment earlier.'\n\t\t\t),\n\t\t\t{\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tconst onCommentDelete = async ( commentId ) => {\n\t\tconst childComment = await getEntityRecord(\n\t\t\t'root',\n\t\t\t'comment',\n\t\t\tcommentId\n\t\t);\n\t\tawait deleteEntityRecord( 'root', 'comment', commentId );\n\n\t\tif ( childComment && ! childComment.parent ) {\n\t\t\tupdateBlockAttributes( clientId, {\n\t\t\t\tblockCommentId: undefined,\n\t\t\t} );\n\t\t}\n\n\t\tcreateNotice(\n\t\t\t'snackbar',\n\t\t\t// translators: Comment deleted successfully\n\t\t\t__( 'Comment deleted successfully.' ),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t\tisDismissible: true,\n\t\t\t}\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tif ( blockDetails ) {\n\t\t\tsetBlockCommentID( blockDetails?.attributes.blockCommentId );\n\t\t}\n\t}, [ postId, clientId ] );\n\n\t// Check if the experimental flag is enabled.\n\tif (\n\t\t! isBlockCommentExperimentEnabled ||\n\t\tpostStatus.postStatus === 'publish'\n\t) {\n\t\treturn null; // or maybe return some message indicating no threads are available.\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ ! blockCommentID && (\n\t\t\t\t<AddCommentButton onClick={ openCollabBoard } />\n\t\t\t) }\n\n\t\t\t{ blockCommentID > 0 && (\n\t\t\t\t<AddCommentToolbarButton onClick={ openCollabBoard } />\n\t\t\t) }\n\t\t\t<PluginSidebar\n\t\t\t\tidentifier={ collabSidebarName }\n\t\t\t\t// translators: Comments sidebar title\n\t\t\t\ttitle={ __( 'Comments' ) }\n\t\t\t\ticon={ commentIcon }\n\t\t\t>\n\t\t\t\t<div className=\"editor-collab-sidebar-panel\">\n\t\t\t\t\t<AddComment\n\t\t\t\t\t\tthreads={ resultComments }\n\t\t\t\t\t\tonSubmit={ addNewComment }\n\t\t\t\t\t\tshowCommentBoard={ showCommentBoard }\n\t\t\t\t\t\tsetShowCommentBoard={ setShowCommentBoard }\n\t\t\t\t\t/>\n\t\t\t\t\t<Comments\n\t\t\t\t\t\tthreads={ resultComments }\n\t\t\t\t\t\tonEditComment={ onEditComment }\n\t\t\t\t\t\tonAddReply={ addNewComment }\n\t\t\t\t\t\tonCommentDelete={ onCommentDelete }\n\t\t\t\t\t\tonCommentResolve={ onCommentResolve }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t</PluginSidebar>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,EAAEC,WAAW,EAAEC,aAAa,QAAQ,iBAAiB;AACvE,SAASC,QAAQ,EAAEC,SAAS,EAAEC,OAAO,QAAQ,oBAAoB;AACjE,SAASC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACzD,SAASC,SAAS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gB,YAAY,EAAE1B,UAAU,CAACC,cAAe,CAAC;IAC7D;EACD,CAAC,EAAE,CAAEY,MAAM,EAAEW,QAAQ,CAAG,CAAC;;EAEzB;EACA,IACC,CAAE7B,+BAA+B,IACjCqB,UAAU,CAACA,UAAU,KAAK,SAAS,EAClC;IACD,OAAO,IAAI,CAAC,CAAC;EACd;EAEA,oBACCzB,KAAA,CAAAE,SAAA;IAAAgE,QAAA,GACG,CAAEhD,cAAc,iBACjBpB,IAAA,CAACH,gBAAgB;MAACwE,OAAO,EAAGlB;IAAiB,CAAE,CAC/C,EAEC/B,cAAc,GAAG,CAAC,iBACnBpB,IAAA,CAACF,uBAAuB;MAACuE,OAAO,EAAGlB;IAAiB,CAAE,CACtD,eACDnD,IAAA,CAACR,aAAa;MACb8E,UAAU,EAAG7E;MACb;MAAA;MACA8E,KAAK,EAAG9F,EAAE,CAAE,UAAW,CAAG;MAC1B+F,IAAI,EAAGvF,WAAa;MAAAmF,QAAA,eAEpBlE,KAAA;QAAKuE,SAAS,EAAC,6BAA6B;QAAAL,QAAA,gBAC3CpE,IAAA,CAACL,UAAU;UACVoC,OAAO,EAAGS,cAAgB;UAC1BkC,QAAQ,EAAGtB,aAAe;UAC1B9B,gBAAgB,EAAGA,gBAAkB;UACrCC,mBAAmB,EAAGA;QAAqB,CAC3C,CAAC,eACFvB,IAAA,CAACN,QAAQ;UACRqC,OAAO,EAAGS,cAAgB;UAC1BwB,aAAa,EAAGA,aAAe;UAC/BW,UAAU,EAAGvB,aAAe;UAC5Ba,eAAe,EAAGA,eAAiB;UACnCH,gBAAgB,EAAGA;QAAkB,CACrC,CAAC;MAAA,CACE;IAAC,CACQ,CAAC;EAAA,CACf,CAAC;AAEL","ignoreList":[]}
@@ -0,0 +1,10 @@
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
+ }
10
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["sanitizeCommentString","str","trim"],"sources":["@wordpress/editor/src/components/collab-sidebar/utils.js"],"sourcesContent":["/**\n * Sanitizes a comment string by removing non-printable ASCII characters.\n *\n * @param {string} str - The comment string to sanitize.\n * @return {string} - The sanitized comment string.\n */\nexport function sanitizeCommentString( str ) {\n\treturn str.trim();\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASA,qBAAqBA,CAAEC,GAAG,EAAG;EAC5C,OAAOA,GAAG,CAACC,IAAI,CAAC,CAAC;AAClB","ignoreList":[]}
@@ -17,9 +17,7 @@ import { useSelect } from '@wordpress/data';
17
17
  * Internal dependencies
18
18
  */
19
19
  import { unlock } from '../../lock-unlock';
20
- import { jsx as _jsx } from "react/jsx-runtime";
21
- import { Fragment as _Fragment } from "react/jsx-runtime";
22
- import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
23
21
  const {
24
22
  useHasBlockToolbar
25
23
  } = unlock(blockEditorPrivateApis);
@@ -1 +1 @@
1
- {"version":3,"names":["clsx","BlockToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","useEffect","Button","Popover","__","next","previous","useSelect","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHasBlockToolbar","CollapsibleBlockToolbar","isCollapsed","onToggle","blockSelectionStart","select","getBlockSelectionStart","hasBlockToolbar","hasBlockSelection","children","className","hideDragHandle","Slot","name","icon","onClick","label","size"],"sources":["@wordpress/editor/src/components/collapsible-block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHasBlockToolbar } = unlock( blockEditorPrivateApis );\n\nexport default function CollapsibleBlockToolbar( { isCollapsed, onToggle } ) {\n\tconst { blockSelectionStart } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockSelectionStart:\n\t\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\n\tconst hasBlockSelection = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tonToggle( false );\n\t\t}\n\t}, [ blockSelectionStart, onToggle ] );\n\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'editor-collapsible-block-toolbar', {\n\t\t\t\t\t'is-collapsed': isCollapsed || ! hasBlockSelection,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t</div>\n\t\t\t<Popover.Slot name=\"block-toolbar\" />\n\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collapsible-block-toolbar__toggle\"\n\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonToggle( ! isCollapsed );\n\t\t\t\t} }\n\t\t\t\tlabel={\n\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t}\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;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,CAAE,CAAG;MAAAC,QAAA,eAELd,IAAA,CAACd,YAAY;QAAC8B,cAAc;MAAA,CAAE;IAAC,CAC3B,CAAC,eACNhB,IAAA,CAACP,OAAO,CAACwB,IAAI;MAACC,IAAI,EAAC;IAAe,CAAE,CAAC,eAErClB,IAAA,CAACR,MAAM;MACNuB,SAAS,EAAC,0CAA0C;MACpDI,IAAI,EAAGZ,WAAW,GAAGZ,IAAI,GAAGC,QAAU;MACtCwB,OAAO,EAAGA,CAAA,KAAM;QACfZ,QAAQ,CAAE,CAAED,WAAY,CAAC;MAC1B,CAAG;MACHc,KAAK,EACJd,WAAW,GACRb,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CAAE,kBAAmB,CAC1B;MACD4B,IAAI,EAAC;IAAS,CACd,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
1
+ {"version":3,"names":["clsx","BlockToolbar","store","blockEditorStore","privateApis","blockEditorPrivateApis","useEffect","Button","Popover","__","next","previous","useSelect","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","useHasBlockToolbar","CollapsibleBlockToolbar","isCollapsed","onToggle","blockSelectionStart","select","getBlockSelectionStart","hasBlockToolbar","hasBlockSelection","children","className","hideDragHandle","Slot","name","icon","onClick","label","size"],"sources":["@wordpress/editor/src/components/collapsible-block-toolbar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect } from '@wordpress/element';\nimport { Button, Popover } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { useHasBlockToolbar } = unlock( blockEditorPrivateApis );\n\nexport default function CollapsibleBlockToolbar( { isCollapsed, onToggle } ) {\n\tconst { blockSelectionStart } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tblockSelectionStart:\n\t\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t\t};\n\t}, [] );\n\tconst hasBlockToolbar = useHasBlockToolbar();\n\n\tconst hasBlockSelection = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tonToggle( false );\n\t\t}\n\t}, [ blockSelectionStart, onToggle ] );\n\n\tif ( ! hasBlockToolbar ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'editor-collapsible-block-toolbar', {\n\t\t\t\t\t'is-collapsed': isCollapsed || ! hasBlockSelection,\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t</div>\n\t\t\t<Popover.Slot name=\"block-toolbar\" />\n\n\t\t\t<Button\n\t\t\t\tclassName=\"editor-collapsible-block-toolbar__toggle\"\n\t\t\t\ticon={ isCollapsed ? next : previous }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonToggle( ! isCollapsed );\n\t\t\t\t} }\n\t\t\t\tlabel={\n\t\t\t\t\tisCollapsed\n\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t}\n\t\t\t\tsize=\"compact\"\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SACCC,YAAY,EACZC,KAAK,IAAIC,gBAAgB,EACzBC,WAAW,IAAIC,sBAAsB,QAC/B,yBAAyB;AAChC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,MAAM,EAAEC,OAAO,QAAQ,uBAAuB;AACvD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EA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EAAGZ,WAAW,GAAGZ,IAAI,GAAGC,QAAU;MACtCwB,OAAO,EAAGA,CAAA,KAAM;QACfZ,QAAQ,CAAE,CAAED,WAAY,CAAC;MAC1B,CAAG;MACHc,KAAK,EACJd,WAAW,GACRb,EAAE,CAAE,kBAAmB,CAAC,GACxBA,EAAE,CAAE,kBAAmB,CAC1B;MACD4B,IAAI,EAAC;IAAS,CACd,CAAC;EAAA,CACD,CAAC;AAEL","ignoreList":[]}
@@ -54,7 +54,7 @@ function useEditorCommandLoader() {
54
54
  isDistractionFree: get('core', 'distractionFree'),
55
55
  isFocusMode: get('core', 'focusMode'),
56
56
  isTopToolbar: get('core', 'fixedToolbar'),
57
- isPreviewMode: getSettings().__unstableIsPreviewMode,
57
+ isPreviewMode: getSettings().isPreviewMode,
58
58
  isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
59
59
  isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
60
60
  isRichEditingEnabled: getEditorSettings().richEditingEnabled,
@@ -105,7 +105,7 @@ function useEditorCommandLoader() {
105
105
  });
106
106
  commands.push({
107
107
  name: 'core/toggle-distraction-free',
108
- label: isDistractionFree ? __('Exit Distraction Free') : __('Enter Distraction Free'),
108
+ label: isDistractionFree ? __('Exit Distraction free') : __('Enter Distraction free'),
109
109
  callback: ({
110
110
  close
111
111
  }) => {
@@ -125,7 +125,7 @@ function useEditorCommandLoader() {
125
125
  });
126
126
  commands.push({
127
127
  name: 'core/toggle-spotlight-mode',
128
- label: __('Toggle spotlight'),
128
+ label: isFocusMode ? __('Exit Spotlight mode') : __('Enter Spotlight mode'),
129
129
  callback: ({
130
130
  close
131
131
  }) => {
@@ -160,7 +160,7 @@ function useEditorCommandLoader() {
160
160
  });
161
161
  commands.push({
162
162
  name: 'core/toggle-top-toolbar',
163
- label: __('Toggle top toolbar'),
163
+ label: __('Top toolbar'),
164
164
  callback: ({
165
165
  close
166
166
  }) => {
@@ -210,7 +210,7 @@ function useEditorCommandLoader() {
210
210
  });
211
211
  commands.push({
212
212
  name: 'core/open-settings-sidebar',
213
- label: __('Toggle settings sidebar'),
213
+ label: __('Show or hide the Settings panel.'),
214
214
  icon: isRTL() ? drawerLeft : drawerRight,
215
215
  callback: ({
216
216
  close
@@ -226,7 +226,7 @@ function useEditorCommandLoader() {
226
226
  });
227
227
  commands.push({
228
228
  name: 'core/open-block-inspector',
229
- label: __('Toggle block inspector'),
229
+ label: __('Show or hide the Block settings panel'),
230
230
  icon: blockDefault,
231
231
  callback: ({
232
232
  close
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","__","isRTL","blockDefault","code","drawerLeft","drawerRight","edit","formatListBullets","listView","external","keyboard","symbol","useCommandLoader","store","preferencesStore","noticesStore","blockEditorStore","coreStore","interfaceStore","editorStore","PATTERN_POST_TYPE","modalName","patternRenameModalName","patternDuplicateModalName","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","isCodeEditingEnabled","isRichEditingEnabled","isPublishSidebarEnabled","select","_get","_getPostType$viewable","get","isListViewOpened","getCurrentPostType","getEditorSettings","getSettings","getPostType","__unstableIsPreviewMode","viewable","codeEditingEnabled","richEditingEnabled","getActiveComplementaryArea","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","openModal","enableComplementaryArea","disableComplementaryArea","getCurrentPostId","allowSwitchEditorMode","commands","isLoading","push","name","label","icon","callback","close","id","type","actions","onClick","activeSidebar","postId","link","window","open","useEditedEntityContextualCommands","postType","useCommands","hook","context"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tblockDefault,\n\tcode,\n\tdrawerLeft,\n\tdrawerRight,\n\tedit,\n\tformatListBullets,\n\tlistView,\n\texternal,\n\tkeyboard,\n\tsymbol,\n} from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { PATTERN_POST_TYPE } from '../../store/constants';\nimport { modalName as patternRenameModalName } from '../pattern-rename-modal';\nimport { modalName as patternDuplicateModalName } from '../pattern-duplicate-modal';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t\tisCodeEditingEnabled,\n\t\tisRichEditingEnabled,\n\t\tisPublishSidebarEnabled,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().__unstableIsPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t\tisCodeEditingEnabled: getEditorSettings().codeEditingEnabled,\n\t\t\tisRichEditingEnabled: getEditorSettings().richEditingEnabled,\n\t\t\tisPublishSidebarEnabled:\n\t\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\t};\n\t}, [] );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { openModal, enableComplementaryArea, disableComplementaryArea } =\n\t\tuseDispatch( interfaceStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/open-shortcut-help',\n\t\tlabel: __( 'Keyboard shortcuts' ),\n\t\ticon: keyboard,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\topenModal( 'editor/keyboard-shortcut-help' );\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-preferences',\n\t\tlabel: __( 'Editor preferences' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\topenModal( 'editor/preferences' );\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( allowSwitchEditorMode ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/toggle-code-editor',\n\t\t\tlabel:\n\t\t\t\teditorMode === 'visual'\n\t\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t\t: __( 'Exit code editor' ),\n\t\t\ticon: code,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tcommands.push( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/document' ) {\n\t\t\t\tdisableComplementaryArea( 'core' );\n\t\t\t} else {\n\t\t\t\tenableComplementaryArea( 'core', 'edit-post/document' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/block' ) {\n\t\t\t\tdisableComplementaryArea( 'core' );\n\t\t\t} else {\n\t\t\t\tenableComplementaryArea( 'core', 'edit-post/block' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-publish-sidebar',\n\t\tlabel: isPublishSidebarEnabled\n\t\t\t? __( 'Disable pre-publish checks' )\n\t\t\t: __( 'Enable pre-publish checks' ),\n\t\ticon: formatListBullets,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\ttoggle( 'core', 'isPublishSidebarEnabled' );\n\t\t\tcreateInfoNotice(\n\t\t\t\tisPublishSidebarEnabled\n\t\t\t\t\t? __( 'Pre-publish checks disabled.' )\n\t\t\t\t\t: __( 'Pre-publish checks enabled.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/publish-sidebar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nfunction useEditedEntityContextualCommands() {\n\tconst { postType } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst commands = [];\n\n\tif ( postType === PATTERN_POST_TYPE ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/rename-pattern',\n\t\t\tlabel: __( 'Rename pattern' ),\n\t\t\ticon: edit,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\topenModal( patternRenameModalName );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t\tcommands.push( {\n\t\t\tname: 'core/duplicate-pattern',\n\t\t\tlabel: __( 'Duplicate pattern' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\topenModal( patternDuplicateModalName );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/editor/contextual-commands',\n\t\thook: useEditedEntityContextualCommands,\n\t\tcontext: 'entity-edit',\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,YAAY,EACZC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,iBAAiB,EACjBC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,MAAM,QACA,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,yBAAyB;AACnE,SAASH,KAAK,IAAII,SAAS,QAAQ,sBAAsB;AACzD,SAASJ,KAAK,IAAIK,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASL,K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;EAAS,CAAC;AACtC;AAEA,eAAe,SAASmB,WAAWA,CAAA,EAAG;EACrCpE,gBAAgB,CAAE;IACjBoD,IAAI,EAAE,qBAAqB;IAC3BiB,IAAI,EAAEzD;EACP,CAAE,CAAC;EAEHZ,gBAAgB,CAAE;IACjBoD,IAAI,EAAE,iCAAiC;IACvCiB,IAAI,EAAEH,iCAAiC;IACvCI,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","__","isRTL","blockDefault","code","drawerLeft","drawerRight","edit","formatListBullets","listView","external","keyboard","symbol","useCommandLoader","store","preferencesStore","noticesStore","blockEditorStore","coreStore","interfaceStore","editorStore","PATTERN_POST_TYPE","modalName","patternRenameModalName","patternDuplicateModalName","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","isCodeEditingEnabled","isRichEditingEnabled","isPublishSidebarEnabled","select","_get","_getPostType$viewable","get","isListViewOpened","getCurrentPostType","getEditorSettings","getSettings","getPostType","viewable","codeEditingEnabled","richEditingEnabled","getActiveComplementaryArea","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","openModal","enableComplementaryArea","disableComplementaryArea","getCurrentPostId","allowSwitchEditorMode","commands","isLoading","push","name","label","icon","callback","close","id","type","actions","onClick","activeSidebar","postId","link","window","open","useEditedEntityContextualCommands","postType","useCommands","hook","context"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tblockDefault,\n\tcode,\n\tdrawerLeft,\n\tdrawerRight,\n\tedit,\n\tformatListBullets,\n\tlistView,\n\texternal,\n\tkeyboard,\n\tsymbol,\n} from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport { PATTERN_POST_TYPE } from '../../store/constants';\nimport { modalName as patternRenameModalName } from '../pattern-rename-modal';\nimport { modalName as patternDuplicateModalName } from '../pattern-duplicate-modal';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t\tisCodeEditingEnabled,\n\t\tisRichEditingEnabled,\n\t\tisPublishSidebarEnabled,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().isPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t\tisCodeEditingEnabled: getEditorSettings().codeEditingEnabled,\n\t\t\tisRichEditingEnabled: getEditorSettings().richEditingEnabled,\n\t\t\tisPublishSidebarEnabled:\n\t\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\t};\n\t}, [] );\n\tconst { getActiveComplementaryArea } = useSelect( interfaceStore );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { openModal, enableComplementaryArea, disableComplementaryArea } =\n\t\tuseDispatch( interfaceStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\tconst allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/open-shortcut-help',\n\t\tlabel: __( 'Keyboard shortcuts' ),\n\t\ticon: keyboard,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\topenModal( 'editor/keyboard-shortcut-help' );\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction free' )\n\t\t\t: __( 'Enter Distraction free' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-preferences',\n\t\tlabel: __( 'Editor preferences' ),\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\topenModal( 'editor/preferences' );\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: isFocusMode\n\t\t\t? __( 'Exit Spotlight mode' )\n\t\t\t: __( 'Enter Spotlight mode' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( allowSwitchEditorMode ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/toggle-code-editor',\n\t\t\tlabel:\n\t\t\t\teditorMode === 'visual'\n\t\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t\t: __( 'Exit code editor' ),\n\t\t\ticon: code,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tcommands.push( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Show or hide the Settings panel.' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/document' ) {\n\t\t\t\tdisableComplementaryArea( 'core' );\n\t\t\t} else {\n\t\t\t\tenableComplementaryArea( 'core', 'edit-post/document' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Show or hide the Block settings panel' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tconst activeSidebar = getActiveComplementaryArea( 'core' );\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/block' ) {\n\t\t\t\tdisableComplementaryArea( 'core' );\n\t\t\t} else {\n\t\t\t\tenableComplementaryArea( 'core', 'edit-post/block' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-publish-sidebar',\n\t\tlabel: isPublishSidebarEnabled\n\t\t\t? __( 'Disable pre-publish checks' )\n\t\t\t: __( 'Enable pre-publish checks' ),\n\t\ticon: formatListBullets,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\ttoggle( 'core', 'isPublishSidebarEnabled' );\n\t\t\tcreateInfoNotice(\n\t\t\t\tisPublishSidebarEnabled\n\t\t\t\t\t? __( 'Pre-publish checks disabled.' )\n\t\t\t\t\t: __( 'Pre-publish checks enabled.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/publish-sidebar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nfunction useEditedEntityContextualCommands() {\n\tconst { postType } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType } = select( editorStore );\n\t\treturn {\n\t\t\tpostType: getCurrentPostType(),\n\t\t};\n\t}, [] );\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst commands = [];\n\n\tif ( postType === PATTERN_POST_TYPE ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/rename-pattern',\n\t\t\tlabel: __( 'Rename pattern' ),\n\t\t\ticon: edit,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\topenModal( patternRenameModalName );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t\tcommands.push( {\n\t\t\tname: 'core/duplicate-pattern',\n\t\t\tlabel: __( 'Duplicate pattern' ),\n\t\t\ticon: symbol,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\topenModal( patternDuplicateModalName );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/editor/contextual-commands',\n\t\thook: useEditedEntityContextualCommands,\n\t\tcontext: 'entity-edit',\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,YAAY,EACZC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,IAAI,EACJC,iBAAiB,EACjBC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,MAAM,QACA,kBAAkB;AACzB,SAASC,gBAAgB,QAAQ,qBAAqB;AACtD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASF,KAAK,IAAIG,gBAAgB,QAAQ,yBAAyB;AACnE,SAASH,KAAK,IAAII,SAAS,QAAQ,sBAAsB;AACzD,SAASJ,KAAK,IAAIK,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;AAClD,SAASC,iBAAiB,QAAQ,uBAAu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;AAEA,eAAe,SAASmB,WAAWA,CAAA,EAAG;EACrCnE,gBAAgB,CAAE;IACjBmD,IAAI,EAAE,qBAAqB;IAC3BiB,IAAI,EAAExD;EACP,CAAE,CAAC;EAEHZ,gBAAgB,CAAE;IACjBmD,IAAI,EAAE,iCAAiC;IACvCiB,IAAI,EAAEH,iCAAiC;IACvCI,OAAO,EAAE;EACV,CAAE,CAAC;AACJ","ignoreList":[]}
@@ -17,8 +17,7 @@ import { serialize } from '@wordpress/blocks';
17
17
  import { store as editorStore } from '../../store';
18
18
  import { TEMPLATE_PART_POST_TYPE, TEMPLATE_PART_AREA_DEFAULT_CATEGORY } from '../../store/constants';
19
19
  import { useExistingTemplateParts, getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from './utils';
20
- import { jsx as _jsx } from "react/jsx-runtime";
21
- import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
21
  export default function CreateTemplatePartModal({
23
22
  modalTitle,
24
23
  ...restProps
@@ -1 +1 @@
1
- {"version":3,"names":["useSelect","useDispatch","Icon","BaseControl","TextControl","Flex","FlexItem","FlexBlock","Button","Modal","__experimentalRadioGroup","RadioGroup","__experimentalRadio","Radio","__experimentalHStack","HStack","__experimentalVStack","VStack","__","useState","useInstanceId","store","noticesStore","coreStore","check","serialize","editorStore","TEMPLATE_PART_POST_TYPE","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","jsx","_jsx","jsxs","_jsxs","CreateTemplatePartModal","modalTitle","restProps","defaultModalTitle","select","getPostType","labels","add_new_item","title","onRequestClose","closeModal","overlayClassName","focusOnMount","size","children","CreateTemplatePartModalContents","defaultArea","blocks","confirmLabel","onCreate","onError","defaultTitle","createErrorNotice","saveEntityRecord","existingTemplateParts","setTitle","area","setArea","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","__experimentalGetDefaultTemplatePartAreas","createTemplatePart","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","error","errorMessage","message","code","type","onSubmit","event","preventDefault","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","required","id","className","checked","map","icon","description","align","justify","variant","onClick","isBusy"],"sources":["@wordpress/editor/src/components/create-template-part-modal/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_PART_AREA_DEFAULT_CATEGORY,\n} from '../../store/constants';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from './utils';\n\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n} ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( TEMPLATE_PART_POST_TYPE )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"editor-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n} ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `editor-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `editor-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"editor-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"editor-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,IAA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AC,SAAS;UACjBnB,IAAI,EAAC,QAAQ;UACb,iBAAgB,CAAEpC,KAAK,IAAIoB,YAAc;UACzCqC,MAAM,EAAGrC,YAAc;UAAAd,QAAA,EAErBI;QAAY,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET","ignoreList":[]}
1
+ {"version":3,"names":["useSelect","useDispatch","Icon","BaseControl","TextControl","Flex","FlexItem","FlexBlock","Button","Modal","__experimentalRadioGroup","RadioGroup","__experimentalRadio","Radio","__experimentalHStack","HStack","__experimentalVStack","VStack","__","useState","useInstanceId","store","noticesStore","coreStore","check","serialize","editorStore","TEMPLATE_PART_POST_TYPE","TEMPLATE_PART_AREA_DEFAULT_CATEGORY","useExistingTemplateParts","getUniqueTemplatePartTitle","getCleanTemplatePartSlug","jsx","_jsx","jsxs","_jsxs","CreateTemplatePartModal","modalTitle","restProps","defaultModalTitle","select","getPostType","labels","add_new_item","title","onRequestClose","closeModal","overlayClassName","focusOnMount","size","children","CreateTemplatePartModalContents","defaultArea","blocks","confirmLabel","onCreate","onError","defaultTitle","createErrorNotice","saveEntityRecord","existingTemplateParts","setTitle","area","setArea","isSubmitting","setIsSubmitting","instanceId","templatePartAreas","__experimentalGetDefaultTemplatePartAreas","createTemplatePart","uniqueTitle","cleanSlug","templatePart","slug","content","throwOnError","error","errorMessage","message","code","type","onSubmit","event","preventDefault","spacing","__next40pxDefaultSize","__nextHasNoMarginBottom","label","value","onChange","required","id","className","checked","map","icon","description","align","justify","variant","onClick","isBusy"],"sources":["@wordpress/editor/src/components/create-template-part-modal/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tIcon,\n\tBaseControl,\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tFlexBlock,\n\tButton,\n\tModal,\n\t__experimentalRadioGroup as RadioGroup,\n\t__experimentalRadio as Radio,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState } from '@wordpress/element';\nimport { useInstanceId } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { check } from '@wordpress/icons';\nimport { serialize } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport {\n\tTEMPLATE_PART_POST_TYPE,\n\tTEMPLATE_PART_AREA_DEFAULT_CATEGORY,\n} from '../../store/constants';\nimport {\n\tuseExistingTemplateParts,\n\tgetUniqueTemplatePartTitle,\n\tgetCleanTemplatePartSlug,\n} from './utils';\n\nexport default function CreateTemplatePartModal( {\n\tmodalTitle,\n\t...restProps\n} ) {\n\tconst defaultModalTitle = useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getPostType( TEMPLATE_PART_POST_TYPE )?.labels\n\t\t\t\t?.add_new_item,\n\t\t[]\n\t);\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ modalTitle || defaultModalTitle }\n\t\t\tonRequestClose={ restProps.closeModal }\n\t\t\toverlayClassName=\"editor-create-template-part-modal\"\n\t\t\tfocusOnMount=\"firstContentElement\"\n\t\t\tsize=\"medium\"\n\t\t>\n\t\t\t<CreateTemplatePartModalContents { ...restProps } />\n\t\t</Modal>\n\t);\n}\n\nexport function CreateTemplatePartModalContents( {\n\tdefaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,\n\tblocks = [],\n\tconfirmLabel = __( 'Add' ),\n\tcloseModal,\n\tonCreate,\n\tonError,\n\tdefaultTitle = '',\n} ) {\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst existingTemplateParts = useExistingTemplateParts();\n\n\tconst [ title, setTitle ] = useState( defaultTitle );\n\tconst [ area, setArea ] = useState( defaultArea );\n\tconst [ isSubmitting, setIsSubmitting ] = useState( false );\n\tconst instanceId = useInstanceId( CreateTemplatePartModal );\n\n\tconst templatePartAreas = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).__experimentalGetDefaultTemplatePartAreas(),\n\t\t[]\n\t);\n\tasync function createTemplatePart() {\n\t\tif ( ! title || isSubmitting ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tsetIsSubmitting( true );\n\t\t\tconst uniqueTitle = getUniqueTemplatePartTitle(\n\t\t\t\ttitle,\n\t\t\t\texistingTemplateParts\n\t\t\t);\n\t\t\tconst cleanSlug = getCleanTemplatePartSlug( uniqueTitle );\n\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tslug: cleanSlug,\n\t\t\t\t\ttitle: uniqueTitle,\n\t\t\t\t\tcontent: serialize( blocks ),\n\t\t\t\t\tarea,\n\t\t\t\t},\n\t\t\t\t{ throwOnError: true }\n\t\t\t);\n\t\t\tawait onCreate( templatePart );\n\n\t\t\t// TODO: Add a success notice?\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __(\n\t\t\t\t\t\t\t'An error occurred while creating the template part.'\n\t\t\t\t\t );\n\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\n\t\t\tonError?.();\n\t\t} finally {\n\t\t\tsetIsSubmitting( false );\n\t\t}\n\t}\n\treturn (\n\t\t<form\n\t\t\tonSubmit={ async ( event ) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tawait createTemplatePart();\n\t\t\t} }\n\t\t>\n\t\t\t<VStack spacing=\"4\">\n\t\t\t\t<TextControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\trequired\n\t\t\t\t/>\n\t\t\t\t<BaseControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\tid={ `editor-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-base-control\"\n\t\t\t\t>\n\t\t\t\t\t<RadioGroup\n\t\t\t\t\t\tlabel={ __( 'Area' ) }\n\t\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-radio-group\"\n\t\t\t\t\t\tid={ `editor-create-template-part-modal__area-selection-${ instanceId }` }\n\t\t\t\t\t\tonChange={ setArea }\n\t\t\t\t\t\tchecked={ area }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ templatePartAreas.map(\n\t\t\t\t\t\t\t( { icon, label, area: value, description } ) => (\n\t\t\t\t\t\t\t\t<Radio\n\t\t\t\t\t\t\t\t\tkey={ label }\n\t\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\t\tclassName=\"editor-create-template-part-modal__area-radio\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<Flex align=\"start\" justify=\"start\">\n\t\t\t\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ icon } />\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t\t<FlexBlock className=\"editor-create-template-part-modal__option-label\">\n\t\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t\t\t<div>{ description }</div>\n\t\t\t\t\t\t\t\t\t\t</FlexBlock>\n\n\t\t\t\t\t\t\t\t\t\t<FlexItem className=\"editor-create-template-part-modal__checkbox\">\n\t\t\t\t\t\t\t\t\t\t\t{ area === value && (\n\t\t\t\t\t\t\t\t\t\t\t\t<Icon icon={ check } />\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t\t\t</Flex>\n\t\t\t\t\t\t\t\t</Radio>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t) }\n\t\t\t\t\t</RadioGroup>\n\t\t\t\t</BaseControl>\n\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tcloseModal();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button\n\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\taria-disabled={ ! title || isSubmitting }\n\t\t\t\t\t\tisBusy={ isSubmitting }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ confirmLabel }\n\t\t\t\t\t</Button>\n\t\t\t\t</HStack>\n\t\t\t</VStack>\n\t\t</form>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,IAAI,EACJC,QAAQ,EACRC,SAAS,EACTC,MAAM,EACNC,KAAK,EACLC,wBAAwB,IAAIC,UAAU,EACtCC,mBAAmB,IAAIC,KAAK,EAC5BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,QACxB,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,oBAAoB;AAC7C,SAASC,aAAa,QAAQ,oBAAoB;AAClD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,SAAS,QAAQ,sBAAsB;AACzD,SAASC,KAAK,QAAQ,kBAAkB;AACxC,SAASC,SAAS,QAAQ,mBAAmB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,IAAI,EAAGA;gBAAM,CAAE;cAAC,CACb,CAAC,eACX5D,KAAA,CAAC5B,SAAS;gBAACqF,SAAS,EAAC,iDAAiD;gBAAA1C,QAAA,GACnEqC,KAAK,eACPtD,IAAA;kBAAAiB,QAAA,EAAO8C;gBAAW,CAAO,CAAC;cAAA,CAChB,CAAC,eAEZ/D,IAAA,CAAC3B,QAAQ;gBAACsF,SAAS,EAAC,6CAA6C;gBAAA1C,QAAA,EAC9DY,IAAI,KAAK0B,KAAK,iBACfvD,IAAA,CAAC/B,IAAI;kBAAC6F,IAAI,EAAGvE;gBAAO,CAAE;cACtB,CACQ,CAAC;YAAA,CACN;UAAC,GAlBD+D,KAmBA,CAET;QAAC,CACU;MAAC,CACD,CAAC,eACdpD,KAAA,CAACpB,MAAM;QAACmF,OAAO,EAAC,OAAO;QAAAhD,QAAA,gBACtBjB,IAAA,CAACzB,MAAM;UACN6E,qBAAqB;UACrBc,OAAO,EAAC,UAAU;UAClBC,OAAO,EAAGA,CAAA,KAAM;YACftD,UAAU,CAAC,CAAC;UACb,CAAG;UAAAI,QAAA,EAEDhC,EAAE,CAAE,QAAS;QAAC,CACT,CAAC,eACTe,IAAA,CAACzB,MAAM;UACN6E,qBAAqB;UACrBc,OAAO,EAAC,SAAS;UACjBnB,IAAI,EAAC,QAAQ;UACb,iBAAgB,CAAEpC,KAAK,IAAIoB,YAAc;UACzCqC,MAAM,EAAGrC,YAAc;UAAAd,QAAA,EAErBI;QAAY,CACP,CAAC;MAAA,CACF,CAAC;IAAA,CACF;EAAC,CACJ,CAAC;AAET","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["paramCase","kebabCase","useSelect","store","coreStore","TEMPLATE_PART_POST_TYPE","useExistingTemplateParts","select","getEntityRecords","per_page","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","replace"],"sources":["@wordpress/editor/src/components/create-template-part-modal/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_POST_TYPE } from '../../store/constants';\n\nexport const useExistingTemplateParts = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\n/**\n * Return a unique template part title based on\n * the given title and existing template parts.\n *\n * @param {string} title The original template part title.\n * @param {Object} templateParts The array of template part entities.\n * @return {string} A unique template part title.\n */\nexport const getUniqueTemplatePartTitle = ( title, templateParts ) => {\n\tconst lowercaseTitle = title.toLowerCase();\n\tconst existingTitles = templateParts.map( ( templatePart ) =>\n\t\ttemplatePart.title.rendered.toLowerCase()\n\t);\n\n\tif ( ! existingTitles.includes( lowercaseTitle ) ) {\n\t\treturn title;\n\t}\n\n\tlet suffix = 2;\n\twhile ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {\n\t\tsuffix++;\n\t}\n\n\treturn `${ title } ${ suffix }`;\n};\n\n/**\n * Get a valid slug for a template part.\n * Currently template parts only allow latin chars.\n * The fallback slug will receive suffix by default.\n *\n * @param {string} title The template part title.\n * @return {string} A valid template part slug.\n */\nexport const getCleanTemplatePartSlug = ( title ) => {\n\treturn kebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,uBAAuB;AAE/D,OAAO,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;EAC7C,OAAOJ,SAAS,CACbK,MAAM,IACPA,MAAM,CAAEH,SAAU,CAAC,CAACI,gBAAgB,CACnC,UAAU,EACVH,uBAAuB,EACvB;IACCI,QAAQ,EAAE,CAAC;EACZ,CACD,CAAC,EACF,EACD,CAAC;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAGA,CAAEC,KAAK,EAAEC,aAAa,KAAM;EACrE,MAAMC,cAAc,GAAGF,KAAK,CAACG,WAAW,CAAC,CAAC;EAC1C,MAAMC,cAAc,GAAGH,aAAa,CAACI,GAAG,CAAIC,YAAY,IACvDA,YAAY,CAACN,KAAK,CAACO,QAAQ,CAACJ,WAAW,CAAC,CACzC,CAAC;EAED,IAAK,CAAEC,cAAc,CAACI,QAAQ,CAAEN,cAAe,CAAC,EAAG;IAClD,OAAOF,KAAK;EACb;EAEA,IAAIS,MAAM,GAAG,CAAC;EACd,OAAQL,cAAc,CAACI,QAAQ,CAAG,GAAGN,cAAgB,IAAIO,MAAQ,EAAE,CAAC,EAAG;IACtEA,MAAM,EAAE;EACT;EAEA,OAAQ,GAAGT,KAAO,IAAIS,MAAQ,EAAC;AAChC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAKV,KAAK,IAAM;EACpD,OAAOV,SAAS,CAAEU,KAAM,CAAC,CAACW,OAAO,CAAE,UAAU,EAAE,EAAG,CAAC,IAAI,gBAAgB;AACxE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["paramCase","kebabCase","useSelect","store","coreStore","TEMPLATE_PART_POST_TYPE","useExistingTemplateParts","select","getEntityRecords","per_page","getUniqueTemplatePartTitle","title","templateParts","lowercaseTitle","toLowerCase","existingTitles","map","templatePart","rendered","includes","suffix","getCleanTemplatePartSlug","replace"],"sources":["@wordpress/editor/src/components/create-template-part-modal/utils.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { paramCase as kebabCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { TEMPLATE_PART_POST_TYPE } from '../../store/constants';\n\nexport const useExistingTemplateParts = () => {\n\treturn useSelect(\n\t\t( select ) =>\n\t\t\tselect( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\tTEMPLATE_PART_POST_TYPE,\n\t\t\t\t{\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t[]\n\t);\n};\n\n/**\n * Return a unique template part title based on\n * the given title and existing template parts.\n *\n * @param {string} title The original template part title.\n * @param {Object} templateParts The array of template part entities.\n * @return {string} A unique template part title.\n */\nexport const getUniqueTemplatePartTitle = ( title, templateParts ) => {\n\tconst lowercaseTitle = title.toLowerCase();\n\tconst existingTitles = templateParts.map( ( templatePart ) =>\n\t\ttemplatePart.title.rendered.toLowerCase()\n\t);\n\n\tif ( ! existingTitles.includes( lowercaseTitle ) ) {\n\t\treturn title;\n\t}\n\n\tlet suffix = 2;\n\twhile ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {\n\t\tsuffix++;\n\t}\n\n\treturn `${ title } ${ suffix }`;\n};\n\n/**\n * Get a valid slug for a template part.\n * Currently template parts only allow latin chars.\n * The fallback slug will receive suffix by default.\n *\n * @param {string} title The template part title.\n * @return {string} A valid template part slug.\n */\nexport const getCleanTemplatePartSlug = ( title ) => {\n\treturn kebabCase( title ).replace( /[^\\w-]+/g, '' ) || 'wp-custom-part';\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,IAAIC,SAAS,QAAQ,aAAa;;AAEpD;AACA;AACA;AACA,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB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