File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
tools/devtools/src/devtools_app
devtools_window/components_tab/details_window Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 44 <div class =" panel-top d-flex align-items-center" >
55 <div class =" ms-1 p-1 text-truncate" style =" width: 100%;" >
66 <span t-if =" store.activeComponent.path.length > 1" >< </span >
7- <b style =" color: var(--component-color); cursor: pointer;" t-on-mouseover.stop=" () => this.store.highlightComponent(this.store.activeComponent.path)" t-on-click.stop=" () => this.store.focusSelectedComponent()" t-on-contextmenu.prevent=" openMenu" t-esc =" store.activeComponent.name" />
7+ <b
8+ style =" color: var(--component-color); cursor: pointer;"
9+ t-on-mouseover.stop=" () => this.store.highlightComponent(this.store.activeComponent.path)"
10+ t-on-click.stop=" () => this.store.onActiveComponentClick()"
11+ t-on-contextmenu.prevent=" openMenu"
12+ t-esc =" store.activeComponent.name"
13+ />
814 <span t-if =" store.activeComponent.path.length > 1" >> </span >
915 <span class =" version" t-else =" " >owl=<t t-esc =" store.activeComponent.version" /></span >
1016 </div >
Original file line number Diff line number Diff line change @@ -608,8 +608,9 @@ export const store = reactive({
608608 } ,
609609
610610 // Center the view around the currently selected component
611- focusSelectedComponent ( ) {
611+ onActiveComponentClick ( ) {
612612 this . selectedElement . scrollIntoView ( { block : "center" , behavior : "smooth" } ) ;
613+ copyToClipboard ( this . activeComponent . name ) ;
613614 } ,
614615
615616 // Toggle the recording of events in the page
@@ -1055,3 +1056,21 @@ async function evalInWindow(code, frameUrl = "top") {
10551056 }
10561057 } ) ;
10571058}
1059+
1060+ function copyToClipboard ( text ) {
1061+ // This is crappy but it seems like document.execCommand is the only remaining way to
1062+ // copy text to clipboard in a devtools extension (even though it is marked as deprecated)
1063+ // since navigator.clipboard.writeText has permission issues inside iframes (and the devtools
1064+ // panel is mounted inside an iframe)
1065+ const textarea = document . createElement ( "textarea" ) ;
1066+ textarea . value = text ;
1067+ textarea . style . opacity = "0" ;
1068+ document . body . appendChild ( textarea ) ;
1069+ textarea . select ( ) ;
1070+ try {
1071+ document . execCommand ( "copy" ) ;
1072+ } catch ( err ) {
1073+ console . error ( "Copy failed" , err ) ;
1074+ }
1075+ document . body . removeChild ( textarea ) ;
1076+ }
You can’t perform that action at this time.
0 commit comments