-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMCInput.html
More file actions
73 lines (72 loc) · 1.81 KB
/
MCInput.html
File metadata and controls
73 lines (72 loc) · 1.81 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
<style>
:host {
display: inline-block;
color: #E0E0E0;
background-color: #222;
border: 2px #eee solid;
text-shadow: 0.13rem 0.13rem 0 #383838;
cursor: text;
width: 13ch;
}
:host([disabled]) {
cursor: default;
opacity: .8;
}
#wrapper {
position: relative;
}
#input {
overflow: auto hidden;
width: 100%;
min-height: 100%;
white-space: pre;
outline: none;
scrollbar-width: none;
display: inline-block;
caret-color: transparent;
}
#input::-webkit-scrollbar { display: none; }
#input:not(:empty) br, #input img {
display: none;
}
#input * {
display: inline;
white-space: pre;
}
#input:empty::before {
content: attr(placeholder);
display: inline-block;
white-space: nowrap;
pointer-events: none;
color: #777;
}
#input:focus-within:not(.has-select-text):empty::after,
#input:focus-within:not(.has-select-text):not(:empty)::before {
content: "_";
overflow: hidden;
width: 1ch;
display: inline-block;
position: absolute;
left: calc(1px * var(--caret-x, 0));
bottom: 0;
}
#input:focus-within:not(:empty)::after {
content: "x";
width: 1ch;
color: transparent;
text-shadow: none;
user-select: none;
display: inline-block;
}
#input.blink:focus-within:empty::after,
#input.blink:focus-within:not(:empty)::before {
animation: caret-blink 1s infinite steps(1);
}
@keyframes caret-blink {
50% { opacity: 0; }
}
</style>
<!-- https://stackoverflow.com/a/55950530/21559442 -->
<div id="wrapper">
<div id="input" contenteditable></div>
</div>