@wordpress/editor 14.4.0 → 14.6.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 (375) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/bindings/post-meta.js +12 -0
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/blog-title/index.js +1 -1
  5. package/build/components/blog-title/index.js.map +1 -1
  6. package/build/components/commands/index.js +8 -2
  7. package/build/components/commands/index.js.map +1 -1
  8. package/build/components/create-template-part-modal/index.js +1 -0
  9. package/build/components/create-template-part-modal/index.js.map +1 -1
  10. package/build/components/document-bar/index.js +1 -1
  11. package/build/components/document-bar/index.js.map +1 -1
  12. package/build/components/global-styles-provider/index.js +17 -4
  13. package/build/components/global-styles-provider/index.js.map +1 -1
  14. package/build/components/header/index.js +2 -3
  15. package/build/components/header/index.js.map +1 -1
  16. package/build/components/inserter-sidebar/index.js +5 -2
  17. package/build/components/inserter-sidebar/index.js.map +1 -1
  18. package/build/components/page-attributes/parent.js +11 -6
  19. package/build/components/page-attributes/parent.js.map +1 -1
  20. package/build/components/post-actions/actions.js +10 -811
  21. package/build/components/post-actions/actions.js.map +1 -1
  22. package/build/components/post-actions/index.js +20 -19
  23. package/build/components/post-actions/index.js.map +1 -1
  24. package/build/components/post-author/hook.js +10 -3
  25. package/build/components/post-author/hook.js.map +1 -1
  26. package/build/components/post-author/panel.js +2 -1
  27. package/build/components/post-author/panel.js.map +1 -1
  28. package/build/components/post-card-panel/index.js +21 -21
  29. package/build/components/post-card-panel/index.js.map +1 -1
  30. package/build/components/post-comments/index.js +6 -20
  31. package/build/components/post-comments/index.js.map +1 -1
  32. package/build/components/post-featured-image/index.js +2 -0
  33. package/build/components/post-featured-image/index.js.map +1 -1
  34. package/build/components/post-publish-panel/postpublish.js +4 -0
  35. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  36. package/build/components/post-slug/index.js +1 -0
  37. package/build/components/post-slug/index.js.map +1 -1
  38. package/build/components/post-status/index.js +17 -41
  39. package/build/components/post-status/index.js.map +1 -1
  40. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -1
  41. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  42. package/build/components/post-template/create-new-template-modal.js +3 -0
  43. package/build/components/post-template/create-new-template-modal.js.map +1 -1
  44. package/build/components/post-url/index.js +6 -5
  45. package/build/components/post-url/index.js.map +1 -1
  46. package/build/components/post-url/panel.js +3 -2
  47. package/build/components/post-url/panel.js.map +1 -1
  48. package/build/components/preview-dropdown/index.js +82 -17
  49. package/build/components/preview-dropdown/index.js.map +1 -1
  50. package/build/components/provider/disable-non-page-content-blocks.js +14 -18
  51. package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
  52. package/build/components/sidebar/post-summary.js +10 -7
  53. package/build/components/sidebar/post-summary.js.map +1 -1
  54. package/build/components/site-discussion/index.js +6 -20
  55. package/build/components/site-discussion/index.js.map +1 -1
  56. package/build/components/template-content-panel/index.js +15 -13
  57. package/build/components/template-content-panel/index.js.map +1 -1
  58. package/build/components/visual-editor/index.js +2 -1
  59. package/build/components/visual-editor/index.js.map +1 -1
  60. package/build/dataviews/actions/duplicate-pattern.js +48 -0
  61. package/build/dataviews/actions/duplicate-pattern.js.map +1 -0
  62. package/build/dataviews/actions/duplicate-post.js +146 -0
  63. package/build/dataviews/actions/duplicate-post.js.map +1 -0
  64. package/build/dataviews/actions/duplicate-post.native.js +9 -0
  65. package/build/dataviews/actions/duplicate-post.native.js.map +1 -0
  66. package/build/dataviews/actions/duplicate-template-part.js +67 -0
  67. package/build/dataviews/actions/duplicate-template-part.js.map +1 -0
  68. package/build/dataviews/actions/export-pattern.native.js +9 -0
  69. package/build/dataviews/actions/export-pattern.native.js.map +1 -0
  70. package/build/dataviews/actions/permanently-delete-post.js +107 -0
  71. package/build/dataviews/actions/permanently-delete-post.js.map +1 -0
  72. package/build/dataviews/actions/rename-post.js +125 -0
  73. package/build/dataviews/actions/rename-post.js.map +1 -0
  74. package/build/dataviews/actions/reorder-page.js +116 -0
  75. package/build/dataviews/actions/reorder-page.js.map +1 -0
  76. package/build/dataviews/actions/reorder-page.native.js +9 -0
  77. package/build/dataviews/actions/reorder-page.native.js.map +1 -0
  78. package/build/dataviews/actions/reset-post.js +1 -1
  79. package/build/dataviews/actions/reset-post.js.map +1 -1
  80. package/build/dataviews/actions/restore-post.js +112 -0
  81. package/build/dataviews/actions/restore-post.js.map +1 -0
  82. package/build/dataviews/actions/trash-post.js +142 -0
  83. package/build/dataviews/actions/trash-post.js.map +1 -0
  84. package/build/dataviews/actions/utils.js +9 -1
  85. package/build/dataviews/actions/utils.js.map +1 -1
  86. package/build/dataviews/actions/view-post-revisions.js +49 -0
  87. package/build/dataviews/actions/view-post-revisions.js.map +1 -0
  88. package/build/dataviews/actions/view-post.js +36 -0
  89. package/build/dataviews/actions/view-post.js.map +1 -0
  90. package/build/dataviews/fields/index.js +32 -0
  91. package/build/dataviews/fields/index.js.map +1 -0
  92. package/build/dataviews/store/private-actions.js +59 -0
  93. package/build/dataviews/store/private-actions.js.map +1 -1
  94. package/build/dataviews/store/private-selectors.js +10 -10
  95. package/build/dataviews/store/private-selectors.js.map +1 -1
  96. package/build/dataviews/store/reducer.js +15 -1
  97. package/build/dataviews/store/reducer.js.map +1 -1
  98. package/build/dataviews/types.js.map +1 -1
  99. package/build/private-apis.js +2 -2
  100. package/build/private-apis.js.map +1 -1
  101. package/build/store/actions.js +16 -2
  102. package/build/store/actions.js.map +1 -1
  103. package/build/store/private-actions.js +9 -2
  104. package/build/store/private-actions.js.map +1 -1
  105. package/build/store/private-selectors.js +33 -2
  106. package/build/store/private-selectors.js.map +1 -1
  107. package/build/store/utils/is-template-revertable.js +1 -1
  108. package/build/store/utils/is-template-revertable.js.map +1 -1
  109. package/build-module/bindings/post-meta.js +12 -0
  110. package/build-module/bindings/post-meta.js.map +1 -1
  111. package/build-module/components/blog-title/index.js +1 -1
  112. package/build-module/components/blog-title/index.js.map +1 -1
  113. package/build-module/components/commands/index.js +8 -2
  114. package/build-module/components/commands/index.js.map +1 -1
  115. package/build-module/components/create-template-part-modal/index.js +1 -0
  116. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  117. package/build-module/components/document-bar/index.js +1 -1
  118. package/build-module/components/document-bar/index.js.map +1 -1
  119. package/build-module/components/global-styles-provider/index.js +17 -4
  120. package/build-module/components/global-styles-provider/index.js.map +1 -1
  121. package/build-module/components/header/index.js +2 -3
  122. package/build-module/components/header/index.js.map +1 -1
  123. package/build-module/components/inserter-sidebar/index.js +5 -2
  124. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  125. package/build-module/components/page-attributes/parent.js +12 -7
  126. package/build-module/components/page-attributes/parent.js.map +1 -1
  127. package/build-module/components/post-actions/actions.js +12 -814
  128. package/build-module/components/post-actions/actions.js.map +1 -1
  129. package/build-module/components/post-actions/index.js +20 -19
  130. package/build-module/components/post-actions/index.js.map +1 -1
  131. package/build-module/components/post-author/hook.js +10 -3
  132. package/build-module/components/post-author/hook.js.map +1 -1
  133. package/build-module/components/post-author/panel.js +2 -1
  134. package/build-module/components/post-author/panel.js.map +1 -1
  135. package/build-module/components/post-card-panel/index.js +21 -21
  136. package/build-module/components/post-card-panel/index.js.map +1 -1
  137. package/build-module/components/post-comments/index.js +7 -23
  138. package/build-module/components/post-comments/index.js.map +1 -1
  139. package/build-module/components/post-featured-image/index.js +2 -0
  140. package/build-module/components/post-featured-image/index.js.map +1 -1
  141. package/build-module/components/post-publish-panel/postpublish.js +4 -0
  142. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  143. package/build-module/components/post-slug/index.js +1 -0
  144. package/build-module/components/post-slug/index.js.map +1 -1
  145. package/build-module/components/post-status/index.js +19 -43
  146. package/build-module/components/post-status/index.js.map +1 -1
  147. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  148. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  149. package/build-module/components/post-template/create-new-template-modal.js +3 -0
  150. package/build-module/components/post-template/create-new-template-modal.js.map +1 -1
  151. package/build-module/components/post-url/index.js +7 -6
  152. package/build-module/components/post-url/index.js.map +1 -1
  153. package/build-module/components/post-url/panel.js +4 -5
  154. package/build-module/components/post-url/panel.js.map +1 -1
  155. package/build-module/components/preview-dropdown/index.js +84 -19
  156. package/build-module/components/preview-dropdown/index.js.map +1 -1
  157. package/build-module/components/provider/disable-non-page-content-blocks.js +15 -19
  158. package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
  159. package/build-module/components/sidebar/post-summary.js +10 -7
  160. package/build-module/components/sidebar/post-summary.js.map +1 -1
  161. package/build-module/components/site-discussion/index.js +7 -21
  162. package/build-module/components/site-discussion/index.js.map +1 -1
  163. package/build-module/components/template-content-panel/index.js +16 -14
  164. package/build-module/components/template-content-panel/index.js.map +1 -1
  165. package/build-module/components/visual-editor/index.js +2 -1
  166. package/build-module/components/visual-editor/index.js.map +1 -1
  167. package/build-module/dataviews/actions/duplicate-pattern.js +39 -0
  168. package/build-module/dataviews/actions/duplicate-pattern.js.map +1 -0
  169. package/build-module/dataviews/actions/duplicate-post.js +139 -0
  170. package/build-module/dataviews/actions/duplicate-post.js.map +1 -0
  171. package/build-module/dataviews/actions/duplicate-post.native.js +3 -0
  172. package/build-module/dataviews/actions/duplicate-post.native.js.map +1 -0
  173. package/build-module/dataviews/actions/duplicate-template-part.js +58 -0
  174. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -0
  175. package/build-module/dataviews/actions/export-pattern.native.js +3 -0
  176. package/build-module/dataviews/actions/export-pattern.native.js.map +1 -0
  177. package/build-module/dataviews/actions/permanently-delete-post.js +99 -0
  178. package/build-module/dataviews/actions/permanently-delete-post.js.map +1 -0
  179. package/build-module/dataviews/actions/rename-post.js +118 -0
  180. package/build-module/dataviews/actions/rename-post.js.map +1 -0
  181. package/build-module/dataviews/actions/reorder-page.js +111 -0
  182. package/build-module/dataviews/actions/reorder-page.js.map +1 -0
  183. package/build-module/dataviews/actions/reorder-page.native.js +3 -0
  184. package/build-module/dataviews/actions/reorder-page.native.js.map +1 -0
  185. package/build-module/dataviews/actions/reset-post.js +1 -1
  186. package/build-module/dataviews/actions/reset-post.js.map +1 -1
  187. package/build-module/dataviews/actions/restore-post.js +104 -0
  188. package/build-module/dataviews/actions/restore-post.js.map +1 -0
  189. package/build-module/dataviews/actions/trash-post.js +135 -0
  190. package/build-module/dataviews/actions/trash-post.js.map +1 -0
  191. package/build-module/dataviews/actions/utils.js +7 -1
  192. package/build-module/dataviews/actions/utils.js.map +1 -1
  193. package/build-module/dataviews/actions/view-post-revisions.js +43 -0
  194. package/build-module/dataviews/actions/view-post-revisions.js.map +1 -0
  195. package/build-module/dataviews/actions/view-post.js +30 -0
  196. package/build-module/dataviews/actions/view-post.js.map +1 -0
  197. package/build-module/dataviews/fields/index.js +26 -0
  198. package/build-module/dataviews/fields/index.js.map +1 -0
  199. package/build-module/dataviews/store/private-actions.js +54 -0
  200. package/build-module/dataviews/store/private-actions.js.map +1 -1
  201. package/build-module/dataviews/store/private-selectors.js +8 -9
  202. package/build-module/dataviews/store/private-selectors.js.map +1 -1
  203. package/build-module/dataviews/store/reducer.js +15 -1
  204. package/build-module/dataviews/store/reducer.js.map +1 -1
  205. package/build-module/dataviews/types.js.map +1 -1
  206. package/build-module/private-apis.js +2 -2
  207. package/build-module/private-apis.js.map +1 -1
  208. package/build-module/store/actions.js +16 -2
  209. package/build-module/store/actions.js.map +1 -1
  210. package/build-module/store/private-actions.js +9 -2
  211. package/build-module/store/private-actions.js.map +1 -1
  212. package/build-module/store/private-selectors.js +32 -2
  213. package/build-module/store/private-selectors.js.map +1 -1
  214. package/build-module/store/utils/is-template-revertable.js +1 -1
  215. package/build-module/store/utils/is-template-revertable.js.map +1 -1
  216. package/build-style/style-rtl.css +21 -34
  217. package/build-style/style.css +21 -34
  218. package/build-types/bindings/post-meta.d.ts +6 -0
  219. package/build-types/bindings/post-meta.d.ts.map +1 -1
  220. package/build-types/components/commands/index.d.ts.map +1 -1
  221. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  222. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  223. package/build-types/components/header/index.d.ts.map +1 -1
  224. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  225. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  226. package/build-types/components/post-actions/actions.d.ts +1 -26
  227. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  228. package/build-types/components/post-actions/index.d.ts +3 -2
  229. package/build-types/components/post-actions/index.d.ts.map +1 -1
  230. package/build-types/components/post-author/hook.d.ts +1 -1
  231. package/build-types/components/post-author/hook.d.ts.map +1 -1
  232. package/build-types/components/post-author/panel.d.ts.map +1 -1
  233. package/build-types/components/post-card-panel/index.d.ts +4 -2
  234. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  235. package/build-types/components/post-comments/index.d.ts.map +1 -1
  236. package/build-types/components/post-slug/index.d.ts.map +1 -1
  237. package/build-types/components/post-status/index.d.ts +2 -1
  238. package/build-types/components/post-status/index.d.ts.map +1 -1
  239. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -17
  240. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  241. package/build-types/components/post-template/create-new-template-modal.d.ts.map +1 -1
  242. package/build-types/components/post-url/index.d.ts.map +1 -1
  243. package/build-types/components/post-url/panel.d.ts.map +1 -1
  244. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  245. package/build-types/components/provider/disable-non-page-content-blocks.d.ts.map +1 -1
  246. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  247. package/build-types/components/site-discussion/index.d.ts.map +1 -1
  248. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  249. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  250. package/build-types/dataviews/actions/duplicate-pattern.d.ts +5 -0
  251. package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +1 -0
  252. package/build-types/dataviews/actions/duplicate-post.d.ts +5 -0
  253. package/build-types/dataviews/actions/duplicate-post.d.ts.map +1 -0
  254. package/build-types/dataviews/actions/duplicate-post.native.d.ts +3 -0
  255. package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +1 -0
  256. package/build-types/dataviews/actions/duplicate-template-part.d.ts +5 -0
  257. package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +1 -0
  258. package/build-types/dataviews/actions/export-pattern.native.d.ts +3 -0
  259. package/build-types/dataviews/actions/export-pattern.native.d.ts.map +1 -0
  260. package/build-types/dataviews/actions/permanently-delete-post.d.ts +5 -0
  261. package/build-types/dataviews/actions/permanently-delete-post.d.ts.map +1 -0
  262. package/build-types/dataviews/actions/rename-post.d.ts +5 -0
  263. package/build-types/dataviews/actions/rename-post.d.ts.map +1 -0
  264. package/build-types/dataviews/actions/reorder-page.d.ts +8 -0
  265. package/build-types/dataviews/actions/reorder-page.d.ts.map +1 -0
  266. package/build-types/dataviews/actions/reorder-page.native.d.ts +3 -0
  267. package/build-types/dataviews/actions/reorder-page.native.d.ts.map +1 -0
  268. package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
  269. package/build-types/dataviews/actions/restore-post.d.ts +5 -0
  270. package/build-types/dataviews/actions/restore-post.d.ts.map +1 -0
  271. package/build-types/dataviews/actions/trash-post.d.ts +5 -0
  272. package/build-types/dataviews/actions/trash-post.d.ts.map +1 -0
  273. package/build-types/dataviews/actions/utils.d.ts +5 -3
  274. package/build-types/dataviews/actions/utils.d.ts.map +1 -1
  275. package/build-types/dataviews/actions/view-post-revisions.d.ts +8 -0
  276. package/build-types/dataviews/actions/view-post-revisions.d.ts.map +1 -0
  277. package/build-types/dataviews/actions/view-post.d.ts +8 -0
  278. package/build-types/dataviews/actions/view-post.d.ts.map +1 -0
  279. package/build-types/dataviews/fields/index.d.ts +8 -0
  280. package/build-types/dataviews/fields/index.d.ts.map +1 -0
  281. package/build-types/dataviews/store/private-actions.d.ts +8 -3
  282. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  283. package/build-types/dataviews/store/private-selectors.d.ts +2 -1
  284. package/build-types/dataviews/store/private-selectors.d.ts.map +1 -1
  285. package/build-types/dataviews/store/reducer.d.ts +4 -1
  286. package/build-types/dataviews/store/reducer.d.ts.map +1 -1
  287. package/build-types/dataviews/types.d.ts +66 -8
  288. package/build-types/dataviews/types.d.ts.map +1 -1
  289. package/build-types/store/actions.d.ts.map +1 -1
  290. package/build-types/store/private-actions.d.ts.map +1 -1
  291. package/build-types/store/private-selectors.d.ts +11 -0
  292. package/build-types/store/private-selectors.d.ts.map +1 -1
  293. package/build-types/store/reducer.d.ts +1 -0
  294. package/build-types/store/reducer.d.ts.map +1 -1
  295. package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
  296. package/package.json +36 -36
  297. package/src/bindings/post-meta.js +20 -0
  298. package/src/components/block-manager/style.scss +2 -2
  299. package/src/components/blog-title/index.js +1 -1
  300. package/src/components/commands/index.js +4 -2
  301. package/src/components/create-template-part-modal/index.js +1 -0
  302. package/src/components/document-bar/index.js +1 -1
  303. package/src/components/document-bar/style.scss +1 -1
  304. package/src/components/editor-interface/style.scss +5 -0
  305. package/src/components/error-boundary/style.native.scss +1 -1
  306. package/src/components/error-boundary/style.scss +1 -1
  307. package/src/components/global-styles-provider/index.js +16 -3
  308. package/src/components/header/index.js +1 -2
  309. package/src/components/inserter-sidebar/index.js +10 -4
  310. package/src/components/list-view-sidebar/style.scss +4 -0
  311. package/src/components/page-attributes/parent.js +38 -16
  312. package/src/components/post-actions/actions.js +10 -1044
  313. package/src/components/post-actions/index.js +25 -17
  314. package/src/components/post-author/hook.js +11 -3
  315. package/src/components/post-author/panel.js +3 -1
  316. package/src/components/post-card-panel/index.js +29 -28
  317. package/src/components/post-comments/index.js +7 -20
  318. package/src/components/post-discussion/style.scss +0 -9
  319. package/src/components/post-featured-image/index.js +2 -0
  320. package/src/components/post-format/style.scss +0 -6
  321. package/src/components/post-publish-panel/postpublish.js +8 -2
  322. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +10 -10
  323. package/src/components/post-slug/index.js +1 -0
  324. package/src/components/post-status/index.js +11 -41
  325. package/src/components/post-status/style.scss +0 -19
  326. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -1
  327. package/src/components/post-template/create-new-template-modal.js +7 -1
  328. package/src/components/post-url/index.js +15 -9
  329. package/src/components/post-url/panel.js +8 -2
  330. package/src/components/preview-dropdown/index.js +113 -35
  331. package/src/components/preview-dropdown/style.scss +5 -0
  332. package/src/components/provider/disable-non-page-content-blocks.js +27 -24
  333. package/src/components/save-publish-panels/style.scss +3 -3
  334. package/src/components/sidebar/post-summary.js +20 -16
  335. package/src/components/site-discussion/index.js +7 -19
  336. package/src/components/site-discussion/style.scss +0 -14
  337. package/src/components/template-content-panel/index.js +40 -22
  338. package/src/components/visual-editor/index.js +8 -6
  339. package/src/components/visual-editor/style.scss +1 -3
  340. package/src/dataviews/actions/duplicate-pattern.tsx +40 -0
  341. package/src/dataviews/actions/duplicate-post.native.tsx +3 -0
  342. package/src/dataviews/actions/duplicate-post.tsx +174 -0
  343. package/src/dataviews/actions/duplicate-template-part.tsx +70 -0
  344. package/src/dataviews/actions/export-pattern.native.tsx +3 -0
  345. package/src/dataviews/actions/permanently-delete-post.tsx +116 -0
  346. package/src/dataviews/actions/rename-post.tsx +146 -0
  347. package/src/dataviews/actions/reorder-page.native.tsx +3 -0
  348. package/src/dataviews/actions/reorder-page.tsx +125 -0
  349. package/src/dataviews/actions/reset-post.tsx +2 -1
  350. package/src/dataviews/actions/restore-post.tsx +134 -0
  351. package/src/dataviews/actions/trash-post.tsx +196 -0
  352. package/src/dataviews/actions/utils.ts +14 -4
  353. package/src/dataviews/actions/view-post-revisions.tsx +47 -0
  354. package/src/dataviews/actions/view-post.tsx +30 -0
  355. package/src/dataviews/fields/index.ts +26 -0
  356. package/src/dataviews/store/private-actions.ts +109 -0
  357. package/src/dataviews/store/private-selectors.ts +9 -17
  358. package/src/dataviews/store/reducer.ts +20 -1
  359. package/src/dataviews/types.ts +58 -6
  360. package/src/private-apis.js +2 -2
  361. package/src/store/actions.js +36 -13
  362. package/src/store/private-actions.js +9 -5
  363. package/src/store/private-selectors.js +45 -2
  364. package/src/store/test/private-selectors.js +78 -0
  365. package/src/store/utils/is-template-revertable.js +2 -1
  366. package/tsconfig.tsbuildinfo +1 -1
  367. package/build/dataviews/actions/index.js +0 -32
  368. package/build/dataviews/actions/index.js.map +0 -1
  369. package/build-module/dataviews/actions/index.js +0 -24
  370. package/build-module/dataviews/actions/index.js.map +0 -1
  371. package/build-types/dataviews/actions/index.d.ts +0 -2
  372. package/build-types/dataviews/actions/index.d.ts.map +0 -1
  373. package/src/components/document-outline/test/__snapshots__/index.js.snap +0 -111
  374. package/src/components/document-outline/test/index.js +0 -185
  375. package/src/dataviews/actions/index.ts +0 -25
