@wordpress/edit-site 4.10.0 → 4.12.1-next.d6164808d3.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 (204) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/build/components/add-new-template/add-custom-template-modal.js +26 -44
  3. package/build/components/add-new-template/add-custom-template-modal.js.map +1 -1
  4. package/build/components/add-new-template/new-template.js +45 -23
  5. package/build/components/add-new-template/new-template.js.map +1 -1
  6. package/build/components/add-new-template/utils.js +493 -242
  7. package/build/components/add-new-template/utils.js.map +1 -1
  8. package/build/components/block-editor/index.js +1 -3
  9. package/build/components/block-editor/index.js.map +1 -1
  10. package/build/components/block-editor/resizable-editor.js +26 -12
  11. package/build/components/block-editor/resizable-editor.js.map +1 -1
  12. package/build/components/global-styles/border-panel.js +3 -3
  13. package/build/components/global-styles/border-panel.js.map +1 -1
  14. package/build/components/global-styles/dimensions-panel.js +280 -20
  15. package/build/components/global-styles/dimensions-panel.js.map +1 -1
  16. package/build/components/global-styles/hooks.js +4 -4
  17. package/build/components/global-styles/hooks.js.map +1 -1
  18. package/build/components/global-styles/screen-color-palette.js +1 -1
  19. package/build/components/global-styles/screen-color-palette.js.map +1 -1
  20. package/build/components/global-styles/screen-colors.js +51 -7
  21. package/build/components/global-styles/screen-colors.js.map +1 -1
  22. package/build/components/global-styles/screen-heading-color.js +157 -0
  23. package/build/components/global-styles/screen-heading-color.js.map +1 -0
  24. package/build/components/global-styles/screen-typography-element.js +4 -0
  25. package/build/components/global-styles/screen-typography-element.js.map +1 -1
  26. package/build/components/global-styles/screen-typography.js +5 -0
  27. package/build/components/global-styles/screen-typography.js.map +1 -1
  28. package/build/components/global-styles/typography-panel.js +82 -14
  29. package/build/components/global-styles/typography-panel.js.map +1 -1
  30. package/build/components/global-styles/typography-utils.js +217 -0
  31. package/build/components/global-styles/typography-utils.js.map +1 -0
  32. package/build/components/global-styles/ui.js +11 -0
  33. package/build/components/global-styles/ui.js.map +1 -1
  34. package/build/components/global-styles/use-global-styles-output.js +183 -52
  35. package/build/components/global-styles/use-global-styles-output.js.map +1 -1
  36. package/build/components/global-styles/utils.js +85 -5
  37. package/build/components/global-styles/utils.js.map +1 -1
  38. package/build/components/header/document-actions/index.js +1 -0
  39. package/build/components/header/document-actions/index.js.map +1 -1
  40. package/build/components/header/index.js +27 -12
  41. package/build/components/header/index.js.map +1 -1
  42. package/build/components/header/mode-switcher/index.js +0 -4
  43. package/build/components/header/mode-switcher/index.js.map +1 -1
  44. package/build/components/header/more-menu/index.js +13 -3
  45. package/build/components/header/more-menu/index.js.map +1 -1
  46. package/build/components/header/undo-redo/redo.js +2 -1
  47. package/build/components/header/undo-redo/redo.js.map +1 -1
  48. package/build/components/list/actions/index.js +1 -1
  49. package/build/components/list/actions/index.js.map +1 -1
  50. package/build/components/save-button/index.js +2 -3
  51. package/build/components/save-button/index.js.map +1 -1
  52. package/build/components/sidebar/default-sidebar.js +11 -1
  53. package/build/components/sidebar/default-sidebar.js.map +1 -1
  54. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js +2 -2
  55. package/build/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  56. package/build/components/sidebar/plugin-sidebar/index.js +11 -1
  57. package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
  58. package/build/components/sidebar/template-card/template-actions.js +1 -1
  59. package/build/components/sidebar/template-card/template-actions.js.map +1 -1
  60. package/build/components/template-details/edit-template-title.js +1 -1
  61. package/build/components/template-details/edit-template-title.js.map +1 -1
  62. package/build/components/template-details/index.js +19 -9
  63. package/build/components/template-details/index.js.map +1 -1
  64. package/build/components/template-details/template-areas.js +1 -1
  65. package/build/components/template-details/template-areas.js.map +1 -1
  66. package/build/components/template-details/template-part-area-selector.js +47 -0
  67. package/build/components/template-details/template-part-area-selector.js.map +1 -0
  68. package/build/components/template-part-converter/convert-to-template-part.js +4 -1
  69. package/build/components/template-part-converter/convert-to-template-part.js.map +1 -1
  70. package/build/hooks/index.js +2 -0
  71. package/build/hooks/index.js.map +1 -1
  72. package/build/hooks/template-part-edit.js +86 -0
  73. package/build/hooks/template-part-edit.js.map +1 -0
  74. package/build/index.js +1 -1
  75. package/build/index.js.map +1 -1
  76. package/build-module/components/add-new-template/add-custom-template-modal.js +27 -45
  77. package/build-module/components/add-new-template/add-custom-template-modal.js.map +1 -1
  78. package/build-module/components/add-new-template/new-template.js +45 -25
  79. package/build-module/components/add-new-template/new-template.js.map +1 -1
  80. package/build-module/components/add-new-template/utils.js +489 -230
  81. package/build-module/components/add-new-template/utils.js.map +1 -1
  82. package/build-module/components/block-editor/index.js +1 -2
  83. package/build-module/components/block-editor/index.js.map +1 -1
  84. package/build-module/components/block-editor/resizable-editor.js +26 -12
  85. package/build-module/components/block-editor/resizable-editor.js.map +1 -1
  86. package/build-module/components/global-styles/border-panel.js +3 -3
  87. package/build-module/components/global-styles/border-panel.js.map +1 -1
  88. package/build-module/components/global-styles/dimensions-panel.js +278 -22
  89. package/build-module/components/global-styles/dimensions-panel.js.map +1 -1
  90. package/build-module/components/global-styles/hooks.js +4 -4
  91. package/build-module/components/global-styles/hooks.js.map +1 -1
  92. package/build-module/components/global-styles/screen-color-palette.js +1 -1
  93. package/build-module/components/global-styles/screen-color-palette.js.map +1 -1
  94. package/build-module/components/global-styles/screen-colors.js +51 -7
  95. package/build-module/components/global-styles/screen-colors.js.map +1 -1
  96. package/build-module/components/global-styles/screen-heading-color.js +143 -0
  97. package/build-module/components/global-styles/screen-heading-color.js.map +1 -0
  98. package/build-module/components/global-styles/screen-typography-element.js +4 -0
  99. package/build-module/components/global-styles/screen-typography-element.js.map +1 -1
  100. package/build-module/components/global-styles/screen-typography.js +5 -0
  101. package/build-module/components/global-styles/screen-typography.js.map +1 -1
  102. package/build-module/components/global-styles/typography-panel.js +83 -15
  103. package/build-module/components/global-styles/typography-panel.js.map +1 -1
  104. package/build-module/components/global-styles/typography-utils.js +204 -0
  105. package/build-module/components/global-styles/typography-utils.js.map +1 -0
  106. package/build-module/components/global-styles/ui.js +10 -0
  107. package/build-module/components/global-styles/ui.js.map +1 -1
  108. package/build-module/components/global-styles/use-global-styles-output.js +182 -61
  109. package/build-module/components/global-styles/use-global-styles-output.js.map +1 -1
  110. package/build-module/components/global-styles/utils.js +82 -5
  111. package/build-module/components/global-styles/utils.js.map +1 -1
  112. package/build-module/components/header/document-actions/index.js +1 -0
  113. package/build-module/components/header/document-actions/index.js.map +1 -1
  114. package/build-module/components/header/index.js +30 -14
  115. package/build-module/components/header/index.js.map +1 -1
  116. package/build-module/components/header/mode-switcher/index.js +0 -4
  117. package/build-module/components/header/mode-switcher/index.js.map +1 -1
  118. package/build-module/components/header/more-menu/index.js +13 -3
  119. package/build-module/components/header/more-menu/index.js.map +1 -1
  120. package/build-module/components/header/undo-redo/redo.js +3 -2
  121. package/build-module/components/header/undo-redo/redo.js.map +1 -1
  122. package/build-module/components/list/actions/index.js +1 -1
  123. package/build-module/components/list/actions/index.js.map +1 -1
  124. package/build-module/components/save-button/index.js +3 -4
  125. package/build-module/components/save-button/index.js.map +1 -1
  126. package/build-module/components/sidebar/default-sidebar.js +9 -1
  127. package/build-module/components/sidebar/default-sidebar.js.map +1 -1
  128. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js +3 -3
  129. package/build-module/components/sidebar/navigation-menu-sidebar/navigation-menu.js.map +1 -1
  130. package/build-module/components/sidebar/plugin-sidebar/index.js +9 -1
  131. package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
  132. package/build-module/components/sidebar/template-card/template-actions.js +1 -1
  133. package/build-module/components/sidebar/template-card/template-actions.js.map +1 -1
  134. package/build-module/components/template-details/edit-template-title.js +1 -1
  135. package/build-module/components/template-details/edit-template-title.js.map +1 -1
  136. package/build-module/components/template-details/index.js +19 -10
  137. package/build-module/components/template-details/index.js.map +1 -1
  138. package/build-module/components/template-details/template-areas.js +1 -1
  139. package/build-module/components/template-details/template-areas.js.map +1 -1
  140. package/build-module/components/template-details/template-part-area-selector.js +35 -0
  141. package/build-module/components/template-details/template-part-area-selector.js.map +1 -0
  142. package/build-module/components/template-part-converter/convert-to-template-part.js +3 -1
  143. package/build-module/components/template-part-converter/convert-to-template-part.js.map +1 -1
  144. package/build-module/hooks/index.js +1 -0
  145. package/build-module/hooks/index.js.map +1 -1
  146. package/build-module/hooks/template-part-edit.js +67 -0
  147. package/build-module/hooks/template-part-edit.js.map +1 -0
  148. package/build-module/index.js +1 -1
  149. package/build-module/index.js.map +1 -1
  150. package/build-style/style-rtl.css +40 -33
  151. package/build-style/style.css +40 -33
  152. package/package.json +29 -29
  153. package/src/components/add-new-template/add-custom-template-modal.js +39 -48
  154. package/src/components/add-new-template/new-template.js +50 -58
  155. package/src/components/add-new-template/style.scss +20 -8
  156. package/src/components/add-new-template/utils.js +529 -231
  157. package/src/components/block-editor/index.js +0 -2
  158. package/src/components/block-editor/resizable-editor.js +28 -18
  159. package/src/components/editor/style.scss +1 -0
  160. package/src/components/global-styles/border-panel.js +3 -3
  161. package/src/components/global-styles/dimensions-panel.js +344 -45
  162. package/src/components/global-styles/hooks.js +6 -3
  163. package/src/components/global-styles/screen-color-palette.js +1 -1
  164. package/src/components/global-styles/screen-colors.js +46 -4
  165. package/src/components/global-styles/screen-heading-color.js +201 -0
  166. package/src/components/global-styles/screen-typography-element.js +4 -0
  167. package/src/components/global-styles/screen-typography.js +6 -0
  168. package/src/components/global-styles/style.scss +14 -6
  169. package/src/components/global-styles/test/typography-utils.js +130 -0
  170. package/src/components/global-styles/test/use-global-styles-output.js +143 -4
  171. package/src/components/global-styles/test/utils.js +68 -8
  172. package/src/components/global-styles/typography-panel.js +119 -48
  173. package/src/components/global-styles/typography-utils.js +228 -0
  174. package/src/components/global-styles/ui.js +13 -0
  175. package/src/components/global-styles/use-global-styles-output.js +203 -53
  176. package/src/components/global-styles/utils.js +70 -4
  177. package/src/components/header/document-actions/index.js +3 -0
  178. package/src/components/header/index.js +41 -14
  179. package/src/components/header/mode-switcher/index.js +0 -3
  180. package/src/components/header/more-menu/index.js +7 -2
  181. package/src/components/header/style.scss +5 -3
  182. package/src/components/header/undo-redo/redo.js +6 -2
  183. package/src/components/list/actions/index.js +3 -1
  184. package/src/components/save-button/index.js +10 -13
  185. package/src/components/sidebar/default-sidebar.js +12 -0
  186. package/src/components/sidebar/navigation-menu-sidebar/navigation-menu.js +1 -5
  187. package/src/components/sidebar/plugin-sidebar/index.js +12 -0
  188. package/src/components/sidebar/style.scss +4 -0
  189. package/src/components/sidebar/template-card/template-actions.js +3 -1
  190. package/src/components/template-details/edit-template-title.js +7 -3
  191. package/src/components/template-details/index.js +23 -8
  192. package/src/components/template-details/style.scss +0 -5
  193. package/src/components/template-details/template-areas.js +3 -1
  194. package/src/components/template-details/template-part-area-selector.js +38 -0
  195. package/src/components/template-part-converter/convert-to-template-part.js +3 -1
  196. package/src/hooks/index.js +1 -0
  197. package/src/hooks/template-part-edit.js +82 -0
  198. package/src/index.js +1 -1
  199. package/src/style.scss +0 -1
  200. package/build/components/edit-template-part-menu-button/index.js +0 -90
  201. package/build/components/edit-template-part-menu-button/index.js.map +0 -1
  202. package/build-module/components/edit-template-part-menu-button/index.js +0 -72
  203. package/build-module/components/edit-template-part-menu-button/index.js.map +0 -1
  204. package/src/components/edit-template-part-menu-button/index.js +0 -82
