@wordpress/editor 13.28.2 → 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.
- package/CHANGELOG.md +2 -0
- package/build/components/commands/index.js +201 -0
- package/build/components/commands/index.js.map +1 -0
- package/build/components/commands/index.native.js +9 -0
- package/build/components/commands/index.native.js.map +1 -0
- package/build/components/document-bar/index.js +78 -67
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-tools/index.js +4 -2
- package/build/components/document-tools/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +20 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/mode-switcher/index.js +86 -0
- package/build/components/mode-switcher/index.js.map +1 -0
- package/build/components/post-title/index.js +0 -5
- package/build/components/post-title/index.js.map +1 -1
- package/build/components/provider/index.js +6 -0
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +4 -9
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +4 -8
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js +53 -0
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
- package/build/private-apis.js +2 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +69 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +13 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/commands/index.js +194 -0
- package/build-module/components/commands/index.js.map +1 -0
- package/build-module/components/commands/index.native.js +3 -0
- package/build-module/components/commands/index.native.js.map +1 -0
- package/build-module/components/document-bar/index.js +81 -70
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +4 -2
- package/build-module/components/document-tools/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +20 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +18 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/mode-switcher/index.js +80 -0
- package/build-module/components/mode-switcher/index.js.map +1 -0
- package/build-module/components/post-title/index.js +0 -5
- package/build-module/components/post-title/index.js.map +1 -1
- package/build-module/components/provider/index.js +6 -0
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +4 -10
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +5 -9
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js +47 -0
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -0
- package/build-module/private-apis.js +2 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +66 -0
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +12 -0
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +4 -47
- package/build-style/style.css +4 -47
- package/package.json +32 -32
- package/src/components/commands/index.js +202 -0
- package/src/components/commands/index.native.js +2 -0
- package/src/components/document-bar/index.js +115 -94
- package/src/components/document-bar/style.scss +4 -37
- package/src/components/document-tools/index.js +22 -16
- package/src/components/global-keyboard-shortcuts/index.js +35 -4
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +20 -0
- package/src/components/mode-switcher/index.js +90 -0
- package/src/components/post-title/index.js +0 -3
- package/src/components/provider/index.js +7 -0
- package/src/components/provider/index.native.js +7 -6
- package/src/components/provider/use-block-editor-settings.js +6 -15
- package/src/components/provider/use-hide-blocks-from-inserter.js +81 -0
- package/src/private-apis.js +2 -0
- package/src/store/actions.js +95 -0
- package/src/store/selectors.js +12 -0
- package/src/store/test/actions.js +82 -0
package/CHANGELOG.md
CHANGED
|
@@ -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":";;;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AAG;IACjByB,QAAQ,CAACE,IAAI,CAAE;MACdC,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 @@
|
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
109
|
-
|
|
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':
|
|
117
|
-
'is-animated': isAnimated,
|
|
99
|
+
'has-back-button': hasBackButton,
|
|
118
100
|
'is-global': isGlobalEntity
|
|
119
101
|
})
|
|
120
|
-
},
|
|
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
|
-
|
|
107
|
+
onNavigateToPreviousEntityRecord();
|
|
126
108
|
},
|
|
127
|
-
size: "compact"
|
|
128
|
-
|
|
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.
|
|
133
|
-
className: "editor-document-bar__title"
|
|
134
|
-
|
|
135
|
-
|
|
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":
|
|
152
|
+
"aria-label": TYPE_LABELS[postType] ?
|
|
142
153
|
// eslint-disable-next-line @wordpress/valid-sprintf
|
|
143
|
-
(0, _i18n.sprintf)(
|
|
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,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAOA,IAAAM,SAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AAKA,IAAAU,MAAA,G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AAGd,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,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AACA,IAAAS,QAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAKA,IAAAW,MAAA,GAAAX,OAAA;AAjCA;AACA;AACA;;AAGA;AACA;AACA;;AAuBA;AACA;AACA;;AAGA,MAAMY,WAAW,GAAG;EACnB;EACAC,UAAU,EAAE,IAAAC,QAAE,EAAE,qBAAsB,CAAC;EACvC;EACAC,a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,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"}
|
|
@@ -51,6 +51,7 @@ function DocumentTools({
|
|
|
51
51
|
setIsListViewOpened
|
|
52
52
|
} = (0, _data.useDispatch)(_store.store);
|
|
53
53
|
const {
|
|
54
|
+
isDistractionFree,
|
|
54
55
|
isInserterOpened,
|
|
55
56
|
isListViewOpen,
|
|
56
57
|
listViewShortcut,
|
|
@@ -77,7 +78,8 @@ function DocumentTools({
|
|
|
77
78
|
listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
|
|
78
79
|
listViewToggleRef: getListViewToggleRef(),
|
|
79
80
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
80
|
-
showIconLabels: get('core', 'showIconLabels')
|
|
81
|
+
showIconLabels: get('core', 'showIconLabels'),
|
|
82
|
+
isDistractionFree: get('core', 'distractionFree')
|
|
81
83
|
};
|
|
82
84
|
}, []);
|
|
83
85
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
@@ -143,7 +145,7 @@ function DocumentTools({
|
|
|
143
145
|
showTooltip: !showIconLabels,
|
|
144
146
|
variant: showIconLabels ? 'tertiary' : undefined,
|
|
145
147
|
size: "compact"
|
|
146
|
-
}), (0, _react.createElement)(_components.ToolbarItem, {
|
|
148
|
+
}), !isDistractionFree && (0, _react.createElement)(_components.ToolbarItem, {
|
|
147
149
|
as: _components.Button,
|
|
148
150
|
className: "editor-document-tools__document-overview-toggle",
|
|
149
151
|
icon: _icons.listView,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_data","_i18n","_blockEditor","_components","_icons","_element","_keyboardShortcuts","_preferences","_lockUnlock","_store","_redo","_undo","useCanBlockToolbarBeFocused","unlock","blockEditorPrivateApis","preventDefault","event","DocumentTools","className","disableBlockTools","children","listViewLabel","__","inserterButton","useRef","setIsInserterOpened","setIsListViewOpened","useDispatch","editorStore","isInserterOpened","isListViewOpen","listViewShortcut","listViewToggleRef","hasFixedToolbar","showIconLabels","useSelect","select","getSettings","blockEditorStore","get","preferencesStore","isListViewOpened","getListViewToggleRef","getShortcutRepresentation","keyboardShortcutsStore","isLargeViewport","useViewportMatch","isWideViewport","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","useCallback","toggleInserter","current","focus","longLabel","_x","shortLabel","_react","createElement","NavigableToolbar","classnames","shouldUseKeyboardFocusShortcut","variant","ToolbarItem","ref","as","Button","isPressed","onMouseDown","onClick","disabled","icon","plus","label","showTooltip","Fragment","ToolSelector","undefined","size","EditorHistoryUndo","EditorHistoryRedo","listView","shortcut","_default","exports","default"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nconst { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction DocumentTools( {\n\tclassName,\n\tdisableBlockTools = false,\n\tchildren,\n\t// This is a temporary prop until the list view is fully unified between post and site editors.\n\tlistViewLabel = __( 'Document Overview' ),\n} ) {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getListViewToggleRef } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ classnames(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\tlabel={ listViewLabel }\n\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAMA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAKA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,KAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,KAAA,GAAAd,sBAAA,CAAAC,OAAA;AA7BA;AACA;AACA;;AAGA;AACA;AACA;;AAgBA;AACA;AACA;;AAMA,MAAM;EAAEc;AAA4B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,wBAAuB,CAAC;AAExE,MAAMC,cAAc,GAAKC,KAAK,IAAM;EACnCA,KAAK,CAACD,cAAc,CAAC,CAAC;AACvB,CAAC;AAED,SAASE,aAAaA,CAAE;EACvBC,SAAS;E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AC9BiD,SAAS,EAAGtC;MACZ;MACA4C,KAAK,EAAGrD,aAAe;MACvBiD,OAAO,EAAGpB,cAAgB;MAC1BiC,QAAQ,EAAGpD,gBAAkB;MAC7B4C,WAAW,EAAG,CAAEzC,cAAgB;MAChC6B,OAAO,EAAG7B,cAAc,GAAG,UAAU,GAAG4C,SAAW;MACnD,iBAAgBhD,cAAgB;MAChCmC,GAAG,EAAGjC,iBAAmB;MACzB+C,IAAI,EAAC;IAAS,CACd,CACA,CACF,EACC3D,QACE,CACY;EAAC;AAErB;AAAC,IAAAgE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcrE,aAAa"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_compose","_data","_i18n","_blockEditor","_components","_icons","_element","_keyboardShortcuts","_preferences","_lockUnlock","_store","_redo","_undo","useCanBlockToolbarBeFocused","unlock","blockEditorPrivateApis","preventDefault","event","DocumentTools","className","disableBlockTools","children","listViewLabel","__","inserterButton","useRef","setIsInserterOpened","setIsListViewOpened","useDispatch","editorStore","isDistractionFree","isInserterOpened","isListViewOpen","listViewShortcut","listViewToggleRef","hasFixedToolbar","showIconLabels","useSelect","select","getSettings","blockEditorStore","get","preferencesStore","isListViewOpened","getListViewToggleRef","getShortcutRepresentation","keyboardShortcutsStore","isLargeViewport","useViewportMatch","isWideViewport","blockToolbarCanBeFocused","toolbarAriaLabel","toggleListView","useCallback","toggleInserter","current","focus","longLabel","_x","shortLabel","_react","createElement","NavigableToolbar","classnames","shouldUseKeyboardFocusShortcut","variant","ToolbarItem","ref","as","Button","isPressed","onMouseDown","onClick","disabled","icon","plus","label","showTooltip","Fragment","ToolSelector","undefined","size","EditorHistoryUndo","EditorHistoryRedo","listView","shortcut","_default","exports","default"],"sources":["@wordpress/editor/src/components/document-tools/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, _x } from '@wordpress/i18n';\nimport {\n\tNavigableToolbar,\n\tToolSelector,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { Button, ToolbarItem } from '@wordpress/components';\nimport { listView, plus } from '@wordpress/icons';\nimport { useRef, useCallback } from '@wordpress/element';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../../lock-unlock';\nimport { store as editorStore } from '../../store';\nimport EditorHistoryRedo from '../editor-history/redo';\nimport EditorHistoryUndo from '../editor-history/undo';\n\nconst { useCanBlockToolbarBeFocused } = unlock( blockEditorPrivateApis );\n\nconst preventDefault = ( event ) => {\n\tevent.preventDefault();\n};\n\nfunction DocumentTools( {\n\tclassName,\n\tdisableBlockTools = false,\n\tchildren,\n\t// This is a temporary prop until the list view is fully unified between post and site editors.\n\tlistViewLabel = __( 'Document Overview' ),\n} ) {\n\tconst inserterButton = useRef();\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst {\n\t\tisDistractionFree,\n\t\tisInserterOpened,\n\t\tisListViewOpen,\n\t\tlistViewShortcut,\n\t\tlistViewToggleRef,\n\t\thasFixedToolbar,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { isListViewOpened, getListViewToggleRef } = unlock(\n\t\t\tselect( editorStore )\n\t\t);\n\t\tconst { getShortcutRepresentation } = select( keyboardShortcutsStore );\n\n\t\treturn {\n\t\t\tisInserterOpened: select( editorStore ).isInserterOpened(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tlistViewShortcut: getShortcutRepresentation(\n\t\t\t\t'core/editor/toggle-list-view'\n\t\t\t),\n\t\t\tlistViewToggleRef: getListViewToggleRef(),\n\t\t\thasFixedToolbar: getSettings().hasFixedToolbar,\n\t\t\tshowIconLabels: get( 'core', 'showIconLabels' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t};\n\t}, [] );\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isWideViewport = useViewportMatch( 'wide' );\n\tconst blockToolbarCanBeFocused = useCanBlockToolbarBeFocused();\n\n\t/* translators: accessibility text for the editor toolbar */\n\tconst toolbarAriaLabel = __( 'Document tools' );\n\n\tconst toggleListView = useCallback(\n\t\t() => setIsListViewOpened( ! isListViewOpen ),\n\t\t[ setIsListViewOpened, isListViewOpen ]\n\t);\n\n\tconst toggleInserter = useCallback( () => {\n\t\tif ( isInserterOpened ) {\n\t\t\t// Focusing the inserter button should close the inserter popover.\n\t\t\t// However, there are some cases it won't close when the focus is lost.\n\t\t\t// See https://github.com/WordPress/gutenberg/issues/43090 for more details.\n\t\t\tinserterButton.current.focus();\n\t\t\tsetIsInserterOpened( false );\n\t\t} else {\n\t\t\tsetIsInserterOpened( true );\n\t\t}\n\t}, [ isInserterOpened, setIsInserterOpened ] );\n\n\t/* translators: button label text should, if possible, be under 16 characters. */\n\tconst longLabel = _x(\n\t\t'Toggle block inserter',\n\t\t'Generic label for block inserter button'\n\t);\n\tconst shortLabel = ! isInserterOpened ? __( 'Add' ) : __( 'Close' );\n\n\treturn (\n\t\t// Some plugins expect and use the `edit-post-header-toolbar` CSS class to\n\t\t// find the toolbar and inject UI elements into it. This is not officially\n\t\t// supported, but we're keeping it in the list of class names for backwards\n\t\t// compatibility.\n\t\t<NavigableToolbar\n\t\t\tclassName={ classnames(\n\t\t\t\t'editor-document-tools',\n\t\t\t\t'edit-post-header-toolbar',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\taria-label={ toolbarAriaLabel }\n\t\t\tshouldUseKeyboardFocusShortcut={ ! blockToolbarCanBeFocused }\n\t\t\tvariant=\"unstyled\"\n\t\t>\n\t\t\t<div className=\"editor-document-tools__left\">\n\t\t\t\t<ToolbarItem\n\t\t\t\t\tref={ inserterButton }\n\t\t\t\t\tas={ Button }\n\t\t\t\t\tclassName=\"editor-document-tools__inserter-toggle\"\n\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\tisPressed={ isInserterOpened }\n\t\t\t\t\tonMouseDown={ preventDefault }\n\t\t\t\t\tonClick={ toggleInserter }\n\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tlabel={ showIconLabels ? shortLabel : longLabel }\n\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\taria-expanded={ isInserterOpened }\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ isLargeViewport && ! hasFixedToolbar && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ ToolSelector }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryUndo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\tas={ EditorHistoryRedo }\n\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\tvariant={ showIconLabels ? 'tertiary' : undefined }\n\t\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ ! isDistractionFree && (\n\t\t\t\t\t\t\t<ToolbarItem\n\t\t\t\t\t\t\t\tas={ Button }\n\t\t\t\t\t\t\t\tclassName=\"editor-document-tools__document-overview-toggle\"\n\t\t\t\t\t\t\t\ticon={ listView }\n\t\t\t\t\t\t\t\tdisabled={ disableBlockTools }\n\t\t\t\t\t\t\t\tisPressed={ isListViewOpen }\n\t\t\t\t\t\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\t\t\t\t\t\tlabel={ listViewLabel }\n\t\t\t\t\t\t\t\tonClick={ toggleListView }\n\t\t\t\t\t\t\t\tshortcut={ listViewShortcut }\n\t\t\t\t\t\t\t\tshowTooltip={ ! showIconLabels }\n\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\tshowIconLabels ? 'tertiary' : undefined\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\taria-expanded={ isListViewOpen }\n\t\t\t\t\t\t\t\tref={ listViewToggleRef }\n\t\t\t\t\t\t\t\tsize=\"compact\"\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\t{ children }\n\t\t\t</div>\n\t\t</NavigableToolbar>\n\t);\n}\n\nexport default DocumentTools;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAMA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,kBAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AAKA,IAAAU,WAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,K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C;IAAS,CACd,CAAC,EACF,IAAArB,MAAA,CAAAC,aAAA,EAACzD,WAAA,CAAA8D,WAAW;MACXE,EAAE,EAAGe,aAAmB;MACxBN,WAAW,EAAG,CAAEzC,cAAgB;MAChC6B,OAAO,EAAG7B,cAAc,GAAG,UAAU,GAAG4C,SAAW;MACnDC,IAAI,EAAC;IAAS,CACd,CAAC,EACA,CAAEnD,iBAAiB,IACpB,IAAA8B,MAAA,CAAAC,aAAA,EAACzD,WAAA,CAAA8D,WAAW;MACXE,EAAE,EAAGC,kBAAQ;MACblD,SAAS,EAAC,iDAAiD;MAC3DuD,IAAI,EAAGU,eAAU;MACjBX,QAAQ,EAAGrD,iBAAmB;MAC9BkD,SAAS,EAAGtC;MACZ;MACA4C,KAAK,EAAGtD,aAAe;MACvBkD,OAAO,EAAGpB,cAAgB;MAC1BiC,QAAQ,EAAGpD,gBAAkB;MAC7B4C,WAAW,EAAG,CAAEzC,cAAgB;MAChC6B,OAAO,EACN7B,cAAc,GAAG,UAAU,GAAG4C,SAC9B;MACD,iBAAgBhD,cAAgB;MAChCmC,GAAG,EAAGjC,iBAAmB;MACzB+C,IAAI,EAAC;IAAS,CACd,CAED,CACF,EACC5D,QACE,CACY;EAAC;AAErB;AAAC,IAAAiE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEctE,aAAa"}
|
|
@@ -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();
|