@wordpress/edit-post 6.2.0 → 6.3.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/sidebar/post-link/index.js +1 -1
  3. package/build/components/sidebar/post-link/index.js.map +1 -1
  4. package/build/components/visual-editor/index.js +3 -3
  5. package/build/components/visual-editor/index.js.map +1 -1
  6. package/build/editor.js +3 -2
  7. package/build/editor.js.map +1 -1
  8. package/build/index.js +3 -0
  9. package/build/index.js.map +1 -1
  10. package/build/index.native.js +3 -0
  11. package/build/index.native.js.map +1 -1
  12. package/build/store/actions.js +76 -49
  13. package/build/store/actions.js.map +1 -1
  14. package/build/store/index.js +7 -10
  15. package/build/store/index.js.map +1 -1
  16. package/build/store/reducer.js +0 -80
  17. package/build/store/reducer.js.map +1 -1
  18. package/build/store/selectors.js +86 -25
  19. package/build/store/selectors.js.map +1 -1
  20. package/build-module/components/sidebar/post-link/index.js +1 -1
  21. package/build-module/components/sidebar/post-link/index.js.map +1 -1
  22. package/build-module/components/visual-editor/index.js +3 -3
  23. package/build-module/components/visual-editor/index.js.map +1 -1
  24. package/build-module/editor.js +2 -2
  25. package/build-module/editor.js.map +1 -1
  26. package/build-module/index.js +3 -0
  27. package/build-module/index.js.map +1 -1
  28. package/build-module/index.native.js +3 -0
  29. package/build-module/index.native.js.map +1 -1
  30. package/build-module/store/actions.js +71 -45
  31. package/build-module/store/actions.js.map +1 -1
  32. package/build-module/store/index.js +7 -10
  33. package/build-module/store/index.js.map +1 -1
  34. package/build-module/store/reducer.js +1 -77
  35. package/build-module/store/reducer.js.map +1 -1
  36. package/build-module/store/selectors.js +82 -23
  37. package/build-module/store/selectors.js.map +1 -1
  38. package/build-style/style-rtl.css +0 -3
  39. package/build-style/style.css +0 -3
  40. package/package.json +27 -26
  41. package/src/components/sidebar/post-link/index.js +1 -1
  42. package/src/components/visual-editor/index.js +5 -3
  43. package/src/editor.js +3 -2
  44. package/src/index.js +3 -0
  45. package/src/index.native.js +3 -0
  46. package/src/store/actions.js +47 -15
  47. package/src/store/index.js +7 -11
  48. package/src/store/reducer.js +1 -74
  49. package/src/store/selectors.js +121 -51
  50. package/src/store/test/actions.js +30 -33
  51. package/src/store/test/reducer.js +0 -126
  52. package/src/store/test/selectors.js +0 -155
  53. package/src/style.scss +0 -4
  54. package/build/store/defaults.js +0 -15
  55. package/build/store/defaults.js.map +0 -1
  56. package/build-module/store/defaults.js +0 -8
  57. package/build-module/store/defaults.js.map +0 -1
  58. package/src/store/defaults.js +0 -7
@@ -2,7 +2,7 @@
2
2
  * External dependencies
3
3
  */
4
4
  import createSelector from 'rememo';
5
- import { get, includes, some, flatten, values } from 'lodash';
5
+ import { includes, some, flatten, values } from 'lodash';
6
6
  /**
7
7
  * WordPress dependencies
8
8
  */
@@ -12,7 +12,9 @@ import { store as interfaceStore } from '@wordpress/interface';
12
12
  import { store as preferencesStore } from '@wordpress/preferences';
13
13
  import { store as coreStore } from '@wordpress/core-data';
14
14
  import { store as editorStore } from '@wordpress/editor';
15
+ import deprecated from '@wordpress/deprecated';
15
16
  const EMPTY_ARRAY = [];
