@wordpress/edit-post 8.34.0 → 8.35.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/commands/use-commands.js +2 -0
- package/build/commands/use-commands.js.map +1 -1
- package/build/components/back-button/fullscreen-mode-close.js +5 -3
- package/build/components/back-button/fullscreen-mode-close.js.map +1 -1
- package/build/components/back-button/index.js +5 -3
- package/build/components/back-button/index.js.map +1 -1
- package/build/components/browser-url/index.js +2 -0
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/editor-initialization/index.js +2 -0
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +3 -1
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/init-pattern-modal/index.js +3 -1
- package/build/components/init-pattern-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +2 -0
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +12 -29
- package/build/components/layout/index.js.map +2 -2
- package/build/components/layout/use-should-iframe.js +3 -1
- package/build/components/layout/use-should-iframe.js.map +1 -1
- package/build/components/meta-boxes/index.js +3 -1
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js +2 -0
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +3 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/meta-boxes/use-meta-box-initialization.js +3 -1
- package/build/components/meta-boxes/use-meta-box-initialization.js.map +1 -1
- package/build/components/more-menu/index.js +5 -3
- package/build/components/more-menu/index.js.map +1 -1
- package/build/components/more-menu/manage-patterns-menu-item.js +3 -1
- package/build/components/more-menu/manage-patterns-menu-item.js.map +1 -1
- package/build/components/more-menu/welcome-guide-menu-item.js +3 -1
- package/build/components/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build/components/preferences-modal/enable-custom-fields.js +4 -2
- package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js +4 -2
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/index.js +5 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +4 -2
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/welcome-guide/default.js +3 -1
- package/build/components/welcome-guide/default.js.map +1 -1
- package/build/components/welcome-guide/image.js +2 -0
- package/build/components/welcome-guide/image.js.map +1 -1
- package/build/components/welcome-guide/index.js +3 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/template.js +3 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/deprecated.js +6 -4
- package/build/deprecated.js.map +1 -1
- package/build/hooks/use-navigate-to-entity-record.js +2 -0
- package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build/index.js +4 -2
- package/build/index.js.map +1 -1
- package/build/lock-unlock.js +3 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +26 -24
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +5 -3
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +3 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +3 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +27 -25
- package/build/store/selectors.js.map +1 -1
- package/build/utils/meta-boxes.js +3 -1
- package/build/utils/meta-boxes.js.map +1 -1
- package/build-module/commands/use-commands.js +1 -0
- package/build-module/commands/use-commands.js.map +1 -1
- package/build-module/components/back-button/fullscreen-mode-close.js +4 -3
- package/build-module/components/back-button/fullscreen-mode-close.js.map +1 -1
- package/build-module/components/back-button/index.js +4 -3
- package/build-module/components/back-button/index.js.map +1 -1
- package/build-module/components/browser-url/index.js +1 -0
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +1 -0
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +2 -1
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/init-pattern-modal/index.js +2 -1
- package/build-module/components/init-pattern-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -0
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +11 -29
- package/build-module/components/layout/index.js.map +2 -2
- package/build-module/components/layout/use-should-iframe.js +2 -1
- package/build-module/components/layout/use-should-iframe.js.map +1 -1
- package/build-module/components/meta-boxes/index.js +2 -1
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +1 -0
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +2 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/meta-boxes/use-meta-box-initialization.js +2 -1
- package/build-module/components/meta-boxes/use-meta-box-initialization.js.map +1 -1
- package/build-module/components/more-menu/index.js +4 -3
- package/build-module/components/more-menu/index.js.map +1 -1
- package/build-module/components/more-menu/manage-patterns-menu-item.js +2 -1
- package/build-module/components/more-menu/manage-patterns-menu-item.js.map +1 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js +2 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js.map +1 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js +3 -2
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js +3 -2
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -3
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +3 -2
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/welcome-guide/default.js +2 -1
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/components/welcome-guide/image.js +1 -0
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +2 -1
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/deprecated.js +5 -4
- package/build-module/deprecated.js.map +1 -1
- package/build-module/hooks/use-navigate-to-entity-record.js +1 -0
- package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build-module/index.js +6 -5
- package/build-module/index.js.map +1 -1
- package/build-module/lock-unlock.js +2 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +25 -24
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +4 -3
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js +2 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +2 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +26 -25
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/meta-boxes.js +2 -1
- package/build-module/utils/meta-boxes.js.map +1 -1
- package/package.json +33 -33
- package/src/components/layout/index.js +5 -30
- package/build/components/layout/use-padding-appender.js +0 -72
- package/build/components/layout/use-padding-appender.js.map +0 -7
- package/build-module/components/layout/use-padding-appender.js +0 -49
- package/build-module/components/layout/use-padding-appender.js.map +0 -7
- package/src/components/layout/use-padding-appender.js +0 -70
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// packages/edit-post/src/store/selectors.js
|
|
1
2
|
import { createSelector, createRegistrySelector } from "@wordpress/data";
|
|
2
3
|
import { store as preferencesStore } from "@wordpress/preferences";
|
|
3
4
|
import { store as coreStore } from "@wordpress/core-data";
|
|
@@ -7,13 +8,13 @@ import {
|
|
|
7
8
|
} from "@wordpress/editor";
|
|
8
9
|
import deprecated from "@wordpress/deprecated";
|
|
9
10
|
import { unlock } from "../lock-unlock";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
var { interfaceStore } = unlock(editorPrivateApis);
|
|
12
|
+
var EMPTY_ARRAY = [];
|
|
13
|
+
var EMPTY_OBJECT = {};
|
|
14
|
+
var getEditorMode = createRegistrySelector(
|
|
14
15
|
(select) => () => select(preferencesStore).get("core", "editorMode") ?? "visual"
|
|
15
16
|
);
|
|
16
|
-
|
|
17
|
+
var isEditorSidebarOpened = createRegistrySelector(
|
|
17
18
|
(select) => () => {
|
|
18
19
|
const activeGeneralSidebar = select(interfaceStore).getActiveComplementaryArea("core");
|
|
19
20
|
return ["edit-post/document", "edit-post/block"].includes(
|
|
@@ -21,7 +22,7 @@ const isEditorSidebarOpened = createRegistrySelector(
|
|
|
21
22
|
);
|
|
22
23
|
}
|
|
23
24
|
);
|
|
24
|
-
|
|
25
|
+
var isPluginSidebarOpened = createRegistrySelector(
|
|
25
26
|
(select) => () => {
|
|
26
27
|
const activeGeneralSidebar = select(interfaceStore).getActiveComplementaryArea("core");
|
|
27
28
|
return !!activeGeneralSidebar && !["edit-post/document", "edit-post/block"].includes(
|
|
@@ -29,7 +30,7 @@ const isPluginSidebarOpened = createRegistrySelector(
|
|
|
29
30
|
);
|
|
30
31
|
}
|
|
31
32
|
);
|
|
32
|
-
|
|
33
|
+
var getActiveGeneralSidebarName = createRegistrySelector(
|
|
33
34
|
(select) => () => {
|
|
34
35
|
return select(interfaceStore).getActiveComplementaryArea("core");
|
|
35
36
|
}
|
|
@@ -56,7 +57,7 @@ function convertPanelsToOldFormat(inactivePanels, openPanels) {
|
|
|
56
57
|
}, panelsWithEnabledState ?? {});
|
|
57
58
|
return panels ?? panelsWithEnabledState ?? EMPTY_OBJECT;
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
+
var getPreferences = createRegistrySelector((select) => () => {
|
|
60
61
|
deprecated(`select( 'core/edit-post' ).getPreferences`, {
|
|
61
62
|
since: "6.0",
|
|
62
63
|
alternative: `select( 'core/preferences' ).get`
|
|
@@ -94,10 +95,10 @@ function getPreference(state, preferenceKey, defaultValue) {
|
|
|
94
95
|
const value = preferences[preferenceKey];
|
|
95
96
|
return value === void 0 ? defaultValue : value;
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
var getHiddenBlockTypes = createRegistrySelector((select) => () => {
|
|
98
99
|
return select(preferencesStore).get("core", "hiddenBlockTypes") ?? EMPTY_ARRAY;
|
|
99
100
|
});
|
|
100
|
-
|
|
101
|
+
var isPublishSidebarOpened = createRegistrySelector(
|
|
101
102
|
(select) => () => {
|
|
102
103
|
deprecated(`select( 'core/edit-post' ).isPublishSidebarOpened`, {
|
|
103
104
|
since: "6.6",
|
|
@@ -106,7 +107,7 @@ const isPublishSidebarOpened = createRegistrySelector(
|
|
|
106
107
|
return select(editorStore).isPublishSidebarOpened();
|
|
107
108
|
}
|
|
108
109
|
);
|
|
109
|
-
|
|
110
|
+
var isEditorPanelRemoved = createRegistrySelector(
|
|
110
111
|
(select) => (state, panelName) => {
|
|
111
112
|
deprecated(`select( 'core/edit-post' ).isEditorPanelRemoved`, {
|
|
112
113
|
since: "6.5",
|
|
@@ -115,7 +116,7 @@ const isEditorPanelRemoved = createRegistrySelector(
|
|
|
115
116
|
return select(editorStore).isEditorPanelRemoved(panelName);
|
|
116
117
|
}
|
|
117
118
|
);
|
|
118
|
-
|
|
119
|
+
var isEditorPanelEnabled = createRegistrySelector(
|
|
119
120
|
(select) => (state, panelName) => {
|
|
120
121
|
deprecated(`select( 'core/edit-post' ).isEditorPanelEnabled`, {
|
|
121
122
|
since: "6.5",
|
|
@@ -124,7 +125,7 @@ const isEditorPanelEnabled = createRegistrySelector(
|
|
|
124
125
|
return select(editorStore).isEditorPanelEnabled(panelName);
|
|
125
126
|
}
|
|
126
127
|
);
|
|
127
|
-
|
|
128
|
+
var isEditorPanelOpened = createRegistrySelector(
|
|
128
129
|
(select) => (state, panelName) => {
|
|
129
130
|
deprecated(`select( 'core/edit-post' ).isEditorPanelOpened`, {
|
|
130
131
|
since: "6.5",
|
|
@@ -133,7 +134,7 @@ const isEditorPanelOpened = createRegistrySelector(
|
|
|
133
134
|
return select(editorStore).isEditorPanelOpened(panelName);
|
|
134
135
|
}
|
|
135
136
|
);
|
|
136
|
-
|
|
137
|
+
var isModalActive = createRegistrySelector(
|
|
137
138
|
(select) => (state, modalName) => {
|
|
138
139
|
deprecated(`select( 'core/edit-post' ).isModalActive`, {
|
|
139
140
|
since: "6.3",
|
|
@@ -142,17 +143,17 @@ const isModalActive = createRegistrySelector(
|
|
|
142
143
|
return !!select(interfaceStore).isModalActive(modalName);
|
|
143
144
|
}
|
|
144
145
|
);
|
|
145
|
-
|
|
146
|
+
var isFeatureActive = createRegistrySelector(
|
|
146
147
|
(select) => (state, feature) => {
|
|
147
148
|
return !!select(preferencesStore).get("core/edit-post", feature);
|
|
148
149
|
}
|
|
149
150
|
);
|
|
150
|
-
|
|
151
|
+
var isPluginItemPinned = createRegistrySelector(
|
|
151
152
|
(select) => (state, pluginName) => {
|
|
152
153
|
return select(interfaceStore).isItemPinned("core", pluginName);
|
|
153
154
|
}
|
|
154
155
|
);
|
|
155
|
-
|
|
156
|
+
var getActiveMetaBoxLocations = createSelector(
|
|
156
157
|
(state) => {
|
|
157
158
|
return Object.keys(state.metaBoxes.locations).filter(
|
|
158
159
|
(location) => isMetaBoxLocationActive(state, location)
|
|
@@ -160,7 +161,7 @@ const getActiveMetaBoxLocations = createSelector(
|
|
|
160
161
|
},
|
|
161
162
|
(state) => [state.metaBoxes.locations]
|
|
162
163
|
);
|
|
163
|
-
|
|
164
|
+
var isMetaBoxLocationVisible = createRegistrySelector(
|
|
164
165
|
(select) => (state, location) => {
|
|
165
166
|
return isMetaBoxLocationActive(state, location) && getMetaBoxesPerLocation(state, location)?.some(({ id }) => {
|
|
166
167
|
return select(editorStore).isEditorPanelEnabled(
|
|
@@ -176,7 +177,7 @@ function isMetaBoxLocationActive(state, location) {
|
|
|
176
177
|
function getMetaBoxesPerLocation(state, location) {
|
|
177
178
|
return state.metaBoxes.locations[location];
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
+
var getAllMetaBoxes = createSelector(
|
|
180
181
|
(state) => {
|
|
181
182
|
return Object.values(state.metaBoxes.locations).flat();
|
|
182
183
|
},
|
|
@@ -188,7 +189,7 @@ function hasMetaBoxes(state) {
|
|
|
188
189
|
function isSavingMetaBoxes(state) {
|
|
189
190
|
return state.metaBoxes.isSaving;
|
|
190
191
|
}
|
|
191
|
-
|
|
192
|
+
var __experimentalGetPreviewDeviceType = createRegistrySelector(
|
|
192
193
|
(select) => () => {
|
|
193
194
|
deprecated(
|
|
194
195
|
`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,
|
|
@@ -201,14 +202,14 @@ const __experimentalGetPreviewDeviceType = createRegistrySelector(
|
|
|
201
202
|
return select(editorStore).getDeviceType();
|
|
202
203
|
}
|
|
203
204
|
);
|
|
204
|
-
|
|
205
|
+
var isInserterOpened = createRegistrySelector((select) => () => {
|
|
205
206
|
deprecated(`select( 'core/edit-post' ).isInserterOpened`, {
|
|
206
207
|
since: "6.5",
|
|
207
208
|
alternative: `select( 'core/editor' ).isInserterOpened`
|
|
208
209
|
});
|
|
209
210
|
return select(editorStore).isInserterOpened();
|
|
210
211
|
});
|
|
211
|
-
|
|
212
|
+
var __experimentalGetInsertionPoint = createRegistrySelector(
|
|
212
213
|
(select) => () => {
|
|
213
214
|
deprecated(
|
|
214
215
|
`select( 'core/edit-post' ).__experimentalGetInsertionPoint`,
|
|
@@ -220,14 +221,14 @@ const __experimentalGetInsertionPoint = createRegistrySelector(
|
|
|
220
221
|
return unlock(select(editorStore)).getInserter();
|
|
221
222
|
}
|
|
222
223
|
);
|
|
223
|
-
|
|
224
|
+
var isListViewOpened = createRegistrySelector((select) => () => {
|
|
224
225
|
deprecated(`select( 'core/edit-post' ).isListViewOpened`, {
|
|
225
226
|
since: "6.5",
|
|
226
227
|
alternative: `select( 'core/editor' ).isListViewOpened`
|
|
227
228
|
});
|
|
228
229
|
return select(editorStore).isListViewOpened();
|
|
229
230
|
});
|
|
230
|
-
|
|
231
|
+
var isEditingTemplate = createRegistrySelector((select) => () => {
|
|
231
232
|
deprecated(`select( 'core/edit-post' ).isEditingTemplate`, {
|
|
232
233
|
since: "6.5",
|
|
233
234
|
alternative: `select( 'core/editor' ).getRenderingMode`
|
|
@@ -237,7 +238,7 @@ const isEditingTemplate = createRegistrySelector((select) => () => {
|
|
|
237
238
|
function areMetaBoxesInitialized(state) {
|
|
238
239
|
return state.metaBoxes.initialized;
|
|
239
240
|
}
|
|
240
|
-
|
|
241
|
+
var getEditedPostTemplate = createRegistrySelector(
|
|
241
242
|
(select) => () => {
|
|
242
243
|
const { id: postId, type: postType } = select(editorStore).getCurrentPost();
|
|
243
244
|
const templateId = unlock(select(coreStore)).getTemplateId(
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/selectors.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nconst { interfaceStore } = unlock( editorPrivateApis );\nconst EMPTY_ARRAY = [];\nconst EMPTY_OBJECT = {};\n\n/**\n * Returns the current editing mode.\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Editing mode.\n */\nexport const getEditorMode = createRegistrySelector(\n\t( select ) => () =>\n\t\tselect( preferencesStore ).get( 'core', 'editorMode' ) ?? 'visual'\n);\n\n/**\n * Returns true if the editor sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the editor sidebar is opened.\n */\nexport const isEditorSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar =\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\treturn [ 'edit-post/document', 'edit-post/block' ].includes(\n\t\t\tactiveGeneralSidebar\n\t\t);\n\t}\n);\n\n/**\n * Returns true if the plugin sidebar is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the plugin sidebar is opened.\n */\nexport const isPluginSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst activeGeneralSidebar =\n\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\treturn (\n\t\t\t!! activeGeneralSidebar &&\n\t\t\t! [ 'edit-post/document', 'edit-post/block' ].includes(\n\t\t\t\tactiveGeneralSidebar\n\t\t\t)\n\t\t);\n\t}\n);\n\n/**\n * Returns the current active general sidebar name, or null if there is no\n * general sidebar active. The active general sidebar is a unique name to\n * identify either an editor or plugin sidebar.\n *\n * Examples:\n *\n * - `edit-post/document`\n * - `my-plugin/insert-image-sidebar`\n *\n * @param {Object} state Global application state.\n *\n * @return {?string} Active general sidebar name.\n */\nexport const getActiveGeneralSidebarName = createRegistrySelector(\n\t( select ) => () => {\n\t\treturn select( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t}\n);\n\n/**\n * Converts panels from the new preferences store format to the old format\n * that the post editor previously used.\n *\n * The resultant converted data should look like this:\n * {\n * panelName: {\n * enabled: false,\n * opened: true,\n * },\n * anotherPanelName: {\n * opened: true\n * },\n * }\n *\n * @param {string[] | undefined} inactivePanels An array of inactive panel names.\n * @param {string[] | undefined} openPanels An array of open panel names.\n *\n * @return {Object} The converted panel data.\n */\nfunction convertPanelsToOldFormat( inactivePanels, openPanels ) {\n\t// First reduce the inactive panels.\n\tconst panelsWithEnabledState = inactivePanels?.reduce(\n\t\t( accumulatedPanels, panelName ) => ( {\n\t\t\t...accumulatedPanels,\n\t\t\t[ panelName ]: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t} ),\n\t\t{}\n\t);\n\n\t// Then reduce the open panels, passing in the result of the previous\n\t// reduction as the initial value so that both open and inactive\n\t// panel state is combined.\n\tconst panels = openPanels?.reduce( ( accumulatedPanels, panelName ) => {\n\t\tconst currentPanelState = accumulatedPanels?.[ panelName ];\n\t\treturn {\n\t\t\t...accumulatedPanels,\n\t\t\t[ panelName ]: {\n\t\t\t\t...currentPanelState,\n\t\t\t\topened: true,\n\t\t\t},\n\t\t};\n\t}, panelsWithEnabledState ?? {} );\n\n\t// The panels variable will only be set if openPanels wasn't `undefined`.\n\t// If it isn't set just return `panelsWithEnabledState`, and if that isn't\n\t// set return an empty object.\n\treturn panels ?? panelsWithEnabledState ?? EMPTY_OBJECT;\n}\n\n/**\n * Returns the preferences (these preferences are persisted locally).\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Preferences Object.\n */\nexport const getPreferences = createRegistrySelector( ( select ) => () => {\n\tdeprecated( `select( 'core/edit-post' ).getPreferences`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\tconst corePreferences = [ 'editorMode', 'hiddenBlockTypes' ].reduce(\n\t\t( accumulatedPrefs, preferenceKey ) => {\n\t\t\tconst value = select( preferencesStore ).get(\n\t\t\t\t'core',\n\t\t\t\tpreferenceKey\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\t...accumulatedPrefs,\n\t\t\t\t[ preferenceKey ]: value,\n\t\t\t};\n\t\t},\n\t\t{}\n\t);\n\n\t// Panels were a preference, but the data structure changed when the state\n\t// was migrated to the preferences store. They need to be converted from\n\t// the new preferences store format to old format to ensure no breaking\n\t// changes for plugins.\n\tconst inactivePanels = select( preferencesStore ).get(\n\t\t'core',\n\t\t'inactivePanels'\n\t);\n\tconst openPanels = select( preferencesStore ).get( 'core', 'openPanels' );\n\tconst panels = convertPanelsToOldFormat( inactivePanels, openPanels );\n\n\treturn {\n\t\t...corePreferences,\n\t\tpanels,\n\t};\n} );\n\n/**\n *\n * @param {Object} state Global application state.\n * @param {string} preferenceKey Preference Key.\n * @param {*} defaultValue Default Value.\n *\n * @return {*} Preference Value.\n */\nexport function getPreference( state, preferenceKey, defaultValue ) {\n\tdeprecated( `select( 'core/edit-post' ).getPreference`, {\n\t\tsince: '6.0',\n\t\talternative: `select( 'core/preferences' ).get`,\n\t} );\n\n\t// Avoid using the `getPreferences` registry selector where possible.\n\tconst preferences = getPreferences( state );\n\tconst value = preferences[ preferenceKey ];\n\treturn value === undefined ? defaultValue : value;\n}\n\n/**\n * Returns an array of blocks that are hidden.\n *\n * @return {Array} A list of the hidden block types\n */\nexport const getHiddenBlockTypes = createRegistrySelector( ( select ) => () => {\n\treturn (\n\t\tselect( preferencesStore ).get( 'core', 'hiddenBlockTypes' ) ??\n\t\tEMPTY_ARRAY\n\t);\n} );\n\n/**\n * Returns true if the publish sidebar is opened.\n *\n * @deprecated\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the publish sidebar is open.\n */\nexport const isPublishSidebarOpened = createRegistrySelector(\n\t( select ) => () => {\n\t\tdeprecated( `select( 'core/edit-post' ).isPublishSidebarOpened`, {\n\t\t\tsince: '6.6',\n\t\t\talternative: `select( 'core/editor' ).isPublishSidebarOpened`,\n\t\t} );\n\t\treturn select( editorStore ).isPublishSidebarOpened();\n\t}\n);\n\n/**\n * Returns true if the given panel was programmatically removed, or false otherwise.\n * All panels are not removed by default.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is removed.\n */\nexport const isEditorPanelRemoved = createRegistrySelector(\n\t( select ) => ( state, panelName ) => {\n\t\tdeprecated( `select( 'core/edit-post' ).isEditorPanelRemoved`, {\n\t\t\tsince: '6.5',\n\t\t\talternative: `select( 'core/editor' ).isEditorPanelRemoved`,\n\t\t} );\n\t\treturn select( editorStore ).isEditorPanelRemoved( panelName );\n\t}\n);\n\n/**\n * Returns true if the given panel is enabled, or false otherwise. Panels are\n * enabled by default.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is enabled.\n */\nexport const isEditorPanelEnabled = createRegistrySelector(\n\t( select ) => ( state, panelName ) => {\n\t\tdeprecated( `select( 'core/edit-post' ).isEditorPanelEnabled`, {\n\t\t\tsince: '6.5',\n\t\t\talternative: `select( 'core/editor' ).isEditorPanelEnabled`,\n\t\t} );\n\t\treturn select( editorStore ).isEditorPanelEnabled( panelName );\n\t}\n);\n\n/**\n * Returns true if the given panel is open, or false otherwise. Panels are\n * closed by default.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n * @param {string} panelName A string that identifies the panel.\n *\n * @return {boolean} Whether or not the panel is open.\n */\nexport const isEditorPanelOpened = createRegistrySelector(\n\t( select ) => ( state, panelName ) => {\n\t\tdeprecated( `select( 'core/edit-post' ).isEditorPanelOpened`, {\n\t\t\tsince: '6.5',\n\t\t\talternative: `select( 'core/editor' ).isEditorPanelOpened`,\n\t\t} );\n\t\treturn select( editorStore ).isEditorPanelOpened( panelName );\n\t}\n);\n\n/**\n * Returns true if a modal is active, or false otherwise.\n *\n * @deprecated since WP 6.3 use `core/interface` store's selector with the same name instead.\n *\n * @param {Object} state Global application state.\n * @param {string} modalName A string that uniquely identifies the modal.\n *\n * @return {boolean} Whether the modal is active.\n */\nexport const isModalActive = createRegistrySelector(\n\t( select ) => ( state, modalName ) => {\n\t\tdeprecated( `select( 'core/edit-post' ).isModalActive`, {\n\t\t\tsince: '6.3',\n\t\t\talternative: `select( 'core/interface' ).isModalActive`,\n\t\t} );\n\t\treturn !! select( interfaceStore ).isModalActive( modalName );\n\t}\n);\n\n/**\n * Returns whether the given feature is enabled or not.\n *\n * @param {Object} state Global application state.\n * @param {string} feature Feature slug.\n *\n * @return {boolean} Is active.\n */\nexport const isFeatureActive = createRegistrySelector(\n\t( select ) => ( state, feature ) => {\n\t\treturn !! select( preferencesStore ).get( 'core/edit-post', feature );\n\t}\n);\n\n/**\n * Returns true if the plugin item is pinned to the header.\n * When the value is not set it defaults to true.\n *\n * @param {Object} state Global application state.\n * @param {string} pluginName Plugin item name.\n *\n * @return {boolean} Whether the plugin item is pinned.\n */\nexport const isPluginItemPinned = createRegistrySelector(\n\t( select ) => ( state, pluginName ) => {\n\t\treturn select( interfaceStore ).isItemPinned( 'core', pluginName );\n\t}\n);\n\n/**\n * Returns an array of active meta box locations.\n *\n * @param {Object} state Post editor state.\n *\n * @return {string[]} Active meta box locations.\n */\nexport const getActiveMetaBoxLocations = createSelector(\n\t( state ) => {\n\t\treturn Object.keys( state.metaBoxes.locations ).filter( ( location ) =>\n\t\t\tisMetaBoxLocationActive( state, location )\n\t\t);\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if a metabox location is active and visible\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active and visible.\n */\nexport const isMetaBoxLocationVisible = createRegistrySelector(\n\t( select ) => ( state, location ) => {\n\t\treturn (\n\t\t\tisMetaBoxLocationActive( state, location ) &&\n\t\t\tgetMetaBoxesPerLocation( state, location )?.some( ( { id } ) => {\n\t\t\t\treturn select( editorStore ).isEditorPanelEnabled(\n\t\t\t\t\t`meta-box-${ id }`\n\t\t\t\t);\n\t\t\t} )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if there is an active meta box in the given location, or false\n * otherwise.\n *\n * @param {Object} state Post editor state.\n * @param {string} location Meta box location to test.\n *\n * @return {boolean} Whether the meta box location is active.\n */\nexport function isMetaBoxLocationActive( state, location ) {\n\tconst metaBoxes = getMetaBoxesPerLocation( state, location );\n\treturn !! metaBoxes && metaBoxes.length !== 0;\n}\n\n/**\n * Returns the list of all the available meta boxes for a given location.\n *\n * @param {Object} state Global application state.\n * @param {string} location Meta box location to test.\n *\n * @return {?Array} List of meta boxes.\n */\nexport function getMetaBoxesPerLocation( state, location ) {\n\treturn state.metaBoxes.locations[ location ];\n}\n\n/**\n * Returns the list of all the available meta boxes.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} List of meta boxes.\n */\nexport const getAllMetaBoxes = createSelector(\n\t( state ) => {\n\t\treturn Object.values( state.metaBoxes.locations ).flat();\n\t},\n\t( state ) => [ state.metaBoxes.locations ]\n);\n\n/**\n * Returns true if the post is using Meta Boxes\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether there are metaboxes or not.\n */\nexport function hasMetaBoxes( state ) {\n\treturn getActiveMetaBoxLocations( state ).length > 0;\n}\n\n/**\n * Returns true if the Meta Boxes are being saved.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the metaboxes are being saved.\n */\nexport function isSavingMetaBoxes( state ) {\n\treturn state.metaBoxes.isSaving;\n}\n\n/**\n * Returns the current editing canvas device type.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport const __experimentalGetPreviewDeviceType = createRegistrySelector(\n\t( select ) => () => {\n\t\tdeprecated(\n\t\t\t`select( 'core/edit-site' ).__experimentalGetPreviewDeviceType`,\n\t\t\t{\n\t\t\t\tsince: '6.5',\n\t\t\t\tversion: '6.7',\n\t\t\t\talternative: `select( 'core/editor' ).getDeviceType`,\n\t\t\t}\n\t\t);\n\t\treturn select( editorStore ).getDeviceType();\n\t}\n);\n\n/**\n * Returns true if the inserter is opened.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport const isInserterOpened = createRegistrySelector( ( select ) => () => {\n\tdeprecated( `select( 'core/edit-post' ).isInserterOpened`, {\n\t\tsince: '6.5',\n\t\talternative: `select( 'core/editor' ).isInserterOpened`,\n\t} );\n\treturn select( editorStore ).isInserterOpened();\n} );\n\n/**\n * Get the insertion point for the inserter.\n *\n * @deprecated\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} The root client ID, index to insert at and starting filter value.\n */\nexport const __experimentalGetInsertionPoint = createRegistrySelector(\n\t( select ) => () => {\n\t\tdeprecated(\n\t\t\t`select( 'core/edit-post' ).__experimentalGetInsertionPoint`,\n\t\t\t{\n\t\t\t\tsince: '6.5',\n\t\t\t\tversion: '6.7',\n\t\t\t}\n\t\t);\n\t\treturn unlock( select( editorStore ) ).getInserter();\n\t}\n);\n\n/**\n * Returns true if the list view is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the list view is opened.\n */\nexport const isListViewOpened = createRegistrySelector( ( select ) => () => {\n\tdeprecated( `select( 'core/edit-post' ).isListViewOpened`, {\n\t\tsince: '6.5',\n\t\talternative: `select( 'core/editor' ).isListViewOpened`,\n\t} );\n\treturn select( editorStore ).isListViewOpened();\n} );\n\n/**\n * Returns true if the template editing mode is enabled.\n *\n * @deprecated\n */\nexport const isEditingTemplate = createRegistrySelector( ( select ) => () => {\n\tdeprecated( `select( 'core/edit-post' ).isEditingTemplate`, {\n\t\tsince: '6.5',\n\t\talternative: `select( 'core/editor' ).getRenderingMode`,\n\t} );\n\treturn select( editorStore ).getCurrentPostType() === 'wp_template';\n} );\n\n/**\n * Returns true if meta boxes are initialized.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether meta boxes are initialized.\n */\nexport function areMetaBoxesInitialized( state ) {\n\treturn state.metaBoxes.initialized;\n}\n\n/**\n * Retrieves the template of the currently edited post.\n *\n * @return {?Object} Post Template.\n */\nexport const getEditedPostTemplate = createRegistrySelector(\n\t( select ) => () => {\n\t\tconst { id: postId, type: postType } =\n\t\t\tselect( editorStore ).getCurrentPost();\n\t\tconst templateId = unlock( select( coreStore ) ).getTemplateId(\n\t\t\tpostType,\n\t\t\tpostId\n\t\t);\n\t\tif ( ! templateId ) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn select( coreStore ).getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template',\n\t\t\ttemplateId\n\t\t);\n\t}\n);\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,gBAAgB,8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/meta-boxes.js"],
|
|
4
4
|
"sourcesContent": ["/**\n * Function returning the current Meta Boxes DOM Node in the editor\n * whether the meta box area is opened or not.\n * If the MetaBox Area is visible returns it, and returns the original container instead.\n *\n * @param {string} location Meta Box location.\n *\n * @return {string} HTML content.\n */\nexport const getMetaBoxContainer = ( location ) => {\n\tconst area = document.querySelector(\n\t\t`.edit-post-meta-boxes-area.is-${ location } .metabox-location-${ location }`\n\t);\n\tif ( area ) {\n\t\treturn area;\n\t}\n\n\treturn document.querySelector( '#metaboxes .metabox-location-' + location );\n};\n"],
|
|
5
|
-
"mappings": "AASO,
|
|
5
|
+
"mappings": ";AASO,IAAM,sBAAsB,CAAE,aAAc;AAClD,QAAM,OAAO,SAAS;AAAA,IACrB,iCAAkC,QAAS,sBAAuB,QAAS;AAAA,EAC5E;AACA,MAAK,MAAO;AACX,WAAO;AAAA,EACR;AAEA,SAAO,SAAS,cAAe,kCAAkC,QAAS;AAC3E;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-post",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.35.0",
|
|
4
4
|
"description": "Edit Post module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -40,37 +40,37 @@
|
|
|
40
40
|
"postbox"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@wordpress/a11y": "^4.
|
|
44
|
-
"@wordpress/admin-ui": "^1.
|
|
45
|
-
"@wordpress/api-fetch": "^7.
|
|
46
|
-
"@wordpress/base-styles": "^6.
|
|
47
|
-
"@wordpress/block-editor": "^15.
|
|
48
|
-
"@wordpress/block-library": "^9.
|
|
49
|
-
"@wordpress/blocks": "^15.
|
|
50
|
-
"@wordpress/commands": "^1.
|
|
51
|
-
"@wordpress/components": "^30.
|
|
52
|
-
"@wordpress/compose": "^7.
|
|
53
|
-
"@wordpress/core-data": "^7.
|
|
54
|
-
"@wordpress/data": "^10.
|
|
55
|
-
"@wordpress/deprecated": "^4.
|
|
56
|
-
"@wordpress/dom": "^4.
|
|
57
|
-
"@wordpress/editor": "^14.
|
|
58
|
-
"@wordpress/element": "^6.
|
|
59
|
-
"@wordpress/global-styles-engine": "^1.
|
|
60
|
-
"@wordpress/hooks": "^4.
|
|
61
|
-
"@wordpress/html-entities": "^4.
|
|
62
|
-
"@wordpress/i18n": "^6.
|
|
63
|
-
"@wordpress/icons": "^11.
|
|
64
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
65
|
-
"@wordpress/keycodes": "^4.
|
|
66
|
-
"@wordpress/notices": "^5.
|
|
67
|
-
"@wordpress/plugins": "^7.
|
|
68
|
-
"@wordpress/preferences": "^4.
|
|
69
|
-
"@wordpress/private-apis": "^1.
|
|
70
|
-
"@wordpress/url": "^4.
|
|
71
|
-
"@wordpress/viewport": "^6.
|
|
72
|
-
"@wordpress/warning": "^3.
|
|
73
|
-
"@wordpress/widgets": "^4.
|
|
43
|
+
"@wordpress/a11y": "^4.35.0",
|
|
44
|
+
"@wordpress/admin-ui": "^1.3.0",
|
|
45
|
+
"@wordpress/api-fetch": "^7.35.0",
|
|
46
|
+
"@wordpress/base-styles": "^6.11.0",
|
|
47
|
+
"@wordpress/block-editor": "^15.8.0",
|
|
48
|
+
"@wordpress/block-library": "^9.35.0",
|
|
49
|
+
"@wordpress/blocks": "^15.8.0",
|
|
50
|
+
"@wordpress/commands": "^1.35.0",
|
|
51
|
+
"@wordpress/components": "^30.8.0",
|
|
52
|
+
"@wordpress/compose": "^7.35.0",
|
|
53
|
+
"@wordpress/core-data": "^7.35.0",
|
|
54
|
+
"@wordpress/data": "^10.35.0",
|
|
55
|
+
"@wordpress/deprecated": "^4.35.0",
|
|
56
|
+
"@wordpress/dom": "^4.35.0",
|
|
57
|
+
"@wordpress/editor": "^14.35.0",
|
|
58
|
+
"@wordpress/element": "^6.35.0",
|
|
59
|
+
"@wordpress/global-styles-engine": "^1.2.0",
|
|
60
|
+
"@wordpress/hooks": "^4.35.0",
|
|
61
|
+
"@wordpress/html-entities": "^4.35.0",
|
|
62
|
+
"@wordpress/i18n": "^6.8.0",
|
|
63
|
+
"@wordpress/icons": "^11.2.0",
|
|
64
|
+
"@wordpress/keyboard-shortcuts": "^5.35.0",
|
|
65
|
+
"@wordpress/keycodes": "^4.35.0",
|
|
66
|
+
"@wordpress/notices": "^5.35.0",
|
|
67
|
+
"@wordpress/plugins": "^7.35.0",
|
|
68
|
+
"@wordpress/preferences": "^4.35.0",
|
|
69
|
+
"@wordpress/private-apis": "^1.35.0",
|
|
70
|
+
"@wordpress/url": "^4.35.0",
|
|
71
|
+
"@wordpress/viewport": "^6.35.0",
|
|
72
|
+
"@wordpress/warning": "^3.35.0",
|
|
73
|
+
"@wordpress/widgets": "^4.35.0",
|
|
74
74
|
"clsx": "^2.1.1",
|
|
75
75
|
"memize": "^2.1.0"
|
|
76
76
|
},
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "77aa1f194edceafe8ac2a1b9438bf84b557e76e3"
|
|
85
85
|
}
|
|
@@ -68,7 +68,6 @@ import WelcomeGuide from '../welcome-guide';
|
|
|
68
68
|
import { store as editPostStore } from '../../store';
|
|
69
69
|
import { unlock } from '../../lock-unlock';
|
|
70
70
|
import useEditPostCommands from '../../commands/use-commands';
|
|
71
|
-
import { usePaddingAppender } from './use-padding-appender';
|
|
72
71
|
import { useShouldIframe } from './use-should-iframe';
|
|
73
72
|
import useNavigateToEntityRecord from '../../hooks/use-navigate-to-entity-record';
|
|
74
73
|
import { useMetaBoxInitialization } from '../meta-boxes/use-meta-box-initialization';
|
|
@@ -83,7 +82,7 @@ const DESIGN_POST_TYPES = [
|
|
|
83
82
|
'wp_navigation',
|
|
84
83
|
];
|
|
85
84
|
|
|
86
|
-
function useEditorStyles( settings
|
|
85
|
+
function useEditorStyles( settings ) {
|
|
87
86
|
const { hasThemeStyleSupport } = useSelect( ( select ) => {
|
|
88
87
|
return {
|
|
89
88
|
hasThemeStyleSupport:
|
|
@@ -91,8 +90,6 @@ function useEditorStyles( settings, ...additionalStyles ) {
|
|
|
91
90
|
};
|
|
92
91
|
}, [] );
|
|
93
92
|
|
|
94
|
-
const addedStyles = additionalStyles.join( '\n' );
|
|
95
|
-
|
|
96
93
|
// Compute the default styles.
|
|
97
94
|
return useMemo( () => {
|
|
98
95
|
const presetStyles =
|
|
@@ -125,21 +122,12 @@ function useEditorStyles( settings, ...additionalStyles ) {
|
|
|
125
122
|
} );
|
|
126
123
|
}
|
|
127
124
|
|
|
128
|
-
|
|
129
|
-
? settings.styles ?? []
|
|
130
|
-
: defaultEditorStyles;
|
|
131
|
-
|
|
132
|
-
if ( addedStyles ) {
|
|
133
|
-
return [ ...baseStyles, { css: addedStyles } ];
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return baseStyles;
|
|
125
|
+
return hasThemeStyles ? settings.styles ?? [] : defaultEditorStyles;
|
|
137
126
|
}, [
|
|
138
127
|
settings.defaultEditorStyles,
|
|
139
128
|
settings.disableLayoutStyles,
|
|
140
129
|
settings.styles,
|
|
141
130
|
hasThemeStyleSupport,
|
|
142
|
-
addedStyles,
|
|
143
131
|
] );
|
|
144
132
|
}
|
|
145
133
|
|
|
@@ -441,7 +429,6 @@ function Layout( {
|
|
|
441
429
|
showMetaBoxes,
|
|
442
430
|
isWelcomeGuideVisible,
|
|
443
431
|
templateId,
|
|
444
|
-
enablePaddingAppender,
|
|
445
432
|
isDevicePreview,
|
|
446
433
|
} = useSelect(
|
|
447
434
|
( select ) => {
|
|
@@ -461,13 +448,8 @@ function Layout( {
|
|
|
461
448
|
const { getBlockSelectionStart, isZoomOut } = unlock(
|
|
462
449
|
select( blockEditorStore )
|
|
463
450
|
);
|
|
464
|
-
const {
|
|
465
|
-
|
|
466
|
-
getRenderingMode,
|
|
467
|
-
getDefaultRenderingMode,
|
|
468
|
-
getDeviceType,
|
|
469
|
-
} = unlock( select( editorStore ) );
|
|
470
|
-
const isRenderingPostOnly = getRenderingMode() === 'post-only';
|
|
451
|
+
const { getEditorMode, getDefaultRenderingMode, getDeviceType } =
|
|
452
|
+
unlock( select( editorStore ) );
|
|
471
453
|
const isNotDesignPostType =
|
|
472
454
|
! DESIGN_POST_TYPES.includes( currentPostType );
|
|
473
455
|
const isDirectlyEditingPattern =
|
|
@@ -498,8 +480,6 @@ function Layout( {
|
|
|
498
480
|
! isEditingTemplate
|
|
499
481
|
? _templateId
|
|
500
482
|
: null,
|
|
501
|
-
enablePaddingAppender:
|
|
502
|
-
! isZoomOut() && isRenderingPostOnly && isNotDesignPostType,
|
|
503
483
|
isDevicePreview: getDeviceType() !== 'Desktop',
|
|
504
484
|
};
|
|
505
485
|
},
|
|
@@ -514,16 +494,12 @@ function Layout( {
|
|
|
514
494
|
|
|
515
495
|
useMetaBoxInitialization( hasActiveMetaboxes && hasResolvedMode );
|
|
516
496
|
|
|
517
|
-
const [ paddingAppenderRef, paddingStyle ] = usePaddingAppender(
|
|
518
|
-
enablePaddingAppender
|
|
519
|
-
);
|
|
520
|
-
|
|
521
497
|
// Set the right context for the command palette
|
|
522
498
|
const commandContext = hasBlockSelected
|
|
523
499
|
? 'block-selection-edit'
|
|
524
500
|
: 'entity-edit';
|
|
525
501
|
useCommandContext( commandContext );
|
|
526
|
-
const styles = useEditorStyles( settings
|
|
502
|
+
const styles = useEditorStyles( settings );
|
|
527
503
|
const editorSettings = useMemo(
|
|
528
504
|
() => ( {
|
|
529
505
|
...settings,
|
|
@@ -646,7 +622,6 @@ function Layout( {
|
|
|
646
622
|
templateId={ templateId }
|
|
647
623
|
className={ className }
|
|
648
624
|
forceIsDirty={ hasActiveMetaboxes }
|
|
649
|
-
contentRef={ paddingAppenderRef }
|
|
650
625
|
disableIframe={ ! shouldIframe }
|
|
651
626
|
// We should auto-focus the canvas (title) on load.
|
|
652
627
|
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var use_padding_appender_exports = {};
|
|
19
|
-
__export(use_padding_appender_exports, {
|
|
20
|
-
usePaddingAppender: () => usePaddingAppender
|
|
21
|
-
});
|
|
22
|
-
module.exports = __toCommonJS(use_padding_appender_exports);
|
|
23
|
-
var import_data = require("@wordpress/data");
|
|
24
|
-
var import_compose = require("@wordpress/compose");
|
|
25
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
26
|
-
var import_blocks = require("@wordpress/blocks");
|
|
27
|
-
const CSS = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
|
|
28
|
-
function usePaddingAppender(enabled) {
|
|
29
|
-
const registry = (0, import_data.useRegistry)();
|
|
30
|
-
const effect = (0, import_compose.useRefEffect)(
|
|
31
|
-
(node) => {
|
|
32
|
-
function onMouseDown(event) {
|
|
33
|
-
if (event.target !== node && // Tests for the parent element because in the iframed editor if the click is
|
|
34
|
-
// below the padding the target will be the parent element (html) and should
|
|
35
|
-
// still be treated as intent to append.
|
|
36
|
-
event.target !== node.parentElement) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const lastChild = node.lastElementChild;
|
|
40
|
-
if (!lastChild) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const lastChildRect = lastChild.getBoundingClientRect();
|
|
44
|
-
if (event.clientY < lastChildRect.bottom) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
event.preventDefault();
|
|
48
|
-
const blockOrder = registry.select(import_block_editor.store).getBlockOrder("");
|
|
49
|
-
const lastBlockClientId = blockOrder[blockOrder.length - 1];
|
|
50
|
-
const lastBlock = registry.select(import_block_editor.store).getBlock(lastBlockClientId);
|
|
51
|
-
const { selectBlock, insertDefaultBlock } = registry.dispatch(import_block_editor.store);
|
|
52
|
-
if (lastBlock && (0, import_blocks.isUnmodifiedDefaultBlock)(lastBlock)) {
|
|
53
|
-
selectBlock(lastBlockClientId);
|
|
54
|
-
} else {
|
|
55
|
-
insertDefaultBlock();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
const { ownerDocument } = node;
|
|
59
|
-
ownerDocument.addEventListener("mousedown", onMouseDown);
|
|
60
|
-
return () => {
|
|
61
|
-
ownerDocument.removeEventListener("mousedown", onMouseDown);
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
[registry]
|
|
65
|
-
);
|
|
66
|
-
return enabled ? [effect, CSS] : [];
|
|
67
|
-
}
|
|
68
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
69
|
-
0 && (module.exports = {
|
|
70
|
-
usePaddingAppender
|
|
71
|
-
});
|
|
72
|
-
//# sourceMappingURL=use-padding-appender.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/use-padding-appender.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n// Ruleset to add space for the typewriter effect. When typing in the last\n// block, there needs to be room to scroll up.\nconst CSS =\n\t':root :where(.editor-styles-wrapper)::after {content: \"\"; display: block; height: 40vh;}';\n\nexport function usePaddingAppender( enabled ) {\n\tconst registry = useRegistry();\n\tconst effect = useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\tif (\n\t\t\t\t\tevent.target !== node &&\n\t\t\t\t\t// Tests for the parent element because in the iframed editor if the click is\n\t\t\t\t\t// below the padding the target will be the parent element (html) and should\n\t\t\t\t\t// still be treated as intent to append.\n\t\t\t\t\tevent.target !== node.parentElement\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle clicks under the last child.\n\t\t\t\tconst lastChild = node.lastElementChild;\n\t\t\t\tif ( ! lastChild ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst lastChildRect = lastChild.getBoundingClientRect();\n\t\t\t\tif ( event.clientY < lastChildRect.bottom ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst blockOrder = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlockOrder( '' );\n\t\t\t\tconst lastBlockClientId = blockOrder[ blockOrder.length - 1 ];\n\n\t\t\t\tconst lastBlock = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlock( lastBlockClientId );\n\t\t\t\tconst { selectBlock, insertDefaultBlock } =\n\t\t\t\t\tregistry.dispatch( blockEditorStore );\n\n\t\t\t\tif ( lastBlock && isUnmodifiedDefaultBlock( lastBlock ) ) {\n\t\t\t\t\tselectBlock( lastBlockClientId );\n\t\t\t\t} else {\n\t\t\t\t\tinsertDefaultBlock();\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst { ownerDocument } = node;\n\t\t\t// Adds the listener on the document so that in the iframed editor clicks below the\n\t\t\t// padding can be handled as they too should be treated as intent to append.\n\t\t\townerDocument.addEventListener( 'mousedown', onMouseDown );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[ registry ]\n\t);\n\treturn enabled ? [ effect, CSS ] : [];\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAA4B;AAC5B,qBAA6B;AAC7B,0BAA0C;AAC1C,oBAAyC;AAIzC,MAAM,MACL;AAEM,SAAS,mBAAoB,SAAU;AAC7C,QAAM,eAAW,yBAAY;AAC7B,QAAM,aAAS;AAAA,IACd,CAAE,SAAU;AACX,eAAS,YAAa,OAAQ;AAC7B,YACC,MAAM,WAAW;AAAA;AAAA;AAAA,QAIjB,MAAM,WAAW,KAAK,eACrB;AACD;AAAA,QACD;AAGA,cAAM,YAAY,KAAK;AACvB,YAAK,CAAE,WAAY;AAClB;AAAA,QACD;AAEA,cAAM,gBAAgB,UAAU,sBAAsB;AACtD,YAAK,MAAM,UAAU,cAAc,QAAS;AAC3C;AAAA,QACD;AAEA,cAAM,eAAe;AAErB,cAAM,aAAa,SACjB,OAAQ,oBAAAA,KAAiB,EACzB,cAAe,EAAG;AACpB,cAAM,oBAAoB,WAAY,WAAW,SAAS,CAAE;AAE5D,cAAM,YAAY,SAChB,OAAQ,oBAAAA,KAAiB,EACzB,SAAU,iBAAkB;AAC9B,cAAM,EAAE,aAAa,mBAAmB,IACvC,SAAS,SAAU,oBAAAA,KAAiB;AAErC,YAAK,iBAAa,wCAA0B,SAAU,GAAI;AACzD,sBAAa,iBAAkB;AAAA,QAChC,OAAO;AACN,6BAAmB;AAAA,QACpB;AAAA,MACD;AACA,YAAM,EAAE,cAAc,IAAI;AAG1B,oBAAc,iBAAkB,aAAa,WAAY;AACzD,aAAO,MAAM;AACZ,sBAAc,oBAAqB,aAAa,WAAY;AAAA,MAC7D;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACA,SAAO,UAAU,CAAE,QAAQ,GAAI,IAAI,CAAC;AACrC;",
|
|
6
|
-
"names": ["blockEditorStore"]
|
|
7
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { useRegistry } from "@wordpress/data";
|
|
2
|
-
import { useRefEffect } from "@wordpress/compose";
|
|
3
|
-
import { store as blockEditorStore } from "@wordpress/block-editor";
|
|
4
|
-
import { isUnmodifiedDefaultBlock } from "@wordpress/blocks";
|
|
5
|
-
const CSS = ':root :where(.editor-styles-wrapper)::after {content: ""; display: block; height: 40vh;}';
|
|
6
|
-
function usePaddingAppender(enabled) {
|
|
7
|
-
const registry = useRegistry();
|
|
8
|
-
const effect = useRefEffect(
|
|
9
|
-
(node) => {
|
|
10
|
-
function onMouseDown(event) {
|
|
11
|
-
if (event.target !== node && // Tests for the parent element because in the iframed editor if the click is
|
|
12
|
-
// below the padding the target will be the parent element (html) and should
|
|
13
|
-
// still be treated as intent to append.
|
|
14
|
-
event.target !== node.parentElement) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const lastChild = node.lastElementChild;
|
|
18
|
-
if (!lastChild) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
const lastChildRect = lastChild.getBoundingClientRect();
|
|
22
|
-
if (event.clientY < lastChildRect.bottom) {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
event.preventDefault();
|
|
26
|
-
const blockOrder = registry.select(blockEditorStore).getBlockOrder("");
|
|
27
|
-
const lastBlockClientId = blockOrder[blockOrder.length - 1];
|
|
28
|
-
const lastBlock = registry.select(blockEditorStore).getBlock(lastBlockClientId);
|
|
29
|
-
const { selectBlock, insertDefaultBlock } = registry.dispatch(blockEditorStore);
|
|
30
|
-
if (lastBlock && isUnmodifiedDefaultBlock(lastBlock)) {
|
|
31
|
-
selectBlock(lastBlockClientId);
|
|
32
|
-
} else {
|
|
33
|
-
insertDefaultBlock();
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
const { ownerDocument } = node;
|
|
37
|
-
ownerDocument.addEventListener("mousedown", onMouseDown);
|
|
38
|
-
return () => {
|
|
39
|
-
ownerDocument.removeEventListener("mousedown", onMouseDown);
|
|
40
|
-
};
|
|
41
|
-
},
|
|
42
|
-
[registry]
|
|
43
|
-
);
|
|
44
|
-
return enabled ? [effect, CSS] : [];
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
usePaddingAppender
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=use-padding-appender.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/layout/use-padding-appender.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\n// Ruleset to add space for the typewriter effect. When typing in the last\n// block, there needs to be room to scroll up.\nconst CSS =\n\t':root :where(.editor-styles-wrapper)::after {content: \"\"; display: block; height: 40vh;}';\n\nexport function usePaddingAppender( enabled ) {\n\tconst registry = useRegistry();\n\tconst effect = useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\tif (\n\t\t\t\t\tevent.target !== node &&\n\t\t\t\t\t// Tests for the parent element because in the iframed editor if the click is\n\t\t\t\t\t// below the padding the target will be the parent element (html) and should\n\t\t\t\t\t// still be treated as intent to append.\n\t\t\t\t\tevent.target !== node.parentElement\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle clicks under the last child.\n\t\t\t\tconst lastChild = node.lastElementChild;\n\t\t\t\tif ( ! lastChild ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst lastChildRect = lastChild.getBoundingClientRect();\n\t\t\t\tif ( event.clientY < lastChildRect.bottom ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst blockOrder = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlockOrder( '' );\n\t\t\t\tconst lastBlockClientId = blockOrder[ blockOrder.length - 1 ];\n\n\t\t\t\tconst lastBlock = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlock( lastBlockClientId );\n\t\t\t\tconst { selectBlock, insertDefaultBlock } =\n\t\t\t\t\tregistry.dispatch( blockEditorStore );\n\n\t\t\t\tif ( lastBlock && isUnmodifiedDefaultBlock( lastBlock ) ) {\n\t\t\t\t\tselectBlock( lastBlockClientId );\n\t\t\t\t} else {\n\t\t\t\t\tinsertDefaultBlock();\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst { ownerDocument } = node;\n\t\t\t// Adds the listener on the document so that in the iframed editor clicks below the\n\t\t\t// padding can be handled as they too should be treated as intent to append.\n\t\t\townerDocument.addEventListener( 'mousedown', onMouseDown );\n\t\t\treturn () => {\n\t\t\t\townerDocument.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[ registry ]\n\t);\n\treturn enabled ? [ effect, CSS ] : [];\n}\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,mBAAmB;AAC5B,SAAS,oBAAoB;AAC7B,SAAS,SAAS,wBAAwB;AAC1C,SAAS,gCAAgC;AAIzC,MAAM,MACL;AAEM,SAAS,mBAAoB,SAAU;AAC7C,QAAM,WAAW,YAAY;AAC7B,QAAM,SAAS;AAAA,IACd,CAAE,SAAU;AACX,eAAS,YAAa,OAAQ;AAC7B,YACC,MAAM,WAAW;AAAA;AAAA;AAAA,QAIjB,MAAM,WAAW,KAAK,eACrB;AACD;AAAA,QACD;AAGA,cAAM,YAAY,KAAK;AACvB,YAAK,CAAE,WAAY;AAClB;AAAA,QACD;AAEA,cAAM,gBAAgB,UAAU,sBAAsB;AACtD,YAAK,MAAM,UAAU,cAAc,QAAS;AAC3C;AAAA,QACD;AAEA,cAAM,eAAe;AAErB,cAAM,aAAa,SACjB,OAAQ,gBAAiB,EACzB,cAAe,EAAG;AACpB,cAAM,oBAAoB,WAAY,WAAW,SAAS,CAAE;AAE5D,cAAM,YAAY,SAChB,OAAQ,gBAAiB,EACzB,SAAU,iBAAkB;AAC9B,cAAM,EAAE,aAAa,mBAAmB,IACvC,SAAS,SAAU,gBAAiB;AAErC,YAAK,aAAa,yBAA0B,SAAU,GAAI;AACzD,sBAAa,iBAAkB;AAAA,QAChC,OAAO;AACN,6BAAmB;AAAA,QACpB;AAAA,MACD;AACA,YAAM,EAAE,cAAc,IAAI;AAG1B,oBAAc,iBAAkB,aAAa,WAAY;AACzD,aAAO,MAAM;AACZ,sBAAc,oBAAqB,aAAa,WAAY;AAAA,MAC7D;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AACA,SAAO,UAAU,CAAE,QAAQ,GAAI,IAAI,CAAC;AACrC;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|