@wordpress/edit-post 8.32.0 → 8.32.1-next.ff1cebbba.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/build/commands/use-commands.js +54 -47
- package/build/commands/use-commands.js.map +7 -1
- package/build/components/back-button/fullscreen-mode-close.js +127 -118
- package/build/components/back-button/fullscreen-mode-close.js.map +7 -1
- package/build/components/back-button/index.js +56 -54
- package/build/components/back-button/index.js.map +7 -1
- package/build/components/browser-url/index.js +45 -44
- package/build/components/browser-url/index.js.map +7 -1
- package/build/components/editor-initialization/index.js +24 -18
- package/build/components/editor-initialization/index.js.map +7 -1
- package/build/components/editor-initialization/listener-hooks.js +42 -43
- package/build/components/editor-initialization/listener-hooks.js.map +7 -1
- package/build/components/init-pattern-modal/index.js +100 -79
- package/build/components/init-pattern-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +37 -33
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/layout/index.js +447 -467
- package/build/components/layout/index.js.map +7 -1
- package/build/components/layout/use-padding-appender.js +66 -59
- package/build/components/layout/use-padding-appender.js.map +7 -1
- package/build/components/layout/use-should-iframe.js +36 -30
- package/build/components/layout/use-should-iframe.js.map +7 -1
- package/build/components/meta-boxes/index.js +46 -33
- package/build/components/meta-boxes/index.js.map +7 -1
- package/build/components/meta-boxes/meta-box-visibility.js +37 -22
- package/build/components/meta-boxes/meta-box-visibility.js.map +7 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +62 -53
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
- package/build/components/meta-boxes/use-meta-box-initialization.js +37 -32
- package/build/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
- package/build/components/more-menu/index.js +64 -44
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/more-menu/manage-patterns-menu-item.js +39 -37
- package/build/components/more-menu/manage-patterns-menu-item.js.map +7 -1
- package/build/components/more-menu/welcome-guide-menu-item.js +39 -21
- package/build/components/more-menu/welcome-guide-menu-item.js.map +7 -1
- package/build/components/preferences-modal/enable-custom-fields.js +76 -66
- package/build/components/preferences-modal/enable-custom-fields.js.map +7 -1
- package/build/components/preferences-modal/enable-panel.js +47 -43
- package/build/components/preferences-modal/enable-panel.js.map +7 -1
- package/build/components/preferences-modal/index.js +51 -39
- package/build/components/preferences-modal/index.js.map +7 -1
- package/build/components/preferences-modal/meta-boxes-section.js +65 -52
- package/build/components/preferences-modal/meta-boxes-section.js.map +7 -1
- package/build/components/welcome-guide/default.js +134 -97
- package/build/components/welcome-guide/default.js.map +7 -1
- package/build/components/welcome-guide/image.js +34 -23
- package/build/components/welcome-guide/image.js.map +7 -1
- package/build/components/welcome-guide/index.js +51 -38
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/components/welcome-guide/template.js +65 -45
- package/build/components/welcome-guide/template.js.map +7 -1
- package/build/deprecated.js +84 -110
- package/build/deprecated.js.map +7 -1
- package/build/hooks/use-navigate-to-entity-record.js +60 -78
- package/build/hooks/use-navigate-to-entity-record.js.map +7 -1
- package/build/index.js +101 -136
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +239 -431
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +33 -26
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -32
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +50 -57
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +288 -459
- package/build/store/selectors.js.map +7 -1
- package/build/utils/meta-boxes.js +31 -19
- package/build/utils/meta-boxes.js.map +7 -1
- package/build-module/commands/use-commands.js +35 -40
- package/build-module/commands/use-commands.js.map +7 -1
- package/build-module/components/back-button/fullscreen-mode-close.js +102 -110
- package/build-module/components/back-button/fullscreen-mode-close.js.map +7 -1
- package/build-module/components/back-button/index.js +28 -47
- package/build-module/components/back-button/index.js.map +7 -1
- package/build-module/components/browser-url/index.js +23 -38
- package/build-module/components/browser-url/index.js.map +7 -1
- package/build-module/components/editor-initialization/index.js +6 -13
- package/build-module/components/editor-initialization/index.js.map +7 -1
- package/build-module/components/editor-initialization/listener-hooks.js +20 -34
- package/build-module/components/editor-initialization/listener-hooks.js.map +7 -1
- package/build-module/components/init-pattern-modal/index.js +90 -74
- package/build-module/components/init-pattern-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +21 -26
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/layout/index.js +439 -448
- package/build-module/components/layout/index.js.map +7 -1
- package/build-module/components/layout/use-padding-appender.js +44 -54
- package/build-module/components/layout/use-padding-appender.js.map +7 -1
- package/build-module/components/layout/use-should-iframe.js +15 -25
- package/build-module/components/layout/use-should-iframe.js.map +7 -1
- package/build-module/components/meta-boxes/index.js +18 -26
- package/build-module/components/meta-boxes/index.js.map +7 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +18 -15
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +7 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +30 -44
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
- package/build-module/components/meta-boxes/use-meta-box-initialization.js +14 -25
- package/build-module/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
- package/build-module/components/more-menu/index.js +36 -37
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/more-menu/manage-patterns-menu-item.js +21 -31
- package/build-module/components/more-menu/manage-patterns-menu-item.js.map +7 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js +22 -16
- package/build-module/components/more-menu/welcome-guide-menu-item.js.map +7 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js +51 -56
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +7 -1
- package/build-module/components/preferences-modal/enable-panel.js +30 -38
- package/build-module/components/preferences-modal/enable-panel.js.map +7 -1
- package/build-module/components/preferences-modal/index.js +24 -34
- package/build-module/components/preferences-modal/index.js.map +7 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +34 -45
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +7 -1
- package/build-module/components/welcome-guide/default.js +107 -91
- package/build-module/components/welcome-guide/default.js.map +7 -1
- package/build-module/components/welcome-guide/image.js +16 -18
- package/build-module/components/welcome-guide/image.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +23 -31
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/components/welcome-guide/template.js +38 -39
- package/build-module/components/welcome-guide/template.js.map +7 -1
- package/build-module/deprecated.js +62 -103
- package/build-module/deprecated.js.map +7 -1
- package/build-module/hooks/use-navigate-to-entity-record.js +42 -73
- package/build-module/hooks/use-navigate-to-entity-record.js.map +7 -1
- package/build-module/index.js +70 -95
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +158 -368
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +9 -21
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -22
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +28 -51
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +232 -442
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/utils/meta-boxes.js +9 -13
- package/build-module/utils/meta-boxes.js.map +7 -1
- package/build-style/classic-rtl.css +0 -154
- package/build-style/classic.css +0 -154
- package/build-style/style-rtl.css +135 -110
- package/build-style/style.css +135 -110
- package/package.json +39 -31
- package/src/classic.scss +3 -0
- package/src/components/back-button/style.scss +3 -0
- package/src/components/layout/index.js +3 -2
- package/src/components/layout/style.scss +4 -0
- package/src/components/meta-boxes/meta-boxes-area/style.scss +3 -0
- package/src/components/welcome-guide/style.scss +3 -0
- package/src/style.scss +8 -4
- package/build/components/header/header-toolbar/index.native.js +0 -204
- package/build/components/header/header-toolbar/index.native.js.map +0 -1
- package/build/components/header/index.native.js +0 -59
- package/build/components/header/index.native.js.map +0 -1
- package/build/components/layout/index.native.js +0 -166
- package/build/components/layout/index.native.js.map +0 -1
- package/build/components/visual-editor/header.native.js +0 -63
- package/build/components/visual-editor/header.native.js.map +0 -1
- package/build/components/visual-editor/index.native.js +0 -44
- package/build/components/visual-editor/index.native.js.map +0 -1
- package/build/editor.native.js +0 -157
- package/build/editor.native.js.map +0 -1
- package/build/index.native.js +0 -58
- package/build/index.native.js.map +0 -1
- package/build-module/components/header/header-toolbar/index.native.js +0 -196
- package/build-module/components/header/header-toolbar/index.native.js.map +0 -1
- package/build-module/components/header/index.native.js +0 -50
- package/build-module/components/header/index.native.js.map +0 -1
- package/build-module/components/layout/index.native.js +0 -158
- package/build-module/components/layout/index.native.js.map +0 -1
- package/build-module/components/visual-editor/header.native.js +0 -56
- package/build-module/components/visual-editor/header.native.js.map +0 -1
- package/build-module/components/visual-editor/index.native.js +0 -35
- package/build-module/components/visual-editor/index.native.js.map +0 -1
- package/build-module/editor.native.js +0 -149
- package/build-module/editor.native.js.map +0 -1
- package/build-module/index.native.js +0 -45
- package/build-module/index.native.js.map +0 -1
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} = useSelect(select => {
|
|
20
|
-
const {
|
|
21
|
-
isFeatureActive
|
|
22
|
-
} = select(editPostStore);
|
|
23
|
-
const _isEditingTemplate = postType === 'wp_template';
|
|
24
|
-
const feature = _isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide';
|
|
25
|
-
return {
|
|
26
|
-
isActive: isFeatureActive(feature),
|
|
27
|
-
isEditingTemplate: _isEditingTemplate
|
|
28
|
-
};
|
|
29
|
-
}, [postType]);
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSelect } from "@wordpress/data";
|
|
3
|
+
import WelcomeGuideDefault from "./default";
|
|
4
|
+
import WelcomeGuideTemplate from "./template";
|
|
5
|
+
import { store as editPostStore } from "../../store";
|
|
6
|
+
function WelcomeGuide({ postType }) {
|
|
7
|
+
const { isActive, isEditingTemplate } = useSelect(
|
|
8
|
+
(select) => {
|
|
9
|
+
const { isFeatureActive } = select(editPostStore);
|
|
10
|
+
const _isEditingTemplate = postType === "wp_template";
|
|
11
|
+
const feature = _isEditingTemplate ? "welcomeGuideTemplate" : "welcomeGuide";
|
|
12
|
+
return {
|
|
13
|
+
isActive: isFeatureActive(feature),
|
|
14
|
+
isEditingTemplate: _isEditingTemplate
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
[postType]
|
|
18
|
+
);
|
|
30
19
|
if (!isActive) {
|
|
31
20
|
return null;
|
|
32
21
|
}
|
|
33
|
-
return isEditingTemplate ?
|
|
22
|
+
return isEditingTemplate ? /* @__PURE__ */ jsx(WelcomeGuideTemplate, {}) : /* @__PURE__ */ jsx(WelcomeGuideDefault, {});
|
|
34
23
|
}
|
|
35
|
-
|
|
24
|
+
export {
|
|
25
|
+
WelcomeGuide as default
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/welcome-guide/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide( { postType } ) {\n\tconst { isActive, isEditingTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isFeatureActive } = select( editPostStore );\n\t\t\tconst _isEditingTemplate = postType === 'wp_template';\n\t\t\tconst feature = _isEditingTemplate\n\t\t\t\t? 'welcomeGuideTemplate'\n\t\t\t\t: 'welcomeGuide';\n\n\t\t\treturn {\n\t\t\t\tisActive: isFeatureActive( feature ),\n\t\t\t\tisEditingTemplate: _isEditingTemplate,\n\t\t\t};\n\t\t},\n\t\t[ postType ]\n\t);\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isEditingTemplate ? (\n\t\t<WelcomeGuideTemplate />\n\t) : (\n\t\t<WelcomeGuideDefault />\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAkCE;AA/BF,SAAS,iBAAiB;AAK1B,OAAO,yBAAyB;AAChC,OAAO,0BAA0B;AACjC,SAAS,SAAS,qBAAqB;AAExB,SAAR,aAA+B,EAAE,SAAS,GAAI;AACpD,QAAM,EAAE,UAAU,kBAAkB,IAAI;AAAA,IACvC,CAAE,WAAY;AACb,YAAM,EAAE,gBAAgB,IAAI,OAAQ,aAAc;AAClD,YAAM,qBAAqB,aAAa;AACxC,YAAM,UAAU,qBACb,yBACA;AAEH,aAAO;AAAA,QACN,UAAU,gBAAiB,OAAQ;AAAA,QACnC,mBAAmB;AAAA,MACpB;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAK,CAAE,UAAW;AACjB,WAAO;AAAA,EACR;AAEA,SAAO,oBACN,oBAAC,wBAAqB,IAEtB,oBAAC,uBAAoB;AAEvB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,40 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})]
|
|
36
|
-
})
|
|
37
|
-
}]
|
|
38
|
-
});
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useDispatch } from "@wordpress/data";
|
|
3
|
+
import { Guide } from "@wordpress/components";
|
|
4
|
+
import { __ } from "@wordpress/i18n";
|
|
5
|
+
import WelcomeGuideImage from "./image";
|
|
6
|
+
import { store as editPostStore } from "../../store";
|
|
7
|
+
function WelcomeGuideTemplate() {
|
|
8
|
+
const { toggleFeature } = useDispatch(editPostStore);
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
|
+
Guide,
|
|
11
|
+
{
|
|
12
|
+
className: "edit-template-welcome-guide",
|
|
13
|
+
contentLabel: __("Welcome to the template editor"),
|
|
14
|
+
finishButtonText: __("Get started"),
|
|
15
|
+
onFinish: () => toggleFeature("welcomeGuideTemplate"),
|
|
16
|
+
pages: [
|
|
17
|
+
{
|
|
18
|
+
image: /* @__PURE__ */ jsx(
|
|
19
|
+
WelcomeGuideImage,
|
|
20
|
+
{
|
|
21
|
+
nonAnimatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.svg",
|
|
22
|
+
animatedSrc: "https://s.w.org/images/block-editor/welcome-template-editor.gif"
|
|
23
|
+
}
|
|
24
|
+
),
|
|
25
|
+
content: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
26
|
+
/* @__PURE__ */ jsx("h1", { className: "edit-post-welcome-guide__heading", children: __("Welcome to the template editor") }),
|
|
27
|
+
/* @__PURE__ */ jsx("p", { className: "edit-post-welcome-guide__text", children: __(
|
|
28
|
+
"Templates help define the layout of the site. You can customize all aspects of your posts and pages using blocks and patterns in this editor."
|
|
29
|
+
) })
|
|
30
|
+
] })
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
);
|
|
39
35
|
}
|
|
40
|
-
|
|
36
|
+
export {
|
|
37
|
+
WelcomeGuideTemplate as default
|
|
38
|
+
};
|
|
39
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/welcome-guide/template.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useDispatch } from '@wordpress/data';\nimport { Guide } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideImage from './image';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuideTemplate() {\n\tconst { toggleFeature } = useDispatch( editPostStore );\n\n\treturn (\n\t\t<Guide\n\t\t\tclassName=\"edit-template-welcome-guide\"\n\t\t\tcontentLabel={ __( 'Welcome to the template editor' ) }\n\t\t\tfinishButtonText={ __( 'Get started' ) }\n\t\t\tonFinish={ () => toggleFeature( 'welcomeGuideTemplate' ) }\n\t\t\tpages={ [\n\t\t\t\t{\n\t\t\t\t\timage: (\n\t\t\t\t\t\t<WelcomeGuideImage\n\t\t\t\t\t\t\tnonAnimatedSrc=\"https://s.w.org/images/block-editor/welcome-template-editor.svg\"\n\t\t\t\t\t\t\tanimatedSrc=\"https://s.w.org/images/block-editor/welcome-template-editor.gif\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t),\n\t\t\t\t\tcontent: (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<h1 className=\"edit-post-welcome-guide__heading\">\n\t\t\t\t\t\t\t\t{ __( 'Welcome to the template editor' ) }\n\t\t\t\t\t\t\t</h1>\n\t\t\t\t\t\t\t<p className=\"edit-post-welcome-guide__text\">\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'Templates help define the layout of the site. You can customize all aspects of your posts and pages using blocks and patterns in this editor.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t</>\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t] }\n\t\t/>\n\t);\n}\n"],
|
|
5
|
+
"mappings": "AAyBM,SAMA,UANA,KAMA,YANA;AAtBN,SAAS,mBAAmB;AAC5B,SAAS,aAAa;AACtB,SAAS,UAAU;AAKnB,OAAO,uBAAuB;AAC9B,SAAS,SAAS,qBAAqB;AAExB,SAAR,uBAAwC;AAC9C,QAAM,EAAE,cAAc,IAAI,YAAa,aAAc;AAErD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,cAAe,GAAI,gCAAiC;AAAA,MACpD,kBAAmB,GAAI,aAAc;AAAA,MACrC,UAAW,MAAM,cAAe,sBAAuB;AAAA,MACvD,OAAQ;AAAA,QACP;AAAA,UACC,OACC;AAAA,YAAC;AAAA;AAAA,cACA,gBAAe;AAAA,cACf,aAAY;AAAA;AAAA,UACb;AAAA,UAED,SACC,iCACC;AAAA,gCAAC,QAAG,WAAU,oCACX,aAAI,gCAAiC,GACxC;AAAA,YACA,oBAAC,OAAE,WAAU,iCACV;AAAA,cACD;AAAA,YACD,GACD;AAAA,aACD;AAAA,QAEF;AAAA,MACD;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,145 +1,104 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
const
|
|
17
|
-
const
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
privateApis as editorPrivateApis,
|
|
4
|
+
PluginBlockSettingsMenuItem as EditorPluginBlockSettingsMenuItem,
|
|
5
|
+
PluginDocumentSettingPanel as EditorPluginDocumentSettingPanel,
|
|
6
|
+
PluginMoreMenuItem as EditorPluginMoreMenuItem,
|
|
7
|
+
PluginPrePublishPanel as EditorPluginPrePublishPanel,
|
|
8
|
+
PluginPostPublishPanel as EditorPluginPostPublishPanel,
|
|
9
|
+
PluginPostStatusInfo as EditorPluginPostStatusInfo,
|
|
10
|
+
PluginSidebar as EditorPluginSidebar,
|
|
11
|
+
PluginSidebarMoreMenuItem as EditorPluginSidebarMoreMenuItem
|
|
12
|
+
} from "@wordpress/editor";
|
|
13
|
+
import { getPath } from "@wordpress/url";
|
|
14
|
+
import deprecated from "@wordpress/deprecated";
|
|
15
|
+
import { unlock } from "./lock-unlock";
|
|
16
|
+
const { PluginPostExcerpt } = unlock(editorPrivateApis);
|
|
17
|
+
const isSiteEditor = getPath(window.location.href)?.includes(
|
|
18
|
+
"site-editor.php"
|
|
19
|
+
);
|
|
20
|
+
const deprecateSlot = (name) => {
|
|
18
21
|
deprecated(`wp.editPost.${name}`, {
|
|
19
|
-
since:
|
|
22
|
+
since: "6.6",
|
|
20
23
|
alternative: `wp.editor.${name}`
|
|
21
24
|
});
|
|
22
25
|
};
|
|
23
|
-
|
|
24
|
-
/* eslint-disable jsdoc/require-param */
|
|
25
|
-
/**
|
|
26
|
-
* @see PluginBlockSettingsMenuItem in @wordpress/editor package.
|
|
27
|
-
*/
|
|
28
|
-
export function PluginBlockSettingsMenuItem(props) {
|
|
26
|
+
function PluginBlockSettingsMenuItem(props) {
|
|
29
27
|
if (isSiteEditor) {
|
|
30
28
|
return null;
|
|
31
29
|
}
|
|
32
|
-
deprecateSlot(
|
|
33
|
-
return
|
|
34
|
-
...props
|
|
35
|
-
});
|
|
30
|
+
deprecateSlot("PluginBlockSettingsMenuItem");
|
|
31
|
+
return /* @__PURE__ */ jsx(EditorPluginBlockSettingsMenuItem, { ...props });
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* @see PluginDocumentSettingPanel in @wordpress/editor package.
|
|
40
|
-
*/
|
|
41
|
-
export function PluginDocumentSettingPanel(props) {
|
|
33
|
+
function PluginDocumentSettingPanel(props) {
|
|
42
34
|
if (isSiteEditor) {
|
|
43
35
|
return null;
|
|
44
36
|
}
|
|
45
|
-
deprecateSlot(
|
|
46
|
-
return
|
|
47
|
-
...props
|
|
48
|
-
});
|
|
37
|
+
deprecateSlot("PluginDocumentSettingPanel");
|
|
38
|
+
return /* @__PURE__ */ jsx(EditorPluginDocumentSettingPanel, { ...props });
|
|
49
39
|
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* @see PluginMoreMenuItem in @wordpress/editor package.
|
|
53
|
-
*/
|
|
54
|
-
export function PluginMoreMenuItem(props) {
|
|
40
|
+
function PluginMoreMenuItem(props) {
|
|
55
41
|
if (isSiteEditor) {
|
|
56
42
|
return null;
|
|
57
43
|
}
|
|
58
|
-
deprecateSlot(
|
|
59
|
-
return
|
|
60
|
-
...props
|
|
61
|
-
});
|
|
44
|
+
deprecateSlot("PluginMoreMenuItem");
|
|
45
|
+
return /* @__PURE__ */ jsx(EditorPluginMoreMenuItem, { ...props });
|
|
62
46
|
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* @see PluginPrePublishPanel in @wordpress/editor package.
|
|
66
|
-
*/
|
|
67
|
-
export function PluginPrePublishPanel(props) {
|
|
47
|
+
function PluginPrePublishPanel(props) {
|
|
68
48
|
if (isSiteEditor) {
|
|
69
49
|
return null;
|
|
70
50
|
}
|
|
71
|
-
deprecateSlot(
|
|
72
|
-
return
|
|
73
|
-
...props
|
|
74
|
-
});
|
|
51
|
+
deprecateSlot("PluginPrePublishPanel");
|
|
52
|
+
return /* @__PURE__ */ jsx(EditorPluginPrePublishPanel, { ...props });
|
|
75
53
|
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* @see PluginPostPublishPanel in @wordpress/editor package.
|
|
79
|
-
*/
|
|
80
|
-
export function PluginPostPublishPanel(props) {
|
|
54
|
+
function PluginPostPublishPanel(props) {
|
|
81
55
|
if (isSiteEditor) {
|
|
82
56
|
return null;
|
|
83
57
|
}
|
|
84
|
-
deprecateSlot(
|
|
85
|
-
return
|
|
86
|
-
...props
|
|
87
|
-
});
|
|
58
|
+
deprecateSlot("PluginPostPublishPanel");
|
|
59
|
+
return /* @__PURE__ */ jsx(EditorPluginPostPublishPanel, { ...props });
|
|
88
60
|
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* @see PluginPostStatusInfo in @wordpress/editor package.
|
|
92
|
-
*/
|
|
93
|
-
export function PluginPostStatusInfo(props) {
|
|
61
|
+
function PluginPostStatusInfo(props) {
|
|
94
62
|
if (isSiteEditor) {
|
|
95
63
|
return null;
|
|
96
64
|
}
|
|
97
|
-
deprecateSlot(
|
|
98
|
-
return
|
|
99
|
-
...props
|
|
100
|
-
});
|
|
65
|
+
deprecateSlot("PluginPostStatusInfo");
|
|
66
|
+
return /* @__PURE__ */ jsx(EditorPluginPostStatusInfo, { ...props });
|
|
101
67
|
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* @see PluginSidebar in @wordpress/editor package.
|
|
105
|
-
*/
|
|
106
|
-
export function PluginSidebar(props) {
|
|
68
|
+
function PluginSidebar(props) {
|
|
107
69
|
if (isSiteEditor) {
|
|
108
70
|
return null;
|
|
109
71
|
}
|
|
110
|
-
deprecateSlot(
|
|
111
|
-
return
|
|
112
|
-
...props
|
|
113
|
-
});
|
|
72
|
+
deprecateSlot("PluginSidebar");
|
|
73
|
+
return /* @__PURE__ */ jsx(EditorPluginSidebar, { ...props });
|
|
114
74
|
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @see PluginSidebarMoreMenuItem in @wordpress/editor package.
|
|
118
|
-
*/
|
|
119
|
-
export function PluginSidebarMoreMenuItem(props) {
|
|
75
|
+
function PluginSidebarMoreMenuItem(props) {
|
|
120
76
|
if (isSiteEditor) {
|
|
121
77
|
return null;
|
|
122
78
|
}
|
|
123
|
-
deprecateSlot(
|
|
124
|
-
return
|
|
125
|
-
...props
|
|
126
|
-
});
|
|
79
|
+
deprecateSlot("PluginSidebarMoreMenuItem");
|
|
80
|
+
return /* @__PURE__ */ jsx(EditorPluginSidebarMoreMenuItem, { ...props });
|
|
127
81
|
}
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* @see PluginPostExcerpt in @wordpress/editor package.
|
|
131
|
-
*/
|
|
132
|
-
export function __experimentalPluginPostExcerpt() {
|
|
82
|
+
function __experimentalPluginPostExcerpt() {
|
|
133
83
|
if (isSiteEditor) {
|
|
134
84
|
return null;
|
|
135
85
|
}
|
|
136
|
-
deprecated(
|
|
137
|
-
since:
|
|
138
|
-
hint:
|
|
139
|
-
link:
|
|
86
|
+
deprecated("wp.editPost.__experimentalPluginPostExcerpt", {
|
|
87
|
+
since: "6.6",
|
|
88
|
+
hint: "Core and custom panels can be access programmatically using their panel name.",
|
|
89
|
+
link: "https://developer.wordpress.org/block-editor/reference-guides/slotfills/plugin-document-setting-panel/#accessing-a-panel-programmatically"
|
|
140
90
|
});
|
|
141
91
|
return PluginPostExcerpt;
|
|
142
92
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
93
|
+
export {
|
|
94
|
+
PluginBlockSettingsMenuItem,
|
|
95
|
+
PluginDocumentSettingPanel,
|
|
96
|
+
PluginMoreMenuItem,
|
|
97
|
+
PluginPostPublishPanel,
|
|
98
|
+
PluginPostStatusInfo,
|
|
99
|
+
PluginPrePublishPanel,
|
|
100
|
+
PluginSidebar,
|
|
101
|
+
PluginSidebarMoreMenuItem,
|
|
102
|
+
__experimentalPluginPostExcerpt
|
|
103
|
+
};
|
|
104
|
+
//# sourceMappingURL=deprecated.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/deprecated.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as editorPrivateApis,\n\tPluginBlockSettingsMenuItem as EditorPluginBlockSettingsMenuItem,\n\tPluginDocumentSettingPanel as EditorPluginDocumentSettingPanel,\n\tPluginMoreMenuItem as EditorPluginMoreMenuItem,\n\tPluginPrePublishPanel as EditorPluginPrePublishPanel,\n\tPluginPostPublishPanel as EditorPluginPostPublishPanel,\n\tPluginPostStatusInfo as EditorPluginPostStatusInfo,\n\tPluginSidebar as EditorPluginSidebar,\n\tPluginSidebarMoreMenuItem as EditorPluginSidebarMoreMenuItem,\n} from '@wordpress/editor';\nimport { getPath } from '@wordpress/url';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from './lock-unlock';\nconst { PluginPostExcerpt } = unlock( editorPrivateApis );\n\nconst isSiteEditor = getPath( window.location.href )?.includes(\n\t'site-editor.php'\n);\n\nconst deprecateSlot = ( name ) => {\n\tdeprecated( `wp.editPost.${ name }`, {\n\t\tsince: '6.6',\n\t\talternative: `wp.editor.${ name }`,\n\t} );\n};\n\n/* eslint-disable jsdoc/require-param */\n/**\n * @see PluginBlockSettingsMenuItem in @wordpress/editor package.\n */\nexport function PluginBlockSettingsMenuItem( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginBlockSettingsMenuItem' );\n\treturn <EditorPluginBlockSettingsMenuItem { ...props } />;\n}\n\n/**\n * @see PluginDocumentSettingPanel in @wordpress/editor package.\n */\nexport function PluginDocumentSettingPanel( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginDocumentSettingPanel' );\n\treturn <EditorPluginDocumentSettingPanel { ...props } />;\n}\n\n/**\n * @see PluginMoreMenuItem in @wordpress/editor package.\n */\nexport function PluginMoreMenuItem( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginMoreMenuItem' );\n\treturn <EditorPluginMoreMenuItem { ...props } />;\n}\n\n/**\n * @see PluginPrePublishPanel in @wordpress/editor package.\n */\nexport function PluginPrePublishPanel( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginPrePublishPanel' );\n\treturn <EditorPluginPrePublishPanel { ...props } />;\n}\n\n/**\n * @see PluginPostPublishPanel in @wordpress/editor package.\n */\nexport function PluginPostPublishPanel( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginPostPublishPanel' );\n\treturn <EditorPluginPostPublishPanel { ...props } />;\n}\n\n/**\n * @see PluginPostStatusInfo in @wordpress/editor package.\n */\nexport function PluginPostStatusInfo( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginPostStatusInfo' );\n\treturn <EditorPluginPostStatusInfo { ...props } />;\n}\n\n/**\n * @see PluginSidebar in @wordpress/editor package.\n */\nexport function PluginSidebar( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginSidebar' );\n\treturn <EditorPluginSidebar { ...props } />;\n}\n\n/**\n * @see PluginSidebarMoreMenuItem in @wordpress/editor package.\n */\nexport function PluginSidebarMoreMenuItem( props ) {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecateSlot( 'PluginSidebarMoreMenuItem' );\n\treturn <EditorPluginSidebarMoreMenuItem { ...props } />;\n}\n\n/**\n * @see PluginPostExcerpt in @wordpress/editor package.\n */\nexport function __experimentalPluginPostExcerpt() {\n\tif ( isSiteEditor ) {\n\t\treturn null;\n\t}\n\tdeprecated( 'wp.editPost.__experimentalPluginPostExcerpt', {\n\t\tsince: '6.6',\n\t\thint: 'Core and custom panels can be access programmatically using their panel name.',\n\t\tlink: 'https://developer.wordpress.org/block-editor/reference-guides/slotfills/plugin-document-setting-panel/#accessing-a-panel-programmatically',\n\t} );\n\treturn PluginPostExcerpt;\n}\n\n/* eslint-enable jsdoc/require-param */\n"],
|
|
5
|
+
"mappings": "AA2CQ;AAxCR;AAAA,EACC,eAAe;AAAA,EACf,+BAA+B;AAAA,EAC/B,8BAA8B;AAAA,EAC9B,sBAAsB;AAAA,EACtB,yBAAyB;AAAA,EACzB,0BAA0B;AAAA,EAC1B,wBAAwB;AAAA,EACxB,iBAAiB;AAAA,EACjB,6BAA6B;AAAA,OACvB;AACP,SAAS,eAAe;AACxB,OAAO,gBAAgB;AAKvB,SAAS,cAAc;AACvB,MAAM,EAAE,kBAAkB,IAAI,OAAQ,iBAAkB;AAExD,MAAM,eAAe,QAAS,OAAO,SAAS,IAAK,GAAG;AAAA,EACrD;AACD;AAEA,MAAM,gBAAgB,CAAE,SAAU;AACjC,aAAY,eAAgB,IAAK,IAAI;AAAA,IACpC,OAAO;AAAA,IACP,aAAa,aAAc,IAAK;AAAA,EACjC,CAAE;AACH;AAMO,SAAS,4BAA6B,OAAQ;AACpD,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,6BAA8B;AAC7C,SAAO,oBAAC,qCAAoC,GAAG,OAAQ;AACxD;AAKO,SAAS,2BAA4B,OAAQ;AACnD,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,4BAA6B;AAC5C,SAAO,oBAAC,oCAAmC,GAAG,OAAQ;AACvD;AAKO,SAAS,mBAAoB,OAAQ;AAC3C,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,oBAAqB;AACpC,SAAO,oBAAC,4BAA2B,GAAG,OAAQ;AAC/C;AAKO,SAAS,sBAAuB,OAAQ;AAC9C,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,uBAAwB;AACvC,SAAO,oBAAC,+BAA8B,GAAG,OAAQ;AAClD;AAKO,SAAS,uBAAwB,OAAQ;AAC/C,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,wBAAyB;AACxC,SAAO,oBAAC,gCAA+B,GAAG,OAAQ;AACnD;AAKO,SAAS,qBAAsB,OAAQ;AAC7C,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,sBAAuB;AACtC,SAAO,oBAAC,8BAA6B,GAAG,OAAQ;AACjD;AAKO,SAAS,cAAe,OAAQ;AACtC,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,eAAgB;AAC/B,SAAO,oBAAC,uBAAsB,GAAG,OAAQ;AAC1C;AAKO,SAAS,0BAA2B,OAAQ;AAClD,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,gBAAe,2BAA4B;AAC3C,SAAO,oBAAC,mCAAkC,GAAG,OAAQ;AACtD;AAKO,SAAS,kCAAkC;AACjD,MAAK,cAAe;AACnB,WAAO;AAAA,EACR;AACA,aAAY,+CAA+C;AAAA,IAC1D,OAAO;AAAA,IACP,MAAM;AAAA,IACN,MAAM;AAAA,EACP,CAAE;AACF,SAAO;AACR;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,76 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* A hook that records the 'entity' history in the post editor as a user
|
|
10
|
-
* navigates between editing a post and editing the post template or patterns.
|
|
11
|
-
*
|
|
12
|
-
* Implemented as a stack, so a little similar to the browser history API.
|
|
13
|
-
*
|
|
14
|
-
* Used to control displaying UI elements like the back button.
|
|
15
|
-
*
|
|
16
|
-
* @param {number} initialPostId The post id of the post when the editor loaded.
|
|
17
|
-
* @param {string} initialPostType The post type of the post when the editor loaded.
|
|
18
|
-
* @param {string} defaultRenderingMode The rendering mode to switch to when navigating.
|
|
19
|
-
*
|
|
20
|
-
* @return {Object} An object containing the `currentPost` variable and
|
|
21
|
-
* `onNavigateToEntityRecord` and `onNavigateToPreviousEntityRecord` functions.
|
|
22
|
-
*/
|
|
23
|
-
export default function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
|
|
24
|
-
const [postHistory, dispatch] = useReducer((historyState, {
|
|
25
|
-
type,
|
|
26
|
-
post,
|
|
27
|
-
previousRenderingMode
|
|
28
|
-
}) => {
|
|
29
|
-
if (type === 'push') {
|
|
30
|
-
return [...historyState, {
|
|
31
|
-
post,
|
|
32
|
-
previousRenderingMode
|
|
33
|
-
}];
|
|
34
|
-
}
|
|
35
|
-
if (type === 'pop') {
|
|
36
|
-
// Try to leave one item in the history.
|
|
37
|
-
if (historyState.length > 1) {
|
|
38
|
-
return historyState.slice(0, -1);
|
|
1
|
+
import { useCallback, useReducer } from "@wordpress/element";
|
|
2
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
3
|
+
import { store as editorStore } from "@wordpress/editor";
|
|
4
|
+
function useNavigateToEntityRecord(initialPostId, initialPostType, defaultRenderingMode) {
|
|
5
|
+
const [postHistory, dispatch] = useReducer(
|
|
6
|
+
(historyState, { type, post: post2, previousRenderingMode: previousRenderingMode2 }) => {
|
|
7
|
+
if (type === "push") {
|
|
8
|
+
return [...historyState, { post: post2, previousRenderingMode: previousRenderingMode2 }];
|
|
39
9
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} = useSelect(editorStore);
|
|
55
|
-
const {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
setRenderingMode(defaultRenderingMode);
|
|
69
|
-
}, [getRenderingMode, setRenderingMode, defaultRenderingMode]);
|
|
10
|
+
if (type === "pop") {
|
|
11
|
+
if (historyState.length > 1) {
|
|
12
|
+
return historyState.slice(0, -1);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return historyState;
|
|
16
|
+
},
|
|
17
|
+
[
|
|
18
|
+
{
|
|
19
|
+
post: { postId: initialPostId, postType: initialPostType }
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
);
|
|
23
|
+
const { post, previousRenderingMode } = postHistory[postHistory.length - 1];
|
|
24
|
+
const { getRenderingMode } = useSelect(editorStore);
|
|
25
|
+
const { setRenderingMode } = useDispatch(editorStore);
|
|
26
|
+
const onNavigateToEntityRecord = useCallback(
|
|
27
|
+
(params) => {
|
|
28
|
+
dispatch({
|
|
29
|
+
type: "push",
|
|
30
|
+
post: { postId: params.postId, postType: params.postType },
|
|
31
|
+
// Save the current rendering mode so we can restore it when navigating back.
|
|
32
|
+
previousRenderingMode: getRenderingMode()
|
|
33
|
+
});
|
|
34
|
+
setRenderingMode(defaultRenderingMode);
|
|
35
|
+
},
|
|
36
|
+
[getRenderingMode, setRenderingMode, defaultRenderingMode]
|
|
37
|
+
);
|
|
70
38
|
const onNavigateToPreviousEntityRecord = useCallback(() => {
|
|
71
|
-
dispatch({
|
|
72
|
-
type: 'pop'
|
|
73
|
-
});
|
|
39
|
+
dispatch({ type: "pop" });
|
|
74
40
|
if (previousRenderingMode) {
|
|
75
41
|
setRenderingMode(previousRenderingMode);
|
|
76
42
|
}
|
|
@@ -78,7 +44,10 @@ export default function useNavigateToEntityRecord(initialPostId, initialPostType
|
|
|
78
44
|
return {
|
|
79
45
|
currentPost: post,
|
|
80
46
|
onNavigateToEntityRecord,
|
|
81
|
-
onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord :
|
|
47
|
+
onNavigateToPreviousEntityRecord: postHistory.length > 1 ? onNavigateToPreviousEntityRecord : void 0
|
|
82
48
|
};
|
|
83
49
|
}
|
|
84
|
-
|
|
50
|
+
export {
|
|
51
|
+
useNavigateToEntityRecord as default
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=use-navigate-to-entity-record.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/hooks/use-navigate-to-entity-record.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useReducer } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\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 * @param {string} defaultRenderingMode The rendering mode to switch to when navigating.\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\tdefaultRenderingMode\n) {\n\tconst [ postHistory, dispatch ] = useReducer(\n\t\t( historyState, { type, post, previousRenderingMode } ) => {\n\t\t\tif ( type === 'push' ) {\n\t\t\t\treturn [ ...historyState, { post, previousRenderingMode } ];\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[\n\t\t\t{\n\t\t\t\tpost: { postId: initialPostId, postType: initialPostType },\n\t\t\t},\n\t\t]\n\t);\n\n\tconst { post, previousRenderingMode } =\n\t\tpostHistory[ postHistory.length - 1 ];\n\n\tconst { getRenderingMode } = useSelect( editorStore );\n\tconst { setRenderingMode } = useDispatch( editorStore );\n\n\tconst onNavigateToEntityRecord = useCallback(\n\t\t( params ) => {\n\t\t\tdispatch( {\n\t\t\t\ttype: 'push',\n\t\t\t\tpost: { postId: params.postId, postType: params.postType },\n\t\t\t\t// Save the current rendering mode so we can restore it when navigating back.\n\t\t\t\tpreviousRenderingMode: getRenderingMode(),\n\t\t\t} );\n\t\t\tsetRenderingMode( defaultRenderingMode );\n\t\t},\n\t\t[ getRenderingMode, setRenderingMode, defaultRenderingMode ]\n\t);\n\n\tconst onNavigateToPreviousEntityRecord = useCallback( () => {\n\t\tdispatch( { type: 'pop' } );\n\t\tif ( previousRenderingMode ) {\n\t\t\tsetRenderingMode( previousRenderingMode );\n\t\t}\n\t}, [ setRenderingMode, previousRenderingMode ] );\n\n\treturn {\n\t\tcurrentPost: post,\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"],
|
|
5
|
+
"mappings": "AAGA,SAAS,aAAa,kBAAkB;AACxC,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,mBAAmB;AAiBtB,SAAR,0BACN,eACA,iBACA,sBACC;AACD,QAAM,CAAE,aAAa,QAAS,IAAI;AAAA,IACjC,CAAE,cAAc,EAAE,MAAM,MAAAA,OAAM,uBAAAC,uBAAsB,MAAO;AAC1D,UAAK,SAAS,QAAS;AACtB,eAAO,CAAE,GAAG,cAAc,EAAE,MAAAD,OAAM,uBAAAC,uBAAsB,CAAE;AAAA,MAC3D;AACA,UAAK,SAAS,OAAQ;AAErB,YAAK,aAAa,SAAS,GAAI;AAC9B,iBAAO,aAAa,MAAO,GAAG,EAAG;AAAA,QAClC;AAAA,MACD;AACA,aAAO;AAAA,IACR;AAAA,IACA;AAAA,MACC;AAAA,QACC,MAAM,EAAE,QAAQ,eAAe,UAAU,gBAAgB;AAAA,MAC1D;AAAA,IACD;AAAA,EACD;AAEA,QAAM,EAAE,MAAM,sBAAsB,IACnC,YAAa,YAAY,SAAS,CAAE;AAErC,QAAM,EAAE,iBAAiB,IAAI,UAAW,WAAY;AACpD,QAAM,EAAE,iBAAiB,IAAI,YAAa,WAAY;AAEtD,QAAM,2BAA2B;AAAA,IAChC,CAAE,WAAY;AACb,eAAU;AAAA,QACT,MAAM;AAAA,QACN,MAAM,EAAE,QAAQ,OAAO,QAAQ,UAAU,OAAO,SAAS;AAAA;AAAA,QAEzD,uBAAuB,iBAAiB;AAAA,MACzC,CAAE;AACF,uBAAkB,oBAAqB;AAAA,IACxC;AAAA,IACA,CAAE,kBAAkB,kBAAkB,oBAAqB;AAAA,EAC5D;AAEA,QAAM,mCAAmC,YAAa,MAAM;AAC3D,aAAU,EAAE,MAAM,MAAM,CAAE;AAC1B,QAAK,uBAAwB;AAC5B,uBAAkB,qBAAsB;AAAA,IACzC;AAAA,EACD,GAAG,CAAE,kBAAkB,qBAAsB,CAAE;AAE/C,SAAO;AAAA,IACN,aAAa;AAAA,IACb;AAAA,IACA,kCACC,YAAY,SAAS,IAClB,mCACA;AAAA,EACL;AACD;",
|
|
6
|
+
"names": ["post", "previousRenderingMode"]
|
|
7
|
+
}
|