@wordpress/editor 13.28.3 → 13.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/components/commands/index.js +201 -0
  3. package/build/components/commands/index.js.map +1 -0
  4. package/build/components/commands/index.native.js +9 -0
  5. package/build/components/commands/index.native.js.map +1 -0
  6. package/build/components/document-bar/index.js +78 -67
  7. package/build/components/document-bar/index.js.map +1 -1
  8. package/build/components/global-keyboard-shortcuts/index.js +20 -2
  9. package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
  10. package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  11. package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  12. package/build/components/mode-switcher/index.js +86 -0
  13. package/build/components/mode-switcher/index.js.map +1 -0
  14. package/build/components/post-title/index.js +0 -5
  15. package/build/components/post-title/index.js.map +1 -1
  16. package/build/components/provider/index.js +6 -0
  17. package/build/components/provider/index.js.map +1 -1
  18. package/build/components/provider/index.native.js +4 -9
  19. package/build/components/provider/index.native.js.map +1 -1
  20. package/build/components/provider/use-block-editor-settings.js +1 -1
  21. package/build/components/provider/use-block-editor-settings.js.map +1 -1
  22. package/build/components/provider/use-hide-blocks-from-inserter.js +53 -0
  23. package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  24. package/build/private-apis.js +2 -0
  25. package/build/private-apis.js.map +1 -1
  26. package/build/store/actions.js +69 -2
  27. package/build/store/actions.js.map +1 -1
  28. package/build/store/selectors.js +13 -1
  29. package/build/store/selectors.js.map +1 -1
  30. package/build-module/components/commands/index.js +194 -0
  31. package/build-module/components/commands/index.js.map +1 -0
  32. package/build-module/components/commands/index.native.js +3 -0
  33. package/build-module/components/commands/index.native.js.map +1 -0
  34. package/build-module/components/document-bar/index.js +81 -70
  35. package/build-module/components/document-bar/index.js.map +1 -1
  36. package/build-module/components/global-keyboard-shortcuts/index.js +20 -2
  37. package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
  38. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
  39. package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
  40. package/build-module/components/mode-switcher/index.js +80 -0
  41. package/build-module/components/mode-switcher/index.js.map +1 -0
  42. package/build-module/components/post-title/index.js +0 -5
  43. package/build-module/components/post-title/index.js.map +1 -1
  44. package/build-module/components/provider/index.js +6 -0
  45. package/build-module/components/provider/index.js.map +1 -1
  46. package/build-module/components/provider/index.native.js +4 -10
  47. package/build-module/components/provider/index.native.js.map +1 -1
  48. package/build-module/components/provider/use-block-editor-settings.js +1 -1
  49. package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
  50. package/build-module/components/provider/use-hide-blocks-from-inserter.js +47 -0
  51. package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
  52. package/build-module/private-apis.js +2 -0
  53. package/build-module/private-apis.js.map +1 -1
  54. package/build-module/store/actions.js +66 -0
  55. package/build-module/store/actions.js.map +1 -1
  56. package/build-module/store/selectors.js +12 -0
  57. package/build-module/store/selectors.js.map +1 -1
  58. package/build-style/style-rtl.css +4 -47
  59. package/build-style/style.css +4 -47
  60. package/package.json +32 -32
  61. package/src/components/commands/index.js +202 -0
  62. package/src/components/commands/index.native.js +2 -0
  63. package/src/components/document-bar/index.js +115 -94
  64. package/src/components/document-bar/style.scss +4 -37
  65. package/src/components/global-keyboard-shortcuts/index.js +35 -4
  66. package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
  67. package/src/components/mode-switcher/index.js +90 -0
  68. package/src/components/post-title/index.js +0 -3
  69. package/src/components/provider/index.js +7 -0
  70. package/src/components/provider/index.native.js +7 -6
  71. package/src/components/provider/use-block-editor-settings.js +0 -3
  72. package/src/components/provider/use-hide-blocks-from-inserter.js +81 -0
  73. package/src/private-apis.js +2 -0
  74. package/src/store/actions.js +95 -0
  75. package/src/store/selectors.js +12 -0
  76. package/src/store/test/actions.js +82 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 13.29.0 (2024-02-21)
6
+
5
7
  ## 13.28.0 (2024-02-09)
6
8
 
