@wordpress/editor 12.2.0 → 12.2.2
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/components/editor-help/index.native.js +3 -3
- package/build/components/editor-help/index.native.js.map +1 -1
- package/build/components/local-autosave-monitor/index.js +5 -5
- package/build/components/local-autosave-monitor/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +1 -1
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-switch-to-draft-button/index.js +19 -14
- package/build/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build/components/post-trash/index.js +15 -29
- package/build/components/post-trash/index.js.map +1 -1
- package/build/components/provider/index.native.js +17 -8
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +3 -2
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/store/actions.js +231 -225
- package/build/store/actions.js.map +1 -1
- package/build/store/actions.native.js +6 -4
- package/build/store/actions.native.js.map +1 -1
- package/build/store/index.js +1 -8
- package/build/store/index.js.map +1 -1
- package/build/store/{controls.js → local-autosave.js} +1 -18
- package/build/store/local-autosave.js.map +1 -0
- package/build/store/reducer.js +0 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/utils/notice-builder.js +5 -0
- package/build/store/utils/notice-builder.js.map +1 -1
- package/build-module/components/editor-help/index.native.js +4 -4
- package/build-module/components/editor-help/index.native.js.map +1 -1
- package/build-module/components/local-autosave-monitor/index.js +1 -1
- package/build-module/components/local-autosave-monitor/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +1 -1
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-switch-to-draft-button/index.js +22 -16
- package/build-module/components/post-switch-to-draft-button/index.js.map +1 -1
- package/build-module/components/post-trash/index.js +15 -27
- package/build-module/components/post-trash/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +19 -10
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +3 -2
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/store/actions.js +208 -207
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/actions.native.js +3 -3
- package/build-module/store/actions.native.js.map +1 -1
- package/build-module/store/index.js +1 -6
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/{controls.js → local-autosave.js} +1 -15
- package/build-module/store/local-autosave.js.map +1 -0
- package/build-module/store/reducer.js +0 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/utils/notice-builder.js +5 -0
- package/build-module/store/utils/notice-builder.js.map +1 -1
- package/package.json +14 -15
- package/src/components/editor-help/index.native.js +6 -6
- package/src/components/local-autosave-monitor/index.js +4 -1
- package/src/components/post-saved-state/index.js +1 -1
- package/src/components/post-switch-to-draft-button/index.js +35 -24
- package/src/components/post-trash/index.js +12 -24
- package/src/components/provider/index.native.js +20 -16
- package/src/components/provider/use-block-editor-settings.js +2 -0
- package/src/store/actions.js +137 -249
- package/src/store/actions.native.js +3 -3
- package/src/store/index.js +0 -6
- package/src/store/{controls.js → local-autosave.js} +0 -8
- package/src/store/reducer.js +0 -2
- package/src/store/test/actions.js +244 -416
- package/src/store/utils/notice-builder.js +5 -0
- package/src/store/utils/test/notice-builder.js +1 -0
- package/build/store/controls.js.map +0 -1
- package/build-module/store/controls.js.map +0 -1
|
@@ -3,47 +3,35 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
|
-
import {
|
|
7
|
-
import { compose } from '@wordpress/compose';
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
11
|
import { store as editorStore } from '../../store';
|
|
13
12
|
|
|
14
|
-
function PostTrash(
|
|
13
|
+
export default function PostTrash() {
|
|
14
|
+
const { isNew, postId } = useSelect( ( select ) => {
|
|
15
|
+
const store = select( editorStore );
|
|
16
|
+
return {
|
|
17
|
+
isNew: store.isEditedPostNew(),
|
|
18
|
+
postId: store.getCurrentPostId(),
|
|
19
|
+
};
|
|
20
|
+
}, [] );
|
|
21
|
+
const { trashPost } = useDispatch( editorStore );
|
|
22
|
+
|
|
15
23
|
if ( isNew || ! postId ) {
|
|
16
24
|
return null;
|
|
17
25
|
}
|
|
18
26
|
|
|
19
|
-
const onClick = () => props.trashPost( postId, postType );
|
|
20
|
-
|
|
21
27
|
return (
|
|
22
28
|
<Button
|
|
23
29
|
className="editor-post-trash"
|
|
24
30
|
isDestructive
|
|
25
31
|
variant="secondary"
|
|
26
|
-
onClick={
|
|
32
|
+
onClick={ () => trashPost() }
|
|
27
33
|
>
|
|
28
34
|
{ __( 'Move to trash' ) }
|
|
29
35
|
</Button>
|
|
30
36
|
);
|
|
31
37
|
}
|
|
32
|
-
|
|
33
|
-
export default compose( [
|
|
34
|
-
withSelect( ( select ) => {
|
|
35
|
-
const {
|
|
36
|
-
isEditedPostNew,
|
|
37
|
-
getCurrentPostId,
|
|
38
|
-
getCurrentPostType,
|
|
39
|
-
} = select( editorStore );
|
|
40
|
-
return {
|
|
41
|
-
isNew: isEditedPostNew(),
|
|
42
|
-
postId: getCurrentPostId(),
|
|
43
|
-
postType: getCurrentPostType(),
|
|
44
|
-
};
|
|
45
|
-
} ),
|
|
46
|
-
withDispatch( ( dispatch ) => ( {
|
|
47
|
-
trashPost: dispatch( editorStore ).trashPost,
|
|
48
|
-
} ) ),
|
|
49
|
-
] )( PostTrash );
|
|
@@ -31,12 +31,8 @@ import {
|
|
|
31
31
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
32
32
|
import { compose } from '@wordpress/compose';
|
|
33
33
|
import { applyFilters } from '@wordpress/hooks';
|
|
34
|
-
import {
|
|
35
|
-
|
|
36
|
-
validateThemeGradients,
|
|
37
|
-
store as blockEditorStore,
|
|
38
|
-
} from '@wordpress/block-editor';
|
|
39
|
-
import { getGlobalStyles } from '@wordpress/components';
|
|
34
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
35
|
+
import { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';
|
|
40
36
|
import { NEW_BLOCK_TYPES } from '@wordpress/block-library';
|
|
41
37
|
|
|
42
38
|
const postTypeEntities = [
|
|
@@ -232,15 +228,18 @@ class NativeEditorProvider extends Component {
|
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
230
|
|
|
235
|
-
getThemeColors( {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
231
|
+
getThemeColors( { rawStyles, rawFeatures } ) {
|
|
232
|
+
const { defaultEditorColors, defaultEditorGradients } = this.props;
|
|
233
|
+
|
|
234
|
+
if ( rawStyles && rawFeatures ) {
|
|
235
|
+
return getGlobalStyles( rawStyles, rawFeatures );
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return getColorsAndGradients(
|
|
239
|
+
defaultEditorColors,
|
|
240
|
+
defaultEditorGradients,
|
|
241
|
+
rawFeatures
|
|
242
|
+
);
|
|
244
243
|
}
|
|
245
244
|
|
|
246
245
|
componentDidUpdate( prevProps ) {
|
|
@@ -363,6 +362,10 @@ export default compose( [
|
|
|
363
362
|
getSettings: getBlockEditorSettings,
|
|
364
363
|
} = select( blockEditorStore );
|
|
365
364
|
|
|
365
|
+
const settings = getBlockEditorSettings();
|
|
366
|
+
const defaultEditorColors = settings?.colors ?? [];
|
|
367
|
+
const defaultEditorGradients = settings?.gradients ?? [];
|
|
368
|
+
|
|
366
369
|
const selectedBlockClientId = getSelectedBlockClientId();
|
|
367
370
|
return {
|
|
368
371
|
mode: getEditorMode(),
|
|
@@ -370,7 +373,8 @@ export default compose( [
|
|
|
370
373
|
blocks: getEditorBlocks(),
|
|
371
374
|
title: getEditedPostAttribute( 'title' ),
|
|
372
375
|
getEditedPostContent,
|
|
373
|
-
|
|
376
|
+
defaultEditorColors,
|
|
377
|
+
defaultEditorGradients,
|
|
374
378
|
selectedBlockIndex: getBlockIndex( selectedBlockClientId ),
|
|
375
379
|
blockCount: getGlobalBlockCount(),
|
|
376
380
|
paragraphCount: getGlobalBlockCount( 'core/paragraph' ),
|
|
@@ -104,6 +104,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
104
104
|
'__experimentalFeatures',
|
|
105
105
|
'__experimentalPreferredStyleVariations',
|
|
106
106
|
'__experimentalSetIsInserterOpened',
|
|
107
|
+
'__experimentalGenerateAnchors',
|
|
107
108
|
'__unstableGalleryWithImageBlocks',
|
|
108
109
|
'alignWide',
|
|
109
110
|
'allowedBlockTypes',
|
|
@@ -148,6 +149,7 @@ function useBlockEditorSettings( settings, hasTemplate ) {
|
|
|
148
149
|
__experimentalCreatePageEntity: createPageEntity,
|
|
149
150
|
__experimentalUserCanCreatePages: userCanCreatePages,
|
|
150
151
|
pageOnFront,
|
|
152
|
+
__experimentalPreferPatternsOnRoot: hasTemplate,
|
|
151
153
|
} ),
|
|
152
154
|
[
|
|
153
155
|
settings,
|