lightview 1.7.3-b → 1.8.1-b
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 +1 -1
- package/components/chart/chart.html +6 -4
- package/components/chart/example.html +1 -1
- package/components/chart.html +67 -65
- package/components/components.js +10 -2
- package/components/gantt/gantt.html +31 -29
- package/components/gauge/gauge.html +20 -0
- package/components/gauge.html +47 -44
- package/components/orgchart/example.html +1 -1
- package/components/orgchart/orgchart.html +30 -25
- package/components/repl/code-editor.html +64 -0
- package/components/repl/editor.html +37 -0
- package/components/repl/editorjs-inline-tool/index.js +3 -0
- package/components/repl/editorjs-inline-tool/inline-tools.js +28 -0
- package/components/repl/editorjs-inline-tool/tool.js +175 -0
- package/components/repl/repl-with-wysiwyg.html +355 -0
- package/components/repl/repl.html +345 -0
- package/components/repl/sup.js +44 -0
- package/components/repl/wysiwyg-repl.html +258 -0
- package/components/timeline/timeline.html +33 -31
- package/examples/anchor.html +11 -0
- package/examples/chart.html +22 -54
- package/examples/counter.html +5 -3
- package/examples/counter2.html +26 -0
- package/examples/directives.html +19 -17
- package/examples/forgeinform.html +45 -43
- package/examples/form.html +22 -20
- package/examples/gauge.html +2 -0
- package/examples/invalid-template-literals.html +5 -3
- package/examples/message.html +10 -4
- package/examples/nested.html +1 -1
- package/examples/object-bound-form.html +12 -10
- package/examples/remote.html +17 -15
- package/examples/shared.html +41 -0
- package/examples/xor.html +21 -20
- package/lightview.js +107 -72
- package/package.json +7 -2
- package/sites/client.html +48 -0
- package/sites/index.html +247 -0
- package/test/basic.html +15 -13
- package/test/basic.test.mjs +0 -10
- package/test/extended.html +17 -20
- package/types.js +10 -1
- package/unsplash.key +1 -0
- package/components/gauge/guage.html +0 -19
package/README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
1
2
|
<html>
|
|
2
3
|
<head>
|
|
3
4
|
<meta charset="UTF-8">
|
|
@@ -5,11 +6,12 @@
|
|
|
5
6
|
</head>
|
|
6
7
|
<body>
|
|
7
8
|
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
9
|
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
const {chart} = await import(new URL("../components.js", this.componentBaseURI).href);
|
|
13
|
+
chart(self);
|
|
14
|
+
}
|
|
13
15
|
</script>
|
|
14
16
|
</body>
|
|
15
17
|
</html>
|
package/components/chart.html
CHANGED
|
@@ -7,75 +7,77 @@
|
|
|
7
7
|
<div id="target"></div>
|
|
8
8
|
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
9
|
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}),
|
|
28
|
-
callback = (textNode, oldValue, newValue) => {
|
|
29
|
-
datatable = new google.visualization.DataTable();
|
|
30
|
-
try {
|
|
31
|
-
table = table || JSON5.parse(newValue.trim());
|
|
32
|
-
datatable = google.visualization.arrayToDataTable(table);
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
let table = JSON5.parse(self.firstChild.textContent.trim()),
|
|
13
|
+
chart,
|
|
14
|
+
datatable,
|
|
15
|
+
options = {};
|
|
16
|
+
const target = self.getElementById("target"),
|
|
17
|
+
resizeObserver = new ResizeObserver(entries => {
|
|
18
|
+
for (let entry of entries) {
|
|
19
|
+
if (entry.contentBoxSize) {
|
|
20
|
+
// Firefox implements `contentBoxSize` as a single content rect, rather than an array
|
|
21
|
+
const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
22
|
+
options.width = contentBoxSize.inlineSize;
|
|
23
|
+
} else {
|
|
24
|
+
options.width = entry.contentRect.width;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
33
27
|
chart.draw(datatable, options);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
28
|
+
}),
|
|
29
|
+
callback = (textNode, oldValue, newValue) => {
|
|
30
|
+
datatable = new google.visualization.DataTable();
|
|
31
|
+
try {
|
|
32
|
+
table = table || JSON5.parse(newValue.trim());
|
|
33
|
+
datatable = google.visualization.arrayToDataTable(table);
|
|
34
|
+
chart.draw(datatable, options);
|
|
35
|
+
table = null;
|
|
36
|
+
} catch (e) {
|
|
37
|
+
target.innerText = e + newValue;
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
self.firstChild.innerText = "Loading ...";
|
|
41
|
+
self.variables({type: "string", title: "string", style: "string"}, {observed});
|
|
42
|
+
if (style) target.setAttribute("style", style);
|
|
43
|
+
self.addRow = (row) => {
|
|
44
|
+
datatable.addRows([row]);
|
|
49
45
|
chart.draw(datatable, options);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
self.init = () => {
|
|
56
|
-
if(!options.title && title) options.title = title;
|
|
57
|
-
chart = new google.visualization[type](target);
|
|
58
|
-
addEventListener("change",({target,value}) => {
|
|
59
|
-
if (target === "type") {
|
|
60
|
-
chart = new google.visualization[type](target);
|
|
61
|
-
} else if (target === "title") {
|
|
62
|
-
options.title = value;
|
|
63
|
-
} else if(target === "style") {
|
|
64
|
-
target.setAttribute("style",value);
|
|
46
|
+
};
|
|
47
|
+
self.setValue = (row, col, value) => {
|
|
48
|
+
if (datatable) {
|
|
49
|
+
datatable.setValue(row, col, value);
|
|
50
|
+
chart.draw(datatable, options);
|
|
65
51
|
}
|
|
66
|
-
|
|
52
|
+
};
|
|
53
|
+
self.setOptions = (newOptions) => {
|
|
54
|
+
Object.assign(options, newOptions);
|
|
55
|
+
};
|
|
56
|
+
self.init = () => {
|
|
57
|
+
if (!options.title && title) options.title = title;
|
|
58
|
+
chart = new google.visualization[type](target);
|
|
59
|
+
addEventListener("change", ({target, value}) => {
|
|
60
|
+
if (target === "type") {
|
|
61
|
+
chart = new google.visualization[type](target);
|
|
62
|
+
} else if (target === "title") {
|
|
63
|
+
options.title = value;
|
|
64
|
+
} else if (target === "style") {
|
|
65
|
+
target.setAttribute("style", value);
|
|
66
|
+
}
|
|
67
|
+
chart.draw(datatable, options);
|
|
68
|
+
});
|
|
69
|
+
const node = self.firstChild;
|
|
70
|
+
callback(node, node.textContent, node.textContent);
|
|
71
|
+
// Will be used by the Lightview global observer
|
|
72
|
+
node.characterDataMutationCallback = callback;
|
|
73
|
+
// resized charts if window resizes
|
|
74
|
+
resizeObserver.observe(target);
|
|
75
|
+
};
|
|
76
|
+
self.addEventListener("connected", ({target}) => {
|
|
77
|
+
google.charts.load("current", {"packages": ["corechart", "gauge"]});
|
|
78
|
+
google.charts.setOnLoadCallback(self.init);
|
|
67
79
|
});
|
|
68
|
-
|
|
69
|
-
callback(node, node.textContent, node.textContent);
|
|
70
|
-
// Will be used by the Lightview global observer
|
|
71
|
-
node.characterDataMutationCallback = callback;
|
|
72
|
-
// resized charts if window resizes
|
|
73
|
-
resizeObserver.observe(target);
|
|
74
|
-
};
|
|
75
|
-
self.addEventListener("connected", ({target}) => {
|
|
76
|
-
google.charts.load("current", {"packages": ["corechart","gauge"]});
|
|
77
|
-
google.charts.setOnLoadCallback(self.init);
|
|
78
|
-
});
|
|
80
|
+
}
|
|
79
81
|
</script>
|
|
80
82
|
</body>
|
|
81
83
|
</html>
|
package/components/components.js
CHANGED
|
@@ -97,9 +97,17 @@ const chart = (self,{packages = ["corechart"],options={},columns=[],rows=[],type
|
|
|
97
97
|
self.dispatchEvent(new Event("mounted"));
|
|
98
98
|
};
|
|
99
99
|
self.addEventListener("connected", ({target}) => {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
const gscript = document.createElement("script");
|
|
101
|
+
gscript.setAttribute("src","https://www.gstatic.com/charts/loader.js");
|
|
102
|
+
gscript.onload = () => {
|
|
103
|
+
google.charts.load("current", {"packages":packages});
|
|
104
|
+
google.charts.setOnLoadCallback(self.init);
|
|
105
|
+
};
|
|
106
|
+
self.appendChild(gscript);
|
|
102
107
|
});
|
|
108
|
+
const jscript = document.createElement("script");
|
|
109
|
+
jscript.setAttribute("src","https://unpkg.com/json5@^2.0.0/dist/index.min.js");
|
|
110
|
+
document.head.appendChild(jscript);
|
|
103
111
|
}
|
|
104
112
|
|
|
105
113
|
export {chart};
|
|
@@ -1,40 +1,42 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
1
2
|
<html>
|
|
2
3
|
<head>
|
|
3
4
|
<title>Lightview:Component:Gantt</title>
|
|
4
5
|
</head>
|
|
5
6
|
<body>
|
|
6
7
|
<div id="target"></div>
|
|
7
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
8
8
|
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
9
|
-
<script
|
|
10
|
-
|
|
11
|
-
{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
9
|
+
<script id="lightview">
|
|
10
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
11
|
+
const {chart} = await import("../components.js"),
|
|
12
|
+
{duration} = await import("/types.js");
|
|
13
|
+
chart(self, {
|
|
14
|
+
packages: ["gantt"],
|
|
15
|
+
columns: [
|
|
16
|
+
{label: "Task ID", type: "string"},
|
|
17
|
+
{label: "Task Name", type: "string"},
|
|
18
|
+
{label: "Start Date", type: "date"},
|
|
19
|
+
{label: "End Date", type: "date"},
|
|
20
|
+
{label: "Duration", type: "number"},
|
|
21
|
+
{label: "% Complete", type: "number"},
|
|
22
|
+
{label: "Dependencies", type: "string"}
|
|
23
|
+
],
|
|
24
|
+
type: "Gantt",
|
|
25
|
+
rowTransform(row, i) {
|
|
26
|
+
return row.map((item, index) => {
|
|
27
|
+
if (item && (index === 2 || index === 3)) {
|
|
28
|
+
const date = new Date(item);
|
|
29
|
+
if (!date || typeof (date) !== "object" || !(date instanceof Date)) {
|
|
30
|
+
throw new TypeError(`row:${i} col:${index} is not a date`);
|
|
31
|
+
}
|
|
32
|
+
return date;
|
|
33
|
+
}
|
|
34
|
+
if (item && index === 4) return duration.parse(item);
|
|
35
|
+
return item;
|
|
36
|
+
})
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if(item && index===4) return duration.parse(item);
|
|
34
|
-
return item;
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
+
});
|
|
39
|
+
}
|
|
38
40
|
</script>
|
|
39
41
|
</body>
|
|
40
42
|
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<html>
|
|
2
|
+
<head>
|
|
3
|
+
<meta charset="UTF-8">
|
|
4
|
+
<title>Lightview:Component:Gauge</title>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<div id="target"></div>
|
|
8
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
9
|
+
<script id="lightview">
|
|
10
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
11
|
+
const {chart} = await import("../components.js");
|
|
12
|
+
chart(self, {
|
|
13
|
+
packages: ["corechart", "gauge"],
|
|
14
|
+
columns: [{label: "Label", type: "string"}, {label: "Value", type: "number"}],
|
|
15
|
+
type: "Gauge"
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
</body>
|
|
20
|
+
</html>
|
package/components/gauge.html
CHANGED
|
@@ -6,52 +6,55 @@
|
|
|
6
6
|
<body hidden>
|
|
7
7
|
<div id="target"></div>
|
|
8
8
|
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
const target = self.getElementById("target"),
|
|
13
|
+
resizeObserver = new ResizeObserver(entries => {
|
|
14
|
+
for (let entry of entries) {
|
|
15
|
+
if (entry.contentBoxSize) {
|
|
16
|
+
// Firefox implements `contentBoxSize` as a single content rect, rather than an array
|
|
17
|
+
const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
18
|
+
options.width = contentBoxSize.inlineSize;
|
|
19
|
+
} else {
|
|
20
|
+
options.width = entry.contentRect.width;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
chart.draw(datatable, options);
|
|
24
|
+
});
|
|
25
|
+
let chart,
|
|
26
|
+
datatable,
|
|
27
|
+
options;
|
|
28
|
+
self.variables({label: "string", value: "number", style: "string"}, {observed});
|
|
29
|
+
if (style) target.setAttribute("style", style);
|
|
30
|
+
self.setValue = (newValue) => {
|
|
31
|
+
if (datatable) {
|
|
32
|
+
datatable.setValue(0, 1, newValue);
|
|
33
|
+
chart.draw(datatable, options);
|
|
19
34
|
}
|
|
20
|
-
|
|
21
|
-
|
|
35
|
+
};
|
|
36
|
+
self.init = () => {
|
|
37
|
+
options = {};
|
|
38
|
+
chart = new google.visualization.Gauge(target);
|
|
39
|
+
datatable = google.visualization.arrayToDataTable([["Label", "Value"], [label, value]]);
|
|
40
|
+
addEventListener("change", ({target, value}) => {
|
|
41
|
+
if (target === "label") {
|
|
42
|
+
datatable.setValue(0, 0, value);
|
|
43
|
+
} else if (target === "value") {
|
|
44
|
+
self.setValue(value);
|
|
45
|
+
} else if (target === "style") {
|
|
46
|
+
target.setAttribute("style", value);
|
|
47
|
+
}
|
|
48
|
+
chart.draw(datatable, options);
|
|
49
|
+
});
|
|
50
|
+
resizeObserver.observe(target);
|
|
51
|
+
self.removeAttribute("hidden");
|
|
52
|
+
};
|
|
53
|
+
self.addEventListener("mounted", ({target}) => {
|
|
54
|
+
google.charts.load("current", {"packages": ["corechart", "gauge"]});
|
|
55
|
+
google.charts.setOnLoadCallback(self.init);
|
|
22
56
|
});
|
|
23
|
-
|
|
24
|
-
datatable,
|
|
25
|
-
options;
|
|
26
|
-
self.variables({label: "string", value:"number", style: "string"}, {observed});
|
|
27
|
-
if(style) target.setAttribute("style",style);
|
|
28
|
-
self.setValue = (newValue) => {
|
|
29
|
-
if(datatable) {
|
|
30
|
-
datatable.setValue(0,1,newValue);
|
|
31
|
-
chart.draw(datatable, options);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
self.init = () => {
|
|
35
|
-
options = { };
|
|
36
|
-
chart = new google.visualization.Gauge(target);
|
|
37
|
-
datatable = google.visualization.arrayToDataTable([["Label","Value"],[label,value]]);
|
|
38
|
-
addEventListener("change",({target,value}) => {
|
|
39
|
-
if (target === "label") {
|
|
40
|
-
datatable.setValue(0,0,value);
|
|
41
|
-
} else if(target ==="value") {
|
|
42
|
-
self.setValue(value);
|
|
43
|
-
} else if(target === "style") {
|
|
44
|
-
target.setAttribute("style",value);
|
|
45
|
-
}
|
|
46
|
-
chart.draw(datatable, options);
|
|
47
|
-
});
|
|
48
|
-
resizeObserver.observe(target);
|
|
49
|
-
self.removeAttribute("hidden");
|
|
50
|
-
};
|
|
51
|
-
self.addEventListener("connected", ({target}) => {
|
|
52
|
-
google.charts.load("current", {"packages": ["corechart","gauge"]});
|
|
53
|
-
google.charts.setOnLoadCallback(self.init);
|
|
54
|
-
});
|
|
57
|
+
}
|
|
55
58
|
</script>
|
|
56
59
|
</body>
|
|
57
60
|
</html>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<title>Lightview:Component:OrgChart:Example</title>
|
|
5
5
|
<link href="./orgchart.html" rel="module">
|
|
6
|
-
<script src="../../
|
|
6
|
+
<script src="../../lightview2.js"></script>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
9
|
<l-orgchart id="myChart" style="height:500px;" title="My Org">
|
|
@@ -1,36 +1,41 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
1
2
|
<html>
|
|
2
3
|
<head>
|
|
3
4
|
<title>Lightview:Component:OrgChart</title>
|
|
5
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
4
6
|
</head>
|
|
5
7
|
<body>
|
|
6
8
|
<link id="load-css-2" rel="stylesheet" type="text/css" href="https://www.gstatic.com/charts/51/css/orgchart/orgchart.css">
|
|
7
9
|
<div id="target"></div>
|
|
8
|
-
<script
|
|
9
|
-
|
|
10
|
-
|
|
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
|
+
const {chart} = await import("../components.js");
|
|
13
|
+
chart(self, {
|
|
14
|
+
options: {allowHtml: true, allowCollapse: true},
|
|
15
|
+
packages: ["orgchart"],
|
|
16
|
+
columns: [
|
|
17
|
+
{label: "Name", type: "string"},
|
|
18
|
+
{label: "Manager", type: "string"},
|
|
19
|
+
{label: "Tooltip", type: "string"}
|
|
20
|
+
],
|
|
21
|
+
type: "OrgChart",
|
|
22
|
+
// 4 columns in definition data name,title,manager,tooltip
|
|
23
|
+
rowTransform(row) {
|
|
24
|
+
return row.reduce((row, item, index) => {
|
|
25
|
+
item ||= "";
|
|
26
|
+
if (index === 1) {
|
|
27
|
+
row[0] = {
|
|
28
|
+
v: row[0],
|
|
29
|
+
f: `<div style="text-align:center;">${row[0]}<div style="font-style:italic">${item}</div></div>`
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
row.push(item);
|
|
33
|
+
}
|
|
34
|
+
return row;
|
|
35
|
+
}, []);
|
|
29
36
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
34
39
|
</script>
|
|
35
40
|
</body>
|
|
36
41
|
</html>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Title</title>
|
|
6
|
+
<link rel="stylesheet"
|
|
7
|
+
href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/styles/default.min.css">
|
|
8
|
+
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.5.1/highlight.min.js"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div style="position:relative">
|
|
12
|
+
<pre style="position:absolute;top:0;left:0;"><textarea id="editor" class="hljs language-html" style="border:none"></textarea></pre>
|
|
13
|
+
<pre style="position:absolute;top:0;left:0;"><code id="codereflector" class="hljs language-html" style="padding:2px;"></code></pre>
|
|
14
|
+
</div>
|
|
15
|
+
<style>
|
|
16
|
+
.cursor {
|
|
17
|
+
-webkit-animation: 2s linear infinite condemned_blink_effect; /* for Safari 4.0 - 8.0 */
|
|
18
|
+
animation: 2s linear infinite condemned_blink_effect;
|
|
19
|
+
position:relative;left:-.45ch;letter-spacing:1px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* for Safari 4.0 - 8.0 */
|
|
23
|
+
@-webkit-keyframes condemned_blink_effect {
|
|
24
|
+
0% {
|
|
25
|
+
visibility: hidden;
|
|
26
|
+
}
|
|
27
|
+
50% {
|
|
28
|
+
visibility: hidden;
|
|
29
|
+
}
|
|
30
|
+
100% {
|
|
31
|
+
visibility: visible;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@keyframes condemned_blink_effect {
|
|
36
|
+
0% {
|
|
37
|
+
visibility: hidden;
|
|
38
|
+
}
|
|
39
|
+
50% {
|
|
40
|
+
visibility: hidden;
|
|
41
|
+
}
|
|
42
|
+
100% {
|
|
43
|
+
visibility: visible;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
<script>
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
const editor = document.getElementById("editor"),
|
|
51
|
+
reflector = document.getElementById("codereflector");
|
|
52
|
+
Object.defineProperty(editor,"innerText",{get() { return editor.value; }});
|
|
53
|
+
editor.addEventListener("input",() => {
|
|
54
|
+
//editor.style.cssText = document.defaultView.getComputedStyle(reflector, "").cssText;
|
|
55
|
+
const startPosition = editor.selectionStart,
|
|
56
|
+
endPosition = editor.selectionEnd,
|
|
57
|
+
value = editor.value.substring(0,startPosition) + "|cursor|" + editor.value.substring(startPosition);
|
|
58
|
+
reflector.innerText = value;
|
|
59
|
+
hljs.highlightElement(reflector);
|
|
60
|
+
reflector.innerHTML = reflector.innerHTML.replace("|cursor|",'<span class="cursor">|</span>');
|
|
61
|
+
})
|
|
62
|
+
</script>
|
|
63
|
+
</body>
|
|
64
|
+
</html>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview:Component:REPL:Example</title>
|
|
6
|
+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/editorjs@latest"></script>
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/header@latest"></script>
|
|
8
|
+
<script src="https://cdn.jsdelivr.net/npm/@editorjs/list@latest"></script>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="editor"></div>
|
|
12
|
+
<script>
|
|
13
|
+
const wysywigEl = document.getElementById("wysywig");
|
|
14
|
+
const editor = new EditorJS({
|
|
15
|
+
/**
|
|
16
|
+
* Id of Element that should contain the Editor
|
|
17
|
+
*/
|
|
18
|
+
holder: "editor",
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Available Tools list.
|
|
22
|
+
* Pass Tool's class or Settings object for each Tool you want to use
|
|
23
|
+
*/
|
|
24
|
+
tools: {
|
|
25
|
+
header: {
|
|
26
|
+
class: Header,
|
|
27
|
+
inlineToolbar: ['link']
|
|
28
|
+
},
|
|
29
|
+
list: {
|
|
30
|
+
class: List,
|
|
31
|
+
inlineToolbar: true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
</script>
|
|
36
|
+
</body>
|
|
37
|
+
</html>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import createGenericInlineTool from './tool.js';
|
|
2
|
+
export var ItalicInlineTool = createGenericInlineTool({
|
|
3
|
+
sanitize: {
|
|
4
|
+
em: {},
|
|
5
|
+
},
|
|
6
|
+
shortcut: 'CMD+I',
|
|
7
|
+
tagName: 'EM',
|
|
8
|
+
toolboxIcon:
|
|
9
|
+
// icon editor-js uses
|
|
10
|
+
'<svg class="icon icon--italic" width="34px" height="34px"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#italic"></use></svg>',
|
|
11
|
+
});
|
|
12
|
+
export var StrongInlineTool = createGenericInlineTool({
|
|
13
|
+
sanitize: {
|
|
14
|
+
strong: {},
|
|
15
|
+
},
|
|
16
|
+
shortcut: 'CMD+B',
|
|
17
|
+
tagName: 'STRONG',
|
|
18
|
+
toolboxIcon: '<svg class="icon icon--bold" width="12px" height="14px"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#bold"></use></svg>',
|
|
19
|
+
});
|
|
20
|
+
export var UnderlineInlineTool = createGenericInlineTool({
|
|
21
|
+
sanitize: {
|
|
22
|
+
u: {},
|
|
23
|
+
},
|
|
24
|
+
tagName: 'U',
|
|
25
|
+
// icon taken from https://github.com/mui-org/material-ui/blob/4fba0dafd30f608937efa32883d151ba01fc9681/packages/material-ui-icons/src/FormatUnderlined.js
|
|
26
|
+
toolboxIcon: '<svg width="24" height="24" viewBox="-8 0 38 24"><path d="M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6zm-7 2v2h14v-2H5z"></path></svg>',
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=inline-tools.js.map
|