-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtexteditor.html
More file actions
188 lines (163 loc) · 7.94 KB
/
texteditor.html
File metadata and controls
188 lines (163 loc) · 7.94 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<header class="text-center py-6">
<h1 class="font-bold text-2xl text-violet-500">TEXT EDITOR</h1>
</header>
<hr class="w-5/6 border-2 border-gray-500 rounded mb-4 mx-auto">
<nav class="flex justify-between px-36 mb-5">
<div class="bg-violet-200 px-2 pb-1 pt-2 border rounded-md border-violet-400">
<button type="button" onclick="makeNormal()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3>N</h3>
</button>
<button type="button" onclick="makeBold()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-bold"></i></h3>
</button>
<button type="button" onclick="makeItalic()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-italic"></i></h3>
</button>
</div>
<div class="bg-violet-200 px-2 pb-1 pt-2 border rounded-md border-violet-400">
<button type="button" onclick="makeLeft()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-align-left"></i></h3>
</button>
<button type="button" onclick="makeCenter()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-align-center"></i></h3>
</button>
<button type="button" onclick="makeRight()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-align-right"></i></h3>
</button>
</div>
<div class="bg-violet-200 px-2 pb-1 pt-2 border rounded-md border-violet-400">
<button type="button" onclick="makeUnderline()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3><i class="fa fa-underline"></i></h3>
</button>
<button type="button" onclick="makeNoUnderline()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 font-bold duration-300 hover:-translate-y-1">
<h3>U</h3>
</button>
</div>
<div class="bg-violet-200 px-2 pb-1 pt-2 border rounded-md border-violet-400">
<button type="button" onclick="makeUpper()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3>ABC</h3>
</button>
<button type="button" onclick="makeLower()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3>abc</h3>
</button>
<button type="button" onclick="makeCapital()"
class="border hover:border-gray-500 border-violet-300 rounded-md px-5 py-1 bg-gray-100 duration-300 hover:-translate-y-1">
<h3>Abc</h3>
</button>
</div>
<button id="clr" type="button" onclick="makeclear()"
class="border border-red-800 rounded-md px-5 py-1 bg-red-200 border-2 border-red-800">
<h3>CLEAR</h3>
</button>
<button type="button" onclick="dark()"
class="border-2 hover:border-gray-500 border-gray-500 rounded-md px-2 py-1 bg-gray-300 duration-300 hover:-translate-y-1">
<h3>MODE</h3>
</button>
</nav>
<div class="px-44 mb-5">
<textarea id="TA" rows="12" placeholder="Write something...."
class="border-4 rounded-md border-violet-500 w-full h-full p-4"></textarea>
<div class="flex justify-center">
<input type="text" class="w-full px-1 border-2 border-gray-500 rounded mr-5" id="fileName"
placeholder="Enter File Name" />
<button id="saveBtn" type="submit" onclick="makeSave()"
class="border-2 border-blue-800 rounded-md px-5 py-1 bg-blue-200">
<h3>Download</h3>
</button>
</div>
</div>
<script>
function makeNormal() {
document.getElementById("TA").style.fontWeight = "normal";
}
function makeBold() {
document.getElementById("TA").style.fontWeight = "bold";
}
function makeItalic() {
document.getElementById("TA").style.fontStyle = "italic";
}
function makeLeft() {
document.getElementById("TA").style.textAlign = "left";
}
function makeCenter() {
document.getElementById("TA").style.textAlign = "center";
}
function makeRight() {
document.getElementById("TA").style.textAlign = "right";
}
function makeLower() {
document.getElementById("TA").style.textTransform = "lowercase";
}
function makeUpper() {
document.getElementById("TA").style.textTransform = "uppercase";
}
function makeCapital() {
document.getElementById("TA").style.textTransform = "capitalize";
}
function makeUnderline() {
document.getElementById("TA").style.textDecoration = "underline";
}
function makeNoUnderline() {
document.getElementById("TA").style.textDecoration = "none";
}
function makeclear() {
document.getElementById("TA").value = " ";
}
let textEle = document.getElementById("TA");
let fileNameEle = document.getElementById("fileName");
let saveBtn = document.getElementById("saveBtn");
saveBtn.addEventListener("click", (e) => {
e.preventDefault();
const textData = textEle.value;
const textDataBlob = new Blob([textEle.value], { type: "text/plain" });
const downloadUrl = window.URL.createObjectURL(textDataBlob)
const downloadLink = document.createElement('a');
downloadLink.download = fileNameEle.value
downloadLink.href = downloadUrl;
downloadLink.click()
console.log(textData);
console.log(textDataBlob);
});
document.getElementById("clr").onmouseover = function () {
document.getElementById("clr").innerHTML = "SURE?";
};
document.getElementById("clr").onmouseout = function () {
document.getElementById("clr").innerHTML = "CLEAR";
}
document.getElementById("saveBtn").onmouseover = function () {
document.getElementById("saveBtn").innerHTML = '<i class="fa fa-download"></i>';
};
document.getElementById("saveBtn").onmouseout = function () {
document.getElementById("saveBtn").innerHTML = "Download";
}
function dark() {
document.body.classList.toggle("dark-mode");
}
</script>
<style>
.dark-mode {
background-color: #222;
}
</style>
</body>
</html>