11import type { CssDiffsType , SelectedElType } from '../types'
2+ import { useClipboard } from '@vueuse/core'
3+ import { ElMessage } from 'element-plus'
4+ import { useI18n } from 'vue-i18n'
25import { formatStyle , type FormatStyleValue } from '../utils'
36
47export function useDevToolsPanel ( ) {
8+ const { t } = useI18n ( )
9+
510 const selectedEl : Array < SelectedElType > = reactive ( [ ] )
611 const cssDiffs : Array < CssDiffsType > = reactive ( [ ] )
712
@@ -84,16 +89,45 @@ export function useDevToolsPanel() {
8489
8590 function onTableCellClassName ( { columnIndex } : { columnIndex : number } ) {
8691 if ( ! columnIndex ) {
87- return 'text-[var(--el-table-text-color)]'
92+ return 'text-[var(--el-table-text-color)] cursor-auto '
8893 }
8994 }
9095
9196 function onTableRowClassName ( { row } : { row : CssDiffsType } ) {
9297 if ( row . isDiff ) {
93- return '!bg-[#ffe6e6] text-[red]'
98+ return '!bg-[#ffe6e6] text-[red] cursor-pointer '
9499 }
95100 else {
96- return '!bg-[#e6ffe6] text-[green]'
101+ return '!bg-[#e6ffe6] text-[green] cursor-pointer'
102+ }
103+ }
104+
105+ function handleCopyStyle ( row : CssDiffsType , column : any ) {
106+ if ( column . property !== 'property' ) {
107+ const source = `${ row . property } : ${ row [ column . property as 'left' | 'right' ] } ;`
108+
109+ const { text, copied, copy } = useClipboard ( {
110+ read : true ,
111+ source,
112+ legacy : true ,
113+ } )
114+
115+ copy ( source )
116+
117+ watch (
118+ ( ) => copied . value ,
119+ ( copied ) => {
120+ if ( copied ) {
121+ ElMessage ( {
122+ message : `${ t ( 'copyInfo' ) } > ${ text . value } ` ,
123+ type : 'success' ,
124+ } )
125+ }
126+ } ,
127+ {
128+ immediate : true ,
129+ } ,
130+ )
97131 }
98132 }
99133
@@ -104,5 +138,6 @@ export function useDevToolsPanel() {
104138 handleClearSelection,
105139 onTableCellClassName,
106140 onTableRowClassName,
141+ handleCopyStyle,
107142 }
108143}
0 commit comments