17
+ const EMPTY_OBJECT = {};
16
18
  /**
17
19
  * Returns the current editing mode.
18
20
  *
@@ -67,10 +69,53 @@ export const isPluginSidebarOpened = createRegistrySelector(select => () => {
67
69
 
68
70
  export const getActiveGeneralSidebarName = createRegistrySelector(select => () => {
69
71
  return select(interfaceStore).getActiveComplementaryArea('core/edit-post');
70
- }); // The current list of preference keys that have been migrated to the
71
- // preferences package.
72
+ });
73
+ /**
74
+ * Converts panels from the new preferences store format to the old format
75
+ * that the post editor previously used.
76
+ *
77
+ * The resultant converted data should look like this:
78
+ * {
79
+ * panelName: {
80
+ * enabled: false,
81
+ * opened: true,
82
+ * },
83
+ * anotherPanelName: {
84
+ * opened: true
85
+ * },
86
+ * }
87
+ *
88
+ * @param {string[] | undefined} inactivePanels An array of inactive panel names.
89
+ * @param {string[] | undefined} openPanels An array of open panel names.
90
+ *
91
+ * @return {Object} The converted panel data.
92
+ */
93
+
94
+ function convertPanelsToOldFormat(inactivePanels, openPanels) {
95
+ var _ref;
96
+
97
+ // First reduce the inactive panels.
98
+ const panelsWithEnabledState = inactivePanels === null || inactivePanels === void 0 ? void 0 : inactivePanels.reduce((accumulatedPanels, panelName) => ({ ...accumulatedPanels,
99
+ [panelName]: {
100
+ enabled: false
101
+ }
102
+ }), {}); // Then reduce the open panels, passing in the result of the previous
103
+ // reduction as the initial value so that both open and inactive
104
+ // panel state is combined.
105
+
106
+ const panels = openPanels === null || openPanels === void 0 ? void 0 : openPanels.reduce((accumulatedPanels, panelName) => {
107
+ const currentPanelState = accumulatedPanels === null || accumulatedPanels === void 0 ? void 0 : accumulatedPanels[panelName];
108
+ return { ...accumulatedPanels,
109
+ [panelName]: { ...currentPanelState,
110
+ opened: true
111
+ }
112
+ };
113
+ }, panelsWithEnabledState !== null && panelsWithEnabledState !== void 0 ? panelsWithEnabledState : {}); // The panels variable will only be set if openPanels wasn't `undefined`.
114
+ // If it isn't set just return `panelsWithEnabledState`, and if that isn't
115
+ // set return an empty object.
72
116
 
73
- const MIGRATED_KEYS = ['hiddenBlockTypes', 'editorMode', 'preferredStyleVariations'];
117
+ return (_ref = panels !== null && panels !== void 0 ? panels : panelsWithEnabledState) !== null && _ref !== void 0 ? _ref : EMPTY_OBJECT;
118
+ }
74
119
  /**
75
120
  * Returns the preferences (these preferences are persisted locally).
76
121
  *
@@ -79,19 +124,30 @@ const MIGRATED_KEYS = ['hiddenBlockTypes', 'editorMode', 'preferredStyleVariatio
79
124
  * @return {Object} Preferences Object.
80
125
  */
81
126
 
