@wordpress/editor 14.49.1 → 14.51.1-next.v.202607070741.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 (262) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/components/collab-sidebar/format.cjs +83 -0
  3. package/build/components/collab-sidebar/format.cjs.map +7 -0
  4. package/build/components/collab-sidebar/hooks.cjs +117 -16
  5. package/build/components/collab-sidebar/hooks.cjs.map +2 -2
  6. package/build/components/collab-sidebar/index.cjs +18 -2
  7. package/build/components/collab-sidebar/index.cjs.map +2 -2
  8. package/build/components/collab-sidebar/note-highlight-styles.cjs +67 -0
  9. package/build/components/collab-sidebar/note-highlight-styles.cjs.map +7 -0
  10. package/build/components/collab-sidebar/utils.cjs +139 -0
  11. package/build/components/collab-sidebar/utils.cjs.map +2 -2
  12. package/build/components/collaborators-presence/use-collaborator-notifications.cjs +55 -30
  13. package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
  14. package/build/components/commands/index.cjs +99 -3
  15. package/build/components/commands/index.cjs.map +2 -2
  16. package/build/components/document-bar/index.cjs +28 -34
  17. package/build/components/document-bar/index.cjs.map +2 -2
  18. package/build/components/entities-saved-states/index.cjs +1 -4
  19. package/build/components/entities-saved-states/index.cjs.map +2 -2
  20. package/build/components/header/index.cjs +1 -8
  21. package/build/components/header/index.cjs.map +2 -2
  22. package/build/components/media-categories/index.cjs +92 -6
  23. package/build/components/media-categories/index.cjs.map +2 -2
  24. package/build/components/page-attributes/parent.cjs +0 -1
  25. package/build/components/page-attributes/parent.cjs.map +2 -2
  26. package/build/components/post-author/combobox.cjs +0 -1
  27. package/build/components/post-author/combobox.cjs.map +2 -2
  28. package/build/components/post-author/select.cjs +0 -1
  29. package/build/components/post-author/select.cjs.map +2 -2
  30. package/build/components/post-preview-button/index.cjs +29 -2
  31. package/build/components/post-preview-button/index.cjs.map +2 -2
  32. package/build/components/post-publish-panel/maybe-upload-media.cjs +15 -26
  33. package/build/components/post-publish-panel/maybe-upload-media.cjs.map +3 -3
  34. package/build/components/post-revisions-preview/revisions-slider.cjs +3 -1
  35. package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
  36. package/build/components/post-taxonomies/flat-term-selector.cjs +0 -1
  37. package/build/components/post-taxonomies/flat-term-selector.cjs.map +2 -2
  38. package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -2
  39. package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
  40. package/build/components/post-template/classic-theme.cjs +0 -1
  41. package/build/components/post-template/classic-theme.cjs.map +2 -2
  42. package/build/components/preferences-modal/index.cjs +54 -28
  43. package/build/components/preferences-modal/index.cjs.map +2 -2
  44. package/build/components/preview-dropdown/index.cjs +38 -9
  45. package/build/components/preview-dropdown/index.cjs.map +3 -3
  46. package/build/components/provider/use-block-editor-settings.cjs +23 -9
  47. package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
  48. package/build/components/resizable-editor/index.cjs +54 -9
  49. package/build/components/resizable-editor/index.cjs.map +3 -3
  50. package/build/components/sidebar/dataform-post-summary.cjs +5 -1
  51. package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
  52. package/build/components/sidebar/index.cjs +29 -38
  53. package/build/components/sidebar/index.cjs.map +3 -3
  54. package/build/components/sidebar/post-summary.cjs +0 -13
  55. package/build/components/sidebar/post-summary.cjs.map +3 -3
  56. package/build/components/visual-editor/index.cjs +15 -11
  57. package/build/components/visual-editor/index.cjs.map +3 -3
  58. package/build/dataviews/store/private-actions.cjs +24 -19
  59. package/build/dataviews/store/private-actions.cjs.map +2 -2
  60. package/build/store/actions.cjs +5 -3
  61. package/build/store/actions.cjs.map +2 -2
  62. package/build/store/constants.cjs +26 -0
  63. package/build/store/constants.cjs.map +2 -2
  64. package/build/store/private-actions.cjs +25 -18
  65. package/build/store/private-actions.cjs.map +3 -3
  66. package/build/store/private-selectors.cjs +5 -0
  67. package/build/store/private-selectors.cjs.map +2 -2
  68. package/build/store/reducer.cjs +6 -6
  69. package/build/store/reducer.cjs.map +2 -2
  70. package/build/store/selectors.cjs +3 -1
  71. package/build/store/selectors.cjs.map +2 -2
  72. package/build/utils/device-type.cjs +52 -0
  73. package/build/utils/device-type.cjs.map +7 -0
  74. package/build/utils/media-sideload-from-url/index.cjs +63 -0
  75. package/build/utils/media-sideload-from-url/index.cjs.map +7 -0
  76. package/build-module/components/collab-sidebar/format.mjs +57 -0
  77. package/build-module/components/collab-sidebar/format.mjs.map +7 -0
  78. package/build-module/components/collab-sidebar/hooks.mjs +121 -16
  79. package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
  80. package/build-module/components/collab-sidebar/index.mjs +21 -5
  81. package/build-module/components/collab-sidebar/index.mjs.map +2 -2
  82. package/build-module/components/collab-sidebar/note-highlight-styles.mjs +41 -0
  83. package/build-module/components/collab-sidebar/note-highlight-styles.mjs.map +7 -0
  84. package/build-module/components/collab-sidebar/utils.mjs +133 -0
  85. package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
  86. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +55 -30
  87. package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
  88. package/build-module/components/commands/index.mjs +99 -3
  89. package/build-module/components/commands/index.mjs.map +2 -2
  90. package/build-module/components/document-bar/index.mjs +28 -34
  91. package/build-module/components/document-bar/index.mjs.map +2 -2
  92. package/build-module/components/entities-saved-states/index.mjs +1 -4
  93. package/build-module/components/entities-saved-states/index.mjs.map +2 -2
  94. package/build-module/components/header/index.mjs +1 -13
  95. package/build-module/components/header/index.mjs.map +2 -2
  96. package/build-module/components/media-categories/index.mjs +93 -7
  97. package/build-module/components/media-categories/index.mjs.map +2 -2
  98. package/build-module/components/page-attributes/parent.mjs +0 -1
  99. package/build-module/components/page-attributes/parent.mjs.map +2 -2
  100. package/build-module/components/post-author/combobox.mjs +0 -1
  101. package/build-module/components/post-author/combobox.mjs.map +2 -2
  102. package/build-module/components/post-author/select.mjs +0 -1
  103. package/build-module/components/post-author/select.mjs.map +2 -2
  104. package/build-module/components/post-preview-button/index.mjs +29 -2
  105. package/build-module/components/post-preview-button/index.mjs.map +2 -2
  106. package/build-module/components/post-publish-panel/maybe-upload-media.mjs +19 -27
  107. package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +2 -2
  108. package/build-module/components/post-revisions-preview/revisions-slider.mjs +3 -1
  109. package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
  110. package/build-module/components/post-taxonomies/flat-term-selector.mjs +0 -1
  111. package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
  112. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -2
  113. package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
  114. package/build-module/components/post-template/classic-theme.mjs +0 -1
  115. package/build-module/components/post-template/classic-theme.mjs.map +2 -2
  116. package/build-module/components/preferences-modal/index.mjs +54 -28
  117. package/build-module/components/preferences-modal/index.mjs.map +2 -2
  118. package/build-module/components/preview-dropdown/index.mjs +38 -9
  119. package/build-module/components/preview-dropdown/index.mjs.map +2 -2
  120. package/build-module/components/provider/use-block-editor-settings.mjs +23 -9
  121. package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
  122. package/build-module/components/resizable-editor/index.mjs +55 -10
  123. package/build-module/components/resizable-editor/index.mjs.map +2 -2
  124. package/build-module/components/sidebar/dataform-post-summary.mjs +6 -2
  125. package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
  126. package/build-module/components/sidebar/index.mjs +29 -42
  127. package/build-module/components/sidebar/index.mjs.map +2 -2
  128. package/build-module/components/sidebar/post-summary.mjs +0 -13
  129. package/build-module/components/sidebar/post-summary.mjs.map +2 -2
  130. package/build-module/components/visual-editor/index.mjs +16 -13
  131. package/build-module/components/visual-editor/index.mjs.map +2 -2
  132. package/build-module/dataviews/store/private-actions.mjs +26 -19
  133. package/build-module/dataviews/store/private-actions.mjs.map +2 -2
  134. package/build-module/store/actions.mjs +5 -3
  135. package/build-module/store/actions.mjs.map +2 -2
  136. package/build-module/store/constants.mjs +25 -0
  137. package/build-module/store/constants.mjs.map +2 -2
  138. package/build-module/store/private-actions.mjs +27 -17
  139. package/build-module/store/private-actions.mjs.map +2 -2
  140. package/build-module/store/private-selectors.mjs +4 -0
  141. package/build-module/store/private-selectors.mjs.map +2 -2
  142. package/build-module/store/reducer.mjs +5 -5
  143. package/build-module/store/reducer.mjs.map +2 -2
  144. package/build-module/store/selectors.mjs +3 -1
  145. package/build-module/store/selectors.mjs.map +2 -2
  146. package/build-module/utils/device-type.mjs +25 -0
  147. package/build-module/utils/device-type.mjs.map +7 -0
  148. package/build-module/utils/media-sideload-from-url/index.mjs +32 -0
  149. package/build-module/utils/media-sideload-from-url/index.mjs.map +7 -0
  150. package/build-style/style-rtl.css +84 -39
  151. package/build-style/style.css +84 -39
  152. package/build-types/components/collab-sidebar/format.d.ts +17 -0
  153. package/build-types/components/collab-sidebar/format.d.ts.map +1 -0
  154. package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
  155. package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
  156. package/build-types/components/collab-sidebar/note-highlight-styles.d.ts +31 -0
  157. package/build-types/components/collab-sidebar/note-highlight-styles.d.ts.map +1 -0
  158. package/build-types/components/collab-sidebar/utils.d.ts +82 -2
  159. package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
  160. package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
  161. package/build-types/components/commands/index.d.ts.map +1 -1
  162. package/build-types/components/document-bar/index.d.ts.map +1 -1
  163. package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
  164. package/build-types/components/header/index.d.ts.map +1 -1
  165. package/build-types/components/media-categories/index.d.ts +12 -3
  166. package/build-types/components/media-categories/index.d.ts.map +1 -1
  167. package/build-types/components/page-attributes/parent.d.ts.map +1 -1
  168. package/build-types/components/post-author/combobox.d.ts.map +1 -1
  169. package/build-types/components/post-author/select.d.ts.map +1 -1
  170. package/build-types/components/post-preview-button/index.d.ts.map +1 -1
  171. package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
  172. package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
  173. package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
  174. package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
  175. package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
  176. package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
  177. package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
  178. package/build-types/components/resizable-editor/index.d.ts.map +1 -1
  179. package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
  180. package/build-types/components/sidebar/index.d.ts.map +1 -1
  181. package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
  182. package/build-types/components/visual-editor/index.d.ts.map +1 -1
  183. package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
  184. package/build-types/store/actions.d.ts.map +1 -1
  185. package/build-types/store/constants.d.ts +6 -0
  186. package/build-types/store/constants.d.ts.map +1 -1
  187. package/build-types/store/index.d.ts +2 -2
  188. package/build-types/store/private-actions.d.ts +9 -15
  189. package/build-types/store/private-actions.d.ts.map +1 -1
  190. package/build-types/store/private-selectors.d.ts +7 -0
  191. package/build-types/store/private-selectors.d.ts.map +1 -1
  192. package/build-types/store/reducer.d.ts +6 -7
  193. package/build-types/store/reducer.d.ts.map +1 -1
  194. package/build-types/store/selectors.d.ts +1 -1
  195. package/build-types/store/selectors.d.ts.map +1 -1
  196. package/build-types/utils/device-type.d.ts +23 -0
  197. package/build-types/utils/device-type.d.ts.map +1 -0
  198. package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
  199. package/build-types/utils/media-sideload-from-url/index.d.ts +18 -0
  200. package/build-types/utils/media-sideload-from-url/index.d.ts.map +1 -0
  201. package/package.json +48 -46
  202. package/src/components/collab-sidebar/format.js +72 -0
  203. package/src/components/collab-sidebar/hooks.js +203 -22
  204. package/src/components/collab-sidebar/index.js +19 -5
  205. package/src/components/collab-sidebar/note-highlight-styles.js +83 -0
  206. package/src/components/collab-sidebar/style.scss +9 -0
  207. package/src/components/collab-sidebar/test/note-highlight-styles.js +106 -0
  208. package/src/components/collab-sidebar/test/utils.js +471 -0
  209. package/src/components/collab-sidebar/utils.js +225 -2
  210. package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +265 -262
  211. package/src/components/collaborators-presence/use-collaborator-notifications.ts +70 -34
  212. package/src/components/commands/index.js +142 -0
  213. package/src/components/document-bar/index.js +0 -9
  214. package/src/components/document-bar/style.scss +0 -17
  215. package/src/components/entities-saved-states/index.js +1 -5
  216. package/src/components/header/index.js +1 -15
  217. package/src/components/header/style.scss +7 -3
  218. package/src/components/media-categories/index.js +160 -6
  219. package/src/components/media-categories/test/index.js +202 -0
  220. package/src/components/page-attributes/parent.js +0 -1
  221. package/src/components/post-author/combobox.js +0 -1
  222. package/src/components/post-author/select.js +0 -1
  223. package/src/components/post-preview-button/index.js +68 -2
  224. package/src/components/post-publish-panel/maybe-upload-media.js +25 -30
  225. package/src/components/post-publish-panel/style.scss +1 -1
  226. package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -127
  227. package/src/components/post-revisions-preview/revisions-slider.js +4 -1
  228. package/src/components/post-revisions-preview/test/block-diff.js +2 -2
  229. package/src/components/post-taxonomies/flat-term-selector.js +0 -1
  230. package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -2
  231. package/src/components/post-template/classic-theme.js +0 -1
  232. package/src/components/preferences-modal/index.js +40 -22
  233. package/src/components/preferences-modal/test/index.js +83 -0
  234. package/src/components/preview-dropdown/index.js +42 -3
  235. package/src/components/provider/use-block-editor-settings.js +42 -7
  236. package/src/components/resizable-editor/index.js +71 -9
  237. package/src/components/resizable-editor/style.scss +7 -0
  238. package/src/components/sidebar/dataform-post-summary.js +13 -1
  239. package/src/components/sidebar/index.js +32 -47
  240. package/src/components/sidebar/post-summary.js +0 -17
  241. package/src/components/styles-canvas/style.scss +1 -2
  242. package/src/components/visual-editor/index.js +19 -15
  243. package/src/components/visual-editor/style.scss +11 -4
  244. package/src/dataviews/store/private-actions.ts +30 -26
  245. package/src/store/actions.js +6 -3
  246. package/src/store/constants.ts +45 -0
  247. package/src/store/private-actions.js +38 -28
  248. package/src/store/private-selectors.js +10 -0
  249. package/src/store/reducer.js +7 -9
  250. package/src/store/selectors.js +3 -1
  251. package/src/store/test/actions.js +31 -22
  252. package/src/utils/device-type.js +46 -0
  253. package/src/utils/media-sideload-from-url/index.js +54 -0
  254. package/src/utils/media-sideload-from-url/test/index.js +162 -0
  255. package/build/components/post-publish-panel/media-util.cjs +0 -72
  256. package/build/components/post-publish-panel/media-util.cjs.map +0 -7
  257. package/build-module/components/post-publish-panel/media-util.mjs +0 -46
  258. package/build-module/components/post-publish-panel/media-util.mjs.map +0 -7
  259. package/build-types/components/post-publish-panel/media-util.d.ts +0 -20
  260. package/build-types/components/post-publish-panel/media-util.d.ts.map +0 -1
  261. package/src/components/post-publish-panel/media-util.js +0 -87
  262. package/src/components/post-publish-panel/test/media-util.js +0 -118
