@wordpress/edit-post 7.32.0 → 7.34.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/README.md +17 -223
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/editor-initialization/index.js +0 -1
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +1 -38
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +20 -51
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/index.native.js +1 -1
- package/build/components/header/index.native.js.map +1 -1
- package/build/components/header/main-dashboard-button/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +17 -42
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/more-menu/manage-patterns-menu-item.js +40 -0
- package/build/components/header/more-menu/manage-patterns-menu-item.js.map +1 -0
- package/build/{plugins/welcome-guide-menu-item/index.js → components/header/more-menu/welcome-guide-menu-item.js} +1 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build/components/init-pattern-modal/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +0 -123
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +28 -29
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/enable-panel.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -32
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/sidebar/post-format/index.js.map +1 -1
- package/build/components/sidebar/post-pending-status/index.js.map +1 -1
- package/build/components/sidebar/post-slug/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +35 -12
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/post-sticky/index.js.map +1 -1
- package/build/components/sidebar/post-trash/index.js.map +1 -1
- package/build/components/sidebar/post-visibility/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +68 -41
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/components/visual-editor/block-inspector-button.js +1 -1
- package/build/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/components/visual-editor/index.js +4 -1
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/visual-editor/index.native.js.map +1 -1
- package/build/components/visual-editor/use-padding-appender.js +62 -0
- package/build/components/visual-editor/use-padding-appender.js.map +1 -0
- package/build/components/welcome-guide/default.js.map +1 -1
- package/build/components/welcome-guide/image.js.map +1 -1
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/deprecated.js +132 -0
- package/build/deprecated.js.map +1 -0
- package/build/editor.js +2 -2
- package/build/editor.js.map +1 -1
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +5 -22
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/components/index.js.map +1 -1
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build/hooks/validate-multiple-use/index.js.map +1 -1
- package/build/index.js +19 -62
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +10 -8
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +34 -19
- package/build/store/selectors.js.map +1 -1
- package/build/utils/meta-boxes.js.map +1 -1
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +1 -2
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +2 -38
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/fullscreen-mode-close/index.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +22 -53
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/index.native.js +1 -1
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/header/main-dashboard-button/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +17 -42
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/more-menu/manage-patterns-menu-item.js +33 -0
- package/build-module/components/header/more-menu/manage-patterns-menu-item.js.map +1 -0
- package/build-module/{plugins/welcome-guide-menu-item/index.js → components/header/more-menu/welcome-guide-menu-item.js} +1 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build-module/components/init-pattern-modal/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -124
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +28 -29
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/enable-panel.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -32
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/sidebar/post-format/index.js.map +1 -1
- package/build-module/components/sidebar/post-pending-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-slug/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +36 -14
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/post-sticky/index.js.map +1 -1
- package/build-module/components/sidebar/post-trash/index.js.map +1 -1
- package/build-module/components/sidebar/post-visibility/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +71 -44
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js +1 -1
- package/build-module/components/visual-editor/block-inspector-button.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js.map +1 -1
- package/build-module/components/visual-editor/index.js +4 -1
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/visual-editor/index.native.js.map +1 -1
- package/build-module/components/visual-editor/use-padding-appender.js +55 -0
- package/build-module/components/visual-editor/use-padding-appender.js.map +1 -0
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/deprecated.js +116 -0
- package/build-module/deprecated.js.map +1 -0
- package/build-module/editor.js +2 -2
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +7 -24
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/components/index.js.map +1 -1
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/use-navigate-to-entity-record.js.map +1 -1
- package/build-module/hooks/validate-multiple-use/index.js.map +1 -1
- package/build-module/index.js +2 -15
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +8 -7
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +33 -18
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/meta-boxes.js.map +1 -1
- package/build-style/classic-rtl.css +2 -2
- package/build-style/classic.css +2 -2
- package/build-style/style-rtl.css +18 -589
- package/build-style/style.css +18 -589
- package/package.json +32 -34
- package/src/classic.scss +1 -1
- package/src/components/editor-initialization/index.js +1 -5
- package/src/components/editor-initialization/listener-hooks.js +1 -40
- package/src/components/editor-initialization/test/listener-hooks.js +1 -96
- package/src/components/header/index.js +25 -71
- package/src/components/header/index.native.js +1 -1
- package/src/components/header/more-menu/index.js +27 -43
- package/src/components/header/more-menu/manage-patterns-menu-item.js +33 -0
- package/src/components/header/style.scss +5 -82
- package/src/components/keyboard-shortcuts/index.js +2 -148
- package/src/components/layout/index.js +26 -47
- package/src/components/layout/style.scss +7 -80
- package/src/components/preferences-modal/index.js +3 -46
- package/src/components/sidebar/post-status/index.js +61 -24
- package/src/components/sidebar/settings-sidebar/index.js +113 -73
- package/src/components/visual-editor/block-inspector-button.js +1 -1
- package/src/components/visual-editor/index.js +4 -0
- package/src/components/visual-editor/use-padding-appender.js +66 -0
- package/src/deprecated.js +107 -0
- package/src/editor.js +2 -2
- package/src/hooks/commands/use-common-commands.js +11 -26
- package/src/index.js +3 -20
- package/src/store/actions.js +10 -12
- package/src/store/selectors.js +41 -33
- package/src/store/test/actions.js +11 -10
- package/src/style.scss +1 -19
- package/build/components/header/plugin-more-menu-item/index.js +0 -78
- package/build/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build/components/header/plugin-sidebar-more-menu-item/index.js +0 -71
- package/build/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build/components/header/post-publish-button-or-toggle.js +0 -91
- package/build/components/header/post-publish-button-or-toggle.js.map +0 -1
- package/build/components/header/preferences-menu-item/index.js +0 -31
- package/build/components/header/preferences-menu-item/index.js.map +0 -1
- package/build/components/header/tools-more-menu-group/index.js +0 -26
- package/build/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build/components/header/writing-menu/index.js +0 -71
- package/build/components/header/writing-menu/index.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/config.js +0 -78
- package/build/components/keyboard-shortcut-help-modal/config.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -49
- package/build/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +0 -132
- package/build/components/keyboard-shortcut-help-modal/index.js.map +0 -1
- package/build/components/keyboard-shortcut-help-modal/shortcut.js +0 -55
- package/build/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
- package/build/components/layout/actions-panel.js +0 -86
- package/build/components/layout/actions-panel.js.map +0 -1
- package/build/components/preferences-modal/enable-publish-sidebar.js +0 -38
- package/build/components/preferences-modal/enable-publish-sidebar.js.map +0 -1
- package/build/components/sidebar/plugin-post-publish-panel/index.js +0 -39
- package/build/components/sidebar/plugin-post-publish-panel/index.js.map +0 -1
- package/build/components/sidebar/plugin-post-status-info/index.js +0 -73
- package/build/components/sidebar/plugin-post-status-info/index.js.map +0 -1
- package/build/components/sidebar/plugin-pre-publish-panel/index.js +0 -43
- package/build/components/sidebar/plugin-pre-publish-panel/index.js.map +0 -1
- package/build/components/sidebar/plugin-sidebar/index.js +0 -104
- package/build/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build/components/start-page-options/index.js +0 -107
- package/build/components/start-page-options/index.js.map +0 -1
- package/build/plugins/copy-content-menu-item/index.js +0 -39
- package/build/plugins/copy-content-menu-item/index.js.map +0 -1
- package/build/plugins/index.js +0 -69
- package/build/plugins/index.js.map +0 -1
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js +0 -41
- package/build/plugins/keyboard-shortcuts-help-menu-item/index.js.map +0 -1
- package/build/plugins/welcome-guide-menu-item/index.js.map +0 -1
- package/build-module/components/header/plugin-more-menu-item/index.js +0 -73
- package/build-module/components/header/plugin-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js +0 -65
- package/build-module/components/header/plugin-sidebar-more-menu-item/index.js.map +0 -1
- package/build-module/components/header/post-publish-button-or-toggle.js +0 -83
- package/build-module/components/header/post-publish-button-or-toggle.js.map +0 -1
- package/build-module/components/header/preferences-menu-item/index.js +0 -24
- package/build-module/components/header/preferences-menu-item/index.js.map +0 -1
- package/build-module/components/header/tools-more-menu-group/index.js +0 -19
- package/build-module/components/header/tools-more-menu-group/index.js.map +0 -1
- package/build-module/components/header/writing-menu/index.js +0 -64
- package/build-module/components/header/writing-menu/index.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/config.js +0 -71
- package/build-module/components/keyboard-shortcut-help-modal/config.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -41
- package/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +0 -122
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +0 -1
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js +0 -48
- package/build-module/components/keyboard-shortcut-help-modal/shortcut.js.map +0 -1
- package/build-module/components/layout/actions-panel.js +0 -78
- package/build-module/components/layout/actions-panel.js.map +0 -1
- package/build-module/components/preferences-modal/enable-publish-sidebar.js +0 -31
- package/build-module/components/preferences-modal/enable-publish-sidebar.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-publish-panel/index.js +0 -32
- package/build-module/components/sidebar/plugin-post-publish-panel/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-status-info/index.js +0 -66
- package/build-module/components/sidebar/plugin-post-status-info/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-pre-publish-panel/index.js +0 -36
- package/build-module/components/sidebar/plugin-pre-publish-panel/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +0 -98
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +0 -1
- package/build-module/components/start-page-options/index.js +0 -100
- package/build-module/components/start-page-options/index.js.map +0 -1
- package/build-module/plugins/copy-content-menu-item/index.js +0 -32
- package/build-module/plugins/copy-content-menu-item/index.js.map +0 -1
- package/build-module/plugins/index.js +0 -65
- package/build-module/plugins/index.js.map +0 -1
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js +0 -33
- package/build-module/plugins/keyboard-shortcuts-help-menu-item/index.js.map +0 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +0 -1
- package/src/components/header/plugin-more-menu-item/index.js +0 -73
- package/src/components/header/plugin-sidebar-more-menu-item/index.js +0 -64
- package/src/components/header/post-publish-button-or-toggle.js +0 -92
- package/src/components/header/preferences-menu-item/index.js +0 -25
- package/src/components/header/test/index.js +0 -51
- package/src/components/header/tools-more-menu-group/index.js +0 -20
- package/src/components/header/writing-menu/index.js +0 -73
- package/src/components/keyboard-shortcut-help-modal/config.js +0 -53
- package/src/components/keyboard-shortcut-help-modal/dynamic-shortcut.js +0 -43
- package/src/components/keyboard-shortcut-help-modal/index.js +0 -163
- package/src/components/keyboard-shortcut-help-modal/shortcut.js +0 -67
- package/src/components/keyboard-shortcut-help-modal/style.scss +0 -61
- package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -36
- package/src/components/layout/actions-panel.js +0 -103
- package/src/components/preferences-modal/enable-publish-sidebar.js +0 -32
- package/src/components/preferences-modal/test/index.js +0 -28
- package/src/components/sidebar/plugin-post-publish-panel/index.js +0 -28
- package/src/components/sidebar/plugin-post-status-info/index.js +0 -63
- package/src/components/sidebar/plugin-post-status-info/test/__snapshots__/index.js.snap +0 -11
- package/src/components/sidebar/plugin-post-status-info/test/index.js +0 -29
- package/src/components/sidebar/plugin-pre-publish-panel/index.js +0 -32
- package/src/components/sidebar/plugin-sidebar/index.js +0 -94
- package/src/components/start-page-options/index.js +0 -108
- package/src/components/start-page-options/style.scss +0 -26
- package/src/plugins/copy-content-menu-item/index.js +0 -29
- package/src/plugins/index.js +0 -85
- package/src/plugins/keyboard-shortcuts-help-menu-item/index.js +0 -34
- /package/src/{plugins/welcome-guide-menu-item/index.js → components/header/more-menu/welcome-guide-menu-item.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["ComplementaryArea","useSelect","__","store","keyboardShortcutsStore","editorStore","PluginSidebarEditPost","className","props","postTitle","shortcut","select","getEditedPostAttribute","getShortcutRepresentation","createElement","panelClassName","smallScreenTitle","scope","toggleShortcut"],"sources":["@wordpress/edit-post/src/components/sidebar/plugin-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { ComplementaryArea } from '@wordpress/interface';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.\n * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.\n * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:\n *\n * ```js\n * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );\n * ```\n *\n * @see PluginSidebarMoreMenuItem\n *\n * @param {Object} props Element props.\n * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.\n * @param {string} [props.className] An optional class name added to the sidebar body.\n * @param {string} props.title Title displayed at the top of the sidebar.\n * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.\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 *\n * @example\n * ```js\n * // Using ES5 syntax\n * var __ = wp.i18n.__;\n * var el = React.createElement;\n * var PanelBody = wp.components.PanelBody;\n * var PluginSidebar = wp.editPost.PluginSidebar;\n * var moreIcon = React.createElement( 'svg' ); //... svg element.\n *\n * function MyPluginSidebar() {\n * \treturn el(\n * \t\t\tPluginSidebar,\n * \t\t\t{\n * \t\t\t\tname: 'my-sidebar',\n * \t\t\t\ttitle: 'My sidebar title',\n * \t\t\t\ticon: moreIcon,\n * \t\t\t},\n * \t\t\tel(\n * \t\t\t\tPanelBody,\n * \t\t\t\t{},\n * \t\t\t\t__( 'My sidebar content' )\n * \t\t\t)\n * \t);\n * }\n * ```\n *\n * @example\n * ```jsx\n * // Using ESNext syntax\n * import { __ } from '@wordpress/i18n';\n * import { PanelBody } from '@wordpress/components';\n * import { PluginSidebar } from '@wordpress/edit-post';\n * import { more } from '@wordpress/icons';\n *\n * const MyPluginSidebar = () => (\n * \t<PluginSidebar\n * \t\tname=\"my-sidebar\"\n * \t\ttitle=\"My sidebar title\"\n * \t\ticon={ more }\n * \t>\n * \t\t<PanelBody>\n * \t\t\t{ __( 'My sidebar content' ) }\n * \t\t</PanelBody>\n * \t</PluginSidebar>\n * );\n * ```\n */\nexport default function PluginSidebarEditPost( { className, ...props } ) {\n\tconst { postTitle, shortcut } = useSelect( ( select ) => {\n\t\treturn {\n\t\t\tpostTitle: select( editorStore ).getEditedPostAttribute( 'title' ),\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/edit-post/toggle-sidebar' ),\n\t\t};\n\t}, [] );\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tpanelClassName={ className }\n\t\t\tclassName=\"edit-post-sidebar\"\n\t\t\tsmallScreenTitle={ postTitle || __( '(no title)' ) }\n\t\t\tscope=\"core/edit-post\"\n\t\t\ttoggleShortcut={ shortcut }\n\t\t\t{ ...props }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,sBAAsB,QAAQ,+BAA+B;AAC/E,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;;AAExD;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAE;EAAEC,SAAS;EAAE,GAAGC;AAAM,CAAC,EAAG;EACxE,MAAM;IAAEC,SAAS;IAAEC;EAAS,CAAC,GAAGT,SAAS,CAAIU,MAAM,IAAM;IACxD,OAAO;MACNF,SAAS,EAAEE,MAAM,CAAEN,WAAY,CAAC,CAACO,sBAAsB,CAAE,OAAQ,CAAC;MAClEF,QAAQ,EAAEC,MAAM,CACfP,sBACD,CAAC,CAACS,yBAAyB,CAAE,+BAAgC;IAC9D,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EACP,OACCC,aAAA,CAACd,iBAAiB;IACjBe,cAAc,EAAGR,SAAW;IAC5BA,SAAS,EAAC,mBAAmB;IAC7BS,gBAAgB,EAAGP,SAAS,IAAIP,EAAE,CAAE,YAAa,CAAG;IACpDe,KAAK,EAAC,gBAAgB;IACtBC,cAAc,EAAGR,QAAU;IAAA,GACtBF;EAAK,CACV,CAAC;AAEJ"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { Modal } from '@wordpress/components';
|
|
6
|
-
import { __ } from '@wordpress/i18n';
|
|
7
|
-
import { useState, useMemo } from '@wordpress/element';
|
|
8
|
-
import { store as blockEditorStore, __experimentalBlockPatternsList as BlockPatternsList } from '@wordpress/block-editor';
|
|
9
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import { useAsyncList } from '@wordpress/compose';
|
|
11
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import { store as editPostStore } from '../../store';
|
|
17
|
-
function useStartPatterns() {
|
|
18
|
-
// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
|
|
19
|
-
// and it has no postTypes declared and the current post type is page or if
|
|
20
|
-
// the current post type is part of the postTypes declared.
|
|
21
|
-
const {
|
|
22
|
-
blockPatternsWithPostContentBlockType,
|
|
23
|
-
postType
|
|
24
|
-
} = useSelect(select => {
|
|
25
|
-
const {
|
|
26
|
-
getPatternsByBlockTypes
|
|
27
|
-
} = select(blockEditorStore);
|
|
28
|
-
const {
|
|
29
|
-
getCurrentPostType
|
|
30
|
-
} = select(editorStore);
|
|
31
|
-
return {
|
|
32
|
-
blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content'),
|
|
33
|
-
postType: getCurrentPostType()
|
|
34
|
-
};
|
|
35
|
-
}, []);
|
|
36
|
-
return useMemo(() => {
|
|
37
|
-
// filter patterns without postTypes declared if the current postType is page
|
|
38
|
-
// or patterns that declare the current postType in its post type array.
|
|
39
|
-
return blockPatternsWithPostContentBlockType.filter(pattern => {
|
|
40
|
-
return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
|
|
41
|
-
});
|
|
42
|
-
}, [postType, blockPatternsWithPostContentBlockType]);
|
|
43
|
-
}
|
|
44
|
-
function PatternSelection({
|
|
45
|
-
blockPatterns,
|
|
46
|
-
onChoosePattern
|
|
47
|
-
}) {
|
|
48
|
-
const shownBlockPatterns = useAsyncList(blockPatterns);
|
|
49
|
-
const {
|
|
50
|
-
resetEditorBlocks
|
|
51
|
-
} = useDispatch(editorStore);
|
|
52
|
-
return createElement(BlockPatternsList, {
|
|
53
|
-
blockPatterns: blockPatterns,
|
|
54
|
-
shownPatterns: shownBlockPatterns,
|
|
55
|
-
onClickPattern: (_pattern, blocks) => {
|
|
56
|
-
resetEditorBlocks(blocks);
|
|
57
|
-
onChoosePattern();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
function StartPageOptionsModal({
|
|
62
|
-
onClose
|
|
63
|
-
}) {
|
|
64
|
-
const startPatterns = useStartPatterns();
|
|
65
|
-
const hasStartPattern = startPatterns.length > 0;
|
|
66
|
-
if (!hasStartPattern) {
|
|
67
|
-
return null;
|
|
68
|
-
}
|
|
69
|
-
return createElement(Modal, {
|
|
70
|
-
className: "edit-post-start-page-options__modal",
|
|
71
|
-
title: __('Choose a pattern'),
|
|
72
|
-
isFullScreen: true,
|
|
73
|
-
onRequestClose: onClose
|
|
74
|
-
}, createElement("div", {
|
|
75
|
-
className: "edit-post-start-page-options__modal-content"
|
|
76
|
-
}, createElement(PatternSelection, {
|
|
77
|
-
blockPatterns: startPatterns,
|
|
78
|
-
onChoosePattern: onClose
|
|
79
|
-
})));
|
|
80
|
-
}
|
|
81
|
-
export default function StartPageOptions() {
|
|
82
|
-
const [isClosed, setIsClosed] = useState(false);
|
|
83
|
-
const shouldEnableModal = useSelect(select => {
|
|
84
|
-
const {
|
|
85
|
-
isCleanNewPost,
|
|
86
|
-
getRenderingMode
|
|
87
|
-
} = select(editorStore);
|
|
88
|
-
const {
|
|
89
|
-
isFeatureActive
|
|
90
|
-
} = select(editPostStore);
|
|
91
|
-
return getRenderingMode() === 'post-only' && !isFeatureActive('welcomeGuide') && isCleanNewPost();
|
|
92
|
-
}, []);
|
|
93
|
-
if (!shouldEnableModal || isClosed) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
return createElement(StartPageOptionsModal, {
|
|
97
|
-
onClose: () => setIsClosed(true)
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["Modal","__","useState","useMemo","store","blockEditorStore","__experimentalBlockPatternsList","BlockPatternsList","useSelect","useDispatch","useAsyncList","editorStore","editPostStore","useStartPatterns","blockPatternsWithPostContentBlockType","postType","select","getPatternsByBlockTypes","getCurrentPostType","filter","pattern","postTypes","Array","isArray","includes","PatternSelection","blockPatterns","onChoosePattern","shownBlockPatterns","resetEditorBlocks","createElement","shownPatterns","onClickPattern","_pattern","blocks","StartPageOptionsModal","onClose","startPatterns","hasStartPattern","length","className","title","isFullScreen","onRequestClose","StartPageOptions","isClosed","setIsClosed","shouldEnableModal","isCleanNewPost","getRenderingMode","isFeatureActive"],"sources":["@wordpress/edit-post/src/components/start-page-options/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useState, useMemo } from '@wordpress/element';\nimport {\n\tstore as blockEditorStore,\n\t__experimentalBlockPatternsList as BlockPatternsList,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useAsyncList } from '@wordpress/compose';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction useStartPatterns() {\n\t// A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,\n\t// and it has no postTypes declared and the current post type is page or if\n\t// the current post type is part of the postTypes declared.\n\tconst { blockPatternsWithPostContentBlockType, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getPatternsByBlockTypes } = select( blockEditorStore );\n\t\t\tconst { getCurrentPostType } = select( editorStore );\n\t\t\treturn {\n\t\t\t\tblockPatternsWithPostContentBlockType:\n\t\t\t\t\tgetPatternsByBlockTypes( 'core/post-content' ),\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\treturn useMemo( () => {\n\t\t// filter patterns without postTypes declared if the current postType is page\n\t\t// or patterns that declare the current postType in its post type array.\n\t\treturn blockPatternsWithPostContentBlockType.filter( ( pattern ) => {\n\t\t\treturn (\n\t\t\t\t( postType === 'page' && ! pattern.postTypes ) ||\n\t\t\t\t( Array.isArray( pattern.postTypes ) &&\n\t\t\t\t\tpattern.postTypes.includes( postType ) )\n\t\t\t);\n\t\t} );\n\t}, [ postType, blockPatternsWithPostContentBlockType ] );\n}\n\nfunction PatternSelection( { blockPatterns, onChoosePattern } ) {\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { resetEditorBlocks } = useDispatch( editorStore );\n\treturn (\n\t\t<BlockPatternsList\n\t\t\tblockPatterns={ blockPatterns }\n\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\tonClickPattern={ ( _pattern, blocks ) => {\n\t\t\t\tresetEditorBlocks( blocks );\n\t\t\t\tonChoosePattern();\n\t\t\t} }\n\t\t/>\n\t);\n}\n\nfunction StartPageOptionsModal( { onClose } ) {\n\tconst startPatterns = useStartPatterns();\n\tconst hasStartPattern = startPatterns.length > 0;\n\n\tif ( ! hasStartPattern ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-post-start-page-options__modal\"\n\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\tisFullScreen\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<div className=\"edit-post-start-page-options__modal-content\">\n\t\t\t\t<PatternSelection\n\t\t\t\t\tblockPatterns={ startPatterns }\n\t\t\t\t\tonChoosePattern={ onClose }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Modal>\n\t);\n}\n\nexport default function StartPageOptions() {\n\tconst [ isClosed, setIsClosed ] = useState( false );\n\tconst shouldEnableModal = useSelect( ( select ) => {\n\t\tconst { isCleanNewPost, getRenderingMode } = select( editorStore );\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn (\n\t\t\tgetRenderingMode() === 'post-only' &&\n\t\t\t! isFeatureActive( 'welcomeGuide' ) &&\n\t\t\tisCleanNewPost()\n\t\t);\n\t}, [] );\n\n\tif ( ! shouldEnableModal || isClosed ) {\n\t\treturn null;\n\t}\n\n\treturn <StartPageOptionsModal onClose={ () => setIsClosed( true ) } />;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,EAAEC,OAAO,QAAQ,oBAAoB;AACtD,SACCC,KAAK,IAAIC,gBAAgB,EACzBC,+BAA+B,IAAIC,iBAAiB,QAC9C,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASN,KAAK,IAAIO,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASP,KAAK,IAAIQ,aAAa,QAAQ,aAAa;AAEpD,SAASC,gBAAgBA,CAAA,EAAG;EAC3B;EACA;EACA;EACA,MAAM;IAAEC,qCAAqC;IAAEC;EAAS,CAAC,GAAGP,SAAS,CAClEQ,MAAM,IAAM;IACb,MAAM;MAAEC;IAAwB,CAAC,GAAGD,MAAM,CAAEX,gBAAiB,CAAC;IAC9D,MAAM;MAAEa;IAAmB,CAAC,GAAGF,MAAM,CAAEL,WAAY,CAAC;IACpD,OAAO;MACNG,qCAAqC,EACpCG,uBAAuB,CAAE,mBAAoB,CAAC;MAC/CF,QAAQ,EAAEG,kBAAkB,CAAC;IAC9B,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,OAAOf,OAAO,CAAE,MAAM;IACrB;IACA;IACA,OAAOW,qCAAqC,CAACK,MAAM,CAAIC,OAAO,IAAM;MACnE,OACGL,QAAQ,KAAK,MAAM,IAAI,CAAEK,OAAO,CAACC,SAAS,IAC1CC,KAAK,CAACC,OAAO,CAAEH,OAAO,CAACC,SAAU,CAAC,IACnCD,OAAO,CAACC,SAAS,CAACG,QAAQ,CAAET,QAAS,CAAG;IAE3C,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEA,QAAQ,EAAED,qCAAqC,CAAG,CAAC;AACzD;AAEA,SAASW,gBAAgBA,CAAE;EAAEC,aAAa;EAAEC;AAAgB,CAAC,EAAG;EAC/D,MAAMC,kBAAkB,GAAGlB,YAAY,CAAEgB,aAAc,CAAC;EACxD,MAAM;IAAEG;EAAkB,CAAC,GAAGpB,WAAW,CAAEE,WAAY,CAAC;EACxD,OACCmB,aAAA,CAACvB,iBAAiB;IACjBmB,aAAa,EAAGA,aAAe;IAC/BK,aAAa,EAAGH,kBAAoB;IACpCI,cAAc,EAAGA,CAAEC,QAAQ,EAAEC,MAAM,KAAM;MACxCL,iBAAiB,CAAEK,MAAO,CAAC;MAC3BP,eAAe,CAAC,CAAC;IAClB;EAAG,CACH,CAAC;AAEJ;AAEA,SAASQ,qBAAqBA,CAAE;EAAEC;AAAQ,CAAC,EAAG;EAC7C,MAAMC,aAAa,GAAGxB,gBAAgB,CAAC,CAAC;EACxC,MAAMyB,eAAe,GAAGD,aAAa,CAACE,MAAM,GAAG,CAAC;EAEhD,IAAK,CAAED,eAAe,EAAG;IACxB,OAAO,IAAI;EACZ;EAEA,OACCR,aAAA,CAAC9B,KAAK;IACLwC,SAAS,EAAC,qCAAqC;IAC/CC,KAAK,EAAGxC,EAAE,CAAE,kBAAmB,CAAG;IAClCyC,YAAY;IACZC,cAAc,EAAGP;EAAS,GAE1BN,aAAA;IAAKU,SAAS,EAAC;EAA6C,GAC3DV,aAAA,CAACL,gBAAgB;IAChBC,aAAa,EAAGW,aAAe;IAC/BV,eAAe,EAAGS;EAAS,CAC3B,CACG,CACC,CAAC;AAEV;AAEA,eAAe,SAASQ,gBAAgBA,CAAA,EAAG;EAC1C,MAAM,CAAEC,QAAQ,EAAEC,WAAW,CAAE,GAAG5C,QAAQ,CAAE,KAAM,CAAC;EACnD,MAAM6C,iBAAiB,GAAGvC,SAAS,CAAIQ,MAAM,IAAM;IAClD,MAAM;MAAEgC,cAAc;MAAEC;IAAiB,CAAC,GAAGjC,MAAM,CAAEL,WAAY,CAAC;IAClE,MAAM;MAAEuC;IAAgB,CAAC,GAAGlC,MAAM,CAAEJ,aAAc,CAAC;IAEnD,OACCqC,gBAAgB,CAAC,CAAC,KAAK,WAAW,IAClC,CAAEC,eAAe,CAAE,cAAe,CAAC,IACnCF,cAAc,CAAC,CAAC;EAElB,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAED,iBAAiB,IAAIF,QAAQ,EAAG;IACtC,OAAO,IAAI;EACZ;EAEA,OAAOf,aAAA,CAACK,qBAAqB;IAACC,OAAO,EAAGA,CAAA,KAAMU,WAAW,CAAE,IAAK;EAAG,CAAE,CAAC;AACvE"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { MenuItem } from '@wordpress/components';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { useCopyToClipboard } from '@wordpress/compose';
|
|
9
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
10
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
11
|
-
export default function CopyContentMenuItem() {
|
|
12
|
-
const {
|
|
13
|
-
createNotice
|
|
14
|
-
} = useDispatch(noticesStore);
|
|
15
|
-
const {
|
|
16
|
-
getEditedPostAttribute
|
|
17
|
-
} = useSelect(editorStore);
|
|
18
|
-
function getText() {
|
|
19
|
-
return getEditedPostAttribute('content');
|
|
20
|
-
}
|
|
21
|
-
function onSuccess() {
|
|
22
|
-
createNotice('info', __('All content copied.'), {
|
|
23
|
-
isDismissible: true,
|
|
24
|
-
type: 'snackbar'
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
const ref = useCopyToClipboard(getText, onSuccess);
|
|
28
|
-
return createElement(MenuItem, {
|
|
29
|
-
ref: ref
|
|
30
|
-
}, __('Copy all blocks'));
|
|
31
|
-
}
|
|
32
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MenuItem","useSelect","useDispatch","__","useCopyToClipboard","store","noticesStore","editorStore","CopyContentMenuItem","createNotice","getEditedPostAttribute","getText","onSuccess","isDismissible","type","ref","createElement"],"sources":["@wordpress/edit-post/src/plugins/copy-content-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as editorStore } from '@wordpress/editor';\n\nexport default function CopyContentMenuItem() {\n\tconst { createNotice } = useDispatch( noticesStore );\n\tconst { getEditedPostAttribute } = useSelect( editorStore );\n\n\tfunction getText() {\n\t\treturn getEditedPostAttribute( 'content' );\n\t}\n\n\tfunction onSuccess() {\n\t\tcreateNotice( 'info', __( 'All content copied.' ), {\n\t\t\tisDismissible: true,\n\t\t\ttype: 'snackbar',\n\t\t} );\n\t}\n\n\tconst ref = useCopyToClipboard( getText, onSuccess );\n\n\treturn <MenuItem ref={ ref }>{ __( 'Copy all blocks' ) }</MenuItem>;\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,kBAAkB,QAAQ,oBAAoB;AACvD,SAASC,KAAK,IAAIC,YAAY,QAAQ,oBAAoB;AAC1D,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AAExD,eAAe,SAASC,mBAAmBA,CAAA,EAAG;EAC7C,MAAM;IAAEC;EAAa,CAAC,GAAGP,WAAW,CAAEI,YAAa,CAAC;EACpD,MAAM;IAAEI;EAAuB,CAAC,GAAGT,SAAS,CAAEM,WAAY,CAAC;EAE3D,SAASI,OAAOA,CAAA,EAAG;IAClB,OAAOD,sBAAsB,CAAE,SAAU,CAAC;EAC3C;EAEA,SAASE,SAASA,CAAA,EAAG;IACpBH,YAAY,CAAE,MAAM,EAAEN,EAAE,CAAE,qBAAsB,CAAC,EAAE;MAClDU,aAAa,EAAE,IAAI;MACnBC,IAAI,EAAE;IACP,CAAE,CAAC;EACJ;EAEA,MAAMC,GAAG,GAAGX,kBAAkB,CAAEO,OAAO,EAAEC,SAAU,CAAC;EAEpD,OAAOI,aAAA,CAAChB,QAAQ;IAACe,GAAG,EAAGA;EAAK,GAAGZ,EAAE,CAAE,iBAAkB,CAAa,CAAC;AACpE"}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { createElement, Fragment } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { MenuItem, VisuallyHidden } from '@wordpress/components';
|
|
6
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
-
import { store as editorStore } from '@wordpress/editor';
|
|
8
|
-
import { useSelect } from '@wordpress/data';
|
|
9
|
-
import { external } from '@wordpress/icons';
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { registerPlugin } from '@wordpress/plugins';
|
|
12
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Internal dependencies
|
|
16
|
-
*/
|
|
17
|
-
import CopyContentMenuItem from './copy-content-menu-item';
|
|
18
|
-
import KeyboardShortcutsHelpMenuItem from './keyboard-shortcuts-help-menu-item';
|
|
19
|
-
import ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';
|
|
20
|
-
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
21
|
-
function ManagePatternsMenuItem() {
|
|
22
|
-
const url = useSelect(select => {
|
|
23
|
-
const {
|
|
24
|
-
canUser
|
|
25
|
-
} = select(coreStore);
|
|
26
|
-
const {
|
|
27
|
-
getEditorSettings
|
|
28
|
-
} = select(editorStore);
|
|
29
|
-
const isBlockTheme = getEditorSettings().__unstableIsBlockBasedTheme;
|
|
30
|
-
const defaultUrl = addQueryArgs('edit.php', {
|
|
31
|
-
post_type: 'wp_block'
|
|
32
|
-
});
|
|
33
|
-
const patternsUrl = addQueryArgs('site-editor.php', {
|
|
34
|
-
path: '/patterns'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// The site editor and templates both check whether the user has
|
|
38
|
-
// edit_theme_options capabilities. We can leverage that here and not
|
|
39
|
-
// display the manage patterns link if the user can't access it.
|
|
40
|
-
return canUser('read', 'templates') && isBlockTheme ? patternsUrl : defaultUrl;
|
|
41
|
-
}, []);
|
|
42
|
-
return createElement(MenuItem, {
|
|
43
|
-
role: "menuitem",
|
|
44
|
-
href: url
|
|
45
|
-
}, __('Manage patterns'));
|
|
46
|
-
}
|
|
47
|
-
registerPlugin('edit-post', {
|
|
48
|
-
render() {
|
|
49
|
-
return createElement(Fragment, null, createElement(ToolsMoreMenuGroup, null, ({
|
|
50
|
-
onClose
|
|
51
|
-
}) => createElement(Fragment, null, createElement(ManagePatternsMenuItem, null), createElement(KeyboardShortcutsHelpMenuItem, {
|
|
52
|
-
onSelect: onClose
|
|
53
|
-
}), createElement(WelcomeGuideMenuItem, null), createElement(CopyContentMenuItem, null), createElement(MenuItem, {
|
|
54
|
-
role: "menuitem",
|
|
55
|
-
icon: external,
|
|
56
|
-
href: __('https://wordpress.org/documentation/article/wordpress-block-editor/'),
|
|
57
|
-
target: "_blank",
|
|
58
|
-
rel: "noopener noreferrer"
|
|
59
|
-
}, __('Help'), createElement(VisuallyHidden, {
|
|
60
|
-
as: "span"
|
|
61
|
-
}, /* translators: accessibility text */
|
|
62
|
-
__('(opens in a new tab)'))))));
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MenuItem","VisuallyHidden","store","coreStore","editorStore","useSelect","external","__","registerPlugin","addQueryArgs","CopyContentMenuItem","KeyboardShortcutsHelpMenuItem","ToolsMoreMenuGroup","WelcomeGuideMenuItem","ManagePatternsMenuItem","url","select","canUser","getEditorSettings","isBlockTheme","__unstableIsBlockBasedTheme","defaultUrl","post_type","patternsUrl","path","createElement","role","href","render","Fragment","onClose","onSelect","icon","target","rel","as"],"sources":["@wordpress/edit-post/src/plugins/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem, VisuallyHidden } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as editorStore } from '@wordpress/editor';\nimport { useSelect } from '@wordpress/data';\nimport { external } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport CopyContentMenuItem from './copy-content-menu-item';\nimport KeyboardShortcutsHelpMenuItem from './keyboard-shortcuts-help-menu-item';\nimport ToolsMoreMenuGroup from '../components/header/tools-more-menu-group';\nimport WelcomeGuideMenuItem from './welcome-guide-menu-item';\n\nfunction ManagePatternsMenuItem() {\n\tconst url = useSelect( ( select ) => {\n\t\tconst { canUser } = select( coreStore );\n\t\tconst { getEditorSettings } = select( editorStore );\n\n\t\tconst isBlockTheme = getEditorSettings().__unstableIsBlockBasedTheme;\n\t\tconst defaultUrl = addQueryArgs( 'edit.php', {\n\t\t\tpost_type: 'wp_block',\n\t\t} );\n\t\tconst patternsUrl = addQueryArgs( 'site-editor.php', {\n\t\t\tpath: '/patterns',\n\t\t} );\n\n\t\t// The site editor and templates both check whether the user has\n\t\t// edit_theme_options capabilities. We can leverage that here and not\n\t\t// display the manage patterns link if the user can't access it.\n\t\treturn canUser( 'read', 'templates' ) && isBlockTheme\n\t\t\t? patternsUrl\n\t\t\t: defaultUrl;\n\t}, [] );\n\n\treturn (\n\t\t<MenuItem role=\"menuitem\" href={ url }>\n\t\t\t{ __( 'Manage patterns' ) }\n\t\t</MenuItem>\n\t);\n}\n\nregisterPlugin( 'edit-post', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<ToolsMoreMenuGroup>\n\t\t\t\t\t{ ( { onClose } ) => (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ManagePatternsMenuItem />\n\t\t\t\t\t\t\t<KeyboardShortcutsHelpMenuItem\n\t\t\t\t\t\t\t\tonSelect={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<WelcomeGuideMenuItem />\n\t\t\t\t\t\t\t<CopyContentMenuItem />\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\thref={ __(\n\t\t\t\t\t\t\t\t\t'https://wordpress.org/documentation/article/wordpress-block-editor/'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Help' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</ToolsMoreMenuGroup>\n\t\t\t</>\n\t\t);\n\t},\n} );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,cAAc,QAAQ,uBAAuB;AAChE,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASD,KAAK,IAAIE,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,QAAQ,QAAQ,kBAAkB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,6BAA6B,MAAM,qCAAqC;AAC/E,OAAOC,kBAAkB,MAAM,4CAA4C;AAC3E,OAAOC,oBAAoB,MAAM,2BAA2B;AAE5D,SAASC,sBAAsBA,CAAA,EAAG;EACjC,MAAMC,GAAG,GAAGV,SAAS,CAAIW,MAAM,IAAM;IACpC,MAAM;MAAEC;IAAQ,CAAC,GAAGD,MAAM,CAAEb,SAAU,CAAC;IACvC,MAAM;MAAEe;IAAkB,CAAC,GAAGF,MAAM,CAAEZ,WAAY,CAAC;IAEnD,MAAMe,YAAY,GAAGD,iBAAiB,CAAC,CAAC,CAACE,2BAA2B;IACpE,MAAMC,UAAU,GAAGZ,YAAY,CAAE,UAAU,EAAE;MAC5Ca,SAAS,EAAE;IACZ,CAAE,CAAC;IACH,MAAMC,WAAW,GAAGd,YAAY,CAAE,iBAAiB,EAAE;MACpDe,IAAI,EAAE;IACP,CAAE,CAAC;;IAEH;IACA;IACA;IACA,OAAOP,OAAO,CAAE,MAAM,EAAE,WAAY,CAAC,IAAIE,YAAY,GAClDI,WAAW,GACXF,UAAU;EACd,CAAC,EAAE,EAAG,CAAC;EAEP,OACCI,aAAA,CAACzB,QAAQ;IAAC0B,IAAI,EAAC,UAAU;IAACC,IAAI,EAAGZ;EAAK,GACnCR,EAAE,CAAE,iBAAkB,CACf,CAAC;AAEb;AAEAC,cAAc,CAAE,WAAW,EAAE;EAC5BoB,MAAMA,CAAA,EAAG;IACR,OACCH,aAAA,CAAAI,QAAA,QACCJ,aAAA,CAACb,kBAAkB,QAChB,CAAE;MAAEkB;IAAQ,CAAC,KACdL,aAAA,CAAAI,QAAA,QACCJ,aAAA,CAACX,sBAAsB,MAAE,CAAC,EAC1BW,aAAA,CAACd,6BAA6B;MAC7BoB,QAAQ,EAAGD;IAAS,CACpB,CAAC,EACFL,aAAA,CAACZ,oBAAoB,MAAE,CAAC,EACxBY,aAAA,CAACf,mBAAmB,MAAE,CAAC,EACvBe,aAAA,CAACzB,QAAQ;MACR0B,IAAI,EAAC,UAAU;MACfM,IAAI,EAAG1B,QAAU;MACjBqB,IAAI,EAAGpB,EAAE,CACR,qEACD,CAAG;MACH0B,MAAM,EAAC,QAAQ;MACfC,GAAG,EAAC;IAAqB,GAEvB3B,EAAE,CAAE,MAAO,CAAC,EACdkB,aAAA,CAACxB,cAAc;MAACkC,EAAE,EAAC;IAAM,GAEvB;IACA5B,EAAE,CAAE,sBAAuB,CAEb,CACP,CACT,CAEgB,CACnB,CAAC;EAEL;AACD,CAAE,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { MenuItem } from '@wordpress/components';
|
|
6
|
-
import { withDispatch } from '@wordpress/data';
|
|
7
|
-
import { __ } from '@wordpress/i18n';
|
|
8
|
-
import { displayShortcut } from '@wordpress/keycodes';
|
|
9
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';
|
|
15
|
-
export function KeyboardShortcutsHelpMenuItem({
|
|
16
|
-
openModal
|
|
17
|
-
}) {
|
|
18
|
-
return createElement(MenuItem, {
|
|
19
|
-
onClick: () => {
|
|
20
|
-
openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
|
|
21
|
-
},
|
|
22
|
-
shortcut: displayShortcut.access('h')
|
|
23
|
-
}, __('Keyboard shortcuts'));
|
|
24
|
-
}
|
|
25
|
-
export default withDispatch(dispatch => {
|
|
26
|
-
const {
|
|
27
|
-
openModal
|
|
28
|
-
} = dispatch(interfaceStore);
|
|
29
|
-
return {
|
|
30
|
-
openModal
|
|
31
|
-
};
|
|
32
|
-
})(KeyboardShortcutsHelpMenuItem);
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["MenuItem","withDispatch","__","displayShortcut","store","interfaceStore","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","KeyboardShortcutsHelpMenuItem","openModal","createElement","onClick","shortcut","access","dispatch"],"sources":["@wordpress/edit-post/src/plugins/keyboard-shortcuts-help-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { withDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\n\nexport function KeyboardShortcutsHelpMenuItem( { openModal } ) {\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t\t} }\n\t\t\tshortcut={ displayShortcut.access( 'h' ) }\n\t\t>\n\t\t\t{ __( 'Keyboard shortcuts' ) }\n\t\t</MenuItem>\n\t);\n}\n\nexport default withDispatch( ( dispatch ) => {\n\tconst { openModal } = dispatch( interfaceStore );\n\n\treturn {\n\t\topenModal,\n\t};\n} )( KeyboardShortcutsHelpMenuItem );\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,qBAAqB;AACrD,SAASC,KAAK,IAAIC,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASC,iCAAiC,QAAQ,+CAA+C;AAEjG,OAAO,SAASC,6BAA6BA,CAAE;EAAEC;AAAU,CAAC,EAAG;EAC9D,OACCC,aAAA,CAACT,QAAQ;IACRU,OAAO,EAAGA,CAAA,KAAM;MACfF,SAAS,CAAEF,iCAAkC,CAAC;IAC/C,CAAG;IACHK,QAAQ,EAAGR,eAAe,CAACS,MAAM,CAAE,GAAI;EAAG,GAExCV,EAAE,CAAE,oBAAqB,CAClB,CAAC;AAEb;AAEA,eAAeD,YAAY,CAAIY,QAAQ,IAAM;EAC5C,MAAM;IAAEL;EAAU,CAAC,GAAGK,QAAQ,CAAER,cAAe,CAAC;EAEhD,OAAO;IACNG;EACD,CAAC;AACF,CAAE,CAAC,CAAED,6BAA8B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","PreferenceToggleMenuItem","__","store","editorStore","WelcomeGuideMenuItem","isEditingTemplate","select","getCurrentPostType","createElement","scope","name","label"],"sources":["@wordpress/edit-post/src/plugins/welcome-guide-menu-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { PreferenceToggleMenuItem } from '@wordpress/preferences';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\n\nexport default function WelcomeGuideMenuItem() {\n\tconst isEditingTemplate = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === 'wp_template',\n\t\t[]\n\t);\n\n\treturn (\n\t\t<PreferenceToggleMenuItem\n\t\t\tscope=\"core/edit-post\"\n\t\t\tname={ isEditingTemplate ? 'welcomeGuideTemplate' : 'welcomeGuide' }\n\t\t\tlabel={ __( 'Welcome Guide' ) }\n\t\t/>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,wBAAwB,QAAQ,wBAAwB;AACjE,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AAExD,eAAe,SAASC,oBAAoBA,CAAA,EAAG;EAC9C,MAAMC,iBAAiB,GAAGN,SAAS,CAChCO,MAAM,IACPA,MAAM,CAAEH,WAAY,CAAC,CAACI,kBAAkB,CAAC,CAAC,KAAK,aAAa,EAC7D,EACD,CAAC;EAED,OACCC,aAAA,CAACR,wBAAwB;IACxBS,KAAK,EAAC,gBAAgB;IACtBC,IAAI,EAAGL,iBAAiB,GAAG,sBAAsB,GAAG,cAAgB;IACpEM,KAAK,EAAGV,EAAE,CAAE,eAAgB;EAAG,CAC/B,CAAC;AAEJ"}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { ActionItem } from '@wordpress/interface';
|
|
5
|
-
import { compose } from '@wordpress/compose';
|
|
6
|
-
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
import { withPluginContext } from '@wordpress/plugins';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
|
|
11
|
-
* The text within the component appears as the menu item label.
|
|
12
|
-
*
|
|
13
|
-
* @param {Object} props Component properties.
|
|
14
|
-
* @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
|
|
15
|
-
* @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 to the left of the menu item label.
|
|
16
|
-
* @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
|
|
17
|
-
* @param {...*} [props.other] Any additional props are passed through to the underlying [MenuItem](https://github.com/WordPress/gutenberg/tree/HEAD/packages/components/src/menu-item/README.md) component.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```js
|
|
21
|
-
* // Using ES5 syntax
|
|
22
|
-
* var __ = wp.i18n.__;
|
|
23
|
-
* var PluginMoreMenuItem = wp.editPost.PluginMoreMenuItem;
|
|
24
|
-
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
25
|
-
*
|
|
26
|
-
* function onButtonClick() {
|
|
27
|
-
* alert( 'Button clicked.' );
|
|
28
|
-
* }
|
|
29
|
-
*
|
|
30
|
-
* function MyButtonMoreMenuItem() {
|
|
31
|
-
* return React.createElement(
|
|
32
|
-
* PluginMoreMenuItem,
|
|
33
|
-
* {
|
|
34
|
-
* icon: moreIcon,
|
|
35
|
-
* onClick: onButtonClick,
|
|
36
|
-
* },
|
|
37
|
-
* __( 'My button title' )
|
|
38
|
-
* );
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```jsx
|
|
44
|
-
* // Using ESNext syntax
|
|
45
|
-
* import { __ } from '@wordpress/i18n';
|
|
46
|
-
* import { PluginMoreMenuItem } from '@wordpress/edit-post';
|
|
47
|
-
* import { more } from '@wordpress/icons';
|
|
48
|
-
*
|
|
49
|
-
* function onButtonClick() {
|
|
50
|
-
* alert( 'Button clicked.' );
|
|
51
|
-
* }
|
|
52
|
-
*
|
|
53
|
-
* const MyButtonMoreMenuItem = () => (
|
|
54
|
-
* <PluginMoreMenuItem
|
|
55
|
-
* icon={ more }
|
|
56
|
-
* onClick={ onButtonClick }
|
|
57
|
-
* >
|
|
58
|
-
* { __( 'My button title' ) }
|
|
59
|
-
* </PluginMoreMenuItem>
|
|
60
|
-
* );
|
|
61
|
-
* ```
|
|
62
|
-
*
|
|
63
|
-
* @return {Component} The component to be rendered.
|
|
64
|
-
*/
|
|
65
|
-
export default compose(
|
|
66
|
-
withPluginContext( ( context, ownProps ) => {
|
|
67
|
-
return {
|
|
68
|
-
as: ownProps.as ?? MenuItem,
|
|
69
|
-
icon: ownProps.icon || context.icon,
|
|
70
|
-
name: 'core/edit-post/plugin-more-menu',
|
|
71
|
-
};
|
|
72
|
-
} )
|
|
73
|
-
)( ActionItem );
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { ComplementaryAreaMoreMenuItem } from '@wordpress/interface';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Renders a menu item in `Plugins` group in `More Menu` drop down,
|
|
8
|
-
* and can be used to activate the corresponding `PluginSidebar` component.
|
|
9
|
-
* The text within the component appears as the menu item label.
|
|
10
|
-
*
|
|
11
|
-
* @param {Object} props Component props.
|
|
12
|
-
* @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
|
|
13
|
-
* @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 to the left of the menu item label.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```js
|
|
17
|
-
* // Using ES5 syntax
|
|
18
|
-
* var __ = wp.i18n.__;
|
|
19
|
-
* var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem;
|
|
20
|
-
* var moreIcon = React.createElement( 'svg' ); //... svg element.
|
|
21
|
-
*
|
|
22
|
-
* function MySidebarMoreMenuItem() {
|
|
23
|
-
* return React.createElement(
|
|
24
|
-
* PluginSidebarMoreMenuItem,
|
|
25
|
-
* {
|
|
26
|
-
* target: 'my-sidebar',
|
|
27
|
-
* icon: moreIcon,
|
|
28
|
-
* },
|
|
29
|
-
* __( 'My sidebar title' )
|
|
30
|
-
* )
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```jsx
|
|
36
|
-
* // Using ESNext syntax
|
|
37
|
-
* import { __ } from '@wordpress/i18n';
|
|
38
|
-
* import { PluginSidebarMoreMenuItem } from '@wordpress/edit-post';
|
|
39
|
-
* import { more } from '@wordpress/icons';
|
|
40
|
-
*
|
|
41
|
-
* const MySidebarMoreMenuItem = () => (
|
|
42
|
-
* <PluginSidebarMoreMenuItem
|
|
43
|
-
* target="my-sidebar"
|
|
44
|
-
* icon={ more }
|
|
45
|
-
* >
|
|
46
|
-
* { __( 'My sidebar title' ) }
|
|
47
|
-
* </PluginSidebarMoreMenuItem>
|
|
48
|
-
* );
|
|
49
|
-
* ```
|
|
50
|
-
*
|
|
51
|
-
* @return {Component} The component to be rendered.
|
|
52
|
-
*/
|
|
53
|
-
|
|
54
|
-
export default function PluginSidebarMoreMenuItem( props ) {
|
|
55
|
-
return (
|
|
56
|
-
<ComplementaryAreaMoreMenuItem
|
|
57
|
-
// Menu item is marked with unstable prop for backward compatibility.
|
|
58
|
-
// @see https://github.com/WordPress/gutenberg/issues/14457
|
|
59
|
-
__unstableExplicitMenuItem
|
|
60
|
-
scope="core/edit-post"
|
|
61
|
-
{ ...props }
|
|
62
|
-
/>
|
|
63
|
-
);
|
|
64
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useViewportMatch, compose } from '@wordpress/compose';
|
|
5
|
-
import { withDispatch, withSelect } from '@wordpress/data';
|
|
6
|
-
import { PostPublishButton, store as editorStore } from '@wordpress/editor';
|
|
7
|
-
|
|
8
|
-
export function PostPublishButtonOrToggle( {
|
|
9
|
-
forceIsDirty,
|
|
10
|
-
hasPublishAction,
|
|
11
|
-
isBeingScheduled,
|
|
12
|
-
isPending,
|
|
13
|
-
isPublished,
|
|
14
|
-
isPublishSidebarEnabled,
|
|
15
|
-
isPublishSidebarOpened,
|
|
16
|
-
isScheduled,
|
|
17
|
-
togglePublishSidebar,
|
|
18
|
-
setEntitiesSavedStatesCallback,
|
|
19
|
-
} ) {
|
|
20
|
-
const IS_TOGGLE = 'toggle';
|
|
21
|
-
const IS_BUTTON = 'button';
|
|
22
|
-
const isSmallerThanMediumViewport = useViewportMatch( 'medium', '<' );
|
|
23
|
-
let component;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
|
|
27
|
-
*
|
|
28
|
-
* 1) We want to show a BUTTON when the post status is at the _final stage_
|
|
29
|
-
* for a particular role (see https://wordpress.org/documentation/article/post-status/):
|
|
30
|
-
*
|
|
31
|
-
* - is published
|
|
32
|
-
* - is scheduled to be published
|
|
33
|
-
* - is pending and can't be published (but only for viewports >= medium).
|
|
34
|
-
* Originally, we considered showing a button for pending posts that couldn't be published
|
|
35
|
-
* (for example, for an author with the contributor role). Some languages can have
|
|
36
|
-
* long translations for "Submit for review", so given the lack of UI real estate available
|
|
37
|
-
* we decided to take into account the viewport in that case.
|
|
38
|
-
* See: https://github.com/WordPress/gutenberg/issues/10475
|
|
39
|
-
*
|
|
40
|
-
* 2) Then, in small viewports, we'll show a TOGGLE.
|
|
41
|
-
*
|
|
42
|
-
* 3) Finally, we'll use the publish sidebar status to decide:
|
|
43
|
-
*
|
|
44
|
-
* - if it is enabled, we show a TOGGLE
|
|
45
|
-
* - if it is disabled, we show a BUTTON
|
|
46
|
-
*/
|
|
47
|
-
if (
|
|
48
|
-
isPublished ||
|
|
49
|
-
( isScheduled && isBeingScheduled ) ||
|
|
50
|
-
( isPending && ! hasPublishAction && ! isSmallerThanMediumViewport )
|
|
51
|
-
) {
|
|
52
|
-
component = IS_BUTTON;
|
|
53
|
-
} else if ( isSmallerThanMediumViewport ) {
|
|
54
|
-
component = IS_TOGGLE;
|
|
55
|
-
} else if ( isPublishSidebarEnabled ) {
|
|
56
|
-
component = IS_TOGGLE;
|
|
57
|
-
} else {
|
|
58
|
-
component = IS_BUTTON;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return (
|
|
62
|
-
<PostPublishButton
|
|
63
|
-
forceIsDirty={ forceIsDirty }
|
|
64
|
-
isOpen={ isPublishSidebarOpened }
|
|
65
|
-
isToggle={ component === IS_TOGGLE }
|
|
66
|
-
onToggle={ togglePublishSidebar }
|
|
67
|
-
setEntitiesSavedStatesCallback={ setEntitiesSavedStatesCallback }
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export default compose(
|
|
73
|
-
withSelect( ( select ) => ( {
|
|
74
|
-
hasPublishAction:
|
|
75
|
-
select( editorStore ).getCurrentPost()?._links?.[
|
|
76
|
-
'wp:action-publish'
|
|
77
|
-
] ?? false,
|
|
78
|
-
isBeingScheduled: select( editorStore ).isEditedPostBeingScheduled(),
|
|
79
|
-
isPending: select( editorStore ).isCurrentPostPending(),
|
|
80
|
-
isPublished: select( editorStore ).isCurrentPostPublished(),
|
|
81
|
-
isPublishSidebarEnabled:
|
|
82
|
-
select( editorStore ).isPublishSidebarEnabled(),
|
|
83
|
-
isPublishSidebarOpened: select( editorStore ).isPublishSidebarOpened(),
|
|
84
|
-
isScheduled: select( editorStore ).isCurrentPostScheduled(),
|
|
85
|
-
} ) ),
|
|
86
|
-
withDispatch( ( dispatch ) => {
|
|
87
|
-
const { togglePublishSidebar } = dispatch( editorStore );
|
|
88
|
-
return {
|
|
89
|
-
togglePublishSidebar,
|
|
90
|
-
};
|
|
91
|
-
} )
|
|
92
|
-
)( PostPublishButtonOrToggle );
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
import { store as interfaceStore } from '@wordpress/interface';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { PREFERENCES_MODAL_NAME } from '../../../components/preferences-modal';
|
|
13
|
-
|
|
14
|
-
export default function PreferencesMenuItem() {
|
|
15
|
-
const { openModal } = useDispatch( interfaceStore );
|
|
16
|
-
return (
|
|
17
|
-
<MenuItem
|
|
18
|
-
onClick={ () => {
|
|
19
|
-
openModal( PREFERENCES_MODAL_NAME );
|
|
20
|
-
} }
|
|
21
|
-
>
|
|
22
|
-
{ __( 'Preferences' ) }
|
|
23
|
-
</MenuItem>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { PostPublishButtonOrToggle } from '../post-publish-button-or-toggle';
|
|
10
|
-
|
|
11
|
-
describe( 'PostPublishButtonOrToggle should render a', () => {
|
|
12
|
-
it( 'button when the post is published (1)', () => {
|
|
13
|
-
render( <PostPublishButtonOrToggle isPublished /> );
|
|
14
|
-
expect(
|
|
15
|
-
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
16
|
-
).toBeVisible();
|
|
17
|
-
} );
|
|
18
|
-
|
|
19
|
-
it( 'button when the post is scheduled (2)', () => {
|
|
20
|
-
render( <PostPublishButtonOrToggle isScheduled isBeingScheduled /> );
|
|
21
|
-
expect(
|
|
22
|
-
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
23
|
-
).toBeVisible();
|
|
24
|
-
} );
|
|
25
|
-
|
|
26
|
-
it( 'button when the post is pending and cannot be published but the viewport is >= medium (3)', () => {
|
|
27
|
-
render(
|
|
28
|
-
<PostPublishButtonOrToggle isPending hasPublishAction={ false } />
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
expect(
|
|
32
|
-
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
33
|
-
).toBeVisible();
|
|
34
|
-
} );
|
|
35
|
-
|
|
36
|
-
it( 'toggle when post is not (1), (2), (3), the viewport is >= medium, and the publish sidebar is enabled', () => {
|
|
37
|
-
render( <PostPublishButtonOrToggle isPublishSidebarEnabled /> );
|
|
38
|
-
expect(
|
|
39
|
-
screen.getByRole( 'button', { name: 'Publish' } )
|
|
40
|
-
).toBeVisible();
|
|
41
|
-
} );
|
|
42
|
-
|
|
43
|
-
it( 'button when post is not (1), (2), (3), the viewport is >= medium, and the publish sidebar is disabled', () => {
|
|
44
|
-
render(
|
|
45
|
-
<PostPublishButtonOrToggle isPublishSidebarEnabled={ false } />
|
|
46
|
-
);
|
|
47
|
-
expect(
|
|
48
|
-
screen.getByRole( 'button', { name: 'Submit for Review' } )
|
|
49
|
-
).toBeVisible();
|
|
50
|
-
} );
|
|
51
|
-
} );
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { createSlotFill, MenuGroup } from '@wordpress/components';
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
|
|
7
|
-
const { Fill: ToolsMoreMenuGroup, Slot } =
|
|
8
|
-
createSlotFill( 'ToolsMoreMenuGroup' );
|
|
9
|
-
|
|
10
|
-
ToolsMoreMenuGroup.Slot = ( { fillProps } ) => (
|
|
11
|
-
<Slot fillProps={ fillProps }>
|
|
12
|
-
{ ( fills ) =>
|
|
13
|
-
fills.length > 0 && (
|
|
14
|
-
<MenuGroup label={ __( 'Tools' ) }>{ fills }</MenuGroup>
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
</Slot>
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export default ToolsMoreMenuGroup;
|