-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
43 lines (41 loc) · 1.09 KB
/
Copy pathindex.html
File metadata and controls
43 lines (41 loc) · 1.09 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<style>
#textbox {
background-color: #d3d3d3;
padding: 24px;
border-radius: 8px;
font-family: sans-serif;
font-size: 1.5rem;
color: #222222;
}
</style>
<body>
<div id="textbox" contenteditable="true"></div>
<script type="module">
import ReplaceKeywords from '/src/index.ts';
const element = document.querySelector('#textbox');
const cfg = {
transformations: [
{
query: 'car',
value: 'carpet',
},
{
query:
/(?:https?:\/\/)(?:[\w-])+\.{1}([a-zA-Z]{2,63})(?:[/\w-]*)*\/?\??(?:[^#\n\r]*)?#?(?:[^\n\r]*)/,
value: (word, query, matches) =>
`<span>${word}, ${query}, ${matches.join(', ')}`,
},
],
};
const rk = new ReplaceKeywords(element, cfg);
console.log(rk.transformations);
</script>
</body>
</html>