@wordpress/edit-post 7.27.2 → 7.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +1 -2
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -1
- package/build/components/browser-url/index.js +1 -2
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js +11 -8
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js +1 -2
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +6 -5
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/main-dashboard-button/index.js +1 -2
- package/build/components/header/main-dashboard-button/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +1 -2
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +1 -2
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/plugin-more-menu-item/index.js +1 -2
- package/build/components/header/plugin-more-menu-item/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js +1 -2
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js +1 -2
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +4 -18
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -5
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +1 -2
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -2
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/actions-panel.js +1 -2
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js +7 -5
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +1 -2
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js +1 -2
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +1 -2
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/preferences-modal/enable-custom-fields.js +1 -2
- package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js +1 -2
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js +1 -2
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +1 -1
- package/build/components/preferences-modal/index.js +1 -2
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +1 -2
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js +1 -2
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-post-publish-panel/index.js +1 -2
- package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +1 -2
- package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build/components/sidebar/plugin-pre-publish-panel/index.js +1 -2
- package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
- package/build/components/sidebar/post-format/index.js +1 -2
- package/build/components/sidebar/post-format/index.js.map +1 -1
- package/build/components/sidebar/post-pending-status/index.js +1 -2
- package/build/components/sidebar/post-pending-status/index.js.map +1 -1
- package/build/components/sidebar/post-slug/index.js +1 -2
- package/build/components/sidebar/post-slug/index.js.map +1 -1
- package/build/components/sidebar/post-sticky/index.js +1 -2
- package/build/components/sidebar/post-sticky/index.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js +2 -2
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js +12 -4
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +28 -6
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/sidebar/template-summary/index.js +1 -2
- package/build/components/sidebar/template-summary/index.js.map +1 -1
- package/build/components/visual-editor/block-inspector-button.js +1 -2
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/components/visual-editor/header.native.js +1 -2
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/editor.js +32 -21
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -2
- package/build/editor.native.js.map +1 -1
- package/build/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +20 -26
- package/build/hooks/use-navigate-to-entity-record.js.map +1 -0
- package/build/hooks/validate-multiple-use/index.js +25 -4
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +1 -2
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +1 -1
- package/build/store/actions.js +7 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -6
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +3 -4
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +1 -2
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +21 -42
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js +10 -6
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/index.js +5 -3
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +4 -17
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +6 -3
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js +1 -0
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js +12 -3
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +27 -3
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/editor.js +31 -19
- package/build-module/editor.js.map +1 -1
- package/build-module/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +20 -26
- package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -0
- package/build-module/hooks/validate-multiple-use/index.js +26 -4
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/store/actions.js +7 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-style/style-rtl.css +29 -22
- package/build-style/style.css +29 -22
- package/package.json +32 -32
- package/src/components/header/fullscreen-mode-close/index.js +13 -10
- package/src/components/header/fullscreen-mode-close/test/index.js +31 -5
- package/src/components/header/index.js +8 -3
- package/src/components/header/style.scss +40 -26
- package/src/components/header/writing-menu/index.js +3 -16
- package/src/components/layout/index.js +3 -2
- package/src/components/sidebar/post-visibility/index.js +1 -0
- package/src/components/sidebar/settings-header/index.js +16 -5
- package/src/components/sidebar/settings-sidebar/index.js +37 -2
- package/src/components/visual-editor/style.scss +1 -1
- package/src/editor.js +34 -21
- package/src/hooks/{use-post-history.js → use-navigate-to-entity-record.js} +23 -27
- package/src/hooks/validate-multiple-use/index.js +28 -3
- package/src/store/actions.js +20 -3
- package/src/style.scss +0 -1
- package/src/test/editor.native.js +8 -5
- package/build/hooks/use-post-history.js.map +0 -1
- package/build-module/hooks/use-post-history.js.map +0 -1
|
@@ -8,6 +8,7 @@ var _react = require("react");
|
|
|
8
8
|
var _components = require("@wordpress/components");
|
|
9
9
|
var _i18n = require("@wordpress/i18n");
|
|
10
10
|
var _data = require("@wordpress/data");
|
|
11
|
+
var _element = require("@wordpress/element");
|
|
11
12
|
var _editor = require("@wordpress/editor");
|
|
12
13
|
var _lockUnlock = require("../../../lock-unlock");
|
|
13
14
|
var _settingsSidebar = require("../settings-sidebar");
|
|
@@ -22,7 +23,7 @@ var _settingsSidebar = require("../settings-sidebar");
|
|
|
22
23
|
const {
|
|
23
24
|
Tabs
|
|
24
25
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
25
|
-
const SettingsHeader = () => {
|
|
26
|
+
const SettingsHeader = (_, ref) => {
|
|
26
27
|
const {
|
|
27
28
|
documentLabel
|
|
28
29
|
} = (0, _data.useSelect)(select => {
|
|
@@ -34,12 +35,19 @@ const SettingsHeader = () => {
|
|
|
34
35
|
documentLabel: getPostTypeLabel() || (0, _i18n._x)('Document', 'noun')
|
|
35
36
|
};
|
|
36
37
|
}, []);
|
|
37
|
-
return (0, _react.createElement)(Tabs.TabList,
|
|
38
|
+
return (0, _react.createElement)(Tabs.TabList, {
|
|
39
|
+
ref: ref
|
|
40
|
+
}, (0, _react.createElement)(Tabs.Tab, {
|
|
38
41
|
tabId: _settingsSidebar.sidebars.document
|
|
42
|
+
// Used for focus management in the SettingsSidebar component.
|
|
43
|
+
,
|
|
44
|
+
"data-tab-id": _settingsSidebar.sidebars.document
|
|
39
45
|
}, documentLabel), (0, _react.createElement)(Tabs.Tab, {
|
|
40
46
|
tabId: _settingsSidebar.sidebars.block
|
|
47
|
+
// Used for focus management in the SettingsSidebar component.
|
|
48
|
+
,
|
|
49
|
+
"data-tab-id": _settingsSidebar.sidebars.block
|
|
41
50
|
}, (0, _i18n.__)('Block')));
|
|
42
51
|
};
|
|
43
|
-
var _default = SettingsHeader;
|
|
44
|
-
exports.default = _default;
|
|
52
|
+
var _default = exports.default = (0, _element.forwardRef)(SettingsHeader);
|
|
45
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_data","_editor","_lockUnlock","_settingsSidebar","Tabs","unlock","componentsPrivateApis","SettingsHeader","documentLabel","useSelect","select","getPostTypeLabel","editorStore","_x","_react","createElement","TabList","Tab","tabId","sidebars","document","block","__","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\nimport { sidebars } from '../settings-sidebar';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SettingsHeader = () => {\n\tconst { documentLabel } = useSelect( ( select ) => {\n\t\tconst { getPostTypeLabel } = select( editorStore );\n\n\t\treturn {\n\t\t\t// translators: Default label for the Document sidebar tab, not selected.\n\t\t\tdocumentLabel: getPostTypeLabel() || _x( 'Document', 'noun' ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Tabs.TabList>\n\t\t\t<Tabs.Tab
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_data","_element","_editor","_lockUnlock","_settingsSidebar","Tabs","unlock","componentsPrivateApis","SettingsHeader","_","ref","documentLabel","useSelect","select","getPostTypeLabel","editorStore","_x","_react","createElement","TabList","Tab","tabId","sidebars","document","block","__","_default","exports","default","forwardRef"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { forwardRef } from '@wordpress/element';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\nimport { sidebars } from '../settings-sidebar';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SettingsHeader = ( _, ref ) => {\n\tconst { documentLabel } = useSelect( ( select ) => {\n\t\tconst { getPostTypeLabel } = select( editorStore );\n\n\t\treturn {\n\t\t\t// translators: Default label for the Document sidebar tab, not selected.\n\t\t\tdocumentLabel: getPostTypeLabel() || _x( 'Document', 'noun' ),\n\t\t};\n\t}, [] );\n\n\treturn (\n\t\t<Tabs.TabList ref={ ref }>\n\t\t\t<Tabs.Tab\n\t\t\t\ttabId={ sidebars.document }\n\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\tdata-tab-id={ sidebars.document }\n\t\t\t>\n\t\t\t\t{ documentLabel }\n\t\t\t</Tabs.Tab>\n\t\t\t<Tabs.Tab\n\t\t\t\ttabId={ sidebars.block }\n\t\t\t\t// Used for focus management in the SettingsSidebar component.\n\t\t\t\tdata-tab-id={ sidebars.block }\n\t\t\t>\n\t\t\t\t{ /* translators: Text label for the Block Settings Sidebar tab. */ }\n\t\t\t\t{ __( 'Block' ) }\n\t\t\t</Tabs.Tab>\n\t\t</Tabs.TabList>\n\t);\n};\n\nexport default forwardRef( SettingsHeader );\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EAAEO;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhD,MAAMC,cAAc,GAAGA,CAAEC,CAAC,EAAEC,GAAG,KAAM;EACpC,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAClD,MAAM;MAAEC;IAAiB,CAAC,GAAGD,MAAM,CAAEE,aAAY,CAAC;IAElD,OAAO;MACN;MACAJ,aAAa,EAAEG,gBAAgB,CAAC,CAAC,IAAI,IAAAE,QAAE,EAAE,UAAU,EAAE,MAAO;IAC7D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,OACC,IAAAC,MAAA,CAAAC,aAAA,EAACb,IAAI,CAACc,OAAO;IAACT,GAAG,EAAGA;EAAK,GACxB,IAAAO,MAAA,CAAAC,aAAA,EAACb,IAAI,CAACe,GAAG;IACRC,KAAK,EAAGC,yBAAQ,CAACC;IACjB;IAAA;IACA,eAAcD,yBAAQ,CAACC;EAAU,GAE/BZ,aACO,CAAC,EACX,IAAAM,MAAA,CAAAC,aAAA,EAACb,IAAI,CAACe,GAAG;IACRC,KAAK,EAAGC,yBAAQ,CAACE;IACjB;IAAA;IACA,eAAcF,yBAAQ,CAACE;EAAO,GAG5B,IAAAC,QAAE,EAAE,OAAQ,CACL,CACG,CAAC;AAEjB,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,mBAAU,EAAErB,cAAe,CAAC"}
|
|
@@ -38,25 +38,47 @@ const SIDEBAR_ACTIVE_BY_DEFAULT = _element.Platform.select({
|
|
|
38
38
|
web: true,
|
|
39
39
|
native: false
|
|
40
40
|
});
|
|
41
|
-
const sidebars = {
|
|
41
|
+
const sidebars = exports.sidebars = {
|
|
42
42
|
document: 'edit-post/document',
|
|
43
43
|
block: 'edit-post/block'
|
|
44
44
|
};
|
|
45
|
-
exports.sidebars = sidebars;
|
|
46
45
|
const SidebarContent = ({
|
|
47
46
|
sidebarName,
|
|
48
47
|
keyboardShortcut,
|
|
49
48
|
isEditingTemplate
|
|
50
49
|
}) => {
|
|
50
|
+
const tabListRef = (0, _element.useRef)(null);
|
|
51
51
|
// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we
|
|
52
52
|
// need to forward the `Tabs` context so it can be passed through the
|
|
53
53
|
// underlying slot/fill.
|
|
54
54
|
const tabsContextValue = (0, _element.useContext)(Tabs.Context);
|
|
55
|
+
|
|
56
|
+
// This effect addresses a race condition caused by tabbing from the last
|
|
57
|
+
// block in the editor into the settings sidebar. Without this effect, the
|
|
58
|
+
// selected tab and browser focus can become separated in an unexpected way
|
|
59
|
+
// (e.g the "block" tab is focused, but the "post" tab is selected).
|
|
60
|
+
(0, _element.useEffect)(() => {
|
|
61
|
+
const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
|
|
62
|
+
const selectedTabElement = tabsElements.find(
|
|
63
|
+
// We are purposefully using a custom `data-tab-id` attribute here
|
|
64
|
+
// because we don't want rely on any assumptions about `Tabs`
|
|
65
|
+
// component internals.
|
|
66
|
+
element => element.getAttribute('data-tab-id') === sidebarName);
|
|
67
|
+
const activeElement = selectedTabElement?.ownerDocument.activeElement;
|
|
68
|
+
const tabsHasFocus = tabsElements.some(element => {
|
|
69
|
+
return activeElement && activeElement.id === element.id;
|
|
70
|
+
});
|
|
71
|
+
if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
|
|
72
|
+
selectedTabElement?.focus();
|
|
73
|
+
}
|
|
74
|
+
}, [sidebarName]);
|
|
55
75
|
return (0, _react.createElement)(_pluginSidebar.default, {
|
|
56
76
|
identifier: sidebarName,
|
|
57
77
|
header: (0, _react.createElement)(Tabs.Context.Provider, {
|
|
58
78
|
value: tabsContextValue
|
|
59
|
-
}, (0, _react.createElement)(_settingsHeader.default,
|
|
79
|
+
}, (0, _react.createElement)(_settingsHeader.default, {
|
|
80
|
+
ref: tabListRef
|
|
81
|
+
})),
|
|
60
82
|
closeLabel: (0, _i18n.__)('Close Settings')
|
|
61
83
|
// This classname is added so we can apply a corrective negative
|
|
62
84
|
// margin to the panel.
|
|
@@ -128,13 +150,13 @@ const SettingsSidebar = () => {
|
|
|
128
150
|
// the selected tab to `null` avoids that.
|
|
129
151
|
, {
|
|
130
152
|
selectedTabId: isSettingsSidebarActive ? sidebarName : null,
|
|
131
|
-
onSelect: onTabSelect
|
|
153
|
+
onSelect: onTabSelect,
|
|
154
|
+
selectOnMove: false
|
|
132
155
|
}, (0, _react.createElement)(SidebarContent, {
|
|
133
156
|
sidebarName: sidebarName,
|
|
134
157
|
keyboardShortcut: keyboardShortcut,
|
|
135
158
|
isEditingTemplate: isEditingTemplate
|
|
136
159
|
}));
|
|
137
160
|
};
|
|
138
|
-
var _default = SettingsSidebar;
|
|
139
|
-
exports.default = _default;
|
|
161
|
+
var _default = exports.default = SettingsSidebar;
|
|
140
162
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","_data","_element","_i18n","_icons","_interface","_keyboardShortcuts","_editor","_settingsHeader","_interopRequireDefault","_postStatus","_metaBoxes","_pluginDocumentSettingPanel","_pluginSidebar","_templateSummary","_store","_components","_lockUnlock","Tabs","unlock","componentsPrivateApis","SIDEBAR_ACTIVE_BY_DEFAULT","Platform","select","web","native","sidebars","document","block","exports","SidebarContent","sidebarName","keyboardShortcut","isEditingTemplate","tabsContextValue","useContext","Context","_react","createElement","default","identifier","header","Provider","value","closeLabel","__","className","headerClassName","title","toggleShortcut","icon","isRTL","drawerLeft","drawerRight","isActiveByDefault","TabPanel","tabId","focusable","Fragment","Slot","PostLastRevisionPanel","PostTaxonomiesPanel","PostFeaturedImagePanel","PostExcerptPanel","PostDiscussionPanel","PageAttributesPanel","location","BlockInspector","SettingsSidebar","isSettingsSidebarActive","useSelect","sidebar","interfaceStore","getActiveComplementaryArea","editPostStore","name","isSettingsSidebar","includes","blockEditorStore","getBlockSelectionStart","shortcut","keyboardShortcutsStore","getShortcutRepresentation","editorStore","getCurrentPostType","openGeneralSidebar","useDispatch","onTabSelect","useCallback","newSelectedTabId","selectedTabId","onSelect","_default"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { Platform, useCallback, useContext } from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport {\n\tstore as editorStore,\n\tPageAttributesPanel,\n\tPostDiscussionPanel,\n\tPostExcerptPanel,\n\tPostFeaturedImagePanel,\n\tPostLastRevisionPanel,\n\tPostTaxonomiesPanel,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport TemplateSummary from '../template-summary';\nimport { store as editPostStore } from '../../../store';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { unlock } from '../../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\nexport const sidebars = {\n\tdocument: 'edit-post/document',\n\tblock: 'edit-post/block',\n};\n\nconst SidebarContent = ( {\n\tsidebarName,\n\tkeyboardShortcut,\n\tisEditingTemplate,\n} ) => {\n\t// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SettingsHeader />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"edit-post-sidebar__panel\"\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ ! isEditingTemplate && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<PostStatus />\n\t\t\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t\t\t<PostLastRevisionPanel />\n\t\t\t\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t\t\t\t<PostFeaturedImagePanel />\n\t\t\t\t\t\t\t<PostExcerptPanel />\n\t\t\t\t\t\t\t<PostDiscussionPanel />\n\t\t\t\t\t\t\t<PageAttributesPanel />\n\t\t\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isEditingTemplate && <TemplateSummary /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nconst SettingsSidebar = () => {\n\tconst {\n\t\tsidebarName,\n\t\tisSettingsSidebarActive,\n\t\tkeyboardShortcut,\n\t\tisEditingTemplate,\n\t} = useSelect( ( select ) => {\n\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t// When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditPostStore.name\n\t\t);\n\t\tlet isSettingsSidebar = true;\n\t\tif ( ! [ sidebars.document, sidebars.block ].includes( sidebar ) ) {\n\t\t\tisSettingsSidebar = false;\n\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\tsidebar = sidebars.block;\n\t\t\t}\n\t\t\tsidebar = sidebars.document;\n\t\t}\n\t\tconst shortcut = select(\n\t\t\tkeyboardShortcutsStore\n\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\treturn {\n\t\t\tsidebarName: sidebar,\n\t\t\tisSettingsSidebarActive: isSettingsSidebar,\n\t\t\tkeyboardShortcut: shortcut,\n\t\t\tisEditingTemplate:\n\t\t\t\tselect( editorStore ).getCurrentPostType() === 'wp_template',\n\t\t};\n\t}, [] );\n\n\tconst { openGeneralSidebar } = useDispatch( editPostStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\topenGeneralSidebar( newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ openGeneralSidebar ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop.Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isSettingsSidebarActive ? sidebarName : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\tsidebarName={ sidebarName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tisEditingTemplate={ isEditingTemplate }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default SettingsSidebar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAaA,IAAAQ,eAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,WAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,UAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAAY,2BAAA,GAAAH,sBAAA,CAAAT,OAAA;AACA,IAAAa,cAAA,GAAAJ,sBAAA,CAAAT,OAAA;AACA,IAAAc,gBAAA,GAAAL,sBAAA,CAAAT,OAAA;AACA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AACA,IAAAiB,WAAA,GAAAjB,OAAA;AAlCA;AACA;AACA;;AAqBA;AACA;AACA;;AAWA,MAAM;EAAEkB;AAAK,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;AAEhD,MAAMC,yBAAyB,GAAGC,iBAAQ,CAACC,MAAM,CAAE;EAClDC,GAAG,EAAE,IAAI;EACTC,MAAM,EAAE;AACT,CAAE,CAAC;AACI,MAAMC,QAAQ,GAAG;EACvBC,QAAQ,EAAE,oBAAoB;EAC9BC,KAAK,EAAE;AACR,CAAC;AAACC,OAAA,CAAA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C;AAET,CAAC;AAAC,IAAA2D,QAAA,GAEaxB,eAAe;AAAAvC,OAAA,CAAAU,OAAA,GAAAqD,QAAA"}
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","_data","_element","_i18n","_icons","_interface","_keyboardShortcuts","_editor","_settingsHeader","_interopRequireDefault","_postStatus","_metaBoxes","_pluginDocumentSettingPanel","_pluginSidebar","_templateSummary","_store","_components","_lockUnlock","Tabs","unlock","componentsPrivateApis","SIDEBAR_ACTIVE_BY_DEFAULT","Platform","select","web","native","sidebars","exports","document","block","SidebarContent","sidebarName","keyboardShortcut","isEditingTemplate","tabListRef","useRef","tabsContextValue","useContext","Context","useEffect","tabsElements","Array","from","current","querySelectorAll","selectedTabElement","find","element","getAttribute","activeElement","ownerDocument","tabsHasFocus","some","id","focus","_react","createElement","default","identifier","header","Provider","value","ref","closeLabel","__","className","headerClassName","title","toggleShortcut","icon","isRTL","drawerLeft","drawerRight","isActiveByDefault","TabPanel","tabId","focusable","Fragment","Slot","PostLastRevisionPanel","PostTaxonomiesPanel","PostFeaturedImagePanel","PostExcerptPanel","PostDiscussionPanel","PageAttributesPanel","location","BlockInspector","SettingsSidebar","isSettingsSidebarActive","useSelect","sidebar","interfaceStore","getActiveComplementaryArea","editPostStore","name","isSettingsSidebar","includes","blockEditorStore","getBlockSelectionStart","shortcut","keyboardShortcutsStore","getShortcutRepresentation","editorStore","getCurrentPostType","openGeneralSidebar","useDispatch","onTabSelect","useCallback","newSelectedTabId","selectedTabId","onSelect","selectOnMove","_default"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport {\n\tstore as editorStore,\n\tPageAttributesPanel,\n\tPostDiscussionPanel,\n\tPostExcerptPanel,\n\tPostFeaturedImagePanel,\n\tPostLastRevisionPanel,\n\tPostTaxonomiesPanel,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport TemplateSummary from '../template-summary';\nimport { store as editPostStore } from '../../../store';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { unlock } from '../../../lock-unlock';\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\nexport const sidebars = {\n\tdocument: 'edit-post/document',\n\tblock: 'edit-post/block',\n};\n\nconst SidebarContent = ( {\n\tsidebarName,\n\tkeyboardShortcut,\n\tisEditingTemplate,\n} ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebarEditPost` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === sidebarName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ sidebarName ] );\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SettingsHeader ref={ tabListRef } />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"edit-post-sidebar__panel\"\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t{ ! isEditingTemplate && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<PostStatus />\n\t\t\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t\t\t<PostLastRevisionPanel />\n\t\t\t\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t\t\t\t<PostFeaturedImagePanel />\n\t\t\t\t\t\t\t<PostExcerptPanel />\n\t\t\t\t\t\t\t<PostDiscussionPanel />\n\t\t\t\t\t\t\t<PageAttributesPanel />\n\t\t\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isEditingTemplate && <TemplateSummary /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nconst SettingsSidebar = () => {\n\tconst {\n\t\tsidebarName,\n\t\tisSettingsSidebarActive,\n\t\tkeyboardShortcut,\n\t\tisEditingTemplate,\n\t} = useSelect( ( select ) => {\n\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t// When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\teditPostStore.name\n\t\t);\n\t\tlet isSettingsSidebar = true;\n\t\tif ( ! [ sidebars.document, sidebars.block ].includes( sidebar ) ) {\n\t\t\tisSettingsSidebar = false;\n\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\tsidebar = sidebars.block;\n\t\t\t}\n\t\t\tsidebar = sidebars.document;\n\t\t}\n\t\tconst shortcut = select(\n\t\t\tkeyboardShortcutsStore\n\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\treturn {\n\t\t\tsidebarName: sidebar,\n\t\t\tisSettingsSidebarActive: isSettingsSidebar,\n\t\t\tkeyboardShortcut: shortcut,\n\t\t\tisEditingTemplate:\n\t\t\t\tselect( editorStore ).getCurrentPostType() === 'wp_template',\n\t\t};\n\t}, [] );\n\n\tconst { openGeneralSidebar } = useDispatch( editPostStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\topenGeneralSidebar( newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ openGeneralSidebar ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\t// Due to how this component is controlled (via a value from the\n\t\t\t// `interfaceStore`), when the sidebar closes the currently selected\n\t\t\t// tab can't be found. This causes the component to continuously reset\n\t\t\t// the selection to `null` in an infinite loop.Proactively setting\n\t\t\t// the selected tab to `null` avoids that.\n\t\t\tselectedTabId={ isSettingsSidebarActive ? sidebarName : null }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\tsidebarName={ sidebarName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tisEditingTemplate={ isEditingTemplate }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default SettingsSidebar;\n"],"mappings":";;;;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAOA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,kBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AAaA,IAAAQ,eAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,WAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,UAAA,GAAAF,sBAAA,CAAAT,OAAA;AACA,IAAA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EtB,IAAAxD,MAAA,CAAAC,aAAA,EAAC1B,cAAc;IACdC,WAAW,EAAGA,WAAa;IAC3BC,gBAAgB,EAAGA,gBAAkB;IACrCC,iBAAiB,EAAGA;EAAmB,CACvC,CACI,CAAC;AAET,CAAC;AAAC,IAAA+E,QAAA,GAAArF,OAAA,CAAA8B,OAAA,GAEa8B,eAAe"}
|
|
@@ -32,6 +32,5 @@ function TemplateSummary() {
|
|
|
32
32
|
className: "edit-post-template-summary__title"
|
|
33
33
|
}, template?.title || template?.slug), (0, _react.createElement)("p", null, template?.description))));
|
|
34
34
|
}
|
|
35
|
-
var _default = TemplateSummary;
|
|
36
|
-
exports.default = _default;
|
|
35
|
+
var _default = exports.default = TemplateSummary;
|
|
37
36
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_icons","require","_data","_components","_editor","TemplateSummary","template","useSelect","select","getCurrentPost","editorStore","_react","createElement","PanelBody","Flex","align","gap","FlexItem","Icon","icon","layout","FlexBlock","className","title","slug","description","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/sidebar/template-summary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, layout } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\nfunction TemplateSummary() {\n\tconst template = useSelect( ( select ) => {\n\t\tconst { getCurrentPost } = select( editorStore );\n\t\treturn getCurrentPost();\n\t}, [] );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<Flex align=\"flex-start\" gap=\"3\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Icon icon={ layout } />\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<h2 className=\"edit-post-template-summary__title\">\n\t\t\t\t\t\t{ template?.title || template?.slug }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p>{ template?.description }</p>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplateSummary;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA,SAASI,eAAeA,CAAA,EAAG;EAC1B,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAe,CAAC,GAAGD,MAAM,CAAEE,aAAY,CAAC;IAChD,OAAOD,cAAc,CAAC,CAAC;EACxB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEH,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAK,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAU,SAAS,QACT,IAAAF,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAW,IAAI;IAACC,KAAK,EAAC,YAAY;IAACC,GAAG,EAAC;EAAG,GAC/B,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAc,QAAQ,QACR,IAAAN,MAAA,CAAAC,aAAA,EAACZ,MAAA,CAAAkB,IAAI;IAACC,IAAI,EAAGC;EAAQ,CAAE,CACd,CAAC,EAEX,IAAAT,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAkB,SAAS,QACT,IAAAV,MAAA,CAAAC,aAAA;IAAIU,SAAS,EAAC;EAAmC,GAC9ChB,QAAQ,EAAEiB,KAAK,IAAIjB,QAAQ,EAAEkB,IAC5B,CAAC,EACL,IAAAb,MAAA,CAAAC,aAAA,aAAKN,QAAQ,EAAEmB,WAAgB,CACrB,CACN,CACI,CAAC;AAEd;AAAC,IAAAC,QAAA,
|
|
1
|
+
{"version":3,"names":["_icons","require","_data","_components","_editor","TemplateSummary","template","useSelect","select","getCurrentPost","editorStore","_react","createElement","PanelBody","Flex","align","gap","FlexItem","Icon","icon","layout","FlexBlock","className","title","slug","description","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/sidebar/template-summary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, layout } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\nfunction TemplateSummary() {\n\tconst template = useSelect( ( select ) => {\n\t\tconst { getCurrentPost } = select( editorStore );\n\t\treturn getCurrentPost();\n\t}, [] );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<Flex align=\"flex-start\" gap=\"3\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Icon icon={ layout } />\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<h2 className=\"edit-post-template-summary__title\">\n\t\t\t\t\t\t{ template?.title || template?.slug }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p>{ template?.description }</p>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplateSummary;\n"],"mappings":";;;;;;;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA,SAASI,eAAeA,CAAA,EAAG;EAC1B,MAAMC,QAAQ,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAe,CAAC,GAAGD,MAAM,CAAEE,aAAY,CAAC;IAChD,OAAOD,cAAc,CAAC,CAAC;EACxB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEH,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OACC,IAAAK,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAU,SAAS,QACT,IAAAF,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAW,IAAI;IAACC,KAAK,EAAC,YAAY;IAACC,GAAG,EAAC;EAAG,GAC/B,IAAAL,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAc,QAAQ,QACR,IAAAN,MAAA,CAAAC,aAAA,EAACZ,MAAA,CAAAkB,IAAI;IAACC,IAAI,EAAGC;EAAQ,CAAE,CACd,CAAC,EAEX,IAAAT,MAAA,CAAAC,aAAA,EAACT,WAAA,CAAAkB,SAAS,QACT,IAAAV,MAAA,CAAAC,aAAA;IAAIU,SAAS,EAAC;EAAmC,GAC9ChB,QAAQ,EAAEiB,KAAK,IAAIjB,QAAQ,EAAEkB,IAC5B,CAAC,EACL,IAAAb,MAAA,CAAAC,aAAA,aAAKN,QAAQ,EAAEmB,WAAgB,CACrB,CACN,CACI,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcvB,eAAe"}
|
|
@@ -51,6 +51,5 @@ function BlockInspectorButton({
|
|
|
51
51
|
shortcut: shortcut
|
|
52
52
|
}, !small && label);
|
|
53
53
|
}
|
|
54
|
-
var _default = BlockInspectorButton;
|
|
55
|
-
exports.default = _default;
|
|
54
|
+
var _default = exports.default = BlockInspectorButton;
|
|
56
55
|
//# sourceMappingURL=block-inspector-button.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_data","_a11y","_keyboardShortcuts","_store","noop","BlockInspectorButton","onClick","small","shortcut","areAdvancedSettingsOpened","useSelect","select","keyboardShortcutsStore","getShortcutRepresentation","editPostStore","getActiveGeneralSidebarName","openGeneralSidebar","closeGeneralSidebar","useDispatch","label","__","_react","createElement","MenuItem","speak","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/visual-editor/block-inspector-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nconst noop = () => {};\n\nexport function BlockInspectorButton( { onClick = noop, small = false } ) {\n\tconst { shortcut, areAdvancedSettingsOpened } = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),\n\t\t\tareAdvancedSettingsOpened:\n\t\t\t\tselect( editPostStore ).getActiveGeneralSidebarName() ===\n\t\t\t\t'edit-post/block',\n\t\t} ),\n\t\t[]\n\t);\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\n\tconst label = areAdvancedSettingsOpened\n\t\t? __( 'Hide more settings' )\n\t\t: __( 'Show more settings' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tif ( areAdvancedSettingsOpened ) {\n\t\t\t\t\tcloseGeneralSidebar();\n\t\t\t\t\tspeak( __( 'Block settings closed' ) );\n\t\t\t\t} else {\n\t\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t\t\tspeak(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Additional settings are now available in the Editor block settings sidebar'\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tshortcut={ shortcut }\n\t\t>\n\t\t\t{ ! small && label }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAA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"names":["_i18n","require","_components","_data","_a11y","_keyboardShortcuts","_store","noop","BlockInspectorButton","onClick","small","shortcut","areAdvancedSettingsOpened","useSelect","select","keyboardShortcutsStore","getShortcutRepresentation","editPostStore","getActiveGeneralSidebarName","openGeneralSidebar","closeGeneralSidebar","useDispatch","label","__","_react","createElement","MenuItem","speak","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/visual-editor/block-inspector-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nconst noop = () => {};\n\nexport function BlockInspectorButton( { onClick = noop, small = false } ) {\n\tconst { shortcut, areAdvancedSettingsOpened } = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),\n\t\t\tareAdvancedSettingsOpened:\n\t\t\t\tselect( editPostStore ).getActiveGeneralSidebarName() ===\n\t\t\t\t'edit-post/block',\n\t\t} ),\n\t\t[]\n\t);\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\n\tconst label = areAdvancedSettingsOpened\n\t\t? __( 'Hide more settings' )\n\t\t: __( 'Show more settings' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tif ( areAdvancedSettingsOpened ) {\n\t\t\t\t\tcloseGeneralSidebar();\n\t\t\t\t\tspeak( __( 'Block settings closed' ) );\n\t\t\t\t} else {\n\t\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t\t\tspeak(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Additional settings are now available in the Editor block settings sidebar'\n\t\t\t\t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AE,uBAAwB,CAAE,CAAC;MACvC,CAAC,MAAM;QACNJ,kBAAkB,CAAE,iBAAkB,CAAC;QACvC,IAAAQ,WAAK,EACJ,IAAAJ,QAAE,EACD,4EACD,CACD,CAAC;MACF;MACAd,OAAO,CAAC,CAAC;IACV,CAAG;IACHE,QAAQ,EAAGA;EAAU,GAEnB,CAAED,KAAK,IAAIY,KACJ,CAAC;AAEb;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEctB,oBAAoB"}
|
|
@@ -36,7 +36,7 @@ const Header = (0, _element.memo)(function EditorHeader({
|
|
|
36
36
|
accessibilityLabel: "post-title"
|
|
37
37
|
}));
|
|
38
38
|
}, (prevProps, nextProps) => prevProps.title === nextProps.title);
|
|
39
|
-
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
39
|
+
var _default = exports.default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
40
40
|
const {
|
|
41
41
|
getEditedPostAttribute
|
|
42
42
|
} = select('core/editor');
|
|
@@ -59,5 +59,4 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
61
|
}), _compose.withPreferredColorScheme])(Header);
|
|
62
|
-
exports.default = _default;
|
|
63
62
|
//# sourceMappingURL=header.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_element","_i18n","_data","_compose","_editor","_blockEditor","Header","memo","EditorHeader","editTitle","setTitleRef","title","wrapperStyles","useEditorWrapperStyles","_react","createElement","View","style","PostTitle","innerRef","onUpdate","placeholder","__","accessibilityLabel","prevProps","nextProps","_default","compose","withSelect","select","getEditedPostAttribute","withDispatch","dispatch","editPost","clearSelectedBlock","blockEditorStore","withPreferredColorScheme"
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_element","_i18n","_data","_compose","_editor","_blockEditor","Header","memo","EditorHeader","editTitle","setTitleRef","title","wrapperStyles","useEditorWrapperStyles","_react","createElement","View","style","PostTitle","innerRef","onUpdate","placeholder","__","accessibilityLabel","prevProps","nextProps","_default","exports","default","compose","withSelect","select","getEditedPostAttribute","withDispatch","dispatch","editPost","clearSelectedBlock","blockEditorStore","withPreferredColorScheme"],"sources":["@wordpress/edit-post/src/components/visual-editor/header.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { memo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose, withPreferredColorScheme } from '@wordpress/compose';\nimport { PostTitle } from '@wordpress/editor';\nimport {\n\tstore as blockEditorStore,\n\tuseEditorWrapperStyles,\n} from '@wordpress/block-editor';\n\nconst Header = memo(\n\tfunction EditorHeader( { editTitle, setTitleRef, title } ) {\n\t\tconst [ wrapperStyles ] = useEditorWrapperStyles();\n\t\treturn (\n\t\t\t<View style={ wrapperStyles }>\n\t\t\t\t<PostTitle\n\t\t\t\t\tinnerRef={ setTitleRef }\n\t\t\t\t\ttitle={ title }\n\t\t\t\t\tonUpdate={ editTitle }\n\t\t\t\t\tplaceholder={ __( 'Add title' ) }\n\t\t\t\t\taccessibilityLabel=\"post-title\"\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t},\n\t( prevProps, nextProps ) => prevProps.title === nextProps.title\n);\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditedPostAttribute } = select( 'core/editor' );\n\n\t\treturn {\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost } = dispatch( 'core/editor' );\n\n\t\tconst { clearSelectedBlock } = dispatch( blockEditorStore );\n\n\t\treturn {\n\t\t\tclearSelectedBlock,\n\t\t\teditTitle( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t};\n\t} ),\n\twithPreferredColorScheme,\n] )( Header );\n"],"mappings":";;;;;;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E9C,MAAM;IAAEE;EAAmB,CAAC,GAAGF,QAAQ,CAAEG,kBAAiB,CAAC;EAE3D,OAAO;IACND,kBAAkB;IAClB3B,SAASA,CAAEE,KAAK,EAAG;MAClBwB,QAAQ,CAAE;QAAExB;MAAM,CAAE,CAAC;IACtB;EACD,CAAC;AACF,CAAE,CAAC,EACH2B,iCAAwB,CACvB,CAAC,CAAEhC,MAAO,CAAC"}
|
package/build/editor.js
CHANGED
|
@@ -13,11 +13,13 @@ var _components = require("@wordpress/components");
|
|
|
13
13
|
var _coreData = require("@wordpress/core-data");
|
|
14
14
|
var _preferences = require("@wordpress/preferences");
|
|
15
15
|
var _commands = require("@wordpress/commands");
|
|
16
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
17
|
+
var _i18n = require("@wordpress/i18n");
|
|
16
18
|
var _layout = _interopRequireDefault(require("./components/layout"));
|
|
17
19
|
var _editorInitialization = _interopRequireDefault(require("./components/editor-initialization"));
|
|
18
20
|
var _store = require("./store");
|
|
19
21
|
var _lockUnlock = require("./lock-unlock");
|
|
20
|
-
var
|
|
22
|
+
var _useNavigateToEntityRecord = _interopRequireDefault(require("./hooks/use-navigate-to-entity-record"));
|
|
21
23
|
/**
|
|
22
24
|
* WordPress dependencies
|
|
23
25
|
*/
|
|
@@ -29,6 +31,14 @@ var _usePostHistory = _interopRequireDefault(require("./hooks/use-post-history")
|
|
|
29
31
|
const {
|
|
30
32
|
ExperimentalEditorProvider
|
|
31
33
|
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
34
|
+
const {
|
|
35
|
+
BlockRemovalWarningModal
|
|
36
|
+
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
37
|
+
// Prevent accidental removal of certain blocks, asking the user for
|
|
38
|
+
// confirmation.
|
|
39
|
+
const blockRemovalRules = {
|
|
40
|
+
'bindings/core/pattern-overrides': (0, _i18n.__)('Blocks from synced patterns that can have overriden content.')
|
|
41
|
+
};
|
|
32
42
|
function Editor({
|
|
33
43
|
postId: initialPostId,
|
|
34
44
|
postType: initialPostType,
|
|
@@ -37,10 +47,11 @@ function Editor({
|
|
|
37
47
|
...props
|
|
38
48
|
}) {
|
|
39
49
|
const {
|
|
50
|
+
initialPost,
|
|
40
51
|
currentPost,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
} = (0,
|
|
52
|
+
onNavigateToEntityRecord,
|
|
53
|
+
onNavigateToPreviousEntityRecord
|
|
54
|
+
} = (0, _useNavigateToEntityRecord.default)(initialPostId, initialPostType);
|
|
44
55
|
const {
|
|
45
56
|
hasInlineToolbar,
|
|
46
57
|
post,
|
|
@@ -75,20 +86,17 @@ function Editor({
|
|
|
75
86
|
updatePreferredStyleVariations
|
|
76
87
|
} = (0, _data.useDispatch)(_store.store);
|
|
77
88
|
const defaultRenderingMode = currentPost.postType === 'wp_template' ? 'all' : 'post-only';
|
|
78
|
-
const editorSettings = (0, _element.useMemo)(() => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
};
|
|
90
|
-
return result;
|
|
91
|
-
}, [settings, hasInlineToolbar, preferredStyleVariations, updatePreferredStyleVariations, getPostLinkProps, goBack, defaultRenderingMode]);
|
|
89
|
+
const editorSettings = (0, _element.useMemo)(() => ({
|
|
90
|
+
...settings,
|
|
91
|
+
onNavigateToEntityRecord,
|
|
92
|
+
onNavigateToPreviousEntityRecord,
|
|
93
|
+
defaultRenderingMode,
|
|
94
|
+
__experimentalPreferredStyleVariations: {
|
|
95
|
+
value: preferredStyleVariations,
|
|
96
|
+
onChange: updatePreferredStyleVariations
|
|
97
|
+
},
|
|
98
|
+
hasInlineToolbar
|
|
99
|
+
}), [settings, hasInlineToolbar, preferredStyleVariations, updatePreferredStyleVariations, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord, defaultRenderingMode]);
|
|
92
100
|
if (!post) {
|
|
93
101
|
return null;
|
|
94
102
|
}
|
|
@@ -101,8 +109,11 @@ function Editor({
|
|
|
101
109
|
...props
|
|
102
110
|
}, (0, _react.createElement)(_editor.ErrorBoundary, null, (0, _react.createElement)(_commands.CommandMenu, null), (0, _react.createElement)(_editorInitialization.default, {
|
|
103
111
|
postId: currentPost.postId
|
|
104
|
-
}), (0, _react.createElement)(_layout.default,
|
|
112
|
+
}), (0, _react.createElement)(_layout.default, {
|
|
113
|
+
initialPost: initialPost
|
|
114
|
+
}), (0, _react.createElement)(BlockRemovalWarningModal, {
|
|
115
|
+
rules: blockRemovalRules
|
|
116
|
+
})), (0, _react.createElement)(_editor.PostLockedModal, null)));
|
|
105
117
|
}
|
|
106
|
-
var _default = Editor;
|
|
107
|
-
exports.default = _default;
|
|
118
|
+
var _default = exports.default = Editor;
|
|
108
119
|
//# sourceMappingURL=editor.js.map
|
package/build/editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_editor","_element","_components","_coreData","_preferences","_commands","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","
|
|
1
|
+
{"version":3,"names":["_data","require","_editor","_element","_components","_coreData","_preferences","_commands","_blockEditor","_i18n","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","_useNavigateToEntityRecord","ExperimentalEditorProvider","unlock","editorPrivateApis","BlockRemovalWarningModal","blockEditorPrivateApis","blockRemovalRules","__","Editor","postId","initialPostId","postType","initialPostType","settings","initialEdits","props","initialPost","currentPost","onNavigateToEntityRecord","onNavigateToPreviousEntityRecord","useNavigateToEntityRecord","hasInlineToolbar","post","preferredStyleVariations","template","useSelect","select","_getPostType$viewable","isFeatureActive","getEditedPostTemplate","editPostStore","getEntityRecord","getPostType","canUser","coreStore","getEditorSettings","editorStore","postObject","supportsTemplateMode","isViewable","viewable","canEditTemplate","preferencesStore","get","updatePreferredStyleVariations","useDispatch","defaultRenderingMode","editorSettings","useMemo","__experimentalPreferredStyleVariations","value","onChange","_react","createElement","SlotFillProvider","useSubRegistry","__unstableTemplate","ErrorBoundary","CommandMenu","default","rules","PostLockedModal","_default","exports"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\nimport useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\nconst { BlockRemovalWarningModal } = unlock( blockEditorPrivateApis );\n// Prevent accidental removal of certain blocks, asking the user for\n// confirmation.\nconst blockRemovalRules = {\n\t'bindings/core/pattern-overrides': __(\n\t\t'Blocks from synced patterns that can have overriden content.'\n\t),\n};\n\nfunction Editor( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n\t...props\n} ) {\n\tconst {\n\t\tinitialPost,\n\t\tcurrentPost,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord( initialPostId, initialPostType );\n\n\tconst { hasInlineToolbar, post, preferredStyleVariations, template } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst { isFeatureActive, getEditedPostTemplate } =\n\t\t\t\t\tselect( editPostStore );\n\t\t\t\tconst { getEntityRecord, getPostType, canUser } =\n\t\t\t\t\tselect( coreStore );\n\t\t\t\tconst { getEditorSettings } = select( editorStore );\n\n\t\t\t\tconst postObject = getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\tcurrentPost.postId\n\t\t\t\t);\n\n\t\t\t\tconst supportsTemplateMode =\n\t\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\t\tconst isViewable =\n\t\t\t\t\tgetPostType( currentPost.postType )?.viewable ?? false;\n\t\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\t\treturn {\n\t\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t\t),\n\t\t\t\t\ttemplate:\n\t\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\t\tisViewable &&\n\t\t\t\t\t\tcanEditTemplate &&\n\t\t\t\t\t\tcurrentPost.postType !== 'wp_template'\n\t\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\tpost: postObject,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ currentPost.postType, currentPost.postId ]\n\t\t);\n\n\tconst { updatePreferredStyleVariations } = useDispatch( editPostStore );\n\tconst defaultRenderingMode =\n\t\tcurrentPost.postType === 'wp_template' ? 'all' : 'post-only';\n\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasInlineToolbar,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasInlineToolbar,\n\t\t\tpreferredStyleVariations,\n\t\t\tupdatePreferredStyleVariations,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode,\n\t\t]\n\t);\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ currentPost.postId } />\n\t\t\t\t\t<Layout initialPost={ initialPost } />\n\t\t\t\t\t<BlockRemovalWarningModal rules={ blockRemovalRules } />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,YAAA,GAAAP,OAAA;AACA,IAAAQ,KAAA,GAAAR,OAAA;AAKA,IAAAS,OAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,0BAAA,GAAAJ,sBAAA,CAAAV,OAAA;AAzBA;AACA;AACA;;AAgBA;AACA;AACA;;AAOA,MAAM;EAAEe;AAA2B,CAAC,GAAG,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AAAqC,MAAA,CAAAC,aAAA,EAAClE,OAAA,CAAAsE,aAAa,QACb,IAAAL,MAAA,CAAAC,aAAA,EAAC7D,SAAA,CAAAkE,WAAW,MAAE,CAAC,EACf,IAAAN,MAAA,CAAAC,aAAA,EAACxD,qBAAA,CAAA8D,OAAoB;IAAClD,MAAM,EAAGQ,WAAW,CAACR;EAAQ,CAAE,CAAC,EACtD,IAAA2C,MAAA,CAAAC,aAAA,EAAC1D,OAAA,CAAAgE,OAAM;IAAC3C,WAAW,EAAGA;EAAa,CAAE,CAAC,EACtC,IAAAoC,MAAA,CAAAC,aAAA,EAACjD,wBAAwB;IAACwD,KAAK,EAAGtD;EAAmB,CAAE,CACzC,CAAC,EAChB,IAAA8C,MAAA,CAAAC,aAAA,EAAClE,OAAA,CAAA0E,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAJ,OAAA,GAEcnD,MAAM"}
|
package/build/editor.native.js
CHANGED
|
@@ -137,7 +137,7 @@ class Editor extends _element.Component {
|
|
|
137
137
|
}))));
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
|
-
var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
140
|
+
var _default = exports.default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
141
141
|
const {
|
|
142
142
|
getEditorMode
|
|
143
143
|
} = select(_store.store);
|
|
@@ -156,5 +156,4 @@ var _default = (0, _compose.compose)([(0, _data.withSelect)(select => {
|
|
|
156
156
|
editEntityRecord
|
|
157
157
|
};
|
|
158
158
|
})])(Editor);
|
|
159
|
-
exports.default = _default;
|
|
160
159
|
//# sourceMappingURL=editor.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_memize","_interopRequireDefault","require","_reactNative","_reactNativeGestureHandler","_element","_editor","_blocks","_data","_compose","_reactNativeBridge","_components","_coreData","_layout","_store","Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","memize","maxSize","setTitleRef","bind","settings","isRTL","I18nManager","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","subscribeSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","subscribeFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","serialize","parse","type","status","meta","_react","createElement","GestureHandlerRootView","style","flex","SlotFillProvider","EditorProvider","useSubRegistry","default","_default","compose","withSelect","select","getEditorMode","editPostStore","withDispatch","dispatch","coreStore"
|
|
1
|
+
{"version":3,"names":["_memize","_interopRequireDefault","require","_reactNative","_reactNativeGestureHandler","_element","_editor","_blocks","_data","_compose","_reactNativeBridge","_components","_coreData","_layout","_store","Editor","Component","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","memize","maxSize","setTitleRef","bind","settings","isRTL","I18nManager","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","subscribeSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","subscribeFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","serialize","parse","type","status","meta","_react","createElement","GestureHandlerRootView","style","flex","SlotFillProvider","EditorProvider","useSubRegistry","default","_default","exports","compose","withSelect","select","getEditorMode","editPostStore","withDispatch","dispatch","coreStore"],"sources":["@wordpress/edit-post/src/editor.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider } from '@wordpress/editor';\nimport { parse, serialize } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport { store as editPostStore } from './store';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings( settings ) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t};\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\tinitialEdits,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings( settings );\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,0BAAA,GAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AAIA,IAAAS,WAAA,GAAAT,OAAA;AACA,IAAAU,SAAA,GAAAV,OAAA;AAKA,IAAAW,OAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,MAAA,GAAAZ,OAAA;AA1BA;AACA;AACA;;AAKA;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMa,MAAM,SAASC,kBAAS,CAAC;EAC9BC,WAAWA,CAAEC,KAAK,EAAG;IACp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aAAA,EAAC3D,WAAA,CAAA+D,gBAAgB,QAChB,IAAAL,MAAA,CAAAC,aAAA,EAAChE,OAAA,CAAAqE,cAAc;MACd3C,QAAQ,EAAGyB,cAAgB;MAC3BF,IAAI,EAAGG,cAAgB;MACvBJ,YAAY,EAAGA,YAAc;MAC7BsB,cAAc,EAAG,KAAO;MAAA,GACnB1D;IAAK,GAEV,IAAAmD,MAAA,CAAAC,aAAA,EAACzD,OAAA,CAAAgE,OAAM;MAAC/C,WAAW,EAAG,IAAI,CAACA;IAAa,CAAE,CAC3B,CACC,CACK,CAAC;EAE3B;AACD;AAAC,IAAAgD,QAAA,GAAAC,OAAA,CAAAF,OAAA,GAEc,IAAAG,gBAAO,EAAE,CACvB,IAAAC,gBAAU,EAAIC,MAAM,IAAM;EACzB,MAAM;IAAEC;EAAc,CAAC,GAAGD,MAAM,CAAEE,YAAc,CAAC;EAEjD,OAAO;IACN3D,IAAI,EAAE0D,aAAa,CAAC;EACrB,CAAC;AACF,CAAE,CAAC,EACH,IAAAE,kBAAY,EAAIC,QAAQ,IAAM;EAC7B,MAAM;IAAE5D;EAAiB,CAAC,GAAG4D,QAAQ,CAAEF,YAAc,CAAC;EACtD,MAAM;IAAEhD;EAAiB,CAAC,GAAGkD,QAAQ,CAAEC,eAAU,CAAC;EAClD,OAAO;IACN7D,gBAAgB;IAChBU;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAErB,MAAO,CAAC"}
|
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default =
|
|
6
|
+
exports.default = useNavigateToEntityRecord;
|
|
7
7
|
var _element = require("@wordpress/element");
|
|
8
|
-
var _url = require("@wordpress/url");
|
|
9
8
|
/**
|
|
10
9
|
* WordPress dependencies
|
|
11
10
|
*/
|
|
@@ -22,9 +21,9 @@ var _url = require("@wordpress/url");
|
|
|
22
21
|
* @param {string} initialPostType The post type of the post when the editor loaded.
|
|
23
22
|
*
|
|
24
23
|
* @return {Object} An object containing the `currentPost` variable and
|
|
25
|
-
* `
|
|
24
|
+
* `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.
|
|
26
25
|
*/
|
|
27
|
-
function
|
|
26
|
+
function useNavigateToEntityRecord(initialPostId, initialPostType) {
|
|
28
27
|
const [postHistory, dispatch] = (0, _element.useReducer)((historyState, {
|
|
29
28
|
type,
|
|
30
29
|
post
|
|
@@ -43,28 +42,22 @@ function usePostHistory(initialPostId, initialPostType) {
|
|
|
43
42
|
postId: initialPostId,
|
|
44
43
|
postType: initialPostType
|
|
45
44
|
}]);
|
|
46
|
-
const
|
|
47
|
-
const currentArgs = (0, _url.getQueryArgs)(window.location.href);
|
|
48
|
-
const currentUrlWithoutArgs = (0, _url.removeQueryArgs)(window.location.href, ...Object.keys(currentArgs));
|
|
49
|
-
const newUrl = (0, _url.addQueryArgs)(currentUrlWithoutArgs, {
|
|
50
|
-
post: params.postId,
|
|
51
|
-
action: 'edit'
|
|
52
|
-
});
|
|
45
|
+
const initialPost = (0, _element.useMemo)(() => {
|
|
53
46
|
return {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
event?.preventDefault();
|
|
57
|
-
dispatch({
|
|
58
|
-
type: 'push',
|
|
59
|
-
post: {
|
|
60
|
-
postId: params.postId,
|
|
61
|
-
postType: params.postType
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
}
|
|
47
|
+
type: initialPostType,
|
|
48
|
+
id: initialPostId
|
|
65
49
|
};
|
|
50
|
+
}, [initialPostType, initialPostId]);
|
|
51
|
+
const onNavigateToEntityRecord = (0, _element.useCallback)(params => {
|
|
52
|
+
dispatch({
|
|
53
|
+
type: 'push',
|
|
54
|
+
post: {
|
|
55
|
+
postId: params.postId,
|
|
56
|
+
postType: params.postType
|
|
57
|
+
}
|
|
58
|
+
});
|
|
66
59
|
}, []);
|
|
67
|
-
const
|
|
60
|
+
const onNavigateToPreviousEntityRecord = (0, _element.useCallback)(() => {
|
|
68
61
|
dispatch({
|
|
69
62
|
type: 'pop'
|
|
70
63
|
});
|
|
@@ -72,8 +65,9 @@ function usePostHistory(initialPostId, initialPostType) {
|
|
|
72
65
|
const currentPost = postHistory[postHistory.length - 1];
|
|
73
66
|
return {
|
|
74
67
|
currentPost,
|
|
75
|
-
|
|
76
|
-
|
|
68
|
+
initialPost,
|
|
69
|
+
onNavigateToEntityRecord,
|
|
70
|
+
onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : undefined
|
|
77
71
|
};
|
|
78
72
|
}
|
|
79
|
-
//# sourceMappingURL=use-
|
|
73
|
+
//# sourceMappingURL=use-navigate-to-entity-record.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_element","require","useNavigateToEntityRecord","initialPostId","initialPostType","postHistory","dispatch","useReducer","historyState","type","post","length","slice","postId","postType","initialPost","useMemo","id","onNavigateToEntityRecord","useCallback","params","onNavigateToPreviousEntityRecord","currentPost","undefined"],"sources":["@wordpress/edit-post/src/hooks/use-navigate-to-entity-record.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useReducer, useMemo } from '@wordpress/element';\n\n/**\n * A hook that records the 'entity' history in the post editor as a user\n * navigates between editing a post and editing the post template or patterns.\n *\n * Implemented as a stack, so a little similar to the browser history API.\n *\n * Used to control displaying UI elements like the back button.\n *\n * @param {number} initialPostId The post id of the post when the editor loaded.\n * @param {string} initialPostType The post type of the post when the editor loaded.\n *\n * @return {Object} An object containing the `currentPost` variable and\n * `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.\n */\nexport default function useNavigateToEntityRecord(\n\tinitialPostId,\n\tinitialPostType\n) {\n\tconst [ postHistory, dispatch ] = useReducer(\n\t\t( historyState, { type, post } ) => {\n\t\t\tif ( type === 'push' ) {\n\t\t\t\treturn [ ...historyState, post ];\n\t\t\t}\n\t\t\tif ( type === 'pop' ) {\n\t\t\t\t// Try to leave one item in the history.\n\t\t\t\tif ( historyState.length > 1 ) {\n\t\t\t\t\treturn historyState.slice( 0, -1 );\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn historyState;\n\t\t},\n\t\t[ { postId: initialPostId, postType: initialPostType } ]\n\t);\n\n\tconst initialPost = useMemo( () => {\n\t\treturn {\n\t\t\ttype: initialPostType,\n\t\t\tid: initialPostId,\n\t\t};\n\t}, [ initialPostType, initialPostId ] );\n\n\tconst onNavigateToEntityRecord = useCallback( ( params ) => {\n\t\tdispatch( {\n\t\t\ttype: 'push',\n\t\t\tpost: { postId: params.postId, postType: params.postType },\n\t\t} );\n\t}, [] );\n\n\tconst onNavigateToPreviousEntityRecord = useCallback( () => {\n\t\tdispatch( { type: 'pop' } );\n\t}, [] );\n\n\tconst currentPost = postHistory[ postHistory.length - 1 ];\n\n\treturn {\n\t\tcurrentPost,\n\t\tinitialPost,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord:\n\t\t\tpostHistory.length > 1\n\t\t\t\t? onNavigateToPreviousEntityRecord\n\t\t\t\t: undefined,\n\t};\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASC,yBAAyBA,CAChDC,aAAa,EACbC,eAAe,EACd;EACD,MAAM,CAAEC,WAAW,EAAEC,QAAQ,CAAE,GAAG,IAAAC,mBAAU,EAC3C,CAAEC,YAAY,EAAE;IAAEC,IAAI;IAAEC;EAAK,CAAC,KAAM;IACnC,IAAKD,IAAI,KAAK,MAAM,EAAG;MACtB,OAAO,CAAE,GAAGD,YAAY,EAAEE,IAAI,CAAE;IACjC;IACA,IAAKD,IAAI,KAAK,KAAK,EAAG;MACrB;MACA,IAAKD,YAAY,CAACG,MAAM,GAAG,CAAC,EAAG;QAC9B,OAAOH,YAAY,CA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