@wordpress/edit-site 5.25.0 → 5.26.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 (433) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/block-editor/back-button.js +3 -2
  4. package/build/components/block-editor/back-button.js.map +1 -1
  5. package/build/components/block-editor/resizable-editor.js +2 -2
  6. package/build/components/block-editor/resizable-editor.js.map +1 -1
  7. package/build/components/block-editor/use-post-link-props.js +27 -0
  8. package/build/components/block-editor/use-post-link-props.js.map +1 -0
  9. package/build/components/block-editor/use-site-editor-settings.js +7 -24
  10. package/build/components/block-editor/use-site-editor-settings.js.map +1 -1
  11. package/build/components/create-template-part-modal/index.js +15 -7
  12. package/build/components/create-template-part-modal/index.js.map +1 -1
  13. package/build/components/editor/index.js +15 -16
  14. package/build/components/editor/index.js.map +1 -1
  15. package/build/components/editor-canvas-container/index.js +9 -7
  16. package/build/components/editor-canvas-container/index.js.map +1 -1
  17. package/build/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
  18. package/build/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  19. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  20. package/build/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
  21. package/build/components/global-styles/font-library-modal/context.js +5 -5
  22. package/build/components/global-styles/font-library-modal/context.js.map +1 -1
  23. package/build/components/global-styles/font-library-modal/font-collection.js +8 -4
  24. package/build/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  25. package/build/components/global-styles/font-library-modal/index.js +38 -21
  26. package/build/components/global-styles/font-library-modal/index.js.map +1 -1
  27. package/build/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  28. package/build/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  29. package/build/components/global-styles/font-library-modal/library-font-variant.js +5 -2
  30. package/build/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  31. package/build/components/global-styles/font-library-modal/local-fonts.js +26 -10
  32. package/build/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  33. package/build/components/global-styles/font-library-modal/resolvers.js +6 -6
  34. package/build/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  35. package/build/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
  36. package/build/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
  37. package/build/components/global-styles/font-library-modal/utils/index.js +35 -38
  38. package/build/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  39. package/build/components/global-styles/preview.js +43 -1
  40. package/build/components/global-styles/preview.js.map +1 -1
  41. package/build/components/global-styles/screen-color-palette.js +16 -12
  42. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  43. package/build/components/global-styles/screen-revisions/index.js +52 -52
  44. package/build/components/global-styles/screen-revisions/index.js.map +1 -1
  45. package/build/components/global-styles/screen-revisions/revisions-buttons.js +26 -35
  46. package/build/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  47. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
  48. package/build/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  49. package/build/components/global-styles/ui.js +13 -62
  50. package/build/components/global-styles/ui.js.map +1 -1
  51. package/build/components/header-edit-mode/document-tools/index.js +8 -106
  52. package/build/components/header-edit-mode/document-tools/index.js.map +1 -1
  53. package/build/components/header-edit-mode/index.js +7 -11
  54. package/build/components/header-edit-mode/index.js.map +1 -1
  55. package/build/components/header-edit-mode/mode-switcher/index.js +0 -2
  56. package/build/components/header-edit-mode/mode-switcher/index.js.map +1 -1
  57. package/build/components/header-edit-mode/more-menu/index.js +10 -7
  58. package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
  59. package/build/components/keyboard-shortcuts/edit-mode.js +0 -23
  60. package/build/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  61. package/build/components/keyboard-shortcuts/register.js +0 -36
  62. package/build/components/keyboard-shortcuts/register.js.map +1 -1
  63. package/build/components/layout/index.js +6 -13
  64. package/build/components/layout/index.js.map +1 -1
  65. package/build/components/page-main/index.js +4 -4
  66. package/build/components/page-main/index.js.map +1 -1
  67. package/build/components/page-pages/index.js +84 -37
  68. package/build/components/page-pages/index.js.map +1 -1
  69. package/build/components/page-patterns/dataviews-pattern-actions.js +305 -0
  70. package/build/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
  71. package/build/components/page-patterns/dataviews-patterns.js +307 -0
  72. package/build/components/page-patterns/dataviews-patterns.js.map +1 -0
  73. package/build/components/page-patterns/duplicate-menu-item.js +1 -1
  74. package/build/components/page-patterns/duplicate-menu-item.js.map +1 -1
  75. package/build/components/page-patterns/grid-item.js +4 -3
  76. package/build/components/page-patterns/grid-item.js.map +1 -1
  77. package/build/components/page-patterns/patterns-list.js +2 -1
  78. package/build/components/page-patterns/patterns-list.js.map +1 -1
  79. package/build/components/page-patterns/use-patterns.js +23 -13
  80. package/build/components/page-patterns/use-patterns.js.map +1 -1
  81. package/build/components/page-templates/index.js +312 -36
  82. package/build/components/page-templates/index.js.map +1 -1
  83. package/build/components/{page-patterns/pagination.js → pagination/index.js} +25 -12
  84. package/build/components/pagination/index.js.map +1 -0
  85. package/build/components/{page-pages/side-editor.js → post-preview/index.js} +8 -4
  86. package/build/components/post-preview/index.js.map +1 -0
  87. package/build/components/preferences-modal/enable-feature.js +3 -2
  88. package/build/components/preferences-modal/enable-feature.js.map +1 -1
  89. package/build/components/preferences-modal/enable-panel-option.js +33 -0
  90. package/build/components/preferences-modal/enable-panel-option.js.map +1 -0
  91. package/build/components/preferences-modal/index.js +57 -9
  92. package/build/components/preferences-modal/index.js.map +1 -1
  93. package/build/components/revisions/index.js +3 -7
  94. package/build/components/revisions/index.js.map +1 -1
  95. package/build/components/routes/link.js +6 -2
  96. package/build/components/routes/link.js.map +1 -1
  97. package/build/components/save-button/index.js +6 -3
  98. package/build/components/save-button/index.js.map +1 -1
  99. package/build/components/sidebar/index.js +3 -11
  100. package/build/components/sidebar/index.js.map +1 -1
  101. package/build/components/sidebar-dataviews/add-new-view.js +2 -2
  102. package/build/components/sidebar-dataviews/add-new-view.js.map +1 -1
  103. package/build/components/sidebar-dataviews/default-views.js +18 -5
  104. package/build/components/sidebar-dataviews/default-views.js.map +1 -1
  105. package/build/components/sidebar-dataviews/index.js +3 -3
  106. package/build/components/sidebar-dataviews/index.js.map +1 -1
  107. package/build/components/sidebar-edit-mode/default-sidebar.js +1 -5
  108. package/build/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  109. package/build/components/sidebar-edit-mode/global-styles-sidebar.js +62 -10
  110. package/build/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  111. package/build/components/sidebar-edit-mode/page-panels/index.js +1 -1
  112. package/build/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  113. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
  114. package/build/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  115. package/build/components/sidebar-edit-mode/template-panel/index.js +4 -13
  116. package/build/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  117. package/build/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  118. package/build/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  119. package/build/components/sidebar-navigation-screen-global-styles/index.js +5 -2
  120. package/build/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  121. package/build/components/sidebar-navigation-screen-page/index.js +4 -1
  122. package/build/components/sidebar-navigation-screen-page/index.js.map +1 -1
  123. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js +69 -0
  124. package/build/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
  125. package/build/components/style-book/index.js +38 -8
  126. package/build/components/style-book/index.js.map +1 -1
  127. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
  128. package/build/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  129. package/build/hooks/commands/use-edit-mode-commands.js +11 -6
  130. package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
  131. package/build/index.js +12 -7
  132. package/build/index.js.map +1 -1
  133. package/build/store/actions.js +39 -44
  134. package/build/store/actions.js.map +1 -1
  135. package/build/store/private-actions.js +6 -2
  136. package/build/store/private-actions.js.map +1 -1
  137. package/build/store/reducer.js +0 -46
  138. package/build/store/reducer.js.map +1 -1
  139. package/build/store/selectors.js +32 -41
  140. package/build/store/selectors.js.map +1 -1
  141. package/build/utils/get-is-list-page.js +1 -1
  142. package/build/utils/get-is-list-page.js.map +1 -1
  143. package/build-module/components/block-editor/back-button.js +4 -3
  144. package/build-module/components/block-editor/back-button.js.map +1 -1
  145. package/build-module/components/block-editor/resizable-editor.js +2 -2
  146. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  147. package/build-module/components/block-editor/use-post-link-props.js +20 -0
  148. package/build-module/components/block-editor/use-post-link-props.js.map +1 -0
  149. package/build-module/components/block-editor/use-site-editor-settings.js +8 -25
  150. package/build-module/components/block-editor/use-site-editor-settings.js.map +1 -1
  151. package/build-module/components/create-template-part-modal/index.js +14 -7
  152. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  153. package/build-module/components/editor/index.js +16 -17
  154. package/build-module/components/editor/index.js.map +1 -1
  155. package/build-module/components/editor-canvas-container/index.js +9 -7
  156. package/build-module/components/editor-canvas-container/index.js.map +1 -1
  157. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js +5 -2
  158. package/build-module/components/global-styles/font-library-modal/collection-font-variant.js.map +1 -1
  159. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  160. package/build-module/components/global-styles/font-library-modal/confirm-delete-dialog.js.map +1 -1
  161. package/build-module/components/global-styles/font-library-modal/context.js +7 -7
  162. package/build-module/components/global-styles/font-library-modal/context.js.map +1 -1
  163. package/build-module/components/global-styles/font-library-modal/font-collection.js +8 -4
  164. package/build-module/components/global-styles/font-library-modal/font-collection.js.map +1 -1
  165. package/build-module/components/global-styles/font-library-modal/index.js +39 -22
  166. package/build-module/components/global-styles/font-library-modal/index.js.map +1 -1
  167. package/build-module/components/global-styles/font-library-modal/installed-fonts.js +2 -2
  168. package/build-module/components/global-styles/font-library-modal/installed-fonts.js.map +1 -1
  169. package/build-module/components/global-styles/font-library-modal/library-font-variant.js +5 -2
  170. package/build-module/components/global-styles/font-library-modal/library-font-variant.js.map +1 -1
  171. package/build-module/components/global-styles/font-library-modal/local-fonts.js +27 -11
  172. package/build-module/components/global-styles/font-library-modal/local-fonts.js.map +1 -1
  173. package/build-module/components/global-styles/font-library-modal/resolvers.js +5 -5
  174. package/build-module/components/global-styles/font-library-modal/resolvers.js.map +1 -1
  175. package/build-module/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +4 -4
  176. package/build-module/components/global-styles/font-library-modal/tab-panel-layout.js.map +1 -0
  177. package/build-module/components/global-styles/font-library-modal/utils/index.js +34 -36
  178. package/build-module/components/global-styles/font-library-modal/utils/index.js.map +1 -1
  179. package/build-module/components/global-styles/preview.js +45 -3
  180. package/build-module/components/global-styles/preview.js.map +1 -1
  181. package/build-module/components/global-styles/screen-color-palette.js +17 -13
  182. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  183. package/build-module/components/global-styles/screen-revisions/index.js +53 -53
  184. package/build-module/components/global-styles/screen-revisions/index.js.map +1 -1
  185. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js +27 -36
  186. package/build-module/components/global-styles/screen-revisions/revisions-buttons.js.map +1 -1
  187. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js +40 -22
  188. package/build-module/components/global-styles/screen-revisions/use-global-styles-revisions.js.map +1 -1
  189. package/build-module/components/global-styles/ui.js +15 -64
  190. package/build-module/components/global-styles/ui.js.map +1 -1
  191. package/build-module/components/header-edit-mode/document-tools/index.js +13 -110
  192. package/build-module/components/header-edit-mode/document-tools/index.js.map +1 -1
  193. package/build-module/components/header-edit-mode/index.js +7 -11
  194. package/build-module/components/header-edit-mode/index.js.map +1 -1
  195. package/build-module/components/header-edit-mode/mode-switcher/index.js +0 -2
  196. package/build-module/components/header-edit-mode/mode-switcher/index.js.map +1 -1
  197. package/build-module/components/header-edit-mode/more-menu/index.js +10 -7
  198. package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
  199. package/build-module/components/keyboard-shortcuts/edit-mode.js +0 -23
  200. package/build-module/components/keyboard-shortcuts/edit-mode.js.map +1 -1
  201. package/build-module/components/keyboard-shortcuts/register.js +0 -36
  202. package/build-module/components/keyboard-shortcuts/register.js.map +1 -1
  203. package/build-module/components/layout/index.js +6 -13
  204. package/build-module/components/layout/index.js.map +1 -1
  205. package/build-module/components/page-main/index.js +4 -4
  206. package/build-module/components/page-main/index.js.map +1 -1
  207. package/build-module/components/page-pages/index.js +83 -36
  208. package/build-module/components/page-pages/index.js.map +1 -1
  209. package/build-module/components/page-patterns/dataviews-pattern-actions.js +292 -0
  210. package/build-module/components/page-patterns/dataviews-pattern-actions.js.map +1 -0
  211. package/build-module/components/page-patterns/dataviews-patterns.js +299 -0
  212. package/build-module/components/page-patterns/dataviews-patterns.js.map +1 -0
  213. package/build-module/components/page-patterns/duplicate-menu-item.js +1 -1
  214. package/build-module/components/page-patterns/duplicate-menu-item.js.map +1 -1
  215. package/build-module/components/page-patterns/grid-item.js +4 -3
  216. package/build-module/components/page-patterns/grid-item.js.map +1 -1
  217. package/build-module/components/page-patterns/patterns-list.js +2 -1
  218. package/build-module/components/page-patterns/patterns-list.js.map +1 -1
  219. package/build-module/components/page-patterns/use-patterns.js +23 -13
  220. package/build-module/components/page-patterns/use-patterns.js.map +1 -1
  221. package/build-module/components/page-templates/index.js +314 -38
  222. package/build-module/components/page-templates/index.js.map +1 -1
  223. package/build-module/components/{page-patterns/pagination.js → pagination/index.js} +24 -12
  224. package/build-module/components/pagination/index.js.map +1 -0
  225. package/build-module/components/{page-pages/side-editor.js → post-preview/index.js} +7 -3
  226. package/build-module/components/post-preview/index.js.map +1 -0
  227. package/build-module/components/preferences-modal/enable-feature.js +3 -2
  228. package/build-module/components/preferences-modal/enable-feature.js.map +1 -1
  229. package/build-module/components/preferences-modal/enable-panel-option.js +26 -0
  230. package/build-module/components/preferences-modal/enable-panel-option.js.map +1 -0
  231. package/build-module/components/preferences-modal/index.js +57 -9
  232. package/build-module/components/preferences-modal/index.js.map +1 -1
  233. package/build-module/components/revisions/index.js +4 -8
  234. package/build-module/components/revisions/index.js.map +1 -1
  235. package/build-module/components/routes/link.js +5 -2
  236. package/build-module/components/routes/link.js.map +1 -1
  237. package/build-module/components/save-button/index.js +6 -3
  238. package/build-module/components/save-button/index.js.map +1 -1
  239. package/build-module/components/sidebar/index.js +3 -11
  240. package/build-module/components/sidebar/index.js.map +1 -1
  241. package/build-module/components/sidebar-dataviews/add-new-view.js +1 -1
  242. package/build-module/components/sidebar-dataviews/add-new-view.js.map +1 -1
  243. package/build-module/components/sidebar-dataviews/default-views.js +17 -5
  244. package/build-module/components/sidebar-dataviews/default-views.js.map +1 -1
  245. package/build-module/components/sidebar-dataviews/index.js +2 -2
  246. package/build-module/components/sidebar-dataviews/index.js.map +1 -1
  247. package/build-module/components/sidebar-edit-mode/default-sidebar.js +1 -5
  248. package/build-module/components/sidebar-edit-mode/default-sidebar.js.map +1 -1
  249. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js +64 -12
  250. package/build-module/components/sidebar-edit-mode/global-styles-sidebar.js.map +1 -1
  251. package/build-module/components/sidebar-edit-mode/page-panels/index.js +2 -2
  252. package/build-module/components/sidebar-edit-mode/page-panels/index.js.map +1 -1
  253. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -4
  254. package/build-module/components/sidebar-edit-mode/plugin-sidebar/index.js.map +1 -1
  255. package/build-module/components/sidebar-edit-mode/template-panel/index.js +6 -15
  256. package/build-module/components/sidebar-edit-mode/template-panel/index.js.map +1 -1
  257. package/build-module/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  258. package/build-module/components/sidebar-navigation-screen-details-footer/index.js.map +1 -1
  259. package/build-module/components/sidebar-navigation-screen-global-styles/index.js +5 -2
  260. package/build-module/components/sidebar-navigation-screen-global-styles/index.js.map +1 -1
  261. package/build-module/components/sidebar-navigation-screen-page/index.js +4 -1
  262. package/build-module/components/sidebar-navigation-screen-page/index.js.map +1 -1
  263. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js +61 -0
  264. package/build-module/components/sidebar-navigation-screen-pages-dataviews/index.js.map +1 -0
  265. package/build-module/components/style-book/index.js +40 -10
  266. package/build-module/components/style-book/index.js.map +1 -1
  267. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js +1 -1
  268. package/build-module/components/sync-state-with-url/use-init-edited-entity-from-url.js.map +1 -1
  269. package/build-module/hooks/commands/use-edit-mode-commands.js +11 -6
  270. package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
  271. package/build-module/index.js +12 -7
  272. package/build-module/index.js.map +1 -1
  273. package/build-module/store/actions.js +36 -41
  274. package/build-module/store/actions.js.map +1 -1
  275. package/build-module/store/private-actions.js +6 -2
  276. package/build-module/store/private-actions.js.map +1 -1
  277. package/build-module/store/reducer.js +0 -44
  278. package/build-module/store/reducer.js.map +1 -1
  279. package/build-module/store/selectors.js +30 -38
  280. package/build-module/store/selectors.js.map +1 -1
  281. package/build-module/utils/get-is-list-page.js +1 -1
  282. package/build-module/utils/get-is-list-page.js.map +1 -1
  283. package/build-style/style-rtl.css +357 -268
  284. package/build-style/style.css +357 -268
  285. package/package.json +42 -42
  286. package/src/components/add-new-template/style.scss +2 -1
  287. package/src/components/block-editor/back-button.js +4 -2
  288. package/src/components/block-editor/resizable-editor.js +1 -1
  289. package/src/components/block-editor/style.scss +1 -2
  290. package/src/components/block-editor/use-post-link-props.js +20 -0
  291. package/src/components/block-editor/use-site-editor-settings.js +10 -41
  292. package/src/components/code-editor/style.scss +0 -4
  293. package/src/components/create-template-part-modal/index.js +83 -82
  294. package/src/components/editor/index.js +24 -31
  295. package/src/components/editor-canvas-container/index.js +8 -6
  296. package/src/components/global-styles/font-library-modal/collection-font-variant.js +7 -2
  297. package/src/components/global-styles/font-library-modal/confirm-delete-dialog.js +3 -3
  298. package/src/components/global-styles/font-library-modal/context.js +7 -7
  299. package/src/components/global-styles/font-library-modal/font-collection.js +10 -5
  300. package/src/components/global-styles/font-library-modal/index.js +44 -24
  301. package/src/components/global-styles/font-library-modal/installed-fonts.js +3 -3
  302. package/src/components/global-styles/font-library-modal/library-font-variant.js +7 -2
  303. package/src/components/global-styles/font-library-modal/local-fonts.js +53 -26
  304. package/src/components/global-styles/font-library-modal/resolvers.js +5 -5
  305. package/src/components/global-styles/font-library-modal/style.scss +5 -2
  306. package/src/components/global-styles/font-library-modal/{tab-layout.js → tab-panel-layout.js} +9 -3
  307. package/src/components/global-styles/font-library-modal/utils/index.js +21 -23
  308. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamily.spec.js +58 -0
  309. package/src/components/global-styles/preview.js +55 -3
  310. package/src/components/global-styles/screen-color-palette.js +16 -26
  311. package/src/components/global-styles/screen-revisions/index.js +91 -92
  312. package/src/components/global-styles/screen-revisions/revisions-buttons.js +37 -38
  313. package/src/components/global-styles/screen-revisions/style.scss +77 -20
  314. package/src/components/global-styles/screen-revisions/test/use-global-styles-revisions.js +67 -0
  315. package/src/components/global-styles/screen-revisions/use-global-styles-revisions.js +73 -46
  316. package/src/components/global-styles/ui.js +13 -74
  317. package/src/components/header-edit-mode/document-tools/index.js +33 -165
  318. package/src/components/header-edit-mode/index.js +6 -17
  319. package/src/components/header-edit-mode/mode-switcher/index.js +0 -4
  320. package/src/components/header-edit-mode/more-menu/index.js +9 -7
  321. package/src/components/header-edit-mode/style.scss +0 -47
  322. package/src/components/keyboard-shortcuts/edit-mode.js +1 -26
  323. package/src/components/keyboard-shortcuts/register.js +0 -43
  324. package/src/components/layout/index.js +8 -27
  325. package/src/components/layout/style.scss +10 -3
  326. package/src/components/list/style.scss +0 -5
  327. package/src/components/page/style.scss +1 -1
  328. package/src/components/page-main/index.js +8 -8
  329. package/src/components/page-pages/index.js +112 -41
  330. package/src/components/page-pages/style.scss +3 -2
  331. package/src/components/page-patterns/dataviews-pattern-actions.js +329 -0
  332. package/src/components/page-patterns/dataviews-patterns.js +380 -0
  333. package/src/components/page-patterns/duplicate-menu-item.js +1 -1
  334. package/src/components/page-patterns/grid-item.js +3 -2
  335. package/src/components/page-patterns/patterns-list.js +2 -1
  336. package/src/components/page-patterns/style.scss +89 -26
  337. package/src/components/page-patterns/use-patterns.js +24 -15
  338. package/src/components/page-templates/index.js +399 -64
  339. package/src/components/{page-patterns/pagination.js → pagination/index.js} +21 -10
  340. package/src/components/pagination/style.scss +5 -0
  341. package/src/components/post-preview/index.js +16 -0
  342. package/src/components/preferences-modal/enable-feature.js +9 -5
  343. package/src/components/preferences-modal/enable-panel-option.js +23 -0
  344. package/src/components/preferences-modal/index.js +107 -22
  345. package/src/components/revisions/index.js +8 -15
  346. package/src/components/routes/link.js +11 -3
  347. package/src/components/save-button/index.js +16 -3
  348. package/src/components/sidebar/index.js +6 -13
  349. package/src/components/sidebar-dataviews/add-new-view.js +1 -1
  350. package/src/components/sidebar-dataviews/default-views.js +23 -6
  351. package/src/components/sidebar-dataviews/index.js +2 -2
  352. package/src/components/sidebar-edit-mode/default-sidebar.js +0 -12
  353. package/src/components/sidebar-edit-mode/global-styles-sidebar.js +85 -14
  354. package/src/components/sidebar-edit-mode/page-panels/index.js +15 -1
  355. package/src/components/sidebar-edit-mode/plugin-sidebar/index.js +0 -12
  356. package/src/components/sidebar-edit-mode/style.scss +0 -10
  357. package/src/components/sidebar-edit-mode/template-panel/index.js +44 -40
  358. package/src/components/sidebar-edit-mode/template-panel/style.scss +0 -4
  359. package/src/components/sidebar-navigation-screen-details-footer/index.js +1 -1
  360. package/src/components/sidebar-navigation-screen-global-styles/index.js +3 -2
  361. package/src/components/sidebar-navigation-screen-page/index.js +2 -1
  362. package/src/components/sidebar-navigation-screen-pages-dataviews/index.js +77 -0
  363. package/src/components/site-hub/style.scss +5 -2
  364. package/src/components/style-book/index.js +65 -21
  365. package/src/components/style-book/style.scss +3 -3
  366. package/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +4 -1
  367. package/src/hooks/commands/use-edit-mode-commands.js +8 -12
  368. package/src/index.js +11 -5
  369. package/src/store/actions.js +35 -45
  370. package/src/store/private-actions.js +7 -3
  371. package/src/store/reducer.js +0 -44
  372. package/src/store/selectors.js +32 -38
  373. package/src/store/test/actions.js +11 -39
  374. package/src/store/test/reducer.js +1 -82
  375. package/src/store/test/selectors.js +0 -24
  376. package/src/style.scss +1 -1
  377. package/src/utils/get-is-list-page.js +2 -3
  378. package/build/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
  379. package/build/components/global-styles/screen-revisions/get-revision-changes.js +0 -146
  380. package/build/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
  381. package/build/components/header-edit-mode/undo-redo/redo.js +0 -41
  382. package/build/components/header-edit-mode/undo-redo/redo.js.map +0 -1
  383. package/build/components/header-edit-mode/undo-redo/undo.js +0 -40
  384. package/build/components/header-edit-mode/undo-redo/undo.js.map +0 -1
  385. package/build/components/page-pages/side-editor.js.map +0 -1
  386. package/build/components/page-patterns/pagination.js.map +0 -1
  387. package/build/components/page-templates/dataviews-templates.js +0 -317
  388. package/build/components/page-templates/dataviews-templates.js.map +0 -1
  389. package/build/components/secondary-sidebar/inserter-sidebar.js +0 -60
  390. package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  391. package/build/components/secondary-sidebar/list-view-sidebar.js +0 -109
  392. package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  393. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -35
  394. package/build/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
  395. package/build/components/sidebar-edit-mode/template-panel/last-revision.js +0 -73
  396. package/build/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
  397. package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -219
  398. package/build/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
  399. package/build-module/components/global-styles/font-library-modal/tab-layout.js.map +0 -1
  400. package/build-module/components/global-styles/screen-revisions/get-revision-changes.js +0 -139
  401. package/build-module/components/global-styles/screen-revisions/get-revision-changes.js.map +0 -1
  402. package/build-module/components/header-edit-mode/undo-redo/redo.js +0 -33
  403. package/build-module/components/header-edit-mode/undo-redo/redo.js.map +0 -1
  404. package/build-module/components/header-edit-mode/undo-redo/undo.js +0 -32
  405. package/build-module/components/header-edit-mode/undo-redo/undo.js.map +0 -1
  406. package/build-module/components/page-pages/side-editor.js.map +0 -1
  407. package/build-module/components/page-patterns/pagination.js.map +0 -1
  408. package/build-module/components/page-templates/dataviews-templates.js +0 -309
  409. package/build-module/components/page-templates/dataviews-templates.js.map +0 -1
  410. package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -53
  411. package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
  412. package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -102
  413. package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
  414. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -27
  415. package/build-module/components/sidebar-edit-mode/sidebar-fixed-bottom.js.map +0 -1
  416. package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js +0 -65
  417. package/build-module/components/sidebar-edit-mode/template-panel/last-revision.js.map +0 -1
  418. package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -209
  419. package/build-module/components/sidebar-edit-mode/template-panel/pattern-categories.js.map +0 -1
  420. package/src/components/global-styles/font-library-modal/utils/test/makeFormDataFromFontFamilies.spec.js +0 -62
  421. package/src/components/global-styles/font-library-modal/utils/test/wpKebabCase.spec.js +0 -28
  422. package/src/components/global-styles/screen-revisions/get-revision-changes.js +0 -171
  423. package/src/components/global-styles/screen-revisions/test/get-revision-changes.js +0 -191
  424. package/src/components/header-edit-mode/undo-redo/redo.js +0 -38
  425. package/src/components/header-edit-mode/undo-redo/undo.js +0 -34
  426. package/src/components/page-pages/side-editor.js +0 -14
  427. package/src/components/page-templates/dataviews-templates.js +0 -360
  428. package/src/components/secondary-sidebar/inserter-sidebar.js +0 -66
  429. package/src/components/secondary-sidebar/list-view-sidebar.js +0 -123
  430. package/src/components/secondary-sidebar/style.scss +0 -65
  431. package/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js +0 -26
  432. package/src/components/sidebar-edit-mode/template-panel/last-revision.js +0 -82
  433. package/src/components/sidebar-edit-mode/template-panel/pattern-categories.js +0 -279
