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>()
131131
132132const appStore = useAppStore ()
133133const snippetStore = useSnippetStore ()
134- const { escape } = useMagicKeys ()
134+ // eslint-disable-next-line camelcase
135+ const { escape, Meta_C, Ctrl_C } = useMagicKeys ()
135136
136137const frameRef = ref <HTMLElement >()
137138const snippetRef = ref <HTMLElement >()
@@ -250,6 +251,12 @@ const onSaveScreenshot = async (type: 'png' | 'svg' = 'png') => {
250251 track (' snippets/create-screenshot' )
251252}
252253
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+
253260watch (
254261 () => appStore .screenshot .darkMode ,
255262 v => {
@@ -269,10 +276,6 @@ watch(
269276 { deep: true }
270277)
271278
272- watch (escape , () => {
273- snippetStore .isScreenshotPreview = false
274- })
275-
276279watch (
277280 () => props .snippet ,
278281 v => setValue (v )
@@ -282,6 +285,21 @@ watch(
282285 v => setLang (v )
283286)
284287
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+
285303onMounted (() => {
286304 init ()
287305})
You can’t perform that action at this time.
0 commit comments