File tree 14 files changed +72
-15
lines changed
components/copy_to_clipboard 14 files changed +72
-15
lines changed Original file line number Diff line number Diff line change @@ -746,6 +746,7 @@ grd_files_release_sources = [
746
746
" front_end/ui/components/cards/cards.js" ,
747
747
" front_end/ui/components/chrome_link/chrome_link.js" ,
748
748
" front_end/ui/components/code_highlighter/code_highlighter.js" ,
749
+ " front_end/ui/components/copy_to_clipboard/copy_to_clipboard.js" ,
749
750
" front_end/ui/components/dialogs/dialogs.js" ,
750
751
" front_end/ui/components/diff_view/diff_view.js" ,
751
752
" front_end/ui/components/expandable_list/expandable_list.js" ,
@@ -2278,6 +2279,7 @@ grd_files_debug_sources = [
2278
2279
" front_end/ui/components/chrome_link/chromeLink.css.js" ,
2279
2280
" front_end/ui/components/code_highlighter/CodeHighlighter.js" ,
2280
2281
" front_end/ui/components/code_highlighter/codeHighlighter.css.js" ,
2282
+ " front_end/ui/components/copy_to_clipboard/copyToClipboard.js" ,
2281
2283
" front_end/ui/components/dialogs/ButtonDialog.js" ,
2282
2284
" front_end/ui/components/dialogs/Dialog.js" ,
2283
2285
" front_end/ui/components/dialogs/ShortcutDialog.js" ,
Original file line number Diff line number Diff line change @@ -299,6 +299,10 @@ export interface InspectorFrontendHostAPI {
299
299
300
300
closeWindow ( ) : void ;
301
301
302
+ /**
303
+ * Don't use directly - use {@link CopyToClipboard.copyTextToClipboard} instead.
304
+ * @deprecated Marked to restrict usage.
305
+ */
302
306
copyText ( text : string | null | undefined ) : void ;
303
307
304
308
inspectedURLChanged ( url : Platform . DevToolsPath . UrlString ) : void ;
Original file line number Diff line number Diff line change 36
36
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js' ;
37
37
import * as Protocol from '../../generated/protocol.js' ;
38
38
import * as Common from '../common/common.js' ;
39
- import * as Host from '../host/host.js' ;
40
39
import * as Platform from '../platform/platform.js' ;
41
40
import * as Root from '../root/root.js' ;
42
41
@@ -574,14 +573,6 @@ export class DOMNode {
574
573
} ) ;
575
574
}
576
575
577
- async copyNode ( ) : Promise < string | null > {
578
- const { outerHTML} = await this . #agent. invoke_getOuterHTML ( { nodeId : this . id } ) ;
579
- if ( outerHTML !== null ) {
580
- Host . InspectorFrontendHost . InspectorFrontendHostInstance . copyText ( outerHTML ) ;
581
- }
582
- return outerHTML ;
583
- }
584
-
585
576
path ( ) : string {
586
577
function getNodeKey ( node : DOMNode ) : number | 'u' | 'a' | 'd' | null {
587
578
if ( ! node . #nodeNameInternal. length ) {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ devtools_module("changes") {
34
34
" ../../panels/snippets:bundle" ,
35
35
" ../../panels/utils:bundle" ,
36
36
" ../../third_party/diff:bundle" ,
37
+ " ../../ui/components/copy_to_clipboard:bundle" ,
37
38
" ../../ui/components/diff_view:bundle" ,
38
39
" ../../ui/legacy:bundle" ,
39
40
" ../../ui/lit:bundle" ,
Original file line number Diff line number Diff line change 4
4
/* eslint-disable rulesdir/no-lit-render-outside-of-view */
5
5
6
6
import * as Common from '../../core/common/common.js' ;
7
- import * as Host from '../../core/host/host.js' ;
8
7
import * as i18n from '../../core/i18n/i18n.js' ;
9
8
import * as Platform from '../../core/platform/platform.js' ;
10
9
import * as Persistence from '../../models/persistence/persistence.js' ;
11
10
import type * as Workspace from '../../models/workspace/workspace.js' ;
12
11
import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js' ;
13
12
import type * as Diff from '../../third_party/diff/diff.js' ;
14
13
import * as Buttons from '../../ui/components/buttons/buttons.js' ;
14
+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
15
15
import type * as DiffView from '../../ui/components/diff_view/diff_view.js' ;
16
16
import * as UI from '../../ui/legacy/legacy.js' ;
17
17
import * as Lit from '../../ui/lit/lit.js' ;
@@ -133,7 +133,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
133
133
return ;
134
134
}
135
135
136
- Host . InspectorFrontendHost . InspectorFrontendHostInstance . copyText ( content . text ) ;
136
+ CopyToClipboard . copyTextToClipboard ( content . text , i18nString ( UIStrings . copied ) ) ;
137
137
this . #copiedFiles[ fileUrl ] = true ;
138
138
this . requestUpdate ( ) ;
139
139
setTimeout ( ( ) => {
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ devtools_module("elements") {
90
90
" ../../panels/utils:bundle" ,
91
91
" ../../ui/components/adorners:bundle" ,
92
92
" ../../ui/components/code_highlighter:bundle" ,
93
+ " ../../ui/components/copy_to_clipboard:bundle" ,
93
94
" ../../ui/components/floating_button:bundle" ,
94
95
" ../../ui/components/highlighting:bundle" ,
95
96
" ../../ui/components/text_editor:bundle" ,
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import * as SDK from '../../core/sdk/sdk.js';
41
41
import * as IssuesManager from '../../models/issues_manager/issues_manager.js' ;
42
42
import * as Adorners from '../../ui/components/adorners/adorners.js' ;
43
43
import * as CodeHighlighter from '../../ui/components/code_highlighter/code_highlighter.js' ;
44
+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
44
45
import * as IconButton from '../../ui/components/icon_button/icon_button.js' ;
45
46
import * as IssueCounter from '../../ui/components/issue_counter/issue_counter.js' ;
46
47
import * as UI from '../../ui/legacy/legacy.js' ;
@@ -376,8 +377,11 @@ export class ElementsTreeOutline extends
376
377
if ( isCut && ( node . isShadowRoot ( ) || node . ancestorUserAgentShadowRoot ( ) ) ) {
377
378
return ;
378
379
}
379
-
380
- void node . copyNode ( ) ;
380
+ void node . getOuterHTML ( ) . then ( outerHTML => {
381
+ if ( outerHTML !== null ) {
382
+ CopyToClipboard . copyTextToClipboard ( outerHTML ) ;
383
+ }
384
+ } ) ;
381
385
this . setClipboardData ( { node, isCut} ) ;
382
386
}
383
387
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ devtools_module("timeline") {
116
116
" ../../services/trace_bounds:bundle" ,
117
117
" ../../ui/components/buttons:bundle" ,
118
118
" ../../ui/components/code_highlighter:bundle" , # trace event highlighting
119
+ " ../../ui/components/copy_to_clipboard:bundle" ,
119
120
" ../../ui/components/icon_button:bundle" ,
120
121
" ../../ui/components/linkifier:bundle" ,
121
122
" ../../ui/components/menus:bundle" ,
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import * as i18n from '../../core/i18n/i18n.js';
11
11
import * as SDK from '../../core/sdk/sdk.js' ;
12
12
import type * as Protocol from '../../generated/protocol.js' ;
13
13
import * as Trace from '../../models/trace/trace.js' ;
14
+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
14
15
import type * as Linkifier from '../../ui/components/linkifier/linkifier.js' ;
15
16
import * as UI from '../../ui/legacy/legacy.js' ;
16
17
import { html , render } from '../../ui/lit/lit.js' ;
@@ -215,8 +216,7 @@ export class TimelineSelectorStatsView extends UI.Widget.VBox {
215
216
] . join ( '\t' ) ) ;
216
217
}
217
218
const data = tableData . join ( '\n' ) ;
218
- void navigator . clipboard . writeText ( data ) ;
219
- UI . ARIAUtils . alert ( i18nString ( UIStrings . tableCopiedToClipboard ) ) ;
219
+ CopyToClipboard . copyTextToClipboard ( data , i18nString ( UIStrings . tableCopiedToClipboard ) ) ;
220
220
} ) ;
221
221
}
222
222
Original file line number Diff line number Diff line change
1
+ # Copyright 2021 The Chromium Authors. All rights reserved.
2
+ # Use of this source code is governed by a BSD-style license that can be
3
+ # found in the LICENSE file.
4
+
5
+ import (" ../../../../scripts/build/ninja/devtools_entrypoint.gni" )
6
+ import (" ../../../../scripts/build/ninja/devtools_module.gni" )
7
+ import (" ../../../../scripts/build/ninja/generate_css.gni" )
8
+ import (" ../../../../scripts/build/typescript/typescript.gni" )
9
+ import (" ../visibility.gni" )
10
+
11
+ devtools_module (" copy_to_clipboard" ) {
12
+ sources = [ " copyToClipboard.ts" ]
13
+
14
+ deps = [
15
+ " ../../../core/host:bundle" ,
16
+ " ../../../ui/legacy:bundle" ,
17
+ ]
18
+ }
19
+
20
+ devtools_entrypoint (" bundle" ) {
21
+ entrypoint = " copy_to_clipboard.ts"
22
+
23
+ deps = [ " :copy_to_clipboard" ]
24
+
25
+ visibility = default_components_visibility
26
+ }
Original file line number Diff line number Diff line change
1
+
2
+ // Copyright 2025 The Chromium Authors. All rights reserved.
3
+ // Use of this source code is governed by a BSD-style license that can be
4
+ // found in the LICENSE file.
5
+
6
+ import * as Host from '../../../core/host/host.js' ;
7
+ import * as UI from '../../legacy/legacy.js' ;
8
+
9
+ /**
10
+ * @param text Text to copy to clipboard
11
+ * @param alert Message to send for a11y
12
+ */
13
+ export function copyTextToClipboard ( text : string , alert ?: string ) : void {
14
+ Host . InspectorFrontendHost . InspectorFrontendHostInstance . copyText ( text ) ;
15
+ // TODO: make alert required.
16
+ if ( alert ) {
17
+ UI . ARIAUtils . alert ( alert ) ;
18
+ }
19
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright 2025 The Chromium Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style license that can be
3
+ // found in the LICENSE file.
4
+
5
+ export { copyTextToClipboard } from './copyToClipboard.js' ;
Original file line number Diff line number Diff line change @@ -144,6 +144,7 @@ devtools_entrypoint("bundle") {
144
144
" ../../panels/*" ,
145
145
" ../../services/window_bounds/*" ,
146
146
" ../../testing/*" ,
147
+ " ../components/copy_to_clipboard:*" ,
147
148
" ../components/data_grid:*" ,
148
149
" ../components/docs/combo_box/*" ,
149
150
" ../components/docs/performance_panel/*" ,
Original file line number Diff line number Diff line change @@ -489,6 +489,7 @@ export const knownContextValues = new Set([
489
489
'autofill-view' ,
490
490
'autofill-view-documentation' ,
491
491
'autofill-view-feedback' ,
492
+ 'automatic-workspace-folders' ,
492
493
'automatic-workspace-folders.connect' ,
493
494
'automatically-ignore-list-known-third-party-scripts' ,
494
495
'auxclick' ,
@@ -3345,6 +3346,7 @@ export const knownContextValues = new Set([
3345
3346
'src' ,
3346
3347
'srgb' ,
3347
3348
'stack-trace' ,
3349
+ 'stage-to-workspace' ,
3348
3350
'stalled' ,
3349
3351
'standard-emulated-device-list' ,
3350
3352
'start' ,
You can’t perform that action at this time.
0 commit comments