forked from ChromeDevTools/devtools-frontend
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathemulation-meta.ts
More file actions
215 lines (198 loc) · 6.96 KB
/
Copy pathemulation-meta.ts
File metadata and controls
215 lines (198 loc) · 6.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import * as Common from '../../core/common/common.js';
import * as i18n from '../../core/i18n/i18n.js';
import * as Root from '../../core/root/root.js';
import * as UI from '../../ui/legacy/legacy.js';
import type * as Emulation from './emulation.js';
const UIStrings = {
/**
*@description Title of an action in the emulation tool to toggle device mode
*/
toggleDeviceToolbar: 'Toggle device toolbar',
/**
*@description Title of an action in the emulation tool to capture screenshot
*/
captureScreenshot: 'Capture screenshot',
/**
* @description Title of an action in the emulation tool to capture full height screenshot. This
* action captures a screenshot of the entire website, not just the visible portion.
*/
captureFullSizeScreenshot: 'Capture full size screenshot',
/**
* @description Title of an action in the emulation tool to capture a screenshot of just this node.
* Node refers to a HTML element/node.
*/
captureNodeScreenshot: 'Capture node screenshot',
/**
* @description Command in the Device Mode Toolbar, to show media query boundaries in the UI.
* https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
*/
showMediaQueries: 'Show media queries',
/**
* @description A tag of Mobile related settings that can be searched in the command menu if the
* user doesn't know the exact name of the tool. Device refers to e.g. phone/tablet.
*/
device: 'device',
/**
*@description Command in the Device Mode Toolbar, to hide media query boundaries in the UI.
* https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries
*/
hideMediaQueries: 'Hide media queries',
/**
*@description Command that shows measuring rulers next to the emulated device.
*/
showRulers: 'Show rulers in the Device Mode toolbar',
/**
*@description Command that hides measuring rulers next to the emulated device.
*/
hideRulers: 'Hide rulers in the Device Mode toolbar',
/**
*@description Command that shows a frame (like a picture frame) around the emulated device.
*/
showDeviceFrame: 'Show device frame',
/**
*@description Command that hides a frame (like a picture frame) around the emulated device.
*/
hideDeviceFrame: 'Hide device frame',
} as const;
const str_ = i18n.i18n.registerUIStrings('panels/emulation/emulation-meta.ts', UIStrings);
const i18nLazyString = i18n.i18n.getLazilyComputedLocalizedString.bind(undefined, str_);
let loadedEmulationModule: (typeof Emulation|undefined);
async function loadEmulationModule(): Promise<typeof Emulation> {
if (!loadedEmulationModule) {
loadedEmulationModule = await import('./emulation.js');
}
return loadedEmulationModule;
}
UI.ActionRegistration.registerActionExtension({
category: UI.ActionRegistration.ActionCategory.MOBILE,
actionId: 'emulation.toggle-device-mode',
toggleable: true,
async loadActionDelegate() {
const Emulation = await loadEmulationModule();
return new Emulation.DeviceModeWrapper.ActionDelegate();
},
condition: Root.Runtime.conditions.canDock,
title: i18nLazyString(UIStrings.toggleDeviceToolbar),
iconClass: UI.ActionRegistration.IconClass.LARGEICON_PHONE,
bindings: [
{
platform: UI.ActionRegistration.Platforms.WINDOWS_LINUX,
shortcut: 'Shift+Ctrl+M',
},
{
platform: UI.ActionRegistration.Platforms.MAC,
shortcut: 'Shift+Meta+M',
},
],
});
UI.ActionRegistration.registerActionExtension({
actionId: 'emulation.capture-screenshot',
category: UI.ActionRegistration.ActionCategory.SCREENSHOT,
async loadActionDelegate() {
const Emulation = await loadEmulationModule();
return new Emulation.DeviceModeWrapper.ActionDelegate();
},
// [RN] Available without docking for React Native targets.
// condition: Root.Runtime.conditions.canDock,
title: i18nLazyString(UIStrings.captureScreenshot),
});
UI.ActionRegistration.registerActionExtension({
actionId: 'emulation.capture-full-height-screenshot',
category: UI.ActionRegistration.ActionCategory.SCREENSHOT,
async loadActionDelegate() {
const Emulation = await loadEmulationModule();
return new Emulation.DeviceModeWrapper.ActionDelegate();
},
condition: Root.Runtime.conditions.canDock,
title: i18nLazyString(UIStrings.captureFullSizeScreenshot),
});
UI.ActionRegistration.registerActionExtension({
actionId: 'emulation.capture-node-screenshot',
category: UI.ActionRegistration.ActionCategory.SCREENSHOT,
async loadActionDelegate() {
const Emulation = await loadEmulationModule();
return new Emulation.DeviceModeWrapper.ActionDelegate();
},
condition: Root.Runtime.conditions.canDock,
title: i18nLazyString(UIStrings.captureNodeScreenshot),
});
Common.Settings.registerSettingExtension({
category: Common.Settings.SettingCategory.MOBILE,
settingName: 'show-media-query-inspector',
settingType: Common.Settings.SettingType.BOOLEAN,
defaultValue: false,
options: [
{
value: true,
title: i18nLazyString(UIStrings.showMediaQueries),
},
{
value: false,
title: i18nLazyString(UIStrings.hideMediaQueries),
},
],
tags: [i18nLazyString(UIStrings.device)],
});
Common.Settings.registerSettingExtension({
category: Common.Settings.SettingCategory.MOBILE,
settingName: 'emulation.show-rulers',
settingType: Common.Settings.SettingType.BOOLEAN,
defaultValue: false,
options: [
{
value: true,
title: i18nLazyString(UIStrings.showRulers),
},
{
value: false,
title: i18nLazyString(UIStrings.hideRulers),
},
],
tags: [i18nLazyString(UIStrings.device)],
});
Common.Settings.registerSettingExtension({
category: Common.Settings.SettingCategory.MOBILE,
settingName: 'emulation.show-device-outline',
settingType: Common.Settings.SettingType.BOOLEAN,
defaultValue: false,
options: [
{
value: true,
title: i18nLazyString(UIStrings.showDeviceFrame),
},
{
value: false,
title: i18nLazyString(UIStrings.hideDeviceFrame),
},
],
tags: [i18nLazyString(UIStrings.device)],
});
UI.Toolbar.registerToolbarItem({
actionId: 'emulation.toggle-device-mode',
condition: Root.Runtime.conditions.canDock,
location: UI.Toolbar.ToolbarItemLocation.MAIN_TOOLBAR_LEFT,
order: 1,
loadItem: undefined,
separator: undefined,
});
Common.AppProvider.registerAppProvider({
async loadAppProvider() {
const Emulation = await loadEmulationModule();
return Emulation.AdvancedApp.AdvancedAppProvider.instance();
},
condition: Root.Runtime.conditions.canDock,
order: 0,
});
UI.ContextMenu.registerItem({
location: UI.ContextMenu.ItemLocation.DEVICE_MODE_MENU_SAVE,
order: 12,
actionId: 'emulation.capture-screenshot',
});
UI.ContextMenu.registerItem({
location: UI.ContextMenu.ItemLocation.DEVICE_MODE_MENU_SAVE,
order: 13,
actionId: 'emulation.capture-full-height-screenshot',
});