@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.
- package/CHANGELOG.md +12 -0
- package/build/components/collab-sidebar/format.cjs +83 -0
- package/build/components/collab-sidebar/format.cjs.map +7 -0
- package/build/components/collab-sidebar/hooks.cjs +117 -16
- package/build/components/collab-sidebar/hooks.cjs.map +2 -2
- package/build/components/collab-sidebar/index.cjs +18 -2
- package/build/components/collab-sidebar/index.cjs.map +2 -2
- package/build/components/collab-sidebar/note-highlight-styles.cjs +67 -0
- package/build/components/collab-sidebar/note-highlight-styles.cjs.map +7 -0
- package/build/components/collab-sidebar/utils.cjs +139 -0
- package/build/components/collab-sidebar/utils.cjs.map +2 -2
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +55 -30
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +2 -2
- package/build/components/commands/index.cjs +99 -3
- package/build/components/commands/index.cjs.map +2 -2
- package/build/components/document-bar/index.cjs +28 -34
- package/build/components/document-bar/index.cjs.map +2 -2
- package/build/components/entities-saved-states/index.cjs +1 -4
- package/build/components/entities-saved-states/index.cjs.map +2 -2
- package/build/components/header/index.cjs +1 -8
- package/build/components/header/index.cjs.map +2 -2
- package/build/components/media-categories/index.cjs +92 -6
- package/build/components/media-categories/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +0 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-author/combobox.cjs +0 -1
- package/build/components/post-author/combobox.cjs.map +2 -2
- package/build/components/post-author/select.cjs +0 -1
- package/build/components/post-author/select.cjs.map +2 -2
- package/build/components/post-preview-button/index.cjs +29 -2
- package/build/components/post-preview-button/index.cjs.map +2 -2
- package/build/components/post-publish-panel/maybe-upload-media.cjs +15 -26
- package/build/components/post-publish-panel/maybe-upload-media.cjs.map +3 -3
- package/build/components/post-revisions-preview/revisions-slider.cjs +3 -1
- package/build/components/post-revisions-preview/revisions-slider.cjs.map +2 -2
- package/build/components/post-taxonomies/flat-term-selector.cjs +0 -1
- package/build/components/post-taxonomies/flat-term-selector.cjs.map +2 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs +0 -2
- package/build/components/post-taxonomies/hierarchical-term-selector.cjs.map +2 -2
- package/build/components/post-template/classic-theme.cjs +0 -1
- package/build/components/post-template/classic-theme.cjs.map +2 -2
- package/build/components/preferences-modal/index.cjs +54 -28
- package/build/components/preferences-modal/index.cjs.map +2 -2
- package/build/components/preview-dropdown/index.cjs +38 -9
- package/build/components/preview-dropdown/index.cjs.map +3 -3
- package/build/components/provider/use-block-editor-settings.cjs +23 -9
- package/build/components/provider/use-block-editor-settings.cjs.map +3 -3
- package/build/components/resizable-editor/index.cjs +54 -9
- package/build/components/resizable-editor/index.cjs.map +3 -3
- package/build/components/sidebar/dataform-post-summary.cjs +5 -1
- package/build/components/sidebar/dataform-post-summary.cjs.map +3 -3
- package/build/components/sidebar/index.cjs +29 -38
- package/build/components/sidebar/index.cjs.map +3 -3
- package/build/components/sidebar/post-summary.cjs +0 -13
- package/build/components/sidebar/post-summary.cjs.map +3 -3
- package/build/components/visual-editor/index.cjs +15 -11
- package/build/components/visual-editor/index.cjs.map +3 -3
- package/build/dataviews/store/private-actions.cjs +24 -19
- package/build/dataviews/store/private-actions.cjs.map +2 -2
- package/build/store/actions.cjs +5 -3
- package/build/store/actions.cjs.map +2 -2
- package/build/store/constants.cjs +26 -0
- package/build/store/constants.cjs.map +2 -2
- package/build/store/private-actions.cjs +25 -18
- package/build/store/private-actions.cjs.map +3 -3
- package/build/store/private-selectors.cjs +5 -0
- package/build/store/private-selectors.cjs.map +2 -2
- package/build/store/reducer.cjs +6 -6
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +3 -1
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/device-type.cjs +52 -0
- package/build/utils/device-type.cjs.map +7 -0
- package/build/utils/media-sideload-from-url/index.cjs +63 -0
- package/build/utils/media-sideload-from-url/index.cjs.map +7 -0
- package/build-module/components/collab-sidebar/format.mjs +57 -0
- package/build-module/components/collab-sidebar/format.mjs.map +7 -0
- package/build-module/components/collab-sidebar/hooks.mjs +121 -16
- package/build-module/components/collab-sidebar/hooks.mjs.map +2 -2
- package/build-module/components/collab-sidebar/index.mjs +21 -5
- package/build-module/components/collab-sidebar/index.mjs.map +2 -2
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs +41 -0
- package/build-module/components/collab-sidebar/note-highlight-styles.mjs.map +7 -0
- package/build-module/components/collab-sidebar/utils.mjs +133 -0
- package/build-module/components/collab-sidebar/utils.mjs.map +2 -2
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +55 -30
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +2 -2
- package/build-module/components/commands/index.mjs +99 -3
- package/build-module/components/commands/index.mjs.map +2 -2
- package/build-module/components/document-bar/index.mjs +28 -34
- package/build-module/components/document-bar/index.mjs.map +2 -2
- package/build-module/components/entities-saved-states/index.mjs +1 -4
- package/build-module/components/entities-saved-states/index.mjs.map +2 -2
- package/build-module/components/header/index.mjs +1 -13
- package/build-module/components/header/index.mjs.map +2 -2
- package/build-module/components/media-categories/index.mjs +93 -7
- package/build-module/components/media-categories/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +0 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-author/combobox.mjs +0 -1
- package/build-module/components/post-author/combobox.mjs.map +2 -2
- package/build-module/components/post-author/select.mjs +0 -1
- package/build-module/components/post-author/select.mjs.map +2 -2
- package/build-module/components/post-preview-button/index.mjs +29 -2
- package/build-module/components/post-preview-button/index.mjs.map +2 -2
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs +19 -27
- package/build-module/components/post-publish-panel/maybe-upload-media.mjs.map +2 -2
- package/build-module/components/post-revisions-preview/revisions-slider.mjs +3 -1
- package/build-module/components/post-revisions-preview/revisions-slider.mjs.map +2 -2
- package/build-module/components/post-taxonomies/flat-term-selector.mjs +0 -1
- package/build-module/components/post-taxonomies/flat-term-selector.mjs.map +2 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs +0 -2
- package/build-module/components/post-taxonomies/hierarchical-term-selector.mjs.map +2 -2
- package/build-module/components/post-template/classic-theme.mjs +0 -1
- package/build-module/components/post-template/classic-theme.mjs.map +2 -2
- package/build-module/components/preferences-modal/index.mjs +54 -28
- package/build-module/components/preferences-modal/index.mjs.map +2 -2
- package/build-module/components/preview-dropdown/index.mjs +38 -9
- package/build-module/components/preview-dropdown/index.mjs.map +2 -2
- package/build-module/components/provider/use-block-editor-settings.mjs +23 -9
- package/build-module/components/provider/use-block-editor-settings.mjs.map +2 -2
- package/build-module/components/resizable-editor/index.mjs +55 -10
- package/build-module/components/resizable-editor/index.mjs.map +2 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs +6 -2
- package/build-module/components/sidebar/dataform-post-summary.mjs.map +2 -2
- package/build-module/components/sidebar/index.mjs +29 -42
- package/build-module/components/sidebar/index.mjs.map +2 -2
- package/build-module/components/sidebar/post-summary.mjs +0 -13
- package/build-module/components/sidebar/post-summary.mjs.map +2 -2
- package/build-module/components/visual-editor/index.mjs +16 -13
- package/build-module/components/visual-editor/index.mjs.map +2 -2
- package/build-module/dataviews/store/private-actions.mjs +26 -19
- package/build-module/dataviews/store/private-actions.mjs.map +2 -2
- package/build-module/store/actions.mjs +5 -3
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/constants.mjs +25 -0
- package/build-module/store/constants.mjs.map +2 -2
- package/build-module/store/private-actions.mjs +27 -17
- package/build-module/store/private-actions.mjs.map +2 -2
- package/build-module/store/private-selectors.mjs +4 -0
- package/build-module/store/private-selectors.mjs.map +2 -2
- package/build-module/store/reducer.mjs +5 -5
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +3 -1
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/device-type.mjs +25 -0
- package/build-module/utils/device-type.mjs.map +7 -0
- package/build-module/utils/media-sideload-from-url/index.mjs +32 -0
- package/build-module/utils/media-sideload-from-url/index.mjs.map +7 -0
- package/build-style/style-rtl.css +84 -39
- package/build-style/style.css +84 -39
- package/build-types/components/collab-sidebar/format.d.ts +17 -0
- package/build-types/components/collab-sidebar/format.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/hooks.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/index.d.ts.map +1 -1
- package/build-types/components/collab-sidebar/note-highlight-styles.d.ts +31 -0
- package/build-types/components/collab-sidebar/note-highlight-styles.d.ts.map +1 -0
- package/build-types/components/collab-sidebar/utils.d.ts +82 -2
- package/build-types/components/collab-sidebar/utils.d.ts.map +1 -1
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -1
- package/build-types/components/commands/index.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/index.d.ts.map +1 -1
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/media-categories/index.d.ts +12 -3
- package/build-types/components/media-categories/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-author/combobox.d.ts.map +1 -1
- package/build-types/components/post-author/select.d.ts.map +1 -1
- package/build-types/components/post-preview-button/index.d.ts.map +1 -1
- package/build-types/components/post-publish-panel/maybe-upload-media.d.ts.map +1 -1
- package/build-types/components/post-revisions-preview/revisions-slider.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/flat-term-selector.d.ts.map +1 -1
- package/build-types/components/post-taxonomies/hierarchical-term-selector.d.ts.map +1 -1
- package/build-types/components/post-template/classic-theme.d.ts.map +1 -1
- package/build-types/components/preview-dropdown/index.d.ts.map +1 -1
- package/build-types/components/provider/use-block-editor-settings.d.ts.map +1 -1
- package/build-types/components/resizable-editor/index.d.ts.map +1 -1
- package/build-types/components/sidebar/dataform-post-summary.d.ts.map +1 -1
- package/build-types/components/sidebar/index.d.ts.map +1 -1
- package/build-types/components/sidebar/post-summary.d.ts.map +1 -1
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/store/private-actions.d.ts.map +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/constants.d.ts +6 -0
- package/build-types/store/constants.d.ts.map +1 -1
- package/build-types/store/index.d.ts +2 -2
- package/build-types/store/private-actions.d.ts +9 -15
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +7 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +6 -7
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -1
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/device-type.d.ts +23 -0
- package/build-types/utils/device-type.d.ts.map +1 -0
- package/build-types/utils/get-template-part-icon.d.ts.map +1 -1
- package/build-types/utils/media-sideload-from-url/index.d.ts +18 -0
- package/build-types/utils/media-sideload-from-url/index.d.ts.map +1 -0
- package/package.json +48 -46
- package/src/components/collab-sidebar/format.js +72 -0
- package/src/components/collab-sidebar/hooks.js +203 -22
- package/src/components/collab-sidebar/index.js +19 -5
- package/src/components/collab-sidebar/note-highlight-styles.js +83 -0
- package/src/components/collab-sidebar/style.scss +9 -0
- package/src/components/collab-sidebar/test/note-highlight-styles.js +106 -0
- package/src/components/collab-sidebar/test/utils.js +471 -0
- package/src/components/collab-sidebar/utils.js +225 -2
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +265 -262
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +70 -34
- package/src/components/commands/index.js +142 -0
- package/src/components/document-bar/index.js +0 -9
- package/src/components/document-bar/style.scss +0 -17
- package/src/components/entities-saved-states/index.js +1 -5
- package/src/components/header/index.js +1 -15
- package/src/components/header/style.scss +7 -3
- package/src/components/media-categories/index.js +160 -6
- package/src/components/media-categories/test/index.js +202 -0
- package/src/components/page-attributes/parent.js +0 -1
- package/src/components/post-author/combobox.js +0 -1
- package/src/components/post-author/select.js +0 -1
- package/src/components/post-preview-button/index.js +68 -2
- package/src/components/post-publish-panel/maybe-upload-media.js +25 -30
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +11 -127
- package/src/components/post-revisions-preview/revisions-slider.js +4 -1
- package/src/components/post-revisions-preview/test/block-diff.js +2 -2
- package/src/components/post-taxonomies/flat-term-selector.js +0 -1
- package/src/components/post-taxonomies/hierarchical-term-selector.js +0 -2
- package/src/components/post-template/classic-theme.js +0 -1
- package/src/components/preferences-modal/index.js +40 -22
- package/src/components/preferences-modal/test/index.js +83 -0
- package/src/components/preview-dropdown/index.js +42 -3
- package/src/components/provider/use-block-editor-settings.js +42 -7
- package/src/components/resizable-editor/index.js +71 -9
- package/src/components/resizable-editor/style.scss +7 -0
- package/src/components/sidebar/dataform-post-summary.js +13 -1
- package/src/components/sidebar/index.js +32 -47
- package/src/components/sidebar/post-summary.js +0 -17
- package/src/components/styles-canvas/style.scss +1 -2
- package/src/components/visual-editor/index.js +19 -15
- package/src/components/visual-editor/style.scss +11 -4
- package/src/dataviews/store/private-actions.ts +30 -26
- package/src/store/actions.js +6 -3
- package/src/store/constants.ts +45 -0
- package/src/store/private-actions.js +38 -28
- package/src/store/private-selectors.js +10 -0
- package/src/store/reducer.js +7 -9
- package/src/store/selectors.js +3 -1
- package/src/store/test/actions.js +31 -22
- package/src/utils/device-type.js +46 -0
- package/src/utils/media-sideload-from-url/index.js +54 -0
- package/src/utils/media-sideload-from-url/test/index.js +162 -0
- package/build/components/post-publish-panel/media-util.cjs +0 -72
- package/build/components/post-publish-panel/media-util.cjs.map +0 -7
- package/build-module/components/post-publish-panel/media-util.mjs +0 -46
- package/build-module/components/post-publish-panel/media-util.mjs.map +0 -7
- package/build-types/components/post-publish-panel/media-util.d.ts +0 -20
- package/build-types/components/post-publish-panel/media-util.d.ts.map +0 -1
- package/src/components/post-publish-panel/media-util.js +0 -87
- 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 {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
|
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
|
|
97
|
-
|
|
98
|
-
const
|
|
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
|
-
|
|
102
|
-
|
|
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
|
-
|
|
141
|
-
|
|
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
|
-
|
|
164
|
-
|
|
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 =
|
|
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={
|
|
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 / $
|
|
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 / $
|
|
15
|
+
grid-template: auto / $button-size-compact min-content 1fr min-content $header-height;
|
|
16
16
|
@include break-medium {
|
|
17
|
-
grid-template: auto / $
|
|
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
|