@@ -0,0 +1,174 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { decodeEntities } from '@wordpress/html-entities';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+ import { __, sprintf, _x } from '@wordpress/i18n';
8
+ import { store as noticesStore } from '@wordpress/notices';
9
+ import { useState } from '@wordpress/element';
10
+ import { DataForm } from '@wordpress/dataviews';
11
+ import {
12
+ Button,
13
+ __experimentalHStack as HStack,
14
+ __experimentalVStack as VStack,
15
+ } from '@wordpress/components';
16
+ import type { Action } from '@wordpress/dataviews';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { getItemTitle } from '../../dataviews/actions/utils';
22
+ import type { CoreDataError, BasePost } from '../types';
23
+ import { titleField } from '../fields';
24
+
25
+ const fields = [ titleField ];
26
+ const formDuplicateAction = {
27
+ fields: [ 'title' ],
28
+ };
29
+
30
+ const duplicatePost: Action< BasePost > = {
31
+ id: 'duplicate-post',
32
+ label: _x( 'Duplicate', 'action label' ),
33
+ isEligible( { status } ) {
34
+ return status !== 'trash';
35
+ },
36
+ RenderModal: ( { items, closeModal, onActionPerformed } ) => {
37
+ const [ item, setItem ] = useState< BasePost >( {
38
+ ...items[ 0 ],
39
+ title: sprintf(
40
+ /* translators: %s: Existing template title */
41
+ __( '%s (Copy)' ),
42
+ getItemTitle( items[ 0 ] )
43
+ ),
44
+ } );
45
+
46
+ const [ isCreatingPage, setIsCreatingPage ] = useState( false );
47
+ const { saveEntityRecord } = useDispatch( coreStore );
48
+ const { createSuccessNotice, createErrorNotice } =
49
+ useDispatch( noticesStore );
50
+
51
+ async function createPage( event: React.FormEvent ) {
52
+ event.preventDefault();
53
+
54
+ if ( isCreatingPage ) {
55
+ return;
56
+ }
57
+
58
+ const newItemOject = {
59
+ status: 'draft',
60
+ title: item.title,
61
+ slug: item.title || __( 'No title' ),
62
+ comment_status: item.comment_status,
63
+ content:
64
+ typeof item.content === 'string'
65
+ ? item.content
66
+ : item.content.raw,
67
+ excerpt:
68
+ typeof item.excerpt === 'string'
69
+ ? item.excerpt
70
+ : item.excerpt?.raw,
71
+ meta: item.meta,
72
+ parent: item.parent,
73
+ password: item.password,
74
+ template: item.template,
75
+ format: item.format,
76
+ featured_media: item.featured_media,
77
+ menu_order: item.menu_order,
78
+ ping_status: item.ping_status,
79
+ };
80
+ const assignablePropertiesPrefix = 'wp:action-assign-';
81
+ // Get all the properties that the current user is able to assign normally author, categories, tags,
82
+ // and custom taxonomies.
83
+ const assignableProperties = Object.keys( item?._links || {} )
84
+ .filter( ( property ) =>
85
+ property.startsWith( assignablePropertiesPrefix )
86
+ )
87
+ .map( ( property ) =>
88
+ property.slice( assignablePropertiesPrefix.length )
89
+ );
90
+ assignableProperties.forEach( ( property ) => {
91
+ if ( item.hasOwnProperty( property ) ) {
92
+ // @ts-ignore
93
+ newItemOject[ property ] = item[ property ];
94
+ }
95
+ } );
96
+ setIsCreatingPage( true );
97
+ try {
98
+ const newItem = await saveEntityRecord(
99
+ 'postType',
100
+ item.type,
101
+ newItemOject,
102
+ { throwOnError: true }
103
+ );
104
+
105
+ createSuccessNotice(
106
+ sprintf(
107
+ // translators: %s: Title of the created template e.g: "Category".
108
+ __( '"%s" successfully created.' ),
109
+ decodeEntities( newItem.title?.rendered || item.title )
110
+ ),
111
+ {
112
+ id: 'duplicate-post-action',
113
+ type: 'snackbar',
114
+ }
115
+ );
116
+
117
+ if ( onActionPerformed ) {
118
+ onActionPerformed( [ newItem ] );
119
+ }
120
+ } catch ( error ) {
121
+ const typedError = error as CoreDataError;
122
+ const errorMessage =
123
+ typedError.message && typedError.code !== 'unknown_error'
124
+ ? typedError.message
125
+ : __( 'An error occurred while duplicating the page.' );
126
+
127
+ createErrorNotice( errorMessage, {
128
+ type: 'snackbar',
129
+ } );
130
+ } finally {
131
+ setIsCreatingPage( false );
132
+ closeModal?.();
133
+ }
134
+ }
135
+
136
+ return (
137
+ <form onSubmit={ createPage }>
138
+ <VStack spacing={ 3 }>
139
+ <DataForm
140
+ data={ item }
141
+ fields={ fields }
142
+ form={ formDuplicateAction }
143
+ onChange={ ( changes ) =>
144
+ setItem( ( prev ) => ( {
145
+ ...prev,
146
+ ...changes,
147
+ } ) )
148
+ }
149
+ />
150
+ <HStack spacing={ 2 } justify="end">
151
+ <Button
152
+ variant="tertiary"
153
+ onClick={ closeModal }
154
+ __next40pxDefaultSize
155
+ >
156
+ { __( 'Cancel' ) }
157
+ </Button>
158
+ <Button
159
+ variant="primary"
160
+ type="submit"
161
+ isBusy={ isCreatingPage }
162
+ aria-disabled={ isCreatingPage }
163
+ __next40pxDefaultSize
164
+ >
165
+ { _x( 'Duplicate', 'action label' ) }
166
+ </Button>
167
+ </HStack>
168
+ </VStack>
169
+ </form>
170
+ );
171
+ },
172
+ };
173
+
174
+ export default duplicatePost;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { __, sprintf, _x } from '@wordpress/i18n';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+ import { useMemo } from '@wordpress/element';
8
+ // @ts-ignore
9
+ import { parse } from '@wordpress/blocks';
10
+ import type { Action } from '@wordpress/dataviews';
11
+
12
+ /**
13
+ * Internal dependencies
14
+ */
15
+ import { TEMPLATE_PART_POST_TYPE } from '../../store/constants';
16
+ import { CreateTemplatePartModalContents } from '../../components/create-template-part-modal';
17
+ import { getItemTitle } from './utils';
18
+ import type { TemplatePart } from '../types';
19
+
20
+ const duplicateTemplatePart: Action< TemplatePart > = {
21
+ id: 'duplicate-template-part',
22
+ label: _x( 'Duplicate', 'action label' ),
23
+ isEligible: ( item ) => item.type === TEMPLATE_PART_POST_TYPE,
24
+ modalHeader: _x( 'Duplicate template part', 'action label' ),
25
+ RenderModal: ( { items, closeModal } ) => {
26
+ const [ item ] = items;
27
+ const blocks = useMemo( () => {
28
+ return (
29
+ item.blocks ??
30
+ parse(
31
+ typeof item.content === 'string'
32
+ ? item.content
33
+ : item.content.raw,
34
+ {
35
+ __unstableSkipMigrationLogs: true,
36
+ }
37
+ )
38
+ );
39
+ }, [ item.content, item.blocks ] );
40
+ const { createSuccessNotice } = useDispatch( noticesStore );
41
+ function onTemplatePartSuccess() {
42
+ createSuccessNotice(
43
+ sprintf(
44
+ // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
45
+ __( '"%s" duplicated.' ),
46
+ getItemTitle( item )
47
+ ),
48
+ { type: 'snackbar', id: 'edit-site-patterns-success' }
49
+ );
50
+ closeModal?.();
51
+ }
52
+ return (
53
+ <CreateTemplatePartModalContents
54
+ blocks={ blocks }
55
+ defaultArea={ item.area }
56
+ defaultTitle={ sprintf(
57
+ /* translators: %s: Existing template part title */
58
+ __( '%s (Copy)' ),
59
+ getItemTitle( item )
60
+ ) }
61
+ onCreate={ onTemplatePartSuccess }
62
+ onError={ closeModal }
63
+ confirmLabel={ _x( 'Duplicate', 'action label' ) }
64
+ closeModal={ closeModal }
65
+ />
66
+ );
67
+ },
68
+ };
69
+
70
+ export default duplicateTemplatePart;
@@ -0,0 +1,3 @@
1
+ const exportPattern = undefined;
2
+
3
+ export default exportPattern;
@@ -0,0 +1,116 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store as coreStore } from '@wordpress/core-data';
5
+ import { __, sprintf } from '@wordpress/i18n';
6
+ import { store as noticesStore } from '@wordpress/notices';
7
+ import type { Action } from '@wordpress/dataviews';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { getItemTitle, isTemplateOrTemplatePart } from './utils';
13
+ import type { CoreDataError, PostWithPermissions } from '../types';
14
+
15
+ const permanentlyDeletePost: Action< PostWithPermissions > = {
16
+ id: 'permanently-delete',
17
+ label: __( 'Permanently delete' ),
18
+ supportsBulk: true,
19
+ isEligible( item ) {
20
+ if ( isTemplateOrTemplatePart( item ) || item.type === 'wp_block' ) {
21
+ return false;
22
+ }
23
+ const { status, permissions } = item;
24
+ return status === 'trash' && permissions?.delete;
25
+ },
26
+ async callback( posts, { registry, onActionPerformed } ) {
27
+ const { createSuccessNotice, createErrorNotice } =
28
+ registry.dispatch( noticesStore );
29
+ const { deleteEntityRecord } = registry.dispatch( coreStore );
30
+ const promiseResult = await Promise.allSettled(
31
+ posts.map( ( post ) => {
32
+ return deleteEntityRecord(
33
+ 'postType',
34
+ post.type,
35
+ post.id,
36
+ { force: true },
37
+ { throwOnError: true }
38
+ );
39
+ } )
40
+ );
41
+ // If all the promises were fulfilled with success.
42
+ if ( promiseResult.every( ( { status } ) => status === 'fulfilled' ) ) {
43
+ let successMessage;
44
+ if ( promiseResult.length === 1 ) {
45
+ successMessage = sprintf(
46
+ /* translators: The posts's title. */
47
+ __( '"%s" permanently deleted.' ),
48
+ getItemTitle( posts[ 0 ] )
49
+ );
50
+ } else {
51
+ successMessage = __( 'The items were permanently deleted.' );
52
+ }
53
+ createSuccessNotice( successMessage, {
54
+ type: 'snackbar',
55
+ id: 'permanently-delete-post-action',
56
+ } );
57
+ onActionPerformed?.( posts );
58
+ } else {
59
+ // If there was at lease one failure.
60
+ let errorMessage;
61
+ // If we were trying to permanently delete a single post.
62
+ if ( promiseResult.length === 1 ) {
63
+ const typedError = promiseResult[ 0 ] as {
64
+ reason?: CoreDataError;
65
+ };
66
+ if ( typedError.reason?.message ) {
67
+ errorMessage = typedError.reason.message;
68
+ } else {
69
+ errorMessage = __(
70
+ 'An error occurred while permanently deleting the item.'
71
+ );
72
+ }
73
+ // If we were trying to permanently delete multiple posts
74
+ } else {
75
+ const errorMessages = new Set();
76
+ const failedPromises = promiseResult.filter(
77
+ ( { status } ) => status === 'rejected'
78
+ );
79
+ for ( const failedPromise of failedPromises ) {
80
+ const typedError = failedPromise as {
81
+ reason?: CoreDataError;
82
+ };
83
+ if ( typedError.reason?.message ) {
84
+ errorMessages.add( typedError.reason.message );
85
+ }
86
+ }
87
+ if ( errorMessages.size === 0 ) {
88
+ errorMessage = __(
89
+ 'An error occurred while permanently deleting the items.'
90
+ );
91
+ } else if ( errorMessages.size === 1 ) {
92
+ errorMessage = sprintf(
93
+ /* translators: %s: an error message */
94
+ __(
95
+ 'An error occurred while permanently deleting the items: %s'
96
+ ),
97
+ [ ...errorMessages ][ 0 ]
98
+ );
99
+ } else {
100
+ errorMessage = sprintf(
101
+ /* translators: %s: a list of comma separated error messages */
102
+ __(
103
+ 'Some errors occurred while permanently deleting the items: %s'
104
+ ),
105
+ [ ...errorMessages ].join( ',' )
106
+ );
107
+ }
108
+ }
109
+ createErrorNotice( errorMessage, {
110
+ type: 'snackbar',
111
+ } );
112
+ }
113
+ },
114
+ };
115
+
116
+ export default permanentlyDeletePost;
@@ -0,0 +1,146 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { useState } from '@wordpress/element';
8
+ // @ts-ignore
9
+ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
10
+ import {
11
+ Button,
12
+ TextControl,
13
+ __experimentalHStack as HStack,
14
+ __experimentalVStack as VStack,
15
+ } from '@wordpress/components';
16
+ import type { Action } from '@wordpress/dataviews';
17
+ import { store as noticesStore } from '@wordpress/notices';
18
+
19
+ /**
20
+ * Internal dependencies
21
+ */
22
+ import {
23
+ TEMPLATE_ORIGINS,
24
+ TEMPLATE_PART_POST_TYPE,
25
+ TEMPLATE_POST_TYPE,
26
+ } from '../../store/constants';
27
+ import { unlock } from '../../lock-unlock';
28
+ import {
29
+ getItemTitle,
30
+ isTemplateRemovable,
31
+ isTemplate,
32
+ isTemplatePart,
33
+ } from './utils';
34
+ import type { CoreDataError, PostWithPermissions } from '../types';
35
+
36
+ // Patterns.
37
+ const { PATTERN_TYPES } = unlock( patternsPrivateApis );
38
+
39
+ const renamePost: Action< PostWithPermissions > = {
40
+ id: 'rename-post',
41
+ label: __( 'Rename' ),
42
+ isEligible( post ) {
43
+ if ( post.status === 'trash' ) {
44
+ return false;
45
+ }
46
+ // Templates, template parts and patterns have special checks for renaming.
47
+ if (
48
+ ! [
49
+ TEMPLATE_POST_TYPE,
50
+ TEMPLATE_PART_POST_TYPE,
51
+ ...Object.values( PATTERN_TYPES ),
52
+ ].includes( post.type )
53
+ ) {
54
+ return post.permissions?.update;
55
+ }
56
+
57
+ // In the case of templates, we can only rename custom templates.
58
+ if ( isTemplate( post ) ) {
59
+ return (
60
+ isTemplateRemovable( post ) &&
61
+ post.is_custom &&
62
+ post.permissions?.update
63
+ );
64
+ }
65
+
66
+ if ( isTemplatePart( post ) ) {
67
+ return (
68
+ post.source === TEMPLATE_ORIGINS.custom &&
69
+ ! post?.has_theme_file &&
70
+ post.permissions?.update
71
+ );
72
+ }
73
+
74
+ return post.type === PATTERN_TYPES.user && post.permissions?.update;
75
+ },
76
+ RenderModal: ( { items, closeModal, onActionPerformed } ) => {
77
+ const [ item ] = items;
78
+ const [ title, setTitle ] = useState( () => getItemTitle( item ) );
79
+ const { editEntityRecord, saveEditedEntityRecord } =
80
+ useDispatch( coreStore );
81
+ const { createSuccessNotice, createErrorNotice } =
82
+ useDispatch( noticesStore );
83
+
84
+ async function onRename( event: React.FormEvent ) {
85
+ event.preventDefault();
86
+ try {
87
+ await editEntityRecord( 'postType', item.type, item.id, {
88
+ title,
89
+ } );
90
+ // Update state before saving rerenders the list.
91
+ setTitle( '' );
92
+ closeModal?.();
93
+ // Persist edited entity.
94
+ await saveEditedEntityRecord( 'postType', item.type, item.id, {
95
+ throwOnError: true,
96
+ } );
97
+ createSuccessNotice( __( 'Name updated' ), {
98
+ type: 'snackbar',
99
+ } );
100
+ onActionPerformed?.( items );
101
+ } catch ( error ) {
102
+ const typedError = error as CoreDataError;
103
+ const errorMessage =
104
+ typedError.message && typedError.code !== 'unknown_error'
105
+ ? typedError.message
106
+ : __( 'An error occurred while updating the name' );
107
+ createErrorNotice( errorMessage, { type: 'snackbar' } );
108
+ }
109
+ }
110
+
111
+ return (
112
+ <form onSubmit={ onRename }>
113
+ <VStack spacing="5">
114
+ <TextControl
115
+ __nextHasNoMarginBottom
116
+ __next40pxDefaultSize
117
+ label={ __( 'Name' ) }
118
+ value={ title }
119
+ onChange={ setTitle }
120
+ required
121
+ />
122
+ <HStack justify="right">
123
+ <Button
124
+ __next40pxDefaultSize
125
+ variant="tertiary"
126
+ onClick={ () => {
127
+ closeModal?.();
128
+ } }
129
+ >
130
+ { __( 'Cancel' ) }
131
+ </Button>
132
+ <Button
133
+ __next40pxDefaultSize
134
+ variant="primary"
135
+ type="submit"
136
+ >
137
+ { __( 'Save' ) }
138
+ </Button>
139
+ </HStack>
140
+ </VStack>
141
+ </form>
142
+ );
143
+ },
144
+ };
145
+
146
+ export default renamePost;
@@ -0,0 +1,3 @@
1
+ const reorderPage = undefined;
2
+
3
+ export default reorderPage;
@@ -0,0 +1,125 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { store as coreStore } from '@wordpress/core-data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { store as noticesStore } from '@wordpress/notices';
8
+ import { useState } from '@wordpress/element';
9
+ import { DataForm, isItemValid } from '@wordpress/dataviews';
10
+ import {
11
+ Button,
12
+ __experimentalHStack as HStack,
13
+ __experimentalVStack as VStack,
14
+ } from '@wordpress/components';
15
+ import type { Action, RenderModalProps } from '@wordpress/dataviews';
16
+
17
+ /**
18
+ * Internal dependencies
19
+ */
20
+ import type { CoreDataError, BasePost } from '../types';
21
+ import { orderField } from '../fields';
22
+
23
+ const fields = [ orderField ];
24
+ const formOrderAction = {
25
+ fields: [ 'menu_order' ],
26
+ };
27
+
28
+ function ReorderModal( {
29
+ items,
30
+ closeModal,
31
+ onActionPerformed,
32
+ }: RenderModalProps< BasePost > ) {
33
+ const [ item, setItem ] = useState( items[ 0 ] );
34
+ const orderInput = item.menu_order;
35
+ const { editEntityRecord, saveEditedEntityRecord } =
36
+ useDispatch( coreStore );
37
+ const { createSuccessNotice, createErrorNotice } =
38
+ useDispatch( noticesStore );
39
+
40
+ async function onOrder( event: React.FormEvent ) {
41
+ event.preventDefault();
42
+
43
+ if ( ! isItemValid( item, fields, formOrderAction ) ) {
44
+ return;
45
+ }
46
+
47
+ try {
48
+ await editEntityRecord( 'postType', item.type, item.id, {
49
+ menu_order: orderInput,
50
+ } );
51
+ closeModal?.();
52
+ // Persist edited entity.
53
+ await saveEditedEntityRecord( 'postType', item.type, item.id, {
54
+ throwOnError: true,
55
+ } );
56
+ createSuccessNotice( __( 'Order updated.' ), {
57
+ type: 'snackbar',
58
+ } );
59
+ onActionPerformed?.( items );
60
+ } catch ( error ) {
61
+ const typedError = error as CoreDataError;
62
+ const errorMessage =
63
+ typedError.message && typedError.code !== 'unknown_error'
64
+ ? typedError.message
65
+ : __( 'An error occurred while updating the order' );
66
+ createErrorNotice( errorMessage, {
67
+ type: 'snackbar',
68
+ } );
69
+ }
70
+ }
71
+ const isSaveDisabled = ! isItemValid( item, fields, formOrderAction );
72
+ return (
73
+ <form onSubmit={ onOrder }>
74
+ <VStack spacing="5">
75
+ <div>
76
+ { __(
77
+ 'Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.'
78
+ ) }
79
+ </div>
80
+ <DataForm
81
+ data={ item }
82
+ fields={ fields }
83
+ form={ formOrderAction }
84
+ onChange={ ( changes ) =>
85
+ setItem( {
86
+ ...item,
87
+ ...changes,
88
+ } )
89
+ }
90
+ />
91
+ <HStack justify="right">
92
+ <Button
93
+ __next40pxDefaultSize
94
+ variant="tertiary"
95
+ onClick={ () => {
96
+ closeModal?.();
97
+ } }
98
+ >
99
+ { __( 'Cancel' ) }
100
+ </Button>
101
+ <Button
102
+ __next40pxDefaultSize
103
+ variant="primary"
104
+ type="submit"
105
+ accessibleWhenDisabled
106
+ disabled={ isSaveDisabled }
107
+ >
108
+ { __( 'Save' ) }
109
+ </Button>
110
+ </HStack>
111
+ </VStack>
112
+ </form>
113
+ );
114
+ }
115
+
116
+ const reorderPage: Action< BasePost > = {
117
+ id: 'order-pages',
118
+ label: __( 'Order' ),
119
+ isEligible( { status } ) {
120
+ return status !== 'trash';
121
+ },
122
+ RenderModal: ReorderModal,
123
+ };
124
+
125
+ export default reorderPage;
@@ -32,7 +32,8 @@ const resetPost: Action< Post > = {
32
32
  return (
33
33
  isTemplateOrTemplatePart( item ) &&
34
34
  item?.source === TEMPLATE_ORIGINS.custom &&
35
- item?.has_theme_file
35
+ ( Boolean( item.type === 'wp_template' && item?.plugin ) ||
36
+ item?.has_theme_file )
36
37
  );
37
38
  },
38
39
  icon: backup,