@wordpress/editor 14.5.0 → 14.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/bindings/post-meta.js +2 -2
  3. package/build/bindings/post-meta.js.map +1 -1
  4. package/build/components/create-template-part-modal/index.js +1 -0
  5. package/build/components/create-template-part-modal/index.js.map +1 -1
  6. package/build/components/global-styles-provider/index.js +17 -4
  7. package/build/components/global-styles-provider/index.js.map +1 -1
  8. package/build/components/inserter-sidebar/index.js +5 -2
  9. package/build/components/inserter-sidebar/index.js.map +1 -1
  10. package/build/components/page-attributes/parent.js +6 -5
  11. package/build/components/page-attributes/parent.js.map +1 -1
  12. package/build/components/post-actions/actions.js +4 -499
  13. package/build/components/post-actions/actions.js.map +1 -1
  14. package/build/components/post-actions/index.js +8 -17
  15. package/build/components/post-actions/index.js.map +1 -1
  16. package/build/components/post-card-panel/index.js +20 -20
  17. package/build/components/post-card-panel/index.js.map +1 -1
  18. package/build/components/post-featured-image/index.js +2 -0
  19. package/build/components/post-featured-image/index.js.map +1 -1
  20. package/build/components/post-publish-panel/postpublish.js +4 -0
  21. package/build/components/post-publish-panel/postpublish.js.map +1 -1
  22. package/build/components/post-slug/index.js +1 -0
  23. package/build/components/post-slug/index.js.map +1 -1
  24. package/build/components/post-taxonomies/hierarchical-term-selector.js +2 -1
  25. package/build/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  26. package/build/components/post-url/index.js +6 -5
  27. package/build/components/post-url/index.js.map +1 -1
  28. package/build/components/sidebar/post-summary.js +10 -7
  29. package/build/components/sidebar/post-summary.js.map +1 -1
  30. package/build/components/template-content-panel/index.js +1 -1
  31. package/build/components/template-content-panel/index.js.map +1 -1
  32. package/build/dataviews/actions/duplicate-pattern.js +48 -0
  33. package/build/dataviews/actions/duplicate-pattern.js.map +1 -0
  34. package/build/dataviews/actions/duplicate-post.js +146 -0
  35. package/build/dataviews/actions/duplicate-post.js.map +1 -0
  36. package/build/dataviews/actions/duplicate-post.native.js +9 -0
  37. package/build/dataviews/actions/duplicate-post.native.js.map +1 -0
  38. package/build/dataviews/actions/duplicate-template-part.js +67 -0
  39. package/build/dataviews/actions/duplicate-template-part.js.map +1 -0
  40. package/build/dataviews/actions/rename-post.js +125 -0
  41. package/build/dataviews/actions/rename-post.js.map +1 -0
  42. package/build/dataviews/actions/reorder-page.js +116 -0
  43. package/build/dataviews/actions/reorder-page.js.map +1 -0
  44. package/build/dataviews/actions/reorder-page.native.js +9 -0
  45. package/build/dataviews/actions/reorder-page.native.js.map +1 -0
  46. package/build/dataviews/actions/reset-post.js +1 -1
  47. package/build/dataviews/actions/reset-post.js.map +1 -1
  48. package/build/dataviews/actions/utils.js +9 -1
  49. package/build/dataviews/actions/utils.js.map +1 -1
  50. package/build/dataviews/actions/view-post-revisions.js +49 -0
  51. package/build/dataviews/actions/view-post-revisions.js.map +1 -0
  52. package/build/dataviews/actions/view-post.js +36 -0
  53. package/build/dataviews/actions/view-post.js.map +1 -0
  54. package/build/dataviews/fields/index.js +32 -0
  55. package/build/dataviews/fields/index.js.map +1 -0
  56. package/build/dataviews/store/private-actions.js +16 -2
  57. package/build/dataviews/store/private-actions.js.map +1 -1
  58. package/build/dataviews/types.js.map +1 -1
  59. package/build/private-apis.js +2 -0
  60. package/build/private-apis.js.map +1 -1
  61. package/build/store/private-actions.js +1 -1
  62. package/build/store/private-actions.js.map +1 -1
  63. package/build/store/utils/is-template-revertable.js +1 -1
  64. package/build/store/utils/is-template-revertable.js.map +1 -1
  65. package/build-module/bindings/post-meta.js +2 -2
  66. package/build-module/bindings/post-meta.js.map +1 -1
  67. package/build-module/components/create-template-part-modal/index.js +1 -0
  68. package/build-module/components/create-template-part-modal/index.js.map +1 -1
  69. package/build-module/components/global-styles-provider/index.js +17 -4
  70. package/build-module/components/global-styles-provider/index.js.map +1 -1
  71. package/build-module/components/inserter-sidebar/index.js +5 -2
  72. package/build-module/components/inserter-sidebar/index.js.map +1 -1
  73. package/build-module/components/page-attributes/parent.js +6 -5
  74. package/build-module/components/page-attributes/parent.js.map +1 -1
  75. package/build-module/components/post-actions/actions.js +5 -501
  76. package/build-module/components/post-actions/actions.js.map +1 -1
  77. package/build-module/components/post-actions/index.js +8 -17
  78. package/build-module/components/post-actions/index.js.map +1 -1
  79. package/build-module/components/post-card-panel/index.js +20 -20
  80. package/build-module/components/post-card-panel/index.js.map +1 -1
  81. package/build-module/components/post-featured-image/index.js +2 -0
  82. package/build-module/components/post-featured-image/index.js.map +1 -1
  83. package/build-module/components/post-publish-panel/postpublish.js +4 -0
  84. package/build-module/components/post-publish-panel/postpublish.js.map +1 -1
  85. package/build-module/components/post-slug/index.js +1 -0
  86. package/build-module/components/post-slug/index.js.map +1 -1
  87. package/build-module/components/post-taxonomies/hierarchical-term-selector.js +3 -2
  88. package/build-module/components/post-taxonomies/hierarchical-term-selector.js.map +1 -1
  89. package/build-module/components/post-url/index.js +7 -6
  90. package/build-module/components/post-url/index.js.map +1 -1
  91. package/build-module/components/sidebar/post-summary.js +10 -7
  92. package/build-module/components/sidebar/post-summary.js.map +1 -1
  93. package/build-module/components/template-content-panel/index.js +1 -1
  94. package/build-module/components/template-content-panel/index.js.map +1 -1
  95. package/build-module/dataviews/actions/duplicate-pattern.js +39 -0
  96. package/build-module/dataviews/actions/duplicate-pattern.js.map +1 -0
  97. package/build-module/dataviews/actions/duplicate-post.js +139 -0
  98. package/build-module/dataviews/actions/duplicate-post.js.map +1 -0
  99. package/build-module/dataviews/actions/duplicate-post.native.js +3 -0
  100. package/build-module/dataviews/actions/duplicate-post.native.js.map +1 -0
  101. package/build-module/dataviews/actions/duplicate-template-part.js +58 -0
  102. package/build-module/dataviews/actions/duplicate-template-part.js.map +1 -0
  103. package/build-module/dataviews/actions/rename-post.js +118 -0
  104. package/build-module/dataviews/actions/rename-post.js.map +1 -0
  105. package/build-module/dataviews/actions/reorder-page.js +111 -0
  106. package/build-module/dataviews/actions/reorder-page.js.map +1 -0
  107. package/build-module/dataviews/actions/reorder-page.native.js +3 -0
  108. package/build-module/dataviews/actions/reorder-page.native.js.map +1 -0
  109. package/build-module/dataviews/actions/reset-post.js +1 -1
  110. package/build-module/dataviews/actions/reset-post.js.map +1 -1
  111. package/build-module/dataviews/actions/utils.js +7 -1
  112. package/build-module/dataviews/actions/utils.js.map +1 -1
  113. package/build-module/dataviews/actions/view-post-revisions.js +43 -0
  114. package/build-module/dataviews/actions/view-post-revisions.js.map +1 -0
  115. package/build-module/dataviews/actions/view-post.js +30 -0
  116. package/build-module/dataviews/actions/view-post.js.map +1 -0
  117. package/build-module/dataviews/fields/index.js +26 -0
  118. package/build-module/dataviews/fields/index.js.map +1 -0
  119. package/build-module/dataviews/store/private-actions.js +16 -2
  120. package/build-module/dataviews/store/private-actions.js.map +1 -1
  121. package/build-module/dataviews/types.js.map +1 -1
  122. package/build-module/private-apis.js +2 -0
  123. package/build-module/private-apis.js.map +1 -1
  124. package/build-module/store/private-actions.js +1 -1
  125. package/build-module/store/private-actions.js.map +1 -1
  126. package/build-module/store/utils/is-template-revertable.js +1 -1
  127. package/build-module/store/utils/is-template-revertable.js.map +1 -1
  128. package/build-style/style-rtl.css +2 -31
  129. package/build-style/style.css +2 -31
  130. package/build-types/components/create-template-part-modal/index.d.ts.map +1 -1
  131. package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
  132. package/build-types/components/inserter-sidebar/index.d.ts.map +1 -1
  133. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  134. package/build-types/components/post-actions/actions.d.ts +1 -26
  135. package/build-types/components/post-actions/actions.d.ts.map +1 -1
  136. package/build-types/components/post-actions/index.d.ts +3 -2
  137. package/build-types/components/post-actions/index.d.ts.map +1 -1
  138. package/build-types/components/post-card-panel/index.d.ts +4 -2
  139. package/build-types/components/post-card-panel/index.d.ts.map +1 -1
  140. package/build-types/components/post-slug/index.d.ts.map +1 -1
  141. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts +1 -17
  142. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  143. package/build-types/components/post-url/index.d.ts.map +1 -1
  144. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  145. package/build-types/components/template-content-panel/index.d.ts.map +1 -1
  146. package/build-types/dataviews/actions/duplicate-pattern.d.ts +5 -0
  147. package/build-types/dataviews/actions/duplicate-pattern.d.ts.map +1 -0
  148. package/build-types/dataviews/actions/duplicate-post.d.ts +5 -0
  149. package/build-types/dataviews/actions/duplicate-post.d.ts.map +1 -0
  150. package/build-types/dataviews/actions/duplicate-post.native.d.ts +3 -0
  151. package/build-types/dataviews/actions/duplicate-post.native.d.ts.map +1 -0
  152. package/build-types/dataviews/actions/duplicate-template-part.d.ts +5 -0
  153. package/build-types/dataviews/actions/duplicate-template-part.d.ts.map +1 -0
  154. package/build-types/dataviews/actions/rename-post.d.ts +5 -0
  155. package/build-types/dataviews/actions/rename-post.d.ts.map +1 -0
  156. package/build-types/dataviews/actions/reorder-page.d.ts +8 -0
  157. package/build-types/dataviews/actions/reorder-page.d.ts.map +1 -0
  158. package/build-types/dataviews/actions/reorder-page.native.d.ts +3 -0
  159. package/build-types/dataviews/actions/reorder-page.native.d.ts.map +1 -0
  160. package/build-types/dataviews/actions/reset-post.d.ts.map +1 -1
  161. package/build-types/dataviews/actions/utils.d.ts +5 -3
  162. package/build-types/dataviews/actions/utils.d.ts.map +1 -1
  163. package/build-types/dataviews/actions/view-post-revisions.d.ts +8 -0
  164. package/build-types/dataviews/actions/view-post-revisions.d.ts.map +1 -0
  165. package/build-types/dataviews/actions/view-post.d.ts +8 -0
  166. package/build-types/dataviews/actions/view-post.d.ts.map +1 -0
  167. package/build-types/dataviews/fields/index.d.ts +8 -0
  168. package/build-types/dataviews/fields/index.d.ts.map +1 -0
  169. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  170. package/build-types/dataviews/types.d.ts +57 -8
  171. package/build-types/dataviews/types.d.ts.map +1 -1
  172. package/build-types/private-apis.d.ts.map +1 -1
  173. package/build-types/store/utils/is-template-revertable.d.ts.map +1 -1
  174. package/package.json +36 -36
  175. package/src/bindings/post-meta.js +2 -2
  176. package/src/components/block-manager/style.scss +2 -2
  177. package/src/components/create-template-part-modal/index.js +1 -0
  178. package/src/components/error-boundary/style.native.scss +1 -1
  179. package/src/components/error-boundary/style.scss +1 -1
  180. package/src/components/global-styles-provider/index.js +16 -3
  181. package/src/components/inserter-sidebar/index.js +10 -4
  182. package/src/components/page-attributes/parent.js +13 -9
  183. package/src/components/post-actions/actions.js +5 -616
  184. package/src/components/post-actions/index.js +16 -20
  185. package/src/components/post-card-panel/index.js +28 -27
  186. package/src/components/post-discussion/style.scss +0 -9
  187. package/src/components/post-featured-image/index.js +2 -0
  188. package/src/components/post-format/style.scss +0 -6
  189. package/src/components/post-publish-panel/postpublish.js +8 -2
  190. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +8 -8
  191. package/src/components/post-slug/index.js +1 -0
  192. package/src/components/post-status/style.scss +0 -19
  193. package/src/components/post-taxonomies/hierarchical-term-selector.js +3 -1
  194. package/src/components/post-url/index.js +15 -9
  195. package/src/components/save-publish-panels/style.scss +3 -3
  196. package/src/components/sidebar/post-summary.js +20 -16
  197. package/src/components/site-discussion/style.scss +0 -14
  198. package/src/components/template-content-panel/index.js +4 -1
  199. package/src/dataviews/actions/duplicate-pattern.tsx +40 -0
  200. package/src/dataviews/actions/duplicate-post.native.tsx +3 -0
  201. package/src/dataviews/actions/duplicate-post.tsx +174 -0
  202. package/src/dataviews/actions/duplicate-template-part.tsx +70 -0
  203. package/src/dataviews/actions/rename-post.tsx +146 -0
  204. package/src/dataviews/actions/reorder-page.native.tsx +3 -0
  205. package/src/dataviews/actions/reorder-page.tsx +125 -0
  206. package/src/dataviews/actions/reset-post.tsx +2 -1
  207. package/src/dataviews/actions/utils.ts +14 -4
  208. package/src/dataviews/actions/view-post-revisions.tsx +47 -0
  209. package/src/dataviews/actions/view-post.tsx +30 -0
  210. package/src/dataviews/fields/index.ts +26 -0
  211. package/src/dataviews/store/private-actions.ts +42 -1
  212. package/src/dataviews/types.ts +47 -6
  213. package/src/private-apis.js +2 -0
  214. package/src/store/private-actions.js +1 -1
  215. package/src/store/utils/is-template-revertable.js +2 -1
  216. package/tsconfig.tsbuildinfo +1 -1
