@wordpress/edit-post 7.30.0 → 7.32.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 (129) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +6 -185
  3. package/build/components/header/index.js +1 -1
  4. package/build/components/header/index.js.map +1 -1
  5. package/build/components/header/post-publish-button-or-toggle.js +2 -7
  6. package/build/components/header/post-publish-button-or-toggle.js.map +1 -1
  7. package/build/components/init-pattern-modal/index.js +99 -0
  8. package/build/components/init-pattern-modal/index.js.map +1 -0
  9. package/build/components/keyboard-shortcut-help-modal/config.js +6 -0
  10. package/build/components/keyboard-shortcut-help-modal/config.js.map +1 -1
  11. package/build/components/keyboard-shortcut-help-modal/index.js +3 -0
  12. package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  13. package/build/components/layout/actions-panel.js +4 -7
  14. package/build/components/layout/actions-panel.js.map +1 -1
  15. package/build/components/layout/index.js +7 -3
  16. package/build/components/layout/index.js.map +1 -1
  17. package/build/components/sidebar/plugin-post-publish-panel/index.js +16 -64
  18. package/build/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  19. package/build/components/sidebar/plugin-pre-publish-panel/index.js +16 -63
  20. package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  21. package/build/components/sidebar/post-status/index.js +3 -1
  22. package/build/components/sidebar/post-status/index.js.map +1 -1
  23. package/build/components/sidebar/settings-sidebar/index.js +8 -4
  24. package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
  25. package/build/editor.js +7 -2
  26. package/build/editor.js.map +1 -1
  27. package/build/editor.native.js +2 -2
  28. package/build/editor.native.js.map +1 -1
  29. package/build/hooks/commands/use-common-commands.js +2 -2
  30. package/build/hooks/commands/use-common-commands.js.map +1 -1
  31. package/build/hooks/use-navigate-to-entity-record.js +36 -19
  32. package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
  33. package/build/index.js +4 -6
  34. package/build/index.js.map +1 -1
  35. package/build/index.native.js +2 -4
  36. package/build/index.native.js.map +1 -1
  37. package/build/store/actions.js +36 -23
  38. package/build/store/actions.js.map +1 -1
  39. package/build/store/reducer.js +1 -15
  40. package/build/store/reducer.js.map +1 -1
  41. package/build/store/selectors.js +10 -5
  42. package/build/store/selectors.js.map +1 -1
  43. package/build-module/components/header/index.js +1 -1
  44. package/build-module/components/header/index.js.map +1 -1
  45. package/build-module/components/header/post-publish-button-or-toggle.js +2 -7
  46. package/build-module/components/header/post-publish-button-or-toggle.js.map +1 -1
  47. package/build-module/components/init-pattern-modal/index.js +93 -0
  48. package/build-module/components/init-pattern-modal/index.js.map +1 -0
  49. package/build-module/components/keyboard-shortcut-help-modal/config.js +6 -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 +3 -0
  52. package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
  53. package/build-module/components/layout/actions-panel.js +4 -5
  54. package/build-module/components/layout/actions-panel.js.map +1 -1
  55. package/build-module/components/layout/index.js +8 -4
  56. package/build-module/components/layout/index.js.map +1 -1
  57. package/build-module/components/sidebar/plugin-post-publish-panel/index.js +14 -62
  58. package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +1 -1
  59. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js +14 -61
  60. package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +1 -1
  61. package/build-module/components/sidebar/post-status/index.js +4 -2
  62. package/build-module/components/sidebar/post-status/index.js.map +1 -1
  63. package/build-module/components/sidebar/settings-sidebar/index.js +9 -5
  64. package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
  65. package/build-module/editor.js +7 -2
  66. package/build-module/editor.js.map +1 -1
  67. package/build-module/editor.native.js +3 -3
  68. package/build-module/editor.native.js.map +1 -1
  69. package/build-module/hooks/commands/use-common-commands.js +2 -2
  70. package/build-module/hooks/commands/use-common-commands.js.map +1 -1
  71. package/build-module/hooks/use-navigate-to-entity-record.js +37 -20
  72. package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
  73. package/build-module/index.js +5 -5
  74. package/build-module/index.js.map +1 -1
  75. package/build-module/index.native.js +2 -4
  76. package/build-module/index.native.js.map +1 -1
  77. package/build-module/store/actions.js +30 -15
  78. package/build-module/store/actions.js.map +1 -1
  79. package/build-module/store/reducer.js +1 -13
  80. package/build-module/store/reducer.js.map +1 -1
  81. package/build-module/store/selectors.js +9 -3
  82. package/build-module/store/selectors.js.map +1 -1
  83. package/build-style/classic-rtl.css +1 -1
  84. package/build-style/classic.css +1 -1
  85. package/build-style/style-rtl.css +1 -7
  86. package/build-style/style.css +1 -7
  87. package/package.json +32 -32
  88. package/src/classic.scss +2 -1
  89. package/src/components/header/index.js +1 -1
  90. package/src/components/header/post-publish-button-or-toggle.js +2 -8
  91. package/src/components/init-pattern-modal/index.js +117 -0
  92. package/src/components/keyboard-shortcut-help-modal/config.js +4 -0
  93. package/src/components/keyboard-shortcut-help-modal/index.js +4 -0
  94. package/src/components/layout/actions-panel.js +5 -4
  95. package/src/components/layout/index.js +9 -4
  96. package/src/components/meta-boxes/meta-boxes-area/style.scss +1 -1
  97. package/src/components/sidebar/plugin-post-publish-panel/index.js +12 -67
  98. package/src/components/sidebar/plugin-pre-publish-panel/index.js +12 -66
  99. package/src/components/sidebar/post-status/index.js +2 -0
  100. package/src/components/sidebar/settings-sidebar/index.js +7 -5
  101. package/src/editor.js +12 -2
  102. package/src/editor.native.js +8 -2
  103. package/src/hooks/commands/use-common-commands.js +2 -2
  104. package/src/hooks/use-navigate-to-entity-record.js +37 -24
  105. package/src/index.js +5 -3
  106. package/src/index.native.js +1 -4
  107. package/src/store/actions.js +27 -12
  108. package/src/store/reducer.js +0 -13
  109. package/src/store/selectors.js +11 -3
  110. package/src/style.scss +0 -1
  111. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -107
  112. package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  113. package/build/components/sidebar/plugin-document-setting-panel/index.js +0 -126
  114. package/build/components/sidebar/plugin-document-setting-panel/index.js.map +0 -1
  115. package/build/components/sidebar/template-summary/index.js +0 -36
  116. package/build/components/sidebar/template-summary/index.js.map +0 -1
  117. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -100
  118. package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +0 -1
  119. package/build-module/components/sidebar/plugin-document-setting-panel/index.js +0 -118
  120. package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +0 -1
  121. package/build-module/components/sidebar/template-summary/index.js +0 -29
  122. package/build-module/components/sidebar/template-summary/index.js.map +0 -1
  123. package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +0 -108
  124. package/src/components/sidebar/plugin-document-setting-panel/index.js +0 -125
  125. package/src/components/sidebar/plugin-post-publish-panel/test/__snapshots__/index.js.snap +0 -39
  126. package/src/components/sidebar/plugin-post-publish-panel/test/index.js +0 -33
  127. package/src/components/sidebar/plugin-pre-publish-panel/test/index.js +0 -33
  128. package/src/components/sidebar/template-summary/index.js +0 -37
  129. package/src/components/sidebar/template-summary/style.scss +0 -5
