-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
52 lines (51 loc) · 2.19 KB
/
index.html
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
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>测试页面</title>
<script defer src="./krich-es.js" type="module"></script>
<link rel="stylesheet" href="./krich-demo.css">
<link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/prism/1.27.0/themes/prism.min.css">
<script defer src="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/prism/1.27.0/components/prism-core.min.js" data-manual></script>
<script defer src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/prism/1.27.0/plugins/autoloader/prism-autoloader.min.js"></script>
<script defer src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/crypto-js/4.1.1/crypto-js.min.js"></script>
<script type="module">
import KRich from './krich-es.js'
document.addEventListener('DOMContentLoaded', () => {
const krich = KRich('#krich')
krich.setHighlight(pre => new Promise(resolve => {
let language = pre.className
language = language.substring(language.indexOf('-') + 1) || 'txt'
const run = () => {
pre.firstChild.innerHTML = Prism.highlight(pre.textContent, Prism.languages[language], language)
resolve()
}
if (language in Prism.languages) {
run()
} else {
Prism.plugins.autoloader.loadLanguages(language, run, err => {
console.error(err)
resolve()
})
}
}), () => [
['PlainText', 'txt'],
['JavaScript', 'js']
])
krich.setImgMapper(data => CryptoJS.MD5(data).toString())
krich.setImgStatusChecker(response => !response.url.includes('403'))
const show = document.querySelector('#show')
setInterval(async () => {
const value = await krich.exportData()
value.html = value.html.innerHTML
show.innerText = JSON.stringify(value, null, 4)
}, 1000)
})
</script>
</head>
<body>
<div id="krich">
</div>
<div id="show"></div>
</body>
</html>