File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1919 " https://*/*" ,
2020 " file:///*" ,
2121 " activeTab" ,
22- " tabs"
22+ " tabs" ,
23+ " clipboardWrite"
2324 ]
2425}
Original file line number Diff line number Diff line change @@ -11,14 +11,24 @@ define(['api'], function(api) {
1111 ce ( 'div' , { class : [ '-toolbox' ] } , [
1212 ce ( 'button' , {
1313 class : [ 'btn' ] ,
14+ attrs : { title : 'Inject console.diff API to current tab' } ,
1415 on : { click : this . onReinject }
1516 } , 'Inject API' ) ,
1617 ( this . hasBothSides ?
1718 ce ( 'button' , {
1819 class : [ 'btn' ] ,
20+ attrs : { title : 'Hide/Show unchanged properties' } ,
1921 on : { click : this . onToggleUnchanged }
2022 } , 'Toggle Unchanged' )
2123 : 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
2232 )
2333 ] ) ,
2434 ( this . hasBothSides ?
@@ -119,6 +129,16 @@ define(['api'], function(api) {
119129 chrome . runtime . sendMessage ( 'jsdiff-panel-reinject' ) ;
120130 } ,
121131
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+
122142 $_restartLastUpdated ( ) {
123143 this . compare . timestamp = Date . now ( ) ;
124144
You can’t perform that action at this time.
0 commit comments