@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useSelect","
|
|
1
|
+
{"version":3,"names":["useDispatch","useSelect","__experimentalLibrary","Library","store","blockEditorStore","useViewportMatch","useCallback","useRef","preferencesStore","ESCAPE","unlock","editorStore","InserterSidebar","closeGeneralSidebar","isRightSidebarOpen","blockSectionRootClientId","inserterSidebarToggleRef","insertionPoint","showMostUsedBlocks","select","getInserterSidebarToggleRef","getInsertionPoint","getBlockRootClientId","__unstableGetEditorMode","getSettings","get","getBlockSectionRootClientId","sectionRootClientId","setIsInserterOpened","isMobileViewport","libraryRef","closeInserterSidebar","current","focus","closeOnEscape","event","keyCode","defaultPrevented","preventDefault","createElement","onKeyDown","className","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":"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","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@ import { createElement } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* External dependencies
|
|
4
4
|
*/
|
|
5
|
-
import
|
|
5
|
+
import clsx from 'clsx';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -45,7 +45,7 @@ const ShortcutSection = ({
|
|
|
45
45
|
shortcuts,
|
|
46
46
|
className
|
|
47
47
|
}) => createElement("section", {
|
|
48
|
-
className:
|
|
48
|
+
className: clsx('editor-keyboard-shortcut-help-modal__section', className)
|
|
49
49
|
}, !!title && createElement("h2", {
|
|
50
50
|
className: "editor-keyboard-shortcut-help-modal__section-title"
|
|
51
51
|
}, title), createElement(ShortcutList, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["clsx","Modal","__","useShortcut","store","keyboardShortcutsStore","useDispatch","useSelect","interfaceStore","textFormattingShortcuts","Shortcut","DynamicShortcut","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","ShortcutList","shortcuts","createElement","className","role","map","shortcut","index","key","name","ShortcutSection","title","ShortcutCategorySection","categoryName","additionalShortcuts","categoryShortcuts","select","getCategoryShortcuts","concat","KeyboardShortcutHelpModal","isModalActive","openModal","closeModal","toggleModal","closeButtonLabel","onRequestClose","keyCombination","character","description","ariaLabel"],"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=\"list-view\"\n\t\t\t/>\n\t\t</Modal>\n\t);\n}\n\nexport default KeyboardShortcutHelpModal;\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,KAAK,QAAQ,uBAAuB;AAC7C,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,WAAW,EACXC,KAAK,IAAIC,sBAAsB,QACzB,+BAA+B;AACtC,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASH,KAAK,IAAII,cAAc,QAAQ,sBAAsB;;AAE9D;AACA;AACA;AACA,SAASC,uBAAuB,QAAQ,UAAU;AAClD,OAAOC,QAAQ,MAAM,YAAY;AACjC,OAAOC,eAAe,MAAM,oBAAoB;AAEhD,MAAMC,iCAAiC,GAAG,+BAA+B;AAEzE,MAAMC,YAAY,GAAGA,CAAE;EAAEC;AAAU,CAAC;AACnC;AACD;AACA;AACA;AACC;AACAC,aAAA;EACCC,SAAS,EAAC,oDAAoD;EAC9DC,IAAI,EAAC;AAAM,GAETH,SAAS,CAACI,GAAG,CAAE,CAAEC,QAAQ,EAAEC,KAAK,KACjCL,aAAA;EACCC,SAAS,EAAC,+CAA+C;EACzDK,GAAG,EAAGD;AAAO,GAEX,OAAOD,QAAQ,KAAK,QAAQ,GAC7BJ,aAAA,CAACJ,eAAe;EAACW,IAAI,EAAGH;AAAU,CAAE,CAAC,GAErCJ,aAAA,CAACL,QAAQ;EAAA,GAAMS;AAAQ,CAAI,CAEzB,CACH,CACC;AACJ,+CACA;AAED,MAAMI,eAAe,GAAGA,CAAE;EAAEC,KAAK;EAAEV,SAAS;EAAEE;AAAU,CAAC,KACxDD,aAAA;EACCC,SAAS,EAAGhB,IAAI,CACf,8CAA8C,EAC9CgB,SACD;AAAG,GAED,CAAC,CAAEQ,KAAK,IACTT,aAAA;EAAIC,SAAS,EAAC;AAAoD,GAC/DQ,KACC,CACJ,EACDT,aAAA,CAACF,YAAY;EAACC,SAAS,EAAGA;AAAW,CAAE,CAC/B,CACT;AAED,MAAMW,uBAAuB,GAAGA,CAAE;EACjCD,KAAK;EACLE,YAAY;EACZC,mBAAmB,GAAG;AACvB,CAAC,KAAM;EACN,MAAMC,iBAAiB,GAAGrB,SAAS,CAChCsB,MAAM,IAAM;IACb,OAAOA,MAAM,CAAExB,sBAAuB,CAAC,CAACyB,oBAAoB,CAC3DJ,YACD,CAAC;EACF,CAAC,EACD,CAAEA,YAAY,CACf,CAAC;EAED,OACCX,aAAA,CAACQ,eAAe;IACfC,KAAK,EAAGA,KAAO;IACfV,SAAS,EAAGc,iBAAiB,CAACG,MAAM,CAAEJ,mBAAoB;EAAG,CAC7D,CAAC;AAEJ,CAAC;AAED,SAASK,yBAAyBA,CAAA,EAAG;EACpC,MAAMC,aAAa,GAAG1B,SAAS,CAC5BsB,MAAM,IACPA,MAAM,CAAErB,cAAe,CAAC,CAACyB,aAAa,CACrCrB,iCACD,CAAC,EACF,EACD,CAAC;EACD,MAAM;IAAEsB,SAAS;IAAEC;EAAW,CAAC,GAAG7B,WAAW,CAAEE,cAAe,CAAC;EAC/D,MAAM4B,WAAW,GAAGA,CAAA,KAAM;IACzB,IAAKH,aAAa,EAAG;MACpBE,UAAU,CAAC,CAAC;IACb,CAAC,MAAM;MACND,SAAS,CAAEtB,iCAAkC,CAAC;IAC/C;EACD,CAAC;EACDT,WAAW,CAAE,gCAAgC,EAAEiC,WAAY,CAAC;EAE5D,IAAK,CAAEH,aAAa,EAAG;IACtB,OAAO,IAAI;EACZ;EAEA,OACClB,aAAA,CAACd,KAAK;IACLe,SAAS,EAAC,qCAAqC;IAC/CQ,KAAK,EAAGtB,EAAE,CAAE,oBAAqB,CAAG;IACpCmC,gBAAgB,EAAGnC,EAAE,CAAE,OAAQ,CAAG;IAClCoC,cAAc,EAAGF;EAAa,GAE9BrB,aAAA,CAACQ,eAAe;IACfP,SAAS,EAAC,qDAAqD;IAC/DF,SAAS,EAAG,CAAE,gCAAgC;EAAI,CAClD,CAAC,EACFC,aAAA,CAACU,uBAAuB;IACvBD,KAAK,EAAGtB,EAAE,CAAE,kBAAmB,CAAG;IAClCwB,YAAY,EAAC;EAAQ,CACrB,CAAC,EAEFX,aAAA,CAACU,uBAAuB;IACvBD,KAAK,EAAGtB,EAAE,CAAE,qBAAsB,CAAG;IACrCwB,YAAY,EAAC;EAAW,CACxB,CAAC,EAEFX,aAAA,CAACU,uBAAuB;IACvBD,KAAK,EAAGtB,EAAE,CAAE,iBAAkB,CAAG;IACjCwB,YAAY,EAAC,OAAO;IACpBC,mBAAmB,EAAG,CACrB;MACCY,cAAc,EAAE;QAAEC,SAAS,EAAE;MAAI,CAAC;MAClCC,WAAW,EAAEvC,EAAE,CACd,qDACD,CAAC;MACD;MACAwC,SAAS,EAAExC,EAAE,CAAE,eAAgB;IAChC,CAAC;EACC,CACH,CAAC,EACFa,aAAA,CAACQ,eAAe;IACfC,KAAK,EAAGtB,EAAE,CAAE,iBAAkB,CAAG;IACjCY,SAAS,EAAGL;EAAyB,CACrC,CAAC,EACFM,aAAA,CAACU,uBAAuB;IACvBD,KAAK,EAAGtB,EAAE,CAAE,qBAAsB,CAAG;IACrCwB,YAAY,EAAC;EAAW,CACxB,CACK,CAAC;AAEV;AAEA,eAAeM,yBAAyB","ignoreList":[]}
|
|
@@ -2,9 +2,9 @@ import { createElement } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { external, trash,
|
|
5
|
+
import { external, trash, backup } from '@wordpress/icons';
|
|
6
6
|
import { addQueryArgs } from '@wordpress/url';
|
|
7
|
-
import { useDispatch } from '@wordpress/data';
|
|
7
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
8
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
10
|
import { __, _n, sprintf, _x } from '@wordpress/i18n';
|
|
@@ -15,7 +15,7 @@ import { Button, TextControl, __experimentalText as Text, __experimentalHStack a
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
17
17
|
*/
|
|
18
|
-
import { TEMPLATE_ORIGINS, TEMPLATE_POST_TYPE } from '../../store/constants';
|
|
18
|
+
import { TEMPLATE_ORIGINS, TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE, PATTERN_POST_TYPE } from '../../store/constants';
|
|
19
19
|
import { store as editorStore } from '../../store';
|
|
20
20
|
import { unlock } from '../../lock-unlock';
|
|
21
21
|
import isTemplateRevertable from '../../store/utils/is-template-revertable';
|
|
@@ -40,8 +40,10 @@ const trashPostAction = {
|
|
|
40
40
|
RenderModal: ({
|
|
41
41
|
items: posts,
|
|
42
42
|
closeModal,
|
|
43
|
+
onActionStart,
|
|
43
44
|
onActionPerformed
|
|
44
45
|
}) => {
|
|
46
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
45
47
|
const {
|
|
46
48
|
createSuccessNotice,
|
|
47
49
|
createErrorNotice
|
|
@@ -59,10 +61,16 @@ const trashPostAction = {
|
|
|
59
61
|
justify: "right"
|
|
60
62
|
}, createElement(Button, {
|
|
61
63
|
variant: "tertiary",
|
|
62
|
-
onClick: closeModal
|
|
64
|
+
onClick: closeModal,
|
|
65
|
+
disabled: isBusy,
|
|
66
|
+
__experimentalIsFocusable: true
|
|
63
67
|
}, __('Cancel')), createElement(Button, {
|
|
64
68
|
variant: "primary",
|
|
65
69
|
onClick: async () => {
|
|
70
|
+
setIsBusy(true);
|
|
71
|
+
if (onActionStart) {
|
|
72
|
+
onActionStart(posts);
|
|
73
|
+
}
|
|
66
74
|
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
67
75
|
return deleteEntityRecord('postType', post.type, post.id, {}, {
|
|
68
76
|
throwOnError: true
|
|
@@ -76,8 +84,12 @@ const trashPostAction = {
|
|
|
76
84
|
if (promiseResult.length === 1) {
|
|
77
85
|
successMessage = sprintf( /* translators: The posts's title. */
|
|
78
86
|
__('"%s" moved to the Trash.'), getItemTitle(posts[0]));
|
|
87
|
+
} else if (posts[0].type === 'page') {
|
|
88
|
+
successMessage = sprintf( /* translators: The number of pages. */
|
|
89
|
+
__('%s pages moved to the Trash.'), posts.length);
|
|
79
90
|
} else {
|
|
80
|
-
successMessage =
|
|
91
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
92
|
+
__('%s posts moved to the Trash.'), posts.length);
|
|
81
93
|
}
|
|
82
94
|
createSuccessNotice(successMessage, {
|
|
83
95
|
type: 'snackbar',
|
|
@@ -121,8 +133,12 @@ const trashPostAction = {
|
|
|
121
133
|
if (onActionPerformed) {
|
|
122
134
|
onActionPerformed(posts);
|
|
123
135
|
}
|
|
136
|
+
setIsBusy(false);
|
|
124
137
|
closeModal();
|
|
125
|
-
}
|
|
138
|
+
},
|
|
139
|
+
isBusy: isBusy,
|
|
140
|
+
disabled: isBusy,
|
|
141
|
+
__experimentalIsFocusable: true
|
|
126
142
|
}, __('Delete'))));
|
|
127
143
|
}
|
|
128
144
|
};
|
|
@@ -228,32 +244,67 @@ function useRestorePostAction() {
|
|
|
228
244
|
return status === 'trash';
|
|
229
245
|
},
|
|
230
246
|
async callback(posts, onActionPerformed) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
247
|
+
await Promise.allSettled(posts.map(post => {
|
|
248
|
+
return editEntityRecord('postType', post.type, post.id, {
|
|
249
|
+
status: 'draft'
|
|
250
|
+
});
|
|
251
|
+
}));
|
|
252
|
+
const promiseResult = await Promise.allSettled(posts.map(post => {
|
|
253
|
+
return saveEditedEntityRecord('postType', post.type, post.id, {
|
|
254
|
+
throwOnError: true
|
|
255
|
+
});
|
|
256
|
+
}));
|
|
257
|
+
if (promiseResult.every(({
|
|
258
|
+
status
|
|
259
|
+
}) => status === 'fulfilled')) {
|
|
260
|
+
let successMessage;
|
|
261
|
+
if (posts.length === 1) {
|
|
262
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
263
|
+
__('"%s" has been restored.'), getItemTitle(posts[0]));
|
|
264
|
+
} else if (posts[0].type === 'page') {
|
|
265
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
266
|
+
__('%d pages have been restored.'), posts.length);
|
|
267
|
+
} else {
|
|
268
|
+
successMessage = sprintf( /* translators: The number of posts. */
|
|
269
|
+
__('%d posts have been restored.'), posts.length);
|
|
239
270
|
}
|
|
240
|
-
createSuccessNotice(
|
|
241
|
-
__('%d posts have been restored.'), posts.length) : sprintf( /* translators: The number of posts. */
|
|
242
|
-
__('"%s" has been restored.'), getItemTitle(posts[0])), {
|
|
271
|
+
createSuccessNotice(successMessage, {
|
|
243
272
|
type: 'snackbar',
|
|
244
273
|
id: 'restore-post-action'
|
|
245
274
|
});
|
|
246
275
|
if (onActionPerformed) {
|
|
247
276
|
onActionPerformed(posts);
|
|
248
277
|
}
|
|
249
|
-
}
|
|
278
|
+
} else {
|
|
279
|
+
// If there was at lease one failure.
|
|
250
280
|
let errorMessage;
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
281
|
+
// If we were trying to move a single post to the trash.
|
|
282
|
+
if (promiseResult.length === 1) {
|
|
283
|
+
if (promiseResult[0].reason?.message) {
|
|
284
|
+
errorMessage = promiseResult[0].reason.message;
|
|
285
|
+
} else {
|
|
286
|
+
errorMessage = __('An error occurred while restoring the post.');
|
|
287
|
+
}
|
|
288
|
+
// If we were trying to move multiple posts to the trash
|
|
255
289
|
} else {
|
|
256
|
-
|
|
290
|
+
const errorMessages = new Set();
|
|
291
|
+
const failedPromises = promiseResult.filter(({
|
|
292
|
+
status
|
|
293
|
+
}) => status === 'rejected');
|
|
294
|
+
for (const failedPromise of failedPromises) {
|
|
295
|
+
if (failedPromise.reason?.message) {
|
|
296
|
+
errorMessages.add(failedPromise.reason.message);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (errorMessages.size === 0) {
|
|
300
|
+
errorMessage = __('An error occurred while restoring the posts.');
|
|
301
|
+
} else if (errorMessages.size === 1) {
|
|
302
|
+
errorMessage = sprintf( /* translators: %s: an error message */
|
|
303
|
+
__('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
|
|
304
|
+
} else {
|
|
305
|
+
errorMessage = sprintf( /* translators: %s: a list of comma separated error messages */
|
|
306
|
+
__('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
|
|
307
|
+
}
|
|
257
308
|
}
|
|
258
309
|
createErrorNotice(errorMessage, {
|
|
259
310
|
type: 'snackbar'
|
|
@@ -278,22 +329,6 @@ const viewPostAction = {
|
|
|
278
329
|
}
|
|
279
330
|
}
|
|
280
331
|
};
|
|
281
|
-
const editPostAction = {
|
|
282
|
-
id: 'edit-post',
|
|
283
|
-
label: __('Edit'),
|
|
284
|
-
isPrimary: true,
|
|
285
|
-
icon: edit,
|
|
286
|
-
isEligible({
|
|
287
|
-
status
|
|
288
|
-
}) {
|
|
289
|
-
return status !== 'trash';
|
|
290
|
-
},
|
|
291
|
-
callback(posts, onActionPerformed) {
|
|
292
|
-
if (onActionPerformed) {
|
|
293
|
-
onActionPerformed(posts);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
};
|
|
297
332
|
const postRevisionsAction = {
|
|
298
333
|
id: 'view-post-revisions',
|
|
299
334
|
label: __('View revisions'),
|
|
@@ -390,7 +425,7 @@ const renamePostAction = {
|
|
|
390
425
|
}, __('Save')))));
|
|
391
426
|
}
|
|
392
427
|
};
|
|
393
|
-
|
|
428
|
+
const duplicatePostAction = {
|
|
394
429
|
id: 'duplicate-post',
|
|
395
430
|
label: _x('Duplicate', 'action label'),
|
|
396
431
|
isEligible({
|
|
@@ -488,13 +523,16 @@ const resetTemplateAction = {
|
|
|
488
523
|
id: 'reset-template',
|
|
489
524
|
label: __('Reset'),
|
|
490
525
|
isEligible: isTemplateRevertable,
|
|
526
|
+
icon: backup,
|
|
491
527
|
supportsBulk: true,
|
|
492
528
|
hideModalHeader: true,
|
|
493
529
|
RenderModal: ({
|
|
494
530
|
items,
|
|
495
531
|
closeModal,
|
|
532
|
+
onActionStart,
|
|
496
533
|
onActionPerformed
|
|
497
534
|
}) => {
|
|
535
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
498
536
|
const {
|
|
499
537
|
revertTemplate
|
|
500
538
|
} = unlock(useDispatch(editorStore));
|
|
@@ -538,14 +576,24 @@ const resetTemplateAction = {
|
|
|
538
576
|
justify: "right"
|
|
539
577
|
}, createElement(Button, {
|
|
540
578
|
variant: "tertiary",
|
|
541
|
-
onClick: closeModal
|
|
579
|
+
onClick: closeModal,
|
|
580
|
+
disabled: isBusy,
|
|
581
|
+
__experimentalIsFocusable: true
|
|
542
582
|
}, __('Cancel')), createElement(Button, {
|
|
543
583
|
variant: "primary",
|
|
544
584
|
onClick: async () => {
|
|
585
|
+
setIsBusy(true);
|
|
586
|
+
if (onActionStart) {
|
|
587
|
+
onActionStart(items);
|
|
588
|
+
}
|
|
545
589
|
await onConfirm(items);
|
|
546
590
|
onActionPerformed?.(items);
|
|
547
591
|
closeModal();
|
|
548
|
-
|
|
592
|
+
isBusy(false);
|
|
593
|
+
},
|
|
594
|
+
isBusy: isBusy,
|
|
595
|
+
disabled: isBusy,
|
|
596
|
+
__experimentalIsFocusable: true
|
|
549
597
|
}, __('Reset'))));
|
|
550
598
|
}
|
|
551
599
|
};
|
|
@@ -567,13 +615,16 @@ const deleteTemplateAction = {
|
|
|
567
615
|
id: 'delete-template',
|
|
568
616
|
label: __('Delete'),
|
|
569
617
|
isEligible: isTemplateRemovable,
|
|
618
|
+
icon: trash,
|
|
570
619
|
supportsBulk: true,
|
|
571
620
|
hideModalHeader: true,
|
|
572
621
|
RenderModal: ({
|
|
573
622
|
items: templates,
|
|
574
623
|
closeModal,
|
|
624
|
+
onActionStart,
|
|
575
625
|
onActionPerformed
|
|
576
626
|
}) => {
|
|
627
|
+
const [isBusy, setIsBusy] = useState(false);
|
|
577
628
|
const {
|
|
578
629
|
removeTemplates
|
|
579
630
|
} = unlock(useDispatch(editorStore));
|
|
@@ -587,16 +638,26 @@ const deleteTemplateAction = {
|
|
|
587
638
|
justify: "right"
|
|
588
639
|
}, createElement(Button, {
|
|
589
640
|
variant: "tertiary",
|
|
590
|
-
onClick: closeModal
|
|
641
|
+
onClick: closeModal,
|
|
642
|
+
disabled: isBusy,
|
|
643
|
+
__experimentalIsFocusable: true
|
|
591
644
|
}, __('Cancel')), createElement(Button, {
|
|
592
645
|
variant: "primary",
|
|
593
646
|
onClick: async () => {
|
|
647
|
+
setIsBusy(true);
|
|
648
|
+
if (onActionStart) {
|
|
649
|
+
onActionStart(templates);
|
|
650
|
+
}
|
|
594
651
|
await removeTemplates(templates, {
|
|
595
652
|
allowUndo: false
|
|
596
653
|
});
|
|
597
654
|
onActionPerformed?.(templates);
|
|
655
|
+
setIsBusy(false);
|
|
598
656
|
closeModal();
|
|
599
|
-
}
|
|
657
|
+
},
|
|
658
|
+
isBusy: isBusy,
|
|
659
|
+
disabled: isBusy,
|
|
660
|
+
__experimentalIsFocusable: true
|
|
600
661
|
}, __('Delete'))));
|
|
601
662
|
}
|
|
602
663
|
};
|
|
@@ -678,18 +739,27 @@ const renameTemplateAction = {
|
|
|
678
739
|
}, __('Save')))));
|
|
679
740
|
}
|
|
680
741
|
};
|
|
681
|
-
export function usePostActions(
|
|
742
|
+
export function usePostActions(postType, onActionPerformed) {
|
|
743
|
+
const {
|
|
744
|
+
postTypeObject
|
|
745
|
+
} = useSelect(select => {
|
|
746
|
+
const {
|
|
747
|
+
getPostType
|
|
748
|
+
} = select(coreStore);
|
|
749
|
+
return {
|
|
750
|
+
postTypeObject: getPostType(postType)
|
|
751
|
+
};
|
|
752
|
+
}, [postType]);
|
|
682
753
|
const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
|
|
683
754
|
const restorePostAction = useRestorePostAction();
|
|
755
|
+
const isTemplateOrTemplatePart = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
|
|
756
|
+
const isPattern = postType === PATTERN_POST_TYPE;
|
|
757
|
+
const isLoaded = !!postTypeObject;
|
|
684
758
|
return useMemo(() => {
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
// actions matching the given IDs.
|
|
690
|
-
const actions = actionIds ? actionIds.map(actionId => defaultActions.find(({
|
|
691
|
-
id
|
|
692
|
-
}) => actionId === id)) : defaultActions;
|
|
759
|
+
if (!isLoaded) {
|
|
760
|
+
return [];
|
|
761
|
+
}
|
|
762
|
+
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);
|
|
693
763
|
if (onActionPerformed) {
|
|
694
764
|
for (let i = 0; i < actions.length; ++i) {
|
|
695
765
|
if (actions[i].callback) {
|
|
@@ -712,8 +782,7 @@ export function usePostActions(onActionPerformed, actionIds = null) {
|
|
|
712
782
|
...actions[i],
|
|
713
783
|
RenderModal: props => {
|
|
714
784
|
return createElement(ExistingRenderModal, {
|
|
715
|
-
|
|
716
|
-
closeModal: props.closeModal,
|
|
785
|
+
...props,
|
|
717
786
|
onActionPerformed: _items => {
|
|
718
787
|
if (props.onActionPerformed) {
|
|
719
788
|
props.onActionPerformed(_items);
|
|
@@ -727,16 +796,6 @@ export function usePostActions(onActionPerformed, actionIds = null) {
|
|
|
727
796
|
}
|
|
728
797
|
}
|
|
729
798
|
return actions;
|
|
730
|
-
},
|
|
731
|
-
// Disable reason: if provided, `actionIds` is a shallow array of
|
|
732
|
-
// strings, and the strings themselves should be part of the useMemo
|
|
733
|
-
// dependencies. Two different disable statements are needed, as the
|
|
734
|
-
// first flags what it thinks are missing dependencies, and the second
|
|
735
|
-
// flags the array spread operation.
|
|
736
|
-
//
|
|
737
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
738
|
-
[
|
|
739
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
740
|
-
...(actionIds || []), permanentlyDeletePostAction, restorePostAction, onActionPerformed]);
|
|
799
|
+
}, [isTemplateOrTemplatePart, isPattern, postTypeObject?.viewable, permanentlyDeletePostAction, restorePostAction, onActionPerformed, isLoaded]);
|
|
741
800
|
}
|
|
742
801
|
//# sourceMappingURL=actions.js.map
|