@@ -722,6 +722,12 @@ textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area:-ms-inp
722
722
  border-radius: 2px;
723
723
  }
724
724
 
725
+ .edit-site-typography-panel__full-width-control {
726
+ grid-column: 1/-1;
727
+ max-width: 100%;
728
+ }
729
+
730
+ .edit-site-global-styles-screen-heading-color,
725
731
  .edit-site-global-styles-screen-typography {
726
732
  margin: 16px;
727
733
  }
@@ -741,6 +747,7 @@ textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area:-ms-inp
741
747
  }
742
748
  .edit-site-global-styles-screen-colors .component-color-indicator {
743
749
  background: linear-gradient(-45deg, transparent 48%, #ddd 48%, #ddd 52%, transparent 52%);
750
+ flex-shrink: 0;
744
751
  }
745
752
 
746
753
  .edit-site-global-styles-header__description,
@@ -770,10 +777,6 @@ textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area:-ms-inp
770
777
  padding: 16px;
771
778
  }
772
779
 
773
- .edit-site-screen-background-color__control .block-editor-color-gradient-control__tab-panel {
774
- padding: 16px;
775
- }
776
-
777
780
  .edit-site-global-styles-variations_item {
778
781
  box-sizing: border-box;
779
782
  }
@@ -798,6 +801,13 @@ textarea.edit-site-code-editor-text-area.edit-site-code-editor-text-area:-ms-inp
798
801
 
