@wordpress/edit-post 6.7.0 → 6.10.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 +6 -0
- package/README.md +1 -1
- package/build/components/block-manager/category.js.map +1 -1
- package/build/components/block-manager/index.js +12 -4
- package/build/components/block-manager/index.js.map +1 -1
- package/build/components/device-preview/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.js.map +1 -1
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build/components/header/template-title/delete-template.js.map +1 -1
- package/build/components/header/template-title/edit-template-title.js +11 -2
- package/build/components/header/template-title/edit-template-title.js.map +1 -1
- package/build/components/header/template-title/index.js.map +1 -1
- package/build/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/actions-panel.js.map +1 -1
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -26
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build/components/sidebar/featured-image/index.js.map +1 -1
- package/build/components/sidebar/page-attributes/index.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build/components/sidebar/post-format/index.js +3 -1
- package/build/components/sidebar/post-format/index.js.map +1 -1
- package/build/components/sidebar/post-schedule/index.js +28 -12
- package/build/components/sidebar/post-schedule/index.js.map +1 -1
- package/build/components/sidebar/post-slug/index.js +3 -1
- package/build/components/sidebar/post-slug/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +6 -2
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-template/create-modal.js +116 -0
- package/build/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build/components/sidebar/post-template/form.js +123 -0
- package/build/components/sidebar/post-template/form.js.map +1 -0
- package/build/components/sidebar/post-template/index.js +124 -0
- package/build/components/sidebar/post-template/index.js.map +1 -0
- package/build/components/sidebar/post-url/index.js +68 -0
- package/build/components/sidebar/post-url/index.js.map +1 -0
- package/build/components/sidebar/post-visibility/index.js +21 -6
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +2 -6
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +31 -13
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/block-inspector-button.js +3 -7
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/components/visual-editor/index.js +4 -2
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/editor.js +1 -1
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/plugins/copy-content-menu-item/index.js +1 -1
- package/build/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +8 -8
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/block-manager/category.js.map +1 -1
- package/build-module/components/block-manager/index.js +13 -5
- package/build-module/components/block-manager/index.js.map +1 -1
- package/build-module/components/device-preview/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.js.map +1 -1
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
- package/build-module/components/header/template-title/delete-template.js.map +1 -1
- package/build-module/components/header/template-title/edit-template-title.js +12 -2
- package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
- package/build-module/components/header/template-title/index.js.map +1 -1
- package/build-module/components/header/tools-more-menu-group/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/actions-panel.js.map +1 -1
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +3 -25
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-publish-sidebar.js.map +1 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +1 -1
- package/build-module/components/sidebar/discussion-panel/index.js.map +1 -1
- package/build-module/components/sidebar/featured-image/index.js.map +1 -1
- package/build-module/components/sidebar/page-attributes/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/build-module/components/sidebar/plugin-post-status-info/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-excerpt/index.js.map +1 -1
- package/build-module/components/sidebar/post-format/index.js +3 -1
- package/build-module/components/sidebar/post-format/index.js.map +1 -1
- package/build-module/components/sidebar/post-schedule/index.js +32 -13
- package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
- package/build-module/components/sidebar/post-slug/index.js +3 -1
- package/build-module/components/sidebar/post-slug/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +4 -2
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-template/create-modal.js +104 -0
- package/build-module/components/sidebar/post-template/create-modal.js.map +1 -0
- package/build-module/components/sidebar/post-template/form.js +106 -0
- package/build-module/components/sidebar/post-template/form.js.map +1 -0
- package/build-module/components/sidebar/post-template/index.js +110 -0
- package/build-module/components/sidebar/post-template/index.js.map +1 -0
- package/build-module/components/sidebar/post-url/index.js +59 -0
- package/build-module/components/sidebar/post-url/index.js.map +1 -0
- package/build-module/components/sidebar/post-visibility/index.js +24 -8
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +2 -4
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +32 -14
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js +3 -5
- package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build-module/components/visual-editor/index.js +4 -2
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/editor.js +2 -2
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +2 -2
- package/build-module/editor.native.js.map +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js +1 -1
- package/build-module/plugins/copy-content-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +8 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +85 -87
- package/build-style/style.css +84 -90
- package/package.json +27 -27
- package/src/components/block-manager/category.js +2 -2
- package/src/components/block-manager/index.js +15 -4
- package/src/components/device-preview/index.js +4 -6
- package/src/components/editor-initialization/listener-hooks.js +2 -3
- package/src/components/header/fullscreen-mode-close/index.js +2 -3
- package/src/components/header/header-toolbar/index.js +6 -11
- package/src/components/header/index.js +6 -9
- package/src/components/header/mode-switcher/index.js +4 -4
- package/src/components/header/post-publish-button-or-toggle.js +4 -6
- package/src/components/header/template-title/delete-template.js +2 -3
- package/src/components/header/template-title/edit-template-title.js +11 -1
- package/src/components/header/template-title/index.js +2 -3
- package/src/components/header/tools-more-menu-group/index.js +2 -3
- package/src/components/keyboard-shortcut-help-modal/config.js +8 -0
- package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +14 -0
- package/src/components/keyboard-shortcut-help-modal/test/index.js +2 -1
- package/src/components/keyboard-shortcuts/index.js +4 -8
- package/src/components/layout/actions-panel.js +6 -9
- package/src/components/layout/index.js +12 -21
- package/src/components/layout/index.native.js +4 -5
- package/src/components/preferences-modal/index.js +5 -23
- package/src/components/preferences-modal/options/enable-custom-fields.js +2 -2
- package/src/components/preferences-modal/options/enable-panel.js +2 -3
- package/src/components/preferences-modal/options/enable-publish-sidebar.js +2 -3
- package/src/components/preferences-modal/test/index.js +3 -3
- package/src/components/secondary-sidebar/inserter-sidebar.js +2 -3
- package/src/components/sidebar/discussion-panel/index.js +2 -3
- package/src/components/sidebar/featured-image/index.js +2 -3
- package/src/components/sidebar/page-attributes/index.js +2 -3
- package/src/components/sidebar/plugin-document-setting-panel/index.js +2 -3
- package/src/components/sidebar/plugin-post-status-info/index.js +2 -2
- package/src/components/sidebar/plugin-sidebar/index.js +2 -3
- package/src/components/sidebar/post-author/style.scss +4 -10
- package/src/components/sidebar/post-excerpt/index.js +2 -3
- package/src/components/sidebar/post-format/index.js +1 -1
- package/src/components/sidebar/post-format/style.scss +5 -0
- package/src/components/sidebar/post-schedule/index.js +27 -16
- package/src/components/sidebar/post-schedule/style.scss +17 -4
- package/src/components/sidebar/post-slug/index.js +1 -1
- package/src/components/sidebar/post-slug/style.scss +4 -3
- package/src/components/sidebar/post-status/index.js +8 -5
- package/src/components/sidebar/post-template/create-modal.js +146 -0
- package/src/components/sidebar/post-template/form.js +143 -0
- package/src/components/sidebar/post-template/index.js +102 -0
- package/src/components/sidebar/post-template/style.scss +36 -0
- package/src/components/sidebar/post-url/index.js +51 -0
- package/src/components/sidebar/post-url/style.scss +23 -0
- package/src/components/sidebar/post-visibility/index.js +22 -8
- package/src/components/sidebar/post-visibility/style.scss +5 -4
- package/src/components/sidebar/settings-sidebar/index.js +1 -5
- package/src/components/sidebar/template/style.scss +0 -8
- package/src/components/start-page-options/index.js +48 -28
- package/src/components/start-page-options/style.scss +0 -9
- package/src/components/visual-editor/block-inspector-button.js +4 -8
- package/src/components/visual-editor/index.js +2 -1
- package/src/editor.js +8 -10
- package/src/editor.native.js +5 -6
- package/src/plugins/copy-content-menu-item/index.js +1 -1
- package/src/store/actions.js +322 -295
- package/src/store/selectors.js +21 -24
- package/src/style.scss +3 -2
- package/build/components/sidebar/post-link/index.js +0 -182
- package/build/components/sidebar/post-link/index.js.map +0 -1
- package/build/components/sidebar/template/actions.js +0 -167
- package/build/components/sidebar/template/actions.js.map +0 -1
- package/build/components/sidebar/template/index.js +0 -164
- package/build/components/sidebar/template/index.js.map +0 -1
- package/build-module/components/sidebar/post-link/index.js +0 -165
- package/build-module/components/sidebar/post-link/index.js.map +0 -1
- package/build-module/components/sidebar/template/actions.js +0 -153
- package/build-module/components/sidebar/template/actions.js.map +0 -1
- package/build-module/components/sidebar/template/index.js +0 -145
- package/build-module/components/sidebar/template/index.js.map +0 -1
- package/src/components/sidebar/post-link/index.js +0 -180
- package/src/components/sidebar/post-link/style.scss +0 -20
- package/src/components/sidebar/template/actions.js +0 -203
- package/src/components/sidebar/template/index.js +0 -164
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-format/index.js"],"names":["PanelRow","PostFormat","PostFormatForm","PostFormatCheck"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SACCC,UAAU,IAAIC,cADf,EAECC,eAFD,QAGO,mBAHP;AAKA,OAAO,SAASF,UAAT,GAAsB;AAC5B,SACC,cAAC,eAAD,QACC,cAAC,QAAD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-format/index.js"],"names":["PanelRow","PostFormat","PostFormatForm","PostFormatCheck"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SACCC,UAAU,IAAIC,cADf,EAECC,eAFD,QAGO,mBAHP;AAKA,OAAO,SAASF,UAAT,GAAsB;AAC5B,SACC,cAAC,eAAD,QACC,cAAC,QAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,cAAC,cAAD,OADD,CADD,CADD;AAOA;AAED,eAAeA,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelRow } from '@wordpress/components';\nimport {\n\tPostFormat as PostFormatForm,\n\tPostFormatCheck,\n} from '@wordpress/editor';\n\nexport function PostFormat() {\n\treturn (\n\t\t<PostFormatCheck>\n\t\t\t<PanelRow className=\"edit-post-post-format\">\n\t\t\t\t<PostFormatForm />\n\t\t\t</PanelRow>\n\t\t</PostFormatCheck>\n\t);\n}\n\nexport default PostFormat;\n"]}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { createElement
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
7
|
import { PanelRow, Dropdown, Button } from '@wordpress/components';
|
|
8
8
|
import { useRef } from '@wordpress/element';
|
|
9
|
-
import { PostSchedule as PostScheduleForm,
|
|
10
|
-
export function PostSchedule() {
|
|
9
|
+
import { PostSchedule as PostScheduleForm, PostScheduleCheck, usePostScheduleLabel } from '@wordpress/editor';
|
|
10
|
+
export default function PostSchedule() {
|
|
11
11
|
const anchorRef = useRef();
|
|
12
12
|
return createElement(PostScheduleCheck, null, createElement(PanelRow, {
|
|
13
13
|
className: "edit-post-post-schedule",
|
|
@@ -18,17 +18,16 @@ export function PostSchedule() {
|
|
|
18
18
|
},
|
|
19
19
|
position: "bottom left",
|
|
20
20
|
contentClassName: "edit-post-post-schedule__dialog",
|
|
21
|
+
focusOnMount: true,
|
|
21
22
|
renderToggle: _ref => {
|
|
22
23
|
let {
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
isOpen,
|
|
25
|
+
onToggle
|
|
25
26
|
} = _ref;
|
|
26
|
-
return createElement(
|
|
27
|
-
|
|
28
|
-
onClick: onToggle
|
|
29
|
-
|
|
30
|
-
variant: "tertiary"
|
|
31
|
-
}, createElement(PostScheduleLabel, null)));
|
|
27
|
+
return createElement(PostScheduleToggle, {
|
|
28
|
+
isOpen: isOpen,
|
|
29
|
+
onClick: onToggle
|
|
30
|
+
});
|
|
32
31
|
},
|
|
33
32
|
renderContent: _ref2 => {
|
|
34
33
|
let {
|
|
@@ -40,5 +39,25 @@ export function PostSchedule() {
|
|
|
40
39
|
}
|
|
41
40
|
})));
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
|
|
43
|
+
function PostScheduleToggle(_ref3) {
|
|
44
|
+
let {
|
|
45
|
+
isOpen,
|
|
46
|
+
onClick
|
|
47
|
+
} = _ref3;
|
|
48
|
+
const label = usePostScheduleLabel();
|
|
49
|
+
const fullLabel = usePostScheduleLabel({
|
|
50
|
+
full: true
|
|
51
|
+
});
|
|
52
|
+
return createElement(Button, {
|
|
53
|
+
className: "edit-post-post-schedule__toggle",
|
|
54
|
+
variant: "tertiary",
|
|
55
|
+
label: fullLabel,
|
|
56
|
+
showTooltip: true,
|
|
57
|
+
"aria-expanded": isOpen // translators: %s: Current post date.
|
|
58
|
+
,
|
|
59
|
+
"aria-label": sprintf(__('Change date: %s'), label),
|
|
60
|
+
onClick: onClick
|
|
61
|
+
}, label);
|
|
62
|
+
}
|
|
44
63
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-schedule/index.js"],"names":["__","PanelRow","Dropdown","Button","useRef","PostSchedule","PostScheduleForm","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-schedule/index.js"],"names":["__","sprintf","PanelRow","Dropdown","Button","useRef","PostSchedule","PostScheduleForm","PostScheduleCheck","usePostScheduleLabel","anchorRef","isOpen","onToggle","onClose","PostScheduleToggle","onClick","label","fullLabel","full"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SACCC,YAAY,IAAIC,gBADjB,EAECC,iBAFD,EAGCC,oBAHD,QAIO,mBAJP;AAMA,eAAe,SAASH,YAAT,GAAwB;AACtC,QAAMI,SAAS,GAAGL,MAAM,EAAxB;AACA,SACC,cAAC,iBAAD,QACC,cAAC,QAAD;AAAU,IAAA,SAAS,EAAC,yBAApB;AAA8C,IAAA,GAAG,EAAGK;AAApD,KACC,4BAAQV,EAAE,CAAE,SAAF,CAAV,CADD,EAEC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AAAEU,MAAAA;AAAF,KADhB;AAEC,IAAA,QAAQ,EAAC,aAFV;AAGC,IAAA,gBAAgB,EAAC,iCAHlB;AAIC,IAAA,YAAY,MAJb;AAKC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,kBAAD;AACC,QAAA,MAAM,EAAGD,MADV;AAEC,QAAA,OAAO,EAAGC;AAFX,QADc;AAAA,KALhB;AAWC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,cAAC,gBAAD;AAAkB,QAAA,OAAO,EAAGA;AAA5B,QADe;AAAA;AAXjB,IAFD,CADD,CADD;AAsBA;;AAED,SAASC,kBAAT,QAAmD;AAAA,MAAtB;AAAEH,IAAAA,MAAF;AAAUI,IAAAA;AAAV,GAAsB;AAClD,QAAMC,KAAK,GAAGP,oBAAoB,EAAlC;AACA,QAAMQ,SAAS,GAAGR,oBAAoB,CAAE;AAAES,IAAAA,IAAI,EAAE;AAAR,GAAF,CAAtC;AACA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,IAAA,KAAK,EAAGD,SAHT;AAIC,IAAA,WAAW,MAJZ;AAKC,qBAAgBN,MALjB,CAMC;AAND;AAOC,kBAAaV,OAAO,CAAED,EAAE,CAAE,iBAAF,CAAJ,EAA2BgB,KAA3B,CAPrB;AAQC,IAAA,OAAO,EAAGD;AARX,KAUGC,KAVH,CADD;AAcA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport { useRef } from '@wordpress/element';\nimport {\n\tPostSchedule as PostScheduleForm,\n\tPostScheduleCheck,\n\tusePostScheduleLabel,\n} from '@wordpress/editor';\n\nexport default function PostSchedule() {\n\tconst anchorRef = useRef();\n\treturn (\n\t\t<PostScheduleCheck>\n\t\t\t<PanelRow className=\"edit-post-post-schedule\" ref={ anchorRef }>\n\t\t\t\t<span>{ __( 'Publish' ) }</span>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ { anchorRef } }\n\t\t\t\t\tposition=\"bottom left\"\n\t\t\t\t\tcontentClassName=\"edit-post-post-schedule__dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostScheduleToggle\n\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostScheduleForm onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PanelRow>\n\t\t</PostScheduleCheck>\n\t);\n}\n\nfunction PostScheduleToggle( { isOpen, onClick } ) {\n\tconst label = usePostScheduleLabel();\n\tconst fullLabel = usePostScheduleLabel( { full: true } );\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-schedule__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\tlabel={ fullLabel }\n\t\t\tshowTooltip\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post date.\n\t\t\taria-label={ sprintf( __( 'Change date: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -6,7 +6,9 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
import { PanelRow } from '@wordpress/components';
|
|
7
7
|
import { PostSlug as PostSlugForm, PostSlugCheck } from '@wordpress/editor';
|
|
8
8
|
export function PostSlug() {
|
|
9
|
-
return createElement(PostSlugCheck, null, createElement(PanelRow,
|
|
9
|
+
return createElement(PostSlugCheck, null, createElement(PanelRow, {
|
|
10
|
+
className: "edit-post-post-slug"
|
|
11
|
+
}, createElement(PostSlugForm, null)));
|
|
10
12
|
}
|
|
11
13
|
export default PostSlug;
|
|
12
14
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-slug/index.js"],"names":["PanelRow","PostSlug","PostSlugForm","PostSlugCheck"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,QAAQ,IAAIC,YAArB,EAAmCC,aAAnC,QAAwD,mBAAxD;AAEA,OAAO,SAASF,QAAT,GAAoB;AAC1B,SACC,cAAC,aAAD,QACC,cAAC,QAAD,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-slug/index.js"],"names":["PanelRow","PostSlug","PostSlugForm","PostSlugCheck"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,uBAAzB;AACA,SAASC,QAAQ,IAAIC,YAArB,EAAmCC,aAAnC,QAAwD,mBAAxD;AAEA,OAAO,SAASF,QAAT,GAAoB;AAC1B,SACC,cAAC,aAAD,QACC,cAAC,QAAD;AAAU,IAAA,SAAS,EAAC;AAApB,KACC,cAAC,YAAD,OADD,CADD,CADD;AAOA;AAED,eAAeA,QAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { PanelRow } from '@wordpress/components';\nimport { PostSlug as PostSlugForm, PostSlugCheck } from '@wordpress/editor';\n\nexport function PostSlug() {\n\treturn (\n\t\t<PostSlugCheck>\n\t\t\t<PanelRow className=\"edit-post-post-slug\">\n\t\t\t\t<PostSlugForm />\n\t\t\t</PanelRow>\n\t\t</PostSlugCheck>\n\t);\n}\n\nexport default PostSlug;\n"]}
|
|
@@ -21,6 +21,8 @@ import PostFormat from '../post-format';
|
|
|
21
21
|
import PostPendingStatus from '../post-pending-status';
|
|
22
22
|
import PluginPostStatusInfo from '../plugin-post-status-info';
|
|
23
23
|
import { store as editPostStore } from '../../../store';
|
|
24
|
+
import PostTemplate from '../post-template';
|
|
25
|
+
import PostURL from '../post-url';
|
|
24
26
|
/**
|
|
25
27
|
* Module Constants
|
|
26
28
|
*/
|
|
@@ -34,10 +36,10 @@ function PostStatus(_ref) {
|
|
|
34
36
|
} = _ref;
|
|
35
37
|
return createElement(PanelBody, {
|
|
36
38
|
className: "edit-post-post-status",
|
|
37
|
-
title: __('
|
|
39
|
+
title: __('Summary'),
|
|
38
40
|
opened: isOpened,
|
|
39
41
|
onToggle: onTogglePanel
|
|
40
|
-
}, createElement(PluginPostStatusInfo.Slot, null, fills => createElement(Fragment, null, createElement(PostVisibility, null), createElement(PostSchedule, null), createElement(
|
|
42
|
+
}, createElement(PluginPostStatusInfo.Slot, null, fills => createElement(Fragment, null, createElement(PostVisibility, null), createElement(PostSchedule, null), createElement(PostURL, null), createElement(PostTemplate, null), createElement(PostSticky, null), createElement(PostPendingStatus, null), createElement(PostFormat, null), createElement(PostSlug, null), createElement(PostAuthor, null), fills, createElement(PostTrash, null))));
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export default compose([withSelect(select => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-status/index.js"],"names":["__","PanelBody","withSelect","withDispatch","compose","ifCondition","PostVisibility","PostTrash","PostSchedule","PostSticky","PostAuthor","PostSlug","PostFormat","PostPendingStatus","PluginPostStatusInfo","store","editPostStore","PANEL_NAME","PostStatus","isOpened","onTogglePanel","fills","select","isEditorPanelRemoved","isEditorPanelOpened","isRemoved","dispatch","toggleEditorPanelOpened"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,uBAA1B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,gBAAvC;AAEA;AACA;AACA;;AACA,MAAMC,UAAU,GAAG,aAAnB;;AAEA,SAASC,UAAT,OAAmD;AAAA,MAA9B;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GAA8B;AAClD,SACC,cAAC,SAAD;AACC,IAAA,SAAS,EAAC,uBADX;AAEC,IAAA,KAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-status/index.js"],"names":["__","PanelBody","withSelect","withDispatch","compose","ifCondition","PostVisibility","PostTrash","PostSchedule","PostSticky","PostAuthor","PostSlug","PostFormat","PostPendingStatus","PluginPostStatusInfo","store","editPostStore","PostTemplate","PostURL","PANEL_NAME","PostStatus","isOpened","onTogglePanel","fills","select","isEditorPanelRemoved","isEditorPanelOpened","isRemoved","dispatch","toggleEditorPanelOpened"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,uBAA1B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,iBAAzC;AACA,SAASC,OAAT,EAAkBC,WAAlB,QAAqC,oBAArC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,QAAP,MAAqB,cAArB;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,oBAAP,MAAiC,4BAAjC;AACA,SAASC,KAAK,I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A0Ba,uBAA1B,CACNV,UADM,CAAP;AAGA;;AAL8B,CAAlB,CAAF,CAZW,CAAF,CAAP,CAmBVC,UAnBU,CAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelBody } from '@wordpress/components';\nimport { withSelect, withDispatch } from '@wordpress/data';\nimport { compose, ifCondition } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport PostVisibility from '../post-visibility';\nimport PostTrash from '../post-trash';\nimport PostSchedule from '../post-schedule';\nimport PostSticky from '../post-sticky';\nimport PostAuthor from '../post-author';\nimport PostSlug from '../post-slug';\nimport PostFormat from '../post-format';\nimport PostPendingStatus from '../post-pending-status';\nimport PluginPostStatusInfo from '../plugin-post-status-info';\nimport { store as editPostStore } from '../../../store';\nimport PostTemplate from '../post-template';\nimport PostURL from '../post-url';\n\n/**\n * Module Constants\n */\nconst PANEL_NAME = 'post-status';\n\nfunction PostStatus( { isOpened, onTogglePanel } ) {\n\treturn (\n\t\t<PanelBody\n\t\t\tclassName=\"edit-post-post-status\"\n\t\t\ttitle={ __( 'Summary' ) }\n\t\t\topened={ isOpened }\n\t\t\tonToggle={ onTogglePanel }\n\t\t>\n\t\t\t<PluginPostStatusInfo.Slot>\n\t\t\t\t{ ( fills ) => (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PostVisibility />\n\t\t\t\t\t\t<PostSchedule />\n\t\t\t\t\t\t<PostURL />\n\t\t\t\t\t\t<PostTemplate />\n\t\t\t\t\t\t<PostSticky />\n\t\t\t\t\t\t<PostPendingStatus />\n\t\t\t\t\t\t<PostFormat />\n\t\t\t\t\t\t<PostSlug />\n\t\t\t\t\t\t<PostAuthor />\n\t\t\t\t\t\t{ fills }\n\t\t\t\t\t\t<PostTrash />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</PluginPostStatusInfo.Slot>\n\t\t</PanelBody>\n\t);\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\t// We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do\n\t\t// not use isEditorPanelEnabled since this panel should not be disabled through the UI.\n\t\tconst { isEditorPanelRemoved, isEditorPanelOpened } =\n\t\t\tselect( editPostStore );\n\t\treturn {\n\t\t\tisRemoved: isEditorPanelRemoved( PANEL_NAME ),\n\t\t\tisOpened: isEditorPanelOpened( PANEL_NAME ),\n\t\t};\n\t} ),\n\tifCondition( ( { isRemoved } ) => ! isRemoved ),\n\twithDispatch( ( dispatch ) => ( {\n\t\tonTogglePanel() {\n\t\t\treturn dispatch( editPostStore ).toggleEditorPanelOpened(\n\t\t\t\tPANEL_NAME\n\t\t\t);\n\t\t},\n\t} ) ),\n] )( PostStatus );\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
9
|
+
import { serialize, createBlock } from '@wordpress/blocks';
|
|
10
|
+
import { Modal, Flex, FlexItem, TextControl, Button } from '@wordpress/components';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import { cleanForSlug } from '@wordpress/url';
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { store as editPostStore } from '../../../store';
|
|
18
|
+
|
|
19
|
+
const DEFAULT_TITLE = __('Custom Template');
|
|
20
|
+
|
|
21
|
+
export default function PostTemplateCreateModal(_ref) {
|
|
22
|
+
let {
|
|
23
|
+
onClose
|
|
24
|
+
} = _ref;
|
|
25
|
+
const defaultBlockTemplate = useSelect(select => select(editorStore).getEditorSettings().defaultBlockTemplate, []);
|
|
26
|
+
const {
|
|
27
|
+
__unstableCreateTemplate,
|
|
28
|
+
__unstableSwitchToTemplateMode
|
|
29
|
+
} = useDispatch(editPostStore);
|
|
30
|
+
const [title, setTitle] = useState('');
|
|
31
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
32
|
+
|
|
33
|
+
const cancel = () => {
|
|
34
|
+
setTitle('');
|
|
35
|
+
onClose();
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const submit = async event => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
|
|
41
|
+
if (isBusy) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setIsBusy(true);
|
|
46
|
+
const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : serialize([createBlock('core/group', {
|
|
47
|
+
tagName: 'header',
|
|
48
|
+
layout: {
|
|
49
|
+
inherit: true
|
|
50
|
+
}
|
|
51
|
+
}, [createBlock('core/site-title'), createBlock('core/site-tagline')]), createBlock('core/separator'), createBlock('core/group', {
|
|
52
|
+
tagName: 'main'
|
|
53
|
+
}, [createBlock('core/group', {
|
|
54
|
+
layout: {
|
|
55
|
+
inherit: true
|
|
56
|
+
}
|
|
57
|
+
}, [createBlock('core/post-title')]), createBlock('core/post-content', {
|
|
58
|
+
layout: {
|
|
59
|
+
inherit: true
|
|
60
|
+
}
|
|
61
|
+
})])]);
|
|
62
|
+
await __unstableCreateTemplate({
|
|
63
|
+
slug: cleanForSlug(title || DEFAULT_TITLE),
|
|
64
|
+
content: newTemplateContent,
|
|
65
|
+
title: title || DEFAULT_TITLE
|
|
66
|
+
});
|
|
67
|
+
setIsBusy(false);
|
|
68
|
+
cancel();
|
|
69
|
+
|
|
70
|
+
__unstableSwitchToTemplateMode(true);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return createElement(Modal, {
|
|
74
|
+
title: __('Create custom template'),
|
|
75
|
+
closeLabel: __('Close'),
|
|
76
|
+
onRequestClose: cancel,
|
|
77
|
+
className: "edit-post-post-template__create-modal"
|
|
78
|
+
}, createElement("form", {
|
|
79
|
+
className: "edit-post-post-template__create-form",
|
|
80
|
+
onSubmit: submit
|
|
81
|
+
}, createElement(Flex, {
|
|
82
|
+
align: "flex-start",
|
|
83
|
+
gap: 8
|
|
84
|
+
}, createElement(FlexItem, null, createElement(TextControl, {
|
|
85
|
+
label: __('Name'),
|
|
86
|
+
value: title,
|
|
87
|
+
onChange: setTitle,
|
|
88
|
+
placeholder: DEFAULT_TITLE,
|
|
89
|
+
disabled: isBusy,
|
|
90
|
+
help: __('Describe the template, e.g. "Post with sidebar". Custom templates can be applied to any post or page.')
|
|
91
|
+
}))), createElement(Flex, {
|
|
92
|
+
justify: "flex-end",
|
|
93
|
+
expanded: false
|
|
94
|
+
}, createElement(FlexItem, null, createElement(Button, {
|
|
95
|
+
variant: "tertiary",
|
|
96
|
+
onClick: cancel
|
|
97
|
+
}, __('Cancel'))), createElement(FlexItem, null, createElement(Button, {
|
|
98
|
+
variant: "primary",
|
|
99
|
+
type: "submit",
|
|
100
|
+
isBusy: isBusy,
|
|
101
|
+
"aria-disabled": isBusy
|
|
102
|
+
}, __('Create'))))));
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=create-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-template/create-modal.js"],"names":["useSelect","useDispatch","store","editorStore","useState","serialize","createBlock","Modal","Flex","FlexItem","TextControl","Button","__","cleanForSlug","editPostStore","DEFAULT_TITLE","PostTemplateCreateModal","onClose","defaultBlockTemplate","select","getEditorSettings","__unstableCreateTemplate","__unstableSwitchToTemplateMode","title","setTitle","isBusy","setIsBusy","cancel","submit","event","preventDefault","newTemplateContent","tagName","layout","inherit","slug","content"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,SA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EAAGC,QAHZ;AAIC,IAAA,WAAW,EAAGT,aAJf;AAKC,IAAA,QAAQ,EAAGU,MALZ;AAMC,IAAA,IAAI,EAAGb,EAAE,CACR,uGADQ;AANV,IADD,CADD,CAJD,EAmBC,cAAC,IAAD;AAAM,IAAA,OAAO,EAAC,UAAd;AAAyB,IAAA,QAAQ,EAAG;AAApC,KACC,cAAC,QAAD,QACC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGe;AAArC,KACGf,EAAE,CAAE,QAAF,CADL,CADD,CADD,EAMC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,MAAM,EAAGa,MAHV;AAIC,qBAAgBA;AAJjB,KAMGb,EAAE,CAAE,QAAF,CANL,CADD,CAND,CAnBD,CAND,CADD;AA8CA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useState } from '@wordpress/element';\nimport { serialize, createBlock } from '@wordpress/blocks';\nimport {\n\tModal,\n\tFlex,\n\tFlexItem,\n\tTextControl,\n\tButton,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { cleanForSlug } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\n\nconst DEFAULT_TITLE = __( 'Custom Template' );\n\nexport default function PostTemplateCreateModal( { onClose } ) {\n\tconst defaultBlockTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getEditorSettings().defaultBlockTemplate,\n\t\t[]\n\t);\n\n\tconst { __unstableCreateTemplate, __unstableSwitchToTemplateMode } =\n\t\tuseDispatch( editPostStore );\n\n\tconst [ title, setTitle ] = useState( '' );\n\n\tconst [ isBusy, setIsBusy ] = useState( false );\n\n\tconst cancel = () => {\n\t\tsetTitle( '' );\n\t\tonClose();\n\t};\n\n\tconst submit = async ( event ) => {\n\t\tevent.preventDefault();\n\n\t\tif ( isBusy ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetIsBusy( true );\n\n\t\tconst newTemplateContent =\n\t\t\tdefaultBlockTemplate ??\n\t\t\tserialize( [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'header',\n\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock( 'core/site-title' ),\n\t\t\t\t\t\tcreateBlock( 'core/site-tagline' ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t\tcreateBlock( 'core/separator' ),\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\ttagName: 'main',\n\t\t\t\t\t},\n\t\t\t\t\t[\n\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t'core/group',\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t[ createBlock( 'core/post-title' ) ]\n\t\t\t\t\t\t),\n\t\t\t\t\t\tcreateBlock( 'core/post-content', {\n\t\t\t\t\t\t\tlayout: { inherit: true },\n\t\t\t\t\t\t} ),\n\t\t\t\t\t]\n\t\t\t\t),\n\t\t\t] );\n\n\t\tawait __unstableCreateTemplate( {\n\t\t\tslug: cleanForSlug( title || DEFAULT_TITLE ),\n\t\t\tcontent: newTemplateContent,\n\t\t\ttitle: title || DEFAULT_TITLE,\n\t\t} );\n\n\t\tsetIsBusy( false );\n\t\tcancel();\n\n\t\t__unstableSwitchToTemplateMode( true );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ __( 'Create custom template' ) }\n\t\t\tcloseLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ cancel }\n\t\t\tclassName=\"edit-post-post-template__create-modal\"\n\t\t>\n\t\t\t<form\n\t\t\t\tclassName=\"edit-post-post-template__create-form\"\n\t\t\t\tonSubmit={ submit }\n\t\t\t>\n\t\t\t\t<Flex align=\"flex-start\" gap={ 8 }>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t\tplaceholder={ DEFAULT_TITLE }\n\t\t\t\t\t\t\tdisabled={ isBusy }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'Describe the template, e.g. \"Post with sidebar\". Custom templates can be applied to any post or page.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\n\t\t\t\t<Flex justify=\"flex-end\" expanded={ false }>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button variant=\"tertiary\" onClick={ cancel }>\n\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tisBusy={ isBusy }\n\t\t\t\t\t\t\taria-disabled={ isBusy }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState, useMemo } from '@wordpress/element';
|
|
7
|
+
import { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';
|
|
8
|
+
import { __ } from '@wordpress/i18n';
|
|
9
|
+
import { addTemplate } from '@wordpress/icons';
|
|
10
|
+
import { Notice, SelectControl, Button } from '@wordpress/components';
|
|
11
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
12
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
13
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { store as editPostStore } from '../../../store';
|
|
19
|
+
import PostTemplateCreateModal from './create-modal';
|
|
20
|
+
export default function PostTemplateForm(_ref) {
|
|
21
|
+
var _options$find, _selectedOption$value;
|
|
22
|
+
|
|
23
|
+
let {
|
|
24
|
+
onClose
|
|
25
|
+
} = _ref;
|
|
26
|
+
const {
|
|
27
|
+
isPostsPage,
|
|
28
|
+
availableTemplates,
|
|
29
|
+
fetchedTemplates,
|
|
30
|
+
selectedTemplateSlug,
|
|
31
|
+
canCreate,
|
|
32
|
+
canEdit
|
|
33
|
+
} = useSelect(select => {
|
|
34
|
+
const editorSettings = select(editorStore).getEditorSettings();
|
|
35
|
+
const siteSettings = select(coreStore).getEntityRecord('root', 'site');
|
|
36
|
+
|
|
37
|
+
const _isPostsPage = select(editorStore).getCurrentPostId() === (siteSettings === null || siteSettings === void 0 ? void 0 : siteSettings.page_for_posts);
|
|
38
|
+
|
|
39
|
+
const canCreateTemplates = select(coreStore).canUser('create', 'templates');
|
|
40
|
+
return {
|
|
41
|
+
isPostsPage: _isPostsPage,
|
|
42
|
+
availableTemplates: editorSettings.availableTemplates,
|
|
43
|
+
fetchedTemplates: select(coreStore).getEntityRecords('postType', 'wp_template', {
|
|
44
|
+
post_type: select(editorStore).getCurrentPostType(),
|
|
45
|
+
per_page: -1
|
|
46
|
+
}),
|
|
47
|
+
selectedTemplateSlug: select(editorStore).getEditedPostAttribute('template'),
|
|
48
|
+
canCreate: canCreateTemplates && !_isPostsPage && editorSettings.supportsTemplateMode,
|
|
49
|
+
canEdit: canCreateTemplates && editorSettings.supportsTemplateMode && !!select(editPostStore).getEditedPostTemplate()
|
|
50
|
+
};
|
|
51
|
+
}, []);
|
|
52
|
+
const options = useMemo(() => Object.entries({ ...availableTemplates,
|
|
53
|
+
...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(_ref2 => {
|
|
54
|
+
let {
|
|
55
|
+
slug,
|
|
56
|
+
title
|
|
57
|
+
} = _ref2;
|
|
58
|
+
return [slug, title.rendered];
|
|
59
|
+
}))
|
|
60
|
+
}).map(_ref3 => {
|
|
61
|
+
let [slug, title] = _ref3;
|
|
62
|
+
return {
|
|
63
|
+
value: slug,
|
|
64
|
+
label: title
|
|
65
|
+
};
|
|
66
|
+
}), [availableTemplates, fetchedTemplates]);
|
|
67
|
+
const selectedOption = (_options$find = options.find(option => option.value === selectedTemplateSlug)) !== null && _options$find !== void 0 ? _options$find : options.find(option => !option.value); // The default option has '' value.
|
|
68
|
+
|
|
69
|
+
const {
|
|
70
|
+
editPost
|
|
71
|
+
} = useDispatch(editorStore);
|
|
72
|
+
const {
|
|
73
|
+
__unstableSwitchToTemplateMode
|
|
74
|
+
} = useDispatch(editPostStore);
|
|
75
|
+
const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
|
|
76
|
+
return createElement("div", {
|
|
77
|
+
className: "edit-post-post-template__form"
|
|
78
|
+
}, createElement(InspectorPopoverHeader, {
|
|
79
|
+
title: __('Template'),
|
|
80
|
+
help: __('Templates define the way content is displayed when viewing your site.'),
|
|
81
|
+
actions: canCreate ? [{
|
|
82
|
+
icon: addTemplate,
|
|
83
|
+
label: __('Add template'),
|
|
84
|
+
onClick: () => setIsCreateModalOpen(true)
|
|
85
|
+
}] : [],
|
|
86
|
+
onClose: onClose
|
|
87
|
+
}), isPostsPage ? createElement(Notice, {
|
|
88
|
+
className: "edit-post-post-template__notice",
|
|
89
|
+
status: "warning",
|
|
90
|
+
isDismissible: false
|
|
91
|
+
}, __('The posts page template cannot be changed.')) : createElement(SelectControl, {
|
|
92
|
+
hideLabelFromVision: true,
|
|
93
|
+
label: __('Template'),
|
|
94
|
+
value: (_selectedOption$value = selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
|
|
95
|
+
options: options,
|
|
96
|
+
onChange: slug => editPost({
|
|
97
|
+
template: slug || ''
|
|
98
|
+
})
|
|
99
|
+
}), canEdit && createElement("p", null, createElement(Button, {
|
|
100
|
+
variant: "link",
|
|
101
|
+
onClick: () => __unstableSwitchToTemplateMode()
|
|
102
|
+
}, __('Edit template'))), isCreateModalOpen && createElement(PostTemplateCreateModal, {
|
|
103
|
+
onClose: () => setIsCreateModalOpen(false)
|
|
104
|
+
}));
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=form.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-template/form.js"],"names":["useState","useMemo","__experimentalInspectorPopoverHeader","InspectorPopoverHeader","__","addTemplate","Notice","SelectControl","Button","useSelect","useDispatch","store","editorStore","coreStore","editPostStore","PostTemplateCreateModal","PostTemplateForm","onClose","isPostsPage","availableTemplates","fetchedTemplates","selectedTemplateSlug","canCreate","canEdit","select","editorSettings","getEditorSettings","siteSettings","getEntityRecord","_isPostsPage","getCurrentPostId","page_for_posts","canCreateTemplates","canUser","getEntityRecords","post_type","getCurrentPostType","per_page","getEditedPostAttribute","supportsTemplateMode","getEditedPostTemplate","options","Object","entries","fromEntries","map","slug","title","rendered","value","label","selectedOption","find","option","editPost","__unstableSwitchToTemplateMode","isCreateModalOpen","setIsCreateModalOpen","icon","onClick","template"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,EAAmBC,OAAnB,QAAkC,oBAAlC;AACA,SAASC,oCAAoC,IAAIC,sBAA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EC,IAAA,OAAO,EAAG,MAAMgC,8BAA8B;AAF/C,KAIGnD,EAAE,CAAE,eAAF,CAJL,CADD,CAvCF,EAgDGoD,iBAAiB,IAClB,cAAC,uBAAD;AACC,IAAA,OAAO,EAAG,MAAMC,oBAAoB,CAAE,KAAF;AADrC,IAjDF,CADD;AAwDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useMemo } from '@wordpress/element';\nimport { __experimentalInspectorPopoverHeader as InspectorPopoverHeader } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { addTemplate } from '@wordpress/icons';\nimport { Notice, SelectControl, Button } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../../store';\nimport PostTemplateCreateModal from './create-modal';\n\nexport default function PostTemplateForm( { onClose } ) {\n\tconst {\n\t\tisPostsPage,\n\t\tavailableTemplates,\n\t\tfetchedTemplates,\n\t\tselectedTemplateSlug,\n\t\tcanCreate,\n\t\tcanEdit,\n\t} = useSelect( ( select ) => {\n\t\tconst editorSettings = select( editorStore ).getEditorSettings();\n\t\tconst siteSettings = select( coreStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'site'\n\t\t);\n\t\tconst _isPostsPage =\n\t\t\tselect( editorStore ).getCurrentPostId() ===\n\t\t\tsiteSettings?.page_for_posts;\n\t\tconst canCreateTemplates = select( coreStore ).canUser(\n\t\t\t'create',\n\t\t\t'templates'\n\t\t);\n\t\treturn {\n\t\t\tisPostsPage: _isPostsPage,\n\t\t\tavailableTemplates: editorSettings.availableTemplates,\n\t\t\tfetchedTemplates: select( coreStore ).getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template',\n\t\t\t\t{\n\t\t\t\t\tpost_type: select( editorStore ).getCurrentPostType(),\n\t\t\t\t\tper_page: -1,\n\t\t\t\t}\n\t\t\t),\n\t\t\tselectedTemplateSlug:\n\t\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' ),\n\t\t\tcanCreate:\n\t\t\t\tcanCreateTemplates &&\n\t\t\t\t! _isPostsPage &&\n\t\t\t\teditorSettings.supportsTemplateMode,\n\t\t\tcanEdit:\n\t\t\t\tcanCreateTemplates &&\n\t\t\t\teditorSettings.supportsTemplateMode &&\n\t\t\t\t!! select( editPostStore ).getEditedPostTemplate(),\n\t\t};\n\t}, [] );\n\n\tconst options = useMemo(\n\t\t() =>\n\t\t\tObject.entries( {\n\t\t\t\t...availableTemplates,\n\t\t\t\t...Object.fromEntries(\n\t\t\t\t\t( fetchedTemplates ?? [] ).map( ( { slug, title } ) => [\n\t\t\t\t\t\tslug,\n\t\t\t\t\t\ttitle.rendered,\n\t\t\t\t\t] )\n\t\t\t\t),\n\t\t\t} ).map( ( [ slug, title ] ) => ( { value: slug, label: title } ) ),\n\t\t[ availableTemplates, fetchedTemplates ]\n\t);\n\n\tconst selectedOption =\n\t\toptions.find( ( option ) => option.value === selectedTemplateSlug ) ??\n\t\toptions.find( ( option ) => ! option.value ); // The default option has '' value.\n\n\tconst { editPost } = useDispatch( editorStore );\n\tconst { __unstableSwitchToTemplateMode } = useDispatch( editPostStore );\n\n\tconst [ isCreateModalOpen, setIsCreateModalOpen ] = useState( false );\n\n\treturn (\n\t\t<div className=\"edit-post-post-template__form\">\n\t\t\t<InspectorPopoverHeader\n\t\t\t\ttitle={ __( 'Template' ) }\n\t\t\t\thelp={ __(\n\t\t\t\t\t'Templates define the way content is displayed when viewing your site.'\n\t\t\t\t) }\n\t\t\t\tactions={\n\t\t\t\t\tcanCreate\n\t\t\t\t\t\t? [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\ticon: addTemplate,\n\t\t\t\t\t\t\t\t\tlabel: __( 'Add template' ),\n\t\t\t\t\t\t\t\t\tonClick: () => setIsCreateModalOpen( true ),\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t ]\n\t\t\t\t\t\t: []\n\t\t\t\t}\n\t\t\t\tonClose={ onClose }\n\t\t\t/>\n\t\t\t{ isPostsPage ? (\n\t\t\t\t<Notice\n\t\t\t\t\tclassName=\"edit-post-post-template__notice\"\n\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\tisDismissible={ false }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'The posts page template cannot be changed.' ) }\n\t\t\t\t</Notice>\n\t\t\t) : (\n\t\t\t\t<SelectControl\n\t\t\t\t\thideLabelFromVision\n\t\t\t\t\tlabel={ __( 'Template' ) }\n\t\t\t\t\tvalue={ selectedOption?.value ?? '' }\n\t\t\t\t\toptions={ options }\n\t\t\t\t\tonChange={ ( slug ) =>\n\t\t\t\t\t\teditPost( { template: slug || '' } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ canEdit && (\n\t\t\t\t<p>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t\tonClick={ () => __unstableSwitchToTemplateMode() }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Edit template' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</p>\n\t\t\t) }\n\t\t\t{ isCreateModalOpen && (\n\t\t\t\t<PostTemplateCreateModal\n\t\t\t\t\tonClose={ () => setIsCreateModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useRef } from '@wordpress/element';
|
|
7
|
+
import { PanelRow, Dropdown, Button } from '@wordpress/components';
|
|
8
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
9
|
+
import { useSelect } from '@wordpress/data';
|
|
10
|
+
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import PostTemplateForm from './form';
|
|
17
|
+
export default function PostTemplate() {
|
|
18
|
+
const anchorRef = useRef();
|
|
19
|
+
const isVisible = useSelect(select => {
|
|
20
|
+
var _select$canUser;
|
|
21
|
+
|
|
22
|
+
const postTypeSlug = select(editorStore).getCurrentPostType();
|
|
23
|
+
const postType = select(coreStore).getPostType(postTypeSlug);
|
|
24
|
+
|
|
25
|
+
if (!(postType !== null && postType !== void 0 && postType.viewable)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const settings = select(editorStore).getEditorSettings();
|
|
30
|
+
const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
|
|
31
|
+
|
|
32
|
+
if (!hasTemplates && !settings.supportsTemplateMode) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
|
|
37
|
+
return canCreateTemplates;
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
if (!isVisible) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return createElement(PanelRow, {
|
|
45
|
+
className: "edit-post-post-template",
|
|
46
|
+
ref: anchorRef
|
|
47
|
+
}, createElement("span", null, __('Template')), createElement(Dropdown, {
|
|
48
|
+
popoverProps: {
|
|
49
|
+
anchorRef
|
|
50
|
+
},
|
|
51
|
+
position: "bottom left",
|
|
52
|
+
className: "edit-post-post-template__dropdown",
|
|
53
|
+
contentClassName: "edit-post-post-template__dialog",
|
|
54
|
+
focusOnMount: true,
|
|
55
|
+
renderToggle: _ref => {
|
|
56
|
+
let {
|
|
57
|
+
isOpen,
|
|
58
|
+
onToggle
|
|
59
|
+
} = _ref;
|
|
60
|
+
return createElement(PostTemplateToggle, {
|
|
61
|
+
isOpen: isOpen,
|
|
62
|
+
onClick: onToggle
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
renderContent: _ref2 => {
|
|
66
|
+
let {
|
|
67
|
+
onClose
|
|
68
|
+
} = _ref2;
|
|
69
|
+
return createElement(PostTemplateForm, {
|
|
70
|
+
onClose: onClose
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function PostTemplateToggle(_ref3) {
|
|
77
|
+
let {
|
|
78
|
+
isOpen,
|
|
79
|
+
onClick
|
|
80
|
+
} = _ref3;
|
|
81
|
+
const templateTitle = useSelect(select => {
|
|
82
|
+
var _select$getEntityReco;
|
|
83
|
+
|
|
84
|
+
const templateSlug = select(editorStore).getEditedPostAttribute('template');
|
|
85
|
+
const settings = select(editorStore).getEditorSettings();
|
|
86
|
+
|
|
87
|
+
if (settings.availableTemplates[templateSlug]) {
|
|
88
|
+
return settings.availableTemplates[templateSlug];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const template = (_select$getEntityReco = select(coreStore).getEntityRecords('postType', 'wp_template', {
|
|
92
|
+
per_page: -1
|
|
93
|
+
})) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.find(_ref4 => {
|
|
94
|
+
let {
|
|
95
|
+
slug
|
|
96
|
+
} = _ref4;
|
|
97
|
+
return slug === templateSlug;
|
|
98
|
+
});
|
|
99
|
+
return template === null || template === void 0 ? void 0 : template.title.rendered;
|
|
100
|
+
}, []);
|
|
101
|
+
return createElement(Button, {
|
|
102
|
+
className: "edit-post-post-template__toggle",
|
|
103
|
+
variant: "tertiary",
|
|
104
|
+
"aria-expanded": isOpen,
|
|
105
|
+
"aria-label": templateTitle ? sprintf( // translators: %s: Name of the currently selected template.
|
|
106
|
+
__('Select template: %s'), templateTitle) : __('Select template'),
|
|
107
|
+
onClick: onClick
|
|
108
|
+
}, templateTitle !== null && templateTitle !== void 0 ? templateTitle : __('Default template'));
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-template/index.js"],"names":["useRef","PanelRow","Dropdown","Button","__","sprintf","useSelect","store","editorStore","coreStore","PostTemplateForm","PostTemplate","anchorRef","isVisible","select","postTypeSlug","getCurrentPostType","postType","getPostType","viewable","settings","getEditorSettings","hasTemplates","availableTemplates","Object","keys","length","supportsTemplateMode","canCreateTemplates","canUser","isOpen","onToggle","onClose","PostTemplateToggle","onClick","templateTitle","templateSlug","getEditedPostAttribute","template","getEntityRecords","per_page","find","slug","title","rendered"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,MAA6B,QAA7B;AAEA,eAAe,SAASC,YAAT,GAAwB;AACtC,QAAMC,SAAS,GAAGZ,MAAM,EAAxB;AAEA,QAAMa,SAAS,GAAGP,SAAS,CAAIQ,MAAF,IAAc;AAAA;;AAC1C,UAAMC,YAAY,GAAGD,MAAM,CAAEN,WAAF,CAAN,CAAsBQ,kBAAtB,EAArB;AACA,UAAMC,QAAQ,GAAGH,MAAM,CAAEL,SAAF,CAAN,CAAoBS,WAApB,CAAiCH,YAAjC,CAAjB;;AACA,QAAK,EAAEE,QAAF,aAAEA,QAAF,eAAEA,QAAQ,CAAEE,QAAZ,CAAL,EAA4B;AAC3B,aAAO,KAAP;AACA;;AAED,UAAMC,QAAQ,GAAGN,MAAM,CA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AAUI,IAAAA;AAAV,GAAsB;AAClD,QAAMC,aAAa,GAAG7B,SAAS,CAAIQ,MAAF,IAAc;AAAA;;AAC9C,UAAMsB,YAAY,GACjBtB,MAAM,CAAEN,WAAF,CAAN,CAAsB6B,sBAAtB,CAA8C,UAA9C,CADD;AAGA,UAAMjB,QAAQ,GAAGN,MAAM,CAAEN,WAAF,CAAN,CAAsBa,iBAAtB,EAAjB;;AACA,QAAKD,QAAQ,CAACG,kBAAT,CAA6Ba,YAA7B,CAAL,EAAmD;AAClD,aAAOhB,QAAQ,CAACG,kBAAT,CAA6Ba,YAA7B,CAAP;AACA;;AAED,UAAME,QAAQ,4BAAGxB,MAAM,CAAEL,SAAF,CAAN,CACf8B,gBADe,CACG,UADH,EACe,aADf,EAC8B;AAAEC,MAAAA,QAAQ,EAAE,CAAC;AAAb,KAD9B,CAAH,0DAAG,sBAEdC,IAFc,CAER;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAgBA,IAAI,KAAKN,YAAzB;AAAA,KAFQ,CAAjB;AAIA,WAAOE,QAAP,aAAOA,QAAP,uBAAOA,QAAQ,CAAEK,KAAV,CAAgBC,QAAvB;AACA,GAd8B,EAc5B,EAd4B,CAA/B;AAgBA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iCADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,qBAAgBd,MAHjB;AAIC,kBACCK,aAAa,GACV9B,OAAO,EACP;AACAD,IAAAA,EAAE,CAAE,qBAAF,CAFK,EAGP+B,aAHO,CADG,GAMV/B,EAAE,CAAE,iBAAF,CAXP;AAaC,IAAA,OAAO,EAAG8B;AAbX,KAeGC,aAfH,aAeGA,aAfH,cAeGA,aAfH,GAeoB/B,EAAE,CAAE,kBAAF,CAftB,CADD;AAmBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport PostTemplateForm from './form';\n\nexport default function PostTemplate() {\n\tconst anchorRef = useRef();\n\n\tconst isVisible = useSelect( ( select ) => {\n\t\tconst postTypeSlug = select( editorStore ).getCurrentPostType();\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tif ( ! postType?.viewable ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tconst hasTemplates =\n\t\t\t!! settings.availableTemplates &&\n\t\t\tObject.keys( settings.availableTemplates ).length > 0;\n\t\tif ( ! hasTemplates && ! settings.supportsTemplateMode ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst canCreateTemplates =\n\t\t\tselect( coreStore ).canUser( 'create', 'templates' ) ?? false;\n\t\treturn canCreateTemplates;\n\t}, [] );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelRow className=\"edit-post-post-template\" ref={ anchorRef }>\n\t\t\t<span>{ __( 'Template' ) }</span>\n\t\t\t<Dropdown\n\t\t\t\tpopoverProps={ { anchorRef } }\n\t\t\t\tposition=\"bottom left\"\n\t\t\t\tclassName=\"edit-post-post-template__dropdown\"\n\t\t\t\tcontentClassName=\"edit-post-post-template__dialog\"\n\t\t\t\tfocusOnMount\n\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t<PostTemplateToggle\n\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t<PostTemplateForm onClose={ onClose } />\n\t\t\t\t) }\n\t\t\t/>\n\t\t</PanelRow>\n\t);\n}\n\nfunction PostTemplateToggle( { isOpen, onClick } ) {\n\tconst templateTitle = useSelect( ( select ) => {\n\t\tconst templateSlug =\n\t\t\tselect( editorStore ).getEditedPostAttribute( 'template' );\n\n\t\tconst settings = select( editorStore ).getEditorSettings();\n\t\tif ( settings.availableTemplates[ templateSlug ] ) {\n\t\t\treturn settings.availableTemplates[ templateSlug ];\n\t\t}\n\n\t\tconst template = select( coreStore )\n\t\t\t.getEntityRecords( 'postType', 'wp_template', { per_page: -1 } )\n\t\t\t?.find( ( { slug } ) => slug === templateSlug );\n\n\t\treturn template?.title.rendered;\n\t}, [] );\n\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-template__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\taria-label={\n\t\t\t\ttemplateTitle\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the currently selected template.\n\t\t\t\t\t\t\t__( 'Select template: %s' ),\n\t\t\t\t\t\t\ttemplateTitle\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Select template' )\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ templateTitle ?? __( 'Default template' ) }\n\t\t</Button>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useRef } from '@wordpress/element';
|
|
7
|
+
import { PanelRow, Dropdown, Button } from '@wordpress/components';
|
|
8
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
9
|
+
import { PostURLCheck, PostURL as PostURLForm, usePostURLLabel } from '@wordpress/editor';
|
|
10
|
+
export default function PostURL() {
|
|
11
|
+
const anchorRef = useRef();
|
|
12
|
+
return createElement(PostURLCheck, null, createElement(PanelRow, {
|
|
13
|
+
className: "edit-post-post-url",
|
|
14
|
+
ref: anchorRef
|
|
15
|
+
}, createElement("span", null, __('URL')), createElement(Dropdown, {
|
|
16
|
+
popoverProps: {
|
|
17
|
+
anchorRef
|
|
18
|
+
},
|
|
19
|
+
position: "bottom left",
|
|
20
|
+
className: "edit-post-post-url__dropdown",
|
|
21
|
+
contentClassName: "edit-post-post-url__dialog",
|
|
22
|
+
focusOnMount: true,
|
|
23
|
+
renderToggle: _ref => {
|
|
24
|
+
let {
|
|
25
|
+
isOpen,
|
|
26
|
+
onToggle
|
|
27
|
+
} = _ref;
|
|
28
|
+
return createElement(PostURLToggle, {
|
|
29
|
+
isOpen: isOpen,
|
|
30
|
+
onClick: onToggle
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
renderContent: _ref2 => {
|
|
34
|
+
let {
|
|
35
|
+
onClose
|
|
36
|
+
} = _ref2;
|
|
37
|
+
return createElement(PostURLForm, {
|
|
38
|
+
onClose: onClose
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
})));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function PostURLToggle(_ref3) {
|
|
45
|
+
let {
|
|
46
|
+
isOpen,
|
|
47
|
+
onClick
|
|
48
|
+
} = _ref3;
|
|
49
|
+
const label = usePostURLLabel();
|
|
50
|
+
return createElement(Button, {
|
|
51
|
+
className: "edit-post-post-url__toggle",
|
|
52
|
+
variant: "tertiary",
|
|
53
|
+
"aria-expanded": isOpen // translators: %s: Current post URL.
|
|
54
|
+
,
|
|
55
|
+
"aria-label": sprintf(__('Change URL: %s'), label),
|
|
56
|
+
onClick: onClick
|
|
57
|
+
}, label);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-url/index.js"],"names":["useRef","PanelRow","Dropdown","Button","__","sprintf","PostURLCheck","PostURL","PostURLForm","usePostURLLabel","anchorRef","isOpen","onToggle","onClose","PostURLToggle","onClick","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,S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,CALrB;AAMC,IAAA,OAAO,EAAGD;AANX,KAQGC,KARH,CADD;AAYA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tPostURLCheck,\n\tPostURL as PostURLForm,\n\tusePostURLLabel,\n} from '@wordpress/editor';\n\nexport default function PostURL() {\n\tconst anchorRef = useRef();\n\treturn (\n\t\t<PostURLCheck>\n\t\t\t<PanelRow className=\"edit-post-post-url\" ref={ anchorRef }>\n\t\t\t\t<span>{ __( 'URL' ) }</span>\n\t\t\t\t<Dropdown\n\t\t\t\t\tpopoverProps={ { anchorRef } }\n\t\t\t\t\tposition=\"bottom left\"\n\t\t\t\t\tclassName=\"edit-post-post-url__dropdown\"\n\t\t\t\t\tcontentClassName=\"edit-post-post-url__dialog\"\n\t\t\t\t\tfocusOnMount\n\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t<PostURLToggle isOpen={ isOpen } onClick={ onToggle } />\n\t\t\t\t\t) }\n\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t<PostURLForm onClose={ onClose } />\n\t\t\t\t\t) }\n\t\t\t\t/>\n\t\t\t</PanelRow>\n\t\t</PostURLCheck>\n\t);\n}\n\nfunction PostURLToggle( { isOpen, onClick } ) {\n\tconst label = usePostURLLabel();\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-url__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post URL.\n\t\t\taria-label={ sprintf( __( 'Change URL: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n"]}
|