@wordpress/edit-site 5.12.2 → 5.12.4
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/build/components/header-edit-mode/more-menu/index.js +12 -16
- package/build/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcut-help-modal/index.js +17 -4
- package/build/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build/components/page-library/grid-item.js +1 -1
- package/build/components/page-library/grid-item.js.map +1 -1
- package/build/components/preferences-modal/index.js +13 -4
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/hooks/commands/use-edit-mode-commands.js +23 -0
- package/build/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-module/components/header-edit-mode/more-menu/index.js +9 -17
- package/build-module/components/header-edit-mode/more-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcut-help-modal/index.js +15 -6
- package/build-module/components/keyboard-shortcut-help-modal/index.js.map +1 -1
- package/build-module/components/page-library/grid-item.js +1 -1
- package/build-module/components/page-library/grid-item.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +14 -8
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js +22 -1
- package/build-module/hooks/commands/use-edit-mode-commands.js.map +1 -1
- package/build-style/style-rtl.css +1 -5
- package/build-style/style.css +1 -5
- package/package.json +14 -14
- package/src/components/header-edit-mode/more-menu/index.js +26 -27
- package/src/components/keyboard-shortcut-help-modal/index.js +21 -7
- package/src/components/page-library/grid-item.js +1 -1
- package/src/components/preferences-modal/index.js +13 -7
- package/src/components/sidebar-navigation-item/style.scss +1 -0
- package/src/components/sidebar-navigation-screen-navigation-menu/style.scss +0 -5
- package/src/components/start-template-options/style.scss +0 -3
- package/src/hooks/commands/use-edit-mode-commands.js +24 -2
|
@@ -10,8 +10,9 @@ import classnames from 'classnames';
|
|
|
10
10
|
|
|
11
11
|
import { Modal } from '@wordpress/components';
|
|
12
12
|
import { __ } from '@wordpress/i18n';
|
|
13
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
14
|
-
import {
|
|
13
|
+
import { useShortcut, store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
14
|
+
import { store as interfaceStore } from '@wordpress/interface';
|
|
15
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
15
16
|
/**
|
|
16
17
|
* Internal dependencies
|
|
17
18
|
*/
|
|
@@ -19,6 +20,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
19
20
|
import { textFormattingShortcuts } from './config';
|
|
20
21
|
import Shortcut from './shortcut';
|
|
21
22
|
import DynamicShortcut from './dynamic-shortcut';
|
|
23
|
+
export const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'edit-site/keyboard-shortcut-help';
|
|
22
24
|
|
|
23
25
|
const ShortcutList = ({
|
|
24
26
|
shortcuts
|
|
@@ -68,10 +70,17 @@ const ShortcutCategorySection = ({
|
|
|
68
70
|
});
|
|
69
71
|
};
|
|
70
72
|
|
|
71
|
-
export default function KeyboardShortcutHelpModal({
|
|
72
|
-
isModalActive
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
export default function KeyboardShortcutHelpModal() {
|
|
74
|
+
const isModalActive = useSelect(select => select(interfaceStore).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME));
|
|
75
|
+
const {
|
|
76
|
+
closeModal,
|
|
77
|
+
openModal
|
|
78
|
+
} = useDispatch(interfaceStore);
|
|
79
|
+
|
|
80
|
+
const toggleModal = () => isModalActive ? closeModal() : openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
|
|
81
|
+
|
|
82
|
+
useShortcut('core/edit-site/keyboard-shortcuts', toggleModal);
|
|
83
|
+
|
|
75
84
|
if (!isModalActive) {
|
|
76
85
|
return null;
|
|
77
86
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/keyboard-shortcut-help-modal/index.js"],"names":["classnames","Modal","__","store","keyboardShortcutsStore","useSelect","textFormattingShortcuts","Shortcut","DynamicShortcut","ShortcutList","shortcuts","map","shortcut","index","ShortcutSection","title","className","ShortcutCategorySection","categoryName","additionalShortcuts","categoryShortcuts","select","getCategoryShortcuts","concat","KeyboardShortcutHelpModal","isModalActive","toggleModal","keyCombination","character","description","ariaLabel"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/keyboard-shortcut-help-modal/index.js"],"names":["classnames","Modal","__","useShortcut","store","keyboardShortcutsStore","interfaceStore","useSelect","useDispatch","textFormattingShortcuts","Shortcut","DynamicShortcut","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","ShortcutList","shortcuts","map","shortcut","index","ShortcutSection","title","className","ShortcutCategorySection","categoryName","additionalShortcuts","categoryShortcuts","select","getCategoryShortcuts","concat","KeyboardShortcutHelpModal","isModalActive","closeModal","openModal","toggleModal","keyCombination","character","description","ariaLabel"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,KAAT,QAAsB,uBAAtB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,WADD,EAECC,KAAK,IAAIC,sBAFV,QAGO,+BAHP;AAIA,SAASD,KAAK,IAAIE,cAAlB,QAAwC,sBAAxC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AAEA;AACA;AACA;;AACA,SAASC,uBAAT,QAAwC,UAAxC;AACA,OAAOC,QAAP,MAAqB,YAArB;AACA,OAAOC,eAAP,MAA4B,oBAA5B;AAEA,OAAO,MAAMC,iCAAiC,GAC7C,kCADM;;AAGP,MAAMC,YAAY,GAAG,CAAE;AAAE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D,CADD;AAwCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\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 { store as interfaceStore } from '@wordpress/interface';\nimport { useSelect, useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { textFormattingShortcuts } from './config';\nimport Shortcut from './shortcut';\nimport DynamicShortcut from './dynamic-shortcut';\n\nexport const KEYBOARD_SHORTCUT_HELP_MODAL_NAME =\n\t'edit-site/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=\"edit-site-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=\"edit-site-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={ classnames(\n\t\t\t'edit-site-keyboard-shortcut-help-modal__section',\n\t\t\tclassName\n\t\t) }\n\t>\n\t\t{ !! title && (\n\t\t\t<h2 className=\"edit-site-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\nexport default function KeyboardShortcutHelpModal() {\n\tconst isModalActive = useSelect( ( select ) =>\n\t\tselect( interfaceStore ).isModalActive(\n\t\t\tKEYBOARD_SHORTCUT_HELP_MODAL_NAME\n\t\t)\n\t);\n\tconst { closeModal, openModal } = useDispatch( interfaceStore );\n\tconst toggleModal = () =>\n\t\tisModalActive\n\t\t\t? closeModal()\n\t\t\t: openModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\tuseShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"edit-site-keyboard-shortcut-help-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ toggleModal }\n\t\t>\n\t\t\t<ShortcutSection\n\t\t\t\tclassName=\"edit-site-keyboard-shortcut-help-modal__main-shortcuts\"\n\t\t\t\tshortcuts={ [ 'core/edit-site/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</Modal>\n\t);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/page-library/grid-item.js"],"names":["classnames","BlockPreview","__experimentalConfirmDialog","ConfirmDialog","DropdownMenu","MenuGroup","MenuItem","__experimentalHeading","Heading","__experimentalHStack","HStack","__unstableCompositeItem","CompositeItem","useInstanceId","useDispatch","useState","__","sprintf","Icon","moreHorizontal","store","noticesStore","reusableBlocksStore","DELETE","BACKSPACE","PATTERNS","USER_PATTERNS","useLink","GridItem","categoryId","composite","icon","item","instanceId","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","__experimentalDeleteReusableBlock","createErrorNotice","createSuccessNotice","onClick","postType","type","postId","id","name","categoryType","canvas","onKeyDown","event","keyCode","isEmpty","blocks","length","patternClassNames","previewClassNames","deletePattern","error","errorMessage","message","code","isUserPattern","ariaDescription","description","undefined","title","display","placement","className","isSmall","describedBy","tabIndex"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,yBAA7B;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,qBAAqB,IAAIC,OAL1B,EAMCC,oBAAoB,IA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AAA,IAAI,EAAGP,cADR;AAEC,IAAA,KAAK,EAAGH,EAAE,CAAE,SAAF,CAFX;AAGC,IAAA,SAAS,EAAC,6BAHX;AAIC,IAAA,YAAY,EAAG;AAAEmD,MAAAA,SAAS,EAAE;AAAb,KAJhB;AAKC,IAAA,WAAW,EAAG;AACbC,MAAAA,SAAS,EAAE,2BADE;AAEbC,MAAAA,OAAO,EAAE,IAFI;AAGbC,MAAAA,WAAW,EAAErD,OAAO;AACnB;AACAD,MAAAA,EAAE,CAAE,4BAAF,CAFiB,EAGnBgB,IAAI,CAACiC,KAHc,CAHP;AAQb;AACA;AACA;AACA;AACAM,MAAAA,QAAQ,EAAE,CAAC;AAZE;AALf,KAoBG,MACD,cAAC,SAAD,QACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MACTnC,qBAAqB,CAAE,IAAF;AAFvB,KAKGpB,EAAE,CAAE,QAAF,CALL,CADD,CArBF,CAfF,CAzBD,CADD,EA4EGmB,kBAAkB,IACnB,cAAC,aAAD;AACC,IAAA,SAAS,EAAGqB,aADb;AAEC,IAAA,QAAQ,EAAG,MAAMpB,qBAAqB,CAAE,KAAF;AAFvC,KAIGpB,EAAE,CAAE,+CAAF,CAJL,CA7EF,CADD;AAuFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalHStack as HStack,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, moreHorizontal } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { PATTERNS, USER_PATTERNS } from './utils';\nimport { useLink } from '../routes/link';\n\nexport default function GridItem( { categoryId, composite, icon, item } ) {\n\tconst instanceId = useInstanceId( GridItem );\n\tconst descriptionId = `edit-site-library__pattern-description-${ instanceId }`;\n\tconst [ isDeleteDialogOpen, setIsDeleteDialogOpen ] = useState( false );\n\n\tconst { __experimentalDeleteReusableBlock } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: item.type === USER_PATTERNS ? item.id : item.name,\n\t\tcategoryId,\n\t\tcategoryType: item.type,\n\t\tcanvas: 'edit',\n\t} );\n\n\tconst onKeyDown = ( event ) => {\n\t\tif ( DELETE === event.keyCode || BACKSPACE === event.keyCode ) {\n\t\t\tsetIsDeleteDialogOpen( true );\n\t\t}\n\t};\n\n\tconst isEmpty = ! item.blocks?.length;\n\tconst patternClassNames = classnames( 'edit-site-library__pattern', {\n\t\t'is-placeholder': isEmpty,\n\t} );\n\tconst previewClassNames = classnames( 'edit-site-library__preview', {\n\t\t'is-inactive': item.type === PATTERNS,\n\t} );\n\n\tconst deletePattern = async () => {\n\t\ttry {\n\t\t\tawait __experimentalDeleteReusableBlock( item.id );\n\t\t\tcreateSuccessNotice( __( 'Pattern successfully deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the pattern.' );\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n\tconst isUserPattern = item.type === USER_PATTERNS;\n\tlet ariaDescription;\n\tif ( isUserPattern ) {\n\t\t// User patterns don't have descriptions, but can be edited and deleted, so include some help text.\n\t\tariaDescription = __(\n\t\t\t'Press Enter to edit, or Delete to delete the pattern.'\n\t\t);\n\t} else if ( item.description ) {\n\t\tariaDescription = item.description;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className={ patternClassNames }>\n\t\t\t\t<CompositeItem\n\t\t\t\t\tclassName={ previewClassNames }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tas=\"div\"\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tonClick={ item.type !== PATTERNS ? onClick : undefined }\n\t\t\t\t\tonKeyDown={ isUserPattern ? onKeyDown : undefined }\n\t\t\t\t\taria-label={ item.title }\n\t\t\t\t\taria-describedby={\n\t\t\t\t\t\tariaDescription ? descriptionId : undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty pattern' ) }\n\t\t\t\t\t{ ! isEmpty && <BlockPreview blocks={ item.blocks } /> }\n\t\t\t\t</CompositeItem>\n\t\t\t\t{ ariaDescription && (\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ariaDescription }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<HStack\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName=\"edit-site-library__footer\"\n\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\t\tclassName=\"edit-site-library__pattern-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon && <Icon icon={ icon } /> }\n\t\t\t\t\t\t<Heading level={ 5 }>{ item.title }</Heading>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t{ item.type === USER_PATTERNS && (\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-library__dropdown\"\n\t\t\t\t\t\t\tpopoverProps={ { placement: 'bottom-end' } }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tclassName: 'edit-site-library__button',\n\t\t\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\t\t\tdescribedBy: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: pattern name */\n\t\t\t\t\t\t\t\t\t__( 'Action menu for %s pattern' ),\n\t\t\t\t\t\t\t\t\titem.title\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// The dropdown menu is not focusable using the\n\t\t\t\t\t\t\t\t// keyboard as this would interfere with the grid's\n\t\t\t\t\t\t\t\t// roving tab index system. Instead, keyboard users\n\t\t\t\t\t\t\t\t// use keyboard shortcuts to trigger actions.\n\t\t\t\t\t\t\t\ttabIndex: -1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetIsDeleteDialogOpen( true )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t{ isDeleteDialogOpen && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tonConfirm={ deletePattern }\n\t\t\t\t\tonCancel={ () => setIsDeleteDialogOpen( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Are you sure you want to delete this pattern?' ) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/page-library/grid-item.js"],"names":["classnames","BlockPreview","__experimentalConfirmDialog","ConfirmDialog","DropdownMenu","MenuGroup","MenuItem","__experimentalHeading","Heading","__experimentalHStack","HStack","__unstableCompositeItem","CompositeItem","useInstanceId","useDispatch","useState","__","sprintf","Icon","moreHorizontal","store","noticesStore","reusableBlocksStore","DELETE","BACKSPACE","PATTERNS","USER_PATTERNS","useLink","GridItem","categoryId","composite","icon","item","instanceId","descriptionId","isDeleteDialogOpen","setIsDeleteDialogOpen","__experimentalDeleteReusableBlock","createErrorNotice","createSuccessNotice","onClick","postType","type","postId","id","name","categoryType","canvas","onKeyDown","event","keyCode","isEmpty","blocks","length","patternClassNames","previewClassNames","deletePattern","error","errorMessage","message","code","isUserPattern","ariaDescription","description","undefined","title","display","placement","className","isSmall","describedBy","tabIndex"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,QAA6B,yBAA7B;AACA,SACCC,2BAA2B,IAAIC,aADhC,EAECC,YAFD,EAGCC,SAHD,EAICC,QAJD,EAKCC,qBAAqB,IAAIC,OAL1B,EAMCC,oBAAoB,IAAIC,MANzB,EAOCC,uBAAuB,IAAIC,aAP5B,QAQO,uBARP;AASA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,EAAeC,cAAf,QAAqC,kBAArC;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASD,KAAK,IAAIE,m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E,CAAE,4BAAF,CAFiB,EAGnBgB,IAAI,CAACiC,KAHc,CAHP;AAQb;AACA;AACA;AACA;AACAM,MAAAA,QAAQ,EAAE,CAAC;AAZE;AALf,KAoBG,MACD,cAAC,SAAD,QACC,cAAC,QAAD;AACC,IAAA,OAAO,EAAG,MACTnC,qBAAqB,CAAE,IAAF;AAFvB,KAKGpB,EAAE,CAAE,QAAF,CALL,CADD,CArBF,CAfF,CAzBD,CADD,EA4EGmB,kBAAkB,IACnB,cAAC,aAAD;AACC,IAAA,SAAS,EAAGqB,aADb;AAEC,IAAA,QAAQ,EAAG,MAAMpB,qBAAqB,CAAE,KAAF;AAFvC,KAIGpB,EAAE,CAAE,+CAAF,CAJL,CA7EF,CADD;AAuFA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { BlockPreview } from '@wordpress/block-editor';\nimport {\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\t__experimentalHeading as Heading,\n\t__experimentalHStack as HStack,\n\t__unstableCompositeItem as CompositeItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useDispatch } from '@wordpress/data';\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, moreHorizontal } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as reusableBlocksStore } from '@wordpress/reusable-blocks';\nimport { DELETE, BACKSPACE } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport { PATTERNS, USER_PATTERNS } from './utils';\nimport { useLink } from '../routes/link';\n\nexport default function GridItem( { categoryId, composite, icon, item } ) {\n\tconst instanceId = useInstanceId( GridItem );\n\tconst descriptionId = `edit-site-library__pattern-description-${ instanceId }`;\n\tconst [ isDeleteDialogOpen, setIsDeleteDialogOpen ] = useState( false );\n\n\tconst { __experimentalDeleteReusableBlock } =\n\t\tuseDispatch( reusableBlocksStore );\n\tconst { createErrorNotice, createSuccessNotice } =\n\t\tuseDispatch( noticesStore );\n\n\tconst { onClick } = useLink( {\n\t\tpostType: item.type,\n\t\tpostId: item.type === USER_PATTERNS ? item.id : item.name,\n\t\tcategoryId,\n\t\tcategoryType: item.type,\n\t\tcanvas: 'view',\n\t} );\n\n\tconst onKeyDown = ( event ) => {\n\t\tif ( DELETE === event.keyCode || BACKSPACE === event.keyCode ) {\n\t\t\tsetIsDeleteDialogOpen( true );\n\t\t}\n\t};\n\n\tconst isEmpty = ! item.blocks?.length;\n\tconst patternClassNames = classnames( 'edit-site-library__pattern', {\n\t\t'is-placeholder': isEmpty,\n\t} );\n\tconst previewClassNames = classnames( 'edit-site-library__preview', {\n\t\t'is-inactive': item.type === PATTERNS,\n\t} );\n\n\tconst deletePattern = async () => {\n\t\ttry {\n\t\t\tawait __experimentalDeleteReusableBlock( item.id );\n\t\t\tcreateSuccessNotice( __( 'Pattern successfully deleted.' ), {\n\t\t\t\ttype: 'snackbar',\n\t\t\t} );\n\t\t} catch ( error ) {\n\t\t\tconst errorMessage =\n\t\t\t\terror.message && error.code !== 'unknown_error'\n\t\t\t\t\t? error.message\n\t\t\t\t\t: __( 'An error occurred while deleting the pattern.' );\n\t\t\tcreateErrorNotice( errorMessage, { type: 'snackbar' } );\n\t\t}\n\t};\n\n\tconst isUserPattern = item.type === USER_PATTERNS;\n\tlet ariaDescription;\n\tif ( isUserPattern ) {\n\t\t// User patterns don't have descriptions, but can be edited and deleted, so include some help text.\n\t\tariaDescription = __(\n\t\t\t'Press Enter to edit, or Delete to delete the pattern.'\n\t\t);\n\t} else if ( item.description ) {\n\t\tariaDescription = item.description;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<div className={ patternClassNames }>\n\t\t\t\t<CompositeItem\n\t\t\t\t\tclassName={ previewClassNames }\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tas=\"div\"\n\t\t\t\t\t{ ...composite }\n\t\t\t\t\tonClick={ item.type !== PATTERNS ? onClick : undefined }\n\t\t\t\t\tonKeyDown={ isUserPattern ? onKeyDown : undefined }\n\t\t\t\t\taria-label={ item.title }\n\t\t\t\t\taria-describedby={\n\t\t\t\t\t\tariaDescription ? descriptionId : undefined\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ isEmpty && __( 'Empty pattern' ) }\n\t\t\t\t\t{ ! isEmpty && <BlockPreview blocks={ item.blocks } /> }\n\t\t\t\t</CompositeItem>\n\t\t\t\t{ ariaDescription && (\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\tstyle={ { display: 'none' } }\n\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ ariaDescription }\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t\t<HStack\n\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\tclassName=\"edit-site-library__footer\"\n\t\t\t\t\tjustify=\"space-between\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\talignment=\"center\"\n\t\t\t\t\t\tjustify=\"left\"\n\t\t\t\t\t\tspacing={ 3 }\n\t\t\t\t\t\tclassName=\"edit-site-library__pattern-title\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ icon && <Icon icon={ icon } /> }\n\t\t\t\t\t\t<Heading level={ 5 }>{ item.title }</Heading>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t{ item.type === USER_PATTERNS && (\n\t\t\t\t\t\t<DropdownMenu\n\t\t\t\t\t\t\ticon={ moreHorizontal }\n\t\t\t\t\t\t\tlabel={ __( 'Actions' ) }\n\t\t\t\t\t\t\tclassName=\"edit-site-library__dropdown\"\n\t\t\t\t\t\t\tpopoverProps={ { placement: 'bottom-end' } }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tclassName: 'edit-site-library__button',\n\t\t\t\t\t\t\t\tisSmall: true,\n\t\t\t\t\t\t\t\tdescribedBy: sprintf(\n\t\t\t\t\t\t\t\t\t/* translators: %s: pattern name */\n\t\t\t\t\t\t\t\t\t__( 'Action menu for %s pattern' ),\n\t\t\t\t\t\t\t\t\titem.title\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t// The dropdown menu is not focusable using the\n\t\t\t\t\t\t\t\t// keyboard as this would interfere with the grid's\n\t\t\t\t\t\t\t\t// roving tab index system. Instead, keyboard users\n\t\t\t\t\t\t\t\t// use keyboard shortcuts to trigger actions.\n\t\t\t\t\t\t\t\ttabIndex: -1,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ () => (\n\t\t\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetIsDeleteDialogOpen( true )\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Delete' ) }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</DropdownMenu>\n\t\t\t\t\t) }\n\t\t\t\t</HStack>\n\t\t\t</div>\n\t\t\t{ isDeleteDialogOpen && (\n\t\t\t\t<ConfirmDialog\n\t\t\t\t\tonConfirm={ deletePattern }\n\t\t\t\t\tonCancel={ () => setIsDeleteDialogOpen( false ) }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Are you sure you want to delete this pattern?' ) }\n\t\t\t\t</ConfirmDialog>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -3,27 +3,33 @@ import { createElement } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { PreferencesModal, PreferencesModalTabs, PreferencesModalSection } from '@wordpress/interface';
|
|
6
|
+
import { PreferencesModal, PreferencesModalTabs, PreferencesModalSection, store as interfaceStore } from '@wordpress/interface';
|
|
7
7
|
import { useMemo } from '@wordpress/element';
|
|
8
8
|
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { useDispatch, useRegistry } from '@wordpress/data';
|
|
9
|
+
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
10
10
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
11
|
/**
|
|
12
12
|
* Internal dependencies
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import EnableFeature from './enable-feature';
|
|
16
|
-
import { store as
|
|
17
|
-
export
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
import { store as editSiteStore } from '../../store';
|
|
17
|
+
export const PREFERENCES_MODAL_NAME = 'edit-site/preferences';
|
|
18
|
+
export default function EditSitePreferencesModal() {
|
|
19
|
+
const isModalActive = useSelect(select => select(interfaceStore).isModalActive(PREFERENCES_MODAL_NAME));
|
|
20
|
+
const {
|
|
21
|
+
closeModal,
|
|
22
|
+
openModal
|
|
23
|
+
} = useDispatch(interfaceStore);
|
|
24
|
+
|
|
25
|
+
const toggleModal = () => isModalActive ? closeModal() : openModal(PREFERENCES_MODAL_NAME);
|
|
26
|
+
|
|
21
27
|
const registry = useRegistry();
|
|
22
28
|
const {
|
|
23
29
|
closeGeneralSidebar,
|
|
24
30
|
setIsListViewOpened,
|
|
25
31
|
setIsInserterOpened
|
|
26
|
-
} = useDispatch(
|
|
32
|
+
} = useDispatch(editSiteStore);
|
|
27
33
|
const {
|
|
28
34
|
set: setPreference
|
|
29
35
|
} = useDispatch(preferencesStore);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/index.js"],"names":["PreferencesModal","PreferencesModalTabs","PreferencesModalSection","useMemo","__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/components/preferences-modal/index.js"],"names":["PreferencesModal","PreferencesModalTabs","PreferencesModalSection","store","interfaceStore","useMemo","__","useSelect","useDispatch","useRegistry","preferencesStore","EnableFeature","editSiteStore","PREFERENCES_MODAL_NAME","EditSitePreferencesModal","isModalActive","select","closeModal","openModal","toggleModal","registry","closeGeneralSidebar","setIsListViewOpened","setIsInserterOpened","set","setPreference","toggleDistractionFree","batch","sections","name","tabLabel","content"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,gBADD,EAECC,oBAFD,EAGCC,uBAHD,EAICC,KAAK,IAAIC,cAJV,QAKO,sBALP;AAMA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,EAAoBC,WAApB,EAAiCC,WAAjC,QAAoD,iBAApD;AACA,SAASN,KAAK,IAAIO,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,SAASR,KAAK,IAAIS,aAAlB,QAAuC,aAAvC;AAEA,OAAO,MAAMC,sBAAsB,GAAG,uBAA/B;AAEP,eAAe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,aAAa,GAAGR,SAAS,CAAIS,MAAF,IAChCA,MAAM,CAAEZ,cAAF,CAAN,CAAyBW,aAAzB,CAAwCF,sBAAxC,CAD8B,CAA/B;AAGA,QAAM;AAAEI,IAAAA,UAAF;AAAcC,IAAAA;AAAd,MAA4BV,WAAW,CAAEJ,cAAF,CAA7C;;AACA,QAAMe,WAAW,GAAG,MACnBJ,aAAa,GAAGE,UAAU,EAAb,GAAkBC,SAAS,CAAEL,sBAAF,CADzC;;AAEA,QAAMO,QAAQ,GAAGX,WAAW,EAA5B;AACA,QAAM;AAAEY,IAAAA,mBAAF;AAAuBC,IAAAA,mBAAvB;AAA4CC,IAAAA;AAA5C,MACLf,WAAW,CAAEI,aAAF,CADZ;AAGA,QAAM;AAAEY,IAAAA,GAAG,EAAEC;AAAP,MAAyBjB,WAAW,CAAEE,gBAAF,CAA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AW,EAAC,sBADb;AAEC,MAAA,IAAI,EAAGA,EAAE,CACR,sDADQ,CAFV;AAKC,MAAA,KAAK,EAAGA,EAAE,CAAE,2BAAF;AALX,MAjCD;AAJF,GAD+B,EAgD/B;AACCuB,IAAAA,IAAI,EAAE,QADP;AAECC,IAAAA,QAAQ,EAAExB,EAAE,CAAE,QAAF,CAFb;AAGCyB,IAAAA,OAAO,EACN,cAAC,uBAAD;AACC,MAAA,KAAK,EAAGzB,EAAE,CAAE,oBAAF,CADX;AAEC,MAAA,WAAW,EAAGA,EAAE,CACf,iFADe;AAFjB,OAMC,cAAC,aAAD;AACC,MAAA,WAAW,EAAC,sBADb;AAEC,MAAA,IAAI,EAAGA,EAAE,CACR,iEADQ,CAFV;AAKC,MAAA,KAAK,EAAGA,EAAE,CAAE,kCAAF;AALX,MAND;AAJF,GAhD+B,CAAR,CAAxB;;AAqEA,MAAK,CAAES,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AACD,SACC,cAAC,gBAAD;AAAkB,IAAA,UAAU,EAAGI;AAA/B,KACC,cAAC,oBAAD;AAAsB,IAAA,QAAQ,EAAGS;AAAjC,IADD,CADD;AAKA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPreferencesModal,\n\tPreferencesModalTabs,\n\tPreferencesModalSection,\n\tstore as interfaceStore,\n} from '@wordpress/interface';\nimport { useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { useSelect, useDispatch, useRegistry } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport EnableFeature from './enable-feature';\nimport { store as editSiteStore } from '../../store';\n\nexport const PREFERENCES_MODAL_NAME = 'edit-site/preferences';\n\nexport default function EditSitePreferencesModal() {\n\tconst isModalActive = useSelect( ( select ) =>\n\t\tselect( interfaceStore ).isModalActive( PREFERENCES_MODAL_NAME )\n\t);\n\tconst { closeModal, openModal } = useDispatch( interfaceStore );\n\tconst toggleModal = () =>\n\t\tisModalActive ? closeModal() : openModal( PREFERENCES_MODAL_NAME );\n\tconst registry = useRegistry();\n\tconst { closeGeneralSidebar, setIsListViewOpened, setIsInserterOpened } =\n\t\tuseDispatch( editSiteStore );\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst toggleDistractionFree = () => {\n\t\tregistry.batch( () => {\n\t\t\tsetPreference( 'core/edit-site', 'fixedToolbar', false );\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t\tcloseGeneralSidebar();\n\t\t} );\n\t};\n\n\tconst sections = useMemo( () => [\n\t\t{\n\t\t\tname: 'general',\n\t\t\ttabLabel: __( 'General' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Appearance' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize options related to the block editor interface and editing flow.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"distractionFree\"\n\t\t\t\t\t\tonToggle={ toggleDistractionFree }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Distraction free' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"focusMode\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Highlights the current block and fades other content.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"showIconLabels\"\n\t\t\t\t\t\tlabel={ __( 'Show button text labels' ) }\n\t\t\t\t\t\thelp={ __( 'Show text instead of icons on buttons.' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"showListViewByDefault\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Opens the block list view sidebar by default.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Always open list view' ) }\n\t\t\t\t\t/>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"showBlockBreadcrumbs\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Shows block breadcrumbs at the bottom of the editor.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Display block breadcrumbs' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tname: 'blocks',\n\t\t\ttabLabel: __( 'Blocks' ),\n\t\t\tcontent: (\n\t\t\t\t<PreferencesModalSection\n\t\t\t\t\ttitle={ __( 'Block interactions' ) }\n\t\t\t\t\tdescription={ __(\n\t\t\t\t\t\t'Customize how you interact with blocks in the block library and editing canvas.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<EnableFeature\n\t\t\t\t\t\tfeatureName=\"keepCaretInsideBlock\"\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Aids screen readers by stopping text caret from leaving blocks.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlabel={ __( 'Contain text cursor inside block' ) }\n\t\t\t\t\t/>\n\t\t\t\t</PreferencesModalSection>\n\t\t\t),\n\t\t},\n\t] );\n\tif ( ! isModalActive ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<PreferencesModal closeModal={ toggleModal }>\n\t\t\t<PreferencesModalTabs sections={ sections } />\n\t\t</PreferencesModal>\n\t);\n}\n"]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
5
|
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { trash, backup, layout, page, drawerLeft, drawerRight, blockDefault, cog, code, keyboardClose } from '@wordpress/icons';
|
|
7
7
|
import { useCommandLoader } from '@wordpress/commands';
|
|
8
8
|
import { privateApis as routerPrivateApis } from '@wordpress/router';
|
|
9
9
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
@@ -16,6 +16,8 @@ import { store as editSiteStore } from '../../store';
|
|
|
16
16
|
import useEditedEntityRecord from '../../components/use-edited-entity-record';
|
|
17
17
|
import isTemplateRemovable from '../../utils/is-template-removable';
|
|
18
18
|
import isTemplateRevertable from '../../utils/is-template-revertable';
|
|
19
|
+
import { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';
|
|
20
|
+
import { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';
|
|
19
21
|
import { unlock } from '../../lock-unlock';
|
|
20
22
|
const {
|
|
21
23
|
useHistory
|
|
@@ -152,6 +154,9 @@ function useEditUICommands() {
|
|
|
152
154
|
editorMode: select(editSiteStore).getEditorMode(),
|
|
153
155
|
activeSidebar: select(interfaceStore).getActiveComplementaryArea(editSiteStore.name)
|
|
154
156
|
}), []);
|
|
157
|
+
const {
|
|
158
|
+
openModal
|
|
159
|
+
} = useDispatch(interfaceStore);
|
|
155
160
|
const {
|
|
156
161
|
toggle
|
|
157
162
|
} = useDispatch(preferencesStore);
|
|
@@ -229,6 +234,22 @@ function useEditUICommands() {
|
|
|
229
234
|
close();
|
|
230
235
|
}
|
|
231
236
|
});
|
|
237
|
+
commands.push({
|
|
238
|
+
name: 'core/open-preferences',
|
|
239
|
+
label: __('Open editor preferences'),
|
|
240
|
+
icon: cog,
|
|
241
|
+
callback: () => {
|
|
242
|
+
openModal(PREFERENCES_MODAL_NAME);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
commands.push({
|
|
246
|
+
name: 'core/open-shortcut-help',
|
|
247
|
+
label: __('Open keyboard shortcuts'),
|
|
248
|
+
icon: keyboardClose,
|
|
249
|
+
callback: () => {
|
|
250
|
+
openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
|
|
251
|
+
}
|
|
252
|
+
});
|
|
232
253
|
return {
|
|
233
254
|
isLoading: false,
|
|
234
255
|
commands
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"names":["useSelect","useDispatch","__","isRTL","code","cog","trash","backup","layout","page","drawerLeft","drawerRight","blockDefault","useCommandLoader","privateApis","routerPrivateApis","store","preferencesStore","interfaceStore","editSiteStore","useEditedEntityRecord","isTemplateRemovable","isTemplateRevertable","unlock","useHistory","usePageContentFocusCommands","isPage","canvasMode","hasPageContentFocus","select","getCanvasMode","setHasPageContentFocus","isLoading","commands","push","name","label","icon","callback","close","useManipulateDocumentCommands","isLoaded","record","template","removeTemplate","revertTemplate","history","type","path","useEditUICommands","openGeneralSidebar","closeGeneralSidebar","switchEditorMode","editorMode","activeSidebar","getEditorMode","getActiveComplementaryArea","toggle","useEditModeCommands","hook","context"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,EAAT,EAAaC,KAAb,QAA0B,iBAA1B;AACA,SACCC,IADD,EAECC,GAFD,EAGCC,KAHD,EAICC,MAJD,EAKCC,MALD,EAMCC,IAND,EAOCC,UAPD,EAQCC,WARD,EASCC,YATD,QAUO,kBAVP;AAWA,SAASC,gBAAT,QAAiC,qBAAjC;AACA,SAASC,WAAW,IAAIC,iBAAxB,QAAiD,mBAAjD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AACA,SAASD,KAAK,IAAIE,cAAlB,QAAwC,sBAAxC;AAEA;AACA;AACA;;AACA,SAASF,KAAK,IAAIG,aAAlB,QAAuC,aAAvC;AACA,OAAOC,qBAAP,MAAkC,2CAAlC;AACA,OAAOC,mBAAP,MAAgC,mCAAhC;AACA,OAAOC,oBAAP,MAAiC,oCAA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EjBwB,IAAAA,IAAI,EAAEnB,6BAFW;AAGjBoB,IAAAA,OAAO,EAAE;AAHQ,GAAF,CAAhB;AAMA/C,EAAAA,gBAAgB,CAAE;AACjBsB,IAAAA,IAAI,EAAE,wBADW;AAEjBwB,IAAAA,IAAI,EAAEV;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tcode,\n\tcog,\n\ttrash,\n\tbackup,\n\tlayout,\n\tpage,\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n} from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { isPage, canvasMode, hasPageContentFocus } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisPage: select( editSiteStore ).isPage(),\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\thasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setHasPageContentFocus } = useDispatch( editSiteStore );\n\n\tif ( ! isPage || canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( hasPageContentFocus ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: __( 'Edit template' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( false );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( true );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst hasPageContentFocus = useSelect(\n\t\t( select ) => select( editSiteStore ).hasPageContentFocus(),\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Reset template' )\n\t\t\t\t: __( 'Reset template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: backup,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Delete template' )\n\t\t\t\t: __( 'Delete template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/' + template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nfunction useEditUICommands() {\n\tconst { openGeneralSidebar, closeGeneralSidebar, switchEditorMode } =\n\t\tuseDispatch( editSiteStore );\n\tconst { canvasMode, editorMode, activeSidebar } = useSelect(\n\t\t( select ) => ( {\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\teditorMode: select( editSiteStore ).getEditorMode(),\n\t\t\tactiveSidebar: select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tif ( canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/template' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/template' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/block-inspector' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/block-inspector' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight mode' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'focusMode' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'fixedToolbar' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel: __( 'Toggle code editor' ),\n\t\ticon: code,\n\t\tcallback: ( { close } ) => {\n\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/edit-ui',\n\t\thook: useEditUICommands,\n\t} );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/edit-site/src/hooks/commands/use-edit-mode-commands.js"],"names":["useSelect","useDispatch","__","isRTL","trash","backup","layout","page","drawerLeft","drawerRight","blockDefault","cog","code","keyboardClose","useCommandLoader","privateApis","routerPrivateApis","store","preferencesStore","interfaceStore","editSiteStore","useEditedEntityRecord","isTemplateRemovable","isTemplateRevertable","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","PREFERENCES_MODAL_NAME","unlock","useHistory","usePageContentFocusCommands","isPage","canvasMode","hasPageContentFocus","select","getCanvasMode","setHasPageContentFocus","isLoading","commands","push","name","label","icon","callback","close","useManipulateDocumentCommands","isLoaded","record","template","removeTemplate","revertTemplate","history","type","path","useEditUICommands","openGeneralSidebar","closeGeneralSidebar","switchEditorMode","editorMode","activeSidebar","getEditorMode","getActi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,gBAAgB,CAAE;AACjBwB,IAAAA,IAAI,EAAE,oCADW;AAEjByB,IAAAA,IAAI,EAAEpB,6BAFW;AAGjBqB,IAAAA,OAAO,EAAE;AAHQ,GAAF,CAAhB;AAMAlD,EAAAA,gBAAgB,CAAE;AACjBwB,IAAAA,IAAI,EAAE,wBADW;AAEjByB,IAAAA,IAAI,EAAEX;AAFW,GAAF,CAAhB;AAIA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\ttrash,\n\tbackup,\n\tlayout,\n\tpage,\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n\tcog,\n\tcode,\n\tkeyboardClose,\n} from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { privateApis as routerPrivateApis } from '@wordpress/router';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\n\n/**\n * Internal dependencies\n */\nimport { store as editSiteStore } from '../../store';\nimport useEditedEntityRecord from '../../components/use-edited-entity-record';\nimport isTemplateRemovable from '../../utils/is-template-removable';\nimport isTemplateRevertable from '../../utils/is-template-revertable';\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\nimport { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';\nimport { unlock } from '../../lock-unlock';\n\nconst { useHistory } = unlock( routerPrivateApis );\n\nfunction usePageContentFocusCommands() {\n\tconst { isPage, canvasMode, hasPageContentFocus } = useSelect(\n\t\t( select ) => ( {\n\t\t\tisPage: select( editSiteStore ).isPage(),\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\thasPageContentFocus: select( editSiteStore ).hasPageContentFocus(),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { setHasPageContentFocus } = useDispatch( editSiteStore );\n\n\tif ( ! isPage || canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( hasPageContentFocus ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-template-focus',\n\t\t\tlabel: __( 'Edit template' ),\n\t\t\ticon: layout,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( false );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t} else {\n\t\tcommands.push( {\n\t\t\tname: 'core/switch-to-page-focus',\n\t\t\tlabel: __( 'Back to page' ),\n\t\t\ticon: page,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tsetHasPageContentFocus( true );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn { isLoading: false, commands };\n}\n\nfunction useManipulateDocumentCommands() {\n\tconst { isLoaded, record: template } = useEditedEntityRecord();\n\tconst { removeTemplate, revertTemplate } = useDispatch( editSiteStore );\n\tconst history = useHistory();\n\tconst hasPageContentFocus = useSelect(\n\t\t( select ) => select( editSiteStore ).hasPageContentFocus(),\n\t\t[]\n\t);\n\n\tif ( ! isLoaded ) {\n\t\treturn { isLoading: true, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tif ( isTemplateRevertable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Reset template' )\n\t\t\t\t: __( 'Reset template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/reset-template',\n\t\t\tlabel,\n\t\t\ticon: backup,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\trevertTemplate( template );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\tif ( isTemplateRemovable( template ) && ! hasPageContentFocus ) {\n\t\tconst label =\n\t\t\ttemplate.type === 'wp_template'\n\t\t\t\t? __( 'Delete template' )\n\t\t\t\t: __( 'Delete template part' );\n\t\tcommands.push( {\n\t\t\tname: 'core/remove-template',\n\t\t\tlabel,\n\t\t\ticon: trash,\n\t\t\tcallback: ( { close } ) => {\n\t\t\t\tremoveTemplate( template );\n\t\t\t\t// Navigate to the template list\n\t\t\t\thistory.push( {\n\t\t\t\t\tpath: '/' + template.type,\n\t\t\t\t} );\n\t\t\t\tclose();\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tisLoading: ! isLoaded,\n\t\tcommands,\n\t};\n}\n\nfunction useEditUICommands() {\n\tconst { openGeneralSidebar, closeGeneralSidebar, switchEditorMode } =\n\t\tuseDispatch( editSiteStore );\n\tconst { canvasMode, editorMode, activeSidebar } = useSelect(\n\t\t( select ) => ( {\n\t\t\tcanvasMode: unlock( select( editSiteStore ) ).getCanvasMode(),\n\t\t\teditorMode: select( editSiteStore ).getEditorMode(),\n\t\t\tactiveSidebar: select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditSiteStore.name\n\t\t\t),\n\t\t} ),\n\t\t[]\n\t);\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst { toggle } = useDispatch( preferencesStore );\n\n\tif ( canvasMode !== 'edit' ) {\n\t\treturn { isLoading: false, commands: [] };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/template' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/template' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-site/block-inspector' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-site/block-inspector' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight mode' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'focusMode' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\ticon: cog,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-site', 'fixedToolbar' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel: __( 'Toggle code editor' ),\n\t\ticon: code,\n\t\tcallback: ( { close } ) => {\n\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-preferences',\n\t\tlabel: __( 'Open editor preferences' ),\n\t\ticon: cog,\n\t\tcallback: () => {\n\t\t\topenModal( PREFERENCES_MODAL_NAME );\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/open-shortcut-help',\n\t\tlabel: __( 'Open keyboard shortcuts' ),\n\t\ticon: keyboardClose,\n\t\tcallback: () => {\n\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t},\n\t} );\n\n\treturn {\n\t\tisLoading: false,\n\t\tcommands,\n\t};\n}\n\nexport function useEditModeCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/page-content-focus',\n\t\thook: usePageContentFocusCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/manipulate-document',\n\t\thook: useManipulateDocumentCommands,\n\t\tcontext: 'site-editor-edit',\n\t} );\n\n\tuseCommandLoader( {\n\t\tname: 'core/edit-site/edit-ui',\n\t\thook: useEditUICommands,\n\t} );\n}\n"]}
|
|
@@ -2444,7 +2444,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
2444
2444
|
.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
|
|
2445
2445
|
column-count: 2;
|
|
2446
2446
|
column-gap: 24px;
|
|
2447
|
-
padding-top: 2px;
|
|
2448
2447
|
}
|
|
2449
2448
|
@media (min-width: 782px) {
|
|
2450
2449
|
.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
|
|
@@ -2891,6 +2890,7 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
2891
2890
|
}
|
|
2892
2891
|
.edit-site-sidebar-navigation-item.components-item[aria-current] {
|
|
2893
2892
|
background: var(--wp-admin-theme-color);
|
|
2893
|
+
color: #fff;
|
|
2894
2894
|
}
|
|
2895
2895
|
.edit-site-sidebar-navigation-item.components-item .edit-site-sidebar-navigation-item__drilldown-indicator {
|
|
2896
2896
|
fill: #757575;
|
|
@@ -3052,10 +3052,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
3052
3052
|
color: #f0f0f0;
|
|
3053
3053
|
}
|
|
3054
3054
|
|
|
3055
|
-
.sidebar-navigation__rename-modal-form {
|
|
3056
|
-
padding-top: 1px;
|
|
3057
|
-
}
|
|
3058
|
-
|
|
3059
3055
|
.edit-site-sidebar-navigation-screen-page__featured-image-wrapper {
|
|
3060
3056
|
background-color: #2f2f2f;
|
|
3061
3057
|
margin-bottom: 16px;
|
package/build-style/style.css
CHANGED
|
@@ -2445,7 +2445,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
2445
2445
|
.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
|
|
2446
2446
|
column-count: 2;
|
|
2447
2447
|
column-gap: 24px;
|
|
2448
|
-
padding-top: 2px;
|
|
2449
2448
|
}
|
|
2450
2449
|
@media (min-width: 782px) {
|
|
2451
2450
|
.edit-site-start-template-options__modal-content .block-editor-block-patterns-list {
|
|
@@ -2892,6 +2891,7 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
2892
2891
|
}
|
|
2893
2892
|
.edit-site-sidebar-navigation-item.components-item[aria-current] {
|
|
2894
2893
|
background: var(--wp-admin-theme-color);
|
|
2894
|
+
color: #fff;
|
|
2895
2895
|
}
|
|
2896
2896
|
.edit-site-sidebar-navigation-item.components-item .edit-site-sidebar-navigation-item__drilldown-indicator {
|
|
2897
2897
|
fill: #757575;
|
|
@@ -3053,10 +3053,6 @@ body.is-fullscreen-mode .edit-site .components-editor-notices__snackbar {
|
|
|
3053
3053
|
color: #f0f0f0;
|
|
3054
3054
|
}
|
|
3055
3055
|
|
|
3056
|
-
.sidebar-navigation__rename-modal-form {
|
|
3057
|
-
padding-top: 1px;
|
|
3058
|
-
}
|
|
3059
|
-
|
|
3060
3056
|
.edit-site-sidebar-navigation-screen-page__featured-image-wrapper {
|
|
3061
3057
|
background-color: #2f2f2f;
|
|
3062
3058
|
margin-bottom: 16px;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/edit-site",
|
|
3
|
-
"version": "5.12.
|
|
3
|
+
"version": "5.12.4",
|
|
4
4
|
"description": "Edit Site Page module for WordPress.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -29,40 +29,40 @@
|
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
30
|
"@wordpress/a11y": "^3.35.1",
|
|
31
31
|
"@wordpress/api-fetch": "^6.32.1",
|
|
32
|
-
"@wordpress/block-editor": "^12.3.
|
|
33
|
-
"@wordpress/block-library": "^8.12.
|
|
32
|
+
"@wordpress/block-editor": "^12.3.3",
|
|
33
|
+
"@wordpress/block-library": "^8.12.4",
|
|
34
34
|
"@wordpress/blocks": "^12.12.1",
|
|
35
|
-
"@wordpress/commands": "^0.6.
|
|
36
|
-
"@wordpress/components": "^25.1.
|
|
35
|
+
"@wordpress/commands": "^0.6.3",
|
|
36
|
+
"@wordpress/components": "^25.1.3",
|
|
37
37
|
"@wordpress/compose": "^6.12.1",
|
|
38
|
-
"@wordpress/core-commands": "^0.4.
|
|
39
|
-
"@wordpress/core-data": "^6.12.
|
|
38
|
+
"@wordpress/core-commands": "^0.4.3",
|
|
39
|
+
"@wordpress/core-data": "^6.12.3",
|
|
40
40
|
"@wordpress/data": "^9.5.1",
|
|
41
41
|
"@wordpress/date": "^4.35.1",
|
|
42
42
|
"@wordpress/deprecated": "^3.35.1",
|
|
43
43
|
"@wordpress/dom": "^3.35.1",
|
|
44
|
-
"@wordpress/editor": "^13.12.
|
|
44
|
+
"@wordpress/editor": "^13.12.3",
|
|
45
45
|
"@wordpress/element": "^5.12.1",
|
|
46
46
|
"@wordpress/escape-html": "^2.35.1",
|
|
47
47
|
"@wordpress/hooks": "^3.35.1",
|
|
48
48
|
"@wordpress/html-entities": "^3.35.1",
|
|
49
49
|
"@wordpress/i18n": "^4.35.1",
|
|
50
50
|
"@wordpress/icons": "^9.26.2",
|
|
51
|
-
"@wordpress/interface": "^5.12.
|
|
51
|
+
"@wordpress/interface": "^5.12.3",
|
|
52
52
|
"@wordpress/keyboard-shortcuts": "^4.12.1",
|
|
53
53
|
"@wordpress/keycodes": "^3.35.1",
|
|
54
54
|
"@wordpress/media-utils": "^4.26.1",
|
|
55
55
|
"@wordpress/notices": "^4.3.1",
|
|
56
|
-
"@wordpress/plugins": "^6.3.
|
|
57
|
-
"@wordpress/preferences": "^3.12.
|
|
56
|
+
"@wordpress/plugins": "^6.3.3",
|
|
57
|
+
"@wordpress/preferences": "^3.12.3",
|
|
58
58
|
"@wordpress/primitives": "^3.33.1",
|
|
59
59
|
"@wordpress/private-apis": "^0.17.1",
|
|
60
|
-
"@wordpress/reusable-blocks": "^4.12.
|
|
60
|
+
"@wordpress/reusable-blocks": "^4.12.3",
|
|
61
61
|
"@wordpress/router": "^0.4.1",
|
|
62
62
|
"@wordpress/style-engine": "^1.18.1",
|
|
63
63
|
"@wordpress/url": "^3.36.1",
|
|
64
64
|
"@wordpress/viewport": "^5.12.1",
|
|
65
|
-
"@wordpress/widgets": "^3.12.
|
|
65
|
+
"@wordpress/widgets": "^3.12.3",
|
|
66
66
|
"@wordpress/wordcount": "^3.35.1",
|
|
67
67
|
"change-case": "^4.1.2",
|
|
68
68
|
"classnames": "^2.3.1",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"publishConfig": {
|
|
85
85
|
"access": "public"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "7efa7c2321a958ddfa723825a0354071435a9d43"
|
|
88
88
|
}
|
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, _x } from '@wordpress/i18n';
|
|
5
|
-
import { useReducer } from '@wordpress/element';
|
|
6
5
|
import { useSelect, useDispatch, useRegistry } from '@wordpress/data';
|
|
7
|
-
import { useShortcut } from '@wordpress/keyboard-shortcuts';
|
|
8
6
|
import { displayShortcut } from '@wordpress/keycodes';
|
|
9
7
|
import { external } from '@wordpress/icons';
|
|
10
8
|
import { MenuGroup, MenuItem, VisuallyHidden } from '@wordpress/components';
|
|
11
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
ActionItem,
|
|
11
|
+
MoreMenuDropdown,
|
|
12
|
+
store as interfaceStore,
|
|
13
|
+
} from '@wordpress/interface';
|
|
12
14
|
import {
|
|
13
15
|
PreferenceToggleMenuItem,
|
|
14
16
|
store as preferencesStore,
|
|
@@ -17,8 +19,14 @@ import {
|
|
|
17
19
|
/**
|
|
18
20
|
* Internal dependencies
|
|
19
21
|
*/
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
+
import {
|
|
23
|
+
KEYBOARD_SHORTCUT_HELP_MODAL_NAME,
|
|
24
|
+
default as KeyboardShortcutHelpModal,
|
|
25
|
+
} from '../../keyboard-shortcut-help-modal';
|
|
26
|
+
import {
|
|
27
|
+
PREFERENCES_MODAL_NAME,
|
|
28
|
+
default as EditSitePreferencesModal,
|
|
29
|
+
} from '../../preferences-modal';
|
|
22
30
|
import ToolsMoreMenuGroup from '../tools-more-menu-group';
|
|
23
31
|
import SiteExport from './site-export';
|
|
24
32
|
import WelcomeGuideMenuItem from './welcome-guide-menu-item';
|
|
@@ -27,16 +35,6 @@ import ModeSwitcher from '../mode-switcher';
|
|
|
27
35
|
import { store as siteEditorStore } from '../../../store';
|
|
28
36
|
|
|
29
37
|
export default function MoreMenu( { showIconLabels } ) {
|
|
30
|
-
const [ isModalActive, toggleModal ] = useReducer(
|
|
31
|
-
( isActive ) => ! isActive,
|
|
32
|
-
false
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const [ isPreferencesModalActive, togglePreferencesModal ] = useReducer(
|
|
36
|
-
( isActive ) => ! isActive,
|
|
37
|
-
false
|
|
38
|
-
);
|
|
39
|
-
|
|
40
38
|
const registry = useRegistry();
|
|
41
39
|
const isDistractionFree = useSelect(
|
|
42
40
|
( select ) =>
|
|
@@ -49,6 +47,7 @@ export default function MoreMenu( { showIconLabels } ) {
|
|
|
49
47
|
|
|
50
48
|
const { setIsInserterOpened, setIsListViewOpened, closeGeneralSidebar } =
|
|
51
49
|
useDispatch( siteEditorStore );
|
|
50
|
+
const { openModal } = useDispatch( interfaceStore );
|
|
52
51
|
const { set: setPreference } = useDispatch( preferencesStore );
|
|
53
52
|
|
|
54
53
|
const toggleDistractionFree = () => {
|
|
@@ -60,8 +59,6 @@ export default function MoreMenu( { showIconLabels } ) {
|
|
|
60
59
|
} );
|
|
61
60
|
};
|
|
62
61
|
|
|
63
|
-
useShortcut( 'core/edit-site/keyboard-shortcuts', toggleModal );
|
|
64
|
-
|
|
65
62
|
return (
|
|
66
63
|
<>
|
|
67
64
|
<MoreMenuDropdown
|
|
@@ -127,7 +124,11 @@ export default function MoreMenu( { showIconLabels } ) {
|
|
|
127
124
|
<MenuGroup label={ __( 'Tools' ) }>
|
|
128
125
|
<SiteExport />
|
|
129
126
|
<MenuItem
|
|
130
|
-
onClick={
|
|
127
|
+
onClick={ () =>
|
|
128
|
+
openModal(
|
|
129
|
+
KEYBOARD_SHORTCUT_HELP_MODAL_NAME
|
|
130
|
+
)
|
|
131
|
+
}
|
|
131
132
|
shortcut={ displayShortcut.access( 'h' ) }
|
|
132
133
|
>
|
|
133
134
|
{ __( 'Keyboard shortcuts' ) }
|
|
@@ -156,21 +157,19 @@ export default function MoreMenu( { showIconLabels } ) {
|
|
|
156
157
|
/>
|
|
157
158
|
</MenuGroup>
|
|
158
159
|
<MenuGroup>
|
|
159
|
-
<MenuItem
|
|
160
|
+
<MenuItem
|
|
161
|
+
onClick={ () =>
|
|
162
|
+
openModal( PREFERENCES_MODAL_NAME )
|
|
163
|
+
}
|
|
164
|
+
>
|
|
160
165
|
{ __( 'Preferences' ) }
|
|
161
166
|
</MenuItem>
|
|
162
167
|
</MenuGroup>
|
|
163
168
|
</>
|
|
164
169
|
) }
|
|
165
170
|
</MoreMenuDropdown>
|
|
166
|
-
<KeyboardShortcutHelpModal
|
|
167
|
-
|
|
168
|
-
toggleModal={ toggleModal }
|
|
169
|
-
/>
|
|
170
|
-
<EditSitePreferencesModal
|
|
171
|
-
isModalActive={ isPreferencesModalActive }
|
|
172
|
-
toggleModal={ togglePreferencesModal }
|
|
173
|
-
/>
|
|
171
|
+
<KeyboardShortcutHelpModal />
|
|
172
|
+
<EditSitePreferencesModal />
|
|
174
173
|
</>
|
|
175
174
|
);
|
|
176
175
|
}
|