File tree 3 files changed +45
-19
lines changed
3 files changed +45
-19
lines changed Original file line number Diff line number Diff line change 1
1
/* eslint-disable react/no-danger */
2
- import { ipcRenderer } from 'electron' ;
2
+ import { clipboard , ipcRenderer } from 'electron' ;
3
3
import React , { useState } from 'react' ;
4
4
5
5
const HtmlPreview = ( ) => {
@@ -19,9 +19,16 @@ const HtmlPreview = () => {
19
19
setOpening ( false ) ;
20
20
} ;
21
21
22
+ const handleClipboard = ( ) => {
23
+ setHtml ( clipboard . readText ( ) ) ;
24
+ } ;
25
+
22
26
return (
23
27
< div className = "min-h-full flex flex-col" >
24
- < div className = "flex justify-start mb-1" >
28
+ < div className = "flex justify-start mb-1 space-x-2" >
29
+ < button type = "button" className = "btn" onClick = { handleClipboard } >
30
+ Clipboard
31
+ </ button >
25
32
< button
26
33
type = "button"
27
34
className = "btn"
Original file line number Diff line number Diff line change @@ -21,21 +21,30 @@ const Md2Html = () => {
21
21
setOpening ( false ) ;
22
22
} ;
23
23
24
+ const handleClipboard = ( ) => {
25
+ setMd ( clipboard . readText ( ) ) ;
26
+ } ;
27
+
24
28
const handleCopy = ( ) => {
25
29
clipboard . write ( { text : marked ( md ) } ) ;
26
30
} ;
27
31
28
32
return (
29
33
< div className = "min-h-full flex flex-col" >
30
34
< div className = "flex justify-between mb-1" >
31
- < button
32
- type = "button"
33
- className = "btn"
34
- onClick = { handleOpen }
35
- disabled = { opening }
36
- >
37
- Open...
38
- </ button >
35
+ < span className = "flex space-x-2" >
36
+ < button type = "button" className = "btn" onClick = { handleClipboard } >
37
+ Clipboard
38
+ </ button >
39
+ < button
40
+ type = "button"
41
+ className = "btn"
42
+ onClick = { handleOpen }
43
+ disabled = { opening }
44
+ >
45
+ Open...
46
+ </ button >
47
+ </ span >
39
48
< span className = "flex space-x-2" >
40
49
< button
41
50
type = "button"
Original file line number Diff line number Diff line change 1
- import { ipcRenderer } from 'electron' ;
1
+ import { clipboard , ipcRenderer } from 'electron' ;
2
2
import React , { useState } from 'react' ;
3
3
import { useDebouncedEffect } from '../../helpers/effectHooks' ;
4
4
@@ -40,17 +40,27 @@ const HtmlPreview = () => {
40
40
setSaving ( false ) ;
41
41
} ;
42
42
43
+ const handleClipboard = ( ) => {
44
+ setContent ( clipboard . readText ( ) ) ;
45
+ } ;
46
+
43
47
return (
44
48
< div className = "min-h-full flex flex-col" >
45
49
< div className = "flex justify-between mb-1" >
46
- < button
47
- type = "button"
48
- className = "btn"
49
- onClick = { handleOpen }
50
- disabled = { opening }
51
- >
52
- Open...
53
- </ button >
50
+ < span className = "flex space-x-2" >
51
+ < button type = "button" className = "btn" onClick = { handleClipboard } >
52
+ Clipboard
53
+ </ button >
54
+ < button
55
+ type = "button"
56
+ className = "btn"
57
+ onClick = { handleOpen }
58
+ disabled = { opening }
59
+ >
60
+ Open...
61
+ </ button >
62
+ </ span >
63
+
54
64
< button
55
65
type = "button"
56
66
className = "btn"
You can’t perform that action at this time.
0 commit comments