-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
131 lines (117 loc) · 3.85 KB
/
index.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
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
var editor = new EditorJS({
placeholder: `Start Writing or [TAB] to see options...`,
readOnly: false,
holder: 'editorjs',
onReady: () => {
new DragDrop(editor);
},
tools: {
math: MathTool,
header: {
class: Header,
config: {
placeholder: 'Header'
},
shortcut: 'CMD+SHIFT+H'
},
image: SimpleImage,
warning: Warning,
alert: {
class: Alert,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+A',
config: {
defaultType: 'primary',
messagePlaceholder: 'Write an alert...',
},
},
list: {
class: NestedList,
inlineToolbar: true,
shortcut: 'CMD+SHIFT+L',
config: {
defaultStyle: 'ordered'
},
},
checklist: {
class: Checklist,
inlineToolbar: true,
},
underline: Underline,
Marker: Marker,
callout: CalloutTool,
delimiter: Delimiter,
inlineCode: {
class: InlineCode,
shortcut: 'CMD+SHIFT+C'
},
embed: {
class: Embed,
inlineToolbar: true,
},
table: {
class: Table,
inlineToolbar: true,
shortcut: 'CMD+ALT+T'
},
},
});
cat = document.getElementById("cat")
catContainer = document.getElementById("catContainer")
catClear = document.getElementById("clearCat")
catClear.addEventListener('click', function () {
catContainer.innerHTML = ""
});
cat.addEventListener('keypress', function (e) {
if (e.key === "Enter") {
if (cat.value != "") {
catContainer.innerHTML = catContainer.innerHTML + `<div class="card m-1 p-1 rounded-2" style="display: inline-block;">` + "#" + cat.value.trim() + `</div>`
cat.value = ""
}
}
});
imageURL = document.getElementById("imageURL");
imageHandler = document.getElementById("imageHandler");
imageURL.addEventListener("input", function () {
if (imageURL != "") {
imageHandler.setAttribute('src', imageURL.value)
}
})
fontStyleSansSerif = document.getElementById("sans-serif")
fontStyleSansSerif.addEventListener("input", function () {
if (fontStyleSansSerif.checked) {
document.getElementById("content").setAttribute("style", "font-family:'Segoe UI Variable Display', sans-serif")
}
})
fontStyleSerif = document.getElementById("serif")
fontStyleSerif.addEventListener("input", function () {
if (fontStyleSerif.checked) {
document.getElementById("content").setAttribute("style", "font-family:serif")
}
})
fontStyleMonospace = document.getElementById("monospace")
fontStyleMonospace.addEventListener("input", function () {
if (fontStyleMonospace.checked) {
document.getElementById("content").setAttribute("style", "font-family:monospace")
}
})
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.setAttribute("data-bs-theme", "dark")
themeToggle.checked = true
}
themeToggle = document.getElementById("themeToggle")
themeToggle.addEventListener('input', function () {
if (themeToggle.checked) {
document.body.setAttribute("data-bs-theme", "dark")
} else {
document.body.setAttribute("data-bs-theme", "light")
}
})
document.getElementById("printBtn").addEventListener('click', ()=>{
document.body.setAttribute("data-bs-theme", "light")
window.print();
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.setAttribute("data-bs-theme", "dark")
themeToggle.checked = true
}
})