-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreview.php
64 lines (52 loc) · 2 KB
/
preview.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
$draftLocation = './data/drafts/default.json';
$content = '';
if (file_exists($draftLocation)) {
$jsonData = file_get_contents($draftLocation);
$content = $jsonData;
}else{
echo 'Conteúdo não encontrado...';
exit(0);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Preview - Minimal Editor.JS</title>
<link href="https://fonts.googleapis.com/css?family=PT+Mono" rel="stylesheet">
<link href="./public/assets/css/bootstrap.min.css" rel="stylesheet">
<script src="./public/assets/json-preview.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
<div class="" style="width:100%; height:52px;">
<nav class="navbar navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">
<img src="./public/assets/logo-editor-js.svg" alt="" width="30" height="24"
class="d-inline-block align-text-top">
<span>Minimal Editor.JS (Preview)
</a>
<div class="d-flex">
<button style="margin-right:20px;" class="btn btn-primary" id="copyToClipboard">Copy to Clipboard</button>
</div>
</div>
</nav>
</div>
<div class="content-draft" style="width:100%; height: calc(100vh - 52px); overflow:auto; padding:20px;; font-size:16px;"><?php echo htmlspecialchars($content); ?></div>
</body>
<script>
document.getElementById('copyToClipboard').addEventListener('click', function() {
const contentDiv = document.querySelector('.content-draft');
const textToCopy = contentDiv.textContent || contentDiv.innerText;
const textarea = document.createElement('textarea');
textarea.value = textToCopy;
document.body.appendChild(textarea);
textarea.select();
document.execCommand('copy');
document.body.removeChild(textarea);
alert('Content copied to clipboard!');
});
</script>
</html>