@wordpress/editor 13.24.1 → 13.25.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 +2 -0
- package/build/components/document-bar/index.js +152 -0
- package/build/components/document-bar/index.js.map +1 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build/components/editor-canvas/index.js +292 -0
- package/build/components/editor-canvas/index.js.map +1 -0
- package/build/components/index.js +24 -8
- package/build/components/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +1 -0
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-saved-state/index.js +1 -0
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-template/block-theme.js +99 -0
- package/build/components/post-template/block-theme.js.map +1 -0
- package/build/components/post-template/classic-theme.js +171 -0
- package/build/components/post-template/classic-theme.js.map +1 -0
- package/build/components/post-template/create-new-template-modal.js +98 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -0
- package/build/components/post-template/create-new-template.js +55 -0
- package/build/components/post-template/create-new-template.js.map +1 -0
- package/build/components/post-template/hooks.js +88 -0
- package/build/components/post-template/hooks.js.map +1 -0
- package/build/components/post-template/panel.js +71 -0
- package/build/components/post-template/panel.js.map +1 -0
- package/build/components/post-template/reset-default-template.js +48 -0
- package/build/components/post-template/reset-default-template.js.map +1 -0
- package/build/components/post-template/swap-template-button.js +84 -0
- package/build/components/post-template/swap-template-button.js.map +1 -0
- package/build/components/post-title/index.native.js +0 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/preview-dropdown/index.js +113 -0
- package/build/components/preview-dropdown/index.js.map +1 -0
- package/build/components/provider/index.js +24 -82
- package/build/components/provider/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/navigation-block-editing-mode.js +40 -0
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +9 -10
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +49 -0
- package/build/hooks/pattern-partial-syncing.js.map +1 -0
- package/build/private-apis.js +4 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +59 -11
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +3 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +52 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/reducer.js +32 -27
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +31 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/document-bar/index.js +144 -0
- package/build-module/components/document-bar/index.js.map +1 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +283 -0
- package/build-module/components/editor-canvas/index.js.map +1 -0
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +1 -0
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +1 -0
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +1 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +91 -0
- package/build-module/components/post-template/block-theme.js.map +1 -0
- package/build-module/components/post-template/classic-theme.js +162 -0
- package/build-module/components/post-template/classic-theme.js.map +1 -0
- package/build-module/components/post-template/create-new-template-modal.js +91 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
- package/build-module/components/post-template/create-new-template.js +47 -0
- package/build-module/components/post-template/create-new-template.js.map +1 -0
- package/build-module/components/post-template/hooks.js +78 -0
- package/build-module/components/post-template/hooks.js.map +1 -0
- package/build-module/components/post-template/panel.js +63 -0
- package/build-module/components/post-template/panel.js.map +1 -0
- package/build-module/components/post-template/reset-default-template.js +41 -0
- package/build-module/components/post-template/reset-default-template.js.map +1 -0
- package/build-module/components/post-template/swap-template-button.js +77 -0
- package/build-module/components/post-template/swap-template-button.js.map +1 -0
- package/build-module/components/post-title/index.native.js +0 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +105 -0
- package/build-module/components/preview-dropdown/index.js.map +1 -0
- package/build-module/components/provider/index.js +25 -83
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +18 -9
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +9 -10
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +46 -0
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
- package/build-module/private-apis.js +4 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +53 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +44 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/reducer.js +30 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +26 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +182 -0
- package/build-style/style.css +182 -0
- package/package.json +32 -31
- package/src/components/document-bar/index.js +182 -0
- package/src/components/document-bar/style.scss +130 -0
- package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
- package/src/components/editor-canvas/index.js +381 -0
- package/src/components/index.js +3 -1
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
- package/src/components/post-saved-state/index.js +1 -0
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-template/block-theme.js +109 -0
- package/src/components/post-template/classic-theme.js +213 -0
- package/src/components/post-template/create-new-template-modal.js +139 -0
- package/src/components/post-template/create-new-template.js +50 -0
- package/src/components/post-template/hooks.js +95 -0
- package/src/components/post-template/panel.js +67 -0
- package/src/components/post-template/reset-default-template.js +43 -0
- package/src/components/post-template/style.scss +52 -0
- package/src/components/post-template/swap-template-button.js +83 -0
- package/src/components/post-title/index.native.js +0 -1
- package/src/components/preview-dropdown/index.js +136 -0
- package/src/components/preview-dropdown/style.scss +5 -0
- package/src/components/provider/index.js +28 -118
- package/src/components/provider/index.native.js +26 -12
- package/src/components/provider/navigation-block-editing-mode.js +37 -0
- package/src/components/provider/use-block-editor-settings.js +6 -9
- package/src/hooks/index.js +1 -0
- package/src/hooks/pattern-partial-syncing.js +73 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +51 -9
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +3 -0
- package/src/store/private-actions.js +61 -0
- package/src/store/reducer.js +32 -27
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +64 -42
- package/src/store/test/selectors.js +88 -147
- package/src/style.scss +3 -0
- package/build/components/post-template/index.js +0 -66
- package/build/components/post-template/index.js.map +0 -1
- package/build-module/components/post-template/index.js +0 -57
- package/build-module/components/post-template/index.js.map +0 -1
- package/src/components/post-template/index.js +0 -64
package/src/private-apis.js
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
+
import EditorCanvas from './components/editor-canvas';
|
|
4
5
|
import { ExperimentalEditorProvider } from './components/provider';
|
|
5
6
|
import { lock } from './lock-unlock';
|
|
6
7
|
import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
|
|
7
8
|
import useBlockEditorSettings from './components/provider/use-block-editor-settings';
|
|
8
9
|
import PostPanelRow from './components/post-panel-row';
|
|
10
|
+
import PreviewDropdown from './components/preview-dropdown';
|
|
9
11
|
|
|
10
12
|
export const privateApis = {};
|
|
11
13
|
lock( privateApis, {
|
|
14
|
+
EditorCanvas,
|
|
12
15
|
ExperimentalEditorProvider,
|
|
13
16
|
EntitiesSavedStatesExtensible,
|
|
14
17
|
PostPanelRow,
|
|
18
|
+
PreviewDropdown,
|
|
15
19
|
|
|
16
20
|
// This is a temporary private API while we're updating the site editor to use EditorProvider.
|
|
17
21
|
useBlockEditorSettings,
|
package/src/store/actions.js
CHANGED
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
export const setupEditor =
|
|
37
37
|
( post, edits, template ) =>
|
|
38
38
|
( { dispatch } ) => {
|
|
39
|
-
dispatch.
|
|
39
|
+
dispatch.setEditedPost( post.type, post.id );
|
|
40
40
|
// Apply a template for new posts only, if exists.
|
|
41
41
|
const isNewPost = post.status === 'auto-draft';
|
|
42
42
|
if ( isNewPost && template ) {
|
|
@@ -70,10 +70,18 @@ export const setupEditor =
|
|
|
70
70
|
* Returns an action object signalling that the editor is being destroyed and
|
|
71
71
|
* that any necessary state or side-effect cleanup should occur.
|
|
72
72
|
*
|
|
73
|
+
* @deprecated
|
|
74
|
+
*
|
|
73
75
|
* @return {Object} Action object.
|
|
74
76
|
*/
|
|
75
77
|
export function __experimentalTearDownEditor() {
|
|
76
|
-
|
|
78
|
+
deprecated(
|
|
79
|
+
"wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor",
|
|
80
|
+
{
|
|
81
|
+
since: '6.5',
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
return { type: 'DO_NOTHING' };
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
/**
|
|
@@ -109,17 +117,33 @@ export function updatePost() {
|
|
|
109
117
|
}
|
|
110
118
|
|
|
111
119
|
/**
|
|
112
|
-
*
|
|
113
|
-
*
|
|
120
|
+
* Setup the editor state.
|
|
121
|
+
*
|
|
122
|
+
* @deprecated
|
|
114
123
|
*
|
|
115
124
|
* @param {Object} post Post object.
|
|
125
|
+
*/
|
|
126
|
+
export function setupEditorState( post ) {
|
|
127
|
+
deprecated( "wp.data.dispatch( 'core/editor' ).setupEditorState", {
|
|
128
|
+
since: '6.5',
|
|
129
|
+
alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost",
|
|
130
|
+
} );
|
|
131
|
+
return setEditedPost( post.type, post.id );
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Returns an action that sets the current post Type and post ID.
|
|
136
|
+
*
|
|
137
|
+
* @param {string} postType Post Type.
|
|
138
|
+
* @param {string} postId Post ID.
|
|
116
139
|
*
|
|
117
140
|
* @return {Object} Action object.
|
|
118
141
|
*/
|
|
119
|
-
export function
|
|
142
|
+
export function setEditedPost( postType, postId ) {
|
|
120
143
|
return {
|
|
121
|
-
type: '
|
|
122
|
-
|
|
144
|
+
type: 'SET_EDITED_POST',
|
|
145
|
+
postType,
|
|
146
|
+
postId,
|
|
123
147
|
};
|
|
124
148
|
}
|
|
125
149
|
|
|
@@ -560,8 +584,12 @@ export function updateEditorSettings( settings ) {
|
|
|
560
584
|
*/
|
|
561
585
|
export const setRenderingMode =
|
|
562
586
|
( mode ) =>
|
|
563
|
-
( { dispatch, registry } ) => {
|
|
564
|
-
|
|
587
|
+
( { dispatch, registry, select } ) => {
|
|
588
|
+
if ( select.__unstableIsEditorReady() ) {
|
|
589
|
+
// We clear the block selection but we also need to clear the selection from the core store.
|
|
590
|
+
registry.dispatch( blockEditorStore ).clearSelectedBlock();
|
|
591
|
+
dispatch.editPost( { selection: undefined }, { undoIgnore: true } );
|
|
592
|
+
}
|
|
565
593
|
|
|
566
594
|
dispatch( {
|
|
567
595
|
type: 'SET_RENDERING_MODE',
|
|
@@ -569,6 +597,20 @@ export const setRenderingMode =
|
|
|
569
597
|
} );
|
|
570
598
|
};
|
|
571
599
|
|
|
600
|
+
/**
|
|
601
|
+
* Action that changes the width of the editing canvas.
|
|
602
|
+
*
|
|
603
|
+
* @param {string} deviceType
|
|
604
|
+
*
|
|
605
|
+
* @return {Object} Action object.
|
|
606
|
+
*/
|
|
607
|
+
export function setDeviceType( deviceType ) {
|
|
608
|
+
return {
|
|
609
|
+
type: 'SET_DEVICE_TYPE',
|
|
610
|
+
deviceType,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
|
|
572
614
|
/**
|
|
573
615
|
* Backward compatibility
|
|
574
616
|
*/
|
package/src/store/defaults.js
CHANGED
package/src/store/index.js
CHANGED
|
@@ -9,7 +9,9 @@ import { createReduxStore, register } from '@wordpress/data';
|
|
|
9
9
|
import reducer from './reducer';
|
|
10
10
|
import * as selectors from './selectors';
|
|
11
11
|
import * as actions from './actions';
|
|
12
|
+
import * as privateActions from './private-actions';
|
|
12
13
|
import { STORE_NAME } from './constants';
|
|
14
|
+
import { unlock } from '../lock-unlock';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Post editor data store configuration.
|
|
@@ -36,3 +38,4 @@ export const store = createReduxStore( STORE_NAME, {
|
|
|
36
38
|
} );
|
|
37
39
|
|
|
38
40
|
register( store );
|
|
41
|
+
unlock( store ).registerPrivateActions( privateActions );
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns an action object used to set which template is currently being used/edited.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} id Template Id.
|
|
12
|
+
*
|
|
13
|
+
* @return {Object} Action object.
|
|
14
|
+
*/
|
|
15
|
+
export function setCurrentTemplateId( id ) {
|
|
16
|
+
return {
|
|
17
|
+
type: 'SET_CURRENT_TEMPLATE_ID',
|
|
18
|
+
id,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a block based template.
|
|
24
|
+
*
|
|
25
|
+
* @param {Object?} template Template to create and assign.
|
|
26
|
+
*/
|
|
27
|
+
export const createTemplate =
|
|
28
|
+
( template ) =>
|
|
29
|
+
async ( { select, dispatch, registry } ) => {
|
|
30
|
+
const savedTemplate = await registry
|
|
31
|
+
.dispatch( coreStore )
|
|
32
|
+
.saveEntityRecord( 'postType', 'wp_template', template );
|
|
33
|
+
registry
|
|
34
|
+
.dispatch( coreStore )
|
|
35
|
+
.editEntityRecord(
|
|
36
|
+
'postType',
|
|
37
|
+
select.getCurrentPostType(),
|
|
38
|
+
select.getCurrentPostId(),
|
|
39
|
+
{
|
|
40
|
+
template: savedTemplate.slug,
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
registry
|
|
44
|
+
.dispatch( noticesStore )
|
|
45
|
+
.createSuccessNotice(
|
|
46
|
+
__( "Custom template created. You're in template mode now." ),
|
|
47
|
+
{
|
|
48
|
+
type: 'snackbar',
|
|
49
|
+
actions: [
|
|
50
|
+
{
|
|
51
|
+
label: __( 'Go back' ),
|
|
52
|
+
onClick: () =>
|
|
53
|
+
dispatch.setRenderingMode(
|
|
54
|
+
select.getEditorSettings()
|
|
55
|
+
.defaultRenderingMode
|
|
56
|
+
),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
};
|
package/src/store/reducer.js
CHANGED
|
@@ -83,8 +83,17 @@ export function shouldOverwriteState( action, previousAction ) {
|
|
|
83
83
|
|
|
84
84
|
export function postId( state = null, action ) {
|
|
85
85
|
switch ( action.type ) {
|
|
86
|
-
case '
|
|
87
|
-
return action.
|
|
86
|
+
case 'SET_EDITED_POST':
|
|
87
|
+
return action.postId;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return state;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function templateId( state = null, action ) {
|
|
94
|
+
switch ( action.type ) {
|
|
95
|
+
case 'SET_CURRENT_TEMPLATE_ID':
|
|
96
|
+
return action.id;
|
|
88
97
|
}
|
|
89
98
|
|
|
90
99
|
return state;
|
|
@@ -92,8 +101,8 @@ export function postId( state = null, action ) {
|
|
|
92
101
|
|
|
93
102
|
export function postType( state = null, action ) {
|
|
94
103
|
switch ( action.type ) {
|
|
95
|
-
case '
|
|
96
|
-
return action.
|
|
104
|
+
case 'SET_EDITED_POST':
|
|
105
|
+
return action.postType;
|
|
97
106
|
}
|
|
98
107
|
|
|
99
108
|
return state;
|
|
@@ -237,28 +246,6 @@ export function postAutosavingLock( state = {}, action ) {
|
|
|
237
246
|
return state;
|
|
238
247
|
}
|
|
239
248
|
|
|
240
|
-
/**
|
|
241
|
-
* Reducer returning whether the editor is ready to be rendered.
|
|
242
|
-
* The editor is considered ready to be rendered once
|
|
243
|
-
* the post object is loaded properly and the initial blocks parsed.
|
|
244
|
-
*
|
|
245
|
-
* @param {boolean} state
|
|
246
|
-
* @param {Object} action
|
|
247
|
-
*
|
|
248
|
-
* @return {boolean} Updated state.
|
|
249
|
-
*/
|
|
250
|
-
export function isReady( state = false, action ) {
|
|
251
|
-
switch ( action.type ) {
|
|
252
|
-
case 'SETUP_EDITOR_STATE':
|
|
253
|
-
return true;
|
|
254
|
-
|
|
255
|
-
case 'TEAR_DOWN_EDITOR':
|
|
256
|
-
return false;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
return state;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
249
|
/**
|
|
263
250
|
* Reducer returning the post editor setting.
|
|
264
251
|
*
|
|
@@ -288,16 +275,34 @@ export function renderingMode( state = 'all', action ) {
|
|
|
288
275
|
return state;
|
|
289
276
|
}
|
|
290
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Reducer returning the editing canvas device type.
|
|
280
|
+
*
|
|
281
|
+
* @param {Object} state Current state.
|
|
282
|
+
* @param {Object} action Dispatched action.
|
|
283
|
+
*
|
|
284
|
+
* @return {Object} Updated state.
|
|
285
|
+
*/
|
|
286
|
+
export function deviceType( state = 'Desktop', action ) {
|
|
287
|
+
switch ( action.type ) {
|
|
288
|
+
case 'SET_DEVICE_TYPE':
|
|
289
|
+
return action.deviceType;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
return state;
|
|
293
|
+
}
|
|
294
|
+
|
|
291
295
|
export default combineReducers( {
|
|
292
296
|
postId,
|
|
293
297
|
postType,
|
|
298
|
+
templateId,
|
|
294
299
|
saving,
|
|
295
300
|
deleting,
|
|
296
301
|
postLock,
|
|
297
302
|
template,
|
|
298
303
|
postSavingLock,
|
|
299
|
-
isReady,
|
|
300
304
|
editorSettings,
|
|
301
305
|
postAutosavingLock,
|
|
302
306
|
renderingMode,
|
|
307
|
+
deviceType,
|
|
303
308
|
} );
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
postLock,
|
|
14
14
|
postSavingLock,
|
|
15
15
|
template,
|
|
16
|
-
isReady,
|
|
17
16
|
editorSettings,
|
|
18
17
|
} from './reducer.js';
|
|
19
18
|
|
|
@@ -87,7 +86,6 @@ export default combineReducers( {
|
|
|
87
86
|
postLock,
|
|
88
87
|
postSavingLock,
|
|
89
88
|
template,
|
|
90
|
-
isReady,
|
|
91
89
|
editorSettings,
|
|
92
90
|
clipboard,
|
|
93
91
|
notices,
|
package/src/store/selectors.js
CHANGED
|
@@ -205,6 +205,17 @@ export function getCurrentPostId( state ) {
|
|
|
205
205
|
return state.postId;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
/**
|
|
209
|
+
* Returns the template ID currently being rendered/edited
|
|
210
|
+
*
|
|
211
|
+
* @param {Object} state Global application state.
|
|
212
|
+
*
|
|
213
|
+
* @return {string?} Template ID.
|
|
214
|
+
*/
|
|
215
|
+
export function getCurrentTemplateId( state ) {
|
|
216
|
+
return state.templateId;
|
|
217
|
+
}
|
|
218
|
+
|
|
208
219
|
/**
|
|
209
220
|
* Returns the number of revisions of the post currently being edited.
|
|
210
221
|
*
|
|
@@ -819,54 +830,54 @@ export function getEditedPostPreviewLink( state ) {
|
|
|
819
830
|
* is a single block within the post and it is of a type known to match a
|
|
820
831
|
* default post format. Returns null if the format cannot be determined.
|
|
821
832
|
*
|
|
822
|
-
* @param {Object} state Global application state.
|
|
823
|
-
*
|
|
824
833
|
* @return {?string} Suggested post format.
|
|
825
834
|
*/
|
|
826
|
-
export
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
835
|
+
export const getSuggestedPostFormat = createRegistrySelector(
|
|
836
|
+
( select ) => () => {
|
|
837
|
+
const blocks = select( blockEditorStore ).getBlocks();
|
|
838
|
+
|
|
839
|
+
if ( blocks.length > 2 ) return null;
|
|
840
|
+
|
|
841
|
+
let name;
|
|
842
|
+
// If there is only one block in the content of the post grab its name
|
|
843
|
+
// so we can derive a suitable post format from it.
|
|
844
|
+
if ( blocks.length === 1 ) {
|
|
845
|
+
name = blocks[ 0 ].name;
|
|
846
|
+
// Check for core/embed `video` and `audio` eligible suggestions.
|
|
847
|
+
if ( name === 'core/embed' ) {
|
|
848
|
+
const provider = blocks[ 0 ].attributes?.providerNameSlug;
|
|
849
|
+
if ( [ 'youtube', 'vimeo' ].includes( provider ) ) {
|
|
850
|
+
name = 'core/video';
|
|
851
|
+
} else if ( [ 'spotify', 'soundcloud' ].includes( provider ) ) {
|
|
852
|
+
name = 'core/audio';
|
|
853
|
+
}
|
|
843
854
|
}
|
|
844
855
|
}
|
|
845
|
-
}
|
|
846
856
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
857
|
+
// If there are two blocks in the content and the last one is a text blocks
|
|
858
|
+
// grab the name of the first one to also suggest a post format from it.
|
|
859
|
+
if ( blocks.length === 2 && blocks[ 1 ].name === 'core/paragraph' ) {
|
|
860
|
+
name = blocks[ 0 ].name;
|
|
861
|
+
}
|
|
852
862
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
863
|
+
// We only convert to default post formats in core.
|
|
864
|
+
switch ( name ) {
|
|
865
|
+
case 'core/image':
|
|
866
|
+
return 'image';
|
|
867
|
+
case 'core/quote':
|
|
868
|
+
case 'core/pullquote':
|
|
869
|
+
return 'quote';
|
|
870
|
+
case 'core/gallery':
|
|
871
|
+
return 'gallery';
|
|
872
|
+
case 'core/video':
|
|
873
|
+
return 'video';
|
|
874
|
+
case 'core/audio':
|
|
875
|
+
return 'audio';
|
|
876
|
+
default:
|
|
877
|
+
return null;
|
|
878
|
+
}
|
|
868
879
|
}
|
|
869
|
-
|
|
880
|
+
);
|
|
870
881
|
|
|
871
882
|
/**
|
|
872
883
|
* Returns the content of the post being edited.
|
|
@@ -1174,7 +1185,7 @@ export function getEditorSelection( state ) {
|
|
|
1174
1185
|
* @return {boolean} is Ready.
|
|
1175
1186
|
*/
|
|
1176
1187
|
export function __unstableIsEditorReady( state ) {
|
|
1177
|
-
return state.
|
|
1188
|
+
return !! state.postId;
|
|
1178
1189
|
}
|
|
1179
1190
|
|
|
1180
1191
|
/**
|
|
@@ -1199,6 +1210,17 @@ export function getRenderingMode( state ) {
|
|
|
1199
1210
|
return state.renderingMode;
|
|
1200
1211
|
}
|
|
1201
1212
|
|
|
1213
|
+
/**
|
|
1214
|
+
* Returns the current editing canvas device type.
|
|
1215
|
+
*
|
|
1216
|
+
* @param {Object} state Global application state.
|
|
1217
|
+
*
|
|
1218
|
+
* @return {string} Device type.
|
|
1219
|
+
*/
|
|
1220
|
+
export function getDeviceType( state ) {
|
|
1221
|
+
return state.deviceType;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1202
1224
|
/*
|
|
1203
1225
|
* Backward compatibility
|
|
1204
1226
|
*/
|