File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
src/renderer/components/screenshot Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,8 @@ const props = defineProps<Props>()
131
131
132
132
const appStore = useAppStore ()
133
133
const snippetStore = useSnippetStore ()
134
- const { escape } = useMagicKeys ()
134
+ // eslint-disable-next-line camelcase
135
+ const { escape, Meta_C, Ctrl_C } = useMagicKeys ()
135
136
136
137
const frameRef = ref <HTMLElement >()
137
138
const snippetRef = ref <HTMLElement >()
@@ -250,6 +251,12 @@ const onSaveScreenshot = async (type: 'png' | 'svg' = 'png') => {
250
251
track (' snippets/create-screenshot' )
251
252
}
252
253
254
+ const copyToClipboard = async () => {
255
+ const data = await domToImage .toBlob (snippetRef .value ! )
256
+ navigator .clipboard .write ([new ClipboardItem ({ ' image/png' : data })])
257
+ track (' snippets/create-screenshot' )
258
+ }
259
+
253
260
watch (
254
261
() => appStore .screenshot .darkMode ,
255
262
v => {
@@ -269,10 +276,6 @@ watch(
269
276
{ deep: true }
270
277
)
271
278
272
- watch (escape , () => {
273
- snippetStore .isScreenshotPreview = false
274
- })
275
-
276
279
watch (
277
280
() => props .snippet ,
278
281
v => setValue (v )
@@ -282,6 +285,21 @@ watch(
282
285
v => setLang (v )
283
286
)
284
287
288
+ watch (escape , () => {
289
+ snippetStore .isScreenshotPreview = false
290
+ })
291
+
292
+ watch (Meta_C , v => {
293
+ if (v ) {
294
+ copyToClipboard ()
295
+ }
296
+ })
297
+ watch (Ctrl_C , v => {
298
+ if (v ) {
299
+ copyToClipboard ()
300
+ }
301
+ })
302
+
285
303
onMounted (() => {
286
304
init ()
287
305
})
You can’t perform that action at this time.
0 commit comments