@wordpress/editor 13.24.1 → 13.26.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 +8 -0
- package/LICENSE.md +1 -1
- package/build/components/document-bar/index.js +164 -0
- package/build/components/document-bar/index.js.map +1 -0
- package/build/components/document-outline/index.js +82 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +160 -0
- package/build/components/document-tools/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 +298 -0
- package/build/components/editor-canvas/index.js.map +1 -0
- package/build/components/entities-saved-states/index.js +3 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +12 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +72 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +77 -0
- package/build/components/inserter-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +150 -0
- package/build/components/list-view-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/list-view-outline.js +28 -0
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build/components/offline-status/index.native.js +85 -0
- package/build/components/offline-status/index.native.js.map +1 -0
- package/build/components/page-attributes/panel.js +63 -0
- package/build/components/page-attributes/panel.js.map +1 -0
- package/build/components/post-discussion/panel.js +59 -0
- package/build/components/post-discussion/panel.js.map +1 -0
- package/build/components/post-excerpt/check.js +19 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/panel.js +55 -0
- package/build/components/post-excerpt/panel.js.map +1 -0
- package/build/components/post-excerpt/plugin.js +72 -0
- package/build/components/post-excerpt/plugin.js.map +1 -0
- package/build/components/post-featured-image/index.js +5 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +60 -0
- package/build/components/post-featured-image/panel.js.map +1 -0
- package/build/components/post-last-revision/panel.js +27 -0
- package/build/components/post-last-revision/panel.js.map +1 -0
- 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 +13 -8
- 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-taxonomies/panel.js +68 -0
- package/build/components/post-taxonomies/panel.js.map +1 -0
- package/build/components/post-template/block-theme.js +100 -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 +70 -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 +86 -0
- package/build/components/post-template/swap-template-button.js.map +1 -0
- package/build/components/post-title/index.native.js +25 -15
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-view-link/index.js +58 -0
- package/build/components/post-view-link/index.js.map +1 -0
- package/build/components/post-visibility/check.js +5 -17
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/preview-dropdown/index.js +118 -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 +36 -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 +38 -15
- 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 +14 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +161 -13
- 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 +5 -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/private-selectors.js +52 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +109 -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 +104 -9
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +8 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +156 -0
- package/build-module/components/document-bar/index.js.map +1 -0
- package/build-module/components/document-outline/index.js +82 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +151 -0
- package/build-module/components/document-tools/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 +289 -0
- package/build-module/components/editor-canvas/index.js.map +1 -0
- package/build-module/components/entities-saved-states/index.js +3 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +9 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +70 -0
- package/build-module/components/inserter-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +142 -0
- package/build-module/components/list-view-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/offline-status/index.native.js +77 -0
- package/build-module/components/offline-status/index.native.js.map +1 -0
- package/build-module/components/page-attributes/panel.js +53 -0
- package/build-module/components/page-attributes/panel.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +50 -0
- package/build-module/components/post-discussion/panel.js.map +1 -0
- package/build-module/components/post-excerpt/check.js +19 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +48 -0
- package/build-module/components/post-excerpt/panel.js.map +1 -0
- package/build-module/components/post-excerpt/plugin.js +64 -0
- package/build-module/components/post-excerpt/plugin.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +5 -8
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +51 -0
- package/build-module/components/post-featured-image/panel.js.map +1 -0
- package/build-module/components/post-last-revision/panel.js +18 -0
- package/build-module/components/post-last-revision/panel.js.map +1 -0
- 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 +13 -8
- 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-taxonomies/panel.js +59 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -0
- package/build-module/components/post-template/block-theme.js +92 -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 +62 -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 +79 -0
- package/build-module/components/post-template/swap-template-button.js.map +1 -0
- package/build-module/components/post-title/index.native.js +26 -16
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-view-link/index.js +51 -0
- package/build-module/components/post-view-link/index.js.map +1 -0
- package/build-module/components/post-visibility/check.js +6 -16
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +110 -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 +37 -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 +38 -15
- 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 +14 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +147 -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 +5 -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/private-selectors.js +43 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +103 -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 +93 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +8 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +433 -0
- package/build-style/style.css +433 -0
- package/package.json +32 -31
- package/src/components/document-bar/index.js +193 -0
- package/src/components/document-bar/style.scss +130 -0
- package/src/components/document-outline/index.js +48 -1
- package/src/components/document-outline/style.scss +12 -0
- package/src/components/document-tools/index.js +177 -0
- package/src/components/document-tools/style.scss +98 -0
- package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
- package/src/components/editor-canvas/index.js +386 -0
- package/src/components/editor-canvas/style.scss +5 -0
- package/src/components/entities-saved-states/index.js +3 -1
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/global-keyboard-shortcuts/index.js +12 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
- package/src/components/index.js +9 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +73 -0
- package/src/components/inserter-sidebar/style.scss +22 -0
- package/src/components/list-view-sidebar/index.js +169 -0
- package/src/components/list-view-sidebar/list-view-outline.js +37 -0
- package/src/components/list-view-sidebar/style.scss +84 -0
- package/src/components/offline-status/index.native.js +101 -0
- package/src/components/offline-status/style.native.scss +28 -0
- package/src/components/offline-status/test/index.native.js +108 -0
- package/src/components/page-attributes/panel.js +62 -0
- package/src/components/post-discussion/panel.js +57 -0
- package/src/components/post-excerpt/check.js +18 -0
- package/src/components/post-excerpt/panel.js +57 -0
- package/src/components/post-excerpt/plugin.js +61 -0
- package/src/components/post-excerpt/test/plugin.js +36 -0
- package/src/components/post-featured-image/index.js +3 -7
- package/src/components/post-featured-image/panel.js +55 -0
- package/src/components/post-last-revision/panel.js +22 -0
- package/src/components/post-last-revision/style.scss +10 -0
- 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 +9 -8
- 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-taxonomies/panel.js +66 -0
- package/src/components/post-template/block-theme.js +110 -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 +66 -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 +86 -0
- package/src/components/post-title/index.native.js +32 -18
- package/src/components/post-title/style.scss +1 -0
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
- package/src/components/post-title/test/index.native.js +78 -0
- package/src/components/post-view-link/index.js +47 -0
- package/src/components/post-visibility/check.js +10 -15
- package/src/components/post-visibility/test/check.js +24 -13
- package/src/components/preview-dropdown/index.js +133 -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 +55 -14
- package/src/components/provider/navigation-block-editing-mode.js +37 -0
- package/src/components/provider/use-block-editor-settings.js +42 -17
- package/src/hooks/index.js +1 -0
- package/src/hooks/pattern-partial-syncing.js +73 -0
- package/src/private-apis.js +14 -0
- package/src/store/actions.js +160 -9
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +5 -0
- package/src/store/private-actions.js +61 -0
- package/src/store/private-selectors.js +51 -0
- package/src/store/reducer.js +103 -26
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +144 -42
- package/src/store/test/actions.js +56 -0
- package/src/store/test/reducer.js +98 -0
- package/src/store/test/selectors.js +137 -147
- package/src/style.scss +7 -0
- package/src/utils/media-upload/index.js +9 -2
- 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/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,129 @@ 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
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Returns an action object used to enable or disable a panel in the editor.
|
|
616
|
+
*
|
|
617
|
+
* @param {string} panelName A string that identifies the panel to enable or disable.
|
|
618
|
+
*
|
|
619
|
+
* @return {Object} Action object.
|
|
620
|
+
*/
|
|
621
|
+
export const toggleEditorPanelEnabled =
|
|
622
|
+
( panelName ) =>
|
|
623
|
+
( { registry } ) => {
|
|
624
|
+
const inactivePanels =
|
|
625
|
+
registry
|
|
626
|
+
.select( preferencesStore )
|
|
627
|
+
.get( 'core', 'inactivePanels' ) ?? [];
|
|
628
|
+
|
|
629
|
+
const isPanelInactive = !! inactivePanels?.includes( panelName );
|
|
630
|
+
|
|
631
|
+
// If the panel is inactive, remove it to enable it, else add it to
|
|
632
|
+
// make it inactive.
|
|
633
|
+
let updatedInactivePanels;
|
|
634
|
+
if ( isPanelInactive ) {
|
|
635
|
+
updatedInactivePanels = inactivePanels.filter(
|
|
636
|
+
( invactivePanelName ) => invactivePanelName !== panelName
|
|
637
|
+
);
|
|
638
|
+
} else {
|
|
639
|
+
updatedInactivePanels = [ ...inactivePanels, panelName ];
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
registry
|
|
643
|
+
.dispatch( preferencesStore )
|
|
644
|
+
.set( 'core', 'inactivePanels', updatedInactivePanels );
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
/**
|
|
648
|
+
* Opens a closed panel and closes an open panel.
|
|
649
|
+
*
|
|
650
|
+
* @param {string} panelName A string that identifies the panel to open or close.
|
|
651
|
+
*/
|
|
652
|
+
export const toggleEditorPanelOpened =
|
|
653
|
+
( panelName ) =>
|
|
654
|
+
( { registry } ) => {
|
|
655
|
+
const openPanels =
|
|
656
|
+
registry.select( preferencesStore ).get( 'core', 'openPanels' ) ??
|
|
657
|
+
[];
|
|
658
|
+
|
|
659
|
+
const isPanelOpen = !! openPanels?.includes( panelName );
|
|
660
|
+
|
|
661
|
+
// If the panel is open, remove it to close it, else add it to
|
|
662
|
+
// make it open.
|
|
663
|
+
let updatedOpenPanels;
|
|
664
|
+
if ( isPanelOpen ) {
|
|
665
|
+
updatedOpenPanels = openPanels.filter(
|
|
666
|
+
( openPanelName ) => openPanelName !== panelName
|
|
667
|
+
);
|
|
668
|
+
} else {
|
|
669
|
+
updatedOpenPanels = [ ...openPanels, panelName ];
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
registry
|
|
673
|
+
.dispatch( preferencesStore )
|
|
674
|
+
.set( 'core', 'openPanels', updatedOpenPanels );
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Returns an action object used to remove a panel from the editor.
|
|
679
|
+
*
|
|
680
|
+
* @param {string} panelName A string that identifies the panel to remove.
|
|
681
|
+
*
|
|
682
|
+
* @return {Object} Action object.
|
|
683
|
+
*/
|
|
684
|
+
export function removeEditorPanel( panelName ) {
|
|
685
|
+
return {
|
|
686
|
+
type: 'REMOVE_PANEL',
|
|
687
|
+
panelName,
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
/**
|
|
692
|
+
* Returns an action object used to open/close the inserter.
|
|
693
|
+
*
|
|
694
|
+
* @param {boolean|Object} value Whether the inserter should be
|
|
695
|
+
* opened (true) or closed (false).
|
|
696
|
+
* To specify an insertion point,
|
|
697
|
+
* use an object.
|
|
698
|
+
* @param {string} value.rootClientId The root client ID to insert at.
|
|
699
|
+
* @param {number} value.insertionIndex The index to insert at.
|
|
700
|
+
*
|
|
701
|
+
* @return {Object} Action object.
|
|
702
|
+
*/
|
|
703
|
+
export function setIsInserterOpened( value ) {
|
|
704
|
+
return {
|
|
705
|
+
type: 'SET_IS_INSERTER_OPENED',
|
|
706
|
+
value,
|
|
707
|
+
};
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
/**
|
|
711
|
+
* Returns an action object used to open/close the list view.
|
|
712
|
+
*
|
|
713
|
+
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
|
|
714
|
+
* @return {Object} Action object.
|
|
715
|
+
*/
|
|
716
|
+
export function setIsListViewOpened( isOpen ) {
|
|
717
|
+
return {
|
|
718
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
719
|
+
isOpen,
|
|
720
|
+
};
|
|
721
|
+
}
|
|
722
|
+
|
|
572
723
|
/**
|
|
573
724
|
* Backward compatibility
|
|
574
725
|
*/
|
package/src/store/defaults.js
CHANGED
package/src/store/index.js
CHANGED
|
@@ -9,7 +9,10 @@ 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';
|
|
13
|
+
import * as privateSelectors from './private-selectors';
|
|
12
14
|
import { STORE_NAME } from './constants';
|
|
15
|
+
import { unlock } from '../lock-unlock';
|
|
13
16
|
|
|
14
17
|
/**
|
|
15
18
|
* Post editor data store configuration.
|
|
@@ -36,3 +39,5 @@ export const store = createReduxStore( STORE_NAME, {
|
|
|
36
39
|
} );
|
|
37
40
|
|
|
38
41
|
register( store );
|
|
42
|
+
unlock( store ).registerPrivateActions( privateActions );
|
|
43
|
+
unlock( store ).registerPrivateSelectors( privateSelectors );
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
5
|
+
import { createRegistrySelector } from '@wordpress/data';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { getRenderingMode } from './selectors';
|
|
11
|
+
|
|
12
|
+
const EMPTY_INSERTION_POINT = {
|
|
13
|
+
rootClientId: undefined,
|
|
14
|
+
insertionIndex: undefined,
|
|
15
|
+
filterValue: undefined,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Get the insertion point for the inserter.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} state Global application state.
|
|
22
|
+
*
|
|
23
|
+
* @return {Object} The root client ID, index to insert at and starting filter value.
|
|
24
|
+
*/
|
|
25
|
+
export const getInsertionPoint = createRegistrySelector(
|
|
26
|
+
( select ) => ( state ) => {
|
|
27
|
+
if ( typeof state.blockInserterPanel === 'object' ) {
|
|
28
|
+
return state.blockInserterPanel;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if ( getRenderingMode( state ) === 'template-locked' ) {
|
|
32
|
+
const [ postContentClientId ] =
|
|
33
|
+
select( blockEditorStore ).__experimentalGetGlobalBlocksByName(
|
|
34
|
+
'core/post-content'
|
|
35
|
+
);
|
|
36
|
+
if ( postContentClientId ) {
|
|
37
|
+
return {
|
|
38
|
+
rootClientId: postContentClientId,
|
|
39
|
+
insertionIndex: undefined,
|
|
40
|
+
filterValue: undefined,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return EMPTY_INSERTION_POINT;
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export function getListViewToggleRef( state ) {
|
|
50
|
+
return state.listViewToggleRef;
|
|
51
|
+
}
|
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;
|
|
@@ -238,66 +247,134 @@ export function postAutosavingLock( state = {}, action ) {
|
|
|
238
247
|
}
|
|
239
248
|
|
|
240
249
|
/**
|
|
241
|
-
* Reducer returning
|
|
242
|
-
* The editor is considered ready to be rendered once
|
|
243
|
-
* the post object is loaded properly and the initial blocks parsed.
|
|
250
|
+
* Reducer returning the post editor setting.
|
|
244
251
|
*
|
|
245
|
-
* @param {
|
|
246
|
-
* @param {Object}
|
|
252
|
+
* @param {Object} state Current state.
|
|
253
|
+
* @param {Object} action Dispatched action.
|
|
247
254
|
*
|
|
248
|
-
* @return {
|
|
255
|
+
* @return {Object} Updated state.
|
|
249
256
|
*/
|
|
250
|
-
export function
|
|
257
|
+
export function editorSettings( state = EDITOR_SETTINGS_DEFAULTS, action ) {
|
|
251
258
|
switch ( action.type ) {
|
|
252
|
-
case '
|
|
253
|
-
return
|
|
259
|
+
case 'UPDATE_EDITOR_SETTINGS':
|
|
260
|
+
return {
|
|
261
|
+
...state,
|
|
262
|
+
...action.settings,
|
|
263
|
+
};
|
|
264
|
+
}
|
|
254
265
|
|
|
255
|
-
|
|
256
|
-
|
|
266
|
+
return state;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function renderingMode( state = 'all', action ) {
|
|
270
|
+
switch ( action.type ) {
|
|
271
|
+
case 'SET_RENDERING_MODE':
|
|
272
|
+
return action.mode;
|
|
257
273
|
}
|
|
258
274
|
|
|
259
275
|
return state;
|
|
260
276
|
}
|
|
261
277
|
|
|
262
278
|
/**
|
|
263
|
-
* Reducer returning the
|
|
279
|
+
* Reducer returning the editing canvas device type.
|
|
264
280
|
*
|
|
265
281
|
* @param {Object} state Current state.
|
|
266
282
|
* @param {Object} action Dispatched action.
|
|
267
283
|
*
|
|
268
284
|
* @return {Object} Updated state.
|
|
269
285
|
*/
|
|
270
|
-
export function
|
|
286
|
+
export function deviceType( state = 'Desktop', action ) {
|
|
271
287
|
switch ( action.type ) {
|
|
272
|
-
case '
|
|
273
|
-
return
|
|
274
|
-
...state,
|
|
275
|
-
...action.settings,
|
|
276
|
-
};
|
|
288
|
+
case 'SET_DEVICE_TYPE':
|
|
289
|
+
return action.deviceType;
|
|
277
290
|
}
|
|
278
291
|
|
|
279
292
|
return state;
|
|
280
293
|
}
|
|
281
294
|
|
|
282
|
-
|
|
295
|
+
/**
|
|
296
|
+
* Reducer storing the list of all programmatically removed panels.
|
|
297
|
+
*
|
|
298
|
+
* @param {Array} state Current state.
|
|
299
|
+
* @param {Object} action Action object.
|
|
300
|
+
*
|
|
301
|
+
* @return {Array} Updated state.
|
|
302
|
+
*/
|
|
303
|
+
export function removedPanels( state = [], action ) {
|
|
283
304
|
switch ( action.type ) {
|
|
284
|
-
case '
|
|
285
|
-
|
|
305
|
+
case 'REMOVE_PANEL':
|
|
306
|
+
if ( ! state.includes( action.panelName ) ) {
|
|
307
|
+
return [ ...state, action.panelName ];
|
|
308
|
+
}
|
|
286
309
|
}
|
|
287
310
|
|
|
288
311
|
return state;
|
|
289
312
|
}
|
|
290
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Reducer to set the block inserter panel open or closed.
|
|
316
|
+
*
|
|
317
|
+
* Note: this reducer interacts with the list view panel reducer
|
|
318
|
+
* to make sure that only one of the two panels is open at the same time.
|
|
319
|
+
*
|
|
320
|
+
* @param {Object} state Current state.
|
|
321
|
+
* @param {Object} action Dispatched action.
|
|
322
|
+
*/
|
|
323
|
+
export function blockInserterPanel( state = false, action ) {
|
|
324
|
+
switch ( action.type ) {
|
|
325
|
+
case 'SET_IS_LIST_VIEW_OPENED':
|
|
326
|
+
return action.isOpen ? false : state;
|
|
327
|
+
case 'SET_IS_INSERTER_OPENED':
|
|
328
|
+
return action.value;
|
|
329
|
+
}
|
|
330
|
+
return state;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Reducer to set the list view panel open or closed.
|
|
335
|
+
*
|
|
336
|
+
* Note: this reducer interacts with the inserter panel reducer
|
|
337
|
+
* to make sure that only one of the two panels is open at the same time.
|
|
338
|
+
*
|
|
339
|
+
* @param {Object} state Current state.
|
|
340
|
+
* @param {Object} action Dispatched action.
|
|
341
|
+
*/
|
|
342
|
+
export function listViewPanel( state = false, action ) {
|
|
343
|
+
switch ( action.type ) {
|
|
344
|
+
case 'SET_IS_INSERTER_OPENED':
|
|
345
|
+
return action.value ? false : state;
|
|
346
|
+
case 'SET_IS_LIST_VIEW_OPENED':
|
|
347
|
+
return action.isOpen;
|
|
348
|
+
}
|
|
349
|
+
return state;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* This reducer does nothing aside initializing a ref to the list view toggle.
|
|
354
|
+
* We will have a unique ref per "editor" instance.
|
|
355
|
+
*
|
|
356
|
+
* @param {Object} state
|
|
357
|
+
* @return {Object} Reference to the list view toggle button.
|
|
358
|
+
*/
|
|
359
|
+
export function listViewToggleRef( state = { current: null } ) {
|
|
360
|
+
return state;
|
|
361
|
+
}
|
|
362
|
+
|
|
291
363
|
export default combineReducers( {
|
|
292
364
|
postId,
|
|
293
365
|
postType,
|
|
366
|
+
templateId,
|
|
294
367
|
saving,
|
|
295
368
|
deleting,
|
|
296
369
|
postLock,
|
|
297
370
|
template,
|
|
298
371
|
postSavingLock,
|
|
299
|
-
isReady,
|
|
300
372
|
editorSettings,
|
|
301
373
|
postAutosavingLock,
|
|
302
374
|
renderingMode,
|
|
375
|
+
deviceType,
|
|
376
|
+
removedPanels,
|
|
377
|
+
blockInserterPanel,
|
|
378
|
+
listViewPanel,
|
|
379
|
+
listViewToggleRef,
|
|
303
380
|
} );
|
|
@@ -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,
|