@@ -68,43 +68,75 @@ export function useCollaboratorNotifications(
68
68
  postId: number | null,
69
69
  postType: string | null
70
70
  ): void {
71
- const { postStatus, isCollaborationEnabled, showNotifications } = useSelect(
72
- ( select ) => {
73
- const {
74
- getCurrentPostAttribute,
75
- isCollaborationEnabledForCurrentPost,
76
- } = unlock( select( editorStore ) );
77
- return {
78
- postStatus: getCurrentPostAttribute( 'status' ) as
79
- | string
80
- | undefined,
81
- isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
82
- showNotifications:
83
- select( preferencesStore ).get(
84
- 'core',
85
- 'showCollaborationNotifications'
86
- ) ?? true,
87
- };
88
- },
89
- []
90
- );
71
+ const {
72
+ postStatus,
73
+ isCollaborationEnabled,
74
+ showJoinNotifications,
75
+ showLeaveNotifications,
76
+ showPostSaveNotifications,
77
+ } = useSelect( ( select ) => {
78
+ const {
79
+ getCurrentPostAttribute,
80
+ isCollaborationEnabledForCurrentPost,
81
+ } = unlock( select( editorStore ) );
82
+ // Notification preferences default to enabled when unset.
83
+ const getNotificationPreference = ( name: string ) =>
84
+ select( preferencesStore ).get( 'core', name ) ?? true;
85
+ return {
86
+ postStatus: getCurrentPostAttribute( 'status' ) as
87
+ | string
88
+ | undefined,
89
+ isCollaborationEnabled: isCollaborationEnabledForCurrentPost(),
90
+ showJoinNotifications: getNotificationPreference(
91
+ 'showCollaborationJoinNotifications'
92
+ ),
93
+ showLeaveNotifications: getNotificationPreference(
94
+ 'showCollaborationLeaveNotifications'
95
+ ),
96
+ showPostSaveNotifications: getNotificationPreference(
97
+ 'showCollaborationPostSaveNotifications'
98
+ ),
99
+ };
100
+ }, [] );
91
101
 
92
102
  const { createNotice } = useDispatch( noticesStore );
93
103
 
94
- // Pass null when collaboration is disabled or notifications are
104
+ // Pass null when collaboration is disabled or a notification type is
95
105
  // turned off to prevent the hooks from subscribing to awareness state.
96
- const shouldSubscribe = isCollaborationEnabled && showNotifications;
97
- const effectivePostId = shouldSubscribe ? postId : null;
98
- const effectivePostType = shouldSubscribe ? postType : null;
106
+ const shouldShowJoinNotifications =
107
+ isCollaborationEnabled && showJoinNotifications;
108
+ const shouldShowLeaveNotifications =
109
+ isCollaborationEnabled && showLeaveNotifications;
110
+ const shouldShowPostSaveNotifications =
111
+ isCollaborationEnabled && showPostSaveNotifications;
112
+ // A disabled notification type passes null, which unsubscribes its hook;
113
+ // callback guards handle any events already queued before then.
114
+ const effectiveTarget = (
115
+ shouldShow: boolean
116
+ ): [ number | null, string | null ] =>
117
+ shouldShow ? [ postId, postType ] : [ null, null ];
118
+ const [ joinPostId, joinPostType ] = effectiveTarget(
119
+ shouldShowJoinNotifications
120
+ );
121
+ const [ leavePostId, leavePostType ] = effectiveTarget(
122
+ shouldShowLeaveNotifications
123
+ );
124
+ const [ postSavePostId, postSavePostType ] = effectiveTarget(
125
+ shouldShowPostSaveNotifications
126
+ );
99
127
 
100
128
  useOnCollaboratorJoin(
101
- effectivePostId,
102
- effectivePostType,
129
+ joinPostId,
130
+ joinPostType,
103
131
  useCallback(
104
132
  (
105
133
  collaborator: PostEditorAwarenessState,
106
134
  me?: PostEditorAwarenessState
107
135
  ) => {
136
+ if ( ! shouldShowJoinNotifications ) {
137
+ return;
138
+ }
139
+
108
140
  /*
109
141
  * Skip collaborators who were present before the current user
110
142
  * joined. Their enteredAt is earlier than ours, meaning we're
@@ -132,15 +164,19 @@ export function useCollaboratorNotifications(
132
164
  }
133
165
  );
134
166
  },
135
- [ createNotice ]
167
+ [ createNotice, shouldShowJoinNotifications ]
136
168
  )
137
169
  );
138
170
 
139
171
  useOnCollaboratorLeave(
140
- effectivePostId,
141
- effectivePostType,
172
+ leavePostId,
173
+ leavePostType,
142
174
  useCallback(
143
175
  ( collaborator: PostEditorAwarenessState ) => {
176
+ if ( ! shouldShowLeaveNotifications ) {
177
+ return;
178
+ }
179
+
144
180
  void createNotice(
145
181
  'info',
146
182
  sprintf(
@@ -155,20 +191,20 @@ export function useCollaboratorNotifications(
155
191
  }
156
192
  );
157
193
  },
158
- [ createNotice ]
194
+ [ createNotice, shouldShowLeaveNotifications ]
159
195
  )
160
196
  );
161
197
 
162
198
  useOnPostSave(
163
- effectivePostId,
164
- effectivePostType,
199
+ postSavePostId,
200
+ postSavePostType,
165
201
  useCallback(
166
202
  (
167
203
  saveEvent: PostSaveEvent,
168
204
  saver: PostEditorAwarenessState,
169
205
  prevEvent: PostSaveEvent | null
170
206
  ) => {
171
- if ( ! postStatus ) {
207
+ if ( ! shouldShowPostSaveNotifications || ! postStatus ) {
172
208
  return;
173
209
  }
174
210
 
@@ -197,7 +233,7 @@ export function useCollaboratorNotifications(
197
233
  isDismissible: false,
198
234
  } );
199
235
  },
200
- [ createNotice, postStatus ]
236
+ [ createNotice, postStatus, shouldShowPostSaveNotifications ]
201
237
  )
202
238
  );
203
239
  }
@@ -41,6 +41,49 @@ import { modalName as patternRenameModalName } from '../pattern-rename-modal';
41
41
  import { modalName as patternDuplicateModalName } from '../pattern-duplicate-modal';
42
42
  import isTemplateRevertable from '../../store/utils/is-template-revertable';
43
43
 
44
+ /**
45
+ * Returns the command that toggles content-only editing for patterns and template parts.
46
+ * The command is registered both globally for search and contextually for block
47
+ * selection, so keeping it in one place ensures the label and callback stay aligned.
48
+ *
49
+ * @param {Object} options Command options.
50
+ * @param {boolean} options.disableContentOnlyForPatternsAndTemplateParts Whether content-only editing is disabled for patterns and template parts.
51
+ * @param {Function} options.stopEditingContentOnlySection Stops editing the current content-only section before changing the setting.
52
+ * @param {Function} options.updateEditorSettings Updates the editor settings.
53
+ * @return {Object} The command configuration.
54
+ */
55
+ function getTogglePatternEditingCommand( {
56
+ disableContentOnlyForPatternsAndTemplateParts,
57
+ stopEditingContentOnlySection,
58
+ updateEditorSettings,
59
+ } ) {
60
+ return {
61
+ name: 'core/toggle-pattern-editing',
62
+ label: disableContentOnlyForPatternsAndTemplateParts
63
+ ? __( 'Disable editing all patterns' )
64
+ : __( 'Enable editing all patterns' ),
65
+ icon: symbol,
66
+ category: 'command',
67
+ callback: ( { close } ) => {
68
+ const disableContentOnly =
69
+ ! disableContentOnlyForPatternsAndTemplateParts;
70
+ stopEditingContentOnlySection();
71
+ updateEditorSettings( {
72
+ disableContentOnlyForUnsyncedPatterns: disableContentOnly,
73
+ disableContentOnlyForTemplateParts: disableContentOnly,
74
+ } );
75
+ close();
76
+ },
77
+ };
78
+ }
79
+
80
+ function isPatternOrTemplatePartBlock( blockName, attributes ) {
81
+ return (
82
+ !! attributes?.metadata?.patternName ||
83
+ blockName === 'core/template-part'
84
+ );
85
+ }
86
+
44
87
  const getEditorCommandLoader = () =>
45
88
  function useEditorCommandLoader() {
46
89
  const {
@@ -54,6 +97,8 @@ const getEditorCommandLoader = () =>
54
97
  isCodeEditingEnabled,
55
98
  isRichEditingEnabled,
56
99
  isPublishSidebarEnabled,
100
+ disableContentOnlyForUnsyncedPatterns,
101
+ disableContentOnlyForTemplateParts,
57
102
  } = useSelect( ( select ) => {
58
103
  const { get } = select( preferencesStore );
59
104
  const { isListViewOpened, getCurrentPostType, getEditorSettings } =
@@ -74,6 +119,11 @@ const getEditorCommandLoader = () =>
74
119
  isRichEditingEnabled: getEditorSettings().richEditingEnabled,
75
120
  isPublishSidebarEnabled:
76
121
  select( editorStore ).isPublishSidebarEnabled(),
122
+ disableContentOnlyForUnsyncedPatterns:
123
+ !! getEditorSettings()
124
+ .disableContentOnlyForUnsyncedPatterns,
125
+ disableContentOnlyForTemplateParts:
126
+ !! getEditorSettings().disableContentOnlyForTemplateParts,
77
127
  };
78
128
  }, [] );
79
129
  const { getActiveComplementaryArea } = useSelect( interfaceStore );
@@ -86,7 +136,12 @@ const getEditorCommandLoader = () =>
86
136
  toggleDistractionFree,
87
137
  toggleSpotlightMode,
88
138
  toggleTopToolbar,
139
+ updateEditorSettings,
89
140
  } = useDispatch( editorStore );
141
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
142
+ const { stopEditingContentOnlySection } = unlock(
143
+ useDispatch( blockEditorStore )
144
+ );
90
145
  const { openModal, enableComplementaryArea, disableComplementaryArea } =
91
146
  useDispatch( interfaceStore );
92
147
  const { getCurrentPostId } = useSelect( editorStore );
@@ -98,6 +153,9 @@ const getEditorCommandLoader = () =>
98
153
  }
99
154
 
100
155
  const commands = [];
156
+ const disableContentOnlyForPatternsAndTemplateParts =
157
+ disableContentOnlyForUnsyncedPatterns &&
158
+ disableContentOnlyForTemplateParts;
101
159
 
102
160
  commands.push( {
103
161
  name: 'core/open-shortcut-help',
@@ -176,6 +234,14 @@ const getEditorCommandLoader = () =>
176
234
  },
177
235
  } );
178
236
 
237
+ commands.push(
238
+ getTogglePatternEditingCommand( {
239
+ disableContentOnlyForPatternsAndTemplateParts,
240
+ stopEditingContentOnlySection,
241
+ updateEditorSettings,
242
+ } )
243
+ );
244
+
179
245
  if ( allowSwitchEditorMode ) {
180
246
  commands.push( {
181
247
  name: 'core/toggle-code-editor',
@@ -290,6 +356,76 @@ const getEditorCommandLoader = () =>
290
356
  };
291
357
  };
292
358
 
359
+ const getPatternEditingContextualCommands = () =>
360
+ function usePatternEditingContextualCommands( { search } ) {
361
+ const {
362
+ disableContentOnlyForPatternsAndTemplateParts,
363
+ hasPatternOrTemplatePartSelection,
364
+ isPreviewMode,
365
+ } = useSelect( ( select ) => {
366
+ const {
367
+ getBlockAttributes,
368
+ getBlockName,
369
+ getBlockParents,
370
+ getSelectedBlockClientId,
371
+ getSelectedBlockClientIds,
372
+ getSettings,
373
+ } = select( blockEditorStore );
374
+ const { getEditorSettings } = select( editorStore );
375
+ const editorSettings = getEditorSettings();
376
+ const selectedBlockClientId = getSelectedBlockClientId();
377
+ const selectedBlockClientIds = getSelectedBlockClientIds();
378
+ const clientIdsToCheck =
379
+ selectedBlockClientId && selectedBlockClientIds.length === 1
380
+ ? [
381
+ selectedBlockClientId,
382
+ ...getBlockParents( selectedBlockClientId, true ),
383
+ ]
384
+ : [];
385
+
386
+ return {
387
+ disableContentOnlyForPatternsAndTemplateParts:
388
+ !! editorSettings.disableContentOnlyForUnsyncedPatterns &&
389
+ !! editorSettings.disableContentOnlyForTemplateParts,
390
+ hasPatternOrTemplatePartSelection: clientIdsToCheck.some(
391
+ ( clientId ) =>
392
+ isPatternOrTemplatePartBlock(
393
+ getBlockName( clientId ),
394
+ getBlockAttributes( clientId )
395
+ )
396
+ ),
397
+ isPreviewMode: getSettings().isPreviewMode,
398
+ };
399
+ }, [] );
400
+ const { updateEditorSettings } = useDispatch( editorStore );
401
+ // eslint-disable-next-line @wordpress/no-unused-vars-before-return
402
+ const { stopEditingContentOnlySection } = unlock(
403
+ useDispatch( blockEditorStore )
404
+ );
405
+
406
+ // Keep the disable command available after full pattern editing is enabled,
407
+ // even when the current selection is no longer inside a pattern or template part.
408
+ if (
409
+ search ||
410
+ ( ! hasPatternOrTemplatePartSelection &&
411
+ ! disableContentOnlyForPatternsAndTemplateParts ) ||
412
+ isPreviewMode
413
+ ) {
414
+ return { isLoading: false, commands: [] };
415
+ }
416
+
417
+ return {
418
+ isLoading: false,
419
+ commands: [
420
+ getTogglePatternEditingCommand( {
421
+ disableContentOnlyForPatternsAndTemplateParts,
422
+ stopEditingContentOnlySection,
423
+ updateEditorSettings,
424
+ } ),
425
+ ],
426
+ };
427
+ };
428
+
293
429
  const getEditedEntityContextualCommands = () =>
294
430
  function useEditedEntityContextualCommands() {
295
431
  const { postType } = useSelect( ( select ) => {
@@ -480,6 +616,12 @@ export default function useCommands() {
480
616
  context: 'entity-edit',
481
617
  } );
482
618
 
619
+ useCommandLoader( {
620
+ name: 'core/editor/pattern-editing-contextual-commands',
621
+ hook: getPatternEditingContextualCommands(),
622
+ context: 'block-selection-edit',
623
+ } );
624
+
483
625
  useCommandLoader( {
484
626
  name: 'core/editor/page-content-focus',
485
627
  hook: getPageContentFocusCommands(),
@@ -16,7 +16,6 @@ import {
16
16
  } from '@wordpress/components';
17
17
  import { BlockIcon, store as blockEditorStore } from '@wordpress/block-editor';
18
18
  import { chevronLeftSmall, chevronRightSmall, layout } from '@wordpress/icons';
19
- import { displayShortcut } from '@wordpress/keycodes';
20
19
  import { store as coreStore } from '@wordpress/core-data';
21
20
  import { store as commandsStore } from '@wordpress/commands';
22
21
  import { useRef, useEffect } from '@wordpress/element';
@@ -141,8 +140,6 @@ export default function DocumentBar( props ) {
141
140
  const { open: openCommandCenter } = useDispatch( commandsStore );
142
141
  const isReducedMotion = useReducedMotion();
143
142
 
144
- const hasShortcut = ! window.__experimentalAdminBarInEditor;
145
-
146
143
  const isTemplate = TEMPLATE_POST_TYPES.includes( postType );
147
144
  const hasBackButton =
148
145
  !! onNavigateToPreviousEntityRecord || !! unlockedPatternInfo;
@@ -177,7 +174,6 @@ export default function DocumentBar( props ) {
177
174
  <div
178
175
  className={ clsx( 'editor-document-bar', {
179
176
  'has-back-button': hasBackButton,
180
- 'has-shortcut': hasShortcut,
181
177
  } ) }
182
178
  >
183
179
  <AnimatePresence>
@@ -270,11 +266,6 @@ export default function DocumentBar( props ) {
270
266
  ) }
271
267
  </WCText>
272
268
  </motion.div>
273
- { hasShortcut && (
274
- <span className="editor-document-bar__shortcut">
275
- { displayShortcut.primary( 'k' ) }
276
- </span>
277
- ) }
278
269
  </Button>
279
270
  ) }
280
271
  </div>
@@ -54,13 +54,6 @@
54
54
  margin: 0 auto;
55
55
  max-width: 70%;
56
56
 
57
- // Offset the layout based on the width of the ⌘K label. This ensures the title is centrally aligned.
58
- .editor-document-bar.has-shortcut & {
59
- @include break-medium() {
60
- padding-left: $grid-unit-30;
61
- }
62
- }
63
-
64
57
  h1 {
65
58
  display: flex;
66
59
  align-items: center;
@@ -88,16 +81,6 @@
88
81
  }
89
82
  }
90
83
 
91
- .editor-document-bar__shortcut {
92
- color: $gray-800;
93
- min-width: $grid-unit-30;
94
- display: none;
95
-
96
- @include break-medium() {
97
- display: initial;
98
- }
99
- }
100
-
101
84
  .editor-document-bar__back.components-button.has-icon.has-text {
102
85
  min-width: $button-size;
103
86
  flex-shrink: 0;
@@ -27,10 +27,6 @@ import { useIsDirty } from './hooks/use-is-dirty';
27
27
  import { store as editorStore } from '../../store';
28
28
  import { unlock } from '../../lock-unlock';
29
29
 
30
- function identity( values ) {
31
- return values;
32
- }
33
-
34
30
  /**
35
31
  * Renders the component for managing saved states of entities.
36
32
  *
@@ -79,7 +75,7 @@ export default function EntitiesSavedStates( {
79
75
  export function EntitiesSavedStatesExtensible( {
80
76
  additionalPrompt = undefined,
81
77
  close,
82
- onSave = identity,
78
+ onSave = undefined,
83
79
  saveEnabled: saveEnabledProp = undefined,
84
80
  saveLabel = __( 'Save' ),
85
81
  renderDialog,
@@ -23,12 +23,6 @@ import PostViewLink from '../post-view-link';
23
23
  import PreviewDropdown from '../preview-dropdown';
24
24
  import ZoomOutToggle from '../zoom-out-toggle';
25
25
  import { store as editorStore } from '../../store';
26
- import {
27
- ATTACHMENT_POST_TYPE,
28
- TEMPLATE_PART_POST_TYPE,
29
- PATTERN_POST_TYPE,
30
- NAVIGATION_POST_TYPE,
31
- } from '../../store/constants';
32
26
  import { CollaboratorsPresence } from '../collaborators-presence/index';
33
27
  import { unlock } from '../../lock-unlock';
34
28
 
@@ -84,14 +78,6 @@ function Header( {
84
78
  [ 'post', 'page', 'wp_template' ].includes( postType ) &&
85
79
  hasSectionRootClientId;
86
80
 
87
- const disablePreviewOption =
88
- [
89
- ATTACHMENT_POST_TYPE,
90
- NAVIGATION_POST_TYPE,
91
- TEMPLATE_PART_POST_TYPE,
92
- PATTERN_POST_TYPE,
93
- ].includes( postType ) || isStylesCanvasActive;
94
-
95
81
  const [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =
96
82
  useState( true );
97
83
 
@@ -152,7 +138,7 @@ function Header( {
152
138
 
153
139
  <PreviewDropdown
154
140
  forceIsAutosaveable={ forceIsDirty }
155
- disabled={ disablePreviewOption }
141
+ disabled={ isStylesCanvasActive }
156
142
  />
157
143
 
158
144
  <PostPreviewButton
@@ -10,11 +10,11 @@
10
10
  background: $white;
11
11
  display: grid;
12
12
  grid-auto-flow: row;
13
- grid-template: auto / $header-height minmax(0, max-content) minmax(min-content, 1fr) $header-height;
13
+ grid-template: auto / $button-size-compact minmax(0, max-content) minmax(min-content, 1fr) $header-height;
14
14
  &:has(> .editor-header__center) {
15
- grid-template: auto / $header-height min-content 1fr min-content $header-height;
15
+ grid-template: auto / $button-size-compact min-content 1fr min-content $header-height;
16
16
  @include break-medium {
17
- grid-template: auto / $header-height minmax(min-content, 2fr) 2.5fr minmax(min-content, 2fr) $header-height;
17
+ grid-template: auto / $button-size-compact minmax(min-content, 2fr) 2.5fr minmax(min-content, 2fr) $header-height;
18
18
  }
19
19
  }
20
20
  @include break-mobile {
@@ -31,6 +31,10 @@
31
31
  }
32
32
  }
33
33
 
34
+ .editor-header__back-button {
35
+ padding-left: $grid-unit;
36
+ }
37
+
34
38
  .editor-header__toolbar {
35
39
  grid-column: 1 / 3;
36
40
  // When there is no back button or the viewport is <= mobile the margin keeps the content off