82
- export const getPreferences = createRegistrySelector(select => state => {
83
- const editPostPreferences = state.preferences; // Some preferences now exist in the preferences store.
127
+
128
+ export const getPreferences = createRegistrySelector(select => () => {
129
+ deprecated(`wp.data.select( 'core/edit-post' ).getPreferences`, {
130
+ since: '6.0',
131
+ alternative: `wp.data.select( 'core/preferences' ).get`
132
+ }); // These preferences now exist in the preferences store.
84
133
  // Fetch them so that they can be merged into the post
85
134
  // editor preferences.
86
135
 
87
- const preferenceStorePreferences = MIGRATED_KEYS.reduce((accumulatedPrefs, preferenceKey) => {
136
+ const preferences = ['hiddenBlockTypes', 'editorMode', 'preferredStyleVariations'].reduce((accumulatedPrefs, preferenceKey) => {
88
137
  const value = select(preferencesStore).get('core/edit-post', preferenceKey);
89
138
  return { ...accumulatedPrefs,
90
139
  [preferenceKey]: value
91
140
  };
92
- }, {});
93
- return { ...editPostPreferences,
94
- ...preferenceStorePreferences
141
+ }, {}); // Panels were a preference, but the data structure changed when the state
142
+ // was migrated to the preferences store. They need to be converted from
143
+ // the new preferences store format to old format to ensure no breaking
144
+ // changes for plugins.
145
+
146
+ const inactivePanels = select(preferencesStore).get('core/edit-post', 'inactivePanels');
147
+ const openPanels = select(preferencesStore).get('core/edit-post', 'openPanels');
148
+ const panels = convertPanelsToOldFormat(inactivePanels, openPanels);
149
+ return { ...preferences,
150
+ panels
95
151
  };
96
152
  });
97
153
  /**
@@ -104,9 +160,12 @@ export const getPreferences = createRegistrySelector(select => state => {
104
160
  */
105
161
 
106
162
  export function getPreference(state, preferenceKey, defaultValue) {
107
- // Avoid using the `getPreferences` registry selector where possible.
108
- const isMigratedKey = MIGRATED_KEYS.includes(preferenceKey);
109
- const preferences = isMigratedKey ? getPreferences(state) : state.preferences;
163
+ deprecated(`wp.data.select( 'core/edit-post' ).getPreference`, {
164
+ since: '6.0',
165
+ alternative: `wp.data.select( 'core/preferences' ).get`
166
+ }); // Avoid using the `getPreferences` registry selector where possible.
167
+
168
+ const preferences = getPreferences(state);
110
169
  const value = preferences[preferenceKey];
111
170
  return value === undefined ? defaultValue : value;
112
171
  }
@@ -155,10 +214,10 @@ export function isEditorPanelRemoved(state, panelName) {
155
214
  * @return {boolean} Whether or not the panel is enabled.
156
215
  */
157
216
 
158
- export function isEditorPanelEnabled(state, panelName) {
159
- const panels = getPreference(state, 'panels');
160
- return !isEditorPanelRemoved(state, panelName) && get(panels, [panelName, 'enabled'], true);
161
- }
217
+ export const isEditorPanelEnabled = createRegistrySelector(select => (state, panelName) => {
218
+ const inactivePanels = select(preferencesStore).get('core/edit-post', 'inactivePanels');
219
+ return !isEditorPanelRemoved(state, panelName) && !(inactivePanels !== null && inactivePanels !== void 0 && inactivePanels.includes(panelName));
220
+ });
162
221
  /**
163
222
  * Returns true if the given panel is open, or false otherwise. Panels are
164
223
  * closed by default.
@@ -169,10 +228,10 @@ export function isEditorPanelEnabled(state, panelName) {
169
228
  * @return {boolean} Whether or not the panel is open.
170
229
  */
171
230
 
172
- export function isEditorPanelOpened(state, panelName) {
173
- const panels = getPreference(state, 'panels');
174
- return get(panels, [panelName]) === true || get(panels, [panelName, 'opened']) === true;
175
- }
231
+ export const isEditorPanelOpened = createRegistrySelector(select => (state, panelName) => {
232
+ const openPanels = select(preferencesStore).get('core/edit-post', 'openPanels');
233
+ return !!(openPanels !== null && openPanels !== void 0 && openPanels.includes(panelName));
234
+ });
176
235
  /**
177
236
  * Returns true if a modal is active, or false otherwise.
178
237
  *
@@ -231,10 +290,10 @@ export const getActiveMetaBoxLocations = createSelector(state => {
231
290
  */
232
291
 
233
292
  export function isMetaBoxLocationVisible(state, location) {
234
- return isMetaBoxLocationActive(state, location) && some(getMetaBoxesPerLocation(state, location), _ref => {
293
+ return isMetaBoxLocationActive(state, location) && some(getMetaBoxesPerLocation(state, location), _ref2 => {
235
294
  let {
236
295
  id
237
- } = _ref;
296
+ } = _ref2;
238
297
  return isEditorPanelEnabled(state, `meta-box-${id}`);
239
298
  });
240
299
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/store/selectors.js"],"names":["createSelector","get","includes","some","flatten","values","createRegistrySelector","store","interfaceStore","preferencesStore","coreStore","editorStore","EMPTY_ARRAY","getEditorMode","select","isEditorSidebarOpened","activeGeneralSidebar","getActiveComplementaryArea","isPluginSidebarOpened","getActiveGeneralSidebarName","MIGRATED_KEYS","getPreferences","state","editPostPreferences","preferences","preferenceStorePreferences","reduce","accumulatedPrefs","preferenceKey","value","getPreference","defaultValue","isMigratedKey","undefined","getHiddenBlockTypes","isPublishSidebarOpened","publishSidebarActive","isEditorPanelRemoved","panelName","removedPanels","isEditorPanelEnabled","panels","isEditorPanelOpened","isModalActive","modalName","activeModal","isFeatureActive","feature","isPluginItemPinned","pluginName","isItemPinned","getActiveMetaBoxLocations","Object","keys","metaBoxes","locations","filter","location","isMetaBoxLocationActive","isMetaBoxLocationVisible","getMetaBoxesPerLocation","id","length","getAllMetaBoxes","hasMetaBoxes","isSavingMetaBoxes","isSaving","__experimentalGetPreviewDeviceType","deviceType","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isEditingTemplate","areMetaBoxesInitialized","initialized","getEditedPostTemplate","currentTemplate","getEditedPostAttribute","templateWithSameSlug","getEntityRecords","per_page","find","template","slug","getEditedEntityRecord","post","getCurrentPost","link","__experimentalGetTemplateForLink"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AACA,SAASC,GAAT,EAAcC,QAAd,EAAwBC,IAAxB,EAA8BC,OAA9B,EAAuCC,MAAvC,QAAqD,QAArD;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AACA,SAASF,KAAK,IAAIG,SAAlB,QAAmC,sBAAnC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,mBAArC;AAEA,MAAMC,WAAW,GAAG,EAApB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAGP,sBAAsB,CAAIQ,MAAF,IAAc;AAAA;;AAAA,wBAClEA,MAAM,CAAEL,gBAAF,CAAN,CAA2BR,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nimport createSelector from 'rememo';\nimport { get, includes, some, flatten, values } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\n\nconst EMPTY_ARRAY = [];\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( ( select ) => () =>\n\tselect( preferencesStore ).get( 'core/edit-post', '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 = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn includes(\n\t\t\t[ 'edit-post/document', 'edit-post/block' ],\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 = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn (\n\t\t\t!! activeGeneralSidebar &&\n\t\t\t! includes(\n\t\t\t\t[ 'edit-post/document', 'edit-post/block' ],\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(\n\t\t\t'core/edit-post'\n\t\t);\n\t}\n);\n\n// The current list of preference keys that have been migrated to the\n// preferences package.\nconst MIGRATED_KEYS = [\n\t'hiddenBlockTypes',\n\t'editorMode',\n\t'preferredStyleVariations',\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(\n\t( select ) => ( state ) => {\n\t\tconst editPostPreferences = state.preferences;\n\n\t\t// Some preferences now exist in the preferences store.\n\t\t// Fetch them so that they can be merged into the post\n\t\t// editor preferences.\n\t\tconst preferenceStorePreferences = MIGRATED_KEYS.reduce(\n\t\t\t( accumulatedPrefs, preferenceKey ) => {\n\t\t\t\tconst value = select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\tpreferenceKey\n\t\t\t\t);\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulatedPrefs,\n\t\t\t\t\t[ preferenceKey ]: value,\n\t\t\t\t};\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\treturn {\n\t\t\t...editPostPreferences,\n\t\t\t...preferenceStorePreferences,\n\t\t};\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\t// Avoid using the `getPreferences` registry selector where possible.\n\tconst isMigratedKey = MIGRATED_KEYS.includes( preferenceKey );\n\tconst preferences = isMigratedKey\n\t\t? getPreferences( state )\n\t\t: state.preferences;\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(\n\t\t\t'core/edit-post',\n\t\t\t'hiddenBlockTypes'\n\t\t) ?? EMPTY_ARRAY\n\t);\n} );\n\n/**\n * Returns true if the publish sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the publish sidebar is open.\n */\nexport function isPublishSidebarOpened( state ) {\n\treturn state.publishSidebarActive;\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 * @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 function isEditorPanelRemoved( state, panelName ) {\n\treturn includes( state.removedPanels, panelName );\n}\n\n/**\n * Returns true if the given panel is enabled, or false otherwise. Panels are\n * enabled by default.\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 function isEditorPanelEnabled( state, panelName ) {\n\tconst panels = getPreference( state, 'panels' );\n\n\treturn (\n\t\t! isEditorPanelRemoved( state, panelName ) &&\n\t\tget( panels, [ panelName, 'enabled' ], true )\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 * @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 function isEditorPanelOpened( state, panelName ) {\n\tconst panels = getPreference( state, 'panels' );\n\treturn (\n\t\tget( panels, [ panelName ] ) === true ||\n\t\tget( panels, [ panelName, 'opened' ] ) === true\n\t);\n}\n\n/**\n * Returns true if a modal is active, or false otherwise.\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 function isModalActive( state, modalName ) {\n\treturn state.activeModal === modalName;\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(\n\t\t\t'core/edit-post',\n\t\t\tpluginName\n\t\t);\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 function isMetaBoxLocationVisible( state, location ) {\n\treturn (\n\t\tisMetaBoxLocationActive( state, location ) &&\n\t\tsome( getMetaBoxesPerLocation( state, location ), ( { id } ) => {\n\t\t\treturn isEditorPanelEnabled( state, `meta-box-${ id }` );\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 flatten( values( state.metaBoxes.locations ) );\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 * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\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 function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\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 function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns true if the template editing mode is enabled.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether we're editing the template.\n */\nexport function isEditingTemplate( state ) {\n\treturn state.isEditingTemplate;\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 currentTemplate = select( editorStore ).getEditedPostAttribute(\n\t\t\t'template'\n\t\t);\n\t\tif ( currentTemplate ) {\n\t\t\tconst templateWithSameSlug = select( coreStore )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )\n\t\t\t\t?.find( ( template ) => template.slug === currentTemplate );\n\t\t\tif ( ! templateWithSameSlug ) {\n\t\t\t\treturn templateWithSameSlug;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateWithSameSlug.id\n\t\t\t);\n\t\t}\n\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tif ( post.link ) {\n\t\t\treturn select( coreStore ).__experimentalGetTemplateForLink(\n\t\t\t\tpost.link\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/store/selectors.js"],"names":["createSelector","includes","some","flatten","values","createRegistrySelector","store","interfaceStore","preferencesStore","coreStore","editorStore","deprecated","EMPTY_ARRAY","EMPTY_OBJECT","getEditorMode","select","get","isEditorSidebarOpened","activeGeneralSidebar","getActiveComplementaryArea","isPluginSidebarOpened","getActiveGeneralSidebarName","convertPanelsToOldFormat","inactivePanels","openPanels","panelsWithEnabledState","reduce","accumulatedPanels","panelName","enabled","panels","currentPanelState","opened","getPreferences","since","alternative","preferences","accumulatedPrefs","preferenceKey","value","getPreference","state","defaultValue","undefined","getHiddenBlockTypes","isPublishSidebarOpened","publishSidebarActive","isEditorPanelRemoved","removedPanels","isEditorPanelEnabled","isEditorPanelOpened","isModalActive","modalName","activeModal","isFeatureActive","feature","isPluginItemPinned","pluginName","isItemPinned","getActiveMetaBoxLocations","Object","keys","metaBoxes","locations","filter","location","isMetaBoxLocationActive","isMetaBoxLocationVisible","getMetaBoxesPerLocation","id","length","getAllMetaBoxes","hasMetaBoxes","isSavingMetaBoxes","isSaving","__experimentalGetPreviewDeviceType","deviceType","isInserterOpened","blockInserterPanel","__experimentalGetInsertionPoint","rootClientId","insertionIndex","filterValue","isListViewOpened","listViewPanel","isEditingTemplate","areMetaBoxesInitialized","initialized","getEditedPostTemplate","currentTemplate","getEditedPostAttribute","templateWithSameSlug","getEntityRecords","per_page","find","template","slug","getEditedEntityRecord","post","getCurrentPost","link","__experimentalGetTemplateForLink"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,cAAP,MAA2B,QAA3B;AACA,SAASC,QAAT,EAAmBC,IAAnB,EAAyBC,OAAzB,EAAkCC,MAAlC,QAAgD,QAAhD;AAEA;AACA;AACA;;AACA,SAASC,sBAAT,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,cAAlB,QAAwC,sBAAxC;AACA,SAASD,KAAK,IAAIE,gBAAlB,QAA0C,wBAA1C;AACA,SAASF,KAAK,IAAIG,SAAlB,QAAmC,sBAAnC;AACA,SAASH,KAAK,IAAII,WAAlB,QAAqC,mBAArC;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AAEA,MAAMC,WAAW,GAAG,EAApB;AACA,MAAMC,YAAY,GAAG,EAArB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAGT,sBAAsB,CAAIU,MAAF,IAAc;AAAA;;AAAA,wBAClEA,MAAM,CAAEP,gBAAF,CAAN,CAA2BQ,GAA3B,CAAgC,gBAAhC,EAAkD,YAAlD,CADkE,qDACE,QADF;AAAA,CAAhB,CAA5C;AAIP;AACA;AACA;AACA;AACA;AACA;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IAAP;AACA,CA3ByD,CAApD","sourcesContent":["/**\n * External dependencies\n */\nimport createSelector from 'rememo';\nimport { includes, some, flatten, values } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport deprecated from '@wordpress/deprecated';\n\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( ( select ) => () =>\n\tselect( preferencesStore ).get( 'core/edit-post', '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 = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn includes(\n\t\t\t[ 'edit-post/document', 'edit-post/block' ],\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 = select(\n\t\t\tinterfaceStore\n\t\t).getActiveComplementaryArea( 'core/edit-post' );\n\t\treturn (\n\t\t\t!! activeGeneralSidebar &&\n\t\t\t! includes(\n\t\t\t\t[ 'edit-post/document', 'edit-post/block' ],\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(\n\t\t\t'core/edit-post'\n\t\t);\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( `wp.data.select( 'core/edit-post' ).getPreferences`, {\n\t\tsince: '6.0',\n\t\talternative: `wp.data.select( 'core/preferences' ).get`,\n\t} );\n\n\t// These preferences now exist in the preferences store.\n\t// Fetch them so that they can be merged into the post\n\t// editor preferences.\n\tconst preferences = [\n\t\t'hiddenBlockTypes',\n\t\t'editorMode',\n\t\t'preferredStyleVariations',\n\t].reduce( ( accumulatedPrefs, preferenceKey ) => {\n\t\tconst value = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\tpreferenceKey\n\t\t);\n\n\t\treturn {\n\t\t\t...accumulatedPrefs,\n\t\t\t[ preferenceKey ]: value,\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/edit-post',\n\t\t'inactivePanels'\n\t);\n\tconst openPanels = select( preferencesStore ).get(\n\t\t'core/edit-post',\n\t\t'openPanels'\n\t);\n\tconst panels = convertPanelsToOldFormat( inactivePanels, openPanels );\n\n\treturn {\n\t\t...preferences,\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( `wp.data.select( 'core/edit-post' ).getPreference`, {\n\t\tsince: '6.0',\n\t\talternative: `wp.data.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(\n\t\t\t'core/edit-post',\n\t\t\t'hiddenBlockTypes'\n\t\t) ?? EMPTY_ARRAY\n\t);\n} );\n\n/**\n * Returns true if the publish sidebar is opened.\n *\n * @param {Object} state Global application state\n *\n * @return {boolean} Whether the publish sidebar is open.\n */\nexport function isPublishSidebarOpened( state ) {\n\treturn state.publishSidebarActive;\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 * @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 function isEditorPanelRemoved( state, panelName ) {\n\treturn includes( state.removedPanels, panelName );\n}\n\n/**\n * Returns true if the given panel is enabled, or false otherwise. Panels are\n * enabled by default.\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\tconst inactivePanels = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'inactivePanels'\n\t\t);\n\t\treturn (\n\t\t\t! isEditorPanelRemoved( state, panelName ) &&\n\t\t\t! inactivePanels?.includes( panelName )\n\t\t);\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 * @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\tconst openPanels = select( preferencesStore ).get(\n\t\t\t'core/edit-post',\n\t\t\t'openPanels'\n\t\t);\n\t\treturn !! openPanels?.includes( panelName );\n\t}\n);\n\n/**\n * Returns true if a modal is active, or false otherwise.\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 function isModalActive( state, modalName ) {\n\treturn state.activeModal === modalName;\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(\n\t\t\t'core/edit-post',\n\t\t\tpluginName\n\t\t);\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 function isMetaBoxLocationVisible( state, location ) {\n\treturn (\n\t\tisMetaBoxLocationActive( state, location ) &&\n\t\tsome( getMetaBoxesPerLocation( state, location ), ( { id } ) => {\n\t\t\treturn isEditorPanelEnabled( state, `meta-box-${ id }` );\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 flatten( values( state.metaBoxes.locations ) );\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 * @param {Object} state Global application state.\n *\n * @return {string} Device type.\n */\nexport function __experimentalGetPreviewDeviceType( state ) {\n\treturn state.deviceType;\n}\n\n/**\n * Returns true if the inserter is opened.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether the inserter is opened.\n */\nexport function isInserterOpened( state ) {\n\treturn !! state.blockInserterPanel;\n}\n\n/**\n * Get the insertion point for the inserter.\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 function __experimentalGetInsertionPoint( state ) {\n\tconst {\n\t\trootClientId,\n\t\tinsertionIndex,\n\t\tfilterValue,\n\t} = state.blockInserterPanel;\n\treturn { rootClientId, insertionIndex, filterValue };\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 function isListViewOpened( state ) {\n\treturn state.listViewPanel;\n}\n\n/**\n * Returns true if the template editing mode is enabled.\n *\n * @param {Object} state Global application state.\n *\n * @return {boolean} Whether we're editing the template.\n */\nexport function isEditingTemplate( state ) {\n\treturn state.isEditingTemplate;\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 currentTemplate = select( editorStore ).getEditedPostAttribute(\n\t\t\t'template'\n\t\t);\n\t\tif ( currentTemplate ) {\n\t\t\tconst templateWithSameSlug = select( coreStore )\n\t\t\t\t.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )\n\t\t\t\t?.find( ( template ) => template.slug === currentTemplate );\n\t\t\tif ( ! templateWithSameSlug ) {\n\t\t\t\treturn templateWithSameSlug;\n\t\t\t}\n\t\t\treturn select( coreStore ).getEditedEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\ttemplateWithSameSlug.id\n\t\t\t);\n\t\t}\n\n\t\tconst post = select( editorStore ).getCurrentPost();\n\t\tif ( post.link ) {\n\t\t\treturn select( coreStore ).__experimentalGetTemplateForLink(\n\t\t\t\tpost.link\n\t\t\t);\n\t\t}\n\n\t\treturn null;\n\t}\n);\n"]}
@@ -1891,9 +1891,6 @@ body.block-editor-page .media-frame select.attachment-filters:last-of-type {
1891
1891
  max-width: 100%;
1892
1892
  height: auto;
1893
1893
  }
1894
- .block-editor__container iframe {
1895
- width: 100%;
1896
- }
1897
1894
 
1898
1895
  body.admin-color-light {
1899
1896
  --wp-admin-theme-color: #0085ba;
@@ -1895,9 +1895,6 @@ body.block-editor-page .media-frame select.attachment-filters:last-of-type {
1895
1895
  max-width: 100%;
1896
1896
  height: auto;
1897
1897
  }
1898
- .block-editor__container iframe {
1899
- width: 100%;
1900
- }
1901
1898
 
1902
1899
  body.admin-color-light {
1903
1900
  --wp-admin-theme-color: #0085ba;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/edit-post",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Edit Post module for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,30 +27,31 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^3.5.0",
31
- "@wordpress/api-fetch": "^6.2.0",
32
- "@wordpress/block-editor": "^8.4.0",
33
- "@wordpress/block-library": "^7.2.0",
34
- "@wordpress/blocks": "^11.4.0",
35
- "@wordpress/components": "^19.7.0",
36
- "@wordpress/compose": "^5.3.0",
37
- "@wordpress/core-data": "^4.3.0",
38
- "@wordpress/data": "^6.5.0",
39
- "@wordpress/editor": "^12.4.0",
40
- "@wordpress/element": "^4.3.0",
41
- "@wordpress/hooks": "^3.5.0",
42
- "@wordpress/i18n": "^4.5.0",
43
- "@wordpress/icons": "^8.1.0",
44
- "@wordpress/interface": "^4.4.0",
45
- "@wordpress/keyboard-shortcuts": "^3.3.0",
46
- "@wordpress/keycodes": "^3.5.0",
47
- "@wordpress/media-utils": "^3.3.0",
48
- "@wordpress/notices": "^3.5.0",
49
- "@wordpress/plugins": "^4.3.0",
50
- "@wordpress/preferences": "^1.1.0",
51
- "@wordpress/url": "^3.6.0",
52
- "@wordpress/viewport": "^4.3.0",
53
- "@wordpress/warning": "^2.5.0",
30
+ "@wordpress/a11y": "^3.6.0",
31
+ "@wordpress/api-fetch": "^6.3.0",
32
+ "@wordpress/block-editor": "^8.5.0",
33
+ "@wordpress/block-library": "^7.3.0",
34
+ "@wordpress/blocks": "^11.5.0",
35
+ "@wordpress/components": "^19.8.0",
36
+ "@wordpress/compose": "^5.4.0",
37
+ "@wordpress/core-data": "^4.4.0",
38
+ "@wordpress/data": "^6.6.0",
39
+ "@wordpress/deprecated": "^3.6.0",
40
+ "@wordpress/editor": "^12.5.0",
41
+ "@wordpress/element": "^4.4.0",
42
+ "@wordpress/hooks": "^3.6.0",
43
+ "@wordpress/i18n": "^4.6.0",
44
+ "@wordpress/icons": "^8.2.0",
45
+ "@wordpress/interface": "^4.5.0",
46
+ "@wordpress/keyboard-shortcuts": "^3.4.0",
47
+ "@wordpress/keycodes": "^3.6.0",
48
+ "@wordpress/media-utils": "^3.4.0",
49
+ "@wordpress/notices": "^3.6.0",
50
+ "@wordpress/plugins": "^4.4.0",
51
+ "@wordpress/preferences": "^1.2.0",
52
+ "@wordpress/url": "^3.7.0",
53
+ "@wordpress/viewport": "^4.4.0",
54
+ "@wordpress/warning": "^2.6.0",
54
55
  "classnames": "^2.3.1",
55
56
  "lodash": "^4.17.21",
56
57
  "memize": "^1.1.0",
@@ -63,5 +64,5 @@
63
64
  "publishConfig": {
64
65
  "access": "public"
65
66
  },
66
- "gitHead": "aa003c3634016cc4ab6348b2106907e371c648e1"
67
+ "gitHead": "11eb1241e63c9240018323551c6753f8a5fa96f9"
67
68
  }
@@ -97,7 +97,7 @@ function PostLink( {
97
97
  { __( 'The last part of the URL.' ) }{ ' ' }
98
98
  <ExternalLink
99
99
  href={ __(
100
- 'https://wordpress.org/support/article/writing-posts/#post-field-descriptions'
100
+ 'https://wordpress.org/support/article/settings-sidebar/#permalink'
101
101
  ) }
102
102
  >
103
103
  { __( 'Read about permalinks' ) }
@@ -124,8 +124,7 @@ export default function VisualEditor( { styles } ) {
124
124
  const { clearSelectedBlock } = useDispatch( blockEditorStore );
125
125
  const { setIsEditingTemplate } = useDispatch( editPostStore );
126
126
  const desktopCanvasStyles = {
127
- // We intentionally omit a 100% height here. The container is a flex item, so the 100% height is granted by default.
128
- // If a percentage height is present, older browsers such as Safari 13 apply that, but do so incorrectly as the inheritance is buggy.
127
+ height: '100%',
129
128
  width: '100%',
130
129
  margin: 0,
131
130
  display: 'flex',
@@ -237,7 +236,10 @@ export default function VisualEditor( { styles } ) {
237
236
  />
238
237
  ) }
239
238
  { ! isTemplateMode && (
240
- <div className="edit-post-visual-editor__post-title-wrapper">
239
+ <div
240
+ className="edit-post-visual-editor__post-title-wrapper"
241
+ contentEditable={ false }
242
+ >
241
243
  <PostTitle />
242
244
  </div>
243
245
  ) }
package/src/editor.js CHANGED
@@ -18,6 +18,7 @@ import { StrictMode, useMemo } from '@wordpress/element';
18
18
  import { SlotFillProvider } from '@wordpress/components';
19
19
  import { store as coreStore } from '@wordpress/core-data';
20
20
  import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
21
+ import { store as preferencesStore } from '@wordpress/preferences';
21
22
 
22
23
  /**
23
24
  * Internal dependencies
@@ -50,7 +51,6 @@ function Editor( {
50
51
  ( select ) => {
51
52
  const {
52
53
  isFeatureActive,
53
- getPreference,
54
54
  __experimentalGetPreviewDeviceType,
55
55
  isEditingTemplate,
56
56
  getEditedPostTemplate,
@@ -86,7 +86,8 @@ function Editor( {
86
86
  focusMode: isFeatureActive( 'focusMode' ),
87
87
  hasReducedUI: isFeatureActive( 'reducedUI' ),
88
88
  hasThemeStyles: isFeatureActive( 'themeStyles' ),
89
- preferredStyleVariations: getPreference(
89
+ preferredStyleVariations: select( preferencesStore ).get(
90
+ 'core/edit-post',
90
91
  'preferredStyleVariations'
91
92
  ),
92
93
  hiddenBlockTypes: getHiddenBlockTypes(),
package/src/index.js CHANGED
@@ -111,6 +111,9 @@ export function initializeEditor(
111
111
  fixedToolbar: false,
112
112
  fullscreenMode: true,
113
113
  hiddenBlockTypes: [],
114
+ inactivePanels: [],
115
+ isPublishSidebarEnabled: true,
116
+ openPanels: [ 'post-status' ],
114
117
  preferredStyleVariations: {},
115
118
  showBlockBreadcrumbs: true,
116
119
  showIconLabels: false,
@@ -26,6 +26,9 @@ export function initializeEditor( id, postType, postId ) {
26
26
  fixedToolbar: false,
27
27
  fullscreenMode: true,
28
28
  hiddenBlockTypes: [],
29
+ inactivePanels: [],
30
+ isPublishSidebarEnabled: true,
31
+ openPanels: [ 'post-status' ],
29
32
  preferredStyleVariations: {},
30
33
  welcomeGuide: true,
31
34
  } );
@@ -107,26 +107,58 @@ export function togglePublishSidebar() {
107
107
  *
108
108
  * @return {Object} Action object.
109
109
  */
110
- export function toggleEditorPanelEnabled( panelName ) {
111
- return {
112
- type: 'TOGGLE_PANEL_ENABLED',
113
- panelName,
114
- };
115
- }
110
+ export const toggleEditorPanelEnabled = ( panelName ) => ( { registry } ) => {
111
+ const inactivePanels =
112
+ registry
113
+ .select( preferencesStore )
114
+ .get( 'core/edit-post', 'inactivePanels' ) ?? [];
115
+
116
+ const isPanelInactive = !! inactivePanels?.includes( panelName );
117
+
118
+ // If the panel is inactive, remove it to enable it, else add it to
119
+ // make it inactive.
120
+ let updatedInactivePanels;
121
+ if ( isPanelInactive ) {
122
+ updatedInactivePanels = inactivePanels.filter(
123
+ ( invactivePanelName ) => invactivePanelName !== panelName
124
+ );
125
+ } else {
126
+ updatedInactivePanels = [ ...inactivePanels, panelName ];
127
+ }
128
+
129
+ registry
130
+ .dispatch( preferencesStore )
131
+ .set( 'core/edit-post', 'inactivePanels', updatedInactivePanels );
132
+ };
116
133
 
117
134
  /**
118
- * Returns an action object used to open or close a panel in the editor.
135
+ * Opens a closed panel and closes an open panel.
119
136
  *
120
137
  * @param {string} panelName A string that identifies the panel to open or close.
121
- *
122
- * @return {Object} Action object.
123
138
  */
124
- export function toggleEditorPanelOpened( panelName ) {
125
- return {
126
- type: 'TOGGLE_PANEL_OPENED',
127
- panelName,
128
- };
129
- }
139
+ export const toggleEditorPanelOpened = ( panelName ) => ( { registry } ) => {
140
+ const openPanels =
141
+ registry
142
+ .select( preferencesStore )
143
+ .get( 'core/edit-post', 'openPanels' ) ?? [];
144
+
145
+ const isPanelOpen = !! openPanels?.includes( panelName );
146
+
147
+ // If the panel is open, remove it to close it, else add it to
148
+ // make it open.
149
+ let updatedOpenPanels;
150
+ if ( isPanelOpen ) {
151
+ updatedOpenPanels = openPanels.filter(
152
+ ( openPanelName ) => openPanelName !== panelName
153
+ );
154
+ } else {
155
+ updatedOpenPanels = [ ...openPanels, panelName ];
156
+ }
157
+
158
+ registry
159
+ .dispatch( preferencesStore )
160
+ .set( 'core/edit-post', 'openPanels', updatedOpenPanels );
161
+ };
130
162
 
131
163
  /**
132
164
  * Returns an action object used to remove a panel from the editor.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createReduxStore, registerStore } from '@wordpress/data';
4
+ import { createReduxStore, register } from '@wordpress/data';
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -11,13 +11,6 @@ import * as actions from './actions';
11
11
  import * as selectors from './selectors';
12
12
  import { STORE_NAME } from './constants';
13
13
 
14
- const storeConfig = {
15
- reducer,
16
- actions,
17
- selectors,
18
- persist: [ 'preferences' ],
19
- };
20
-
21
14
  /**
22
15
  * Store definition for the edit post namespace.
23
16
  *
@@ -25,7 +18,10 @@ const storeConfig = {
25
18
  *
26
19
  * @type {Object}
27
20
  */
28
- export const store = createReduxStore( STORE_NAME, storeConfig );
21
+ export const store = createReduxStore( STORE_NAME, {
22
+ reducer,
23
+ actions,
24
+ selectors,
25
+ } );
29
26
 
30
- // Ideally we use register instead of register store.
31
- registerStore( STORE_NAME, storeConfig );
27
+ register( store );