-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext-editor-localstorage.html
More file actions
100 lines (98 loc) · 2.71 KB
/
text-editor-localstorage.html
File metadata and controls
100 lines (98 loc) · 2.71 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<html>
<title>Text Editor</title>
<style>
*:focus, *:focus-visible {
outline: none;
}
*::placeholder { color: rgba(255, 255, 255, 0.6); }
* { color: rgba(255, 255, 255, 0.6);}
html, body {
height: 100%;
min-height: 100%;
width: 100%;
min-width: 100%;
margin: 0;
padding: 0;
}
body {
display: flex;
flex-direction: row;
justify-content: center;
background: #121212;
font-family: 'Roboto', monospace;
font-style: normal;
font-weight: 500;
font-size: 1rem;
line-height: 24px;
letter-spacing: 0.15px;
color: rgba(255, 255, 255, 0.6);
}
input, textarea {
background: none;
}
input:focus, textarea:focus, input:focus-within, textarea:focus-within, input:focus-visible {
border-color: #6200ee !important;
}
textarea {
resize: none;
}
#wrap {
height: 100%;
min-height: 100%;
width: 50vw;
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
}
#title {
margin: 1rem 0;
padding: 16px 16px 12px 16px;
border: solid 1px rgba(255, 255, 255, 0.12);
border-radius: 4px;
}
#content {
height: 100%;
margin-bottom: 1rem;
padding: 16px 16px 12px 16px;
border: solid 1px rgba(255, 255, 255, 0.12);
border-radius: 4px;
}
@media print {
body {
padding: 0rem;
}
}
</style>
<link rel="stylesheet" href="https://unpkg.com/normalize.css@8.0.1/normalize.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/normalize.css@8.0.1/normalize.css">
<body>
<div id="wrap">
<input type="text" id="title" placeholder="Title..."></input>
<textarea placeholder="Enter content here..." id="content"></textarea>
</div>
<script type="text/javascript">
let title = localStorage.getItem('title') || '';
let content = localStorage.getItem('content') || '';
document.getElementById("title").addEventListener(
"input",
function () {
let title = document.getElementById("title").value;
document.title = title;
localStorage.setItem('title', title)
},
false
);
document.getElementById("content").addEventListener(
"input",
function () {
localStorage.setItem('content', document.getElementById("content").value)
},
false
);
</script>
</body>
</html>