@wordpress/editor 14.0.3 → 14.0.5
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/build/bindings/pattern-overrides.js +8 -5
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +4 -0
- package/build/bindings/post-meta.js.map +1 -1
- package/build/components/editor/index.js +5 -0
- package/build/components/editor/index.js.map +1 -1
- package/build/components/editor-interface/index.js +2 -1
- package/build/components/editor-interface/index.js.map +1 -1
- package/build/components/page-attributes/parent.js +2 -1
- package/build/components/page-attributes/parent.js.map +1 -1
- package/build/components/post-actions/actions.js +14 -36
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/export-pattern-action.js +2 -2
- package/build/components/post-actions/export-pattern-action.js.map +1 -1
- package/build/components/post-saved-state/index.js +11 -1
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-status/index.js +2 -1
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/save-publish-panels/index.js +30 -16
- package/build/components/save-publish-panels/index.js.map +1 -1
- package/build/hooks/pattern-overrides.js +2 -2
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/store/utils/is-template-revertable.js +6 -8
- package/build/store/utils/is-template-revertable.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +8 -5
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +4 -0
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/components/editor/index.js +5 -0
- package/build-module/components/editor/index.js.map +1 -1
- package/build-module/components/editor-interface/index.js +2 -1
- package/build-module/components/editor-interface/index.js.map +1 -1
- package/build-module/components/page-attributes/parent.js +2 -1
- package/build-module/components/page-attributes/parent.js.map +1 -1
- package/build-module/components/post-actions/actions.js +14 -36
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/export-pattern-action.js +2 -2
- package/build-module/components/post-actions/export-pattern-action.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +11 -1
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-status/index.js +1 -1
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/save-publish-panels/index.js +30 -16
- package/build-module/components/save-publish-panels/index.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +3 -1
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/store/utils/is-template-revertable.js +6 -8
- package/build-module/store/utils/is-template-revertable.js.map +1 -1
- package/build-style/style-rtl.css +13 -1
- package/build-style/style.css +13 -1
- package/package.json +6 -6
- package/src/bindings/pattern-overrides.js +9 -10
- package/src/bindings/post-meta.js +5 -0
- package/src/components/editor/index.js +6 -0
- package/src/components/editor-interface/index.js +17 -12
- package/src/components/page-attributes/parent.js +6 -3
- package/src/components/post-actions/actions.js +33 -58
- package/src/components/post-actions/export-pattern-action.js +4 -2
- package/src/components/post-featured-image/style.scss +15 -0
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-saved-state/index.js +11 -1
- package/src/components/post-status/index.js +1 -1
- package/src/components/save-publish-panels/index.js +33 -23
- package/src/components/visual-editor/style.scss +1 -1
- package/src/hooks/pattern-overrides.js +4 -1
- package/src/store/utils/is-template-revertable.js +8 -8
|
@@ -59,11 +59,6 @@ function isTemplateRemovable( template ) {
|
|
|
59
59
|
! template.templatePart?.has_theme_file
|
|
60
60
|
);
|
|
61
61
|
}
|
|
62
|
-
const canDeleteOrReset = ( item ) => {
|
|
63
|
-
const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
|
|
64
|
-
const isUserPattern = item.type === PATTERN_TYPES.user;
|
|
65
|
-
return isUserPattern || ( isTemplatePart && item.isCustom );
|
|
66
|
-
};
|
|
67
62
|
|
|
68
63
|
function getItemTitle( item ) {
|
|
69
64
|
if ( typeof item.title === 'string' ) {
|
|
@@ -254,16 +249,14 @@ const trashPostAction = {
|
|
|
254
249
|
__( '"%s" moved to trash.' ),
|
|
255
250
|
getItemTitle( items[ 0 ] )
|
|
256
251
|
);
|
|
257
|
-
} else if ( items[ 0 ].type === 'page' ) {
|
|
258
|
-
successMessage = sprintf(
|
|
259
|
-
/* translators: The number of items. */
|
|
260
|
-
__( '%s items moved to trash.' ),
|
|
261
|
-
items.length
|
|
262
|
-
);
|
|
263
252
|
} else {
|
|
264
253
|
successMessage = sprintf(
|
|
265
|
-
/* translators: The number of
|
|
266
|
-
|
|
254
|
+
/* translators: The number of items. */
|
|
255
|
+
_n(
|
|
256
|
+
'%s item moved to trash.',
|
|
257
|
+
'%s items moved to trash.',
|
|
258
|
+
items.length
|
|
259
|
+
),
|
|
267
260
|
items.length
|
|
268
261
|
);
|
|
269
262
|
}
|
|
@@ -881,21 +874,11 @@ const duplicatePostAction = {
|
|
|
881
874
|
},
|
|
882
875
|
};
|
|
883
876
|
|
|
884
|
-
const isTemplatePartRevertable = ( item ) => {
|
|
885
|
-
if ( ! item ) {
|
|
886
|
-
return false;
|
|
887
|
-
}
|
|
888
|
-
const hasThemeFile = item.templatePart?.has_theme_file;
|
|
889
|
-
return canDeleteOrReset( item ) && hasThemeFile;
|
|
890
|
-
};
|
|
891
|
-
|
|
892
877
|
const resetTemplateAction = {
|
|
893
878
|
id: 'reset-template',
|
|
894
879
|
label: __( 'Reset' ),
|
|
895
880
|
isEligible: ( item ) => {
|
|
896
|
-
return item
|
|
897
|
-
? isTemplatePartRevertable( item )
|
|
898
|
-
: isTemplateRevertable( item );
|
|
881
|
+
return isTemplateRevertable( item );
|
|
899
882
|
},
|
|
900
883
|
icon: backup,
|
|
901
884
|
supportsBulk: true,
|
|
@@ -907,47 +890,39 @@ const resetTemplateAction = {
|
|
|
907
890
|
onActionPerformed,
|
|
908
891
|
} ) => {
|
|
909
892
|
const [ isBusy, setIsBusy ] = useState( false );
|
|
910
|
-
const { revertTemplate
|
|
911
|
-
useDispatch( editorStore )
|
|
912
|
-
);
|
|
893
|
+
const { revertTemplate } = unlock( useDispatch( editorStore ) );
|
|
913
894
|
const { saveEditedEntityRecord } = useDispatch( coreStore );
|
|
914
895
|
const { createSuccessNotice, createErrorNotice } =
|
|
915
896
|
useDispatch( noticesStore );
|
|
916
897
|
const onConfirm = async () => {
|
|
917
898
|
try {
|
|
918
|
-
|
|
919
|
-
await
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
await saveEditedEntityRecord(
|
|
927
|
-
'postType',
|
|
928
|
-
template.type,
|
|
929
|
-
template.id
|
|
930
|
-
);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
createSuccessNotice(
|
|
934
|
-
items.length > 1
|
|
935
|
-
? sprintf(
|
|
936
|
-
/* translators: The number of items. */
|
|
937
|
-
__( '%s items reset.' ),
|
|
938
|
-
items.length
|
|
939
|
-
)
|
|
940
|
-
: sprintf(
|
|
941
|
-
/* translators: The template/part's name. */
|
|
942
|
-
__( '"%s" reset.' ),
|
|
943
|
-
decodeEntities( getItemTitle( items[ 0 ] ) )
|
|
944
|
-
),
|
|
945
|
-
{
|
|
946
|
-
type: 'snackbar',
|
|
947
|
-
id: 'revert-template-action',
|
|
948
|
-
}
|
|
899
|
+
for ( const template of items ) {
|
|
900
|
+
await revertTemplate( template, {
|
|
901
|
+
allowUndo: false,
|
|
902
|
+
} );
|
|
903
|
+
await saveEditedEntityRecord(
|
|
904
|
+
'postType',
|
|
905
|
+
template.type,
|
|
906
|
+
template.id
|
|
949
907
|
);
|
|
950
908
|
}
|
|
909
|
+
createSuccessNotice(
|
|
910
|
+
items.length > 1
|
|
911
|
+
? sprintf(
|
|
912
|
+
/* translators: The number of items. */
|
|
913
|
+
__( '%s items reset.' ),
|
|
914
|
+
items.length
|
|
915
|
+
)
|
|
916
|
+
: sprintf(
|
|
917
|
+
/* translators: The template/part's name. */
|
|
918
|
+
__( '"%s" reset.' ),
|
|
919
|
+
decodeEntities( getItemTitle( items[ 0 ] ) )
|
|
920
|
+
),
|
|
921
|
+
{
|
|
922
|
+
type: 'snackbar',
|
|
923
|
+
id: 'revert-template-action',
|
|
924
|
+
}
|
|
925
|
+
);
|
|
951
926
|
} catch ( error ) {
|
|
952
927
|
let fallbackErrorMessage;
|
|
953
928
|
if ( items[ 0 ].type === TEMPLATE_POST_TYPE ) {
|
|
@@ -24,8 +24,10 @@ function getJsonFromItem( item ) {
|
|
|
24
24
|
{
|
|
25
25
|
__file: item.type,
|
|
26
26
|
title: item.title || item.name,
|
|
27
|
-
content: item
|
|
28
|
-
syncStatus:
|
|
27
|
+
content: item?.patternPost?.content?.raw || item.content,
|
|
28
|
+
syncStatus:
|
|
29
|
+
item?.patternPost?.wp_pattern_sync_status ||
|
|
30
|
+
item.wp_pattern_sync_status,
|
|
29
31
|
},
|
|
30
32
|
null,
|
|
31
33
|
2
|
|
@@ -20,6 +20,21 @@
|
|
|
20
20
|
opacity: 1;
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
.components-drop-zone__content {
|
|
25
|
+
border-radius: $radius-block-ui;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Align text and icons horizontally to avoid clipping when the featured image is not set.
|
|
29
|
+
&:has(.editor-post-featured-image__toggle) .components-drop-zone .components-drop-zone__content-inner {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: $grid-unit-10;
|
|
33
|
+
|
|
34
|
+
.components-drop-zone__content-icon {
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
23
38
|
}
|
|
24
39
|
|
|
25
40
|
.editor-post-featured-image__toggle,
|
|
@@ -21,6 +21,7 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
21
21
|
/**
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
|
+
import { STATUS_OPTIONS } from '../../components/post-status';
|
|
24
25
|
import { store as editorStore } from '../../store';
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -104,10 +105,19 @@ export default function PostSavedState( { forceIsDirty } ) {
|
|
|
104
105
|
return null;
|
|
105
106
|
}
|
|
106
107
|
|
|
108
|
+
// We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.
|
|
109
|
+
// The reason for this is that this button handles the `save as pending` and `save draft` actions.
|
|
110
|
+
// An exception for this is when the post has a custom status and there should be a way to save changes without
|
|
111
|
+
// having to publish. This should be handled better in the future when custom statuses have better support.
|
|
112
|
+
// @see https://github.com/WordPress/gutenberg/issues/3144.
|
|
113
|
+
const isIneligibleStatus =
|
|
114
|
+
! [ 'pending', 'draft', 'auto-draft' ].includes( postStatus ) &&
|
|
115
|
+
STATUS_OPTIONS.map( ( { value } ) => value ).includes( postStatus );
|
|
116
|
+
|
|
107
117
|
if (
|
|
108
118
|
isPublished ||
|
|
109
119
|
isScheduled ||
|
|
110
|
-
|
|
120
|
+
isIneligibleStatus ||
|
|
111
121
|
( postStatusHasChanged &&
|
|
112
122
|
[ 'pending', 'draft' ].includes( postStatus ) )
|
|
113
123
|
) {
|
|
@@ -30,20 +30,28 @@ export default function SavePublishPanels( {
|
|
|
30
30
|
useDispatch( editorStore );
|
|
31
31
|
const {
|
|
32
32
|
publishSidebarOpened,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
33
|
+
isPublishable,
|
|
34
|
+
isDirty,
|
|
35
|
+
hasOtherEntitiesChanges,
|
|
36
|
+
} = useSelect( ( select ) => {
|
|
37
|
+
const {
|
|
38
|
+
isPublishSidebarOpened,
|
|
39
|
+
isEditedPostPublishable,
|
|
40
|
+
isCurrentPostPublished,
|
|
41
|
+
isEditedPostDirty,
|
|
42
|
+
hasNonPostEntityChanges,
|
|
43
|
+
} = select( editorStore );
|
|
44
|
+
const _hasOtherEntitiesChanges =
|
|
45
|
+
hasNonPostEntityChanges() ||
|
|
46
|
+
unlock( select( editorStore ) ).hasPostMetaChanges();
|
|
47
|
+
return {
|
|
48
|
+
publishSidebarOpened: isPublishSidebarOpened(),
|
|
49
|
+
isPublishable:
|
|
50
|
+
! isCurrentPostPublished() && isEditedPostPublishable(),
|
|
51
|
+
isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
|
|
52
|
+
hasOtherEntitiesChanges: _hasOtherEntitiesChanges,
|
|
53
|
+
};
|
|
54
|
+
}, [] );
|
|
47
55
|
|
|
48
56
|
const openEntitiesSavedStates = useCallback(
|
|
49
57
|
() => setEntitiesSavedStatesCallback( true ),
|
|
@@ -62,29 +70,31 @@ export default function SavePublishPanels( {
|
|
|
62
70
|
PostPublishExtension={ PluginPostPublishPanel.Slot }
|
|
63
71
|
/>
|
|
64
72
|
);
|
|
65
|
-
} else if (
|
|
73
|
+
} else if ( isPublishable && ! hasOtherEntitiesChanges ) {
|
|
66
74
|
unmountableContent = (
|
|
67
|
-
<div className="editor-layout__toggle-
|
|
75
|
+
<div className="editor-layout__toggle-publish-panel">
|
|
68
76
|
<Button
|
|
69
77
|
variant="secondary"
|
|
70
|
-
className="editor-layout__toggle-
|
|
71
|
-
onClick={
|
|
78
|
+
className="editor-layout__toggle-publish-panel-button"
|
|
79
|
+
onClick={ togglePublishSidebar }
|
|
72
80
|
aria-expanded={ false }
|
|
73
81
|
>
|
|
74
|
-
{ __( 'Open
|
|
82
|
+
{ __( 'Open publish panel' ) }
|
|
75
83
|
</Button>
|
|
76
84
|
</div>
|
|
77
85
|
);
|
|
78
86
|
} else {
|
|
79
87
|
unmountableContent = (
|
|
80
|
-
<div className="editor-layout__toggle-
|
|
88
|
+
<div className="editor-layout__toggle-entities-saved-states-panel">
|
|
81
89
|
<Button
|
|
82
90
|
variant="secondary"
|
|
83
|
-
className="editor-layout__toggle-
|
|
84
|
-
onClick={
|
|
91
|
+
className="editor-layout__toggle-entities-saved-states-panel-button"
|
|
92
|
+
onClick={ openEntitiesSavedStates }
|
|
85
93
|
aria-expanded={ false }
|
|
94
|
+
disabled={ ! isDirty }
|
|
95
|
+
__experimentalIsFocusable
|
|
86
96
|
>
|
|
87
|
-
{ __( 'Open
|
|
97
|
+
{ __( 'Open save panel' ) }
|
|
88
98
|
</Button>
|
|
89
99
|
</div>
|
|
90
100
|
);
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
// In the iframed canvas this keeps extra scrollbars from appearing (when block toolbars overflow). In the
|
|
21
21
|
// legacy (non-iframed) canvas, overflow must not be hidden in order to maintain support for sticky positioning.
|
|
22
|
-
|
|
22
|
+
&.is-iframed {
|
|
23
23
|
overflow: hidden;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -14,6 +14,8 @@ import { store as blocksStore } from '@wordpress/blocks';
|
|
|
14
14
|
import { store as editorStore } from '../store';
|
|
15
15
|
import { unlock } from '../lock-unlock';
|
|
16
16
|
|
|
17
|
+
/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
|
|
18
|
+
|
|
17
19
|
const {
|
|
18
20
|
PatternOverridesControls,
|
|
19
21
|
ResetOverridesControl,
|
|
@@ -46,7 +48,8 @@ const withPatternOverrideControls = createHigherOrderComponent(
|
|
|
46
48
|
{ isSupportedBlock && <PatternOverridesBlockControls /> }
|
|
47
49
|
</>
|
|
48
50
|
);
|
|
49
|
-
}
|
|
51
|
+
},
|
|
52
|
+
'withPatternOverrideControls'
|
|
50
53
|
);
|
|
51
54
|
|
|
52
55
|
// Split into a separate component to avoid a store subscription
|
|
@@ -6,18 +6,18 @@ import { TEMPLATE_ORIGINS } from '../constants';
|
|
|
6
6
|
// Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Check if a template is revertable to its original theme-provided
|
|
9
|
+
* Check if a template or template part is revertable to its original theme-provided file.
|
|
10
10
|
*
|
|
11
|
-
* @param {Object}
|
|
12
|
-
* @return {boolean} Whether the
|
|
11
|
+
* @param {Object} templateOrTemplatePart The entity to check.
|
|
12
|
+
* @return {boolean} Whether the entity is revertable.
|
|
13
13
|
*/
|
|
14
|
-
export default function isTemplateRevertable(
|
|
15
|
-
if ( !
|
|
14
|
+
export default function isTemplateRevertable( templateOrTemplatePart ) {
|
|
15
|
+
if ( ! templateOrTemplatePart ) {
|
|
16
16
|
return false;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
return (
|
|
20
|
-
|
|
20
|
+
templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom &&
|
|
21
|
+
templateOrTemplatePart.has_theme_file
|
|
21
22
|
);
|
|
22
|
-
/* eslint-enable camelcase */
|
|
23
23
|
}
|