-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
73 lines (59 loc) · 2.67 KB
/
script.js
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
document.addEventListener("DOMContentLoaded", function () {
const boldButton = document.getElementById("bold");
const underlineButton = document.getElementById("underline");
const italicButton = document.getElementById("italic");
const strikethroughButton = document.getElementById("strikethrough");
const justifyRightButton = document.getElementById("justifyRight");
const justifyLeftButton = document.getElementById("justifyLeft");
const justifyCenterButton = document.getElementById("justifyCenter");
const justifyFullButton = document.getElementById("justifyFull");
const unorderedListButton = document.getElementById("unorderedList");
const increaseFontSizeButton = document.getElementById("increaseFontSize");
const decreaseFontSizeButton = document.getElementById("decreaseFontSize");
const copyButton = document.getElementById("copyBtn");
const resetButton = document.getElementById("resetBtn");
boldButton.addEventListener("click", function () {
document.execCommand("bold", false, null);
});
italicButton.addEventListener("click", function () {
document.execCommand("italic", false, null);
});
underlineButton.addEventListener("click", function () {
document.execCommand("underline", false, null);
});
strikethroughButton.addEventListener("click", function () {
document.execCommand("strikethrough", false, null);
});
justifyRightButton.addEventListener("click", function () {
document.execCommand("justifyRight", false, null);
});
justifyLeftButton.addEventListener("click", function () {
document.execCommand("justifyLeft", false, null);
});
justifyCenterButton.addEventListener("click", function () {
document.execCommand("justifyCenter", false, null);
});
justifyFullButton.addEventListener("click", function () {
document.execCommand("justifyFull", false, null);
});
unorderedListButton.addEventListener("click", function () {
document.execCommand("insertUnorderedList", false, null);
});
increaseFontSizeButton.addEventListener("click", function () {
const currentSize = parseInt(getComputedStyle(text).fontSize, 10);
text.style.fontSize = (currentSize + 1) + "px";
});
decreaseFontSizeButton.addEventListener("click", function () {
const currentSize = parseInt(getComputedStyle(text).fontSize, 10);
text.style.fontSize = (currentSize - 1) + "px";
});
copyButton.addEventListener("click", function () {
const allText = text.innerText;
if (allText) {
navigator.clipboard.writeText(allText);
}
});
resetButton.addEventListener("click", function () {
text.innerHTML = "";
});
});