@wordpress/editor 13.34.0 → 13.35.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 +10 -4
- package/build/bindings/pattern-overrides.js +70 -1
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +126 -0
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js +11 -0
- package/build/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build/components/collapsible-block-toolbar/index.js +2 -2
- package/build/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build/components/document-bar/index.js +2 -2
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/item.js +2 -2
- package/build/components/document-outline/item.js.map +1 -1
- package/build/components/document-tools/index.js +15 -18
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/editor-canvas/index.js +19 -8
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/global-styles-provider/index.js +130 -0
- package/build/components/global-styles-provider/index.js.map +1 -0
- package/build/components/header/index.js +147 -0
- package/build/components/header/index.js.map +1 -0
- package/build/components/inserter-sidebar/index.js +56 -31
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/post-actions/actions.js +122 -64
- package/build/components/post-actions/actions.js.map +1 -1
- package/build/components/post-actions/index.js +7 -14
- package/build/components/post-actions/index.js.map +1 -1
- package/build/components/post-card-panel/index.js +5 -29
- package/build/components/post-card-panel/index.js.map +1 -1
- package/build/components/post-comments/index.js +28 -8
- package/build/components/post-comments/index.js.map +1 -1
- package/build/components/post-discussion/panel.js +103 -21
- package/build/components/post-discussion/panel.js.map +1 -1
- package/build/components/post-excerpt/panel.js +2 -2
- package/build/components/post-excerpt/panel.js.map +1 -1
- package/build/components/post-format/panel.js +27 -0
- package/build/components/post-format/panel.js.map +1 -0
- package/build/components/post-panel-row/index.js +2 -2
- package/build/components/post-panel-row/index.js.map +1 -1
- package/build/components/post-panel-section/index.js +28 -0
- package/build/components/post-panel-section/index.js.map +1 -0
- package/build/components/post-pingbacks/index.js +5 -2
- package/build/components/post-pingbacks/index.js.map +1 -1
- package/build/components/post-saved-state/index.js +2 -2
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-slug/panel.js +27 -0
- package/build/components/post-slug/panel.js.map +1 -0
- package/build/components/post-status/index.js +4 -4
- package/build/components/post-status/index.js.map +1 -1
- package/build/components/post-sticky/panel.js +21 -0
- package/build/components/post-sticky/panel.js.map +1 -0
- package/build/components/post-title/index.js +2 -2
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/post-title/post-title-raw.js +2 -2
- package/build/components/post-title/post-title-raw.js.map +1 -1
- package/build/components/post-transform-panel/hooks.js +90 -0
- package/build/components/post-transform-panel/hooks.js.map +1 -0
- package/build/components/post-transform-panel/index.js +101 -0
- package/build/components/post-transform-panel/index.js.map +1 -0
- package/build/components/post-trash/panel.js +18 -0
- package/build/components/post-trash/panel.js.map +1 -0
- package/build/components/post-type-support-check/index.js +1 -1
- package/build/components/post-type-support-check/index.js.map +1 -1
- package/build/components/preferences-modal/index.js +3 -3
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/provider/index.js +3 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +21 -3
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/sidebar/constants.js +11 -0
- package/build/components/sidebar/constants.js.map +1 -0
- package/build/components/sidebar/header.js +53 -0
- package/build/components/sidebar/header.js.map +1 -0
- package/build/components/sidebar/index.js +157 -0
- package/build/components/sidebar/index.js.map +1 -0
- package/build/components/sidebar/post-summary.js +84 -0
- package/build/components/sidebar/post-summary.js.map +1 -0
- package/build/components/start-page-options/index.js +5 -7
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/start-template-options/index.js +192 -0
- package/build/components/start-template-options/index.js.map +1 -0
- package/build/components/template-content-panel/index.js +38 -0
- package/build/components/template-content-panel/index.js.map +1 -0
- package/build/hooks/pattern-overrides.js +10 -5
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build/private-apis.js +7 -12
- package/build/private-apis.js.map +1 -1
- package/build/private-apis.native.js +72 -0
- package/build/private-apis.native.js.map +1 -0
- package/build/store/private-selectors.js +6 -1
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +15 -0
- package/build/store/reducer.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +69 -1
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +119 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +1 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js +5 -0
- package/build-module/components/block-settings-menu/content-only-settings-menu.native.js.map +1 -0
- package/build-module/components/collapsible-block-toolbar/index.js +2 -2
- package/build-module/components/collapsible-block-toolbar/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +2 -2
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/item.js +2 -2
- package/build-module/components/document-outline/item.js.map +1 -1
- package/build-module/components/document-tools/index.js +16 -19
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +19 -8
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/global-styles-provider/index.js +120 -0
- package/build-module/components/global-styles-provider/index.js.map +1 -0
- package/build-module/components/header/index.js +139 -0
- package/build-module/components/header/index.js.map +1 -0
- package/build-module/components/inserter-sidebar/index.js +59 -34
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/post-actions/actions.js +125 -66
- package/build-module/components/post-actions/actions.js.map +1 -1
- package/build-module/components/post-actions/index.js +7 -14
- package/build-module/components/post-actions/index.js.map +1 -1
- package/build-module/components/post-card-panel/index.js +7 -30
- package/build-module/components/post-card-panel/index.js.map +1 -1
- package/build-module/components/post-comments/index.js +30 -10
- package/build-module/components/post-comments/index.js.map +1 -1
- package/build-module/components/post-discussion/panel.js +105 -23
- package/build-module/components/post-discussion/panel.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +2 -2
- package/build-module/components/post-excerpt/panel.js.map +1 -1
- package/build-module/components/post-format/panel.js +18 -0
- package/build-module/components/post-format/panel.js.map +1 -0
- package/build-module/components/post-panel-row/index.js +2 -2
- package/build-module/components/post-panel-row/index.js.map +1 -1
- package/build-module/components/post-panel-section/index.js +20 -0
- package/build-module/components/post-panel-section/index.js.map +1 -0
- package/build-module/components/post-pingbacks/index.js +6 -3
- package/build-module/components/post-pingbacks/index.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +2 -2
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-slug/panel.js +18 -0
- package/build-module/components/post-slug/panel.js.map +1 -0
- package/build-module/components/post-status/index.js +4 -4
- package/build-module/components/post-status/index.js.map +1 -1
- package/build-module/components/post-sticky/panel.js +12 -0
- package/build-module/components/post-sticky/panel.js.map +1 -0
- package/build-module/components/post-title/index.js +2 -2
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/post-title/post-title-raw.js +2 -2
- package/build-module/components/post-title/post-title-raw.js.map +1 -1
- package/build-module/components/post-transform-panel/hooks.js +83 -0
- package/build-module/components/post-transform-panel/hooks.js.map +1 -0
- package/build-module/components/post-transform-panel/index.js +94 -0
- package/build-module/components/post-transform-panel/index.js.map +1 -0
- package/build-module/components/post-trash/panel.js +10 -0
- package/build-module/components/post-trash/panel.js.map +1 -0
- package/build-module/components/post-type-support-check/index.js +1 -1
- package/build-module/components/post-type-support-check/index.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +3 -3
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/provider/index.js +3 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +21 -3
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/sidebar/constants.js +5 -0
- package/build-module/components/sidebar/constants.js.map +1 -0
- package/build-module/components/sidebar/header.js +46 -0
- package/build-module/components/sidebar/header.js.map +1 -0
- package/build-module/components/sidebar/index.js +149 -0
- package/build-module/components/sidebar/index.js.map +1 -0
- package/build-module/components/sidebar/post-summary.js +77 -0
- package/build-module/components/sidebar/post-summary.js.map +1 -0
- package/build-module/components/start-page-options/index.js +5 -7
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/start-template-options/index.js +185 -0
- package/build-module/components/start-template-options/index.js.map +1 -0
- package/build-module/components/template-content-panel/index.js +31 -0
- package/build-module/components/template-content-panel/index.js.map +1 -0
- package/build-module/hooks/pattern-overrides.js +10 -5
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-module/private-apis.js +7 -12
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-apis.native.js +62 -0
- package/build-module/private-apis.native.js.map +1 -0
- package/build-module/store/private-selectors.js +3 -0
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +14 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-style/style-rtl.css +328 -18
- package/build-style/style.css +328 -18
- package/package.json +38 -36
- package/src/bindings/pattern-overrides.js +83 -1
- package/src/components/autocompleters/style.scss +1 -2
- package/src/components/block-settings-menu/content-only-settings-menu.js +175 -0
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +4 -0
- package/src/components/block-settings-menu/style.scss +4 -0
- package/src/components/collapsible-block-toolbar/index.js +2 -2
- package/src/components/document-bar/index.js +2 -2
- package/src/components/document-outline/item.js +2 -2
- package/src/components/document-tools/index.js +19 -21
- package/src/components/editor-canvas/index.js +18 -6
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +1 -1
- package/src/components/global-styles-provider/index.js +162 -0
- package/src/components/header/index.js +154 -0
- package/src/components/header/style.scss +231 -0
- package/src/components/inserter-sidebar/index.js +52 -29
- package/src/components/inserter-sidebar/style.scss +10 -3
- package/src/components/keyboard-shortcut-help-modal/index.js +2 -2
- package/src/components/list-view-sidebar/style.scss +1 -0
- package/src/components/page-attributes/test/order.js +5 -1
- package/src/components/post-actions/actions.js +256 -150
- package/src/components/post-actions/index.js +5 -38
- package/src/components/post-card-panel/index.js +39 -85
- package/src/components/post-comments/index.js +47 -9
- package/src/components/post-discussion/panel.js +108 -31
- package/src/components/post-discussion/style.scss +26 -0
- package/src/components/post-excerpt/panel.js +2 -2
- package/src/components/post-format/panel.js +22 -0
- package/src/components/post-format/style.scss +6 -0
- package/src/components/post-last-revision/test/check.js +5 -1
- package/src/components/post-panel-row/index.js +2 -2
- package/src/components/post-panel-section/index.js +19 -0
- package/src/components/post-panel-section/style.scss +3 -0
- package/src/components/post-pingbacks/index.js +11 -2
- package/src/components/post-publish-panel/style.scss +5 -0
- package/src/components/post-saved-state/index.js +2 -2
- package/src/components/post-slug/panel.js +22 -0
- package/src/components/post-slug/style.scss +5 -0
- package/src/components/post-slug/test/index.js +5 -1
- package/src/components/post-status/index.js +4 -4
- package/src/components/post-sticky/panel.js +18 -0
- package/src/components/post-title/index.js +2 -2
- package/src/components/post-title/post-title-raw.js +2 -2
- package/src/components/post-transform-panel/hooks.js +114 -0
- package/src/components/post-transform-panel/index.js +99 -0
- package/src/components/post-trash/panel.js +13 -0
- package/src/components/post-type-support-check/index.js +1 -1
- package/src/components/post-type-support-check/test/index.js +2 -2
- package/src/components/preferences-modal/index.js +3 -3
- package/src/components/provider/index.js +4 -0
- package/src/components/provider/use-block-editor-settings.js +19 -4
- package/src/components/sidebar/constants.js +4 -0
- package/src/components/sidebar/header.js +49 -0
- package/src/components/sidebar/index.js +200 -0
- package/src/components/sidebar/post-summary.js +104 -0
- package/src/components/sidebar/style.scss +18 -0
- package/src/components/start-page-options/index.js +6 -4
- package/src/components/start-template-options/index.js +219 -0
- package/src/components/start-template-options/style.scss +55 -0
- package/src/components/template-areas/style.scss +0 -1
- package/src/components/template-content-panel/index.js +36 -0
- package/src/hooks/pattern-overrides.js +12 -6
- package/src/private-apis.js +10 -12
- package/src/private-apis.native.js +61 -0
- package/src/store/private-selectors.js +3 -0
- package/src/store/reducer.js +12 -0
- package/src/style.scss +7 -0
- package/src/components/post-slug/test/check.js +0 -17
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_data","_compose","_components","_preferences","_element","_interface","_blockEditor","_collapsibleBlockToolbar","_documentBar","_documentTools","_moreMenu","_postPreviewButton","_postPublishButtonOrToggle","_postSavedState","_postTypeSupportCheck","_postViewLink","_previewDropdown","_store","slideY","hidden","y","distractionFreeInactive","hover","transition","type","delay","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","children","isWideViewport","useViewportMatch","isLargeViewport","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","isNestedEntity","isZoomedOutView","useSelect","select","get","getPreference","preferencesStore","getEditorMode","getEditorSettings","_isPublishSidebarOpened","editorStore","__unstableGetEditorMode","blockEditorStore","onNavigateToPreviousEntityRecord","hasTopToolbar","isBlockToolsCollapsed","setIsBlockToolsCollapsed","useState","_react","createElement","className","__unstableMotion","div","variants","default","disableBlockTools","isCollapsed","onToggle","clsx","supportKeys","forceIsAutosaveable","disabled","PinnedItems","Slot","scope","_default","exports"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport CollapsableBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostTypeSupportCheck from '../post-type-support-check';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport { store as editorStore } from '../../store';\n\nconst slideY = {\n\thidden: { y: '-50px' },\n\tdistractionFreeInactive: { y: 0 },\n\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tchildren,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\tisNestedEntity,\n\t\tisZoomedOutView,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst hasTopToolbar = isLargeViewport && hasFixedToolbar;\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ children }\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasTopToolbar && (\n\t\t\t\t\t<CollapsableBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<div\n\t\t\t\t\tclassName={ clsx( 'editor-header__center', {\n\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\t! isBlockToolsCollapsed && hasTopToolbar,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ ! title ? (\n\t\t\t\t\t\t<PostTypeSupportCheck supportKeys=\"title\">\n\t\t\t\t\t\t\t<DocumentBar />\n\t\t\t\t\t\t</PostTypeSupportCheck>\n\t\t\t\t\t) : (\n\t\t\t\t\t\ttitle\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t</motion.div>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity || isZoomedOutView }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ customSaveButton }\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;A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CAAC,EACd,CAAErC,gBAAgB,IACnB,IAAA+B,MAAA,CAAAC,aAAA,EAAC/C,0BAAA,CAAAoD,OAAyB;IACzBpC,YAAY,EAAGA,YAAc;IAC7BE,8BAA8B,EAC7BA;EACA,CACD,CACD,EACCH,gBAAgB,EAChB,CAAEM,cAAc,IAAI,CAAEK,cAAc,KACrC,IAAAoB,MAAA,CAAAC,aAAA,EAACtD,UAAA,CAAAmE,WAAW,CAACC,IAAI;IAACC,KAAK,EAAC;EAAM,CAAE,CAChC,EACD,IAAAhB,MAAA,CAAAC,aAAA,EAACjD,SAAA,CAAAsD,OAAQ,MAAE,CACA,CACR,CAAC;AAER;AAAC,IAAAW,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEctC,MAAM","ignoreList":[]}
|
|
@@ -6,13 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = InserterSidebar;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _data = require("@wordpress/data");
|
|
9
|
-
var _components = require("@wordpress/components");
|
|
10
9
|
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
var _icons = require("@wordpress/icons");
|
|
12
10
|
var _compose = require("@wordpress/compose");
|
|
13
|
-
var _i18n = require("@wordpress/i18n");
|
|
14
11
|
var _element = require("@wordpress/element");
|
|
15
12
|
var _preferences = require("@wordpress/preferences");
|
|
13
|
+
var _keycodes = require("@wordpress/keycodes");
|
|
16
14
|
var _lockUnlock = require("../../lock-unlock");
|
|
17
15
|
var _store = require("../../store");
|
|
18
16
|
/**
|
|
@@ -28,51 +26,78 @@ function InserterSidebar({
|
|
|
28
26
|
isRightSidebarOpen
|
|
29
27
|
}) {
|
|
30
28
|
const {
|
|
29
|
+
blockSectionRootClientId,
|
|
30
|
+
inserterSidebarToggleRef,
|
|
31
31
|
insertionPoint,
|
|
32
32
|
showMostUsedBlocks
|
|
33
33
|
} = (0, _data.useSelect)(select => {
|
|
34
34
|
const {
|
|
35
|
+
getInserterSidebarToggleRef,
|
|
35
36
|
getInsertionPoint
|
|
36
37
|
} = (0, _lockUnlock.unlock)(select(_store.store));
|
|
38
|
+
const {
|
|
39
|
+
getBlockRootClientId,
|
|
40
|
+
__unstableGetEditorMode,
|
|
41
|
+
getSettings
|
|
42
|
+
} = select(_blockEditor.store);
|
|
37
43
|
const {
|
|
38
44
|
get
|
|
39
45
|
} = select(_preferences.store);
|
|
46
|
+
const getBlockSectionRootClientId = () => {
|
|
47
|
+
if (__unstableGetEditorMode() === 'zoom-out') {
|
|
48
|
+
const {
|
|
49
|
+
sectionRootClientId
|
|
50
|
+
} = (0, _lockUnlock.unlock)(getSettings());
|
|
51
|
+
if (sectionRootClientId) {
|
|
52
|
+
return sectionRootClientId;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return getBlockRootClientId();
|
|
56
|
+
};
|
|
40
57
|
return {
|
|
58
|
+
inserterSidebarToggleRef: getInserterSidebarToggleRef(),
|
|
41
59
|
insertionPoint: getInsertionPoint(),
|
|
42
|
-
showMostUsedBlocks: get('core', 'mostUsedBlocks')
|
|
60
|
+
showMostUsedBlocks: get('core', 'mostUsedBlocks'),
|
|
61
|
+
blockSectionRootClientId: getBlockSectionRootClientId()
|
|
43
62
|
};
|
|
44
63
|
}, []);
|
|
45
64
|
const {
|
|
46
65
|
setIsInserterOpened
|
|
47
66
|
} = (0, _data.useDispatch)(_store.store);
|
|
48
67
|
const isMobileViewport = (0, _compose.useViewportMatch)('medium', '<');
|
|
49
|
-
const TagName = !isMobileViewport ? _components.VisuallyHidden : 'div';
|
|
50
|
-
const [inserterDialogRef, inserterDialogProps] = (0, _compose.__experimentalUseDialog)({
|
|
51
|
-
onClose: () => setIsInserterOpened(false),
|
|
52
|
-
focusOnMount: true
|
|
53
|
-
});
|
|
54
68
|
const libraryRef = (0, _element.useRef)();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
69
|
+
|
|
70
|
+
// When closing the inserter, focus should return to the toggle button.
|
|
71
|
+
const closeInserterSidebar = (0, _element.useCallback)(() => {
|
|
72
|
+
setIsInserterOpened(false);
|
|
73
|
+
inserterSidebarToggleRef.current?.focus();
|
|
74
|
+
}, [inserterSidebarToggleRef, setIsInserterOpened]);
|
|
75
|
+
const closeOnEscape = (0, _element.useCallback)(event => {
|
|
76
|
+
if (event.keyCode === _keycodes.ESCAPE && !event.defaultPrevented) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
closeInserterSidebar();
|
|
79
|
+
}
|
|
80
|
+
}, [closeInserterSidebar]);
|
|
81
|
+
return (
|
|
82
|
+
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
83
|
+
(0, _react.createElement)("div", {
|
|
84
|
+
onKeyDown: closeOnEscape,
|
|
85
|
+
className: "editor-inserter-sidebar"
|
|
86
|
+
}, (0, _react.createElement)("div", {
|
|
87
|
+
className: "editor-inserter-sidebar__content"
|
|
88
|
+
}, (0, _react.createElement)(_blockEditor.__experimentalLibrary, {
|
|
89
|
+
showMostUsedBlocks: showMostUsedBlocks,
|
|
90
|
+
showInserterHelpPanel: true,
|
|
91
|
+
shouldFocusBlock: isMobileViewport,
|
|
92
|
+
rootClientId: blockSectionRootClientId !== null && blockSectionRootClientId !== void 0 ? blockSectionRootClientId : insertionPoint.rootClientId,
|
|
93
|
+
__experimentalInsertionIndex: insertionPoint.insertionIndex,
|
|
94
|
+
__experimentalInitialTab: insertionPoint.tab,
|
|
95
|
+
__experimentalInitialCategory: insertionPoint.category,
|
|
96
|
+
__experimentalFilterValue: insertionPoint.filterValue,
|
|
97
|
+
__experimentalOnPatternCategorySelection: isRightSidebarOpen ? closeGeneralSidebar : undefined,
|
|
98
|
+
ref: libraryRef,
|
|
99
|
+
onClose: closeInserterSidebar
|
|
100
|
+
})))
|
|
101
|
+
);
|
|
77
102
|
}
|
|
78
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","
|
|
1
|
+
{"version":3,"names":["_data","require","_blockEditor","_compose","_element","_preferences","_keycodes","_lockUnlock","_store","InserterSidebar","closeGeneralSidebar","isRightSidebarOpen","blockSectionRootClientId","inserterSidebarToggleRef","insertionPoint","showMostUsedBlocks","useSelect","select","getInserterSidebarToggleRef","getInsertionPoint","unlock","editorStore","getBlockRootClientId","__unstableGetEditorMode","getSettings","blockEditorStore","get","preferencesStore","getBlockSectionRootClientId","sectionRootClientId","setIsInserterOpened","useDispatch","isMobileViewport","useViewportMatch","libraryRef","useRef","closeInserterSidebar","useCallback","current","focus","closeOnEscape","event","keyCode","ESCAPE","defaultPrevented","preventDefault","_react","createElement","onKeyDown","className","__experimentalLibrary","showInserterHelpPanel","shouldFocusBlock","rootClientId","__experimentalInsertionIndex","insertionIndex","__experimentalInitialTab","tab","__experimentalInitialCategory","category","__experimentalFilterValue","filterValue","__experimentalOnPatternCategorySelection","undefined","ref","onClose"],"sources":["@wordpress/editor/src/components/inserter-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\t__experimentalLibrary as Library,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useCallback, useRef } from '@wordpress/element';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { ESCAPE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\n\nexport default function InserterSidebar( {\n\tcloseGeneralSidebar,\n\tisRightSidebarOpen,\n} ) {\n\tconst {\n\t\tblockSectionRootClientId,\n\t\tinserterSidebarToggleRef,\n\t\tinsertionPoint,\n\t\tshowMostUsedBlocks,\n\t} = useSelect( ( select ) => {\n\t\tconst { getInserterSidebarToggleRef, getInsertionPoint } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst { getBlockRootClientId, __unstableGetEditorMode, getSettings } =\n\t\t\tselect( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst getBlockSectionRootClientId = () => {\n\t\t\tif ( __unstableGetEditorMode() === 'zoom-out' ) {\n\t\t\t\tconst { sectionRootClientId } = unlock( getSettings() );\n\t\t\t\tif ( sectionRootClientId ) {\n\t\t\t\t\treturn sectionRootClientId;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn getBlockRootClientId();\n\t\t};\n\t\treturn {\n\t\t\tinserterSidebarToggleRef: getInserterSidebarToggleRef(),\n\t\t\tinsertionPoint: getInsertionPoint(),\n\t\t\tshowMostUsedBlocks: get( 'core', 'mostUsedBlocks' ),\n\t\t\tblockSectionRootClientId: getBlockSectionRootClientId(),\n\t\t};\n\t}, [] );\n\tconst { setIsInserterOpened } = useDispatch( editorStore );\n\n\tconst isMobileViewport = useViewportMatch( 'medium', '<' );\n\tconst libraryRef = useRef();\n\n\t// When closing the inserter, focus should return to the toggle button.\n\tconst closeInserterSidebar = useCallback( () => {\n\t\tsetIsInserterOpened( false );\n\t\tinserterSidebarToggleRef.current?.focus();\n\t}, [ inserterSidebarToggleRef, setIsInserterOpened ] );\n\n\tconst closeOnEscape = useCallback(\n\t\t( event ) => {\n\t\t\tif ( event.keyCode === ESCAPE && ! event.defaultPrevented ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tcloseInserterSidebar();\n\t\t\t}\n\t\t},\n\t\t[ closeInserterSidebar ]\n\t);\n\n\treturn (\n\t\t// eslint-disable-next-line jsx-a11y/no-static-element-interactions\n\t\t<div onKeyDown={ closeOnEscape } className=\"editor-inserter-sidebar\">\n\t\t\t<div className=\"editor-inserter-sidebar__content\">\n\t\t\t\t<Library\n\t\t\t\t\tshowMostUsedBlocks={ showMostUsedBlocks }\n\t\t\t\t\tshowInserterHelpPanel\n\t\t\t\t\tshouldFocusBlock={ isMobileViewport }\n\t\t\t\t\trootClientId={\n\t\t\t\t\t\tblockSectionRootClientId ?? insertionPoint.rootClientId\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalInsertionIndex={\n\t\t\t\t\t\tinsertionPoint.insertionIndex\n\t\t\t\t\t}\n\t\t\t\t\t__experimentalInitialTab={ insertionPoint.tab }\n\t\t\t\t\t__experimentalInitialCategory={ insertionPoint.category }\n\t\t\t\t\t__experimentalFilterValue={ insertionPoint.filterValue }\n\t\t\t\t\t__experimentalOnPatternCategorySelection={\n\t\t\t\t\t\tisRightSidebarOpen ? closeGeneralSidebar : undefined\n\t\t\t\t\t}\n\t\t\t\t\tref={ libraryRef }\n\t\t\t\t\tonClose={ closeInserterSidebar }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAjBA;AACA;AACA;;AAWA;AACA;AACA;;AAIe,SAASQ,eAAeA,CAAE;EACxCC,mBAAmB;EACnBC;AACD,CAAC,EAAG;EACH,MAAM;IACLC,wBAAwB;IACxBC,wBAAwB;IACxBC,cAAc;IACdC;EACD,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC5B,MAAM;MAAEC,2BAA2B;MAAEC;IAAkB,CAAC,GAAG,IAAAC,kBAAM,EAChEH,MAAM,CAAEI,YAAY,CACrB,CAAC;IACD,MAAM;MAAEC,oBAAoB;MA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KAAK,CAACI,cAAc,CAAC,CAAC;MACtBT,oBAAoB,CAAC,CAAC;IACvB;EACD,CAAC,EACD,CAAEA,oBAAoB,CACvB,CAAC;EAED;IACC;IACA,IAAAU,MAAA,CAAAC,aAAA;MAAKC,SAAS,EAAGR,aAAe;MAACS,SAAS,EAAC;IAAyB,GACnE,IAAAH,MAAA,CAAAC,aAAA;MAAKE,SAAS,EAAC;IAAkC,GAChD,IAAAH,MAAA,CAAAC,aAAA,EAAC7C,YAAA,CAAAgD,qBAAO;MACPnC,kBAAkB,EAAGA,kBAAoB;MACzCoC,qBAAqB;MACrBC,gBAAgB,EAAGpB,gBAAkB;MACrCqB,YAAY,EACXzC,wBAAwB,aAAxBA,wBAAwB,cAAxBA,wBAAwB,GAAIE,cAAc,CAACuC,YAC3C;MACDC,4BAA4B,EAC3BxC,cAAc,CAACyC,cACf;MACDC,wBAAwB,EAAG1C,cAAc,CAAC2C,GAAK;MAC/CC,6BAA6B,EAAG5C,cAAc,CAAC6C,QAAU;MACzDC,yBAAyB,EAAG9C,cAAc,CAAC+C,WAAa;MACxDC,wCAAwC,EACvCnD,kBAAkB,GAAGD,mBAAmB,GAAGqD,SAC3C;MACDC,GAAG,EAAG9B,UAAY;MAClB+B,OAAO,EAAG7B;IAAsB,CAChC,CACG,CACD;EAAC;AAER","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var
|
|
9
|
+
var _clsx = _interopRequireDefault(require("clsx"));
|
|
10
10
|
var _components = require("@wordpress/components");
|
|
11
11
|
var _i18n = require("@wordpress/i18n");
|
|
12
12
|
var _keyboardShortcuts = require("@wordpress/keyboard-shortcuts");
|
|
@@ -53,7 +53,7 @@ const ShortcutSection = ({
|
|
|
53
53
|
shortcuts,
|
|
54
54
|
className
|
|
55
55
|
}) => (0, _react.createElement)("section", {
|
|
56
|
-
className: (0,
|
|
56
|
+
className: (0, _clsx.default)('editor-keyboard-shortcut-help-modal__section', className)
|
|
57
57
|
}, !!title && (0, _react.createElement)("h2", {
|
|
58
58
|
className: "editor-keyboard-shortcut-help-modal__section-title"
|
|
59
59
|
}, title), (0, _react.createElement)(ShortcutList, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_components","_i18n","_keyboardShortcuts","_data","_interface","_config","_shortcut","_dynamicShortcut","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","ShortcutList","shortcuts","_react","createElement","className","role","map","shortcut","index","key","default","name","ShortcutSection","title","clsx","ShortcutCategorySection","categoryName","additionalShortcuts","categoryShortcuts","useSelect","select","keyboardShortcutsStore","getCategoryShortcuts","concat","KeyboardShortcutHelpModal","isModalActive","interfaceStore","openModal","closeModal","useDispatch","toggleModal","useShortcut","Modal","__","closeButtonLabel","onRequestClose","keyCombination","character","description","ariaLabel","textFormattingShortcuts","_default","exports"],"sources":["@wordpress/editor/src/components/keyboard-shortcut-help-modal/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nconst KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';\n\nconst ShortcutList = ( { shortcuts } ) => (\n\t/*\n\t * Disable reason: The `list` ARIA role is redundant but\n\t * Safari+VoiceOver won't announce the list otherwise.\n\t */\n\t/* eslint-disable jsx-a11y/no-redundant-roles */\n\t<ul\n\t\tclassName=\"editor-keyboard-shortcut-help-modal__shortcut-list\"\n\t\trole=\"list\"\n\t>\n\t\t{ shortcuts.map( ( shortcut, index ) => (\n\t\t\t<li\n\t\t\t\tclassName=\"editor-keyboard-shortcut-help-modal__shortcut\"\n\t\t\t\tkey={ index }\n\t\t\t>\n\t\t\t\t{ typeof shortcut === 'string' ? (\n\t\t\t\t\t<DynamicShortcut name={ shortcut } />\n\t\t\t\t) : (\n\t\t\t\t\t<Shortcut { ...shortcut } />\n\t\t\t\t) }\n\t\t\t</li>\n\t\t) ) }\n\t</ul>\n\t/* eslint-enable jsx-a11y/no-redundant-roles */\n);\n\nconst ShortcutSection = ( { title, shortcuts, className } ) => (\n\t<section\n\t\tclassName={ clsx(\n\t\t\t'editor-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"editor-keyboard-shortcut-help-modal__section-title\">\n\t\t\t\t{ title }\n\t\t\t</h2>\n\t\t) }\n\t\t<ShortcutList shortcuts={ shortcuts } />\n\t</section>\n);\n\nconst ShortcutCategorySection = ( {\n\ttitle,\n\tcategoryName,\n\tadditionalShortcuts = [],\n} ) => {\n\tconst categoryShortcuts = useSelect(\n\t\t( select ) => {\n\t\t\treturn select( keyboardShortcutsStore ).getCategoryShortcuts(\n\t\t\t\tcategoryName\n\t\t\t);\n\t\t},\n\t\t[ categoryName ]\n\t);\n\n\treturn (\n\t\t<ShortcutSection\n\t\t\ttitle={ title }\n\t\t\tshortcuts={ categoryShortcuts.concat( additionalShortcuts ) }\n\t\t/>\n\t);\n};\n\nfunction KeyboardShortcutHelpModal() {\n\tconst isModalActive = useSelect(\n\t\t( select ) =>\n\t\t\tselect( interfaceStore ).isModalActive(\n\t\t\t\tKEYBOARD_SHORTCUT_HELP_MODAL_NAME\n\t\t\t),\n\t\t[]\n\t);\n\tconst { openModal, closeModal } = useDispatch( interfaceStore );\n\tconst toggleModal = () => {\n\t\tif ( isModalActive ) {\n\t\t\tcloseModal();\n\t\t} else {\n\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t}\n\t};\n\tuseShortcut( 'core/editor/keyboard-shortcuts', toggleModal );\n\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"editor-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tcloseButtonLabel={ __( 'Close' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"editor-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/editor/keyboard-shortcuts' ] }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Global shortcuts' ) }\n\t\t\t\tcategoryName=\"global\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Selection shortcuts' ) }\n\t\t\t\tcategoryName=\"selection\"\n\t\t\t/>\n\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'Block shortcuts' ) }\n\t\t\t\tcategoryName=\"block\"\n\t\t\t\tadditionalShortcuts={ [\n\t\t\t\t\t{\n\t\t\t\t\t\tkeyCombination: { character: '/' },\n\t\t\t\t\t\tdescription: __(\n\t\t\t\t\t\t\t'Change the block type after adding a new paragraph.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t/* translators: The forward-slash character. e.g. '/'. */\n\t\t\t\t\t\tariaLabel: __( 'Forward-slash' ),\n\t\t\t\t\t},\n\t\t\t\t] }\n\t\t\t/>\n\t\t\t<ShortcutSection\n\t\t\t\ttitle={ __( 'Text formatting' ) }\n\t\t\t\tshortcuts={ textFormattingShortcuts }\n\t\t\t/>\n\t\t\t<ShortcutCategorySection\n\t\t\t\ttitle={ __( 'List View shortcuts' ) }\n\t\t\t\tcategoryName=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yB","ignoreList":[]}
|
|
@@ -4,7 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.duplicatePostAction = void 0;
|
|
8
7
|
exports.usePostActions = usePostActions;
|
|
9
8
|
var _react = require("react");
|
|
10
9
|
var _icons = require("@wordpress/icons");
|
|
@@ -49,8 +48,10 @@ const trashPostAction = {
|
|
|
49
48
|
RenderModal: ({
|
|
50
49
|
items: posts,
|
|
51
50
|
closeModal,
|
|
51
|
+
onActionStart,
|
|
52
52
|
onActionPerformed
|
|
53
53
|
}) => {
|
|
54
|
+
const [isBusy, setIsBusy] = (0, _element.useState)(false);
|
|
54
55
|
const {
|
|
55
56
|
createSuccessNotice,
|
|
56
57
|
createErrorNotice
|
|
@@ -68,10 +69,16 @@ const trashPostAction = {
|
|
|
68
69
|
justify: "right"
|
|
69
70
|
}, (0, _react.createElement)(_components.Button, {
|
|
70
71
|
variant: "tertiary",
|
|
71
|
-
onClick: closeModal
|
|
72
|
+
onClick: closeModal,
|
|
73
|
+
disabled: isBusy,
|
|
74
|
+
__experimentalIsFocusable: true
|
|
72
75
|
}, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
|
|
73
76
|
variant: "primary",
|
|
74
77
|
onClick: async () => {
|
|
78
|
+
setIsBusy(true);
|
|
79
|
+
if (onActionStart) {
|
|
80
|
+
onActionStart(posts);
|
|
81
|
+
}
|
|
75
82
|
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
76
83
|
return deleteEntityRecord('postType', post.type, post.id, {}, {
|
|
77
84
|
throwOnError: true
|
|
@@ -85,8 +92,12 @@ const trashPostAction = {
|
|
|
85
92
|
if (promiseResult.length === 1) {
|
|
86
93
|
successMessage = (0, _i18n.sprintf)( /* translators: The posts's title. */
|
|
87
94
|
(0, _i18n.__)('"%s" moved to the Trash.'), getItemTitle(posts[0]));
|
|
95
|
+
} else if (posts[0].type === 'page') {
|
|
96
|
+
successMessage = (0, _i18n.sprintf)( /* translators: The number of pages. */
|
|
97
|
+
(0, _i18n.__)('%s pages moved to the Trash.'), posts.length);
|
|
88
98
|
} else {
|
|
89
|
-
successMessage = (0, _i18n.
|
|
99
|
+
successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
|
|
100
|
+
(0, _i18n.__)('%s posts moved to the Trash.'), posts.length);
|
|
90
101
|
}
|
|
91
102
|
createSuccessNotice(successMessage, {
|
|
92
103
|
type: 'snackbar',
|
|
@@ -130,8 +141,12 @@ const trashPostAction = {
|
|
|
130
141
|
if (onActionPerformed) {
|
|
131
142
|
onActionPerformed(posts);
|
|
132
143
|
}
|
|
144
|
+
setIsBusy(false);
|
|
133
145
|
closeModal();
|
|
134
|
-
}
|
|
146
|
+
},
|
|
147
|
+
isBusy: isBusy,
|
|
148
|
+
disabled: isBusy,
|
|
149
|
+
__experimentalIsFocusable: true
|
|
135
150
|
}, (0, _i18n.__)('Delete'))));
|
|
136
151
|
}
|
|
137
152
|
};
|
|
@@ -237,32 +252,67 @@ function useRestorePostAction() {
|
|
|
237
252
|
return status === 'trash';
|
|
238
253
|
},
|
|
239
254
|
async callback(posts, onActionPerformed) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
255
|
+
await Promise.allSettled(posts.map(post => {
|
|
256
|
+
return editEntityRecord('postType', post.type, post.id, {
|
|
257
|
+
status: 'draft'
|
|
258
|
+
});
|
|
259
|
+
}));
|
|
260
|
+
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
261
|
+
return saveEditedEntityRecord('postType', post.type, post.id, {
|
|
262
|
+
throwOnError: true
|
|
263
|
+
});
|
|
264
|
+
}));
|
|
265
|
+
if (promiseResult.every(({
|
|
266
|
+
status
|
|
267
|
+
}) => status === 'fulfilled')) {
|
|
268
|
+
let successMessage;
|
|
269
|
+
if (posts.length === 1) {
|
|
270
|
+
successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
|
|
271
|
+
(0, _i18n.__)('"%s" has been restored.'), getItemTitle(posts[0]));
|
|
272
|
+
} else if (posts[0].type === 'page') {
|
|
273
|
+
successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
|
|
274
|
+
(0, _i18n.__)('%d pages have been restored.'), posts.length);
|
|
275
|
+
} else {
|
|
276
|
+
successMessage = (0, _i18n.sprintf)( /* translators: The number of posts. */
|
|
277
|
+
(0, _i18n.__)('%d posts have been restored.'), posts.length);
|
|
248
278
|
}
|
|
249
|
-
createSuccessNotice(
|
|
250
|
-
(0, _i18n.__)('%d posts have been restored.'), posts.length) : (0, _i18n.sprintf)( /* translators: The number of posts. */
|
|
251
|
-
(0, _i18n.__)('"%s" has been restored.'), getItemTitle(posts[0])), {
|
|
279
|
+
createSuccessNotice(successMessage, {
|
|
252
280
|
type: 'snackbar',
|
|
253
281
|
id: 'restore-post-action'
|
|
254
282
|
});
|
|
255
283
|
if (onActionPerformed) {
|
|
256
284
|
onActionPerformed(posts);
|
|
257
285
|
}
|
|
258
|
-
}
|
|
286
|
+
} else {
|
|
287
|
+
// If there was at lease one failure.
|
|
259
288
|
let errorMessage;
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
289
|
+
// If we were trying to move a single post to the trash.
|
|
290
|
+
if (promiseResult.length === 1) {
|
|
291
|
+
if (promiseResult[0].reason?.message) {
|
|
292
|
+
errorMessage = promiseResult[0].reason.message;
|
|
293
|
+
} else {
|
|
294
|
+
errorMessage = (0, _i18n.__)('An error occurred while restoring the post.');
|
|
295
|
+
}
|
|
296
|
+
// If we were trying to move multiple posts to the trash
|
|
264
297
|
} else {
|
|
265
|
-
|
|
298
|
+
const errorMessages = new Set();
|
|
299
|
+
const failedPromises = promiseResult.filter(({
|
|
300
|
+
status
|
|
301
|
+
}) => status === 'rejected');
|
|
302
|
+
for (const failedPromise of failedPromises) {
|
|
303
|
+
if (failedPromise.reason?.message) {
|
|
304
|
+
errorMessages.add(failedPromise.reason.message);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (errorMessages.size === 0) {
|
|
308
|
+
errorMessage = (0, _i18n.__)('An error occurred while restoring the posts.');
|
|
309
|
+
} else if (errorMessages.size === 1) {
|
|
310
|
+
errorMessage = (0, _i18n.sprintf)( /* translators: %s: an error message */
|
|
311
|
+
(0, _i18n.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
|
|
312
|
+
} else {
|
|
313
|
+
errorMessage = (0, _i18n.sprintf)( /* translators: %s: a list of comma separated error messages */
|
|
314
|
+
(0, _i18n.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
|
|
315
|
+
}
|
|
266
316
|
}
|
|
267
317
|
createErrorNotice(errorMessage, {
|
|
268
318
|
type: 'snackbar'
|
|
@@ -287,22 +337,6 @@ const viewPostAction = {
|
|
|
287
337
|
}
|
|
288
338
|
}
|
|
289
339
|
};
|
|
290
|
-
const editPostAction = {
|
|
291
|
-
id: 'edit-post',
|
|
292
|
-
label: (0, _i18n.__)('Edit'),
|
|
293
|
-
isPrimary: true,
|
|
294
|
-
icon: _icons.edit,
|
|
295
|
-
isEligible({
|
|
296
|
-
status
|
|
297
|
-
}) {
|
|
298
|
-
return status !== 'trash';
|
|
299
|
-
},
|
|
300
|
-
callback(posts, onActionPerformed) {
|
|
301
|
-
if (onActionPerformed) {
|
|
302
|
-
onActionPerformed(posts);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
};
|
|
306
340
|
const postRevisionsAction = {
|
|
307
341
|
id: 'view-post-revisions',
|
|
308
342
|
label: (0, _i18n.__)('View revisions'),
|
|
@@ -399,7 +433,7 @@ const renamePostAction = {
|
|
|
399
433
|
}, (0, _i18n.__)('Save')))));
|
|
400
434
|
}
|
|
401
435
|
};
|
|
402
|
-
const duplicatePostAction =
|
|
436
|
+
const duplicatePostAction = {
|
|
403
437
|
id: 'duplicate-post',
|
|
404
438
|
label: (0, _i18n._x)('Duplicate', 'action label'),
|
|
405
439
|
isEligible({
|
|
@@ -497,13 +531,16 @@ const resetTemplateAction = {
|
|
|
497
531
|
id: 'reset-template',
|
|
498
532
|
label: (0, _i18n.__)('Reset'),
|
|
499
533
|
isEligible: _isTemplateRevertable.default,
|
|
534
|
+
icon: _icons.backup,
|
|
500
535
|
supportsBulk: true,
|
|
501
536
|
hideModalHeader: true,
|
|
502
537
|
RenderModal: ({
|
|
503
538
|
items,
|
|
504
539
|
closeModal,
|
|
540
|
+
onActionStart,
|
|
505
541
|
onActionPerformed
|
|
506
542
|
}) => {
|
|
543
|
+
const [isBusy, setIsBusy] = (0, _element.useState)(false);
|
|
507
544
|
const {
|
|
508
545
|
revertTemplate
|
|
509
546
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
@@ -547,14 +584,24 @@ const resetTemplateAction = {
|
|
|
547
584
|
justify: "right"
|
|
548
585
|
}, (0, _react.createElement)(_components.Button, {
|
|
549
586
|
variant: "tertiary",
|
|
550
|
-
onClick: closeModal
|
|
587
|
+
onClick: closeModal,
|
|
588
|
+
disabled: isBusy,
|
|
589
|
+
__experimentalIsFocusable: true
|
|
551
590
|
}, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
|
|
552
591
|
variant: "primary",
|
|
553
592
|
onClick: async () => {
|
|
593
|
+
setIsBusy(true);
|
|
594
|
+
if (onActionStart) {
|
|
595
|
+
onActionStart(items);
|
|
596
|
+
}
|
|
554
597
|
await onConfirm(items);
|
|
555
598
|
onActionPerformed?.(items);
|
|
556
599
|
closeModal();
|
|
557
|
-
|
|
600
|
+
isBusy(false);
|
|
601
|
+
},
|
|
602
|
+
isBusy: isBusy,
|
|
603
|
+
disabled: isBusy,
|
|
604
|
+
__experimentalIsFocusable: true
|
|
558
605
|
}, (0, _i18n.__)('Reset'))));
|
|
559
606
|
}
|
|
560
607
|
};
|
|
@@ -576,13 +623,16 @@ const deleteTemplateAction = {
|
|
|
576
623
|
id: 'delete-template',
|
|
577
624
|
label: (0, _i18n.__)('Delete'),
|
|
578
625
|
isEligible: isTemplateRemovable,
|
|
626
|
+
icon: _icons.trash,
|
|
579
627
|
supportsBulk: true,
|
|
580
628
|
hideModalHeader: true,
|
|
581
629
|
RenderModal: ({
|
|
582
630
|
items: templates,
|
|
583
631
|
closeModal,
|
|
632
|
+
onActionStart,
|
|
584
633
|
onActionPerformed
|
|
585
634
|
}) => {
|
|
635
|
+
const [isBusy, setIsBusy] = (0, _element.useState)(false);
|
|
586
636
|
const {
|
|
587
637
|
removeTemplates
|
|
588
638
|
} = (0, _lockUnlock.unlock)((0, _data.useDispatch)(_store.store));
|
|
@@ -596,16 +646,26 @@ const deleteTemplateAction = {
|
|
|
596
646
|
justify: "right"
|
|
597
647
|
}, (0, _react.createElement)(_components.Button, {
|
|
598
648
|
variant: "tertiary",
|
|
599
|
-
onClick: closeModal
|
|
649
|
+
onClick: closeModal,
|
|
650
|
+
disabled: isBusy,
|
|
651
|
+
__experimentalIsFocusable: true
|
|
600
652
|
}, (0, _i18n.__)('Cancel')), (0, _react.createElement)(_components.Button, {
|
|
601
653
|
variant: "primary",
|
|
602
654
|
onClick: async () => {
|
|
655
|
+
setIsBusy(true);
|
|
656
|
+
if (onActionStart) {
|
|
657
|
+
onActionStart(templates);
|
|
658
|
+
}
|
|
603
659
|
await removeTemplates(templates, {
|
|
604
660
|
allowUndo: false
|
|
605
661
|
});
|
|
606
662
|
onActionPerformed?.(templates);
|
|
663
|
+
setIsBusy(false);
|
|
607
664
|
closeModal();
|
|
608
|
-
}
|
|
665
|
+
},
|
|
666
|
+
isBusy: isBusy,
|
|
667
|
+
disabled: isBusy,
|
|
668
|
+
__experimentalIsFocusable: true
|
|
609
669
|
}, (0, _i18n.__)('Delete'))));
|
|
610
670
|
}
|
|
611
671
|
};
|
|
@@ -687,18 +747,27 @@ const renameTemplateAction = {
|
|
|
687
747
|
}, (0, _i18n.__)('Save')))));
|
|
688
748
|
}
|
|
689
749
|
};
|
|
690
|
-
function usePostActions(
|
|
750
|
+
function usePostActions(postType, onActionPerformed) {
|
|
751
|
+
const {
|
|
752
|
+
postTypeObject
|
|
753
|
+
} = (0, _data.useSelect)(select => {
|
|
754
|
+
const {
|
|
755
|
+
getPostType
|
|
756
|
+
} = select(_coreData.store);
|
|
757
|
+
return {
|
|
758
|
+
postTypeObject: getPostType(postType)
|
|
759
|
+
};
|
|
760
|
+
}, [postType]);
|
|
691
761
|
const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
|
|
692
762
|
const restorePostAction = useRestorePostAction();
|
|
763
|
+
const isTemplateOrTemplatePart = [_constants.TEMPLATE_POST_TYPE, _constants.TEMPLATE_PART_POST_TYPE].includes(postType);
|
|
764
|
+
const isPattern = postType === _constants.PATTERN_POST_TYPE;
|
|
765
|
+
const isLoaded = !!postTypeObject;
|
|
693
766
|
return (0, _element.useMemo)(() => {
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
// actions matching the given IDs.
|
|
699
|
-
const actions = actionIds ? actionIds.map(actionId => defaultActions.find(({
|
|
700
|
-
id
|
|
701
|
-
}) => actionId === id)) : defaultActions;
|
|
767
|
+
if (!isLoaded) {
|
|
768
|
+
return [];
|
|
769
|
+
}
|
|
770
|
+
const actions = [isTemplateOrTemplatePart && resetTemplateAction, postTypeObject?.viewable && viewPostAction, !isTemplateOrTemplatePart && restorePostAction, isTemplateOrTemplatePart && deleteTemplateAction, !isTemplateOrTemplatePart && permanentlyDeletePostAction, postRevisionsAction, process.env.IS_GUTENBERG_PLUGIN ? !isTemplateOrTemplatePart && !isPattern && duplicatePostAction : false, !isTemplateOrTemplatePart && renamePostAction, isTemplateOrTemplatePart && renameTemplateAction, !isTemplateOrTemplatePart && trashPostAction].filter(Boolean);
|
|
702
771
|
if (onActionPerformed) {
|
|
703
772
|
for (let i = 0; i < actions.length; ++i) {
|
|
704
773
|
if (actions[i].callback) {
|
|
@@ -721,8 +790,7 @@ function usePostActions(onActionPerformed, actionIds = null) {
|
|
|
721
790
|
...actions[i],
|
|
722
791
|
RenderModal: props => {
|
|
723
792
|
return (0, _react.createElement)(ExistingRenderModal, {
|
|
724
|
-
|
|
725
|
-
closeModal: props.closeModal,
|
|
793
|
+
...props,
|
|
726
794
|
onActionPerformed: _items => {
|
|
727
795
|
if (props.onActionPerformed) {
|
|
728
796
|
props.onActionPerformed(_items);
|
|
@@ -736,16 +804,6 @@ function usePostActions(onActionPerformed, actionIds = null) {
|
|
|
736
804
|
}
|
|
737
805
|
}
|
|
738
806
|
return actions;
|
|
739
|
-
},
|
|
740
|
-
// Disable reason: if provided, `actionIds` is a shallow array of
|
|
741
|
-
// strings, and the strings themselves should be part of the useMemo
|
|
742
|
-
// dependencies. Two different disable statements are needed, as the
|
|
743
|
-
// first flags what it thinks are missing dependencies, and the second
|
|
744
|
-
// flags the array spread operation.
|
|
745
|
-
//
|
|
746
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
747
|
-
[
|
|
748
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
749
|
-
...(actionIds || []), permanentlyDeletePostAction, restorePostAction, onActionPerformed]);
|
|
807
|
+
}, [isTemplateOrTemplatePart, isPattern, postTypeObject?.viewable, permanentlyDeletePostAction, restorePostAction, onActionPerformed, isLoaded]);
|
|
750
808
|
}
|
|
751
809
|
//# sourceMappingURL=actions.js.map
|