lightview 1.7.2-b → 1.8.2
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/README.md +15 -16
- package/docs/CNAME +1 -0
- package/docs/api.html +674 -0
- package/docs/blank.html +10 -0
- package/docs/comparedto.html +89 -0
- package/docs/components/chart-repl.html +69 -0
- package/docs/components/chart.html +17 -0
- package/{components → docs/components}/components.js +31 -11
- package/docs/components/contents.html +17 -0
- package/docs/components/gantt-repl.html +61 -0
- package/docs/components/gantt.html +42 -0
- package/docs/components/gauge-repl.html +66 -0
- package/docs/components/gauge.html +20 -0
- package/docs/components/orgchart-repl.html +64 -0
- package/docs/components/orgchart.html +41 -0
- package/docs/components/repl-as-src.html +17 -0
- package/docs/components/repl-repl.html +95 -0
- package/docs/components/repl.html +527 -0
- package/docs/components/timeline-repl.html +72 -0
- package/docs/components/timeline.html +44 -0
- package/docs/components.html +14 -0
- package/docs/css/highlightjs.min.css +9 -0
- package/docs/css/tutorial.css +35 -0
- package/docs/examples/anchor.html +11 -0
- package/{components/chart/example.html → docs/examples/chart.html} +6 -4
- package/docs/examples/counter.html +26 -0
- package/{examples → docs/examples}/counter.test.mjs +0 -0
- package/docs/examples/counter2.html +26 -0
- package/{examples → docs/examples}/directives.html +20 -18
- package/{examples → docs/examples}/foreign.html +1 -1
- package/docs/examples/forgeinform.html +98 -0
- package/docs/examples/form.html +61 -0
- package/{examples → docs/examples}/gauge.html +4 -2
- package/{examples → docs/examples}/invalid-template-literals.html +6 -4
- package/{examples → docs/examples}/medium/remote.html +1 -1
- package/docs/examples/message.html +18 -0
- package/{examples → docs/examples}/nested.html +2 -2
- package/docs/examples/object-bound-form.html +34 -0
- package/{examples → docs/examples}/remote-server.js +0 -0
- package/docs/examples/remote.html +34 -0
- package/{examples → docs/examples}/remote.json +0 -0
- package/{examples → docs/examples}/scratch.html +1 -1
- package/docs/examples/sensors/index.html +44 -0
- package/{examples → docs/examples}/sensors/sensor-server.js +0 -0
- package/docs/examples/shared.html +41 -0
- package/{examples → docs/examples}/template.html +1 -1
- package/{examples → docs/examples}/timeline.html +2 -2
- package/docs/examples/todo.html +40 -0
- package/docs/examples/top.html +10 -0
- package/{examples → docs/examples}/types.html +1 -1
- package/{examples → docs/examples}/xor.html +22 -20
- package/docs/examples.html +25 -0
- package/docs/index.html +44 -0
- package/docs/javascript/codejar.min.js +8 -0
- package/docs/javascript/highlightjs.min.js +1173 -0
- package/docs/javascript/isomorphic-git.js +9 -0
- package/docs/javascript/json5.min.js +1 -0
- package/docs/javascript/lightning-fs.js +1 -0
- package/docs/javascript/lightview.js +1285 -0
- package/docs/javascript/marked.min.js +6 -0
- package/docs/javascript/peerjs.min.js +70 -0
- package/docs/javascript/turndown.js +973 -0
- package/docs/javascript/types.js +606 -0
- package/docs/javascript/utils.js +45 -0
- package/docs/lightview.html +63 -0
- package/docs/old_index.html +965 -0
- package/docs/old_index.md +1132 -0
- package/docs/slidein.html +51 -0
- package/docs/tutorial/0-getting-started.html +67 -0
- package/docs/tutorial/1-intro-to-variables.html +103 -0
- package/docs/tutorial/10-template-components.html +80 -0
- package/docs/tutorial/11-linked-components.html +76 -0
- package/docs/tutorial/12-imported-components.html +67 -0
- package/docs/tutorial/13-input-binding.html +94 -0
- package/docs/tutorial/14-automatic-variable-creation.html +74 -0
- package/docs/tutorial/15-form-binding.html +110 -0
- package/docs/tutorial/16-if-directive.html +60 -0
- package/docs/tutorial/17-loop-directives.html +83 -0
- package/docs/tutorial/18-sanitizing-and-escaping-input.html +79 -0
- package/docs/tutorial/2-imported-and-exported-variables.html +80 -0
- package/docs/tutorial/3-data-types.html +89 -0
- package/docs/tutorial/4-extended-data-types.html +83 -0
- package/docs/tutorial/5-extended-functional-types.html +96 -0
- package/docs/tutorial/5.1-extended-functional-types.html +79 -0
- package/docs/tutorial/5.2-extended-functional-types.html +70 -0
- package/docs/tutorial/6-conventional-javascript.html +75 -0
- package/docs/tutorial/7-monitoring-with-observers.html +107 -0
- package/docs/tutorial/8-event-listeners.html +65 -0
- package/docs/tutorial/9-intro-to-components.html +91 -0
- package/docs/tutorial/contents.html +32 -0
- package/docs/tutorial/my-component.html +29 -0
- package/docs/tutorial/remote-value.json +4 -0
- package/docs/websiterepl.html +46 -0
- package/lightview.js +499 -363
- package/lightview.min.js +1 -0
- package/lightview_good.js +1267 -0
- package/lightview_optimized.js +1274 -0
- package/package.json +7 -2
- package/repl_hold.html +320 -0
- package/test/basic.html +29 -17
- package/test/basic.test.mjs +1 -11
- package/test/extended.html +16 -19
- package/types.js +118 -36
- package/unsplash.key +1 -0
- package/components/chart/chart.html +0 -15
- package/components/chart.html +0 -81
- package/components/gantt/example.html +0 -27
- package/components/gantt/gantt.html +0 -34
- package/components/gauge/example.html +0 -28
- package/components/gauge/guage.html +0 -19
- package/components/gauge.html +0 -57
- package/components/timeline.html +0 -81
- package/examples/chart.html +0 -66
- package/examples/counter.html +0 -24
- package/examples/forgeinform.html +0 -96
- package/examples/form.html +0 -59
- package/examples/message.html +0 -12
- package/examples/object-bound-form.html +0 -32
- package/examples/remote.html +0 -32
- package/examples/sensors/index.html +0 -30
- package/examples/todo.html +0 -38
- package/examples/top.html +0 -10
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<head>
|
|
3
|
+
<title>Lightview:Sensor Demo</title>
|
|
4
|
+
<link href="../../components/gauge-repl.html" rel="module">
|
|
5
|
+
<script src="../../../lightview.js?as=x-body"></script>
|
|
6
|
+
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
7
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div style="width:100%;text-align:center">
|
|
11
|
+
<div style="display:inline-block">
|
|
12
|
+
<l-gauge id="sensor1" type="Gauge" label="Sensor One" value="50"></l-gauge>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div style="display:inline-block">
|
|
16
|
+
<l-gauge id="sensor2" type="Gauge" label="Sensor Two" value="50"></l-gauge>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
<script id="lightview">
|
|
21
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
22
|
+
const {remote} = await import("../../../types.js");
|
|
23
|
+
self.variables({sensor1: "number"}, {
|
|
24
|
+
remote: remote({
|
|
25
|
+
ttl: 5000,
|
|
26
|
+
path: "https://lightview.dev/sensors/sensor1"
|
|
27
|
+
})
|
|
28
|
+
});
|
|
29
|
+
self.variables({sensor2: "number"}, {
|
|
30
|
+
remote: remote({
|
|
31
|
+
ttl: 7500,
|
|
32
|
+
path: "https://lightview.dev/sensors/sensor2"
|
|
33
|
+
})
|
|
34
|
+
});
|
|
35
|
+
await sensor1;
|
|
36
|
+
await sensor2;
|
|
37
|
+
addEventListener("change", ({variableName, value}) => {
|
|
38
|
+
const sensor = document.body.getElementById(variableName);
|
|
39
|
+
sensor.setValue(value);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Form</title>
|
|
6
|
+
<template id="myform">
|
|
7
|
+
${formname}: <form>
|
|
8
|
+
<input type="text" value="${name}">
|
|
9
|
+
</form>
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
self.variables({
|
|
13
|
+
name: "string"
|
|
14
|
+
}, {
|
|
15
|
+
shared,
|
|
16
|
+
reactive
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
self.variables({
|
|
20
|
+
formname: "string"
|
|
21
|
+
}, {
|
|
22
|
+
imported
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
</template>
|
|
27
|
+
<script src="https://000686818.codepen.website/lightview.js"></script>
|
|
28
|
+
<script>
|
|
29
|
+
Lightview.createComponent("x-form", document.getElementById("myform"))
|
|
30
|
+
</script>
|
|
31
|
+
</head>
|
|
32
|
+
|
|
33
|
+
<body>
|
|
34
|
+
<div style="margin:20px">
|
|
35
|
+
<p>Changing one field will change the other. Try it.</p>
|
|
36
|
+
<x-form formname="Form1"></x-form>
|
|
37
|
+
<x-form formname="Form2"></x-form>
|
|
38
|
+
</div>
|
|
39
|
+
</body>
|
|
40
|
+
|
|
41
|
+
</html>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<head>
|
|
3
3
|
<title>Chart</title>
|
|
4
|
-
<link href="../components/timeline.html" rel="module">
|
|
5
|
-
<script src="
|
|
4
|
+
<link href="../components/timeline-repl.html" rel="module">
|
|
5
|
+
<script src="../../lightview.js"></script>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
8
|
<l-timeline id="myPieChart" style="max-width:750px" type="PieChart" title="How Much Pizza I Ate Last Night">
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<body>
|
|
3
|
+
<script src="./javascript/lightview.js?as=x-body"></script>
|
|
4
|
+
<input name="New Todo" value="${newItem}" placeholder="new todo item...">
|
|
5
|
+
<button l-on:click="${addToList}">Add ToDo</button>
|
|
6
|
+
<div l-for="${todoList}">
|
|
7
|
+
<input value="${item.done}" type="checkbox">
|
|
8
|
+
<span class="${item.done ? 'checked' : ''}">${item.text}</span>
|
|
9
|
+
<span l-on:click="({self}) => self.removeFromList(${index})">X</span>
|
|
10
|
+
<br/>
|
|
11
|
+
</div>
|
|
12
|
+
<script id="lightview">
|
|
13
|
+
Lightview.createInputVariables = true;
|
|
14
|
+
currentComponent.mount = function() {
|
|
15
|
+
this.variables(
|
|
16
|
+
{
|
|
17
|
+
todoList: Array
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
reactive,
|
|
21
|
+
set: [
|
|
22
|
+
{text: 'Write my first post', done: true},
|
|
23
|
+
{text: 'Upload the post to the blog', done: false}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
this.addToList = () => {
|
|
28
|
+
todoList = [...todoList, {text: newItem, done: false}];
|
|
29
|
+
newItem = '';
|
|
30
|
+
};
|
|
31
|
+
this.removeFromList = (index) => {
|
|
32
|
+
todoList.splice(index, 1);
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
</script>
|
|
36
|
+
<style>
|
|
37
|
+
.checked { text-decoration: line-through; }
|
|
38
|
+
</style>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
|
@@ -7,29 +7,31 @@
|
|
|
7
7
|
<p>
|
|
8
8
|
Play: <input type="checkbox" value="${run}">
|
|
9
9
|
</p>
|
|
10
|
-
<script
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
self.variables({
|
|
13
|
+
run: "boolean"
|
|
14
|
+
}, {reactive});
|
|
15
|
+
self.variables({
|
|
16
|
+
name: "string"
|
|
17
|
+
}, {
|
|
18
|
+
imported
|
|
19
|
+
});
|
|
20
|
+
addEventListener("change", ({
|
|
21
|
+
variableName,
|
|
22
|
+
value
|
|
23
|
+
}) => {
|
|
24
|
+
if (variableName === "run" && value === true) {
|
|
25
|
+
self.siblings.forEach((sibling) => {
|
|
26
|
+
sibling.setVariableValue(variableName, false);
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
29
31
|
</script>
|
|
30
32
|
</template>
|
|
31
33
|
<title>Lightview:Examples:XOR</title>
|
|
32
|
-
<script src="
|
|
34
|
+
<script src="../../lightview.js"></script>
|
|
33
35
|
<script>
|
|
34
36
|
Lightview.createComponent("x-audiostream", document.getElementById("audiostream"))
|
|
35
37
|
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview:Examples</title>
|
|
6
|
+
<script src="https://unpkg.com/@isomorphic-git/lightning-fs"></script>
|
|
7
|
+
<script src="https://unpkg.com/isomorphic-git"></script>
|
|
8
|
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
|
9
|
+
<script src="https://unpkg.com/turndown/dist/turndown.js"></script>
|
|
10
|
+
<script>var lightviewDebug = false; </script>
|
|
11
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
|
|
12
|
+
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css">
|
|
13
|
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
14
|
+
<link href="components/repl.html" rel="module">
|
|
15
|
+
<script src="../lightview.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
<body>
|
|
18
|
+
<l-repl id="repl" style="min-height:95vh" src="../examples/counter.html">
|
|
19
|
+
<div slot="head"></div>
|
|
20
|
+
<div slot="body"></div>
|
|
21
|
+
<div slot="css"></div>
|
|
22
|
+
<div slot="script"></div>
|
|
23
|
+
</l-repl>
|
|
24
|
+
</body>
|
|
25
|
+
</html>
|
package/docs/index.html
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview</title>
|
|
6
|
+
<link rel="stylesheet" href="css/highlightjs.min.css">
|
|
7
|
+
<script src="javascript/highlightjs.min.js"></script>
|
|
8
|
+
<script>hljs.highlightAll();</script>
|
|
9
|
+
</head>
|
|
10
|
+
<body style="min-width:100%;height:98vh;overflow:hidden">
|
|
11
|
+
<div id="tabs" style="display:flex;flex-direction:row;min-width:100%;border-bottom:1px solid;padding-bottom:5px;">
|
|
12
|
+
<span style="flex-grow:0.2;">
|
|
13
|
+
<a href="./lightview.html" target="content">Lightview</a>
|
|
14
|
+
</span>
|
|
15
|
+
<span style="flex-grow:0.4;text-align:center">
|
|
16
|
+
<a href="./tutorial/0-getting-started.html" target="content" as="l-tutorial-1">Tutorial</a>
|
|
17
|
+
<a href="./comparedto.html" target="content">Compared To</a>
|
|
18
|
+
<a href="./api.html" target="content">API</a>
|
|
19
|
+
<a href="./components/chart-repl.html" target="content">Components</a>
|
|
20
|
+
<a href="./websiterepl.html" target="content">REPL</a>
|
|
21
|
+
</span>
|
|
22
|
+
<span style="flex-grow:0.2;text-align:right;">
|
|
23
|
+
<a class="tabctrl" href="https://github.com/anywhichway/lightview" target="_other">GitHub</a>
|
|
24
|
+
<a class="tabctrl" href="https://www.npmjs.com/package/lightview" target="_other">NPM</a>
|
|
25
|
+
</span>
|
|
26
|
+
</div>
|
|
27
|
+
<iframe name="content" style="width:100%;" src="lightview.html"></iframe>
|
|
28
|
+
<style id="style">
|
|
29
|
+
a {
|
|
30
|
+
font-size: x-large;
|
|
31
|
+
color: black;
|
|
32
|
+
padding-left: 5px;
|
|
33
|
+
padding-right: 5px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
a:hover {
|
|
37
|
+
color: blue;
|
|
38
|
+
}
|
|
39
|
+
</style>
|
|
40
|
+
<script>
|
|
41
|
+
document.querySelector("iframe").style.height = (document.body.clientHeight - document.getElementById("tabs").clientHeight)+"px"
|
|
42
|
+
</script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minified by jsDelivr using Terser v5.10.0.
|
|
3
|
+
* Original file: /npm/codejar@3.6.0/codejar.js
|
|
4
|
+
*
|
|
5
|
+
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
|
|
6
|
+
*/
|
|
7
|
+
const globalWindow=window;export function CodeJar(t,e,n={}){const o=Object.assign({tab:"\t",indentOn:/[({\[]$/,moveToNewLine:/^[)}\]]/,spellcheck:!1,catchTab:!0,preserveIdent:!0,addClosing:!0,history:!0,window:globalWindow},n),r=o.window,i=r.document;let s,d,l=[],a=[],c=-1,f=!1;t.setAttribute("contenteditable","plaintext-only"),t.setAttribute("spellcheck",o.spellcheck?"true":"false"),t.style.outline="none",t.style.overflowWrap="break-word",t.style.overflowY="auto",t.style.whiteSpace="pre-wrap";let u=!1;e(t),"plaintext-only"!==t.contentEditable&&(u=!0),u&&t.setAttribute("contenteditable","true");const p=L((()=>{const n=T();e(t,n),b(n)}),30);let h=!1;const g=t=>!O(t)&&!x(t)&&"Meta"!==t.key&&"Control"!==t.key&&"Alt"!==t.key&&!t.key.startsWith("Arrow"),y=L((t=>{g(t)&&(C(),h=!1)}),300),N=(e,n)=>{l.push([e,n]),t.addEventListener(e,n)};function T(){const e=K(),n={start:0,end:0,dir:void 0};let{anchorNode:o,anchorOffset:r,focusNode:s,focusOffset:d}=e;if(!o||!s)throw"error1";if(o.nodeType===Node.ELEMENT_NODE){const t=i.createTextNode("");o.insertBefore(t,o.childNodes[r]),o=t,r=0}if(s.nodeType===Node.ELEMENT_NODE){const t=i.createTextNode("");s.insertBefore(t,s.childNodes[d]),s=t,d=0}return v(t,(t=>{if(t===o&&t===s)return n.start+=r,n.end+=d,n.dir=r<=d?"->":"<-","stop";if(t===o){if(n.start+=r,n.dir)return"stop";n.dir="->"}else if(t===s){if(n.end+=d,n.dir)return"stop";n.dir="<-"}t.nodeType===Node.TEXT_NODE&&("->"!=n.dir&&(n.start+=t.nodeValue.length),"<-"!=n.dir&&(n.end+=t.nodeValue.length))})),t.normalize(),n}function b(e){const n=K();let o,r,i=0,s=0;if(e.dir||(e.dir="->"),e.start<0&&(e.start=0),e.end<0&&(e.end=0),"<-"==e.dir){const{start:t,end:n}=e;e.start=n,e.end=t}let d=0;v(t,(t=>{if(t.nodeType!==Node.TEXT_NODE)return;const n=(t.nodeValue||"").length;if(d+n>e.start&&(o||(o=t,i=e.start-d),d+n>e.end))return r=t,s=e.end-d,"stop";d+=n})),o||(o=t,i=t.childNodes.length),r||(r=t,s=t.childNodes.length),"<-"==e.dir&&([o,i,r,s]=[r,s,o,i]),n.setBaseAndExtent(o,i,r,s)}function E(){const e=K().getRangeAt(0),n=i.createRange();return n.selectNodeContents(t),n.setEnd(e.startContainer,e.startOffset),n.toString()}function m(){const e=K().getRangeAt(0),n=i.createRange();return n.selectNodeContents(t),n.setStart(e.endContainer,e.endOffset),n.toString()}function k(t){if(u&&"Enter"===t.key)if(D(t),t.stopPropagation(),""==m()){M("\n ");const t=T();t.start=--t.end,b(t)}else M("\n")}function C(){if(!f)return;const e=t.innerHTML,n=T(),o=a[c];if(o&&o.html===e&&o.pos.start===n.start&&o.pos.end===n.end)return;c++,a[c]={html:e,pos:n},a.splice(c+1);c>300&&(c=300,a.splice(0,1))}function v(t,e){const n=[];t.firstChild&&n.push(t.firstChild);let o=n.pop();for(;o&&"stop"!==e(o);)o.nextSibling&&n.push(o.nextSibling),o.firstChild&&n.push(o.firstChild),o=n.pop()}function w(t){return t.metaKey||t.ctrlKey}function O(t){return w(t)&&!t.shiftKey&&"KeyZ"===t.code}function x(t){return w(t)&&t.shiftKey&&"KeyZ"===t.code}function M(t){t=t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),i.execCommand("insertHTML",!1,t)}function L(t,e){let n=0;return(...o)=>{clearTimeout(n),n=r.setTimeout((()=>t(...o)),e)}}function S(t){let e=t.length-1;for(;e>=0&&"\n"!==t[e];)e--;e++;let n=e;for(;n<t.length&&/[ \t]/.test(t[n]);)n++;return[t.substring(e,n)||"",e,n]}function A(){return t.textContent||""}function D(t){t.preventDefault()}function K(){var e;return(null===(e=t.parentNode)||void 0===e?void 0:e.nodeType)==Node.DOCUMENT_FRAGMENT_NODE?t.parentNode.getSelection():r.getSelection()}return N("keydown",(e=>{e.defaultPrevented||(d=A(),o.preserveIdent?function(t){if("Enter"===t.key){const e=E(),n=m();let[r]=S(e),i=r;if(o.indentOn.test(e)&&(i+=o.tab),i.length>0?(D(t),t.stopPropagation(),M("\n"+i)):k(t),i!==r&&o.moveToNewLine.test(n)){const t=T();M("\n"+r),b(t)}}}(e):k(e),o.catchTab&&function(t){if("Tab"===t.key)if(D(t),t.shiftKey){const t=E();let[e,n]=S(t);if(e.length>0){const t=T(),r=Math.min(o.tab.length,e.length);b({start:n,end:n+r}),i.execCommand("delete"),t.start-=r,t.end-=r,b(t)}}else M(o.tab)}(e),o.addClosing&&function(t){const e="([{'\"",n=")]}'\"",o=m(),r=E(),i="\\"===r.substr(r.length-1),s=o.substr(0,1);if(n.includes(t.key)&&!i&&s===t.key){const e=T();D(t),e.start=++e.end,b(e)}else if(e.includes(t.key)&&!i&&("\"'".includes(t.key)||[""," ","\n"].includes(s))){D(t);const o=T(),r=o.start==o.end?"":K().toString();M(t.key+r+n[e.indexOf(t.key)]),o.start++,o.end++,b(o)}}(e),o.history&&(!function(e){if(O(e)){D(e),c--;const n=a[c];n&&(t.innerHTML=n.html,b(n.pos)),c<0&&(c=0)}if(x(e)){D(e),c++;const n=a[c];n&&(t.innerHTML=n.html,b(n.pos)),c>=a.length&&c--}}(e),g(e)&&!h&&(C(),h=!0)),u&&b(T()))})),N("keyup",(t=>{t.defaultPrevented||t.isComposing||(d!==A()&&p(),y(t),s&&s(A()))})),N("focus",(t=>{f=!0})),N("blur",(t=>{f=!1})),N("paste",(n=>{C(),function(n){D(n);const o=(n.originalEvent||n).clipboardData.getData("text/plain").replace(/\r/g,""),r=T();M(o),e(t),b({start:Math.min(r.start,r.end)+o.length,end:Math.min(r.start,r.end)+o.length,dir:"<-"})}(n),C(),s&&s(A())})),{updateOptions(t){Object.assign(o,t)},updateCode(n){t.textContent=n,e(t)},onUpdate(t){s=t},toString:A,save:T,restore:b,recordHistory:C,destroy(){for(let[e,n]of l)t.removeEventListener(e,n)}}}
|
|
8
|
+
//# sourceMappingURL=/sm/96f81945d5ecf71ee083a671465d6081d317ddc1afb05de3cce12b31422fa964.map
|