7
9
  ## 13.27.0 (2024-01-24)
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useCommands;
7
+ var _data = require("@wordpress/data");
8
+ var _i18n = require("@wordpress/i18n");
9
+ var _icons = require("@wordpress/icons");
10
+ var _commands = require("@wordpress/commands");
11
+ var _preferences = require("@wordpress/preferences");
12
+ var _notices = require("@wordpress/notices");
13
+ var _blockEditor = require("@wordpress/block-editor");
14
+ var _coreData = require("@wordpress/core-data");
15
+ var _store = require("../../store");
16
+ /**
17
+ * WordPress dependencies
18
+ */
19
+
20
+ /**
21
+ * Internal dependencies
22
+ */
23
+
24
+ function useEditorCommandLoader() {
25
+ const {
26
+ editorMode,
27
+ isListViewOpen,
28
+ showBlockBreadcrumbs,
29
+ isDistractionFree,
30
+ isTopToolbar,
31
+ isFocusMode,
32
+ isPreviewMode,
33
+ isViewable
34
+ } = (0, _data.useSelect)(select => {
35
+ var _get, _getPostType$viewable;
36
+ const {
37
+ get
38
+ } = select(_preferences.store);
39
+ const {
40
+ isListViewOpened,
41
+ getCurrentPostType
42
+ } = select(_store.store);
43
+ const {
44
+ getSettings
45
+ } = select(_blockEditor.store);
46
+ const {
47
+ getPostType
48
+ } = select(_coreData.store);
49
+ return {
50
+ editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
51
+ isListViewOpen: isListViewOpened(),
52
+ showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
53
+ isDistractionFree: get('core', 'distractionFree'),
54
+ isFocusMode: get('core', 'focusMode'),
55
+ isTopToolbar: get('core', 'fixedToolbar'),
56
+ isPreviewMode: getSettings().__unstableIsPreviewMode,
57
+ isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false
58
+ };
59
+ }, []);
60
+ const {
61
+ toggle
62
+ } = (0, _data.useDispatch)(_preferences.store);
63
+ const {
64
+ createInfoNotice
65
+ } = (0, _data.useDispatch)(_notices.store);
66
+ const {
67
+ __unstableSaveForPreview,
68
+ setIsListViewOpened,
69
+ switchEditorMode,
70
+ toggleDistractionFree
71
+ } = (0, _data.useDispatch)(_store.store);
72
+ const {
73
+ getCurrentPostId
74
+ } = (0, _data.useSelect)(_store.store);
75
+ if (isPreviewMode) {
76
+ return {
77
+ commands: [],
78
+ isLoading: false
79
+ };
80
+ }
81
+ const commands = [];
82
+ commands.push({
83
+ name: 'core/toggle-distraction-free',
84
+ label: isDistractionFree ? (0, _i18n.__)('Exit Distraction Free') : (0, _i18n.__)('Enter Distraction Free '),
85
+ callback: ({
86
+ close
87
+ }) => {
88
+ toggleDistractionFree();
89
+ close();
90
+ }
91
+ });
92
+ commands.push({
93
+ name: 'core/toggle-spotlight-mode',
94
+ label: (0, _i18n.__)('Toggle spotlight'),
95
+ callback: ({
96
+ close
97
+ }) => {
98
+ toggle('core', 'focusMode');
99
+ close();
100
+ createInfoNotice(isFocusMode ? (0, _i18n.__)('Spotlight off.') : (0, _i18n.__)('Spotlight on.'), {
101
+ id: 'core/editor/toggle-spotlight-mode/notice',
102
+ type: 'snackbar',
103
+ actions: [{
104
+ label: (0, _i18n.__)('Undo'),
105
+ onClick: () => {
106
+ toggle('core', 'focusMode');
107
+ }
108
+ }]
109
+ });
110
+ }
111
+ });
112
+ commands.push({
113
+ name: 'core/toggle-list-view',
114
+ label: isListViewOpen ? (0, _i18n.__)('Close List View') : (0, _i18n.__)('Open List View'),
115
+ icon: _icons.listView,
116
+ callback: ({
117
+ close
118
+ }) => {
119
+ setIsListViewOpened(!isListViewOpen);
120
+ close();
121
+ createInfoNotice(isListViewOpen ? (0, _i18n.__)('List View off.') : (0, _i18n.__)('List View on.'), {
122
+ id: 'core/editor/toggle-list-view/notice',
123
+ type: 'snackbar'
124
+ });
125
+ }
126
+ });
127
+ commands.push({
128
+ name: 'core/toggle-top-toolbar',
129
+ label: (0, _i18n.__)('Toggle top toolbar'),
130
+ callback: ({
131
+ close
132
+ }) => {
133
+ toggle('core', 'fixedToolbar');
134
+ if (isDistractionFree) {
135
+ toggleDistractionFree();
136
+ }
137
+ close();
138
+ createInfoNotice(isTopToolbar ? (0, _i18n.__)('Top toolbar off.') : (0, _i18n.__)('Top toolbar on.'), {
139
+ id: 'core/editor/toggle-top-toolbar/notice',
140
+ type: 'snackbar',
141
+ actions: [{
142
+ label: (0, _i18n.__)('Undo'),
143
+ onClick: () => {
144
+ toggle('core', 'fixedToolbar');
145
+ }
146
+ }]
147
+ });
148
+ }
149
+ });
150
+ commands.push({
151
+ name: 'core/toggle-code-editor',
152
+ label: editorMode === 'visual' ? (0, _i18n.__)('Open code editor') : (0, _i18n.__)('Exit code editor'),
153
+ icon: _icons.code,
154
+ callback: ({
155
+ close
156
+ }) => {
157
+ switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
158
+ close();
159
+ }
160
+ });
161
+ commands.push({
162
+ name: 'core/toggle-breadcrumbs',
163
+ label: showBlockBreadcrumbs ? (0, _i18n.__)('Hide block breadcrumbs') : (0, _i18n.__)('Show block breadcrumbs'),
164
+ callback: ({
165
+ close
166
+ }) => {
167
+ toggle('core', 'showBlockBreadcrumbs');
168
+ close();
169
+ createInfoNotice(showBlockBreadcrumbs ? (0, _i18n.__)('Breadcrumbs hidden.') : (0, _i18n.__)('Breadcrumbs visible.'), {
170
+ id: 'core/editor/toggle-breadcrumbs/notice',
171
+ type: 'snackbar'
172
+ });
173
+ }
174
+ });
175
+ if (isViewable) {
176
+ commands.push({
177
+ name: 'core/preview-link',
178
+ label: (0, _i18n.__)('Preview in a new tab'),
179
+ icon: _icons.external,
180
+ callback: async ({
181
+ close
182
+ }) => {
183
+ close();
184
+ const postId = getCurrentPostId();
185
+ const link = await __unstableSaveForPreview();
186
+ window.open(link, `wp-preview-${postId}`);
187
+ }
188
+ });
189
+ }
190
+ return {
191
+ commands,
192
+ isLoading: false
193
+ };
194
+ }
195
+ function useCommands() {
196
+ (0, _commands.useCommandLoader)({
197
+ name: 'core/editor/edit-ui',
198
+ hook: useEditorCommandLoader
199
+ });
200
+ }
201
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_data","require","_i18n","_icons","_commands","_preferences","_notices","_blockEditor","_coreData","_store","useEditorCommandLoader","editorMode","isListViewOpen","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","isPreviewMode","isViewable","useSelect","select","_get","_getPostType$viewable","get","preferencesStore","isListViewOpened","getCurrentPostType","editorStore","getSettings","blockEditorStore","getPostType","coreStore","__unstableIsPreviewMode","viewable","toggle","useDispatch","createInfoNotice","noticesStore","__unstableSaveForPreview","setIsListViewOpened","switchEditorMode","toggleDistractionFree","getCurrentPostId","commands","isLoading","push","name","label","__","callback","close","id","type","actions","onClick","icon","listView","code","external","postId","link","window","open","useCommands","useCommandLoader","hook"],"sources":["@wordpress/editor/src/components/commands/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { code, listView, external } from '@wordpress/icons';\nimport { useCommandLoader } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nfunction useEditorCommandLoader() {\n\tconst {\n\t\teditorMode,\n\t\tisListViewOpen,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t\tisPreviewMode,\n\t\tisViewable,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getCurrentPostType } = select( editorStore );\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { getPostType } = select( coreStore );\n\n\t\treturn {\n\t\t\teditorMode: get( 'core', 'editorMode' ) ?? 'visual',\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisPreviewMode: getSettings().__unstableIsPreviewMode,\n\t\t\tisViewable: getPostType( getCurrentPostType() )?.viewable ?? false,\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst {\n\t\t__unstableSaveForPreview,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\n\tif ( isPreviewMode ) {\n\t\treturn { commands: [], isLoading: false };\n\t}\n\n\tconst commands = [];\n\n\tcommands.push( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free ' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tcommands.push( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel:\n\t\t\teditorMode === 'visual'\n\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t: __( 'Exit 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/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tif ( isViewable ) {\n\t\tcommands.push( {\n\t\t\tname: 'core/preview-link',\n\t\t\tlabel: __( 'Preview in a new tab' ),\n\t\t\ticon: external,\n\t\t\tcallback: async ( { close } ) => {\n\t\t\t\tclose();\n\t\t\t\tconst postId = getCurrentPostId();\n\t\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t\t},\n\t\t} );\n\t}\n\n\treturn {\n\t\tcommands,\n\t\tisLoading: false,\n\t};\n}\n\nexport default function useCommands() {\n\tuseCommandLoader( {\n\t\tname: 'core/editor/edit-ui',\n\t\thook: useEditorCommandLoader,\n\t} );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAC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ACdC,IAAI,EAAE,mBAAmB;MACzBC,KAAK,EAAE,IAAAC,QAAE,EAAE,sBAAuB,CAAC;MACnCO,IAAI,EAAEG,eAAQ;MACdT,QAAQ,EAAE,MAAAA,CAAQ;QAAEC;MAAM,CAAC,KAAM;QAChCA,KAAK,CAAC,CAAC;QACP,MAAMS,MAAM,GAAGjB,gBAAgB,CAAC,CAAC;QACjC,MAAMkB,IAAI,GAAG,MAAMtB,wBAAwB,CAAC,CAAC;QAC7CuB,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;MAC9C;IACD,CAAE,CAAC;EACJ;EAEA,OAAO;IACNhB,QAAQ;IACRC,SAAS,EAAE;EACZ,CAAC;AACF;AAEe,SAASmB,WAAWA,CAAA,EAAG;EACrC,IAAAC,0BAAgB,EAAE;IACjBlB,IAAI,EAAE,qBAAqB;IAC3BmB,IAAI,EAAEvD;EACP,CAAE,CAAC;AACJ"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = useCommands;
7
+ // Commands are disabled in the mobile native version.
8
+ function useCommands() {}
9
+ //# sourceMappingURL=index.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCommands"],"sources":["@wordpress/editor/src/components/commands/index.native.js"],"sourcesContent":["// Commands are disabled in the mobile native version.\nexport default function useCommands() {}\n"],"mappings":";;;;;;AAAA;AACe,SAASA,WAAWA,CAAA,EAAG,CAAC"}
@@ -16,6 +16,7 @@ var _keycodes = require("@wordpress/keycodes");
16
16
  var _coreData = require("@wordpress/core-data");
17
17
  var _commands = require("@wordpress/commands");
18
18
  var _element = require("@wordpress/element");
19
+ var _compose = require("@wordpress/compose");
19
20
  var _store = require("../../store");
20
21
  /**
21
22
  * External dependencies
@@ -29,7 +30,7 @@ var _store = require("../../store");
29
30
  * Internal dependencies
30
31
  */
31
32
 
32
- const typeLabels = {
33
+ const TYPE_LABELS = {
33
34
  // translators: 1: Pattern title.
34
35
  wp_pattern: (0, _i18n.__)('Editing pattern: %s'),
35
36
  // translators: 1: Navigation menu title.
@@ -39,108 +40,118 @@ const typeLabels = {
39
40
  // translators: 1: Template part title.
40
41
  wp_template_part: (0, _i18n.__)('Editing template part: %s')
41
42
  };
42
- const icons = {
43
+ const ICONS = {
43
44
  wp_block: _icons.symbol,
44
45
  wp_navigation: _icons.navigation
45
46
  };
47
+ const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
48
+ const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
49
+ const MotionButton = (0, _components.__unstableMotion)(_components.Button);
46
50
  function DocumentBar() {
51
+ var _ICONS$postType;
47
52
  const {
48
53
  postType,
49
- postId,
54
+ document,
55
+ isResolving,
56
+ templateIcon,
57
+ templateTitle,
50
58
  onNavigateToPreviousEntityRecord
51
59
  } = (0, _data.useSelect)(select => {
52
60
  const {
53
- getCurrentPostId,
54
61
  getCurrentPostType,
55
- getEditorSettings: getSettings
62
+ getCurrentPostId,
63
+ getEditorSettings,
64
+ __experimentalGetTemplateInfo: getTemplateInfo
56
65
  } = select(_store.store);
66
+ const {
67
+ getEditedEntityRecord,
68
+ getIsResolving
69
+ } = select(_coreData.store);
70
+ const _postType = getCurrentPostType();
71
+ const _postId = getCurrentPostId();
72
+ const _document = getEditedEntityRecord('postType', _postType, _postId);
73
+ const _templateInfo = getTemplateInfo(_document);
57
74
  return {
58
- postType: getCurrentPostType(),
59
- postId: getCurrentPostId(),
60
- onNavigateToPreviousEntityRecord: getSettings().onNavigateToPreviousEntityRecord,
61
- getEditorSettings: getSettings
75
+ postType: _postType,
76
+ document: _document,
77
+ isResolving: getIsResolving('getEditedEntityRecord', 'postType', _postType, _postId),
78
+ templateIcon: _templateInfo.icon,
79
+ templateTitle: _templateInfo.title,
80
+ onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
62
81
  };
63
82
  }, []);
64
- const handleOnBack = () => {
65
- if (onNavigateToPreviousEntityRecord) {
66
- onNavigateToPreviousEntityRecord();
67
- }
68
- };
69
- return (0, _react.createElement)(BaseDocumentActions, {
70
- postType: postType,
71
- postId: postId,
72
- onBack: onNavigateToPreviousEntityRecord ? handleOnBack : undefined
73
- });
74
- }
75
- function BaseDocumentActions({
76
- postType,
77
- postId,
78
- onBack
79
- }) {
80
- var _icons$postType;
81
83
  const {
82
84
  open: openCommandCenter
83
85
  } = (0, _data.useDispatch)(_commands.store);
84
- const {
85
- editedRecord: doc,
86
- isResolving
87
- } = (0, _coreData.useEntityRecord)('postType', postType, postId);
88
- const {
89
- templateIcon,
90
- templateTitle
91
- } = (0, _data.useSelect)(select => {
92
- const {
93
- __experimentalGetTemplateInfo: getTemplateInfo
94
- } = select(_store.store);
95
- const templateInfo = getTemplateInfo(doc);
96
- return {
97
- templateIcon: templateInfo.icon,
98
- templateTitle: templateInfo.title
99
- };
100
- });
101
- const isNotFound = !doc && !isResolving;
102
- const icon = (_icons$postType = icons[postType]) !== null && _icons$postType !== void 0 ? _icons$postType : _icons.page;
103
- const [isAnimated, setIsAnimated] = (0, _element.useState)(false);
104
- const isMounting = (0, _element.useRef)(true);
105
- const isTemplate = ['wp_template', 'wp_template_part'].includes(postType);
106
- const isGlobalEntity = ['wp_template', 'wp_navigation', 'wp_template_part', 'wp_block'].includes(postType);
86
+ const isReducedMotion = (0, _compose.useReducedMotion)();
87
+ const isNotFound = !document && !isResolving;
88
+ const icon = (_ICONS$postType = ICONS[postType]) !== null && _ICONS$postType !== void 0 ? _ICONS$postType : _icons.page;
89
+ const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
90
+ const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
91
+ const hasBackButton = !!onNavigateToPreviousEntityRecord;
92
+ const title = isTemplate ? templateTitle : document.title;
93
+ const mounted = (0, _element.useRef)(false);
107
94
  (0, _element.useEffect)(() => {
108
- if (!isMounting.current) {
109
- setIsAnimated(true);
110
- }
111
- isMounting.current = false;
112
- }, [postType, postId]);
113
- const title = isTemplate ? templateTitle : doc.title;
95
+ mounted.current = true;
96
+ }, []);
114
97
  return (0, _react.createElement)("div", {
115
98
  className: (0, _classnames.default)('editor-document-bar', {
116
- 'has-back-button': !!onBack,
117
- 'is-animated': isAnimated,
99
+ 'has-back-button': hasBackButton,
118
100
  'is-global': isGlobalEntity
119
101
  })
120
- }, onBack && (0, _react.createElement)(_components.Button, {
102
+ }, (0, _react.createElement)(_components.__unstableAnimatePresence, null, hasBackButton && (0, _react.createElement)(MotionButton, {
121
103
  className: "editor-document-bar__back",
122
104
  icon: (0, _i18n.isRTL)() ? _icons.chevronRightSmall : _icons.chevronLeftSmall,
123
105
  onClick: event => {
124
106
  event.stopPropagation();
125
- onBack();
107
+ onNavigateToPreviousEntityRecord();
126
108
  },
127
- size: "compact"
128
- }, (0, _i18n.__)('Back')), isNotFound && (0, _react.createElement)(_components.__experimentalText, null, (0, _i18n.__)('Document not found')), !isNotFound && (0, _react.createElement)(_components.Button, {
109
+ size: "compact",
110
+ initial: mounted.current ? {
111
+ opacity: 0,
112
+ transform: 'translateX(15%)'
113
+ } : false // Don't show entry animation when DocumentBar mounts.
114
+ ,
115
+ animate: {
116
+ opacity: 1,
117
+ transform: 'translateX(0%)'
118
+ },
119
+ exit: {
120
+ opacity: 0,
121
+ transform: 'translateX(15%)'
122
+ },
123
+ transition: isReducedMotion ? {
124
+ duration: 0
125
+ } : undefined
126
+ }, (0, _i18n.__)('Back'))), isNotFound ? (0, _react.createElement)(_components.__experimentalText, null, (0, _i18n.__)('Document not found')) : (0, _react.createElement)(_components.Button, {
129
127
  className: "editor-document-bar__command",
130
128
  onClick: () => openCommandCenter(),
131
129
  size: "compact"
132
- }, (0, _react.createElement)(_components.__experimentalHStack, {
133
- className: "editor-document-bar__title",
134
- spacing: 1,
135
- justify: "center"
130
+ }, (0, _react.createElement)(_components.__unstableMotion.div, {
131
+ className: "editor-document-bar__title"
132
+ // Force entry animation when the back button is added or removed.
133
+ ,
134
+ key: hasBackButton,
135
+ initial: mounted.current ? {
136
+ opacity: 0,
137
+ transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
138
+ } : false // Don't show entry animation when DocumentBar mounts.
139
+ ,
140
+ animate: {
141
+ opacity: 1,
142
+ transform: 'translateX(0%)'
143
+ },
144
+ transition: isReducedMotion ? {
145
+ duration: 0
146
+ } : undefined
136
147
  }, (0, _react.createElement)(_blockEditor.BlockIcon, {
137
148
  icon: isTemplate ? templateIcon : icon
138
149
  }), (0, _react.createElement)(_components.__experimentalText, {
139
150
  size: "body",
140
151
  as: "h1",
141
- "aria-label": typeLabels[postType] ?
152
+ "aria-label": TYPE_LABELS[postType] ?
142
153
  // eslint-disable-next-line @wordpress/valid-sprintf
143
- (0, _i18n.sprintf)(typeLabels[postType], title) : undefined
154
+ (0, _i18n.sprintf)(TYPE_LABELS[postType], title) : undefined
144
155
  }, title)), (0, _react.createElement)("span", {
145
156
  className: "editor-document-bar__shortcut"
146
157
  }, _keycodes.displayShortcut.primary('k'))));
@@ -1 +1 @@
1
- {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_data","_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_store","typeLabels","wp_pattern","__","wp_navigation","wp_template","wp_template_part","icons","wp_block","symbol","navigationIcon","DocumentBar","postType","postId","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostId","getCurrentPostType","getEditorSettings","getSettings","editorStore","handleOnBack","_react","createElement","BaseDocumentActions","onBack","undefined","_icons$postType","open","openCommandCenter","useDispatch","commandsStore","editedRecord","doc","isResolving","useEntityRecord","templateIcon","templateTitle","__experimentalGetTemplateInfo","getTemplateInfo","templateInfo","icon","title","isNotFound","pageIcon","isAnimated","setIsAnimated","useState","isMounting","useRef","isTemplate","includes","isGlobalEntity","useEffect","current","className","classnames","Button","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","__experimentalText","__experimentalHStack","spacing","justify","BlockIcon","as","sprintf","displayShortcut","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__experimentalHStack as HStack,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useEntityRecord } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst typeLabels = {\n\t// translators: 1: Pattern title.\n\twp_pattern: __( 'Editing pattern: %s' ),\n\t// translators: 1: Navigation menu title.\n\twp_navigation: __( 'Editing navigation menu: %s' ),\n\t// translators: 1: Template title.\n\twp_template: __( 'Editing template: %s' ),\n\t// translators: 1: Template part title.\n\twp_template_part: __( 'Editing template part: %s' ),\n};\n\nconst icons = {\n\twp_block: symbol,\n\twp_navigation: navigationIcon,\n};\n\nexport default function DocumentBar() {\n\tconst { postType, postId, onNavigateToPreviousEntityRecord } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetCurrentPostId,\n\t\t\t\tgetCurrentPostType,\n\t\t\t\tgetEditorSettings: getSettings,\n\t\t\t} = select( editorStore );\n\t\t\treturn {\n\t\t\t\tpostType: getCurrentPostType(),\n\t\t\t\tpostId: getCurrentPostId(),\n\t\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\t\tgetSettings().onNavigateToPreviousEntityRecord,\n\t\t\t\tgetEditorSettings: getSettings,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst handleOnBack = () => {\n\t\tif ( onNavigateToPreviousEntityRecord ) {\n\t\t\tonNavigateToPreviousEntityRecord();\n\t\t}\n\t};\n\n\treturn (\n\t\t<BaseDocumentActions\n\t\t\tpostType={ postType }\n\t\t\tpostId={ postId }\n\t\t\tonBack={\n\t\t\t\tonNavigateToPreviousEntityRecord ? handleOnBack : undefined\n\t\t\t}\n\t\t/>\n\t);\n}\n\nfunction BaseDocumentActions( { postType, postId, onBack } ) {\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst { editedRecord: doc, isResolving } = useEntityRecord(\n\t\t'postType',\n\t\tpostType,\n\t\tpostId\n\t);\n\tconst { templateIcon, templateTitle } = useSelect( ( select ) => {\n\t\tconst { __experimentalGetTemplateInfo: getTemplateInfo } =\n\t\t\tselect( editorStore );\n\t\tconst templateInfo = getTemplateInfo( doc );\n\t\treturn {\n\t\t\ttemplateIcon: templateInfo.icon,\n\t\t\ttemplateTitle: templateInfo.title,\n\t\t};\n\t} );\n\tconst isNotFound = ! doc && ! isResolving;\n\tconst icon = icons[ postType ] ?? pageIcon;\n\tconst [ isAnimated, setIsAnimated ] = useState( false );\n\tconst isMounting = useRef( true );\n\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\tpostType\n\t);\n\tconst isGlobalEntity = [\n\t\t'wp_template',\n\t\t'wp_navigation',\n\t\t'wp_template_part',\n\t\t'wp_block',\n\t].includes( postType );\n\n\tuseEffect( () => {\n\t\tif ( ! isMounting.current ) {\n\t\t\tsetIsAnimated( true );\n\t\t}\n\t\tisMounting.current = false;\n\t}, [ postType, postId ] );\n\n\tconst title = isTemplate ? templateTitle : doc.title;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'editor-document-bar', {\n\t\t\t\t'has-back-button': !! onBack,\n\t\t\t\t'is-animated': isAnimated,\n\t\t\t\t'is-global': isGlobalEntity,\n\t\t\t} ) }\n\t\t>\n\t\t\t{ onBack && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\tonBack();\n\t\t\t\t\t} }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ isNotFound && <Text>{ __( 'Document not found' ) }</Text> }\n\t\t\t{ ! isNotFound && (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<HStack\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\tspacing={ 1 }\n\t\t\t\t\t\tjustify=\"center\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockIcon icon={ isTemplate ? templateIcon : icon } />\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\ttypeLabels[ postType ]\n\t\t\t\t\t\t\t\t\t? // eslint-disable-next-line @wordpress/valid-sprintf\n\t\t\t\t\t\t\t\t\t sprintf( typeLabels[ postType ], title )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</HStack>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,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AA8B;IACxCM,OAAO,EAAGA,CAAA,KAAMhC,iBAAiB,CAAC,CAAG;IACrCmC,IAAI,EAAC;EAAS,GAEd,IAAA1C,MAAA,CAAAC,aAAA,EAAC/B,WAAA,CAAA0E,oBAAM;IACNX,SAAS,EAAC,4BAA4B;IACtCY,OAAO,EAAG,CAAG;IACbC,OAAO,EAAC;EAAQ,GAEhB,IAAA9C,MAAA,CAAAC,aAAA,EAAC9B,YAAA,CAAA4E,SAAS;IAAC5B,IAAI,EAAGS,UAAU,GAAGd,YAAY,GAAGK;EAAM,CAAE,CAAC,EACvD,IAAAnB,MAAA,CAAAC,aAAA,EAAC/B,WAAA,CAAAyE,kBAAI;IACJD,IAAI,EAAC,MAAM;IACXM,EAAE,EAAC,IAAI;IACP,cACCtE,UAAU,CAAEW,QAAQ,CAAE;IACnB;IACA,IAAA4D,aAAO,EAAEvE,UAAU,CAAEW,QAAQ,CAAE,EAAE+B,KAAM,CAAC,GACxChB;EACH,GAECgB,KACG,CACC,CAAC,EACT,IAAApB,MAAA,CAAAC,aAAA;IAAMgC,SAAS,EAAC;EAA+B,GAC5CiB,yBAAe,CAACC,OAAO,CAAE,GAAI,CAC1B,CACC,CAEL,CAAC;AAER"}
1
+ {"version":3,"names":["_classnames","_interopRequireDefault","require","_i18n","_data","_components","_blockEditor","_icons","_keycodes","_coreData","_commands","_element","_compose","_store","TYPE_LABELS","wp_pattern","__","wp_navigation","wp_template","wp_template_part","ICONS","wp_block","symbol","navigationIcon","TEMPLATE_POST_TYPES","GLOBAL_POST_TYPES","MotionButton","motion","Button","DocumentBar","_ICONS$postType","postType","document","isResolving","templateIcon","templateTitle","onNavigateToPreviousEntityRecord","useSelect","select","getCurrentPostType","getCurrentPostId","getEditorSettings","__experimentalGetTemplateInfo","getTemplateInfo","editorStore","getEditedEntityRecord","getIsResolving","coreStore","_postType","_postId","_document","_templateInfo","icon","title","open","openCommandCenter","useDispatch","commandsStore","isReducedMotion","useReducedMotion","isNotFound","pageIcon","isTemplate","includes","isGlobalEntity","hasBackButton","mounted","useRef","useEffect","current","_react","createElement","className","classnames","__unstableAnimatePresence","isRTL","chevronRightSmall","chevronLeftSmall","onClick","event","stopPropagation","size","initial","opacity","transform","animate","exit","transition","duration","undefined","__experimentalText","__unstableMotion","div","key","BlockIcon","as","sprintf","displayShortcut","primary"],"sources":["@wordpress/editor/src/components/document-bar/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, isRTL, sprintf } from '@wordpress/i18n';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tButton,\n\t__experimentalText as Text,\n\t__unstableMotion as motion,\n\t__unstableAnimatePresence as AnimatePresence,\n} from '@wordpress/components';\nimport { BlockIcon } from '@wordpress/block-editor';\nimport {\n\tchevronLeftSmall,\n\tchevronRightSmall,\n\tpage as pageIcon,\n\tnavigation as navigationIcon,\n\tsymbol,\n} from '@wordpress/icons';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as commandsStore } from '@wordpress/commands';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useReducedMotion } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nconst TYPE_LABELS = {\n\t// translators: 1: Pattern title.\n\twp_pattern: __( 'Editing pattern: %s' ),\n\t// translators: 1: Navigation menu title.\n\twp_navigation: __( 'Editing navigation menu: %s' ),\n\t// translators: 1: Template title.\n\twp_template: __( 'Editing template: %s' ),\n\t// translators: 1: Template part title.\n\twp_template_part: __( 'Editing template part: %s' ),\n};\n\nconst ICONS = {\n\twp_block: symbol,\n\twp_navigation: navigationIcon,\n};\n\nconst TEMPLATE_POST_TYPES = [ 'wp_template', 'wp_template_part' ];\n\nconst GLOBAL_POST_TYPES = [\n\t...TEMPLATE_POST_TYPES,\n\t'wp_block',\n\t'wp_navigation',\n];\n\nconst MotionButton = motion( Button );\n\nexport default function DocumentBar() {\n\tconst {\n\t\tpostType,\n\t\tdocument,\n\t\tisResolving,\n\t\ttemplateIcon,\n\t\ttemplateTitle,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tgetCurrentPostType,\n\t\t\tgetCurrentPostId,\n\t\t\tgetEditorSettings,\n\t\t\t__experimentalGetTemplateInfo: getTemplateInfo,\n\t\t} = select( editorStore );\n\t\tconst { getEditedEntityRecord, getIsResolving } = select( coreStore );\n\t\tconst _postType = getCurrentPostType();\n\t\tconst _postId = getCurrentPostId();\n\t\tconst _document = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t_postType,\n\t\t\t_postId\n\t\t);\n\t\tconst _templateInfo = getTemplateInfo( _document );\n\t\treturn {\n\t\t\tpostType: _postType,\n\t\t\tdocument: _document,\n\t\t\tisResolving: getIsResolving(\n\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t'postType',\n\t\t\t\t_postType,\n\t\t\t\t_postId\n\t\t\t),\n\t\t\ttemplateIcon: _templateInfo.icon,\n\t\t\ttemplateTitle: _templateInfo.title,\n\t\t\tonNavigateToPreviousEntityRecord:\n\t\t\t\tgetEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t};\n\t}, [] );\n\n\tconst { open: openCommandCenter } = useDispatch( commandsStore );\n\tconst isReducedMotion = useReducedMotion();\n\n\tconst isNotFound = ! document && ! isResolving;\n\tconst icon = ICONS[ postType ] ?? pageIcon;\n\tconst isTemplate = TEMPLATE_POST_TYPES.includes( postType );\n\tconst isGlobalEntity = GLOBAL_POST_TYPES.includes( postType );\n\tconst hasBackButton = !! onNavigateToPreviousEntityRecord;\n\tconst title = isTemplate ? templateTitle : document.title;\n\n\tconst mounted = useRef( false );\n\tuseEffect( () => {\n\t\tmounted.current = true;\n\t}, [] );\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'editor-document-bar', {\n\t\t\t\t'has-back-button': hasBackButton,\n\t\t\t\t'is-global': isGlobalEntity,\n\t\t\t} ) }\n\t\t>\n\t\t\t<AnimatePresence>\n\t\t\t\t{ hasBackButton && (\n\t\t\t\t\t<MotionButton\n\t\t\t\t\t\tclassName=\"editor-document-bar__back\"\n\t\t\t\t\t\ticon={ isRTL() ? chevronRightSmall : chevronLeftSmall }\n\t\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\tonNavigateToPreviousEntityRecord();\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmounted.current\n\t\t\t\t\t\t\t\t? { opacity: 0, transform: 'translateX(15%)' }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ { opacity: 1, transform: 'translateX(0%)' } }\n\t\t\t\t\t\texit={ { opacity: 0, transform: 'translateX(15%)' } }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Back' ) }\n\t\t\t\t\t</MotionButton>\n\t\t\t\t) }\n\t\t\t</AnimatePresence>\n\t\t\t{ isNotFound ? (\n\t\t\t\t<Text>{ __( 'Document not found' ) }</Text>\n\t\t\t) : (\n\t\t\t\t<Button\n\t\t\t\t\tclassName=\"editor-document-bar__command\"\n\t\t\t\t\tonClick={ () => openCommandCenter() }\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t>\n\t\t\t\t\t<motion.div\n\t\t\t\t\t\tclassName=\"editor-document-bar__title\"\n\t\t\t\t\t\t// Force entry animation when the back button is added or removed.\n\t\t\t\t\t\tkey={ hasBackButton }\n\t\t\t\t\t\tinitial={\n\t\t\t\t\t\t\tmounted.current\n\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\topacity: 0,\n\t\t\t\t\t\t\t\t\t\ttransform: hasBackButton\n\t\t\t\t\t\t\t\t\t\t\t? 'translateX(15%)'\n\t\t\t\t\t\t\t\t\t\t\t: 'translateX(-15%)',\n\t\t\t\t\t\t\t\t }\n\t\t\t\t\t\t\t\t: false // Don't show entry animation when DocumentBar mounts.\n\t\t\t\t\t\t}\n\t\t\t\t\t\tanimate={ {\n\t\t\t\t\t\t\topacity: 1,\n\t\t\t\t\t\t\ttransform: 'translateX(0%)',\n\t\t\t\t\t\t} }\n\t\t\t\t\t\ttransition={\n\t\t\t\t\t\t\tisReducedMotion ? { duration: 0 } : undefined\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t<BlockIcon icon={ isTemplate ? templateIcon : icon } />\n\t\t\t\t\t\t<Text\n\t\t\t\t\t\t\tsize=\"body\"\n\t\t\t\t\t\t\tas=\"h1\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\tTYPE_LABELS[ postType ]\n\t\t\t\t\t\t\t\t\t? // eslint-disable-next-line @wordpress/valid-sprintf\n\t\t\t\t\t\t\t\t\t sprintf( TYPE_LABELS[ postType ], title )\n\t\t\t\t\t\t\t\t\t: undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</Text>\n\t\t\t\t\t</motion.div>\n\t\t\t\t\t<span className=\"editor-document-bar__shortcut\">\n\t\t\t\t\t\t{ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t</span>\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAMA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,SAAA,GAAAN,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,CAAAsF,gBAAM,CAACC,GAAG;IACVpB,SAAS,EAAC;IACV;IAAA;IACAqB,GAAG,EAAG5B,aAAe;IACrBiB,OAAO,EACNhB,OAAO,CAACG,OAAO,GACZ;MACAc,OAAO,EAAE,CAAC;MACVC,SAAS,EAAEnB,aAAa,GACrB,iBAAiB,GACjB;IACH,CAAC,GACD,KAAK,CAAC;IACT;IACDoB,OAAO,EAAG;MACTF,OAAO,EAAE,CAAC;MACVC,SAAS,EAAE;IACZ,CAAG;IACHG,UAAU,EACT7B,eAAe,GAAG;MAAE8B,QAAQ,EAAE;IAAE,CAAC,GAAGC;EACpC,GAED,IAAAnB,MAAA,CAAAC,aAAA,EAACjE,YAAA,CAAAwF,SAAS;IAAC1C,IAAI,EAAGU,UAAU,GAAG5B,YAAY,GAAGkB;EAAM,CAAE,CAAC,EACvD,IAAAkB,MAAA,CAAAC,aAAA,EAAClE,WAAA,CAAAqF,kBAAI;IACJT,IAAI,EAAC,MAAM;IACXc,EAAE,EAAC,IAAI;IACP,cACCjF,WAAW,CAAEiB,QAAQ,CAAE;IACpB;IACA,IAAAiE,aAAO,EAAElF,WAAW,CAAEiB,QAAQ,CAAE,EAAEsB,KAAM,CAAC,GACzCoC;EACH,GAECpC,KACG,CACK,CAAC,EACb,IAAAiB,MAAA,CAAAC,aAAA;IAAMC,SAAS,EAAC;EAA+B,GAC5CyB,yBAAe,CAACC,OAAO,CAAE,GAAI,CAC1B,CACC,CAEL,CAAC;AAER"}
@@ -16,17 +16,35 @@ var _store = require("../../store");
16
16
  */
17
17
 
18
18
  function EditorKeyboardShortcuts() {
19
+ const isModeToggleDisabled = (0, _data.useSelect)(select => {
20
+ const {
21
+ richEditingEnabled,
22
+ codeEditingEnabled
23
+ } = select(_store.store).getEditorSettings();
24
+ return !richEditingEnabled || !codeEditingEnabled;
25
+ }, []);
19
26
  const {
20
27
  redo,
21
28
  undo,
22
29
  savePost,
23
- setIsListViewOpened
30
+ setIsListViewOpened,
31
+ switchEditorMode,
32
+ toggleDistractionFree
24
33
  } = (0, _data.useDispatch)(_store.store);
25
34
  const {
26
35
  isEditedPostDirty,
27
36
  isPostSavingLocked,
28
- isListViewOpened
37
+ isListViewOpened,
38
+ getEditorMode
29
39
  } = (0, _data.useSelect)(_store.store);
40
+ (0, _keyboardShortcuts.useShortcut)('core/editor/toggle-mode', () => {
41
+ switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
42
+ }, {
43
+ isDisabled: isModeToggleDisabled
44
+ });
45
+ (0, _keyboardShortcuts.useShortcut)('core/editor/toggle-distraction-free', () => {
46
+ toggleDistractionFree();
47
+ });
30
48
  (0, _keyboardShortcuts.useShortcut)('core/editor/undo', event => {
31
49
  undo();
32
50
  event.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"names":["_keyboardShortcuts","require","_data","_store","EditorKeyboardShortcuts","redo","undo","savePost","setIsListViewOpened","useDispatch","editorStore","isEditedPostDirty","isPostSavingLocked","isListViewOpened","useSelect","useShortcut","event","preventDefault"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function EditorKeyboardShortcuts() {\n\tconst { redo, undo, savePost, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst { isEditedPostDirty, isPostSavingLocked, isListViewOpened } =\n\t\tuseSelect( editorStore );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\t// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.\n\tuseShortcut( 'core/editor/toggle-list-view', ( event ) => {\n\t\tif ( ! isListViewOpened() ) {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsListViewOpened( true );\n\t\t}\n\t} );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,uBAAuBA,CAAA,EAAG;EACjD,MAAM;IAAEC,IAAI;IAAEC,IAAI;IAAEC,QAAQ;IAAEC;EAAoB,CAAC,GAClD,IAAAC,iBAAW,EAAEC,YAAY,CAAC;EAC3B,MAAM;IAAEC,iBAAiB;IAAEC,kBAAkB;IAAEC;EAAiB,CAAC,GAChE,IAAAC,eAAS,EAAEJ,YAAY,CAAC;EAEzB,IAAAK,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CV,IAAI,CAAC,CAAC;IACNU,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CX,IAAI,CAAC,CAAC;IACNW,KAAK,CAACC,cAAc,CAAC,CAAC;EACvB,CAAE,CAAC;EAEH,IAAAF,8BAAW,EAAE,kBAAkB,EAAIC,KAAK,IAAM;IAC7CA,KAAK,CAACC,cAAc,CAAC,CAAC;;IAEtB;AACF;AACA;IACE,IAAKL,kBAAkB,CAAC,CAAC,EAAG;MAC3B;IACD;;IAEA;IACA;IACA;IACA;IACA;IACA,IAAK,CAAED,iBAAiB,CAAC,CAAC,EAAG;MAC5B;IACD;IAEAJ,QAAQ,CAAC,CAAC;EACX,CAAE,CAAC;;EAEH;EACA,IAAAQ,8BAAW,EAAE,8BAA8B,EAAIC,KAAK,IAAM;IACzD,IAAK,CAAEH,gBAAgB,CAAC,CAAC,EAAG;MAC3BG,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBT,mBAAmB,CAAE,IAAK,CAAC;IAC5B;EACD,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ"}
1
+ {"version":3,"names":["_keyboardShortcuts","require","_data","_store","EditorKeyboardShortcuts","isModeToggleDisabled","useSelect","select","richEditingEnabled","codeEditingEnabled","editorStore","getEditorSettings","redo","undo","savePost","setIsListViewOpened","switchEditorMode","toggleDistractionFree","useDispatch","isEditedPostDirty","isPostSavingLocked","isListViewOpened","getEditorMode","useShortcut","isDisabled","event","preventDefault"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useShortcut } from '@wordpress/keyboard-shortcuts';\nimport { useDispatch, useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\nexport default function EditorKeyboardShortcuts() {\n\tconst isModeToggleDisabled = useSelect( ( select ) => {\n\t\tconst { richEditingEnabled, codeEditingEnabled } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\treturn ! richEditingEnabled || ! codeEditingEnabled;\n\t}, [] );\n\tconst {\n\t\tredo,\n\t\tundo,\n\t\tsavePost,\n\t\tsetIsListViewOpened,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editorStore );\n\tconst {\n\t\tisEditedPostDirty,\n\t\tisPostSavingLocked,\n\t\tisListViewOpened,\n\t\tgetEditorMode,\n\t} = useSelect( editorStore );\n\n\tuseShortcut(\n\t\t'core/editor/toggle-mode',\n\t\t() => {\n\t\t\tswitchEditorMode(\n\t\t\t\tgetEditorMode() === 'visual' ? 'text' : 'visual'\n\t\t\t);\n\t\t},\n\t\t{\n\t\t\tisDisabled: isModeToggleDisabled,\n\t\t}\n\t);\n\n\tuseShortcut( 'core/editor/toggle-distraction-free', () => {\n\t\ttoggleDistractionFree();\n\t} );\n\n\tuseShortcut( 'core/editor/undo', ( event ) => {\n\t\tundo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/redo', ( event ) => {\n\t\tredo();\n\t\tevent.preventDefault();\n\t} );\n\n\tuseShortcut( 'core/editor/save', ( event ) => {\n\t\tevent.preventDefault();\n\n\t\t/**\n\t\t * Do not save the post if post saving is locked.\n\t\t */\n\t\tif ( isPostSavingLocked() ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO: This should be handled in the `savePost` effect in\n\t\t// considering `isSaveable`. See note on `isEditedPostSaveable`\n\t\t// selector about dirtiness and meta-boxes.\n\t\t//\n\t\t// See: `isEditedPostSaveable`\n\t\tif ( ! isEditedPostDirty() ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsavePost();\n\t} );\n\n\t// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.\n\tuseShortcut( 'core/editor/toggle-list-view', ( event ) => {\n\t\tif ( ! isListViewOpened() ) {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsListViewOpened( true );\n\t\t}\n\t} );\n\n\treturn null;\n}\n"],"mappings":";;;;;;AAGA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,MAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGe,SAASG,uBAAuBA,CAAA,EAAG;EACjD,MAAMC,oBAAoB,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IACrD,MAAM;MAAEC,kBAAkB;MAAEC;IAAmB,CAAC,GAC/CF,MAAM,CAAEG,YAAY,CAAC,CAACC,iBAAiB,C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M;IACzD,IAAK,CAAEJ,gBAAgB,CAAC,CAAC,EAAG;MAC3BI,KAAK,CAACC,cAAc,CAAC,CAAC;MACtBX,mBAAmB,CAAE,IAAK,CAAC;IAC5B;EACD,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ"}
@@ -21,6 +21,15 @@ function EditorKeyboardShortcutsRegister() {
21
21
  registerShortcut
22
22
  } = (0, _data.useDispatch)(_keyboardShortcuts.store);
23
23
  (0, _element.useEffect)(() => {
24
+ registerShortcut({
25
+ name: 'core/editor/toggle-mode',
26
+ category: 'global',
27
+ description: (0, _i18n.__)('Switch between visual editor and code editor.'),
28
+ keyCombination: {
29
+ modifier: 'secondary',
30
+ character: 'm'
31
+ }
32
+ });
24
33
  registerShortcut({
25
34
  name: 'core/editor/save',
26
35
  category: 'global',
@@ -65,6 +74,15 @@ function EditorKeyboardShortcutsRegister() {
65
74
  character: 'o'
66
75
  }
67
76
  });
77
+ registerShortcut({
78
+ name: 'core/editor/toggle-distraction-free',
79
+ category: 'global',
80
+ description: (0, _i18n.__)('Toggle distraction free mode.'),
81
+ keyCombination: {
82
+ modifier: 'primaryShift',
83
+ character: '\\'
84
+ }
85
+ });
68
86
  }, [registerShortcut]);
69
87
  return (0, _react.createElement)(_blockEditor.BlockEditorKeyboardShortcuts.Register, null);
70
88
  }
@@ -1 +1 @@
1
- {"version":3,"names":["_element","require","_data","_i18n","_blockEditor","_keyboardShortcuts","_keycodes","EditorKeyboardShortcutsRegister","registerShortcut","useDispatch","keyboardShortcutsStore","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","isAppleOS","_react","createElement","BlockEditorKeyboardShortcuts","Register","_default","exports","default"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\n\nfunction EditorKeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/toggle-list-view',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the block list view.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'o',\n\t\t\t},\n\t\t} );\n\t}, [ registerShortcut ] );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AE,CAAC;IAEHV,gBAAgB,CAAE;MACjBI,IAAI,EAAE,8BAA8B;MACpCC,QAAQ,EAAE,QAAQ;MAClBC,WAAW,EAAE,IAAAC,QAAE,EAAE,2BAA4B,CAAC;MAC9CC,cAAc,EAAE;QACfC,QAAQ,EAAE,QAAQ;QAClBC,SAAS,EAAE;MACZ;IACD,CAAE,CAAC;EACJ,CAAC,EAAE,CAAEV,gBAAgB,CAAG,CAAC;EAEzB,OAAO,IAAAa,MAAA,CAAAC,aAAA,EAAClB,YAAA,CAAAmB,4BAA4B,CAACC,QAAQ,MAAE,CAAC;AACjD;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpB,+BAA+B"}
1
+ {"version":3,"names":["_element","require","_data","_i18n","_blockEditor","_keyboardShortcuts","_keycodes","EditorKeyboardShortcutsRegister","registerShortcut","useDispatch","keyboardShortcutsStore","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","isAppleOS","_react","createElement","BlockEditorKeyboardShortcuts","Register","_default","exports","default"],"sources":["@wordpress/editor/src/components/global-keyboard-shortcuts/register-shortcuts.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { BlockEditorKeyboardShortcuts } from '@wordpress/block-editor';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { isAppleOS } from '@wordpress/keycodes';\n\nfunction EditorKeyboardShortcutsRegister() {\n\t// Registering the shortcuts.\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/toggle-mode',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Switch between visual editor and code editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'm',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/save',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Save your changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 's',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/undo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Undo your last changes.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primary',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/redo',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Redo your last undo.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: 'z',\n\t\t\t},\n\t\t\t// Disable on Apple OS because it conflicts with the browser's\n\t\t\t// history shortcut. It's a fine alias for both Windows and Linux.\n\t\t\t// Since there's no conflict for Ctrl+Shift+Z on both Windows and\n\t\t\t// Linux, we keep it as the default for consistency.\n\t\t\taliases: isAppleOS()\n\t\t\t\t? []\n\t\t\t\t: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmodifier: 'primary',\n\t\t\t\t\t\t\tcharacter: 'y',\n\t\t\t\t\t\t},\n\t\t\t\t ],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/toggle-list-view',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the block list view.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'o',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/editor/toggle-distraction-free',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Toggle distraction free mode.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: '\\\\',\n\t\t\t},\n\t\t} );\n\t}, [ registerSh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