@@ -1,109 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = ListViewSidebar;
7
- var _react = require("react");
8
- var _blockEditor = require("@wordpress/block-editor");
9
- var _components = require("@wordpress/components");
10
- var _compose = require("@wordpress/compose");
11
- var _data = require("@wordpress/data");
12
- var _element = require("@wordpress/element");
13
- var _i18n = require("@wordpress/i18n");
14
- var _icons = require("@wordpress/icons");
15
- var _keycodes = require("@wordpress/keycodes");
16
- var _dom = require("@wordpress/dom");
17
- var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
18
- var _store = require("../../store");
19
- var _lockUnlock = require("../../lock-unlock");
20
- /**
21
- * WordPress dependencies
22
- */
23
-
24
- /**
25
- * Internal dependencies
26
- */
27
-
28
- const {
29
- PrivateListView
30
- } = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
31
- function ListViewSidebar({
32
- listViewToggleElement
33
- }) {
34
- const {
35
- setIsListViewOpened
36
- } = (0, _data.useDispatch)(_store.store);
37
-
38
- // This hook handles focus when the sidebar first renders.
39
- const focusOnMountRef = (0, _compose.useFocusOnMount)('firstElement');
40
-
41
- // When closing the list view, focus should return to the toggle button.
42
- const closeListView = (0, _element.useCallback)(() => {
43
- setIsListViewOpened(false);
44
- listViewToggleElement?.focus();
45
- }, [listViewToggleElement, setIsListViewOpened]);
46
- const closeOnEscape = (0, _element.useCallback)(event => {
47
- if (event.keyCode === _keycodes.ESCAPE && !event.defaultPrevented) {
48
- event.preventDefault();
49
- closeListView();
50
- }
51
- }, [closeListView]);
52
-
53
- // Use internal state instead of a ref to make sure that the component
54
- // re-renders when the dropZoneElement updates.
55
- const [dropZoneElement, setDropZoneElement] = (0, _element.useState)(null);
56
-
57
- // This ref refers to the sidebar as a whole.
58
- const sidebarRef = (0, _element.useRef)();
59
- // This ref refers to the close button.
60
- const sidebarCloseButtonRef = (0, _element.useRef)();
61
- // This ref refers to the list view application area.
62
- const listViewRef = (0, _element.useRef)();
63
-
64
- /*
65
- * Callback function to handle list view or close button focus.
66
- *
67
- * @return void
68
- */
69
- function handleSidebarFocus() {
70
- // Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks.
71
- const listViewApplicationFocus = _dom.focus.tabbable.find(listViewRef.current)[0];
72
- const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : sidebarCloseButtonRef.current;
73
- listViewFocusArea.focus();
74
- }
75
- const handleToggleListViewShortcut = (0, _element.useCallback)(() => {
76
- // If the sidebar has focus, it is safe to close.
77
- if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
78
- closeListView();
79
- } else {
80
- // If the list view or close button does not have focus, focus should be moved to it.
81
- handleSidebarFocus();
82
- }
83
- }, [closeListView]);
84
-
85
- // This only fires when the sidebar is open because of the conditional rendering.
86
- // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
87
- (0, _keyboardShortcuts.useShortcut)('core/edit-site/toggle-list-view', handleToggleListViewShortcut);
88
- return (
89
- // eslint-disable-next-line jsx-a11y/no-static-element-interactions
90
- (0, _react.createElement)("div", {
91
- className: "edit-site-editor__list-view-panel",
92
- onKeyDown: closeOnEscape,
93
- ref: sidebarRef
94
- }, (0, _react.createElement)("div", {
95
- className: "edit-site-editor__list-view-panel-header"
96
- }, (0, _react.createElement)("strong", null, (0, _i18n.__)('List View')), (0, _react.createElement)(_components.Button, {
97
- icon: _icons.closeSmall,
98
- label: (0, _i18n.__)('Close'),
99
- onClick: closeListView,
100
- ref: sidebarCloseButtonRef
101
- })), (0, _react.createElement)("div", {
102
- className: "edit-site-editor__list-view-panel-content",
103
- ref: (0, _compose.useMergeRefs)([focusOnMountRef, setDropZoneElement, listViewRef])
104
- }, (0, _react.createElement)(PrivateListView, {
105
- dropZoneElement: dropZoneElement
106
- })))
107
- );
108
- }
109
- //# sourceMappingURL=list-view-sidebar.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_blockEditor","require","_components","_compose","_data","_element","_i18n","_icons","_keycodes","_dom","_keyboardShortcuts","_store","_lockUnlock","PrivateListView","unlock","blockEditorPrivateApis","ListViewSidebar","listViewToggleElement","setIsListViewOpened","useDispatch","editSiteStore","focusOnMountRef","useFocusOnMount","closeListView","useCallback","focus","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","dropZoneElement","setDropZoneElement","useState","sidebarRef","useRef","sidebarCloseButtonRef","listViewRef","handleSidebarFocus","listViewApplicationFocus","tabbable","find","current","listViewFocusArea","contains","handleToggleListViewShortcut","ownerDocument","activeElement","useShortcut","_react","createElement","className","onKeyDown","ref","__","Button","icon","closeSmall","label","onClick","useMergeRefs"],"sources":["@wordpress/edit-site/src/components/secondary-sidebar/list-view-sidebar.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { Button } from '@wordpress/components';\nimport { useFocusOnMount, useMergeRefs } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useCallback, useRef, useState } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { closeSmall } from '@wordpress/icons';\nimport { ESCAPE } from '@wordpress/keycodes';\nimport { focus } from '@wordpress/dom';\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { PrivateListView } = unlock( blockEditorPrivateApis );\n\nexport default function ListViewSidebar( { listViewToggleElement } ) {\n\tconst { setIsListViewOpened } = useDispatch( editSiteStore );\n\n\t// This hook handles focus when the sidebar first renders.\n\tconst focusOnMountRef = useFocusOnMount( 'firstElement' );\n\n\t// When closing the list view, focus should return to the toggle button.\n\tconst closeListView = useCallback( () => {\n\t\tsetIsListViewOpened( false );\n\t\tlistViewToggleElement?.focus();\n\t}, [ listViewToggleElement, setIsListViewOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseListView();\n\t\t\t}\n\t\t},\n\t\t[ closeListView ]\n\t);\n\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the dropZoneElement updates.\n\tconst [ dropZoneElement, setDropZoneElement ] = useState( null );\n\n\t// This ref refers to the sidebar as a whole.\n\tconst sidebarRef = useRef();\n\t// This ref refers to the close button.\n\tconst sidebarCloseButtonRef = useRef();\n\t// This ref refers to the list view application area.\n\tconst listViewRef = useRef();\n\n\t/*\n\t * Callback function to handle list view or close button focus.\n\t *\n\t * @return void\n\t */\n\tfunction handleSidebarFocus() {\n\t\t// Either focus the list view or the sidebar close button. Must have a fallback because the list view does not render when there are no blocks.\n\t\tconst listViewApplicationFocus = focus.tabbable.find(\n\t\t\tlistViewRef.current\n\t\t)[ 0 ];\n\t\tconst listViewFocusArea = sidebarRef.current.contains(\n\t\t\tlistViewApplicationFocus\n\t\t)\n\t\t\t? listViewApplicationFocus\n\t\t\t: sidebarCloseButtonRef.current;\n\t\tlistViewFocusArea.focus();\n\t}\n\n\tconst handleToggleListViewShortcut = useCallback( () => {\n\t\t// If the sidebar has focus, it is safe to close.\n\t\tif (\n\t\t\tsidebarRef.current.contains(\n\t\t\t\tsidebarRef.current.ownerDocument.activeElement\n\t\t\t)\n\t\t) {\n\t\t\tcloseListView();\n\t\t} else {\n\t\t\t// If the list view or close button does not have focus, focus should be moved to it.\n\t\t\thandleSidebarFocus();\n\t\t}\n\t}, [ closeListView ] );\n\n\t// This only fires when the sidebar is open because of the conditional rendering.\n\t// It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.\n\tuseShortcut(\n\t\t'core/edit-site/toggle-list-view',\n\t\thandleToggleListViewShortcut\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div\n\t\t\tclassName=\"edit-site-editor__list-view-panel\"\n\t\t\tonKeyDown={ closeOnEscape }\n\t\t\tref={ sidebarRef }\n\t\t>\n\t\t\t<div className=\"edit-site-editor__list-view-panel-header\">\n\t\t\t\t<strong>{ __( 'List View' ) }</strong>\n\t\t\t\t<Button\n\t\t\t\t\ticon={ closeSmall }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ closeListView }\n\t\t\t\t\tref={ sidebarCloseButtonRef }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName=\"edit-site-editor__list-view-panel-content\"\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tfocusOnMountRef,\n\t\t\t\t\tsetDropZoneElement,\n\t\t\t\t\tlistViewRef,\n\t\t\t\t] ) }\n\t\t\t>\n\t\t\t\t<PrivateListView dropZoneElement={ dropZoneElement } />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ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V;IAAG,GAEL,IAAAY,MAAA,CAAAC,aAAA,EAACtC,eAAe;MAACmB,eAAe,EAAGA;IAAiB,CAAE,CAClD,CACD;EAAC;AAER"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.SidebarFixedBottomSlot = void 0;
7
- exports.default = SidebarFixedBottom;
8
- var _react = require("react");
9
- var _components = require("@wordpress/components");
10
- var _lockUnlock = require("../../lock-unlock");
11
- /**
12
- * WordPress dependencies
13
- */
14
-
15
- /**
16
- * Internal dependencies
17
- */
18
-
19
- const {
20
- createPrivateSlotFill
21
- } = (0, _lockUnlock.unlock)(_components.privateApis);
22
- const SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';
23
- const {
24
- Slot: SidebarFixedBottomSlot,
25
- Fill: SidebarFixedBottomFill
26
- } = createPrivateSlotFill(SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME);
27
- exports.SidebarFixedBottomSlot = SidebarFixedBottomSlot;
28
- function SidebarFixedBottom({
29
- children
30
- }) {
31
- return (0, _react.createElement)(SidebarFixedBottomFill, null, (0, _react.createElement)("div", {
32
- className: "edit-site-sidebar-fixed-bottom-slot"
33
- }, children));
34
- }
35
- //# sourceMappingURL=sidebar-fixed-bottom.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_components","require","_lockUnlock","createPrivateSlotFill","unlock","componentsPrivateApis","SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME","Slot","SidebarFixedBottomSlot","Fill","SidebarFixedBottomFill","exports","SidebarFixedBottom","children","_react","createElement","className"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/sidebar-fixed-bottom.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\n\nconst { createPrivateSlotFill } = unlock( componentsPrivateApis );\nconst SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME = 'SidebarFixedBottom';\nconst { Slot: SidebarFixedBottomSlot, Fill: SidebarFixedBottomFill } =\n\tcreatePrivateSlotFill( SIDEBAR_FIXED_BOTTOM_SLOT_FILL_NAME );\n\nexport default function SidebarFixedBottom( { children } ) {\n\treturn (\n\t\t<SidebarFixedBottomFill>\n\t\t\t<div className=\"edit-site-sidebar-fixed-bottom-slot\">\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</SidebarFixedBottomFill>\n\t);\n}\n\nexport { SidebarFixedBottomSlot };\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AARA;AACA;AACA;;AAGA;AACA;AACA;;AAGA,MAAM;EAAEE;AAAsB,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AACjE,MAAMC,mCAAmC,GAAG,oBAAoB;AAChE,MAAM;EAAEC,IAAI,EAAEC,sBAAsB;EAAEC,IAAI,EAAEC;AAAuB,CAAC,GACnEP,qBAAqB,CAAEG,mCAAoC,CAAC;AAACK,OAAA,CAAAH,sBAAA,GAAAA,sBAAA;AAE/C,SAASI,kBAAkBA,CAAE;EAAEC;AAAS,CAAC,EAAG;EAC1D,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACL,sBAAsB,QACtB,IAAAI,MAAA,CAAAC,aAAA;IAAKC,SAAS,EAAC;EAAqC,GACjDH,QACE,CACkB,CAAC;AAE3B"}
@@ -1,73 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = LastRevision;
8
- var _react = require("react");
9
- var _components = require("@wordpress/components");
10
- var _i18n = require("@wordpress/i18n");
11
- var _icons = require("@wordpress/icons");
12
- var _url = require("@wordpress/url");
13
- var _editor = require("@wordpress/editor");
14
- var _useEditedEntityRecord = _interopRequireDefault(require("../../use-edited-entity-record"));
15
- /**
16
- * WordPress dependencies
17
- */
18
-
19
- /**
20
- * Internal dependencies
21
- */
22
-
23
- const useRevisionData = () => {
24
- var _currentTemplate$_lin, _currentTemplate$_lin2;
25
- const {
26
- record: currentTemplate
27
- } = (0, _useEditedEntityRecord.default)();
28
- const lastRevisionId = (_currentTemplate$_lin = currentTemplate?._links?.['predecessor-version']?.[0]?.id) !== null && _currentTemplate$_lin !== void 0 ? _currentTemplate$_lin : null;
29
- const revisionsCount = (_currentTemplate$_lin2 = currentTemplate?._links?.['version-history']?.[0]?.count) !== null && _currentTemplate$_lin2 !== void 0 ? _currentTemplate$_lin2 : 0;
30
- return {
31
- currentTemplate,
32
- lastRevisionId,
33
- revisionsCount
34
- };
35
- };
36
- function PostLastRevisionCheck({
37
- children
38
- }) {
39
- const {
40
- lastRevisionId,
41
- revisionsCount
42
- } = useRevisionData();
43
- if (!process.env.IS_GUTENBERG_PLUGIN) {
44
- return null;
45
- }
46
- if (!lastRevisionId || revisionsCount < 2) {
47
- return null;
48
- }
49
- return (0, _react.createElement)(_editor.PostTypeSupportCheck, {
50
- supportKeys: "revisions"
51
- }, children);
52
- }
53
- const PostLastRevision = () => {
54
- const {
55
- lastRevisionId,
56
- revisionsCount
57
- } = useRevisionData();
58
- return (0, _react.createElement)(PostLastRevisionCheck, null, (0, _react.createElement)(_components.PanelRow, {
59
- header: (0, _i18n.__)('Editing history'),
60
- className: "edit-site-template-revisions"
61
- }, (0, _react.createElement)(_components.Button, {
62
- href: (0, _url.addQueryArgs)('revision.php', {
63
- revision: lastRevisionId
64
- }),
65
- className: "edit-site-template-last-revision__title",
66
- icon: _icons.backup
67
- }, (0, _i18n.sprintf)( /* translators: %d: number of revisions */
68
- (0, _i18n._n)('%d Revision', '%d Revisions', revisionsCount), revisionsCount))));
69
- };
70
- function LastRevision() {
71
- return (0, _react.createElement)(PostLastRevisionCheck, null, (0, _react.createElement)(PostLastRevision, null));
72
- }
73
- //# sourceMappingURL=last-revision.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_components","require","_i18n","_icons","_url","_editor","_useEditedEntityRecord","_interopRequireDefault","useRevisionData","_currentTemplate$_lin","_currentTemplate$_lin2","record","currentTemplate","useEditedEntityRecord","lastRevisionId","_links","id","revisionsCount","count","PostLastRevisionCheck","children","process","env","IS_GUTENBERG_PLUGIN","_react","createElement","PostTypeSupportCheck","supportKeys","PostLastRevision","PanelRow","header","__","className","Button","href","addQueryArgs","revision","icon","backup","sprintf","_n","LastRevision"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/last-revision.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button, PanelRow } from '@wordpress/components';\nimport { sprintf, _n, __ } from '@wordpress/i18n';\nimport { backup } from '@wordpress/icons';\nimport { addQueryArgs } from '@wordpress/url';\nimport { PostTypeSupportCheck } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport useEditedEntityRecord from '../../use-edited-entity-record';\n\nconst useRevisionData = () => {\n\tconst { record: currentTemplate } = useEditedEntityRecord();\n\n\tconst lastRevisionId =\n\t\tcurrentTemplate?._links?.[ 'predecessor-version' ]?.[ 0 ]?.id ?? null;\n\n\tconst revisionsCount =\n\t\tcurrentTemplate?._links?.[ 'version-history' ]?.[ 0 ]?.count ?? 0;\n\n\treturn {\n\t\tcurrentTemplate,\n\t\tlastRevisionId,\n\t\trevisionsCount,\n\t};\n};\n\nfunction PostLastRevisionCheck( { children } ) {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\tif ( ! process.env.IS_GUTENBERG_PLUGIN ) {\n\t\treturn null;\n\t}\n\n\tif ( ! lastRevisionId || revisionsCount < 2 ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PostTypeSupportCheck supportKeys=\"revisions\">\n\t\t\t{ children }\n\t\t</PostTypeSupportCheck>\n\t);\n}\n\nconst PostLastRevision = () => {\n\tconst { lastRevisionId, revisionsCount } = useRevisionData();\n\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PanelRow\n\t\t\t\theader={ __( 'Editing history' ) }\n\t\t\t\tclassName=\"edit-site-template-revisions\"\n\t\t\t>\n\t\t\t\t<Button\n\t\t\t\t\thref={ addQueryArgs( 'revision.php', {\n\t\t\t\t\t\trevision: lastRevisionId,\n\t\t\t\t\t} ) }\n\t\t\t\t\tclassName=\"edit-site-template-last-revision__title\"\n\t\t\t\t\ticon={ backup }\n\t\t\t\t>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %d: number of revisions */\n\t\t\t\t\t\t_n( '%d Revision', '%d Revisions', revisionsCount ),\n\t\t\t\t\t\trevisionsCount\n\t\t\t\t\t) }\n\t\t\t\t</Button>\n\t\t\t</PanelRow>\n\t\t</PostLastRevisionCheck>\n\t);\n};\n\nexport default function LastRevision() {\n\treturn (\n\t\t<PostLastRevisionCheck>\n\t\t\t<PostLastRevision />\n\t\t</PostLastRevisionCheck>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,IAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,sBAAA,GAAAC,sBAAA,CAAAN,OAAA;AAZA;AACA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMO,eAAe,GAAGA,CAAA,KAAM;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EAC7B,MAAM;IAAEC,MAAM,EAAEC;EAAgB,CAAC,GAAG,IAAAC,8BAAqB,EAAC,CAAC;EAE3D,MAAMC,cAAc,IAAAL,qBAAA,GACnBG,eAAe,EAAEG,MAAM,GAAI,qBAAqB,CAAE,GAAI,CAAC,CAAE,EAAEC,EAAE,cAAAP,qBAAA,cAAAA,qBAAA,GAAI,IAAI;EAEtE,MAAMQ,cAAc,IAAAP,sBAAA,GAC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AEc,SAASwB,YAAYA,CAAA,EAAG;EACtC,OACC,IAAAjB,MAAA,CAAAC,aAAA,EAACN,qBAAqB,QACrB,IAAAK,MAAA,CAAAC,aAAA,EAACG,gBAAgB,MAAE,CACG,CAAC;AAE1B"}
@@ -1,219 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = PatternCategories;
7
- exports.unescapeTerm = exports.unescapeString = void 0;
8
- var _react = require("react");
9
- var _i18n = require("@wordpress/i18n");
10
- var _element = require("@wordpress/element");
11
- var _components = require("@wordpress/components");
12
- var _data = require("@wordpress/data");
13
- var _coreData = require("@wordpress/core-data");
14
- var _compose = require("@wordpress/compose");
15
- var _notices = require("@wordpress/notices");
16
- var _htmlEntities = require("@wordpress/html-entities");
17
- var _constants = require("../../../utils/constants");
18
- /**
19
- * WordPress dependencies
20
- */
21
-
22
- /**
23
- * Internal dependencies
24
- */
25
-
26
- const unescapeString = arg => {
27
- return (0, _htmlEntities.decodeEntities)(arg);
28
- };
29
-
30
- /**
31
- * Returns a term object with name unescaped.
32
- *
33
- * @param {Object} term The term object to unescape.
34
- *
35
- * @return {Object} Term object with name property unescaped.
36
- */
37
- exports.unescapeString = unescapeString;
38
- const unescapeTerm = term => {
39
- return {
40
- ...term,
41
- name: unescapeString(term.name)
42
- };
43
- };
44
-
45
- /**
46
- * Shared reference to an empty array for cases where it is important to avoid
47
- * returning a new array reference on every invocation.
48
- *
49
- * @type {Array<any>}
50
- */
51
- exports.unescapeTerm = unescapeTerm;
52
- const EMPTY_ARRAY = [];
53
-
54
- /**
55
- * Module constants
56
- */
57
- const MAX_TERMS_SUGGESTIONS = 20;
58
- const DEFAULT_QUERY = {
59
- per_page: MAX_TERMS_SUGGESTIONS,
60
- _fields: 'id,name',
61
- context: 'view'
62
- };
63
- const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
64
- const termNamesToIds = (names, terms) => {
65
- return names.map(termName => terms.find(term => isSameTermName(term.name, termName)).id);
66
- };
67
- function PatternCategories({
68
- post
69
- }) {
70
- var _taxonomy$labels$sing;
71
- const slug = 'wp_pattern_category';
72
- const [values, setValues] = (0, _element.useState)([]);
73
- const [search, setSearch] = (0, _element.useState)('');
74
- const debouncedSearch = (0, _compose.useDebounce)(setSearch, 500);
75
- const {
76
- terms,
77
- taxonomy,
78
- hasAssignAction,
79
- hasCreateAction,
80
- hasResolvedTerms
81
- } = (0, _data.useSelect)(select => {
82
- var _post$_links, _post$_links2;
83
- const {
84
- getEntityRecords,
85
- getTaxonomy,
86
- hasFinishedResolution
87
- } = select(_coreData.store);
88
- const _taxonomy = getTaxonomy(slug);
89
- const _termIds = post?.wp_pattern_category?.length > 0 ? post?.wp_pattern_category : EMPTY_ARRAY;
90
- const query = {
91
- ...DEFAULT_QUERY,
92
- include: _termIds?.join(','),
93
- per_page: -1
94
- };
95
- return {
96
- hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
97
- hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
98
- taxonomy: _taxonomy,
99
- termIds: _termIds,
100
- terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
101
- hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
102
- };
103
- }, [slug, post]);
104
- const {
105
- searchResults
106
- } = (0, _data.useSelect)(select => {
107
- const {
108
- getEntityRecords
109
- } = select(_coreData.store);
110
- return {
111
- searchResults: !!search ? getEntityRecords('taxonomy', slug, {
112
- ...DEFAULT_QUERY,
113
- search
114
- }) : EMPTY_ARRAY
115
- };
116
- }, [search, slug]);
117
-
118
- // Update terms state only after the selectors are resolved.
119
- // We're using this to avoid terms temporarily disappearing on slow networks
120
- // while core data makes REST API requests.
121
- (0, _element.useEffect)(() => {
122
- if (hasResolvedTerms) {
123
- const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
124
- setValues(newValues);
125
- }
126
- }, [terms, hasResolvedTerms]);
127
- const suggestions = (0, _element.useMemo)(() => {
128
- return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
129
- }, [searchResults]);
130
- const {
131
- saveEntityRecord,
132
- editEntityRecord,
133
- invalidateResolution
134
- } = (0, _data.useDispatch)(_coreData.store);
135
- const {
136
- createErrorNotice
137
- } = (0, _data.useDispatch)(_notices.store);
138
- if (!hasAssignAction) {
139
- return null;
140
- }
141
- async function findOrCreateTerm(term) {
142
- try {
143
- const newTerm = await saveEntityRecord('taxonomy', slug, term, {
144
- throwOnError: true
145
- });
146
- invalidateResolution('getUserPatternCategories');
147
- return unescapeTerm(newTerm);
148
- } catch (error) {
149
- if (error.code !== 'term_exists') {
150
- throw error;
151
- }
152
- return {
153
- id: error.data.term_id,
154
- name: term.name
155
- };
156
- }
157
- }
158
- function onUpdateTerms(newTermIds) {
159
- editEntityRecord('postType', _constants.PATTERN_TYPES.user, post.id, {
160
- wp_pattern_category: newTermIds
161
- });
162
- }
163
- function onChange(termNames) {
164
- const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
165
- const uniqueTerms = termNames.reduce((acc, name) => {
166
- if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
167
- acc.push(name);
168
- }
169
- return acc;
170
- }, []);
171
- const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
172
-
173
- // Optimistically update term values.
174
- // The selector will always re-fetch terms later.
175
- setValues(uniqueTerms);
176
- if (newTermNames.length === 0) {
177
- return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
178
- }
179
- if (!hasCreateAction) {
180
- return;
181
- }
182
- Promise.all(newTermNames.map(termName => findOrCreateTerm({
183
- name: termName
184
- }))).then(newTerms => {
185
- const newAvailableTerms = availableTerms.concat(newTerms);
186
- return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
187
- }).catch(error => {
188
- createErrorNotice(error.message, {
189
- type: 'snackbar'
190
- });
191
- });
192
- }
193
- const singularName = (_taxonomy$labels$sing = taxonomy?.labels?.singular_name) !== null && _taxonomy$labels$sing !== void 0 ? _taxonomy$labels$sing : slug === 'post_tag' ? (0, _i18n.__)('Tag') : (0, _i18n.__)('Term');
194
- const termAddedLabel = (0, _i18n.sprintf)( /* translators: %s: term name. */
195
- (0, _i18n._x)('%s added', 'term'), singularName);
196
- const termRemovedLabel = (0, _i18n.sprintf)( /* translators: %s: term name. */
197
- (0, _i18n._x)('%s removed', 'term'), singularName);
198
- const removeTermLabel = (0, _i18n.sprintf)( /* translators: %s: term name. */
199
- (0, _i18n._x)('Remove %s', 'term'), singularName);
200
- return (0, _react.createElement)(_components.PanelRow, {
201
- initialOpen: true,
202
- title: (0, _i18n.__)('Categories')
203
- }, (0, _react.createElement)(_components.FlexBlock, null, (0, _react.createElement)(_components.FormTokenField, {
204
- __next40pxDefaultSize: true,
205
- value: values,
206
- suggestions: suggestions,
207
- onChange: onChange,
208
- onInputChange: debouncedSearch,
209
- maxSuggestions: MAX_TERMS_SUGGESTIONS,
210
- label: (0, _i18n.__)('Pattern categories'),
211
- messages: {
212
- added: termAddedLabel,
213
- removed: termRemovedLabel,
214
- remove: removeTermLabel
215
- },
216
- tokenizeOnBlur: true
217
- })));
218
- }
219
- //# sourceMappingURL=pattern-categories.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_i18n","require","_element","_components","_data","_coreData","_compose","_notices","_htmlEntities","_constants","unescapeString","arg","decodeEntities","exports","unescapeTerm","term","name","EMPTY_ARRAY","MAX_TERMS_SUGGESTIONS","DEFAULT_QUERY","per_page","_fields","context","isSameTermName","termA","termB","toLowerCase","termNamesToIds","names","terms","map","termName","find","id","PatternCategories","post","_taxonomy$labels$sing","slug","values","setValues","useState","search","setSearch","debouncedSearch","useDebounce","taxonomy","hasAssignAction","hasCreateAction","hasResolvedTerms","useSelect","select","_post$_links","_post$_links2","getEntityRecords","getTaxonomy","hasFinishedResolution","coreStore","_taxonomy","_termIds","wp_pattern_category","length","query","include","join","_links","rest_base","termIds","searchResults","useEffect","newValues","suggestions","useMemo","saveEntityRecord","editEntityRecord","invalidateResolution","useDispatch","createErrorNotice","noticesStore","findOrCreateTerm","newTerm","throwOnError","error","code","data","term_id","onUpdateTerms","newTermIds","PATTERN_TYPES","user","onChange","termNames","availableTerms","uniqueTerms","reduce","acc","some","n","push","newTermNames","filter","Promise","all","then","newTerms","newAvailableTerms","concat","catch","message","type","singularName","labels","singular_name","__","termAddedLabel","sprintf","_x","termRemovedLabel","removeTermLabel","_react","createElement","PanelRow","initialOpen","title","FlexBlock","FormTokenField","__next40pxDefaultSize","value","onInputChange","maxSuggestions","label","messages","added","removed","remove","tokenizeOnBlur"],"sources":["@wordpress/edit-site/src/components/sidebar-edit-mode/template-panel/pattern-categories.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\nimport { FormTokenField, FlexBlock, PanelRow } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDebounce } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport { PATTERN_TYPES } from '../../../utils/constants';\n\nexport const unescapeString = ( arg ) => {\n\treturn decodeEntities( arg );\n};\n\n/**\n * Returns a term object with name unescaped.\n *\n * @param {Object} term The term object to unescape.\n *\n * @return {Object} Term object with name property unescaped.\n */\nexport const unescapeTerm = ( term ) => {\n\treturn {\n\t\t...term,\n\t\tname: unescapeString( term.name ),\n\t};\n};\n\n/**\n * Shared reference to an empty array for cases where it is important to avoid\n * returning a new array reference on every invocation.\n *\n * @type {Array<any>}\n */\nconst EMPTY_ARRAY = [];\n\n/**\n * Module constants\n */\nconst MAX_TERMS_SUGGESTIONS = 20;\nconst DEFAULT_QUERY = {\n\tper_page: MAX_TERMS_SUGGESTIONS,\n\t_fields: 'id,name',\n\tcontext: 'view',\n};\n\nconst isSameTermName = ( termA, termB ) =>\n\tunescapeString( termA ).toLowerCase() ===\n\tunescapeString( termB ).toLowerCase();\n\nconst termNamesToIds = ( names, terms ) => {\n\treturn names.map(\n\t\t( termName ) =>\n\t\t\tterms.find( ( term ) => isSameTermName( term.name, termName ) ).id\n\t);\n};\n\nexport default function PatternCategories( { post } ) {\n\tconst slug = 'wp_pattern_category';\n\tconst [ values, setValues ] = useState( [] );\n\tconst [ search, setSearch ] = useState( '' );\n\tconst debouncedSearch = useDebounce( setSearch, 500 );\n\n\tconst {\n\t\tterms,\n\t\ttaxonomy,\n\t\thasAssignAction,\n\t\thasCreateAction,\n\t\thasResolvedTerms,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomy, hasFinishedResolution } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst _taxonomy = getTaxonomy( slug );\n\t\t\tconst _termIds =\n\t\t\t\tpost?.wp_pattern_category?.length > 0\n\t\t\t\t\t? post?.wp_pattern_category\n\t\t\t\t\t: EMPTY_ARRAY;\n\t\t\tconst query = {\n\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\tinclude: _termIds?.join( ',' ),\n\t\t\t\tper_page: -1,\n\t\t\t};\n\n\t\t\treturn {\n\t\t\t\thasCreateAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-create-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\thasAssignAction: _taxonomy\n\t\t\t\t\t? post._links?.[\n\t\t\t\t\t\t\t'wp:action-assign-' + _taxonomy.rest_base\n\t\t\t\t\t ] ?? false\n\t\t\t\t\t: false,\n\t\t\t\ttaxonomy: _taxonomy,\n\t\t\t\ttermIds: _termIds,\n\t\t\t\tterms: _termIds?.length\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, query )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t\thasResolvedTerms: hasFinishedResolution( 'getEntityRecords', [\n\t\t\t\t\t'taxonomy',\n\t\t\t\t\tslug,\n\t\t\t\t\tquery,\n\t\t\t\t] ),\n\t\t\t};\n\t\t},\n\t\t[ slug, post ]\n\t);\n\n\tconst { searchResults } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\n\t\t\treturn {\n\t\t\t\tsearchResults: !! search\n\t\t\t\t\t? getEntityRecords( 'taxonomy', slug, {\n\t\t\t\t\t\t\t...DEFAULT_QUERY,\n\t\t\t\t\t\t\tsearch,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_ARRAY,\n\t\t\t};\n\t\t},\n\t\t[ search, slug ]\n\t);\n\n\t// Update terms state only after the selectors are resolved.\n\t// We're using this to avoid terms temporarily disappearing on slow networks\n\t// while core data makes REST API requests.\n\tuseEffect( () => {\n\t\tif ( hasResolvedTerms ) {\n\t\t\tconst newValues = ( terms ?? [] ).map( ( term ) =>\n\t\t\t\tunescapeString( term.name )\n\t\t\t);\n\n\t\t\tsetValues( newValues );\n\t\t}\n\t}, [ terms, hasResolvedTerms ] );\n\n\tconst suggestions = useMemo( () => {\n\t\treturn ( searchResults ?? [] ).map( ( term ) =>\n\t\t\tunescapeString( term.name )\n\t\t);\n\t}, [ searchResults ] );\n\n\tconst { saveEntityRecord, editEntityRecord, invalidateResolution } =\n\t\tuseDispatch( coreStore );\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\n\tif ( ! hasAssignAction ) {\n\t\treturn null;\n\t}\n\n\tasync function findOrCreateTerm( term ) {\n\t\ttry {\n\t\t\tconst newTerm = await saveEntityRecord( 'taxonomy', slug, term, {\n\t\t\t\tthrowOnError: true,\n\t\t\t} );\n\t\t\tinvalidateResolution( 'getUserPatternCategories' );\n\t\t\treturn unescapeTerm( newTerm );\n\t\t} catch ( error ) {\n\t\t\tif ( error.code !== 'term_exists' ) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tid: error.data.term_id,\n\t\t\t\tname: term.name,\n\t\t\t};\n\t\t}\n\t}\n\n\tfunction onUpdateTerms( newTermIds ) {\n\t\teditEntityRecord( 'postType', PATTERN_TYPES.user, post.id, {\n\t\t\twp_pattern_category: newTermIds,\n\t\t} );\n\t}\n\n\tfunction onChange( termNames ) {\n\t\tconst availableTerms = [\n\t\t\t...( terms ?? [] ),\n\t\t\t...( searchResults ?? [] ),\n\t\t];\n\t\tconst uniqueTerms = termNames.reduce( ( acc, name ) => {\n\t\t\tif (\n\t\t\t\t! acc.some( ( n ) => n.toLowerCase() === name.toLowerCase() )\n\t\t\t) {\n\t\t\t\tacc.push( name );\n\t\t\t}\n\t\t\treturn acc;\n\t\t}, [] );\n\n\t\tconst newTermNames = uniqueTerms.filter(\n\t\t\t( termName ) =>\n\t\t\t\t! availableTerms.find( ( term ) =>\n\t\t\t\t\tisSameTermName( term.name, termName )\n\t\t\t\t)\n\t\t);\n\n\t\t// Optimistically update term values.\n\t\t// The selector will always re-fetch terms later.\n\t\tsetValues( uniqueTerms );\n\n\t\tif ( newTermNames.length === 0 ) {\n\t\t\treturn onUpdateTerms(\n\t\t\t\ttermNamesToIds( uniqueTerms, availableTerms )\n\t\t\t);\n\t\t}\n\n\t\tif ( ! hasCreateAction ) {\n\t\t\treturn;\n\t\t}\n\n\t\tPromise.all(\n\t\t\tnewTermNames.map( ( termName ) =>\n\t\t\t\tfindOrCreateTerm( { name: termName } )\n\t\t\t)\n\t\t)\n\t\t\t.then( ( newTerms ) => {\n\t\t\t\tconst newAvailableTerms = availableTerms.concat( newTerms );\n\t\t\t\treturn onUpdateTerms(\n\t\t\t\t\ttermNamesToIds( uniqueTerms, newAvailableTerms )\n\t\t\t\t);\n\t\t\t} )\n\t\t\t.catch( ( error ) => {\n\t\t\t\tcreateErrorNotice( error.message, {\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t} );\n\t\t\t} );\n\t}\n\n\tconst singularName =\n\t\ttaxonomy?.labels?.singular_name ??\n\t\t( slug === 'post_tag' ? __( 'Tag' ) : __( 'Term' ) );\n\tconst termAddedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s added', 'term' ),\n\t\tsingularName\n\t);\n\tconst termRemovedLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( '%s removed', 'term' ),\n\t\tsingularName\n\t);\n\tconst removeTermLabel = sprintf(\n\t\t/* translators: %s: term name. */\n\t\t_x( 'Remove %s', 'term' ),\n\t\tsingularName\n\t);\n\n\treturn (\n\t\t<PanelRow initialOpen={ true } title={ __( 'Categories' ) }>\n\t\t\t<FlexBlock>\n\t\t\t\t<FormTokenField\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tvalue={ values }\n\t\t\t\t\tsuggestions={ suggestions }\n\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\tonInputChange={ debouncedSearch }\n\t\t\t\t\tmaxSuggestions={ MAX_TERMS_SUGGESTIONS }\n\t\t\t\t\tlabel={ __( 'Pattern categories' ) }\n\t\t\t\t\tmessages={ {\n\t\t\t\t\t\tadded: termAddedLabel,\n\t\t\t\t\t\tremoved: termRemovedLabel,\n\t\t\t\t\t\tremove: removeTermLabel,\n\t\t\t\t\t} }\n\t\t\t\t\ttokenizeOnBlur\n\t\t\t\t/>\n\t\t\t</FlexBlock>\n\t\t</PanelRow>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA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D,MAAMC,cAAc,GAAG,IAAAC,aAAO,GAC7B;EACA,IAAAC,QAAE,EAAE,UAAU,EAAE,MAAO,CAAC,EACxBN,YACD,CAAC;EACD,MAAMO,gBAAgB,GAAG,IAAAF,aAAO,GAC/B;EACA,IAAAC,QAAE,EAAE,YAAY,EAAE,MAAO,CAAC,EAC1BN,YACD,CAAC;EACD,MAAMQ,eAAe,GAAG,IAAAH,aAAO,GAC9B;EACA,IAAAC,QAAE,EAAE,WAAW,EAAE,MAAO,CAAC,EACzBN,YACD,CAAC;EAED,OACC,IAAAS,MAAA,CAAAC,aAAA,EAACpH,WAAA,CAAAqH,QAAQ;IAACC,WAAW,EAAG,IAAM;IAACC,KAAK,EAAG,IAAAV,QAAE,EAAE,YAAa;EAAG,GAC1D,IAAAM,MAAA,CAAAC,aAAA,EAACpH,WAAA,CAAAwH,SAAS,QACT,IAAAL,MAAA,CAAAC,aAAA,EAACpH,WAAA,CAAAyH,cAAc;IACdC,qBAAqB;IACrBC,KAAK,EAAGxF,MAAQ;IAChBgC,WAAW,EAAGA,WAAa;IAC3BmB,QAAQ,EAAGA,QAAU;IACrBsC,aAAa,EAAGpF,eAAiB;IACjCqF,cAAc,EAAG9G,qBAAuB;IACxC+G,KAAK,EAAG,IAAAjB,QAAE,EAAE,oBAAqB,CAAG;IACpCkB,QAAQ,EAAG;MACVC,KAAK,EAAElB,cAAc;MACrBmB,OAAO,EAAEhB,gBAAgB;MACzBiB,MAAM,EAAEhB;IACT,CAAG;IACHiB,cAAc;EAAA,CACd,CACS,CACF,CAAC;AAEb"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["__experimentalText","Text","__experimentalHeading","Heading","__experimentalVStack","VStack","__experimentalSpacer","Spacer","__experimentalHStack","HStack","Button","chevronLeft","TabLayout","title","description","handleBack","children","footer","createElement","className","margin","spacing","justify","variant","onClick","icon","size","level"],"sources":["@wordpress/edit-site/src/components/global-styles/font-library-modal/tab-layout.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalText as Text,\n\t__experimentalHeading as Heading,\n\t__experimentalVStack as VStack,\n\t__experimentalSpacer as Spacer,\n\t__experimentalHStack as HStack,\n\tButton,\n} from '@wordpress/components';\nimport { chevronLeft } from '@wordpress/icons';\n\nfunction TabLayout( { title, description, handleBack, children, footer } ) {\n\treturn (\n\t\t<div className=\"font-library-modal__tab-layout\">\n\t\t\t<Spacer margin={ 4 } />\n\t\t\t<VStack spacing={ 4 } justify=\"space-between\">\n\t\t\t\t<header>\n\t\t\t\t\t<VStack spacing={ 2 }>\n\t\t\t\t\t\t<HStack justify=\"flex-start\">\n\t\t\t\t\t\t\t{ !! handleBack && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t\tonClick={ handleBack }\n\t\t\t\t\t\t\t\t\ticon={ chevronLeft }\n\t\t\t\t\t\t\t\t\tsize=\"small\"\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ title && (\n\t\t\t\t\t\t\t\t<Heading\n\t\t\t\t\t\t\t\t\tlevel={ 2 }\n\t\t\t\t\t\t\t\t\tsize={ 13 }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-site-global-styles-header\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t\t\t</Heading>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</HStack>\n\t\t\t\t\t\t{ description && <Text>{ description }</Text> }\n\t\t\t\t\t</VStack>\n\t\t\t\t</header>\n\t\t\t\t<main>{ children }</main>\n\t\t\t\t{ footer && <footer>{ footer }</footer> }\n\t\t\t</VStack>\n\t\t</div>\n\t);\n}\n\nexport default TabLayout;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,kBAAkB,IAAIC,IAAI,EAC1BC,qBAAqB,IAAIC,OAAO,EAChCC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,oBAAoB,IAAIC,MAAM,EAC9BC,MAAM,QACA,uBAAuB;AAC9B,SAASC,WAAW,QAAQ,kBAAkB;AAE9C,SAASC,SAASA,CAAE;EAAEC,KAAK;EAAEC,WAAW;EAAEC,UAAU;EAAEC,QAAQ;EAAEC;AAAO,CAAC,EAAG;EAC1E,OACCC,aAAA;IAAKC,SAAS,EAAC;EAAgC,GAC9CD,aAAA,CAACX,MAAM;IAACa,MAAM,EAAG;EAAG,CAAE,CAAC,EACvBF,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG,CAAG;IAACC,OAAO,EAAC;EAAe,GAC5CJ,aAAA,iBACCA,aAAA,CAACb,MAAM;IAACgB,OAAO,EAAG;EAAG,GACpBH,aAAA,CAACT,MAAM;IAACa,OAAO,EAAC;EAAY,GACzB,CAAC,CAAEP,UAAU,IACdG,aAAA,CAACR,MAAM;IACNa,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGT,UAAY;IACtBU,IAAI,EAAGd,WAAa;IACpBe,IAAI,EAAC;EAAO,CACZ,CACD,EACCb,KAAK,IACNK,aAAA,CAACf,OAAO;IACPwB,KAAK,EAAG,CAAG;IACXD,IAAI,EAAG,EAAI;IACXP,SAAS,EAAC;EAAgC,GAExCN,KACM,CAEH,CAAC,EACPC,WAAW,IAAII,aAAA,CAACjB,IAAI,QAAGa,WAAmB,CACrC,CACD,CAAC,EACTI,aAAA,eAAQF,QAAgB,CAAC,EACvBC,MAAM,IAAIC,aAAA,iBAAUD,MAAgB,CAC/B,CACJ,CAAC;AAER;AAEA,eAAeL,SAAS"}
@@ -1,139 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { __, sprintf } from '@wordpress/i18n';
5
- const globalStylesChangesCache = new Map();
6
- const EMPTY_ARRAY = [];
7
- const translationMap = {
8
- caption: __('Caption'),
9
- link: __('Link'),
10
- button: __('Button'),
11
- heading: __('Heading'),
12
- 'settings.color': __('Color settings'),
13
- 'settings.typography': __('Typography settings'),
14
- 'styles.color': __('Colors'),
15
- 'styles.spacing': __('Spacing'),
16
- 'styles.typography': __('Typography')
17
- };
18
- const isObject = obj => obj !== null && typeof obj === 'object';
19
-
20
- /**
21
- * Get the translation for a given global styles key.
22
- * @param {string} key A key representing a path to a global style property or setting.
23
- * @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.
24
- * @return {string|undefined} A translated key or undefined if no translation exists.
25
- */
26
- function getTranslation(key, blockNames) {
27
- if (translationMap[key]) {
28
- return translationMap[key];
29
- }
30
- const keyArray = key.split('.');
31
- if (keyArray?.[0] === 'blocks') {
32
- const blockName = blockNames[keyArray[1]];
33
- return blockName ? sprintf(
34
- // translators: %s: block name.
35
- __('%s block'), blockName) : keyArray[1];
36
- }
37
- if (keyArray?.[0] === 'elements') {
38
- return sprintf(
39
- // translators: %s: element name, e.g., heading button, link, caption.
40
- __('%s element'), translationMap[keyArray[1]]);
41
- }
42
- return undefined;
43
- }
44
-
45
- /**
46
- * A deep comparison of two objects, optimized for comparing global styles.
47
- * @param {Object} changedObject The changed object to compare.
48
- * @param {Object} originalObject The original object to compare against.
49
- * @param {string} parentPath A key/value pair object of block names and their rendered titles.
50
- * @return {string[]} An array of paths whose values have changed.
51
- */
52
- function deepCompare(changedObject, originalObject, parentPath = '') {
53
- // We have two non-object values to compare.
54
- if (!isObject(changedObject) && !isObject(originalObject)) {
55
- /*
56
- * Only return a path if the value has changed.
57
- * And then only the path name up to 2 levels deep.
58
- */
59
- return changedObject !== originalObject ? parentPath.split('.').slice(0, 2).join('.') : undefined;
60
- }
61
-
62
- // Enable comparison when an object doesn't have a corresponding property to compare.
63
- changedObject = isObject(changedObject) ? changedObject : {};
64
- originalObject = isObject(originalObject) ? originalObject : {};
65
- const allKeys = new Set([...Object.keys(changedObject), ...Object.keys(originalObject)]);
66
- let diffs = [];
67
- for (const key of allKeys) {
68
- const path = parentPath ? parentPath + '.' + key : key;
69
- const changedPath = deepCompare(changedObject[key], originalObject[key], path);
70
- if (changedPath) {
71
- diffs = diffs.concat(changedPath);
72
- }
73
- }
74
- return diffs;
75
- }
76
-
77
- /**
78
- * Get an array of translated summarized global styles changes.
79
- * Results are cached using a Map() key of `JSON.stringify( { revision, previousRevision } )`.
80
- *
81
- * @param {Object} revision The changed object to compare.
82
- * @param {Object} previousRevision The original object to compare against.
83
- * @param {Record<string,string>} blockNames A key/value pair object of block names and their rendered titles.
84
- * @return {string[]} An array of translated changes.
85
- */
86
- export default function getRevisionChanges(revision, previousRevision, blockNames) {
87
- const cacheKey = JSON.stringify({
88
- revision,
89
- previousRevision
90
- });
91
- if (globalStylesChangesCache.has(cacheKey)) {
92
- return globalStylesChangesCache.get(cacheKey);
93
- }
94
-
95
- /*
96
- * Compare the two revisions with normalized keys.
97
- * The order of these keys determines the order in which
98
- * they'll appear in the results.
99
- */
100
- const changedValueTree = deepCompare({
101
- styles: {
102
- color: revision?.styles?.color,
103
- typography: revision?.styles?.typography,
104
- spacing: revision?.styles?.spacing
105
- },
106
- blocks: revision?.styles?.blocks,
107
- elements: revision?.styles?.elements,
108
- settings: revision?.settings
109
- }, {
110
- styles: {
111
- color: previousRevision?.styles?.color,
112
- typography: previousRevision?.styles?.typography,
113
- spacing: previousRevision?.styles?.spacing
114
- },
115
- blocks: previousRevision?.styles?.blocks,
116
- elements: previousRevision?.styles?.elements,
117
- settings: previousRevision?.settings
118
- });
119
- if (!changedValueTree.length) {
120
- globalStylesChangesCache.set(cacheKey, EMPTY_ARRAY);
121
- return EMPTY_ARRAY;
122
- }
123
-
124
- // Remove duplicate results.
125
- const result = [...new Set(changedValueTree)]
126
- /*
127
- * Translate the keys.
128
- * Remove duplicate or empty translations.
129
- */.reduce((acc, curr) => {
130
- const translation = getTranslation(curr, blockNames);
131
- if (translation && !acc.includes(translation)) {
132
- acc.push(translation);
133
- }
134
- return acc;
135
- }, []);
136
- globalStylesChangesCache.set(cacheKey, result);
137
- return result;
138
- }
139
- //# sourceMappingURL=get-revision-changes.js.map