@@ -1,100 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { BlockSettingsMenuControls } from '@wordpress/block-editor';
6
- import { MenuItem } from '@wordpress/components';
7
- import { compose } from '@wordpress/compose';
8
- const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
9
-
10
- /**
11
- * Plugins may want to add an item to the menu either for every block
12
- * or only for the specific ones provided in the `allowedBlocks` component property.
13
- *
14
- * If there are multiple blocks selected the item will be rendered if every block
15
- * is of one allowed type (not necessarily the same).
16
- *
17
- * @param {string[]} selectedBlocks Array containing the names of the blocks selected
18
- * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
19
- * @return {boolean} Whether the item will be rendered or not.
20
- */
21
- const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
22
-
23
- /**
24
- * Renders a new item in the block settings menu.
25
- *
26
- * @param {Object} props Component props.
27
- * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
28
- * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
29
- * @param {string} props.label The menu item text.
30
- * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
31
- * @param {boolean} [props.small] Whether to render the label or not.
32
- * @param {string} [props.role] The ARIA role for the menu item.
33
- *
34
- * @example
35
- * ```js
36
- * // Using ES5 syntax
37
- * var __ = wp.i18n.__;
38
- * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
39
- *
40
- * function doOnClick(){
41
- * // To be called when the user clicks the menu item.
42
- * }
43
- *
44
- * function MyPluginBlockSettingsMenuItem() {
45
- * return React.createElement(
46
- * PluginBlockSettingsMenuItem,
47
- * {
48
- * allowedBlocks: [ 'core/paragraph' ],
49
- * icon: 'dashicon-name',
50
- * label: __( 'Menu item text' ),
51
- * onClick: doOnClick,
52
- * }
53
- * );
54
- * }
55
- * ```
56
- *
57
- * @example
58
- * ```jsx
59
- * // Using ESNext syntax
60
- * import { __ } from '@wordpress/i18n';
61
- * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
62
- *
63
- * const doOnClick = ( ) => {
64
- * // To be called when the user clicks the menu item.
65
- * };
66
- *
67
- * const MyPluginBlockSettingsMenuItem = () => (
68
- * <PluginBlockSettingsMenuItem
69
- * allowedBlocks={ [ 'core/paragraph' ] }
70
- * icon='dashicon-name'
71
- * label={ __( 'Menu item text' ) }
72
- * onClick={ doOnClick } />
73
- * );
74
- * ```
75
- *
76
- * @return {Component} The component to be rendered.
77
- */
78
- const PluginBlockSettingsMenuItem = ({
79
- allowedBlocks,
80
- icon,
81
- label,
82
- onClick,
83
- small,
84
- role
85
- }) => createElement(BlockSettingsMenuControls, null, ({
86
- selectedBlocks,
87
- onClose
88
- }) => {
89
- if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
90
- return null;
91
- }
92
- return createElement(MenuItem, {
93
- onClick: compose(onClick, onClose),
94
- icon: icon,
95
- label: small ? label : undefined,
96
- role: role
97
- }, !small && label);
98
- });
99
- export default PluginBlockSettingsMenuItem;
100
- //# sourceMappingURL=plugin-block-settings-menu-item.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["BlockSettingsMenuControls","MenuItem","compose","isEverySelectedBlockAllowed","selected","allowed","filter","id","includes","length","shouldRenderItem","selectedBlocks","allowedBlocks","Array","isArray","PluginBlockSettingsMenuItem","icon","label","onClick","small","role","createElement","onClose","undefined"],"sources":["@wordpress/edit-post/src/components/block-settings-menu/plugin-block-settings-menu-item.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { BlockSettingsMenuControls } from '@wordpress/block-editor';\nimport { MenuItem } from '@wordpress/components';\nimport { compose } from '@wordpress/compose';\n\nconst isEverySelectedBlockAllowed = ( selected, allowed ) =>\n\tselected.filter( ( id ) => ! allowed.includes( id ) ).length === 0;\n\n/**\n * Plugins may want to add an item to the menu either for every block\n * or only for the specific ones provided in the `allowedBlocks` component property.\n *\n * If there are multiple blocks selected the item will be rendered if every block\n * is of one allowed type (not necessarily the same).\n *\n * @param {string[]} selectedBlocks Array containing the names of the blocks selected\n * @param {string[]} allowedBlocks Array containing the names of the blocks allowed\n * @return {boolean} Whether the item will be rendered or not.\n */\nconst shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>\n\t! Array.isArray( allowedBlocks ) ||\n\tisEverySelectedBlockAllowed( selectedBlocks, allowedBlocks );\n\n/**\n * Renders a new item in the block settings menu.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.\n * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.\n * @param {string} props.label The menu item text.\n * @param {Function} props.onClick Callback function to be executed when the user click the menu item.\n * @param {boolean} [props.small] Whether to render the label or not.\n * @param {string} [props.role] The ARIA role for the menu item.\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;\n *\n * function doOnClick(){\n * \t// To be called when the user clicks the menu item.\n * }\n *\n * function MyPluginBlockSettingsMenuItem() {\n * \treturn React.createElement(\n * \t\tPluginBlockSettingsMenuItem,\n * \t\t{\n * \t\t\tallowedBlocks: [ 'core/paragraph' ],\n * \t\t\ticon: 'dashicon-name',\n * \t\t\tlabel: __( 'Menu item text' ),\n * \t\t\tonClick: doOnClick,\n * \t\t}\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';\n *\n * const doOnClick = ( ) => {\n * // To be called when the user clicks the menu item.\n * };\n *\n * const MyPluginBlockSettingsMenuItem = () => (\n * <PluginBlockSettingsMenuItem\n * \t\tallowedBlocks={ [ 'core/paragraph' ] }\n * \t\ticon='dashicon-name'\n * \t\tlabel={ __( 'Menu item text' ) }\n * \t\tonClick={ doOnClick } />\n * );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nconst PluginBlockSettingsMenuItem = ( {\n\tallowedBlocks,\n\ticon,\n\tlabel,\n\tonClick,\n\tsmall,\n\trole,\n} ) => (\n\t<BlockSettingsMenuControls>\n\t\t{ ( { selectedBlocks, onClose } ) => {\n\t\t\tif ( ! shouldRenderItem( selectedBlocks, allowedBlocks ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn (\n\t\t\t\t<MenuItem\n\t\t\t\t\tonClick={ compose( onClick, onClose ) }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ small ? label : undefined }\n\t\t\t\t\trole={ role }\n\t\t\t\t>\n\t\t\t\t\t{ ! small && label }\n\t\t\t\t</MenuItem>\n\t\t\t);\n\t\t} }\n\t</BlockSettingsMenuControls>\n);\n\nexport default PluginBlockSettingsMenuItem;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,yBAAyB,QAAQ,yBAAyB;AACnE,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,2BAA2B,GAAGA,CAAEC,QAAQ,EAAEC,OAAO,KACtDD,QAAQ,CAACE,MAAM,CAAIC,EAAE,IAAM,CAAEF,OAAO,CAACG,QAAQ,CAAED,EAAG,CAAE,CAAC,CAACE,MAAM,KAAK,CAAC;;AAEnE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,gBAAgB,GAAGA,CAAEC,cAAc,EAAEC,aAAa,KACvD,CAAEC,KAAK,CAACC,OAAO,CAAEF,aAAc,CAAC,IAChCT,2BAA2B,CAAEQ,cAAc,EAAEC,aAAc,CAAC;;AAE7D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,2BAA2B,GAAGA,CAAE;EACrCH,aAAa;EACbI,IAAI;EACJC,KAAK;EACLC,OAAO;EACPC,KAAK;EACLC;AACD,CAAC,KACAC,aAAA,CAACrB,yBAAyB,QACvB,CAAE;EAAEW,cAAc;EAAEW;AAAQ,CAAC,KAAM;EACpC,IAAK,CAAEZ,gBAAgB,CAAEC,cAAc,EAAEC,aAAc,CAAC,EAAG;IAC1D,OAAO,IAAI;EACZ;EACA,OACCS,aAAA,CAACpB,QAAQ;IACRiB,OAAO,EAAGhB,OAAO,CAAEgB,OAAO,EAAEI,OAAQ,CAAG;IACvCN,IAAI,EAAGA,IAAM;IACbC,KAAK,EAAGE,KAAK,GAAGF,KAAK,GAAGM,SAAW;IACnCH,IAAI,EAAGA;EAAM,GAEX,CAAED,KAAK,IAAIF,KACJ,CAAC;AAEb,CAC0B,CAC3B;AAED,eAAeF,2BAA2B"}
@@ -1,118 +0,0 @@
1
- import { createElement, Fragment } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { createSlotFill, PanelBody } from '@wordpress/components';
6
- import { usePluginContext } from '@wordpress/plugins';
7
- import { useDispatch, useSelect } from '@wordpress/data';
8
- import warning from '@wordpress/warning';
9
- import { store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import { unlock } from '../../../lock-unlock';
15
- const {
16
- Fill,
17
- Slot
18
- } = createSlotFill('PluginDocumentSettingPanel');
19
- const {
20
- EnablePluginDocumentSettingPanelOption
21
- } = unlock(editorPrivateApis);
22
-
23
- /**
24
- * Renders items below the Status & Availability panel in the Document Sidebar.
25
- *
26
- * @param {Object} props Component properties.
27
- * @param {string} props.name Required. A machine-friendly name for the panel.
28
- * @param {string} [props.className] An optional class name added to the row.
29
- * @param {string} [props.title] The title of the panel
30
- * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
31
- * @param {Element} props.children Children to be rendered
32
- *
33
- * @example
34
- * ```js
35
- * // Using ES5 syntax
36
- * var el = React.createElement;
37
- * var __ = wp.i18n.__;
38
- * var registerPlugin = wp.plugins.registerPlugin;
39
- * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
40
- *
41
- * function MyDocumentSettingPlugin() {
42
- * return el(
43
- * PluginDocumentSettingPanel,
44
- * {
45
- * className: 'my-document-setting-plugin',
46
- * title: 'My Panel',
47
- * name: 'my-panel',
48
- * },
49
- * __( 'My Document Setting Panel' )
50
- * );
51
- * }
52
- *
53
- * registerPlugin( 'my-document-setting-plugin', {
54
- * render: MyDocumentSettingPlugin
55
- * } );
56
- * ```
57
- *
58
- * @example
59
- * ```jsx
60
- * // Using ESNext syntax
61
- * import { registerPlugin } from '@wordpress/plugins';
62
- * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
63
- *
64
- * const MyDocumentSettingTest = () => (
65
- * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
66
- * <p>My Document Setting Panel</p>
67
- * </PluginDocumentSettingPanel>
68
- * );
69
- *
70
- * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
71
- * ```
72
- *
73
- * @return {Component} The component to be rendered.
74
- */
75
- const PluginDocumentSettingPanel = ({
76
- name,
77
- className,
78
- title,
79
- icon,
80
- children
81
- }) => {
82
- const {
83
- name: pluginName
84
- } = usePluginContext();
85
- const panelName = `${pluginName}/${name}`;
86
- const {
87
- opened,
88
- isEnabled
89
- } = useSelect(select => {
90
- const {
91
- isEditorPanelOpened,
92
- isEditorPanelEnabled
93
- } = select(editorStore);
94
- return {
95
- opened: isEditorPanelOpened(panelName),
96
- isEnabled: isEditorPanelEnabled(panelName)
97
- };
98
- }, [panelName]);
99
- const {
100
- toggleEditorPanelOpened
101
- } = useDispatch(editorStore);
102
- if (undefined === name) {
103
- typeof SCRIPT_DEBUG !== "undefined" && SCRIPT_DEBUG === true ? warning('PluginDocumentSettingPanel requires a name property.') : void 0;
104
- }
105
- return createElement(Fragment, null, createElement(EnablePluginDocumentSettingPanelOption, {
106
- label: title,
107
- panelName: panelName
108
- }), createElement(Fill, null, isEnabled && createElement(PanelBody, {
109
- className: className,
110
- title: title,
111
- icon: icon,
112
- opened: opened,
113
- onToggle: () => toggleEditorPanelOpened(panelName)
114
- }, children)));
115
- };
116
- PluginDocumentSettingPanel.Slot = Slot;
117
- export default PluginDocumentSettingPanel;
118
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["createSlotFill","PanelBody","usePluginContext","useDispatch","useSelect","warning","store","editorStore","privateApis","editorPrivateApis","unlock","Fill","Slot","EnablePluginDocumentSettingPanelOption","PluginDocumentSettingPanel","name","className","title","icon","children","pluginName","panelName","opened","isEnabled","select","isEditorPanelOpened","isEditorPanelEnabled","toggleEditorPanelOpened","undefined","SCRIPT_DEBUG","createElement","Fragment","label","onToggle"],"sources":["@wordpress/edit-post/src/components/sidebar/plugin-document-setting-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSlotFill, PanelBody } from '@wordpress/components';\nimport { usePluginContext } from '@wordpress/plugins';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport warning from '@wordpress/warning';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../../lock-unlock';\n\nconst { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );\nconst { EnablePluginDocumentSettingPanelOption } = unlock( editorPrivateApis );\n\n/**\n * Renders items below the Status & Availability panel in the Document Sidebar.\n *\n * @param {Object} props Component properties.\n * @param {string} props.name Required. A machine-friendly name for the panel.\n * @param {string} [props.className] An optional class name added to the row.\n * @param {string} [props.title] The title of the panel\n * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.\n * @param {Element} props.children Children to be rendered\n *\n * @example\n * ```js\n * // Using ES5 syntax\n * var el = React.createElement;\n * var __ = wp.i18n.__;\n * var registerPlugin = wp.plugins.registerPlugin;\n * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;\n *\n * function MyDocumentSettingPlugin() {\n * \treturn el(\n * \t\tPluginDocumentSettingPanel,\n * \t\t{\n * \t\t\tclassName: 'my-document-setting-plugin',\n * \t\t\ttitle: 'My Panel',\n * \t\t\tname: 'my-panel',\n * \t\t},\n * \t\t__( 'My Document Setting Panel' )\n * \t);\n * }\n *\n * registerPlugin( 'my-document-setting-plugin', {\n * \t\trender: MyDocumentSettingPlugin\n * } );\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { registerPlugin } from '@wordpress/plugins';\n * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';\n *\n * const MyDocumentSettingTest = () => (\n * \t\t<PluginDocumentSettingPanel className=\"my-document-setting-plugin\" title=\"My Panel\" name=\"my-panel\">\n *\t\t\t<p>My Document Setting Panel</p>\n *\t\t</PluginDocumentSettingPanel>\n *\t);\n *\n * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );\n * ```\n *\n * @return {Component} The component to be rendered.\n */\nconst PluginDocumentSettingPanel = ( {\n\tname,\n\tclassName,\n\ttitle,\n\ticon,\n\tchildren,\n} ) => {\n\tconst { name: pluginName } = usePluginContext();\n\tconst panelName = `${ pluginName }/${ name }`;\n\tconst { opened, isEnabled } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isEditorPanelOpened, isEditorPanelEnabled } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\topened: isEditorPanelOpened( panelName ),\n\t\t\t\tisEnabled: isEditorPanelEnabled( panelName ),\n\t\t\t};\n\t\t},\n\t\t[ panelName ]\n\t);\n\tconst { toggleEditorPanelOpened } = useDispatch( editorStore );\n\n\tif ( undefined === name ) {\n\t\twarning( 'PluginDocumentSettingPanel requires a name property.' );\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<EnablePluginDocumentSettingPanelOption\n\t\t\t\tlabel={ title }\n\t\t\t\tpanelName={ panelName }\n\t\t\t/>\n\t\t\t<Fill>\n\t\t\t\t{ isEnabled && (\n\t\t\t\t\t<PanelBody\n\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\ttitle={ title }\n\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\topened={ opened }\n\t\t\t\t\t\tonToggle={ () => toggleEditorPanelOpened( panelName ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</PanelBody>\n\t\t\t\t) }\n\t\t\t</Fill>\n\t\t</>\n\t);\n};\n\nPluginDocumentSettingPanel.Slot = Slot;\n\nexport default PluginDocumentSettingPanel;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,cAAc,EAAEC,SAAS,QAAQ,uBAAuB;AACjE,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,OAAOC,OAAO,MAAM,oBAAoB;AACxC,SACCC,KAAK,IAAIC,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;;AAE1B;AACA;AACA;AACA,SAASC,MAAM,QAAQ,sBAAsB;AAE7C,MAAM;EAAEC,IAAI;EAAEC;AAAK,CAAC,GAAGZ,cAAc,CAAE,4BAA6B,CAAC;AACrE,MAAM;EAAEa;AAAuC,CAAC,GAAGH,MAAM,CAAED,iBAAkB,CAAC;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,0BAA0B,GAAGA,CAAE;EACpCC,IAAI;EACJC,SAAS;EACTC,KAAK;EACLC,IAAI;EACJC;AACD,CAAC,KAAM;EACN,MAAM;IAAEJ,IAAI,EAAEK;EAAW,CAAC,GAAGlB,gBAAgB,CAAC,CAAC;EAC/C,MAAMmB,SAAS,GAAI,GAAGD,UAAY,IAAIL,IAAM,EAAC;EAC7C,MAAM;IAAEO,MAAM;IAAEC;EAAU,CAAC,GAAGnB,SAAS,CACpCoB,MAAM,IAAM;IACb,MAAM;MAAEC,mBAAmB;MAAEC;IAAqB,CAAC,GAClDF,MAAM,CAAEjB,WAAY,CAAC;IAEtB,OAAO;MACNe,MAAM,EAAEG,mBAAmB,CAAEJ,SAAU,CAAC;MACxCE,SAAS,EAAEG,oBAAoB,CAAEL,SAAU;IAC5C,CAAC;EACF,CAAC,EACD,CAAEA,SAAS,CACZ,CAAC;EACD,MAAM;IAAEM;EAAwB,CAAC,GAAGxB,WAAW,CAAEI,WAAY,CAAC;EAE9D,IAAKqB,SAAS,KAAKb,IAAI,EAAG;IACzB,OAAAc,YAAA,oBAAAA,YAAA,YAAAxB,OAAO,CAAE,sDAAuD,CAAC;EAClE;EAEA,OACCyB,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACjB,sCAAsC;IACtCmB,KAAK,EAAGf,KAAO;IACfI,SAAS,EAAGA;EAAW,CACvB,CAAC,EACFS,aAAA,CAACnB,IAAI,QACFY,SAAS,IACVO,aAAA,CAAC7B,SAAS;IACTe,SAAS,EAAGA,SAAW;IACvBC,KAAK,EAAGA,KAAO;IACfC,IAAI,EAAGA,IAAM;IACbI,MAAM,EAAGA,MAAQ;IACjBW,QAAQ,EAAGA,CAAA,KAAMN,uBAAuB,CAAEN,SAAU;EAAG,GAErDF,QACQ,CAEP,CACL,CAAC;AAEL,CAAC;AAEDL,0BAA0B,CAACF,IAAI,GAAGA,IAAI;AAEtC,eAAeE,0BAA0B"}
@@ -1,29 +0,0 @@
1
- import { createElement } from "react";
2
- /**
3
- * WordPress dependencies
4
- */
5
- import { Icon, layout } from '@wordpress/icons';
6
- import { useSelect } from '@wordpress/data';
7
- import { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';
8
- import { store as editorStore } from '@wordpress/editor';
9
- function TemplateSummary() {
10
- const template = useSelect(select => {
11
- const {
12
- getCurrentPost
13
- } = select(editorStore);
14
- return getCurrentPost();
15
- }, []);
16
- if (!template) {
17
- return null;
18
- }
19
- return createElement(PanelBody, null, createElement(Flex, {
20
- align: "flex-start",
21
- gap: "3"
22
- }, createElement(FlexItem, null, createElement(Icon, {
23
- icon: layout
24
- })), createElement(FlexBlock, null, createElement("h2", {
25
- className: "edit-post-template-summary__title"
26
- }, template?.title || template?.slug), createElement("p", null, template?.description))));
27
- }
28
- export default TemplateSummary;
29
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Icon","layout","useSelect","Flex","FlexItem","FlexBlock","PanelBody","store","editorStore","TemplateSummary","template","select","getCurrentPost","createElement","align","gap","icon","className","title","slug","description"],"sources":["@wordpress/edit-post/src/components/sidebar/template-summary/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Icon, layout } from '@wordpress/icons';\nimport { useSelect } from '@wordpress/data';\nimport { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';\nimport { store as editorStore } from '@wordpress/editor';\n\nfunction TemplateSummary() {\n\tconst template = useSelect( ( select ) => {\n\t\tconst { getCurrentPost } = select( editorStore );\n\t\treturn getCurrentPost();\n\t}, [] );\n\n\tif ( ! template ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PanelBody>\n\t\t\t<Flex align=\"flex-start\" gap=\"3\">\n\t\t\t\t<FlexItem>\n\t\t\t\t\t<Icon icon={ layout } />\n\t\t\t\t</FlexItem>\n\n\t\t\t\t<FlexBlock>\n\t\t\t\t\t<h2 className=\"edit-post-template-summary__title\">\n\t\t\t\t\t\t{ template?.title || template?.slug }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p>{ template?.description }</p>\n\t\t\t\t</FlexBlock>\n\t\t\t</Flex>\n\t\t</PanelBody>\n\t);\n}\n\nexport default TemplateSummary;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,IAAI,EAAEC,MAAM,QAAQ,kBAAkB;AAC/C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,IAAI,EAAEC,QAAQ,EAAEC,SAAS,EAAEC,SAAS,QAAQ,uBAAuB;AAC5E,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AAExD,SAASC,eAAeA,CAAA,EAAG;EAC1B,MAAMC,QAAQ,GAAGR,SAAS,CAAIS,MAAM,IAAM;IACzC,MAAM;MAAEC;IAAe,CAAC,GAAGD,MAAM,CAAEH,WAAY,CAAC;IAChD,OAAOI,cAAc,CAAC,CAAC;EACxB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAEF,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OACCG,aAAA,CAACP,SAAS,QACTO,aAAA,CAACV,IAAI;IAACW,KAAK,EAAC,YAAY;IAACC,GAAG,EAAC;EAAG,GAC/BF,aAAA,CAACT,QAAQ,QACRS,aAAA,CAACb,IAAI;IAACgB,IAAI,EAAGf;EAAQ,CAAE,CACd,CAAC,EAEXY,aAAA,CAACR,SAAS,QACTQ,aAAA;IAAII,SAAS,EAAC;EAAmC,GAC9CP,QAAQ,EAAEQ,KAAK,IAAIR,QAAQ,EAAES,IAC5B,CAAC,EACLN,aAAA,YAAKH,QAAQ,EAAEU,WAAgB,CACrB,CACN,CACI,CAAC;AAEd;AAEA,eAAeX,eAAe"}
@@ -1,108 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { BlockSettingsMenuControls } from '@wordpress/block-editor';
5
- import { MenuItem } from '@wordpress/components';
6
- import { compose } from '@wordpress/compose';
7
-
8
- const isEverySelectedBlockAllowed = ( selected, allowed ) =>
9
- selected.filter( ( id ) => ! allowed.includes( id ) ).length === 0;
10
-
11
- /**
12
- * Plugins may want to add an item to the menu either for every block
13
- * or only for the specific ones provided in the `allowedBlocks` component property.
14
- *
15
- * If there are multiple blocks selected the item will be rendered if every block
16
- * is of one allowed type (not necessarily the same).
17
- *
18
- * @param {string[]} selectedBlocks Array containing the names of the blocks selected
19
- * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
20
- * @return {boolean} Whether the item will be rendered or not.
21
- */
22
- const shouldRenderItem = ( selectedBlocks, allowedBlocks ) =>
23
- ! Array.isArray( allowedBlocks ) ||
24
- isEverySelectedBlockAllowed( selectedBlocks, allowedBlocks );
25
-
26
- /**
27
- * Renders a new item in the block settings menu.
28
- *
29
- * @param {Object} props Component props.
30
- * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
31
- * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
32
- * @param {string} props.label The menu item text.
33
- * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
34
- * @param {boolean} [props.small] Whether to render the label or not.
35
- * @param {string} [props.role] The ARIA role for the menu item.
36
- *
37
- * @example
38
- * ```js
39
- * // Using ES5 syntax
40
- * var __ = wp.i18n.__;
41
- * var PluginBlockSettingsMenuItem = wp.editPost.PluginBlockSettingsMenuItem;
42
- *
43
- * function doOnClick(){
44
- * // To be called when the user clicks the menu item.
45
- * }
46
- *
47
- * function MyPluginBlockSettingsMenuItem() {
48
- * return React.createElement(
49
- * PluginBlockSettingsMenuItem,
50
- * {
51
- * allowedBlocks: [ 'core/paragraph' ],
52
- * icon: 'dashicon-name',
53
- * label: __( 'Menu item text' ),
54
- * onClick: doOnClick,
55
- * }
56
- * );
57
- * }
58
- * ```
59
- *
60
- * @example
61
- * ```jsx
62
- * // Using ESNext syntax
63
- * import { __ } from '@wordpress/i18n';
64
- * import { PluginBlockSettingsMenuItem } from '@wordpress/edit-post';
65
- *
66
- * const doOnClick = ( ) => {
67
- * // To be called when the user clicks the menu item.
68
- * };
69
- *
70
- * const MyPluginBlockSettingsMenuItem = () => (
71
- * <PluginBlockSettingsMenuItem
72
- * allowedBlocks={ [ 'core/paragraph' ] }
73
- * icon='dashicon-name'
74
- * label={ __( 'Menu item text' ) }
75
- * onClick={ doOnClick } />
76
- * );
77
- * ```
78
- *
79
- * @return {Component} The component to be rendered.
80
- */
81
- const PluginBlockSettingsMenuItem = ( {
82
- allowedBlocks,
83
- icon,
84
- label,
85
- onClick,
86
- small,
87
- role,
88
- } ) => (
89
- <BlockSettingsMenuControls>
90
- { ( { selectedBlocks, onClose } ) => {
91
- if ( ! shouldRenderItem( selectedBlocks, allowedBlocks ) ) {
92
- return null;
93
- }
94
- return (
95
- <MenuItem
96
- onClick={ compose( onClick, onClose ) }
97
- icon={ icon }
98
- label={ small ? label : undefined }
99
- role={ role }
100
- >
101
- { ! small && label }
102
- </MenuItem>
103
- );
104
- } }
105
- </BlockSettingsMenuControls>
106
- );
107
-
108
- export default PluginBlockSettingsMenuItem;
@@ -1,125 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { createSlotFill, PanelBody } from '@wordpress/components';
5
- import { usePluginContext } from '@wordpress/plugins';
6
- import { useDispatch, useSelect } from '@wordpress/data';
7
- import warning from '@wordpress/warning';
8
- import {
9
- store as editorStore,
10
- privateApis as editorPrivateApis,
11
- } from '@wordpress/editor';
12
-
13
- /**
14
- * Internal dependencies
15
- */
16
- import { unlock } from '../../../lock-unlock';
17
-
18
- const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
19
- const { EnablePluginDocumentSettingPanelOption } = unlock( editorPrivateApis );
20
-
21
- /**
22
- * Renders items below the Status & Availability panel in the Document Sidebar.
23
- *
24
- * @param {Object} props Component properties.
25
- * @param {string} props.name Required. A machine-friendly name for the panel.
26
- * @param {string} [props.className] An optional class name added to the row.
27
- * @param {string} [props.title] The title of the panel
28
- * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
29
- * @param {Element} props.children Children to be rendered
30
- *
31
- * @example
32
- * ```js
33
- * // Using ES5 syntax
34
- * var el = React.createElement;
35
- * var __ = wp.i18n.__;
36
- * var registerPlugin = wp.plugins.registerPlugin;
37
- * var PluginDocumentSettingPanel = wp.editPost.PluginDocumentSettingPanel;
38
- *
39
- * function MyDocumentSettingPlugin() {
40
- * return el(
41
- * PluginDocumentSettingPanel,
42
- * {
43
- * className: 'my-document-setting-plugin',
44
- * title: 'My Panel',
45
- * name: 'my-panel',
46
- * },
47
- * __( 'My Document Setting Panel' )
48
- * );
49
- * }
50
- *
51
- * registerPlugin( 'my-document-setting-plugin', {
52
- * render: MyDocumentSettingPlugin
53
- * } );
54
- * ```
55
- *
56
- * @example
57
- * ```jsx
58
- * // Using ESNext syntax
59
- * import { registerPlugin } from '@wordpress/plugins';
60
- * import { PluginDocumentSettingPanel } from '@wordpress/edit-post';
61
- *
62
- * const MyDocumentSettingTest = () => (
63
- * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
64
- * <p>My Document Setting Panel</p>
65
- * </PluginDocumentSettingPanel>
66
- * );
67
- *
68
- * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
69
- * ```
70
- *
71
- * @return {Component} The component to be rendered.
72
- */
73
- const PluginDocumentSettingPanel = ( {
74
- name,
75
- className,
76
- title,
77
- icon,
78
- children,
79
- } ) => {
80
- const { name: pluginName } = usePluginContext();
81
- const panelName = `${ pluginName }/${ name }`;
82
- const { opened, isEnabled } = useSelect(
83
- ( select ) => {
84
- const { isEditorPanelOpened, isEditorPanelEnabled } =
85
- select( editorStore );
86
-
87
- return {
88
- opened: isEditorPanelOpened( panelName ),
89
- isEnabled: isEditorPanelEnabled( panelName ),
90
- };
91
- },
92
- [ panelName ]
93
- );
94
- const { toggleEditorPanelOpened } = useDispatch( editorStore );
95
-
96
- if ( undefined === name ) {
97
- warning( 'PluginDocumentSettingPanel requires a name property.' );
98
- }
99
-
100
- return (
101
- <>
102
- <EnablePluginDocumentSettingPanelOption
103
- label={ title }
104
- panelName={ panelName }
105
- />
106
- <Fill>
107
- { isEnabled && (
108
- <PanelBody
109
- className={ className }
110
- title={ title }
111
- icon={ icon }
112
- opened={ opened }
113
- onToggle={ () => toggleEditorPanelOpened( panelName ) }
114
- >
115
- { children }
116
- </PanelBody>
117
- ) }
118
- </Fill>
119
- </>
120
- );
121
- };
122
-
123
- PluginDocumentSettingPanel.Slot = Slot;
124
-
125
- export default PluginDocumentSettingPanel;
@@ -1,39 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`PluginPostPublishPanel renders fill properly 1`] = `
4
- <div>
5
- <div
6
- class="components-panel__body my-plugin-post-publish-panel is-opened"
7
- >
8
- <h2
9
- class="components-panel__body-title"
10
- >
11
- <button
12
- aria-expanded="true"
13
- class="components-button components-panel__body-toggle"
14
- type="button"
15
- >
16
- <span
17
- aria-hidden="true"
18
- >
19
- <svg
20
- aria-hidden="true"
21
- class="components-panel__arrow"
22
- focusable="false"
23
- height="24"
24
- viewBox="0 0 24 24"
25
- width="24"
26
- xmlns="http://www.w3.org/2000/svg"
27
- >
28
- <path
29
- d="M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
30
- />
31
- </svg>
32
- </span>
33
- My panel title
34
- </button>
35
- </h2>
36
- My panel content
37
- </div>
38
- </div>
39
- `;
@@ -1,33 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { render } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { SlotFillProvider } from '@wordpress/components';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import PluginPostPublishPanel from '../';
15
-
16
- describe( 'PluginPostPublishPanel', () => {
17
- test( 'renders fill properly', () => {
18
- const { container } = render(
19
- <SlotFillProvider>
20
- <PluginPostPublishPanel
21
- className="my-plugin-post-publish-panel"
22
- title="My panel title"
23
- initialOpen
24
- >
25
- My panel content
26
- </PluginPostPublishPanel>
27
- <PluginPostPublishPanel.Slot />
28
- </SlotFillProvider>
29
- );
30
-
31
- expect( container ).toMatchSnapshot();
32
- } );
33
- } );
@@ -1,33 +0,0 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { render, screen } from '@testing-library/react';
5
-
6
- /**
7
- * WordPress dependencies
8
- */
9
- import { SlotFillProvider } from '@wordpress/components';
10
-
11
- /**
12
- * Internal dependencies
13
- */
14
- import PluginPrePublishPanel from '../';
15
-
16
- describe( 'PluginPrePublishPanel', () => {
17
- test( 'renders fill properly', () => {
18
- render(
19
- <SlotFillProvider>
20
- <PluginPrePublishPanel
21
- className="my-plugin-pre-publish-panel"
22
- title="My panel title"
23
- initialOpen
24
- >
25
- My panel content
26
- </PluginPrePublishPanel>
27
- <PluginPrePublishPanel.Slot />
28
- </SlotFillProvider>
29
- );
30
-
31
- expect( screen.getByText( 'My panel title' ) ).toBeVisible();
32
- } );
33
- } );
@@ -1,37 +0,0 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { Icon, layout } from '@wordpress/icons';
5
- import { useSelect } from '@wordpress/data';
6
- import { Flex, FlexItem, FlexBlock, PanelBody } from '@wordpress/components';
7
- import { store as editorStore } from '@wordpress/editor';
8
-
9
- function TemplateSummary() {
10
- const template = useSelect( ( select ) => {
11
- const { getCurrentPost } = select( editorStore );
12
- return getCurrentPost();
13
- }, [] );
14
-
15
- if ( ! template ) {
16
- return null;
17
- }
18
-
19
- return (
20
- <PanelBody>
21
- <Flex align="flex-start" gap="3">
22
- <FlexItem>
23
- <Icon icon={ layout } />
24
- </FlexItem>
25
-
26
- <FlexBlock>
27
- <h2 className="edit-post-template-summary__title">
28
- { template?.title || template?.slug }
29
- </h2>
30
- <p>{ template?.description }</p>
31
- </FlexBlock>
32
- </Flex>
33
- </PanelBody>
34
- );
35
- }
36
-
37
- export default TemplateSummary;
@@ -1,5 +0,0 @@
1
- h2.edit-post-template-summary__title {
2
- line-height: $icon-size;
3
- margin: 0 0 $grid-unit-05;
4
- font-weight: 500;
5
- }