File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 19
19
" https://*/*" ,
20
20
" file:///*" ,
21
21
" activeTab" ,
22
- " tabs"
22
+ " tabs" ,
23
+ " clipboardWrite"
23
24
]
24
25
}
Original file line number Diff line number Diff line change @@ -11,14 +11,24 @@ define(['api'], function(api) {
11
11
ce ( 'div' , { class : [ '-toolbox' ] } , [
12
12
ce ( 'button' , {
13
13
class : [ 'btn' ] ,
14
+ attrs : { title : 'Inject console.diff API to current tab' } ,
14
15
on : { click : this . onReinject }
15
16
} , 'Inject API' ) ,
16
17
( this . hasBothSides ?
17
18
ce ( 'button' , {
18
19
class : [ 'btn' ] ,
20
+ attrs : { title : 'Hide/Show unchanged properties' } ,
19
21
on : { click : this . onToggleUnchanged }
20
22
} , 'Toggle Unchanged' )
21
23
: null
24
+ ) ,
25
+ ( this . hasBothSides ?
26
+ ce ( 'button' , {
27
+ class : [ 'btn' ] ,
28
+ attrs : { title : 'Copy delta as json string' } ,
29
+ on : { click : this . onCopyDelta }
30
+ } , 'Copy' )
31
+ : null
22
32
)
23
33
] ) ,
24
34
( this . hasBothSides ?
@@ -119,6 +129,16 @@ define(['api'], function(api) {
119
129
chrome . runtime . sendMessage ( 'jsdiff-panel-reinject' ) ;
120
130
} ,
121
131
132
+ onCopyDelta ( ) {
133
+ const delta = api . jsondiffpatch . diff ( this . compare . left , this . compare . right ) ;
134
+ const sDelta = JSON . stringify ( delta ) ;
135
+ document . oncopy = function ( e ) {
136
+ e . clipboardData . setData ( 'text' , sDelta ) ;
137
+ e . preventDefault ( ) ;
138
+ } ;
139
+ document . execCommand ( 'copy' , false , null ) ;
140
+ } ,
141
+
122
142
$_restartLastUpdated ( ) {
123
143
this . compare . timestamp = Date . now ( ) ;
124
144
You can’t perform that action at this time.
0 commit comments