@wordpress/edit-post 6.8.0 → 6.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/build/components/header/header-toolbar/index.js +7 -6
  4. package/build/components/header/header-toolbar/index.js.map +1 -1
  5. package/build/components/header/template-title/edit-template-title.js +11 -2
  6. package/build/components/header/template-title/edit-template-title.js.map +1 -1
  7. package/build/components/keyboard-shortcut-help-modal/config.js +12 -0
  8. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  9. package/build/components/keyboard-shortcut-help-modal/index.js +1 -3
  10. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  11. package/build/components/preferences-modal/index.js +3 -26
  12. package/build/components/preferences-modal/index.js.map +1 -1
  13. package/build/components/sidebar/plugin-post-status-info/index.js +2 -2
  14. package/build/components/sidebar/plugin-post-status-info/index.js.map +1 -1
  15. package/build/components/sidebar/post-format/index.js +3 -1
  16. package/build/components/sidebar/post-format/index.js.map +1 -1
  17. package/build/components/sidebar/post-schedule/index.js +28 -12
  18. package/build/components/sidebar/post-schedule/index.js.map +1 -1
  19. package/build/components/sidebar/post-slug/index.js +3 -1
  20. package/build/components/sidebar/post-slug/index.js.map +1 -1
  21. package/build/components/sidebar/post-status/index.js +6 -2
  22. package/build/components/sidebar/post-status/index.js.map +1 -1
  23. package/build/components/sidebar/post-template/create-modal.js +116 -0
  24. package/build/components/sidebar/post-template/create-modal.js.map +1 -0
  25. package/build/components/sidebar/post-template/form.js +123 -0
  26. package/build/components/sidebar/post-template/form.js.map +1 -0
  27. package/build/components/sidebar/post-template/index.js +128 -0
  28. package/build/components/sidebar/post-template/index.js.map +1 -0
  29. package/build/components/sidebar/post-url/index.js +68 -0
  30. package/build/components/sidebar/post-url/index.js.map +1 -0
  31. package/build/components/sidebar/post-visibility/index.js +21 -6
  32. package/build/components/sidebar/post-visibility/index.js.map +1 -1
  33. package/build/components/sidebar/settings-sidebar/index.js +2 -6
  34. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  35. package/build/components/start-page-options/index.js +31 -13
  36. package/build/components/start-page-options/index.js.map +1 -1
  37. package/build/components/visual-editor/index.js +4 -2
  38. package/build/components/visual-editor/index.js.map +1 -1
  39. package/build/editor.js +8 -3
  40. package/build/editor.js.map +1 -1
  41. package/build/editor.native.js +1 -1
  42. package/build/editor.native.js.map +1 -1
  43. package/build/store/selectors.js +8 -8
  44. package/build/store/selectors.js.map +1 -1
  45. package/build-module/components/header/header-toolbar/index.js +8 -6
  46. package/build-module/components/header/header-toolbar/index.js.map +1 -1
  47. package/build-module/components/header/template-title/edit-template-title.js +12 -2
  48. package/build-module/components/header/template-title/edit-template-title.js.map +1 -1
  49. package/build-module/components/keyboard-shortcut-help-modal/config.js +12 -0
  50. package/build-module/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  51. package/build-module/components/keyboard-shortcut-help-modal/index.js +1 -2
  52. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  53. package/build-module/components/preferences-modal/index.js +3 -25
  54. package/build-module/components/preferences-modal/index.js.map +1 -1
  55. package/build-module/components/sidebar/plugin-post-status-info/index.js +2 -2
  56. package/build-module/components/sidebar/plugin-post-status-info/index.js.map +1 -1
  57. package/build-module/components/sidebar/post-format/index.js +3 -1
  58. package/build-module/components/sidebar/post-format/index.js.map +1 -1
  59. package/build-module/components/sidebar/post-schedule/index.js +32 -13
  60. package/build-module/components/sidebar/post-schedule/index.js.map +1 -1
  61. package/build-module/components/sidebar/post-slug/index.js +3 -1
  62. package/build-module/components/sidebar/post-slug/index.js.map +1 -1
  63. package/build-module/components/sidebar/post-status/index.js +4 -2
  64. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  65. package/build-module/components/sidebar/post-template/create-modal.js +104 -0
  66. package/build-module/components/sidebar/post-template/create-modal.js.map +1 -0
  67. package/build-module/components/sidebar/post-template/form.js +106 -0
  68. package/build-module/components/sidebar/post-template/form.js.map +1 -0
  69. package/build-module/components/sidebar/post-template/index.js +114 -0
  70. package/build-module/components/sidebar/post-template/index.js.map +1 -0
  71. package/build-module/components/sidebar/post-url/index.js +59 -0
  72. package/build-module/components/sidebar/post-url/index.js.map +1 -0
  73. package/build-module/components/sidebar/post-visibility/index.js +24 -8
  74. package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
  75. package/build-module/components/sidebar/settings-sidebar/index.js +2 -4
  76. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  77. package/build-module/components/start-page-options/index.js +32 -14
  78. package/build-module/components/start-page-options/index.js.map +1 -1
  79. package/build-module/components/visual-editor/index.js +4 -2
  80. package/build-module/components/visual-editor/index.js.map +1 -1
  81. package/build-module/editor.js +9 -4
  82. package/build-module/editor.js.map +1 -1
  83. package/build-module/editor.native.js +2 -2
  84. package/build-module/editor.native.js.map +1 -1
  85. package/build-module/store/selectors.js +8 -7
  86. package/build-module/store/selectors.js.map +1 -1
  87. package/build-style/style-rtl.css +82 -91
  88. package/build-style/style.css +81 -94
  89. package/package.json +27 -27
  90. package/src/components/header/header-toolbar/index.js +10 -10
  91. package/src/components/header/header-toolbar/style.scss +2 -5
  92. package/src/components/header/style.scss +0 -6
  93. package/src/components/header/template-title/edit-template-title.js +11 -1
  94. package/src/components/keyboard-shortcut-help-modal/config.js +8 -0
  95. package/src/components/keyboard-shortcut-help-modal/index.js +1 -2
  96. package/src/components/keyboard-shortcut-help-modal/style.scss +0 -5
  97. package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +14 -0
  98. package/src/components/preferences-modal/index.js +5 -23
  99. package/src/components/preferences-modal/test/index.js +3 -3
  100. package/src/components/sidebar/plugin-post-status-info/index.js +2 -2
  101. package/src/components/sidebar/post-author/style.scss +4 -10
  102. package/src/components/sidebar/post-format/index.js +1 -1
  103. package/src/components/sidebar/post-format/style.scss +5 -0
  104. package/src/components/sidebar/post-schedule/index.js +27 -16
  105. package/src/components/sidebar/post-schedule/style.scss +16 -3
  106. package/src/components/sidebar/post-slug/index.js +1 -1
  107. package/src/components/sidebar/post-slug/style.scss +4 -3
  108. package/src/components/sidebar/post-status/index.js +6 -2
  109. package/src/components/sidebar/post-template/create-modal.js +146 -0
  110. package/src/components/sidebar/post-template/form.js +143 -0
  111. package/src/components/sidebar/post-template/index.js +106 -0
  112. package/src/components/sidebar/post-template/style.scss +36 -0
  113. package/src/components/sidebar/post-url/index.js +51 -0
  114. package/src/components/sidebar/post-url/style.scss +23 -0
  115. package/src/components/sidebar/post-visibility/index.js +22 -8
  116. package/src/components/sidebar/post-visibility/style.scss +4 -4
  117. package/src/components/sidebar/settings-sidebar/index.js +1 -5
  118. package/src/components/sidebar/template/style.scss +0 -8
  119. package/src/components/start-page-options/index.js +46 -22
  120. package/src/components/start-page-options/style.scss +0 -9
  121. package/src/components/visual-editor/index.js +2 -1
  122. package/src/editor.js +8 -4
  123. package/src/editor.native.js +2 -2
  124. package/src/store/selectors.js +5 -8
  125. package/src/style.scss +3 -2
  126. package/src/test/editor.native.js +1 -3
  127. package/build/components/sidebar/post-link/index.js +0 -182
  128. package/build/components/sidebar/post-link/index.js.map +0 -1
  129. package/build/components/sidebar/template/actions.js +0 -172
  130. package/build/components/sidebar/template/actions.js.map +0 -1
  131. package/build/components/sidebar/template/index.js +0 -164
  132. package/build/components/sidebar/template/index.js.map +0 -1
  133. package/build-module/components/sidebar/post-link/index.js +0 -165
  134. package/build-module/components/sidebar/post-link/index.js.map +0 -1
  135. package/build-module/components/sidebar/template/actions.js +0 -158
  136. package/build-module/components/sidebar/template/actions.js.map +0 -1
  137. package/build-module/components/sidebar/template/index.js +0 -145
  138. package/build-module/components/sidebar/template/index.js.map +0 -1
  139. package/src/components/sidebar/post-link/index.js +0 -179
  140. package/src/components/sidebar/post-link/style.scss +0 -20
  141. package/src/components/sidebar/template/actions.js +0 -206
  142. package/src/components/sidebar/template/index.js +0 -160
