Skip to content

Commit befd0a0

Browse files
committed
Clipboard
1 parent a6878c2 commit befd0a0

File tree

3 files changed

+45
-19
lines changed

3 files changed

+45
-19
lines changed

src/components/html-preview/HtmlPreview.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable react/no-danger */
2-
import { ipcRenderer } from 'electron';
2+
import { clipboard, ipcRenderer } from 'electron';
33
import React, { useState } from 'react';
44

55
const HtmlPreview = () => {
@@ -19,9 +19,16 @@ const HtmlPreview = () => {
1919
setOpening(false);
2020
};
2121

22+
const handleClipboard = () => {
23+
setHtml(clipboard.readText());
24+
};
25+
2226
return (
2327
<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>
2532
<button
2633
type="button"
2734
className="btn"

src/components/md-to-html/MarkdownToHtml.tsx

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,30 @@ const Md2Html = () => {
2121
setOpening(false);
2222
};
2323

24+
const handleClipboard = () => {
25+
setMd(clipboard.readText());
26+
};
27+
2428
const handleCopy = () => {
2529
clipboard.write({ text: marked(md) });
2630
};
2731

2832
return (
2933
<div className="min-h-full flex flex-col">
3034
<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>
3948
<span className="flex space-x-2">
4049
<button
4150
type="button"

src/components/qrcode/QrCode.tsx

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ipcRenderer } from 'electron';
1+
import { clipboard, ipcRenderer } from 'electron';
22
import React, { useState } from 'react';
33
import { useDebouncedEffect } from '../../helpers/effectHooks';
44

@@ -40,17 +40,27 @@ const HtmlPreview = () => {
4040
setSaving(false);
4141
};
4242

43+
const handleClipboard = () => {
44+
setContent(clipboard.readText());
45+
};
46+
4347
return (
4448
<div className="min-h-full flex flex-col">
4549
<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+
5464
<button
5565
type="button"
5666
className="btn"

0 commit comments

Comments
 (0)