File tree Expand file tree Collapse file tree 14 files changed +72
-15
lines changed
components/copy_to_clipboard Expand file tree Collapse file tree 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 = [
746746 " front_end/ui/components/cards/cards.js" ,
747747 " front_end/ui/components/chrome_link/chrome_link.js" ,
748748 " front_end/ui/components/code_highlighter/code_highlighter.js" ,
749+ " front_end/ui/components/copy_to_clipboard/copy_to_clipboard.js" ,
749750 " front_end/ui/components/dialogs/dialogs.js" ,
750751 " front_end/ui/components/diff_view/diff_view.js" ,
751752 " front_end/ui/components/expandable_list/expandable_list.js" ,
@@ -2278,6 +2279,7 @@ grd_files_debug_sources = [
22782279 " front_end/ui/components/chrome_link/chromeLink.css.js" ,
22792280 " front_end/ui/components/code_highlighter/CodeHighlighter.js" ,
22802281 " front_end/ui/components/code_highlighter/codeHighlighter.css.js" ,
2282+ " front_end/ui/components/copy_to_clipboard/copyToClipboard.js" ,
22812283 " front_end/ui/components/dialogs/ButtonDialog.js" ,
22822284 " front_end/ui/components/dialogs/Dialog.js" ,
22832285 " front_end/ui/components/dialogs/ShortcutDialog.js" ,
Original file line number Diff line number Diff line change @@ -299,6 +299,10 @@ export interface InspectorFrontendHostAPI {
299299
300300 closeWindow ( ) : void ;
301301
302+ /**
303+ * Don't use directly - use {@link CopyToClipboard.copyTextToClipboard} instead.
304+ * @deprecated Marked to restrict usage.
305+ */
302306 copyText ( text : string | null | undefined ) : void ;
303307
304308 inspectedURLChanged ( url : Platform . DevToolsPath . UrlString ) : void ;
Original file line number Diff line number Diff line change 3636import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js' ;
3737import * as Protocol from '../../generated/protocol.js' ;
3838import * as Common from '../common/common.js' ;
39- import * as Host from '../host/host.js' ;
4039import * as Platform from '../platform/platform.js' ;
4140import * as Root from '../root/root.js' ;
4241
@@ -574,14 +573,6 @@ export class DOMNode {
574573 } ) ;
575574 }
576575
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-
585576 path ( ) : string {
586577 function getNodeKey ( node : DOMNode ) : number | 'u' | 'a' | 'd' | null {
587578 if ( ! node . #nodeNameInternal. length ) {
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ devtools_module("changes") {
3434 " ../../panels/snippets:bundle" ,
3535 " ../../panels/utils:bundle" ,
3636 " ../../third_party/diff:bundle" ,
37+ " ../../ui/components/copy_to_clipboard:bundle" ,
3738 " ../../ui/components/diff_view:bundle" ,
3839 " ../../ui/legacy:bundle" ,
3940 " ../../ui/lit:bundle" ,
Original file line number Diff line number Diff line change 44/* eslint-disable rulesdir/no-lit-render-outside-of-view */
55
66import * as Common from '../../core/common/common.js' ;
7- import * as Host from '../../core/host/host.js' ;
87import * as i18n from '../../core/i18n/i18n.js' ;
98import * as Platform from '../../core/platform/platform.js' ;
109import * as Persistence from '../../models/persistence/persistence.js' ;
1110import type * as Workspace from '../../models/workspace/workspace.js' ;
1211import * as WorkspaceDiff from '../../models/workspace_diff/workspace_diff.js' ;
1312import type * as Diff from '../../third_party/diff/diff.js' ;
1413import * as Buttons from '../../ui/components/buttons/buttons.js' ;
14+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
1515import type * as DiffView from '../../ui/components/diff_view/diff_view.js' ;
1616import * as UI from '../../ui/legacy/legacy.js' ;
1717import * as Lit from '../../ui/lit/lit.js' ;
@@ -133,7 +133,7 @@ export class CombinedDiffView extends UI.Widget.Widget {
133133 return ;
134134 }
135135
136- Host . InspectorFrontendHost . InspectorFrontendHostInstance . copyText ( content . text ) ;
136+ CopyToClipboard . copyTextToClipboard ( content . text , i18nString ( UIStrings . copied ) ) ;
137137 this . #copiedFiles[ fileUrl ] = true ;
138138 this . requestUpdate ( ) ;
139139 setTimeout ( ( ) => {
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ devtools_module("elements") {
9090 " ../../panels/utils:bundle" ,
9191 " ../../ui/components/adorners:bundle" ,
9292 " ../../ui/components/code_highlighter:bundle" ,
93+ " ../../ui/components/copy_to_clipboard:bundle" ,
9394 " ../../ui/components/floating_button:bundle" ,
9495 " ../../ui/components/highlighting:bundle" ,
9596 " ../../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';
4141import * as IssuesManager from '../../models/issues_manager/issues_manager.js' ;
4242import * as Adorners from '../../ui/components/adorners/adorners.js' ;
4343import * as CodeHighlighter from '../../ui/components/code_highlighter/code_highlighter.js' ;
44+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
4445import * as IconButton from '../../ui/components/icon_button/icon_button.js' ;
4546import * as IssueCounter from '../../ui/components/issue_counter/issue_counter.js' ;
4647import * as UI from '../../ui/legacy/legacy.js' ;
@@ -376,8 +377,11 @@ export class ElementsTreeOutline extends
376377 if ( isCut && ( node . isShadowRoot ( ) || node . ancestorUserAgentShadowRoot ( ) ) ) {
377378 return ;
378379 }
379-
380- void node . copyNode ( ) ;
380+ void node . getOuterHTML ( ) . then ( outerHTML => {
381+ if ( outerHTML !== null ) {
382+ CopyToClipboard . copyTextToClipboard ( outerHTML ) ;
383+ }
384+ } ) ;
381385 this . setClipboardData ( { node, isCut} ) ;
382386 }
383387
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ devtools_module("timeline") {
116116 " ../../services/trace_bounds:bundle" ,
117117 " ../../ui/components/buttons:bundle" ,
118118 " ../../ui/components/code_highlighter:bundle" , # trace event highlighting
119+ " ../../ui/components/copy_to_clipboard:bundle" ,
119120 " ../../ui/components/icon_button:bundle" ,
120121 " ../../ui/components/linkifier:bundle" ,
121122 " ../../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';
1111import * as SDK from '../../core/sdk/sdk.js' ;
1212import type * as Protocol from '../../generated/protocol.js' ;
1313import * as Trace from '../../models/trace/trace.js' ;
14+ import * as CopyToClipboard from '../../ui/components/copy_to_clipboard/copy_to_clipboard.js' ;
1415import type * as Linkifier from '../../ui/components/linkifier/linkifier.js' ;
1516import * as UI from '../../ui/legacy/legacy.js' ;
1617import { html , render } from '../../ui/lit/lit.js' ;
@@ -215,8 +216,7 @@ export class TimelineSelectorStatsView extends UI.Widget.VBox {
215216 ] . join ( '\t' ) ) ;
216217 }
217218 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 ) ) ;
220220 } ) ;
221221 }
222222
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+ }
You can’t perform that action at this time.
0 commit comments