@@ -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,SAAT,EA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,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,sBAAjD,QAA+E,yBAA/E;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,kBAA5B;AACA,SAASC,MAAT,EAAiBC,aAAjB,EAAgCC,MAAhC,QAA8C,uBAA9C;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASD,KAAK,IAAIE,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,gBAAvC;AACA,OAAOC,uBAAP,MAAoC,gBAApC;AAEA,eAAe,SAASC,gBAAT,OAAyC;AAAA;;AAAA,MAAd;AAAEC,IAAAA;AAAF,GAAc;AACvD,QAAM;AACLC,IAAAA,WADK;AAELC,IAAAA,kBAFK;AAGLC,IAAAA,gBAHK;AAILC,IAAAA,oBAJK;AAKLC,IAAAA,SALK;AAMLC,IAAAA;AANK,MAOFd,SAAS,CAAIe,MAAF,IAAc;AAC5B,UAAMC,cAAc,GAAGD,MAAM,CAAEZ,WAAF,CAAN,CAAsBc,iBAAtB,EAAvB;AACA,UAAMC,YAAY,GAAGH,MAAM,CAAEX,SAAF,CAAN,CAAoBe,eAApB,CACpB,MADoB,EAEpB,MAFo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KAKGd,EAAE,CAAE,4CAAF,CALL,CADY,GASZ,cAAC,aAAD;AACC,IAAA,mBAAmB,MADpB;AAEC,IAAA,KAAK,EAAGA,EAAE,CAAE,UAAF,CAFX;AAGC,IAAA,KAAK,2BAAG+C,cAAH,aAAGA,cAAH,uBAAGA,cAAc,CAAEF,KAAnB,yEAA4B,EAHlC;AAIC,IAAA,OAAO,EAAGR,OAJX;AAKC,IAAA,QAAQ,EAAKK,IAAF,IACVQ,QAAQ,CAAE;AAAEM,MAAAA,QAAQ,EAAEd,IAAI,IAAI;AAApB,KAAF;AANV,IA5BF,EAsCGvB,OAAO,IACR,yBACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,MADT;AAEC,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,114 @@
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) {
33
+ return true;
34
+ }
35
+
36
+ if (!settings.supportsTemplateMode) {
37
+ return false;
38
+ }
39
+
40
+ const canCreateTemplates = (_select$canUser = select(coreStore).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
41
+ return canCreateTemplates;
42
+ }, []);
43
+
44
+ if (!isVisible) {
45
+ return null;
46
+ }
47
+
48
+ return createElement(PanelRow, {
49
+ className: "edit-post-post-template",
50
+ ref: anchorRef
51
+ }, createElement("span", null, __('Template')), createElement(Dropdown, {
52
+ popoverProps: {
53
+ anchorRef
54
+ },
55
+ position: "bottom left",
56
+ className: "edit-post-post-template__dropdown",
57
+ contentClassName: "edit-post-post-template__dialog",
58
+ focusOnMount: true,
59
+ renderToggle: _ref => {
60
+ let {
61
+ isOpen,
62
+ onToggle
63
+ } = _ref;
64
+ return createElement(PostTemplateToggle, {
65
+ isOpen: isOpen,
66
+ onClick: onToggle
67
+ });
68
+ },
69
+ renderContent: _ref2 => {
70
+ let {
71
+ onClose
72
+ } = _ref2;
73
+ return createElement(PostTemplateForm, {
74
+ onClose: onClose
75
+ });
76
+ }
77
+ }));
78
+ }
79
+
80
+ function PostTemplateToggle(_ref3) {
81
+ let {
82
+ isOpen,
83
+ onClick
84
+ } = _ref3;
85
+ const templateTitle = useSelect(select => {
86
+ var _select$getEntityReco;
87
+
88
+ const templateSlug = select(editorStore).getEditedPostAttribute('template');
89
+ const settings = select(editorStore).getEditorSettings();
90
+
91
+ if (settings.availableTemplates[templateSlug]) {
92
+ return settings.availableTemplates[templateSlug];
93
+ }
94
+
95
+ const template = (_select$getEntityReco = select(coreStore).getEntityRecords('postType', 'wp_template', {
96
+ per_page: -1
97
+ })) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco.find(_ref4 => {
98
+ let {
99
+ slug
100
+ } = _ref4;
101
+ return slug === templateSlug;
102
+ });
103
+ return template === null || template === void 0 ? void 0 : template.title.rendered;
104
+ }, []);
105
+ return createElement(Button, {
106
+ className: "edit-post-post-template__toggle",
107
+ variant: "tertiary",
108
+ "aria-expanded": isOpen,
109
+ "aria-label": templateTitle ? sprintf( // translators: %s: Name of the currently selected template.
110
+ __('Select template: %s'), templateTitle) : __('Select template'),
111
+ onClick: onClick
112
+ }, templateTitle !== null && templateTitle !== void 0 ? templateTitle : __('Default template'));
113
+ }
114
+ //# 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,CAAEN,WAAF,CAAN,CAAsBa,iBAAtB,EAAjB;AACA,UAAMC,YAAY,GACjB,CAAC,CAAEF,QAAQ,CAACG,kBAAZ,IACAC,MAAM,CAACC,IAAP,CAAaL,QAAQ,CAACG,kBAAtB,EAA2CG,MAA3C,GAAoD,CAFrD;;AAGA,QAAKJ,YAAL,EAAoB;AACnB,aAAO,IAAP;AACA;;AAED,QAAK,CAAEF,QAAQ,CAACO,oBAAhB,EAAuC;AACtC,aAAO,KAAP;AACA;;AAED,UAAMC,kBAAkB,sBACvBd,MAAM,CAAEL,S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;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 ) {\n\t\t\treturn true;\n\t\t}\n\n\t\tif ( ! 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,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,YADD,EAECC,OAAO,IAAIC,WAFZ,EAGCC,eAHD,QAIO,mBAJP;AAMA,eAAe,SAASF,OAAT,GAAmB;AACjC,QAAMG,SAAS,GAAGV,MAAM,EAAxB;AACA,SACC,cAAC,YAAD,QACC,cAAC,QAAD;AAAU,IAAA,SAAS,EAAC,oBAApB;AAAyC,IAAA,GAAG,EAAGU;AAA/C,KACC,4BAAQN,EAAE,CAAE,KAAF,CAAV,CADD,EAEC,cAAC,QAAD;AACC,IAAA,YAAY,EAAG;AAAEM,MAAAA;AAAF,KADhB;AAEC,IAAA,QAAQ,EAAC,aAFV;AAGC,IAAA,SAAS,EAAC,8BAHX;AAIC,IAAA,gBAAgB,EAAC,4BAJlB;AAKC,IAAA,YAAY,MALb;AAMC,IAAA,YAAY,EAAG;AAAA,UAAE;AAAEC,QAAAA,MAAF;AAAUC,QAAAA;AAAV,OAAF;AAAA,aACd,cAAC,aAAD;AAAe,QAAA,MAAM,EAAGD,MAAxB;AAAiC,QAAA,OAAO,EAAGC;AAA3C,QADc;AAAA,KANhB;AASC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,cAAC,WAAD;AAAa,QAAA,OAAO,EAAGA;AAAvB,QADe;AAAA;AATjB,IAFD,CADD,CADD;AAoBA;;AAED,SAASC,aAAT,QAA8C;AAAA,MAAtB;AAAEH,IAAAA,MAAF;AAAUI,IAAAA;AAAV,GAAsB;AAC7C,QAAMC,KAAK,GAAGP,eAAe,EAA7B;AACA,SACC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,4BADX;AAEC,IAAA,OAAO,EAAC,UAFT;AAGC,qBAAgBE,MAHjB,CAIC;AAJD;AAKC,kBAAaN,OAAO,CAAED,EAAE,CAAE,gBAAF,CAAJ,EAA0BY,KAA1B,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"]}
@@ -3,9 +3,9 @@ import { createElement } from "@wordpress/element";
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
- import { PostVisibility as PostVisibilityForm, PostVisibilityLabel, PostVisibilityCheck } from '@wordpress/editor';
8
+ import { PostVisibility as PostVisibilityForm, PostVisibilityLabel, PostVisibilityCheck, usePostVisibilityLabel } from '@wordpress/editor';
9
9
  import { useRef } from '@wordpress/element';