@@ -26,59 +26,56 @@ import {
26
26
  GLOBAL_POST_TYPES,
27
27
  } from '../../store/constants';
28
28
  import { unlock } from '../../lock-unlock';
29
+ import PostActions from '../post-actions';
29
30
 
30
- export default function PostCardPanel( { actions } ) {
31
+ export default function PostCardPanel( {
32
+ postType,
33
+ postId,
34
+ onActionPerformed,
35
+ } ) {
31
36
  const { isFrontPage, isPostsPage, title, icon, isSync } = useSelect(
32
37
  ( select ) => {
33
- const {
34
- getEditedPostAttribute,
35
- getCurrentPostType,
36
- getCurrentPostId,
37
- __experimentalGetTemplateInfo,
38
- } = select( editorStore );
39
- const { canUser } = select( coreStore );
40
- const { getEditedEntityRecord } = select( coreStore );
38
+ const { __experimentalGetTemplateInfo } = select( editorStore );
39
+ const { canUser, getEditedEntityRecord } = select( coreStore );
41
40
  const siteSettings = canUser( 'read', {
42
41
  kind: 'root',
43
42
  name: 'site',
44
43
  } )
45
44
  ? getEditedEntityRecord( 'root', 'site' )
46
45
  : undefined;
47
- const _type = getCurrentPostType();
48
- const _id = getCurrentPostId();
49
- const _record = getEditedEntityRecord( 'postType', _type, _id );
46
+ const _record = getEditedEntityRecord(
47
+ 'postType',
48
+ postType,
49
+ postId
50
+ );
50
51
  const _templateInfo =
51
52
  [ TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE ].includes(
52
- _type
53
+ postType
53
54
  ) && __experimentalGetTemplateInfo( _record );
54
55
  let _isSync = false;
55
- if ( GLOBAL_POST_TYPES.includes( _type ) ) {
56
- if ( PATTERN_POST_TYPE === _type ) {
56
+ if ( GLOBAL_POST_TYPES.includes( postType ) ) {
57
+ if ( PATTERN_POST_TYPE === postType ) {
57
58
  // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
58
59
  const currentSyncStatus =
59
- getEditedPostAttribute( 'meta' )
60
- ?.wp_pattern_sync_status === 'unsynced'
60
+ _record?.meta?.wp_pattern_sync_status === 'unsynced'
61
61
  ? 'unsynced'
62
- : getEditedPostAttribute(
63
- 'wp_pattern_sync_status'
64
- );
62
+ : _record?.wp_pattern_sync_status;
65
63
  _isSync = currentSyncStatus !== 'unsynced';
66
64
  } else {
67
65
  _isSync = true;
68
66
  }
69
67
  }
70
68
  return {
71
- title:
72
- _templateInfo?.title || getEditedPostAttribute( 'title' ),
73
- icon: unlock( select( editorStore ) ).getPostIcon( _type, {
69
+ title: _templateInfo?.title || _record?.title,
70
+ icon: unlock( select( editorStore ) ).getPostIcon( postType, {
74
71
  area: _record?.area,
75
72
  } ),
76
73
  isSync: _isSync,
77
- isFrontPage: siteSettings?.page_on_front === _id,
78
- isPostsPage: siteSettings?.page_for_posts === _id,
74
+ isFrontPage: siteSettings?.page_on_front === postId,
75
+ isPostsPage: siteSettings?.page_for_posts === postId,
79
76
  };
80
77
  },
81
- []
78
+ [ postId, postType ]
82
79
  );
83
80
  return (
84
81
  <div className="editor-post-card-panel">
@@ -113,7 +110,11 @@ export default function PostCardPanel( { actions } ) {
113
110
  </span>
114
111
  ) }
115
112
  </Text>
116
- { actions }
113
+ <PostActions
114
+ postType={ postType }
115
+ postId={ postId }
116
+ onActionPerformed={ onActionPerformed }
117
+ />
117
118
  </HStack>
118
119
  </div>
119
120
  );
@@ -2,15 +2,6 @@
2
2
  // sidebar width - popover padding - form margin
3
3
  min-width: $sidebar-width - $grid-unit-20 - $grid-unit-20;
4
4
  margin: $grid-unit-10;
5
-
6
- .components-radio-control__option {
7
- align-items: flex-start;
8
- }
9
-
10
- .components-radio-control__label .components-text {
11
- display: block;
12
- margin-top: $grid-unit-05;
13
- }
14
5
  }
15
6
  .editor-post-discussion__panel-toggle {
16
7
 
@@ -180,6 +180,8 @@ function PostFeaturedImage( {
180
180
  : `editor-post-featured-image-${ featuredImageId }-describedby`
181
181
  }
182
182
  aria-haspopup="dialog"
183
+ disabled={ isLoading }
184
+ accessibleWhenDisabled
183
185
  >
184
186
  { !! featuredImageId && media && (
185
187
  <img
@@ -7,9 +7,3 @@
7
7
  min-width: $sidebar-width - $grid-unit-20 - $grid-unit-20;
8
8
  margin: $grid-unit-10;
9
9
  }
10
-
11
- .editor-post-format__options {
12
- .components-base-control__field > .components-v-stack {
13
- gap: $grid-unit-15;
14
- }
15
- }
@@ -44,7 +44,7 @@ const getFuturePostUrl = ( post ) => {
44
44
  function CopyButton( { text, onCopy, children } ) {
45
45
  const ref = useCopyToClipboard( text, onCopy );
46
46
  return (
47
- <Button variant="secondary" ref={ ref }>
47
+ <Button __next40pxDefaultSize variant="secondary" ref={ ref }>
48
48
  { children }
49
49
  </Button>
50
50
  );
@@ -122,6 +122,7 @@ class PostPublishPanelPostpublish extends Component {
122
122
  </p>
123
123
  <div className="post-publish-panel__postpublish-post-address-container">
124
124
  <TextControl
125
+ __next40pxDefaultSize
125
126
  __nextHasNoMarginBottom
126
127
  className="post-publish-panel__postpublish-post-address"
127
128
  readOnly
@@ -145,12 +146,17 @@ class PostPublishPanelPostpublish extends Component {
145
146
 
146
147
  <div className="post-publish-panel__postpublish-buttons">
147
148
  { ! isScheduled && (
148
- <Button variant="primary" href={ link }>
149
+ <Button
150
+ variant="primary"
151
+ href={ link }
152
+ __next40pxDefaultSize
153
+ >
149
154
  { viewPostLabel }
150
155
  </Button>
151
156
  ) }
152
157
  <Button
153
158
  variant={ isScheduled ? 'primary' : 'secondary' }
159
+ __next40pxDefaultSize
154
160
  href={ addLink }
155
161
  >
156
162
  { addNewPostLabel }
@@ -120,7 +120,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
120
120
  post address
121
121
  </label>
122
122
  <input
123
- class="components-text-control__input"
123
+ class="components-text-control__input is-next-40px-default-size"
124
124
  id="inspector-text-control-0"
125
125
  readonly=""
126
126
  type="text"
@@ -132,7 +132,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
132
132
  class="post-publish-panel__postpublish-post-address__copy-button-wrap"
133
133
  >
134
134
  <button
135
- class="components-button is-secondary"
135
+ class="components-button is-next-40px-default-size is-secondary"
136
136
  type="button"
137
137
  >
138
138
  Copy
@@ -143,11 +143,11 @@ exports[`PostPublishPanel should render the post-publish panel if the post is pu
143
143
  class="post-publish-panel__postpublish-buttons"
144
144
  >
145
145
  <a
146
- class="components-button is-primary"
146
+ class="components-button is-next-40px-default-size is-primary"
147
147
  href="https://wordpress.local/sample-page/"
148
148
  />
149
149
  <a
150
- class="components-button is-secondary"
150
+ class="components-button is-next-40px-default-size is-secondary"
151
151
  href="post-new.php?"
152
152
  />
153
153
  </div>
@@ -312,7 +312,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
312
312
  post address
313
313
  </label>
314
314
  <input
315
- class="components-text-control__input"
315
+ class="components-text-control__input is-next-40px-default-size"
316
316
  id="inspector-text-control-1"
317
317
  readonly=""
318
318
  type="text"
@@ -324,7 +324,7 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
324
324
  class="post-publish-panel__postpublish-post-address__copy-button-wrap"
325
325
  >
326
326
  <button
327
- class="components-button is-secondary"
327
+ class="components-button is-next-40px-default-size is-secondary"
328
328
  type="button"
329
329
  >
330
330
  Copy
@@ -335,11 +335,11 @@ exports[`PostPublishPanel should render the post-publish panel if the post is sc
335
335
  class="post-publish-panel__postpublish-buttons"
336
336
  >
337
337
  <a
338
- class="components-button is-primary"
338
+ class="components-button is-next-40px-default-size is-primary"
339
339
  href="https://wordpress.local/sample-page/"
340
340
  />
341
341
  <a
342
- class="components-button is-secondary"
342
+ class="components-button is-next-40px-default-size is-secondary"
343
343
  href="post-new.php?"
344
344
  />
345
345
  </div>
@@ -24,6 +24,7 @@ function PostSlugControl() {
24
24
 
25
25
  return (
26
26
  <TextControl
27
+ __next40pxDefaultSize
27
28
  __nextHasNoMarginBottom
28
29
  label={ __( 'Slug' ) }
29
30
  autoComplete="off"
@@ -18,25 +18,6 @@
18
18
  padding: $grid-unit-20;
19
19
  }
20
20
 
21
- .editor-change-status__options {
22
- .components-base-control__field > .components-v-stack {
23
- gap: $grid-unit-15;
24
- }
25
-
26
- // TODO: it's not great to override component styles.. This might be resolved
27
- // by the new radio control component.
28
- .components-radio-control__option {
29
- align-items: flex-start;
30
- }
31
-
32
- label {
33
- .components-text {
34
- display: block;
35
- margin-top: $grid-unit-05;
36
- }
37
- }
38
- }
39
-
40
21
  .editor-change-status__password-legend {
41
22
  padding: 0;
42
23
  margin-bottom: $grid-unit-10;
@@ -12,6 +12,7 @@ import {
12
12
  withFilters,
13
13
  Flex,
14
14
  FlexItem,
15
+ SearchControl,
15
16
  } from '@wordpress/components';
16
17
  import { useDispatch, useSelect } from '@wordpress/data';
17
18
  import { useDebounce } from '@wordpress/compose';
@@ -406,7 +407,8 @@ export function HierarchicalTermSelector( { slug } ) {
406
407
  return (
407
408
  <Flex direction="column" gap="4">
408
409
  { showFilter && (
409
- <TextControl
410
+ <SearchControl
411
+ __next40pxDefaultSize
410
412
  __nextHasNoMarginBottom
411
413
  label={ filterLabel }
412
414
  value={ filterValue }
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { useSelect, useDispatch } from '@wordpress/data';
5
5
  import { safeDecodeURIComponent, cleanForSlug } from '@wordpress/url';
6
- import { useState } from '@wordpress/element';
6
+ import { useState, createInterpolateElement } from '@wordpress/element';
7
7
  import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
8
8
  import { __ } from '@wordpress/i18n';
9
9
  import {
@@ -83,14 +83,20 @@ export default function PostURL( { onClose } ) {
83
83
  <VStack spacing={ 3 }>
84
84
  { isEditable && (
85
85
  <div>
86
- { __( 'Customize the last part of the URL. ' ) }
87
- <ExternalLink
88
- href={ __(
89
- 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
90
- ) }
91
- >
92
- { __( 'Learn more.' ) }
93
- </ExternalLink>
86
+ { createInterpolateElement(
87
+ __(
88
+ 'Customize the last part of the URL. <a>Learn more.</a>'
89
+ ),
90
+ {
91
+ a: (
92
+ <ExternalLink
93
+ href={ __(
94
+ 'https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'
95
+ ) }
96
+ />
97
+ ),
98
+ }
99
+ ) }
94
100
  </div>
95
101
  ) }
96
102
  <div>
@@ -3,7 +3,7 @@
3
3
  .editor-layout__toggle-sidebar-panel,
4
4
  .editor-layout__toggle-entities-saved-states-panel {
5
5
  z-index: z-index(".editor-layout__toggle-sidebar-panel");
6
- position: fixed !important; // Need to override the default relative positionning
6
+ position: fixed !important; // Necessary to override the default relative positioning.
7
7
  top: -9999em;
8
8
  bottom: auto;
9
9
  left: auto;
@@ -11,8 +11,8 @@
11
11
  box-sizing: border-box;
12
12
  width: $sidebar-width;
13
13
  background-color: $white;
14
- border: 1px dotted $gray-300;
15
- height: auto !important; // Need to override the default sidebar positionnings
14
+ border: $border-width dotted $gray-300;
15
+ height: auto !important; // Necessary to override the default sidebar positioning.
16
16
  padding: $grid-unit-30;
17
17
  display: flex;
18
18
  justify-content: center;
@@ -8,7 +8,6 @@ import { useSelect } from '@wordpress/data';
8
8
  * Internal dependencies
9
9
  */
10
10
  import PluginPostStatusInfo from '../plugin-post-status-info';
11
- import PostActions from '../post-actions';
12
11
  import PostAuthorPanel from '../post-author/panel';
13
12
  import PostCardPanel from '../post-card-panel';
14
13
  import PostContentInformation from '../post-content-information';
@@ -36,16 +35,23 @@ import { PrivatePostLastRevision } from '../post-last-revision';
36
35
  const PANEL_NAME = 'post-status';
37
36
 
38
37
  export default function PostSummary( { onActionPerformed } ) {
39
- const { isRemovedPostStatusPanel } = useSelect( ( select ) => {
40
- // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
41
- // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
42
- const { isEditorPanelRemoved, getCurrentPostType } =
43
- select( editorStore );
44
- return {
45
- isRemovedPostStatusPanel: isEditorPanelRemoved( PANEL_NAME ),
46
- postType: getCurrentPostType(),
47
- };
48
- }, [] );
38
+ const { isRemovedPostStatusPanel, postType, postId } = useSelect(
39
+ ( select ) => {
40
+ // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
41
+ // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
42
+ const {
43
+ isEditorPanelRemoved,
44
+ getCurrentPostType,
45
+ getCurrentPostId,
46
+ } = select( editorStore );
47
+ return {
48
+ isRemovedPostStatusPanel: isEditorPanelRemoved( PANEL_NAME ),
49
+ postType: getCurrentPostType(),
50
+ postId: getCurrentPostId(),
51
+ };
52
+ },
53
+ []
54
+ );
49
55
 
50
56
  return (
51
57
  <PostPanelSection className="editor-post-summary">
@@ -54,11 +60,9 @@ export default function PostSummary( { onActionPerformed } ) {
54
60
  <>
55
61
  <VStack spacing={ 4 }>
56
62
  <PostCardPanel
57
- actions={
58
- <PostActions
59
- onActionPerformed={ onActionPerformed }
60
- />
61
- }
63
+ postType={ postType }
64
+ postId={ postId }
65
+ onActionPerformed={ onActionPerformed }
62
66
  />
63
67
  <PostFeaturedImagePanel withPanelBody={ false } />
64
68
  <PostExcerptPanel />
@@ -3,17 +3,3 @@
3
3
  padding: $grid-unit-20;
4
4
  }
5
5
 
6
- .editor-site-discussion__options {
7
- // TODO: it's not great to override component styles.. This might be resolved
8
- // by the new radio control component.
9
- .components-radio-control__option {
10
- align-items: flex-start;
11
- }
12
-
13
- label {
14
- .components-text {
15
- display: block;
16
- margin-top: $grid-unit-05;
17
- }
18
- }
19
- }
@@ -59,7 +59,10 @@ export default function TemplateContentPanel() {
59
59
 
60
60
  const { enableComplementaryArea } = useDispatch( interfaceStore );
61
61
 
62
- if ( renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE ) {
62
+ if (
63
+ ( renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE ) ||
64
+ clientIds.length === 0
65
+ ) {
63
66
  return null;
64
67
  }
65
68
 
@@ -0,0 +1,40 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { _x } from '@wordpress/i18n';
5
+ // @ts-ignore
6
+ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
7
+ import type { Action } from '@wordpress/dataviews';
8
+
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+ import { unlock } from '../../lock-unlock';
13
+ import type { Pattern } from '../types';
14
+
15
+ // Patterns.
16
+ const { CreatePatternModalContents, useDuplicatePatternProps } =
17
+ unlock( patternsPrivateApis );
18
+
19
+ const duplicatePattern: Action< Pattern > = {
20
+ id: 'duplicate-pattern',
21
+ label: _x( 'Duplicate', 'action label' ),
22
+ isEligible: ( item ) => item.type !== 'wp_template_part',
23
+ modalHeader: _x( 'Duplicate pattern', 'action label' ),
24
+ RenderModal: ( { items, closeModal } ) => {
25
+ const [ item ] = items;
26
+ const duplicatedProps = useDuplicatePatternProps( {
27
+ pattern: item,
28
+ onSuccess: () => closeModal?.(),
29
+ } );
30
+ return (
31
+ <CreatePatternModalContents
32
+ onClose={ closeModal }
33
+ confirmLabel={ _x( 'Duplicate', 'action label' ) }
34
+ { ...duplicatedProps }
35
+ />
36
+ );
37
+ },
38
+ };
39
+
40
+ export default duplicatePattern;
@@ -0,0 +1,3 @@
1
+ const duplicatePost = undefined;
2
+
3
+ export default duplicatePost;
@@ -0,0 +1,174 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useDispatch } from '@wordpress/data';
5
+ import { decodeEntities } from '@wordpress/html-entities';
6
+ import { store as coreStore } from '@wordpress/core-data';
7
+ import { __, sprintf, _x } from '@wordpress/i18n';
8
+ import { store as noticesStore } from '@wordpress/notices';
9
+ import { useState } from '@wordpress/element';
10
+ import { DataForm } from '@wordpress/dataviews';
11
+ import {
12
+ Button,
13
+ __experimentalHStack as HStack,
14
+ __experimentalVStack as VStack,
15
+ } from '@wordpress/components';
16
+ import type { Action } from '@wordpress/dataviews';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import { getItemTitle } from '../../dataviews/actions/utils';
22
+ import type { CoreDataError, BasePost } from '../types';
23
+ import { titleField } from '../fields';
24
+
25
+ const fields = [ titleField ];
26
+ const formDuplicateAction = {
27
+ fields: [ 'title' ],
28
+ };
29
+
30
+ const duplicatePost: Action< BasePost > = {
31
+ id: 'duplicate-post',
32
+ label: _x( 'Duplicate', 'action label' ),
33
+ isEligible( { status } ) {
34
+ return status !== 'trash';
35
+ },
36
+ RenderModal: ( { items, closeModal, onActionPerformed } ) => {
37
+ const [ item, setItem ] = useState< BasePost >( {
38
+ ...items[ 0 ],
39
+ title: sprintf(
40
+ /* translators: %s: Existing template title */
41
+ __( '%s (Copy)' ),
42
+ getItemTitle( items[ 0 ] )
43
+ ),
44
+ } );
45
+
46
+ const [ isCreatingPage, setIsCreatingPage ] = useState( false );
47
+ const { saveEntityRecord } = useDispatch( coreStore );
48
+ const { createSuccessNotice, createErrorNotice } =
49
+ useDispatch( noticesStore );
50
+
51
+ async function createPage( event: React.FormEvent ) {
52
+ event.preventDefault();
53
+
54
+ if ( isCreatingPage ) {
55
+ return;
56
+ }
57
+
58
+ const newItemOject = {
59
+ status: 'draft',
60
+ title: item.title,
61
+ slug: item.title || __( 'No title' ),
62
+ comment_status: item.comment_status,
63
+ content:
64
+ typeof item.content === 'string'
65
+ ? item.content
66
+ : item.content.raw,
67
+ excerpt:
68
+ typeof item.excerpt === 'string'
69
+ ? item.excerpt
70
+ : item.excerpt?.raw,
71
+ meta: item.meta,
72
+ parent: item.parent,
73
+ password: item.password,
74
+ template: item.template,
75
+ format: item.format,
76
+ featured_media: item.featured_media,
77
+ menu_order: item.menu_order,
78
+ ping_status: item.ping_status,
79
+ };
80
+ const assignablePropertiesPrefix = 'wp:action-assign-';
81
+ // Get all the properties that the current user is able to assign normally author, categories, tags,
82
+ // and custom taxonomies.
83
+ const assignableProperties = Object.keys( item?._links || {} )
84
+ .filter( ( property ) =>
85
+ property.startsWith( assignablePropertiesPrefix )
86
+ )
87
+ .map( ( property ) =>
88
+ property.slice( assignablePropertiesPrefix.length )
89
+ );
90
+ assignableProperties.forEach( ( property ) => {
91
+ if ( item.hasOwnProperty( property ) ) {
92
+ // @ts-ignore
93
+ newItemOject[ property ] = item[ property ];
94
+ }
95
+ } );
96
+ setIsCreatingPage( true );
97
+ try {
98
+ const newItem = await saveEntityRecord(
99
+ 'postType',
100
+ item.type,
101
+ newItemOject,
102
+ { throwOnError: true }
103
+ );
104
+
105
+ createSuccessNotice(
106
+ sprintf(
107
+ // translators: %s: Title of the created template e.g: "Category".
108
+ __( '"%s" successfully created.' ),
109
+ decodeEntities( newItem.title?.rendered || item.title )
110
+ ),
111
+ {
112
+ id: 'duplicate-post-action',
113
+ type: 'snackbar',
114
+ }
115
+ );
116
+
117
+ if ( onActionPerformed ) {
118
+ onActionPerformed( [ newItem ] );
119
+ }
120
+ } catch ( error ) {
121
+ const typedError = error as CoreDataError;
122
+ const errorMessage =
123
+ typedError.message && typedError.code !== 'unknown_error'
124
+ ? typedError.message
125
+ : __( 'An error occurred while duplicating the page.' );
126
+
127
+ createErrorNotice( errorMessage, {
128
+ type: 'snackbar',
129
+ } );
130
+ } finally {
131
+ setIsCreatingPage( false );
132
+ closeModal?.();
133
+ }
134
+ }
135
+
136
+ return (
137
+ <form onSubmit={ createPage }>
138
+ <VStack spacing={ 3 }>
139
+ <DataForm
140
+ data={ item }
141
+ fields={ fields }
142
+ form={ formDuplicateAction }
143
+ onChange={ ( changes ) =>
144
+ setItem( ( prev ) => ( {
145
+ ...prev,
146
+ ...changes,
147
+ } ) )
148
+ }
149
+ />
150
+ <HStack spacing={ 2 } justify="end">
151
+ <Button
152
+ variant="tertiary"
153
+ onClick={ closeModal }
154
+ __next40pxDefaultSize
155
+ >
156
+ { __( 'Cancel' ) }
157
+ </Button>
158
+ <Button
159
+ variant="primary"
160
+ type="submit"
161
+ isBusy={ isCreatingPage }
162
+ aria-disabled={ isCreatingPage }
163
+ __next40pxDefaultSize
164
+ >
165
+ { _x( 'Duplicate', 'action label' ) }
166
+ </Button>
167
+ </HStack>
168
+ </VStack>
169
+ </form>
170
+ );
171
+ },
172
+ };
173
+
174
+ export default duplicatePost;