799
802
  .edit-site-global-styles__color-indicator-wrapper {
800
803
  height: 24px;
804
+ flex-shrink: 0;
805
+ }
806
+
807
+ .edit-site-global-styles__color-label {
808
+ white-space: nowrap;
809
+ overflow: hidden;
810
+ text-overflow: ellipsis;
801
811
  }
802
812
 
803
813
  .edit-site-header {
@@ -1001,14 +1011,13 @@ body.is-navigation-sidebar-open .edit-site-header .edit-site-header_end .compone
1001
1011
  padding-left: 6px;
1002
1012
  padding-right: 6px;
1003
1013
  }
1014
+ .show-icon-labels .edit-site-header .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info::after {
1015
+ content: none;
1016
+ }
1004
1017
  .show-icon-labels .edit-site-header .edit-site-header-toolbar__inserter-toggle.edit-site-header-toolbar__inserter-toggle,
1005
1018
  .show-icon-labels .edit-site-header .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info {
1006
1019
  height: 36px;
1007
- padding: 0 6px;
1008
- }
1009
- .show-icon-labels .edit-site-header .edit-site-header-toolbar__inserter-toggle.edit-site-header-toolbar__inserter-toggle::after,
1010
- .show-icon-labels .edit-site-header .edit-site-document-actions__get-info.edit-site-document-actions__get-info.edit-site-document-actions__get-info::after {
1011
- content: none;
1020
+ padding: 0 8px;
1012
1021
  }