10
10
  export function PostVisibility() {
11
11
  const rowRef = useRef();
@@ -26,17 +26,16 @@ export function PostVisibility() {
26
26
  // when the label changes.
27
27
  anchorRef: rowRef.current
28
28
  },
29
+ focusOnMount: true,
29
30
  renderToggle: _ref2 => {
30
31
  let {
31
32
  isOpen,
32
33
  onToggle
33
34
  } = _ref2;
34
- return createElement(Button, {
35
- "aria-expanded": isOpen,
36
- className: "edit-post-post-visibility__toggle",
37
- onClick: onToggle,
38
- variant: "tertiary"
39
- }, createElement(PostVisibilityLabel, null));
35
+ return createElement(PostVisibilityToggle, {
36
+ isOpen: isOpen,
37
+ onClick: onToggle
38
+ });
40
39
  },
41
40
  renderContent: _ref3 => {
42
41
  let {
@@ -50,5 +49,22 @@ export function PostVisibility() {
50
49
  }
51
50
  });
52
51
  }
52
+
53
+ function PostVisibilityToggle(_ref4) {
54
+ let {
55
+ isOpen,
56
+ onClick
57
+ } = _ref4;
58
+ const label = usePostVisibilityLabel();
59
+ return createElement(Button, {
60
+ className: "edit-post-post-visibility__toggle",
61
+ variant: "tertiary",
62
+ "aria-expanded": isOpen // translators: %s: Current post visibility.
63
+ ,
64
+ "aria-label": sprintf(__('Select visibility: %s'), label),
65
+ onClick: onClick
66
+ }, label);
67
+ }
68
+
53
69
  export default PostVisibility;
