@wordpress/editor 14.13.0 → 14.13.1-next.a9f418477.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 (304) hide show
  1. package/README.md +8 -28
  2. package/build/bindings/post-meta.js +2 -3
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/autocompleters/user.js +1 -3
  5. package/build/components/autocompleters/user.js.map +1 -1
  6. package/build/components/collab-sidebar/constants.js +2 -1
  7. package/build/components/collab-sidebar/constants.js.map +1 -1
  8. package/build/components/collab-sidebar/index.js +108 -43
  9. package/build/components/collab-sidebar/index.js.map +1 -1
  10. package/build/components/collab-sidebar/utils.js +32 -0
  11. package/build/components/collab-sidebar/utils.js.map +1 -1
  12. package/build/components/document-bar/index.js +3 -1
  13. package/build/components/document-bar/index.js.map +1 -1
  14. package/build/components/entities-saved-states/index.js +6 -6
  15. package/build/components/entities-saved-states/index.js.map +1 -1
  16. package/build/components/error-boundary/index.js +26 -13
  17. package/build/components/error-boundary/index.js.map +1 -1
  18. package/build/components/header/index.js +5 -2
  19. package/build/components/header/index.js.map +1 -1
  20. package/build/components/index.js +10 -26
  21. package/build/components/index.js.map +1 -1
  22. package/build/components/post-actions/actions.js +29 -2
  23. package/build/components/post-actions/actions.js.map +1 -1
  24. package/build/components/post-actions/index.js +1 -1
  25. package/build/components/post-actions/index.js.map +1 -1
  26. package/build/components/post-actions/set-as-homepage.js +170 -0
  27. package/build/components/post-actions/set-as-homepage.js.map +1 -0
  28. package/build/components/post-author/constants.js +1 -1
  29. package/build/components/post-author/constants.js.map +1 -1
  30. package/build/components/post-author/hook.js +1 -0
  31. package/build/components/post-author/hook.js.map +1 -1
  32. package/build/components/post-card-panel/index.js +1 -3
  33. package/build/components/post-card-panel/index.js.map +1 -1
  34. package/build/components/post-fields/index.js +3 -3
  35. package/build/components/post-fields/index.js.map +1 -1
  36. package/build/components/post-publish-button/index.js +4 -2
  37. package/build/components/post-publish-button/index.js.map +1 -1
  38. package/build/components/post-publish-button/post-publish-button-or-toggle.js +32 -37
  39. package/build/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  40. package/build/components/post-publish-panel/maybe-upload-media.js +0 -1
  41. package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  42. package/build/components/post-publish-panel/media-util.js +0 -1
  43. package/build/components/post-publish-panel/media-util.js.map +1 -1
  44. package/build/components/post-publish-panel/postpublish.js +103 -117
  45. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  46. package/build/components/post-publish-panel/prepublish.js +1 -1
  47. package/build/components/post-publish-panel/prepublish.js.map +1 -1
  48. package/build/components/post-trash/check.js +4 -4
  49. package/build/components/post-trash/check.js.map +1 -1
  50. package/build/components/post-url/index.js +2 -1
  51. package/build/components/post-url/index.js.map +1 -1
  52. package/build/components/provider/index.js +9 -1
  53. package/build/components/provider/index.js.map +1 -1
  54. package/build/components/save-publish-panels/index.js +3 -1
  55. package/build/components/save-publish-panels/index.js.map +1 -1
  56. package/build/components/template-part-menu-items/convert-to-template-part.js +2 -3
  57. package/build/components/template-part-menu-items/convert-to-template-part.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/store/private-actions.js +17 -9
  61. package/build/dataviews/store/private-actions.js.map +1 -1
  62. package/build/private-apis.js +2 -2
  63. package/build/private-apis.js.map +1 -1
  64. package/build/store/constants.js +0 -1
  65. package/build/store/constants.js.map +1 -1
  66. package/build/store/private-actions.js +0 -1
  67. package/build/store/private-actions.js.map +1 -1
  68. package/build/store/selectors.js +1 -1
  69. package/build/store/selectors.js.map +1 -1
  70. package/build/utils/pageTypeBadge.js +3 -10
  71. package/build/utils/pageTypeBadge.js.map +1 -1
  72. package/build-module/bindings/post-meta.js +2 -3
  73. package/build-module/bindings/post-meta.js.map +1 -1
  74. package/build-module/components/autocompleters/user.js +1 -3
  75. package/build-module/components/autocompleters/user.js.map +1 -1
  76. package/build-module/components/collab-sidebar/constants.js +1 -0
  77. package/build-module/components/collab-sidebar/constants.js.map +1 -1
  78. package/build-module/components/collab-sidebar/index.js +111 -46
  79. package/build-module/components/collab-sidebar/index.js.map +1 -1
  80. package/build-module/components/collab-sidebar/utils.js +31 -0
  81. package/build-module/components/collab-sidebar/utils.js.map +1 -1
  82. package/build-module/components/document-bar/index.js +3 -1
  83. package/build-module/components/document-bar/index.js.map +1 -1
  84. package/build-module/components/entities-saved-states/index.js +6 -6
  85. package/build-module/components/entities-saved-states/index.js.map +1 -1
  86. package/build-module/components/error-boundary/index.js +28 -15
  87. package/build-module/components/error-boundary/index.js.map +1 -1
  88. package/build-module/components/header/index.js +5 -2
  89. package/build-module/components/header/index.js.map +1 -1
  90. package/build-module/components/index.js +0 -2
  91. package/build-module/components/index.js.map +1 -1
  92. package/build-module/components/post-actions/actions.js +29 -2
  93. package/build-module/components/post-actions/actions.js.map +1 -1
  94. package/build-module/components/post-actions/index.js +1 -1
  95. package/build-module/components/post-actions/index.js.map +1 -1
  96. package/build-module/components/post-actions/set-as-homepage.js +162 -0
  97. package/build-module/components/post-actions/set-as-homepage.js.map +1 -0
  98. package/build-module/components/post-author/constants.js +1 -1
  99. package/build-module/components/post-author/constants.js.map +1 -1
  100. package/build-module/components/post-author/hook.js +1 -0
  101. package/build-module/components/post-author/hook.js.map +1 -1
  102. package/build-module/components/post-card-panel/index.js +1 -3
  103. package/build-module/components/post-card-panel/index.js.map +1 -1
  104. package/build-module/components/post-fields/index.js +3 -3
  105. package/build-module/components/post-fields/index.js.map +1 -1
  106. package/build-module/components/post-publish-button/index.js +4 -2
  107. package/build-module/components/post-publish-button/index.js.map +1 -1
  108. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js +34 -38
  109. package/build-module/components/post-publish-button/post-publish-button-or-toggle.js.map +1 -1
  110. package/build-module/components/post-publish-panel/maybe-upload-media.js +0 -1
  111. package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
  112. package/build-module/components/post-publish-panel/media-util.js +0 -1
  113. package/build-module/components/post-publish-panel/media-util.js.map +1 -1
  114. package/build-module/components/post-publish-panel/postpublish.js +104 -118
  115. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  116. package/build-module/components/post-publish-panel/prepublish.js +1 -1
  117. package/build-module/components/post-publish-panel/prepublish.js.map +1 -1
  118. package/build-module/components/post-trash/check.js +4 -4
  119. package/build-module/components/post-trash/check.js.map +1 -1
  120. package/build-module/components/post-url/index.js +2 -1
  121. package/build-module/components/post-url/index.js.map +1 -1
  122. package/build-module/components/provider/index.js +10 -2
  123. package/build-module/components/provider/index.js.map +1 -1
  124. package/build-module/components/save-publish-panels/index.js +3 -1
  125. package/build-module/components/save-publish-panels/index.js.map +1 -1
  126. package/build-module/components/template-part-menu-items/convert-to-template-part.js +1 -1
  127. package/build-module/components/template-part-menu-items/convert-to-template-part.js.map +1 -1
  128. package/build-module/components/visual-editor/index.js +2 -1
  129. package/build-module/components/visual-editor/index.js.map +1 -1
  130. package/build-module/dataviews/store/private-actions.js +17 -9
  131. package/build-module/dataviews/store/private-actions.js.map +1 -1
  132. package/build-module/private-apis.js +1 -1
  133. package/build-module/private-apis.js.map +1 -1
  134. package/build-module/store/constants.js +0 -1
  135. package/build-module/store/constants.js.map +1 -1
  136. package/build-module/store/private-actions.js +0 -1
  137. package/build-module/store/private-actions.js.map +1 -1
  138. package/build-module/store/selectors.js +1 -1
  139. package/build-module/store/selectors.js.map +1 -1
  140. package/build-module/utils/pageTypeBadge.js +3 -10
  141. package/build-module/utils/pageTypeBadge.js.map +1 -1
  142. package/build-style/style-rtl.css +41 -64
  143. package/build-style/style.css +41 -64
  144. package/build-types/bindings/post-meta.d.ts.map +1 -1
  145. package/build-types/components/autocompleters/user.d.ts +7 -3
  146. package/build-types/components/autocompleters/user.d.ts.map +1 -1
  147. package/build-types/components/collab-sidebar/constants.d.ts +1 -0
  148. package/build-types/components/collab-sidebar/constants.d.ts.map +1 -1
  149. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  150. package/build-types/components/collab-sidebar/utils.d.ts +10 -0
  151. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  152. package/build-types/components/document-bar/index.d.ts.map +1 -1
  153. package/build-types/components/entities-saved-states/index.d.ts +5 -5
  154. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  155. package/build-types/components/error-boundary/index.d.ts.map +1 -1
  156. package/build-types/components/header/index.d.ts.map +1 -1
  157. package/build-types/components/index.d.ts +0 -2
  158. package/build-types/components/index.d.ts.map +1 -1
  159. package/build-types/components/keyboard-shortcut-help-modal/shortcut.d.ts +1 -1
  160. package/build-types/components/media-categories/index.d.ts.map +1 -1
  161. package/build-types/components/pattern-duplicate-modal/index.d.ts.map +1 -1
  162. package/build-types/components/pattern-rename-modal/index.d.ts.map +1 -1
  163. package/build-types/components/post-actions/actions.d.ts +1 -1
  164. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  165. package/build-types/components/post-actions/set-as-homepage.d.ts +10 -0
  166. package/build-types/components/post-actions/set-as-homepage.d.ts.map +1 -0
  167. package/build-types/components/post-author/hook.d.ts.map +1 -1
  168. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  169. package/build-types/components/post-fields/index.d.ts +3 -1
  170. package/build-types/components/post-fields/index.d.ts.map +1 -1
  171. package/build-types/components/post-publish-button/index.d.ts.map +1 -1
  172. package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts +1 -13
  173. package/build-types/components/post-publish-button/post-publish-button-or-toggle.d.ts.map +1 -1
  174. package/build-types/components/post-publish-panel/postpublish.d.ts +4 -2
  175. package/build-types/components/post-publish-panel/postpublish.d.ts.map +1 -1
  176. package/build-types/components/post-taxonomies/flat-term-selector.d.ts +4 -4
  177. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  178. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +4 -4
  179. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  180. package/build-types/components/post-title/constants.d.ts.map +1 -1
  181. package/build-types/components/post-trash/check.d.ts +6 -6
  182. package/build-types/components/post-trash/check.d.ts.map +1 -1
  183. package/build-types/components/post-url/index.d.ts +5 -2
  184. package/build-types/components/post-url/index.d.ts.map +1 -1
  185. package/build-types/components/provider/index.d.ts.map +1 -1
  186. package/build-types/components/save-publish-panels/index.d.ts.map +1 -1
  187. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  188. package/build-types/dataviews/api.d.ts.map +1 -1
  189. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  190. package/build-types/dataviews/store/reducer.d.ts +1 -1
  191. package/build-types/hooks/custom-sources-backwards-compatibility.d.ts.map +1 -1
  192. package/build-types/hooks/pattern-overrides.d.ts.map +1 -1
  193. package/build-types/lock-unlock.d.ts +2 -2
  194. package/build-types/store/actions.d.ts +7 -9
  195. package/build-types/store/actions.d.ts.map +1 -1
  196. package/build-types/store/private-actions.d.ts +1 -1
  197. package/build-types/store/private-actions.d.ts.map +1 -1
  198. package/build-types/store/reducer.d.ts +1 -1
  199. package/build-types/store/selectors.d.ts +2 -2
  200. package/build-types/store/selectors.d.ts.map +1 -1
  201. package/build-types/utils/pageTypeBadge.d.ts +3 -1
  202. package/build-types/utils/pageTypeBadge.d.ts.map +1 -1
  203. package/package.json +36 -36
  204. package/src/bindings/post-meta.js +2 -5
  205. package/src/components/autocompleters/user.js +1 -3
  206. package/src/components/collab-sidebar/constants.js +1 -0
  207. package/src/components/collab-sidebar/index.js +115 -47
  208. package/src/components/collab-sidebar/style.scss +13 -0
  209. package/src/components/collab-sidebar/utils.js +36 -0
  210. package/src/components/document-bar/index.js +3 -1
  211. package/src/components/editor-interface/style.scss +2 -1
  212. package/src/components/entities-saved-states/index.js +6 -9
  213. package/src/components/error-boundary/index.js +30 -16
  214. package/src/components/error-boundary/style.scss +5 -1
  215. package/src/components/header/index.js +17 -5
  216. package/src/components/header/style.scss +1 -1
  217. package/src/components/index.js +0 -2
  218. package/src/components/post-actions/actions.js +38 -2
  219. package/src/components/post-actions/index.js +1 -1
  220. package/src/components/post-actions/set-as-homepage.js +183 -0
  221. package/src/components/post-author/constants.js +1 -1
  222. package/src/components/post-author/hook.js +1 -0
  223. package/src/components/post-card-panel/index.js +1 -3
  224. package/src/components/post-card-panel/style.scss +1 -0
  225. package/src/components/post-fields/index.ts +5 -3
  226. package/src/components/post-publish-button/index.js +2 -0
  227. package/src/components/post-publish-button/post-publish-button-or-toggle.js +38 -40
  228. package/src/components/post-publish-button/test/post-publish-button-or-toggle.js +24 -9
  229. package/src/components/post-publish-panel/postpublish.js +114 -124
  230. package/src/components/post-publish-panel/prepublish.js +1 -1
  231. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
  232. package/src/components/post-trash/check.js +4 -4
  233. package/src/components/post-url/index.js +2 -1
  234. package/src/components/provider/index.js +17 -3
  235. package/src/components/save-publish-panels/index.js +5 -1
  236. package/src/components/template-part-menu-items/convert-to-template-part.js +1 -1
  237. package/src/components/visual-editor/index.js +1 -0
  238. package/src/components/visual-editor/style.scss +29 -6
  239. package/src/dataviews/store/private-actions.ts +36 -20
  240. package/src/private-apis.js +1 -1
  241. package/src/store/selectors.js +1 -1
  242. package/src/style.scss +0 -2
  243. package/src/utils/pageTypeBadge.js +3 -8
  244. package/tsconfig.tsbuildinfo +1 -1
  245. package/build/components/create-template-part-modal/index.js +0 -170
  246. package/build/components/create-template-part-modal/index.js.map +0 -1
  247. package/build/components/create-template-part-modal/utils.js +0 -64
  248. package/build/components/create-template-part-modal/utils.js.map +0 -1
  249. package/build/components/post-slug/check.js +0 -29
  250. package/build/components/post-slug/check.js.map +0 -1
  251. package/build/components/post-slug/index.js +0 -79
  252. package/build/components/post-slug/index.js.map +0 -1
  253. package/build/components/post-slug/panel.js +0 -30
  254. package/build/components/post-slug/panel.js.map +0 -1
  255. package/build/dataviews/actions/duplicate-template-part.js +0 -67
  256. package/build/dataviews/actions/duplicate-template-part.js.map +0 -1
  257. package/build/dataviews/actions/utils.js +0 -58
  258. package/build/dataviews/actions/utils.js.map +0 -1
  259. package/build/dataviews/types.js +0 -6
  260. package/build/dataviews/types.js.map +0 -1
  261. package/build-module/components/create-template-part-modal/index.js +0 -162
  262. package/build-module/components/create-template-part-modal/index.js.map +0 -1
  263. package/build-module/components/create-template-part-modal/utils.js +0 -54
  264. package/build-module/components/create-template-part-modal/utils.js.map +0 -1
  265. package/build-module/components/post-slug/check.js +0 -23
  266. package/build-module/components/post-slug/check.js.map +0 -1
  267. package/build-module/components/post-slug/index.js +0 -71
  268. package/build-module/components/post-slug/index.js.map +0 -1
  269. package/build-module/components/post-slug/panel.js +0 -21
  270. package/build-module/components/post-slug/panel.js.map +0 -1
  271. package/build-module/dataviews/actions/duplicate-template-part.js +0 -58
  272. package/build-module/dataviews/actions/duplicate-template-part.js.map +0 -1
  273. package/build-module/dataviews/actions/utils.js +0 -47
  274. package/build-module/dataviews/actions/utils.js.map +0 -1
  275. package/build-module/dataviews/types.js +0 -2
  276. package/build-module/dataviews/types.js.map +0 -1
  277. package/build-types/components/create-template-part-modal/index.d.ts +0 -14
  278. package/build-types/components/create-template-part-modal/index.d.ts.map +0 -1
  279. package/build-types/components/create-template-part-modal/utils.d.ts +0 -4
  280. package/build-types/components/create-template-part-modal/utils.d.ts.map +0 -1
  281. package/build-types/components/post-slug/check.d.ts +0 -12
  282. package/build-types/components/post-slug/check.d.ts.map +0 -1
  283. package/build-types/components/post-slug/index.d.ts +0 -7
  284. package/build-types/components/post-slug/index.d.ts.map +0 -1
  285. package/build-types/components/post-slug/panel.d.ts +0 -3
  286. package/build-types/components/post-slug/panel.d.ts.map +0 -1
  287. package/build-types/dataviews/actions/duplicate-template-part.d.ts +0 -5
  288. package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +0 -1
  289. package/build-types/dataviews/actions/utils.d.ts +0 -13
  290. package/build-types/dataviews/actions/utils.d.ts.map +0 -1
  291. package/build-types/dataviews/types.d.ts +0 -92
  292. package/build-types/dataviews/types.d.ts.map +0 -1
  293. package/src/components/create-template-part-modal/index.js +0 -210
  294. package/src/components/create-template-part-modal/style.scss +0 -63
  295. package/src/components/create-template-part-modal/test/utils.js +0 -60
  296. package/src/components/create-template-part-modal/utils.js +0 -67
  297. package/src/components/post-slug/check.js +0 -20
  298. package/src/components/post-slug/index.js +0 -73
  299. package/src/components/post-slug/panel.js +0 -22
  300. package/src/components/post-slug/style.scss +0 -5
  301. package/src/components/post-slug/test/index.js +0 -53
  302. package/src/dataviews/actions/duplicate-template-part.tsx +0 -70
  303. package/src/dataviews/actions/utils.ts +0 -64
  304. package/src/dataviews/types.ts +0 -85
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/dataviews/actions/utils.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAE7D,wBAAgB,UAAU,CAAE,IAAI,EAAE,IAAI,GAAI,IAAI,IAAI,QAAQ,CAEzD;AAED,wBAAgB,cAAc,CAAE,IAAI,EAAE,IAAI,GAAI,IAAI,IAAI,YAAY,CAEjE;AAED,wBAAgB,wBAAwB,CACvC,CAAC,EAAE,IAAI,GACL,CAAC,IAAI,QAAQ,GAAG,YAAY,CAE9B;AAED,wBAAgB,YAAY,CAAE,IAAI,EAAE,IAAI,UAWvC;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAE,QAAQ,EAAE,QAAQ,GAAG,YAAY,WAcrE"}
@@ -1,92 +0,0 @@
1
- type PostStatus = 'published' | 'draft' | 'pending' | 'private' | 'future' | 'auto-draft' | 'trash';
2
- export interface CommonPost {
3
- status?: PostStatus;
4
- title: string | {
5
- rendered: string;
6
- } | {
7
- raw: string;
8
- };
9
- content: string | {
10
- raw: string;
11
- rendered: string;
12
- };
13
- type: string;
14
- id: string | number;
15
- blocks?: Object[];
16
- _links?: Links;
17
- }
18
- interface Links {
19
- 'predecessor-version'?: {
20
- href: string;
21
- id: number;
22
- }[];
23
- 'version-history'?: {
24
- href: string;
25
- count: number;
26
- }[];
27
- [key: string]: {
28
- href: string;
29
- }[] | undefined;
30
- }
31
- export interface BasePost extends CommonPost {
32
- comment_status?: 'open' | 'closed';
33
- excerpt?: string | {
34
- raw: string;
35
- rendered: string;
36
- };
37
- meta?: Record<string, any>;
38
- parent?: number;
39
- password?: string;
40
- template?: string;
41
- format?: string;
42
- featured_media?: number;
43
- menu_order?: number;
44
- ping_status?: 'open' | 'closed';
45
- link?: string;
46
- }
47
- export interface Template extends CommonPost {
48
- type: 'wp_template';
49
- is_custom: boolean;
50
- source: string;
51
- origin: string;
52
- plugin?: string;
53
- has_theme_file: boolean;
54
- id: string;
55
- }
56
- export interface TemplatePart extends CommonPost {
57
- type: 'wp_template_part';
58
- source: string;
59
- origin: string;
60
- has_theme_file: boolean;
61
- id: string;
62
- area: string;
63
- }
64
- export interface Pattern extends CommonPost {
65
- slug: string;
66
- title: {
67
- raw: string;
68
- };
69
- wp_pattern_sync_status: string;
70
- }
71
- export type Post = Template | TemplatePart | Pattern | BasePost;
72
- export type PostWithPermissions = Post & {
73
- permissions: {
74
- delete: boolean;
75
- update: boolean;
76
- };
77
- };
78
- export interface PostType {
79
- slug: string;
80
- viewable: boolean;
81
- supports?: {
82
- 'page-attributes'?: boolean;
83
- title?: boolean;
84
- revisions?: boolean;
85
- };
86
- }
87
- export type CoreDataError = {
88
- message?: string;
89
- code?: string;
90
- };
91
- export {};
92
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dataviews/types.ts"],"names":[],"mappings":"AAAA,KAAK,UAAU,GACZ,WAAW,GACX,OAAO,GACP,SAAS,GACT,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,OAAO,CAAC;AAEX,MAAM,WAAW,UAAU;IAC1B,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,KAAK,EAAE,MAAM,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E,CAAC"}
@@ -1,210 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useSelect, useDispatch } from '@wordpress/data';
5
- import {
6
- Icon,
7
- BaseControl,
8
- TextControl,
9
- Flex,
10
- FlexItem,
11
- FlexBlock,
12
- Button,
13
- Modal,
14
- __experimentalRadioGroup as RadioGroup,
15
- __experimentalRadio as Radio,
16
- __experimentalHStack as HStack,
17
- __experimentalVStack as VStack,
18
- } from '@wordpress/components';
19
- import { __ } from '@wordpress/i18n';
20
- import { useState } from '@wordpress/element';
21
- import { useInstanceId } from '@wordpress/compose';
22
- import { store as noticesStore } from '@wordpress/notices';
23
- import { store as coreStore } from '@wordpress/core-data';
24
- import { check } from '@wordpress/icons';
25
- import { serialize } from '@wordpress/blocks';
26
-
27
- /**
28
- * Internal dependencies
29
- */
30
- import {
31
- TEMPLATE_PART_POST_TYPE,
32
- TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
33
- } from '../../store/constants';
34
- import {
35
- useExistingTemplateParts,
36
- getUniqueTemplatePartTitle,
37
- getCleanTemplatePartSlug,
38
- } from './utils';
39
-
40
- export default function CreateTemplatePartModal( {
41
- modalTitle,
42
- ...restProps
43
- } ) {
44
- const defaultModalTitle = useSelect(
45
- ( select ) =>
46
- select( coreStore ).getPostType( TEMPLATE_PART_POST_TYPE )?.labels
47
- ?.add_new_item,
48
- []
49
- );
50
- return (
51
- <Modal
52
- title={ modalTitle || defaultModalTitle }
53
- onRequestClose={ restProps.closeModal }
54
- overlayClassName="editor-create-template-part-modal"
55
- focusOnMount="firstContentElement"
56
- size="medium"
57
- >
58
- <CreateTemplatePartModalContents { ...restProps } />
59
- </Modal>
60
- );
61
- }
62
-
63
- export function CreateTemplatePartModalContents( {
64
- defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
65
- blocks = [],
66
- confirmLabel = __( 'Add' ),
67
- closeModal,
68
- onCreate,
69
- onError,
70
- defaultTitle = '',
71
- } ) {
72
- const { createErrorNotice } = useDispatch( noticesStore );
73
- const { saveEntityRecord } = useDispatch( coreStore );
74
- const existingTemplateParts = useExistingTemplateParts();
75
-
76
- const [ title, setTitle ] = useState( defaultTitle );
77
- const [ area, setArea ] = useState( defaultArea );
78
- const [ isSubmitting, setIsSubmitting ] = useState( false );
79
- const instanceId = useInstanceId( CreateTemplatePartModal );
80
-
81
- const templatePartAreas = useSelect(
82
- ( select ) =>
83
- select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
84
- ?.default_template_part_areas || [],
85
- []
86
- );
87
-
88
- async function createTemplatePart() {
89
- if ( ! title || isSubmitting ) {
90
- return;
91
- }
92
-
93
- try {
94
- setIsSubmitting( true );
95
- const uniqueTitle = getUniqueTemplatePartTitle(
96
- title,
97
- existingTemplateParts
98
- );
99
- const cleanSlug = getCleanTemplatePartSlug( uniqueTitle );
100
-
101
- const templatePart = await saveEntityRecord(
102
- 'postType',
103
- TEMPLATE_PART_POST_TYPE,
104
- {
105
- slug: cleanSlug,
106
- title: uniqueTitle,
107
- content: serialize( blocks ),
108
- area,
109
- },
110
- { throwOnError: true }
111
- );
112
- await onCreate( templatePart );
113
-
114
- // TODO: Add a success notice?
115
- } catch ( error ) {
116
- const errorMessage =
117
- error.message && error.code !== 'unknown_error'
118
- ? error.message
119
- : __(
120
- 'An error occurred while creating the template part.'
121
- );
122
-
123
- createErrorNotice( errorMessage, { type: 'snackbar' } );
124
-
125
- onError?.();
126
- } finally {
127
- setIsSubmitting( false );
128
- }
129
- }
130
- return (
131
- <form
132
- onSubmit={ async ( event ) => {
133
- event.preventDefault();
134
- await createTemplatePart();
135
- } }
136
- >
137
- <VStack spacing="4">
138
- <TextControl
139
- __next40pxDefaultSize
140
- __nextHasNoMarginBottom
141
- label={ __( 'Name' ) }
142
- value={ title }
143
- onChange={ setTitle }
144
- required
145
- />
146
- <BaseControl
147
- __nextHasNoMarginBottom
148
- label={ __( 'Area' ) }
149
- id={ `editor-create-template-part-modal__area-selection-${ instanceId }` }
150
- className="editor-create-template-part-modal__area-base-control"
151
- >
152
- <RadioGroup
153
- label={ __( 'Area' ) }
154
- className="editor-create-template-part-modal__area-radio-group"
155
- id={ `editor-create-template-part-modal__area-selection-${ instanceId }` }
156
- onChange={ setArea }
157
- checked={ area }
158
- >
159
- { templatePartAreas.map(
160
- ( { icon, label, area: value, description } ) => (
161
- <Radio
162
- __next40pxDefaultSize
163
- key={ label }
164
- value={ value }
165
- className="editor-create-template-part-modal__area-radio"
166
- >
167
- <Flex align="start" justify="start">
168
- <FlexItem>
169
- <Icon icon={ icon } />
170
- </FlexItem>
171
- <FlexBlock className="editor-create-template-part-modal__option-label">
172
- { label }
173
- <div>{ description }</div>
174
- </FlexBlock>
175
-
176
- <FlexItem className="editor-create-template-part-modal__checkbox">
177
- { area === value && (
178
- <Icon icon={ check } />
179
- ) }
180
- </FlexItem>
181
- </Flex>
182
- </Radio>
183
- )
184
- ) }
185
- </RadioGroup>
186
- </BaseControl>
187
- <HStack justify="right">
188
- <Button
189
- __next40pxDefaultSize
190
- variant="tertiary"
191
- onClick={ () => {
192
- closeModal();
193
- } }
194
- >
195
- { __( 'Cancel' ) }
196
- </Button>
197
- <Button
198
- __next40pxDefaultSize
199
- variant="primary"
200
- type="submit"
201
- aria-disabled={ ! title || isSubmitting }
202
- isBusy={ isSubmitting }
203
- >
204
- { confirmLabel }
205
- </Button>
206
- </HStack>
207
- </VStack>
208
- </form>
209
- );
210
- }
@@ -1,63 +0,0 @@
1
- .editor-create-template-part-modal {
2
- z-index: z-index(".editor-create-template-part-modal");
3
- }
4
-
5
- .editor-create-template-part-modal__area-radio-group {
6
- width: 100%;
7
- border: $border-width solid $gray-700;
8
- border-radius: $radius-small;
9
-
10
- .components-button.editor-create-template-part-modal__area-radio {
11
- display: block;
12
- width: 100%;
13
- height: 100%;
14
- text-align: left;
15
- padding: $grid-unit-15;
16
-
17
- &,
18
- &.is-secondary:hover,
19
- &.is-primary:hover {
20
- margin: 0;
21
- background-color: inherit;
22
- border-bottom: $border-width solid $gray-700;
23
- border-radius: 0;
24
-
25
- &:not(:focus) {
26
- box-shadow: none;
27
- }
28
-
29
- &:focus {
30
- border-bottom: $border-width solid $white;
31
- }
32
-
33
- &:last-of-type {
34
- border-bottom: none;
35
- }
36
- }
37
-
38
- &:not(:hover),
39
- &[aria-checked="true"] {
40
- color: $gray-900;
41
- cursor: auto;
42
-
43
- .editor-create-template-part-modal__option-label div {
44
- color: $gray-600;
45
- }
46
- }
47
-
48
- .editor-create-template-part-modal__option-label {
49
- padding-top: $grid-unit-05;
50
- white-space: normal;
51
-
52
- div {
53
- padding-top: $grid-unit-05;
54
- font-size: $helptext-font-size;
55
- }
56
- }
57
-
58
- .editor-create-template-part-modal__checkbox {
59
- margin-left: auto;
60
- min-width: $grid-unit-30;
61
- }
62
- }
63
- }
@@ -1,60 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import { getUniqueTemplatePartTitle, getCleanTemplatePartSlug } from '../utils';
5
-
6
- describe( 'getUniqueTemplatePartTitle', () => {
7
- it( 'should return the title if it is unique', () => {
8
- const title = 'My Template Part';
9
- const templateParts = [
10
- {
11
- title: {
12
- rendered: 'Template Part With Another Title',
13
- },
14
- },
15
- ];
16
-
17
- expect( getUniqueTemplatePartTitle( title, templateParts ) ).toBe(
18
- title
19
- );
20
- } );
21
-
22
- it( 'should return the title with a suffix if it is not unique', () => {
23
- const title = 'My Template Part';
24
- const templateParts = [
25
- {
26
- title: {
27
- rendered: 'My Template Part',
28
- },
29
- },
30
- {
31
- title: {
32
- rendered: 'My Template Part 2',
33
- },
34
- },
35
- ];
36
-
37
- expect( getUniqueTemplatePartTitle( title, templateParts ) ).toBe(
38
- 'My Template Part 3'
39
- );
40
- } );
41
- } );
42
-
43
- describe( 'getCleanTemplatePartSlug', () => {
44
- it( 'should return a slug with only latin chars', () => {
45
- const title = 'Myɶ Template Partɮ';
46
- expect( getCleanTemplatePartSlug( title ) ).toBe( 'my-template-part' );
47
- } );
48
-
49
- it( 'should return a slug with only latin chars and numbers', () => {
50
- const title = 'My Template Part 2';
51
- expect( getCleanTemplatePartSlug( title ) ).toBe(
52
- 'my-template-part-2'
53
- );
54
- } );
55
-
56
- it( 'should default the slug to wp-custom-part', () => {
57
- const title = '';
58
- expect( getCleanTemplatePartSlug( title ) ).toBe( 'wp-custom-part' );
59
- } );
60
- } );
@@ -1,67 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { paramCase as kebabCase } from 'change-case';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { useSelect } from '@wordpress/data';
10
- import { store as coreStore } from '@wordpress/core-data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import { TEMPLATE_PART_POST_TYPE } from '../../store/constants';
16
-
17
- export const useExistingTemplateParts = () => {
18
- return useSelect(
19
- ( select ) =>
20
- select( coreStore ).getEntityRecords(
21
- 'postType',
22
- TEMPLATE_PART_POST_TYPE,
23
- {
24
- per_page: -1,
25
- }
26
- ),
27
- []
28
- );
29
- };
30
-
31
- /**
32
- * Return a unique template part title based on
33
- * the given title and existing template parts.
34
- *
35
- * @param {string} title The original template part title.
36
- * @param {Object} templateParts The array of template part entities.
37
- * @return {string} A unique template part title.
38
- */
39
- export const getUniqueTemplatePartTitle = ( title, templateParts ) => {
40
- const lowercaseTitle = title.toLowerCase();
41
- const existingTitles = templateParts.map( ( templatePart ) =>
42
- templatePart.title.rendered.toLowerCase()
43
- );
44
-
45
- if ( ! existingTitles.includes( lowercaseTitle ) ) {
46
- return title;
47
- }
48
-
49
- let suffix = 2;
50
- while ( existingTitles.includes( `${ lowercaseTitle } ${ suffix }` ) ) {
51
- suffix++;
52
- }
53
-
54
- return `${ title } ${ suffix }`;
55
- };
56
-
57
- /**
58
- * Get a valid slug for a template part.
59
- * Currently template parts only allow latin chars.
60
- * The fallback slug will receive suffix by default.
61
- *
62
- * @param {string} title The template part title.
63
- * @return {string} A valid template part slug.
64
- */
65
- export const getCleanTemplatePartSlug = ( title ) => {
66
- return kebabCase( title ).replace( /[^\w-]+/g, '' ) || 'wp-custom-part';
67
- };
@@ -1,20 +0,0 @@
1
- /**
2
- * Internal dependencies
3
- */
4
- import PostTypeSupportCheck from '../post-type-support-check';
5
-
6
- /**
7
- * Wrapper component that renders its children only if the post type supports the slug.
8
- *
9
- * @param {Object} props Props.
10
- * @param {React.ReactNode} props.children Children to be rendered.
11
- *
12
- * @return {React.ReactNode} The rendered component.
13
- */
14
- export default function PostSlugCheck( { children } ) {
15
- return (
16
- <PostTypeSupportCheck supportKeys="slug">
17
- { children }
18
- </PostTypeSupportCheck>
19
- );
20
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { useDispatch, useSelect } from '@wordpress/data';
5
- import { useState } from '@wordpress/element';
6
- import { __ } from '@wordpress/i18n';
7
- import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
8
- import { TextControl } from '@wordpress/components';
9
-
10
- /**
11
- * Internal dependencies
12
- */
13
- import PostSlugCheck from './check';
14
- import { store as editorStore } from '../../store';
15
-
16
- function PostSlugControl() {
17
- const postSlug = useSelect( ( select ) => {
18
- return safeDecodeURIComponent(
19
- select( editorStore ).getEditedPostSlug()
20
- );
21
- }, [] );
22
- const { editPost } = useDispatch( editorStore );
23
- const [ forceEmptyField, setForceEmptyField ] = useState( false );
24
-
25
- return (
26
- <TextControl
27
- __next40pxDefaultSize
28
- __nextHasNoMarginBottom
29
- label={ __( 'Slug' ) }
30
- autoComplete="off"
31
- spellCheck="false"
32
- value={ forceEmptyField ? '' : postSlug }
33
- onChange={ ( newValue ) => {
34
- editPost( { slug: newValue } );
35
- // When we delete the field the permalink gets
36
- // reverted to the original value.
37
- // The forceEmptyField logic allows the user to have
38
- // the field temporarily empty while typing.
39
- if ( ! newValue ) {
40
- if ( ! forceEmptyField ) {
41
- setForceEmptyField( true );
42
- }
43
- return;
44
- }
45
- if ( forceEmptyField ) {
46
- setForceEmptyField( false );
47
- }
48
- } }
49
- onBlur={ ( event ) => {
50
- editPost( {
51
- slug: cleanForSlug( event.target.value ),
52
- } );
53
- if ( forceEmptyField ) {
54
- setForceEmptyField( false );
55
- }
56
- } }
57
- className="editor-post-slug"
58
- />
59
- );
60
- }
61
-
62
- /**
63
- * Renders the PostSlug component. It provide a control for editing the post slug.
64
- *
65
- * @return {React.ReactNode} The rendered component.
66
- */
67
- export default function PostSlug() {
68
- return (
69
- <PostSlugCheck>
70
- <PostSlugControl />
71
- </PostSlugCheck>
72
- );
73
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { PanelRow } from '@wordpress/components';
5
-
6
- /**
7
- * Internal dependencies
8
- */
9
- import PostSlugForm from './';
10
- import PostSlugCheck from './check';
11
-
12
- export function PostSlug() {
13
- return (
14
- <PostSlugCheck>
15
- <PanelRow className="editor-post-slug">
16
- <PostSlugForm />
17
- </PanelRow>
18
- </PostSlugCheck>
19
- );
20
- }
21
-
22
- export default PostSlug;
@@ -1,5 +0,0 @@
1
- .editor-post-slug {
2
- display: flex;
3
- flex-direction: column;
4
- align-items: stretch;
5
- }
@@ -1,53 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { act, render, screen } from '@testing-library/react';
5
- import userEvent from '@testing-library/user-event';
6
-
7
- /**
8
- * WordPress dependencies
9
- */
10
- import { useSelect, useDispatch } from '@wordpress/data';
11
-
12
- /**
13
- * Internal dependencies
14
- */
15
- import PostSlug from '../';
16
-
17
- jest.mock( '@wordpress/data/src/components/use-select', () => jest.fn() );
18
- jest.mock( '@wordpress/data/src/components/use-dispatch/use-dispatch', () =>
19
- jest.fn()
20
- );
21
-
22
- describe( 'PostSlug', () => {
23
- it( 'should update slug with sanitized input', async () => {
24
- const user = userEvent.setup();
25
- const editPost = jest.fn();
26
-
27
- useSelect.mockImplementation( ( mapSelect ) =>
28
- mapSelect( () => ( {
29
- getPostType: () => ( {
30
- supports: {
31
- slug: true,
32
- },
33
- } ),
34
- getEditedPostAttribute: () => 'post',
35
- getEditedPostSlug: () => '1',
36
- } ) )
37
- );
38
- useDispatch.mockImplementation( () => ( {
39
- editPost,
40
- } ) );
41
-
42
- render( <PostSlug /> );
43
-
44
- const input = screen.getByRole( 'textbox', { name: 'Slug' } );
45
- await user.type( input, '2', {
46
- initialSelectionStart: 0,
47
- initialSelectionEnd: 1,
48
- } );
49
- act( () => input.blur() );
50
-
51
- expect( editPost ).toHaveBeenCalledWith( { slug: '2' } );
52
- } );
53
- } );