1013
1022
  .show-icon-labels .edit-site-header .edit-site-header_start .edit-site-header__toolbar > * + * {
1014
1023
  margin-left: 8px;
@@ -1490,30 +1499,36 @@ body.is-fullscreen-mode .edit-site-list-header {
1490
1499
  }
1491
1500
  }
1492
1501
 
1493
- .edit-site-custom-template-modal__contents > div {
1494
- text-align: center;
1495
- cursor: pointer;
1502
+ .edit-site-custom-template-modal__contents > .components-button {
1496
1503
  padding: 24px;
1497
- border: 1px solid #ddd;
1504
+ box-shadow: inset 0 0 0 1px #949494;
1498
1505
  border-radius: 2px;
1499
1506
  width: 256px;
1507
+ height: auto;
1500
1508
  display: flex;
1501
1509
  flex-direction: column;
1502
1510
  gap: 8px;
1503
- align-items: center;
1504
- justify-content: center;
1511
+ outline: 1px solid transparent;
1512
+ }
1513
+ .edit-site-custom-template-modal__contents > .components-button span:first-child {
1514
+ color: #1e1e1e;
1505
1515
  }
1506
- .edit-site-custom-template-modal__contents > div span {
1516
+ .edit-site-custom-template-modal__contents > .components-button span {
1507
1517
  color: #757575;
1508
1518
  }
1509
- .edit-site-custom-template-modal__contents > div:hover {
1510
- border-color: var(--wp-admin-theme-color);
1519
+ .edit-site-custom-template-modal__contents > .components-button:hover {
1520
+ color: var(--wp-admin-theme-color-darker-10);
1521
+ box-shadow: inset 0 0 0 1px var(--wp-admin-theme-color-darker-10);
1511
1522
  }
1512
- .edit-site-custom-template-modal__contents > div:hover h5 {
1523
+ .edit-site-custom-template-modal__contents > .components-button:hover span:first-child {
1513
1524
  color: var(--wp-admin-theme-color);
1514
1525
  }
1515
- .edit-site-custom-template-modal__contents > div:focus {
1526
+ .edit-site-custom-template-modal__contents > .components-button:focus {
1516
1527
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
1528
+ outline: 3px solid transparent;
1529
+ }
1530
+ .edit-site-custom-template-modal__contents > .components-button:focus span:first-child {
1531
+ color: var(--wp-admin-theme-color);
1517
1532
  }
1518
1533
  .edit-site-custom-template-modal .components-search-control input[type=search].components-search-control__input {
1519
1534
  background: #fff;
@@ -1658,6 +1673,10 @@ body.is-fullscreen-mode .edit-site-list-header {
1658
1673
  grid-column: span 1;
1659
1674
  }
1660
1675
 
1676
+ .edit-site-global-styles-sidebar .components-tools-panel .span-columns {
1677
+ grid-column: 1/-1;
1678
+ }
1679
+
1661
1680
  .edit-site-global-styles-sidebar__blocks-group {
1662
1681
  padding-top: 24px;
1663
1682
  border-top: 1px solid #e0e0e0;
@@ -1883,6 +1902,7 @@ html.wp-toolbar {
1883
1902
  position: relative;
1884
1903
  height: 100%;
1885
1904
  display: block;
1905
+ overflow: hidden;
1886
1906
  }
1887
1907
  .edit-site-visual-editor iframe {
1888
1908
  display: block;
@@ -1944,11 +1964,7 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
1944
1964
  .edit-site-template-details .edit-site-template-details__group + .edit-site-template-details__group {
1945
1965
  border-top: 1px solid #ccc;
1946
1966
  }
1947
- .edit-site-template-details .edit-site-template-details__title {
1948
- margin: 0;
1949
- }
1950
1967
  .edit-site-template-details .edit-site-template-details__description {
1951
- margin: 12px 0 0;
1952
1968
  color: #757575;
1953
1969
  }
1954
1970
  .edit-site-template-details .edit-site-template-details__group.edit-site-template-details__template-areas {
@@ -2188,40 +2204,31 @@ html.wp-toolbar {
2188
2204
  background: #fff;
2189
2205
  }
2190
2206
 
2191
- body.appearance_page_gutenberg-edit-site,
2192
2207
  body.site-editor-php {
2193
2208
  background: #fff;
2194
2209
  /* We hide legacy notices in Gutenberg Based Pages, because they were not designed in a way that scaled well.
2195
2210
  Plugins can use Gutenberg notices if they need to pass on information to the user when they are editing. */
2196
2211
  }
2197
- body.appearance_page_gutenberg-edit-site #wpcontent,
2198
2212
  body.site-editor-php #wpcontent {
2199
2213
  padding-left: 0;
2200
2214
  }
2201
- body.appearance_page_gutenberg-edit-site #wpbody-content,
2202
2215
  body.site-editor-php #wpbody-content {
2203
2216
  padding-bottom: 0;
2204
2217
  }
2205
- body.appearance_page_gutenberg-edit-site #wpbody-content > div:not(.edit-site):not(#screen-meta),
2206
2218
  body.site-editor-php #wpbody-content > div:not(.edit-site):not(#screen-meta) {
2207
2219
  display: none;
2208
2220
  }
2209
- body.appearance_page_gutenberg-edit-site #wpfooter,
2210
2221
  body.site-editor-php #wpfooter {
2211
2222
  display: none;
2212
2223
  }
2213
- body.appearance_page_gutenberg-edit-site .a11y-speak-region,
2214
2224
  body.site-editor-php .a11y-speak-region {
2215
2225
  left: -1px;
2216
2226
  top: -1px;
2217
2227
  }
2218
- body.appearance_page_gutenberg-edit-site ul#adminmenu a.wp-has-current-submenu::after,
2219
- body.appearance_page_gutenberg-edit-site ul#adminmenu > li.current > a.current::after,
2220
2228
  body.site-editor-php ul#adminmenu a.wp-has-current-submenu::after,
2221
2229
  body.site-editor-php ul#adminmenu > li.current > a.current::after {
2222
2230
  border-right-color: #fff;
2223
2231
  }
2224
- body.appearance_page_gutenberg-edit-site .media-frame select.attachment-filters:last-of-type,
2225
2232
  body.site-editor-php .media-frame select.attachment-filters:last-of-type {
2226
2233
  width: auto;
2227
2234
  max-width: 100%;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-site",
3
- "version": "4.10.0",
3
+ "version": "4.12.1-next.d6164808d3.0",
4
4
  "description": "Edit Site Page module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,33 +27,33 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.13.0",
31
- "@wordpress/api-fetch": "^6.10.0",
32
- "@wordpress/block-editor": "^9.5.0",
33
- "@wordpress/block-library": "^7.10.0",
34
- "@wordpress/blocks": "^11.12.0",
35
- "@wordpress/components": "^19.15.0",
36
- "@wordpress/compose": "^5.11.0",
37
- "@wordpress/core-data": "^4.11.0",
38
- "@wordpress/data": "^6.13.0",
39
- "@wordpress/deprecated": "^3.13.0",
40
- "@wordpress/editor": "^12.12.0",
41
- "@wordpress/element": "^4.11.0",
42
- "@wordpress/hooks": "^3.13.0",
43
- "@wordpress/html-entities": "^3.13.0",
44
- "@wordpress/i18n": "^4.13.0",
45
- "@wordpress/icons": "^9.4.0",
46
- "@wordpress/interface": "^4.12.0",
47
- "@wordpress/keyboard-shortcuts": "^3.11.0",
48
- "@wordpress/keycodes": "^3.13.0",
49
- "@wordpress/media-utils": "^4.4.0",
50
- "@wordpress/notices": "^3.13.0",
51
- "@wordpress/plugins": "^4.11.0",
52
- "@wordpress/preferences": "^2.5.0",
53
- "@wordpress/reusable-blocks": "^3.11.0",
54
- "@wordpress/style-engine": "^0.12.0",
55
- "@wordpress/url": "^3.14.0",
56
- "@wordpress/viewport": "^4.11.0",
30
+ "@wordpress/a11y": "^3.15.1-next.d6164808d3.0",
31
+ "@wordpress/api-fetch": "^6.12.1-next.d6164808d3.0",
32
+ "@wordpress/block-editor": "^9.7.1-next.d6164808d3.0",
33
+ "@wordpress/block-library": "^7.12.2-next.d6164808d3.0",
34
+ "@wordpress/blocks": "^11.14.1-next.d6164808d3.0",
35
+ "@wordpress/components": "^20.0.1-next.d6164808d3.0",
36
+ "@wordpress/compose": "^5.13.1-next.d6164808d3.0",
37
+ "@wordpress/core-data": "^4.14.1-next.d6164808d3.0",
38
+ "@wordpress/data": "^7.0.1-next.d6164808d3.0",
39
+ "@wordpress/deprecated": "^3.15.1-next.d6164808d3.0",
40
+ "@wordpress/editor": "^12.14.1-next.d6164808d3.0",
41
+ "@wordpress/element": "^4.13.1-next.d6164808d3.0",
42
+ "@wordpress/hooks": "^3.15.1-next.d6164808d3.0",
43
+ "@wordpress/html-entities": "^3.15.1-next.d6164808d3.0",
44
+ "@wordpress/i18n": "^4.15.1-next.d6164808d3.0",
45
+ "@wordpress/icons": "^9.6.1-next.d6164808d3.0",
46
+ "@wordpress/interface": "^4.14.1-next.d6164808d3.0",
47
+ "@wordpress/keyboard-shortcuts": "^3.13.1-next.d6164808d3.0",
48
+ "@wordpress/keycodes": "^3.15.1-next.d6164808d3.0",
49
+ "@wordpress/media-utils": "^4.6.1-next.d6164808d3.0",
50
+ "@wordpress/notices": "^3.15.1-next.d6164808d3.0",
51
+ "@wordpress/plugins": "^4.13.1-next.d6164808d3.0",
52
+ "@wordpress/preferences": "^2.7.1-next.d6164808d3.0",
53
+ "@wordpress/reusable-blocks": "^3.13.1-next.d6164808d3.0",
54
+ "@wordpress/style-engine": "^0.14.1-next.d6164808d3.0",
55
+ "@wordpress/url": "^3.16.1-next.d6164808d3.0",
56
+ "@wordpress/viewport": "^4.13.1-next.d6164808d3.0",
57
57
  "classnames": "^2.3.1",
58
58
  "downloadjs": "^1.4.7",
59
59
  "history": "^5.1.0",
@@ -68,5 +68,5 @@
68
68
  "publishConfig": {
69
69
  "access": "public"
70
70
  },
71
- "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
71
+ "gitHead": "ba8a396d2f418e53a6c4c50575582f3f3eb11ff7"
72
72
  }
@@ -11,7 +11,6 @@ import {
11
11
  SearchControl,
12
12
  TextHighlight,
13
13
  __experimentalText as Text,
14
- __experimentalHeading as Heading,
15
14
  __unstableComposite as Composite,
16
15
  __unstableUseCompositeState as useCompositeState,
17
16
  __unstableCompositeItem as CompositeItem,
@@ -26,34 +25,6 @@ import { mapToIHasNameAndId } from './utils';
26
25
 
27
26
  const EMPTY_ARRAY = [];
28
27
 
29
- function selectSuggestion( suggestion, onSelect, entityForSuggestions ) {
30
- const {
31
- labels,
32
- slug,
33
- config: { templateSlug, templatePrefix },
34
- } = entityForSuggestions;
35
- const title = sprintf(
36
- // translators: Represents the title of a user's custom template in the Site Editor, where %1$s is the singular name of a post type or taxonomy and %2$s is the name of the post or term, e.g. "Post: Hello, WordPress", "Category: shoes"
37
- __( '%1$s: %2$s' ),
38
- labels.singular_name,
39
- suggestion.name
40
- );
41
- let newTemplateSlug = `${ templateSlug || slug }-${ suggestion.slug }`;
42
- if ( templatePrefix ) {
43
- newTemplateSlug = templatePrefix + newTemplateSlug;
44
- }
45
- const newTemplate = {
46
- title,
47
- description: sprintf(
48
- // translators: Represents the description of a user's custom template in the Site Editor, e.g. "Template for Post: Hello, WordPress"
49
- __( 'Template for %1$s' ),
50
- title
51
- ),
52
- slug: newTemplateSlug,
53
- };
54
- onSelect( newTemplate );
55
- }
56
-
57
28
  function SuggestionListItem( {
58
29
  suggestion,
59
30
  search,
@@ -70,7 +41,11 @@ function SuggestionListItem( {
70
41
  { ...composite }
71
42
  className={ baseCssClass }
72
43
  onClick={ () =>
73
- selectSuggestion( suggestion, onSelect, entityForSuggestions )
44
+ onSelect(
45
+ entityForSuggestions.config.getSpecificTemplate(
46
+ suggestion
47
+ )
48
+ )
74
49
  }
75
50
  >
76
51
  <span className={ `${ baseCssClass }__title` }>
@@ -98,18 +73,16 @@ function useDebouncedInput() {
98
73
  }
99
74
 
100
75
  function useSearchSuggestions( entityForSuggestions, search ) {
101
- const { config, postsToExclude } = entityForSuggestions;
76
+ const { config } = entityForSuggestions;
102
77
  const query = useMemo(
103
78
  () => ( {
104
79
  order: 'asc',
105
- _fields: 'id,name,title,slug,link',
106
80
  context: 'view',
107
81
  search,
108
- orderBy: config.getOrderBy( { search } ),
109
- exclude: postsToExclude,
110
82
  per_page: search ? 20 : 10,
83
+ ...config.queryArgs( search ),
111
84
  } ),
112
- [ search, config, postsToExclude ]
85
+ [ search, config ]
113
86
  );
114
87
  const { records: searchResults, hasResolved: searchHasResolved } =
115
88
  useEntityRecords(
@@ -145,19 +118,26 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
145
118
  debouncedSearch
146
119
  );
147
120
  const { labels } = entityForSuggestions;
121
+ const [ showSearchControl, setShowSearchControl ] = useState( false );
122
+ if ( ! showSearchControl && suggestions?.length > 9 ) {
123
+ setShowSearchControl( true );
124
+ }
148
125
  return (
149
126
  <>
150
- <SearchControl
151
- onChange={ setSearch }
152
- value={ search }
153
- label={ labels.search_items }
154
- placeholder={ labels.search_items }
155
- />
127
+ { showSearchControl && (
128
+ <SearchControl
129
+ onChange={ setSearch }
130
+ value={ search }
131
+ label={ labels.search_items }
132
+ placeholder={ labels.search_items }
133
+ />
134
+ ) }
156
135
  { !! suggestions?.length && (
157
136
  <Composite
158
137
  { ...composite }
159
138
  role="listbox"
160
139
  className="edit-site-custom-template-modal__suggestions_list"
140
+ aria-label={ __( 'Suggestions list' ) }
161
141
  >
162
142
  { suggestions.map( ( suggestion ) => (
163
143
  <SuggestionListItem
@@ -210,15 +190,25 @@ function AddCustomTemplateModal( { onClose, onSelect, entityForSuggestions } ) {
210
190
  >
211
191
  <FlexItem
212
192
  isBlock
193
+ as={ Button }
213
194
  onClick={ () => {
214
- const { slug, title, description } =
215
- entityForSuggestions.template;
216
- onSelect( { slug, title, description } );
195
+ const {
196
+ slug,
197
+ title,
198
+ description,
199
+ templatePrefix,
200
+ } = entityForSuggestions.template;
201
+ onSelect( {
202
+ slug,
203
+ title,
204
+ description,
205
+ templatePrefix,
206
+ } );
217
207
  } }
218
208
  >
219
- <Heading level={ 5 }>
209
+ <Text as="span" weight={ 600 }>
220
210
  { entityForSuggestions.labels.all_items }
221
- </Heading>
211
+ </Text>
222
212
  <Text as="span">
223
213
  {
224
214
  // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
@@ -228,13 +218,14 @@ function AddCustomTemplateModal( { onClose, onSelect, entityForSuggestions } ) {
228
218
  </FlexItem>
229
219
  <FlexItem
230
220
  isBlock
221
+ as={ Button }
231
222
  onClick={ () => {
232
223
  setShowSearchEntities( true );
233
224
  } }
234
225
  >
235
- <Heading level={ 5 }>
226
+ <Text as="span" weight={ 600 }>
236
227
  { entityForSuggestions.labels.singular_name }
237
- </Heading>
228
+ </Text>
238
229
  <Text as="span">
239
230
  {
240
231
  // translators: The user is given the choice to set up a template for all items of a post type or taxonomy, or just a specific one.
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
+ import apiFetch from '@wordpress/api-fetch';
5
+ import { addQueryArgs } from '@wordpress/url';
4
6
  import {
5
7
  DropdownMenu,
6
8
  MenuGroup,
@@ -26,7 +28,7 @@ import {
26
28
  tag,
27
29
  layout as customGenericTemplateIcon,
28
30
  } from '@wordpress/icons';
29
- import { __ } from '@wordpress/i18n';
31
+ import { __, sprintf } from '@wordpress/i18n';
30
32
  import { store as noticesStore } from '@wordpress/notices';
31
33
 
32
34
  /**
@@ -36,13 +38,9 @@ import AddCustomTemplateModal from './add-custom-template-modal';
36
38
  import {
37
39
  useExistingTemplates,
38
40
  useDefaultTemplateTypes,
39
- entitiesConfig,
40
- usePostTypes,
41
- usePostTypePage,
42
- useTaxonomies,
43
- useTaxonomyCategory,
44
- useTaxonomyTag,
45
- useExtraTemplates,
41
+ useTaxonomiesMenuItems,
42
+ usePostTypeMenuItems,
43
+ useAuthorMenuItem,
46
44
  } from './utils';
47
45
  import AddCustomGenericTemplateModal from './add-custom-generic-template-modal';
48
46
  import { useHistory } from '../routes';
@@ -90,12 +88,25 @@ export default function NewTemplate( { postType } ) {
90
88
 
91
89
  const history = useHistory();
92
90
  const { saveEntityRecord } = useDispatch( coreStore );
93
- const { createErrorNotice } = useDispatch( noticesStore );
91
+ const { createErrorNotice, createSuccessNotice } =
92
+ useDispatch( noticesStore );
94
93
  const { setTemplate } = useDispatch( editSiteStore );
95
94
 
96
95
  async function createTemplate( template, isWPSuggestion = true ) {
97
96
  try {
98
- const { title, description, slug } = template;
97
+ const { title, description, slug, templatePrefix } = template;
98
+ let templateContent = template.content;
99
+ // Try to find fallback content from existing templates.
100
+ if ( ! templateContent ) {
101
+ const fallbackTemplate = await apiFetch( {
102
+ path: addQueryArgs( '/wp/v2/templates/lookup', {
103
+ slug,
104
+ is_custom: ! isWPSuggestion,
105
+ template_prefix: templatePrefix,
106
+ } ),
107
+ } );
108
+ templateContent = fallbackTemplate.content;
109
+ }
99
110
  const newTemplate = await saveEntityRecord(
100
111
  'postType',
101
112
  'wp_template',
@@ -105,6 +116,7 @@ export default function NewTemplate( { postType } ) {
105
116
  slug: slug.toString(),
106
117
  status: 'publish',
107
118
  title,
119
+ content: templateContent,
108
120
  // This adds a post meta field in template that is part of `is_custom` value calculation.
109
121
  is_wp_suggestion: isWPSuggestion,
110
122
  },
@@ -119,8 +131,16 @@ export default function NewTemplate( { postType } ) {
119
131
  postId: newTemplate.id,
120
132
  postType: newTemplate.type,
121
133
  } );
122
-
123
- // TODO: Add a success notice?
134
+ createSuccessNotice(
135
+ sprintf(
136
+ // translators: %s: Title of the created template e.g: "Category".
137
+ __( '"%s" successfully created.' ),
138
+ title
139
+ ),
140
+ {
141
+ type: 'snackbar',
142
+ }
143
+ );
124
144
  } catch ( error ) {
125
145
  const errorMessage =
126
146
  error.message && error.code !== 'unknown_error'
@@ -225,19 +245,11 @@ function useMissingTemplates(
225
245
  setEntityForSuggestions,
226
246
  setShowCustomTemplateModal
227
247
  ) {
228
- const postTypes = usePostTypes();
229
- const pagePostType = usePostTypePage();
230
- const taxonomies = useTaxonomies();
231
- const categoryTaxonomy = useTaxonomyCategory();
232
- const tagTaxonomy = useTaxonomyTag();
233
-
234
248
  const existingTemplates = useExistingTemplates();
235
249
  const defaultTemplateTypes = useDefaultTemplateTypes();
236
-
237
250
  const existingTemplateSlugs = ( existingTemplates || [] ).map(
238
251
  ( { slug } ) => slug
239
252
  );
240
-
241
253
  const missingDefaultTemplates = ( defaultTemplateTypes || [] ).filter(
242
254
  ( template ) =>
243
255
  DEFAULT_TEMPLATE_SLUGS.includes( template.slug ) &&
@@ -247,33 +259,27 @@ function useMissingTemplates(
247
259
  setShowCustomTemplateModal( true );
248
260
  setEntityForSuggestions( _entityForSuggestions );
249
261
  };
250
- // TODO: find better names for these variables. `useExtraTemplates` returns an array of items.
251
- const categoryMenuItem = useExtraTemplates(
252
- categoryTaxonomy,
253
- entitiesConfig.category,
254
- onClickMenuItem
255
- );
256
- const tagMenuItem = useExtraTemplates(
257
- tagTaxonomy,
258
- entitiesConfig.tag,
259
- onClickMenuItem
260
- );
261
- const pageMenuItem = useExtraTemplates(
262
- pagePostType,
263
- entitiesConfig.page,
264
- onClickMenuItem
265
- );
266
262
  // We need to replace existing default template types with
267
263
  // the create specific template functionality. The original
268
264
  // info (title, description, etc.) is preserved in the
269
- // `useExtraTemplates` hook.
265
+ // used hooks.
270
266
  const enhancedMissingDefaultTemplateTypes = [ ...missingDefaultTemplates ];
271
- [ categoryMenuItem, tagMenuItem, pageMenuItem ].forEach( ( menuItem ) => {
272
- if ( ! menuItem?.length ) {
267
+ const { defaultTaxonomiesMenuItems, taxonomiesMenuItems } =
268
+ useTaxonomiesMenuItems( onClickMenuItem );
269
+ const { defaultPostTypesMenuItems, postTypesMenuItems } =
270
+ usePostTypeMenuItems( onClickMenuItem );
271
+
272
+ const authorMenuItem = useAuthorMenuItem( onClickMenuItem );
273
+ [
274
+ ...defaultTaxonomiesMenuItems,
275
+ ...defaultPostTypesMenuItems,
276
+ authorMenuItem,
277
+ ].forEach( ( menuItem ) => {
278
+ if ( ! menuItem ) {
273
279
  return;
274
280
  }
275
281
  const matchIndex = enhancedMissingDefaultTemplateTypes.findIndex(
276
- ( template ) => template.slug === menuItem[ 0 ].slug
282
+ ( template ) => template.slug === menuItem.slug
277
283
  );
278
284
  // Some default template types might have been filtered above from
279
285
  // `missingDefaultTemplates` because they only check for the general
@@ -281,13 +287,9 @@ function useMissingTemplates(
281
287
  // with the check if it has available specific item to create a
282
288
  // template for.
283
289
  if ( matchIndex > -1 ) {
284
- enhancedMissingDefaultTemplateTypes.splice(
285
- matchIndex,
286
- 1,
287
- menuItem[ 0 ]
288
- );
290
+ enhancedMissingDefaultTemplateTypes[ matchIndex ] = menuItem;
289
291
  } else {
290
- enhancedMissingDefaultTemplateTypes.push( menuItem[ 0 ] );
292
+ enhancedMissingDefaultTemplateTypes.push( menuItem );
291
293
  }
292
294
  } );
293
295
  // Update the sort order to match the DEFAULT_TEMPLATE_SLUGS order.
@@ -297,20 +299,10 @@ function useMissingTemplates(
297
299
  DEFAULT_TEMPLATE_SLUGS.indexOf( template2.slug )
298
300
  );
299
301
  } );
300
- const extraPostTypeTemplates = useExtraTemplates(
301
- postTypes,
302
- entitiesConfig.postType,
303
- onClickMenuItem
304
- );
305
- const extraTaxonomyTemplates = useExtraTemplates(
306
- taxonomies,
307
- entitiesConfig.taxonomy,
308
- onClickMenuItem
309
- );
310
302
  const missingTemplates = [
311
303
  ...enhancedMissingDefaultTemplateTypes,
312
- ...extraPostTypeTemplates,
313
- ...extraTaxonomyTemplates,
304
+ ...postTypesMenuItems,
305
+ ...taxonomiesMenuItems,
314
306
  ];
315
307
  return missingTemplates;
316
308
  }
@@ -12,33 +12,45 @@
12
12
 
13
13
  .edit-site-custom-template-modal {
14
14
  &__contents {
15
- > div {
16
- text-align: center;
17
- cursor: pointer;
15
+ > .components-button {
18
16
  padding: $grid-unit-30;
19
- border: 1px solid $gray-300;
17
+ box-shadow: inset 0 0 0 $border-width $gray-600;
20
18
  border-radius: $radius-block-ui;
21
19
  width: 256px;
20
+ height: auto;
22
21
  display: flex;
23
22
  flex-direction: column;
24
23
  gap: $grid-unit;
25
- align-items: center;
26
- justify-content: center;
24
+
25
+ // Show the boundary of the button, in High Contrast Mode.
26
+ outline: 1px solid transparent;
27
+
28
+ span:first-child {
29
+ color: $gray-900;
30
+ }
27
31
 
28
32
  span {
29
33
  color: $gray-700;
30
34
  }
31
35
 
32
36
  &:hover {
33
- border-color: var(--wp-admin-theme-color);
37
+ color: var(--wp-admin-theme-color-darker-10);
38
+ box-shadow: inset 0 0 0 $border-width var(--wp-admin-theme-color-darker-10);
34
39
 
35
- h5 {
40
+ span:first-child {
36
41
  color: var(--wp-admin-theme-color);
37
42
  }
38
43
  }
39
44
 
40
45
  &:focus {
41
46
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
47
+
48
+ // Windows High Contrast mode will show this outline, but not the box-shadow.
49
+ outline: 3px solid transparent;
50
+
51
+ span:first-child {
52
+ color: var(--wp-admin-theme-color);
53
+ }
42
54
  }
43
55
  }
44
56
  }