54
70
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-visibility/index.js"],"names":["__","PanelRow","Dropdown","Button","PostVisibility","PostVisibilityForm","PostVisibilityLabel","PostVisibilityCheck","useRef","rowRef","canEdit","anchorRef","current","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SACCC,cAAc,IAAIC,kBADnB,EAECC,mBAFD,EAGCC,mBAHD,QAIO,mBAJP;AAKA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,OAAO,SAASJ,cAAT,GAA0B;AAChC,QAAMK,MAAM,GAAGD,MAAM,EAArB;AACA,SACC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAG;AAAA,UAAE;AAAEE,QAAAA;AAAF,OAAF;AAAA,aACR,cAAC,QAAD;AAAU,QAAA,GAAG,EAAGD,MAAhB;AAAyB,QAAA,SAAS,EAAC;AAAnC,SACC,4BAAQT,EAAE,CAAE,YAAF,CAAV,CADD,EAEG,CAAEU,OAAF,IACD,4BACC,cAAC,mBAAD,OADD,CAHF,EAOGA,OAAO,IACR,cAAC,QAAD;AACC,QAAA,QAAQ,EAAC,aADV;AAEC,QAAA,gBAAgB,EAAC,mCAFlB;AAGC,QAAA,YAAY,EAAG;AACd;AACA;AACA;AACAC,UAAAA,SAAS,EAAEF,MAAM,CAACG;AAJJ,SAHhB;AASC,QAAA,YAAY,EAAG;AAAA,cAAE;AAAEC,YAAAA,MAAF;AAAUC,YAAAA;AAAV,WAAF;AAAA,iBACd,cAAC,MAAD;AACC,6BAAgBD,MADjB;AAEC,YAAA,SAAS,EAAC,mCAFX;AAGC,YAAA,OAAO,EAAGC,QAHX;AAIC,YAAA,OAAO,EAAC;AAJT,aAMC,cAAC,mBAAD,OAND,CADc;AAAA,SAThB;AAmBC,QAAA,aAAa,EAAG;AAAA,cAAE;AAAEC,YAAAA;AAAF,WAAF;AAAA,iBACf,cAAC,kBAAD;AAAoB,YAAA,OAAO,EAAGA;AAA9B,YADe;AAAA;AAnBjB,QARF,CADQ;AAAA;AADV,IADD;AAuCA;AAED,eAAeX,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport {\n\tPostVisibility as PostVisibilityForm,\n\tPostVisibilityLabel,\n\tPostVisibilityCheck,\n} from '@wordpress/editor';\nimport { useRef } from '@wordpress/element';\n\nexport function PostVisibility() {\n\tconst rowRef = useRef();\n\treturn (\n\t\t<PostVisibilityCheck\n\t\t\trender={ ( { canEdit } ) => (\n\t\t\t\t<PanelRow ref={ rowRef } className=\"edit-post-post-visibility\">\n\t\t\t\t\t<span>{ __( 'Visibility' ) }</span>\n\t\t\t\t\t{ ! canEdit && (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canEdit && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tposition=\"bottom left\"\n\t\t\t\t\t\t\tcontentClassName=\"edit-post-post-visibility__dialog\"\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t// Anchor the popover to the middle of the\n\t\t\t\t\t\t\t\t// entire row so that it doesn't move around\n\t\t\t\t\t\t\t\t// when the label changes.\n\t\t\t\t\t\t\t\tanchorRef: rowRef.current,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\tclassName=\"edit-post-post-visibility__toggle\"\n\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<PostVisibilityForm onClose={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelRow>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default PostVisibility;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/post-visibility/index.js"],"names":["__","sprintf","PanelRow","Dropdown","Button","PostVisibility","PostVisibilityForm","PostVisibilityLabel","PostVisibilityCheck","usePostVisibilityLabel","useRef","rowRef","canEdit","anchorRef","current","isOpen","onToggle","onClose","PostVisibilityToggle","onClick","label"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,EAAmBC,QAAnB,EAA6BC,MAA7B,QAA2C,uBAA3C;AACA,SACCC,cAAc,IAAIC,kBADnB,EAECC,mBAFD,EAGCC,mBAHD,EAICC,sBAJD,QAKO,mBALP;AAMA,SAASC,MAAT,QAAuB,oBAAvB;AAEA,OAAO,SAASL,cAAT,GAA0B;AAChC,QAAMM,MAAM,GAAGD,MAAM,EAArB;AACA,SACC,cAAC,mBAAD;AACC,IAAA,MAAM,EAAG;AA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i18n';\nimport { PanelRow, Dropdown, Button } from '@wordpress/components';\nimport {\n\tPostVisibility as PostVisibilityForm,\n\tPostVisibilityLabel,\n\tPostVisibilityCheck,\n\tusePostVisibilityLabel,\n} from '@wordpress/editor';\nimport { useRef } from '@wordpress/element';\n\nexport function PostVisibility() {\n\tconst rowRef = useRef();\n\treturn (\n\t\t<PostVisibilityCheck\n\t\t\trender={ ( { canEdit } ) => (\n\t\t\t\t<PanelRow ref={ rowRef } className=\"edit-post-post-visibility\">\n\t\t\t\t\t<span>{ __( 'Visibility' ) }</span>\n\t\t\t\t\t{ ! canEdit && (\n\t\t\t\t\t\t<span>\n\t\t\t\t\t\t\t<PostVisibilityLabel />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) }\n\t\t\t\t\t{ canEdit && (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tposition=\"bottom left\"\n\t\t\t\t\t\t\tcontentClassName=\"edit-post-post-visibility__dialog\"\n\t\t\t\t\t\t\tpopoverProps={ {\n\t\t\t\t\t\t\t\t// Anchor the popover to the middle of the\n\t\t\t\t\t\t\t\t// entire row so that it doesn't move around\n\t\t\t\t\t\t\t\t// when the label changes.\n\t\t\t\t\t\t\t\tanchorRef: rowRef.current,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tfocusOnMount\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<PostVisibilityToggle\n\t\t\t\t\t\t\t\t\tisOpen={ isOpen }\n\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<PostVisibilityForm onClose={ onClose } />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelRow>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nfunction PostVisibilityToggle( { isOpen, onClick } ) {\n\tconst label = usePostVisibilityLabel();\n\treturn (\n\t\t<Button\n\t\t\tclassName=\"edit-post-post-visibility__toggle\"\n\t\t\tvariant=\"tertiary\"\n\t\t\taria-expanded={ isOpen }\n\t\t\t// translators: %s: Current post visibility.\n\t\t\taria-label={ sprintf( __( 'Select visibility: %s' ), label ) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ label }\n\t\t</Button>\n\t);\n}\n\nexport default PostVisibility;\n"]}
@@ -18,13 +18,11 @@ import LastRevision from '../last-revision';
18
18
  import PostTaxonomies from '../post-taxonomies';
19
19
  import FeaturedImage from '../featured-image';
20
20
  import PostExcerpt from '../post-excerpt';
21
- import PostLink from '../post-link';
22
21
  import DiscussionPanel from '../discussion-panel';
23
22
  import PageAttributes from '../page-attributes';
24
23
  import MetaBoxes from '../../meta-boxes';
25
24
  import PluginDocumentSettingPanel from '../plugin-document-setting-panel';
26
25
  import PluginSidebarEditPost from '../plugin-sidebar';
27
- import Template from '../template';
28
26
  import TemplateSummary from '../template-summary';
29
27
  import { __ } from '@wordpress/i18n';
30
28
  import { useSelect } from '@wordpress/data';
@@ -43,7 +41,7 @@ const SettingsSidebar = () => {
43
41
  // The settings sidebar is used by the edit-post/document and edit-post/block sidebars.
44
42
  // sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.
45
43
  // If one of the two sidebars is active the component will contain the content of that sidebar.
46
- // When neither of the the two sidebars is active we can not simply return null, because the PluginSidebarEditPost
44
+ // When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost
47
45
  // component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName
48
46
  // should contain the sidebar that will be active when the toggle button is pressed. If a block
49
47
  // is selected, that should be edit-post/block otherwise it's edit-post/document.
@@ -77,7 +75,7 @@ const SettingsSidebar = () => {
77
75
  toggleShortcut: keyboardShortcut,
78
76
  icon: cog,
79
77
  isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
80
- }, !isTemplateMode && sidebarName === 'edit-post/document' && createElement(Fragment, null, createElement(PostStatus, null), createElement(Template, null), createElement(PluginDocumentSettingPanel.Slot, null), createElement(LastRevision, null), createElement(PostLink, null), createElement(PostTaxonomies, null), createElement(FeaturedImage, null), createElement(PostExcerpt, null), createElement(DiscussionPanel, null), createElement(PageAttributes, null), createElement(MetaBoxes, {
78
+ }, !isTemplateMode && sidebarName === 'edit-post/document' && createElement(Fragment, null, createElement(PostStatus, null), createElement(PluginDocumentSettingPanel.Slot, null), createElement(LastRevision, null), createElement(PostTaxonomies, null), createElement(FeaturedImage, null), createElement(PostExcerpt, null), createElement(DiscussionPanel, null), createElement(PageAttributes, null), createElement(MetaBoxes, {
81
79
  location: "side"
82
80
  })), isTemplateMode && sidebarName === 'edit-post/document' && createElement(TemplateSummary, null), sidebarName === 'edit-post/block' && createElement(BlockInspector, null));
83
81
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"names":["BlockInspector","store","blockEditorStore","cog","Platform","keyboardShortcutsStore","interfaceStore","SettingsHeader","PostStatus","LastRevision","PostTaxonomies","FeaturedImage","PostExcerpt","PostLink","DiscussionPanel","PageAttributes","MetaBoxes","PluginDocumentSettingPanel","PluginSidebarEditPost","Template","TemplateSummary","__","useSelect","editPostStore","SIDEBAR_ACTIVE_BY_DEFAULT","select","web","native","SettingsSidebar","sidebarName","keyboardShortcut","isTemplateMode","sidebar","getActiveComplementaryArea","name","includes","getBlockSelectionStart","shortcut","getShortcutRepresentation","isEditingTemplate"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,GAAT,QAAoB,kBAApB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASH,KAAK,IAAII,sBAAlB,QAAgD,+BAAhD;AACA,SAASJ,KAAK,IAAIK,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;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,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { cog } from '@wordpress/icons';\nimport { Platform } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport LastRevision from '../last-revision';\nimport PostTaxonomies from '../post-taxonomies';\nimport FeaturedImage from '../featured-image';\nimport PostExcerpt from '../post-excerpt';\nimport PostLink from '../post-link';\nimport DiscussionPanel from '../discussion-panel';\nimport PageAttributes from '../page-attributes';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport Template from '../template';\nimport TemplateSummary from '../template-summary';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as editPostStore } from '../../../store';\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SettingsSidebar = () => {\n\tconst { sidebarName, keyboardShortcut, isTemplateMode } = useSelect(\n\t\t( select ) => {\n\t\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t\t// When neither of the the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditPostStore.name\n\t\t\t);\n\t\t\tif (\n\t\t\t\t! [ 'edit-post/document', 'edit-post/block' ].includes(\n\t\t\t\t\tsidebar\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\t\tsidebar = 'edit-post/block';\n\t\t\t\t}\n\t\t\t\tsidebar = 'edit-post/document';\n\t\t\t}\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\t\treturn {\n\t\t\t\tsidebarName: sidebar,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tisTemplateMode: select( editPostStore ).isEditingTemplate(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\tcloseLabel={ __( 'Close settings' ) }\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ cog }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t{ ! isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<>\n\t\t\t\t\t<PostStatus />\n\t\t\t\t\t<Template />\n\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t<LastRevision />\n\t\t\t\t\t<PostLink />\n\t\t\t\t\t<PostTaxonomies />\n\t\t\t\t\t<FeaturedImage />\n\t\t\t\t\t<PostExcerpt />\n\t\t\t\t\t<DiscussionPanel />\n\t\t\t\t\t<PageAttributes />\n\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<TemplateSummary />\n\t\t\t) }\n\t\t\t{ sidebarName === 'edit-post/block' && <BlockInspector /> }\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nexport default SettingsSidebar;\n"]}
1
+ {"version":3,"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"names":["BlockInspector","store","blockEditorStore","cog","Platform","keyboardShortcutsStore","interfaceStore","SettingsHeader","PostStatus","LastRevision","PostTaxonomies","FeaturedImage","PostExcerpt","DiscussionPanel","PageAttributes","MetaBoxes","PluginDocumentSettingPanel","PluginSidebarEditPost","TemplateSummary","__","useSelect","editPostStore","SIDEBAR_ACTIVE_BY_DEFAULT","select","web","native","SettingsSidebar","sidebarName","keyboardShortcut","isTemplateMode","sidebar","getActiveComplementaryArea","name","includes","getBlockSelectionStart","shortcut","getShortcutRepresentation","isEditingTemplate"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,cADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;AAIA,SAASC,GAAT,QAAoB,kBAApB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASH,KAAK,IAAII,sBAAlB,QAAgD,+BAAhD;AACA,SAASJ,KAAK,IAAIK,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,YAAP,MAAyB,kBAAzB;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,WAAP,MAAwB,iBAAxB;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,OAAOC,cAAP,MAA2B,oBAA3B;AACA,OAAOC,SAAP,MAAsB,kBAAtB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,OAAOC,qBAAP,MAAkC,mBAAlC;AACA,OAAOC,eAAP,MAA4B,qBAA5B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASnB,KAAK,IAAIoB,aAAlB,QAAuC,gBAA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AGS,gBAPlB;AAQC,IAAA,IAAI,EAAGzB,GARR;AASC,IAAA,iBAAiB,EAAGmB;AATrB,KAWG,CAAEO,cAAF,IAAoBF,WAAW,KAAK,oBAApC,IACD,8BACC,cAAC,UAAD,OADD,EAEC,cAAC,0BAAD,CAA4B,IAA5B,OAFD,EAGC,cAAC,YAAD,OAHD,EAIC,cAAC,cAAD,OAJD,EAKC,cAAC,aAAD,OALD,EAMC,cAAC,WAAD,OAND,EAOC,cAAC,eAAD,OAPD,EAQC,cAAC,cAAD,OARD,EASC,cAAC,SAAD;AAAW,IAAA,QAAQ,EAAC;AAApB,IATD,CAZF,EAwBGE,cAAc,IAAIF,WAAW,KAAK,oBAAlC,IACD,cAAC,eAAD,OAzBF,EA2BGA,WAAW,KAAK,iBAAhB,IAAqC,cAAC,cAAD,OA3BxC,CADD;AA+BA,CAlED;;AAoEA,eAAeD,eAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { cog } from '@wordpress/icons';\nimport { Platform } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport LastRevision from '../last-revision';\nimport PostTaxonomies from '../post-taxonomies';\nimport FeaturedImage from '../featured-image';\nimport PostExcerpt from '../post-excerpt';\nimport DiscussionPanel from '../discussion-panel';\nimport PageAttributes from '../page-attributes';\nimport MetaBoxes from '../../meta-boxes';\nimport PluginDocumentSettingPanel from '../plugin-document-setting-panel';\nimport PluginSidebarEditPost from '../plugin-sidebar';\nimport TemplateSummary from '../template-summary';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { store as editPostStore } from '../../../store';\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\n\nconst SettingsSidebar = () => {\n\tconst { sidebarName, keyboardShortcut, isTemplateMode } = useSelect(\n\t\t( select ) => {\n\t\t\t// The settings sidebar is used by the edit-post/document and edit-post/block sidebars.\n\t\t\t// sidebarName represents the sidebar that is active or that should be active when the SettingsSidebar toggle button is pressed.\n\t\t\t// If one of the two sidebars is active the component will contain the content of that sidebar.\n\t\t\t// When neither of the two sidebars is active we can not simply return null, because the PluginSidebarEditPost\n\t\t\t// component, besides being used to render the sidebar, also renders the toggle button. In that case sidebarName\n\t\t\t// should contain the sidebar that will be active when the toggle button is pressed. If a block\n\t\t\t// is selected, that should be edit-post/block otherwise it's edit-post/document.\n\t\t\tlet sidebar = select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditPostStore.name\n\t\t\t);\n\t\t\tif (\n\t\t\t\t! [ 'edit-post/document', 'edit-post/block' ].includes(\n\t\t\t\t\tsidebar\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\tif ( select( blockEditorStore ).getBlockSelectionStart() ) {\n\t\t\t\t\tsidebar = 'edit-post/block';\n\t\t\t\t}\n\t\t\t\tsidebar = 'edit-post/document';\n\t\t\t}\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' );\n\t\t\treturn {\n\t\t\t\tsidebarName: sidebar,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tisTemplateMode: select( editPostStore ).isEditingTemplate(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PluginSidebarEditPost\n\t\t\tidentifier={ sidebarName }\n\t\t\theader={ <SettingsHeader sidebarName={ sidebarName } /> }\n\t\t\tcloseLabel={ __( 'Close settings' ) }\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ cog }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t{ ! isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<>\n\t\t\t\t\t<PostStatus />\n\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t<LastRevision />\n\t\t\t\t\t<PostTaxonomies />\n\t\t\t\t\t<FeaturedImage />\n\t\t\t\t\t<PostExcerpt />\n\t\t\t\t\t<DiscussionPanel />\n\t\t\t\t\t<PageAttributes />\n\t\t\t\t\t<MetaBoxes location=\"side\" />\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t{ isTemplateMode && sidebarName === 'edit-post/document' && (\n\t\t\t\t<TemplateSummary />\n\t\t\t) }\n\t\t\t{ sidebarName === 'edit-post/block' && <BlockInspector /> }\n\t\t</PluginSidebarEditPost>\n\t);\n};\n\nexport default SettingsSidebar;\n"]}