@uiw/copy-to-clipboard 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +13 -2
- package/dist/CONTRIBUTORS.svg +12 -0
- package/dist/badges.svg +20 -0
- package/dist/copy-to-clipboard.cjs.js +2 -1
- package/dist/copy-to-clipboard.esm.js +2 -1
- package/dist/copy-to-clipboard.umd.js +2 -1
- package/dist/copy-to-clipboard.umd.js.map +1 -1
- package/dist/copy-to-clipboard.umd.min.js +2 -2
- package/dist/copy-to-clipboard.umd.min.js.map +1 -1
- package/dist/css/copy.css +49 -0
- package/dist/css/demo-preview.css +62 -0
- package/dist/css/main.css +258 -0
- package/dist/css/media.css +52 -0
- package/dist/css/sidebar.css +41 -0
- package/dist/css/tocbot.css +52 -0
- package/dist/index.html +88 -177
- package/dist/js/copy.js +40 -0
- package/dist/js/dark-mode.js +162 -0
- package/dist/js/demo-preview.js +31 -0
- package/dist/js/markdown-style.js +1006 -0
- package/dist/js/tocbot.js +128 -0
- package/dist/lcov-report/base.css +224 -0
- package/dist/lcov-report/block-navigation.js +87 -0
- package/dist/lcov-report/favicon.png +0 -0
- package/dist/lcov-report/index.html +116 -0
- package/dist/lcov-report/main.js.html +238 -0
- package/dist/lcov-report/prettify.css +1 -0
- package/dist/lcov-report/prettify.js +2 -0
- package/dist/lcov-report/sort-arrow-sprite.png +0 -0
- package/dist/lcov-report/sorter.js +196 -0
- package/dist/sitemap.txt +1 -0
- package/package.json +3 -15
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @package @wcj/dark-mode@1.0.14
|
|
3
|
+
* Web Component that toggles dark mode 🌒
|
|
4
|
+
* Github: https://github.com/jaywcjlove/dark-mode.git
|
|
5
|
+
* Website: https://jaywcjlove.github.io/dark-mode
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT license.
|
|
8
|
+
* @license Copyright © 2022. Licensed under the MIT License
|
|
9
|
+
* @author kenny wong <wowohoo@qq.com>
|
|
10
|
+
*/
|
|
11
|
+
const t = document;
|
|
12
|
+
const e = '_dark_mode_theme_';
|
|
13
|
+
const s = 'permanent';
|
|
14
|
+
const o = 'colorschemechange';
|
|
15
|
+
const i = 'permanentcolorscheme';
|
|
16
|
+
const h = 'light';
|
|
17
|
+
const r = 'dark';
|
|
18
|
+
const n = (t, e, s = e) => {
|
|
19
|
+
Object.defineProperty(t, s, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get() {
|
|
22
|
+
const t = this.getAttribute(e);
|
|
23
|
+
return t === null ? '' : t;
|
|
24
|
+
},
|
|
25
|
+
set(t) {
|
|
26
|
+
this.setAttribute(e, t);
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const c = (t, e, s = e) => {
|
|
31
|
+
Object.defineProperty(t, s, {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get() {
|
|
34
|
+
return this.hasAttribute(e);
|
|
35
|
+
},
|
|
36
|
+
set(t) {
|
|
37
|
+
if (t) {
|
|
38
|
+
this.setAttribute(e, '');
|
|
39
|
+
} else {
|
|
40
|
+
this.removeAttribute(e);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
class a extends HTMLElement {
|
|
46
|
+
static get observedAttributes() {
|
|
47
|
+
return ['mode', h, r, s];
|
|
48
|
+
}
|
|
49
|
+
LOCAL_NANE = e;
|
|
50
|
+
constructor() {
|
|
51
|
+
super();
|
|
52
|
+
this.t();
|
|
53
|
+
}
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
n(this, 'mode');
|
|
56
|
+
n(this, r);
|
|
57
|
+
n(this, h);
|
|
58
|
+
c(this, s);
|
|
59
|
+
const a = localStorage.getItem(e);
|
|
60
|
+
if (a && [h, r].includes(a)) {
|
|
61
|
+
this.mode = a;
|
|
62
|
+
this.permanent = true;
|
|
63
|
+
}
|
|
64
|
+
if (this.permanent && !a) {
|
|
65
|
+
localStorage.setItem(e, this.mode);
|
|
66
|
+
}
|
|
67
|
+
const l = [h, r].includes(a);
|
|
68
|
+
if (this.permanent && a) {
|
|
69
|
+
this.o();
|
|
70
|
+
} else {
|
|
71
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
72
|
+
this.mode = r;
|
|
73
|
+
this.o();
|
|
74
|
+
}
|
|
75
|
+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
|
|
76
|
+
this.mode = h;
|
|
77
|
+
this.o();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!this.permanent && !l) {
|
|
81
|
+
window.matchMedia('(prefers-color-scheme: light)').onchange = (t) => {
|
|
82
|
+
this.mode = t.matches ? h : r;
|
|
83
|
+
this.o();
|
|
84
|
+
};
|
|
85
|
+
window.matchMedia('(prefers-color-scheme: dark)').onchange = (t) => {
|
|
86
|
+
this.mode = t.matches ? r : h;
|
|
87
|
+
this.o();
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
const d = new MutationObserver((s, h) => {
|
|
91
|
+
this.mode = t.documentElement.dataset.colorMode;
|
|
92
|
+
if (this.permanent && l) {
|
|
93
|
+
localStorage.setItem(e, this.mode);
|
|
94
|
+
this.i(i, { permanent: this.permanent });
|
|
95
|
+
}
|
|
96
|
+
this.h();
|
|
97
|
+
this.i(o, { colorScheme: this.mode });
|
|
98
|
+
});
|
|
99
|
+
d.observe(t.documentElement, { attributes: true });
|
|
100
|
+
this.i(o, { colorScheme: this.mode });
|
|
101
|
+
this.h();
|
|
102
|
+
}
|
|
103
|
+
attributeChangedCallback(t, s, o) {
|
|
104
|
+
if (t === 'mode' && s !== o && [h, r].includes(o)) {
|
|
105
|
+
const t = localStorage.getItem(e);
|
|
106
|
+
if (this.mode === t) {
|
|
107
|
+
this.mode = o;
|
|
108
|
+
this.h();
|
|
109
|
+
this.o();
|
|
110
|
+
} else if (this.mode && this.mode !== t) {
|
|
111
|
+
this.h();
|
|
112
|
+
this.o();
|
|
113
|
+
}
|
|
114
|
+
} else if ((t === h || t === r) && s !== o) {
|
|
115
|
+
this.h();
|
|
116
|
+
}
|
|
117
|
+
if (t === 'permanent' && typeof this.permanent === 'boolean') {
|
|
118
|
+
this.permanent ? localStorage.setItem(e, this.mode) : localStorage.removeItem(e);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
o() {
|
|
122
|
+
t.documentElement.setAttribute('data-color-mode', this.mode);
|
|
123
|
+
}
|
|
124
|
+
h() {
|
|
125
|
+
this.icon.textContent = this.mode === h ? '🌒' : '🌞';
|
|
126
|
+
this.text.textContent = this.mode === h ? this.getAttribute(r) : this.getAttribute(h);
|
|
127
|
+
}
|
|
128
|
+
t() {
|
|
129
|
+
var s = this.attachShadow({ mode: 'open' });
|
|
130
|
+
this.label = t.createElement('span');
|
|
131
|
+
this.label.setAttribute('class', 'wrapper');
|
|
132
|
+
this.label.onclick = () => {
|
|
133
|
+
this.mode = this.mode === h ? r : h;
|
|
134
|
+
if (this.permanent) {
|
|
135
|
+
localStorage.setItem(e, this.mode);
|
|
136
|
+
}
|
|
137
|
+
this.o();
|
|
138
|
+
this.h();
|
|
139
|
+
};
|
|
140
|
+
s.appendChild(this.label);
|
|
141
|
+
this.icon = t.createElement('span');
|
|
142
|
+
this.label.appendChild(this.icon);
|
|
143
|
+
this.text = t.createElement('span');
|
|
144
|
+
this.label.appendChild(this.text);
|
|
145
|
+
const o = `\n[data-color-mode*='dark'], [data-color-mode*='dark'] body {\n color-scheme: dark;\n --color-theme-bg: #0d1117;\n --color-theme-text: #c9d1d9;\n background-color: var(--color-theme-bg);\n color: var(--color-theme-text);\n}\n\n[data-color-mode*='light'], [data-color-mode*='light'] body {\n color-scheme: light;\n --color-theme-bg: #fff;\n --color-theme-text: #24292f;\n background-color: var(--color-theme-bg);\n color: var(--color-theme-text);\n}`;
|
|
146
|
+
const i = '_dark_mode_style_';
|
|
147
|
+
const n = t.getElementById(i);
|
|
148
|
+
if (!n) {
|
|
149
|
+
var c = t.createElement('style');
|
|
150
|
+
c.id = i;
|
|
151
|
+
c.textContent = o;
|
|
152
|
+
t.head.appendChild(c);
|
|
153
|
+
}
|
|
154
|
+
var a = t.createElement('style');
|
|
155
|
+
a.textContent = `\n .wrapper { cursor: pointer; user-select: none; position: relative; }\n .wrapper > span + span { margin-left: .4rem; }\n `;
|
|
156
|
+
s.appendChild(a);
|
|
157
|
+
}
|
|
158
|
+
i(t, e) {
|
|
159
|
+
this.dispatchEvent(new CustomEvent(t, { bubbles: true, composed: true, detail: e }));
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
customElements.define('dark-mode', a);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const demo = document.querySelectorAll('.idoc-demo-warpper .idoc-demo-previw');
|
|
2
|
+
|
|
3
|
+
function getButton(elm, type = 'BUTTON') {
|
|
4
|
+
let btn;
|
|
5
|
+
do {
|
|
6
|
+
elm = elm.nextElementSibling
|
|
7
|
+
if (elm.tagName === type) {
|
|
8
|
+
btn = elm;
|
|
9
|
+
elm = undefined;
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
} while (elm);
|
|
13
|
+
return btn;
|
|
14
|
+
}
|
|
15
|
+
if (demo && demo.length > 0) {
|
|
16
|
+
demo.forEach((item) => {
|
|
17
|
+
if (item.previousElementSibling && item.previousElementSibling.tagName === 'INPUT') {
|
|
18
|
+
const button = getButton(item);
|
|
19
|
+
if (button) {
|
|
20
|
+
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
|
|
21
|
+
if (item.tagName === 'DIV') {
|
|
22
|
+
item.innerHTML = item.previousElementSibling.defaultValue
|
|
23
|
+
}
|
|
24
|
+
button.onclick = () => {
|
|
25
|
+
item.classList.toggle('ishiden');
|
|
26
|
+
button.innerHTML = item.classList.contains('ishiden') ? 'Preview' : 'Show Code';
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|