lightview 1.8.1-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/{components/chart → docs/components}/chart.html +2 -2
- package/{components → docs/components}/components.js +3 -3
- package/docs/components/contents.html +17 -0
- package/docs/components/gantt-repl.html +61 -0
- package/{components/gantt → docs/components}/gantt.html +3 -3
- package/docs/components/gauge-repl.html +66 -0
- package/{components/gauge → docs/components}/gauge.html +2 -2
- package/docs/components/orgchart-repl.html +64 -0
- package/{components/orgchart → docs/components}/orgchart.html +2 -2
- 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/{components/timeline → docs/components}/timeline.html +2 -2
- 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/{examples → docs/examples}/chart.html +2 -2
- package/{examples → docs/examples}/counter.html +1 -1
- package/{examples → docs/examples}/counter.test.mjs +0 -0
- package/{examples → docs/examples}/counter2.html +1 -1
- package/{examples → docs/examples}/directives.html +1 -1
- package/{examples → docs/examples}/foreign.html +1 -1
- package/{examples → docs/examples}/forgeinform.html +1 -1
- package/{examples → docs/examples}/form.html +1 -1
- package/{examples → docs/examples}/gauge.html +2 -2
- package/{examples → docs/examples}/invalid-template-literals.html +1 -1
- package/{examples → docs/examples}/medium/remote.html +1 -1
- package/{examples → docs/examples}/message.html +0 -0
- package/{examples → docs/examples}/nested.html +1 -1
- package/{examples → docs/examples}/object-bound-form.html +0 -0
- package/{examples → docs/examples}/remote-server.js +0 -0
- package/{examples → docs/examples}/remote.html +2 -2
- 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/{examples → docs/examples}/shared.html +0 -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 +1 -1
- 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 +430 -340
- package/lightview.min.js +1 -0
- package/lightview_good.js +1267 -0
- package/lightview_optimized.js +1274 -0
- package/package.json +1 -1
- package/repl_hold.html +320 -0
- package/test/basic.html +15 -4
- package/test/basic.test.mjs +1 -1
- package/test/extended.html +1 -1
- package/types.js +109 -36
- package/components/chart/example.html +0 -32
- package/components/chart.html +0 -83
- package/components/gantt/example.html +0 -22
- package/components/gauge/example.html +0 -28
- package/components/gauge.html +0 -60
- package/components/orgchart/example.html +0 -25
- package/components/repl/code-editor.html +0 -64
- package/components/repl/editor.html +0 -37
- package/components/repl/editorjs-inline-tool/index.js +0 -3
- package/components/repl/editorjs-inline-tool/inline-tools.js +0 -28
- package/components/repl/editorjs-inline-tool/tool.js +0 -175
- package/components/repl/repl-with-wysiwyg.html +0 -355
- package/components/repl/repl.html +0 -345
- package/components/repl/sup.js +0 -44
- package/components/repl/wysiwyg-repl.html +0 -258
- package/components/timeline/example.html +0 -33
- package/components/timeline.html +0 -81
- package/examples/anchor.html +0 -11
- package/examples/sensors/index.html +0 -30
- package/examples/todo.html +0 -38
- package/examples/top.html +0 -10
- package/sites/client.html +0 -48
- package/sites/index.html +0 -247
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview:REPL</title>
|
|
6
|
+
<style>
|
|
7
|
+
.hljs[slot] { padding: 5px; }
|
|
8
|
+
</style>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<link rel="stylesheet" href="../css/highlightjs.min.css" export>
|
|
12
|
+
<script src="../javascript/lightning-fs.js"></script>
|
|
13
|
+
<script src="../javascript/isomorphic-git.js"></script>
|
|
14
|
+
<script src="../javascript/highlightjs.min.js"></script>
|
|
15
|
+
<script src="../javascript/turndown.js"></script>
|
|
16
|
+
<div id="content" style="flex:auto;min-width:500px;border:1px solid;padding:10px;margin-top:1em;margin-bottom:1em; auto;overflow:auto;font-size:smaller">
|
|
17
|
+
<div style="display:flex;flex-direction:column;">
|
|
18
|
+
<div l-if="${!hidetabs}" id="tabs" style="flex-grow:0;width:100%;border:1px;padding-bottom:5px;text-align:center" hidden>
|
|
19
|
+
<span style="padding-right:10px" for="headhtml"><label for="headhtml" l-on:click="${onTabClick}">HTML Head</label><input for="headhtml" value="${headhtmlPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
20
|
+
<span style="padding-right:10px" for="bodyhtml"><label for="bodyhtml" l-on:click="${onTabClick}">HTML Body</label><input for="bodyhtml" value="${bodyhtmlPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
21
|
+
<!--span style="padding-right:10px" for="markdown"><label for="markdown" l-on:click="${onTabClick}">Markdown (Body)</label><input for="markdown" value="${markdownPinned}" type="checkbox" l-on:click="${onPinClick}"></span-->
|
|
22
|
+
<span style="padding-right:10px" for="css"><label for="css" l-on:click="${onTabClick}">Style</label><input for="css" value="${cssPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
23
|
+
<span style="padding-right:10px" for="script"><label for="script" l-on:click="${onTabClick}">Script</label><input for="script" value="${scriptPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
24
|
+
<span style="padding-right:10px" for="preview"><label for="preview" l-on:click="${onTabClick}">Preview</label><input for="preview" value="${previewPinned}" type="checkbox" l-on:click="${onPinClick}"></span>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
<div id="headhtml" style="margin:10px" class="language-html"><slot name="headhtml"></slot></div>
|
|
28
|
+
<div id="bodyhtml" style="margin:10px" class="language-html"><slot name="bodyhtml"></slot></div>
|
|
29
|
+
<!--textarea id="markdown" style="margin-right:2px;">${markdown}</textarea-->
|
|
30
|
+
<div id="css" style="margin:10px" class="language-css"><slot name="css"></slot></div>
|
|
31
|
+
<div id="script" style="margin:10px" class="language-javascript"><slot name="script"></slot></div>
|
|
32
|
+
<iframe id="preview" style="height:${previewheight||'150px'};max-width:99%;width:99%;" hidden></iframe>
|
|
33
|
+
</div>
|
|
34
|
+
<div l-if="${editable}" style="width:100%;text-align:center">
|
|
35
|
+
<div style="padding:5px">${source}</div>
|
|
36
|
+
<button l-on:click="${doSave}">Save</button>
|
|
37
|
+
<button l-if="${canReset}" l-on:click="${doReset}">Reset</button>
|
|
38
|
+
</div>
|
|
39
|
+
<style>
|
|
40
|
+
label:hover {
|
|
41
|
+
text-decoration: underline
|
|
42
|
+
}
|
|
43
|
+
slot[name=headhtml]:not([hidden])::before { content: "<head>" }
|
|
44
|
+
slot[name=headhtml]:not([hidden])::after { content: "</head>" }
|
|
45
|
+
slot[name=bodyhtml]:not([hidden])::before { content: "<body${bodyattributes ? ' ' + bodyattributes : ''}>" }
|
|
46
|
+
slot[name=bodyhtml]:not([hidden])::after { content: "</body>" }
|
|
47
|
+
slot[name=css]:not([hidden])::before { content: "<style>" }
|
|
48
|
+
slot[name=css]:not([hidden])::after { content: "< /style>" }
|
|
49
|
+
slot[name=script]:not([hidden])::before { content: "<script ${scriptattributes}>" }
|
|
50
|
+
slot[name=script]:not([hidden])::after { content: "</script>" }
|
|
51
|
+
</style>
|
|
52
|
+
<script id="lightview">
|
|
53
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
54
|
+
let CJ
|
|
55
|
+
try {
|
|
56
|
+
const {CodeJar} = await import(new URL("../javascript/codejar.min.js", this.componentBaseURI).href);
|
|
57
|
+
CJ = CodeJar;
|
|
58
|
+
} catch {
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
let turndownService;
|
|
62
|
+
try {
|
|
63
|
+
turndownService = new TurndownService({
|
|
64
|
+
headingStyle: "atx",
|
|
65
|
+
codeBlockStyle: "fenced",
|
|
66
|
+
emDelimiter: "*"
|
|
67
|
+
});
|
|
68
|
+
turndownService.keep(() => true);
|
|
69
|
+
} catch(e) {
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const {html, css, script} = await import(new URL("../javascript/types.js", this.componentBaseURI).href);
|
|
74
|
+
self.variables({
|
|
75
|
+
onTabClick: "function",
|
|
76
|
+
onPinClick: "function",
|
|
77
|
+
doSave: "function",
|
|
78
|
+
doReset: "function"
|
|
79
|
+
});
|
|
80
|
+
self.variables({
|
|
81
|
+
wysiwygPinned: "boolean",
|
|
82
|
+
headhtmlPinned: "boolean",
|
|
83
|
+
headhtml: html,
|
|
84
|
+
bodyhtmlPinned: "boolean",
|
|
85
|
+
bodyhtml: html,
|
|
86
|
+
bodyattributes:"string",
|
|
87
|
+
markdownPinned: "boolean",
|
|
88
|
+
markdown: "string",
|
|
89
|
+
cssPinned: "boolean",
|
|
90
|
+
cssText: css,
|
|
91
|
+
scriptPinned: "boolean",
|
|
92
|
+
scriptText: script,
|
|
93
|
+
scriptattributes:"string",
|
|
94
|
+
source: "string",
|
|
95
|
+
canReset: "boolean",
|
|
96
|
+
editable: "boolean"
|
|
97
|
+
}, {reactive});
|
|
98
|
+
self.variables({
|
|
99
|
+
previewPinned: "boolean"
|
|
100
|
+
},{imported,reactive});
|
|
101
|
+
self.variables({
|
|
102
|
+
src: "string",
|
|
103
|
+
path: "string",
|
|
104
|
+
hidetabs: "boolean",
|
|
105
|
+
maintainbody: "boolean",
|
|
106
|
+
contentbackground:"string",
|
|
107
|
+
readonly: "boolean",
|
|
108
|
+
previewheight: "string"
|
|
109
|
+
}, {imported});
|
|
110
|
+
|
|
111
|
+
bodyhtmlPinned = true;
|
|
112
|
+
canReset = false;
|
|
113
|
+
bodyattributes = "";
|
|
114
|
+
scriptattributes = "";
|
|
115
|
+
editable = false;
|
|
116
|
+
|
|
117
|
+
const getPath = () => {
|
|
118
|
+
if(path==="$location" || path==null) return source = window.location.pathname;
|
|
119
|
+
return source = path;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const trimContent = (text) => {
|
|
123
|
+
let result = text;
|
|
124
|
+
if(result[0]==="\n") result = result.substring(1);
|
|
125
|
+
while(result[result.length-1]==="\n") result = result.substring(0,result.length-1);
|
|
126
|
+
return result;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const loadFromFile = async () => {
|
|
130
|
+
const html = await fs.readFile(url.pathname, {encoding: "utf8"});
|
|
131
|
+
source = `IndexedDB://${url.hostname + "_repl"}${url.pathname}`;
|
|
132
|
+
return html;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
const loadFromServer = async () => {
|
|
136
|
+
const response = await fetch(url.href);
|
|
137
|
+
const html = await response.text();
|
|
138
|
+
source = url.href;
|
|
139
|
+
return html;
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const loadFromTemplate = () => {
|
|
143
|
+
const templateEl = this.querySelector('[slot="src"]');
|
|
144
|
+
if(templateEl) {
|
|
145
|
+
const template = document.createElement("div");
|
|
146
|
+
template.innerHTML = templateEl.innerHTML;
|
|
147
|
+
return template;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const initFromTemplate = (template) => {
|
|
152
|
+
head_el = document.createElement("head");
|
|
153
|
+
body_el = document.createElement("body");
|
|
154
|
+
if(template) {
|
|
155
|
+
const head = template.querySelector("l-head");
|
|
156
|
+
if(head) {
|
|
157
|
+
headhtml = trimContent(head.innerHTML || "");
|
|
158
|
+
[...head.attributes].forEach((attr) => head_el.setAttribute(attr.name,attr.value));
|
|
159
|
+
} else {
|
|
160
|
+
headhtml = "";
|
|
161
|
+
}
|
|
162
|
+
style_el = template.querySelector("style");
|
|
163
|
+
if(style_el) {
|
|
164
|
+
cssText = trimContent(style_el.innerText);
|
|
165
|
+
style_el.remove();
|
|
166
|
+
} else {
|
|
167
|
+
style_el = document.createElement("style");
|
|
168
|
+
cssText = "";
|
|
169
|
+
}
|
|
170
|
+
script_el = template.querySelector('script:not([src*="lightview.js"])');
|
|
171
|
+
if(script_el && script_el.parentElement===template) {
|
|
172
|
+
scriptText = trimContent(script_el.innerText);
|
|
173
|
+
script_el.remove();
|
|
174
|
+
} else {
|
|
175
|
+
script_el = document.createElement("script");
|
|
176
|
+
scriptText = "";
|
|
177
|
+
}
|
|
178
|
+
const body = template.querySelector("l-body");
|
|
179
|
+
if(body) {
|
|
180
|
+
bodyhtml = trimContent(body.innerHTML);
|
|
181
|
+
[...body.attributes].forEach((attr) => body_el.setAttribute(attr.name,attr.value))
|
|
182
|
+
} else {
|
|
183
|
+
bodyhtml = "";
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
script_el = document.createElement("script");
|
|
187
|
+
style_el = document.createElement("style");
|
|
188
|
+
bodyhtml = "";
|
|
189
|
+
headhtml = "";
|
|
190
|
+
scriptText = "";
|
|
191
|
+
cssText = "";
|
|
192
|
+
}
|
|
193
|
+
body_el.appendChild(style_el);
|
|
194
|
+
body_el.appendChild(script_el);
|
|
195
|
+
bodyattributes = "";
|
|
196
|
+
[...body_el.attributes].forEach((attr) => bodyattributes = bodyattributes + " " + attr.name + '=\\"' + attr.value + '\\"');
|
|
197
|
+
scriptattributes = "";
|
|
198
|
+
[...script_el.attributes].forEach((attr) => scriptattributes = scriptattributes + " " + attr.name + '=\\"' + attr.value + '\\"');
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
let head_el,
|
|
202
|
+
body_el,
|
|
203
|
+
style_el,
|
|
204
|
+
script_el;
|
|
205
|
+
const parseFullHTML = (fullHTML) => {
|
|
206
|
+
const parser = new DOMParser(),
|
|
207
|
+
fragment = parser.parseFromString(fullHTML, "text/html");
|
|
208
|
+
head_el = fragment?.head,
|
|
209
|
+
body_el = fragment?.body,
|
|
210
|
+
style_el = fragment?.body.querySelector("style"),
|
|
211
|
+
script_el = fragment?.body.querySelector("script:not([src])");
|
|
212
|
+
if(!maintainbody) {
|
|
213
|
+
if (style_el) {
|
|
214
|
+
cssText = trimContent(style_el?.innerHTML);
|
|
215
|
+
style_el.remove();
|
|
216
|
+
} else {
|
|
217
|
+
cssText = "";
|
|
218
|
+
}
|
|
219
|
+
if (script_el) {
|
|
220
|
+
scriptText = trimContent(script_el?.innerHTML);
|
|
221
|
+
script_el.remove();
|
|
222
|
+
} else {
|
|
223
|
+
scriptText = "";
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
headhtml = trimContent(head_el?.innerHTML || "");
|
|
227
|
+
bodyhtml = trimContent(body_el?.innerHTML);
|
|
228
|
+
if(style_el && body_el) body_el.appendChild(style_el);
|
|
229
|
+
if(script_el && body_el) body_el.appendChild(script_el);
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
let fs,
|
|
233
|
+
url;
|
|
234
|
+
if (src) {
|
|
235
|
+
url = new URL(src,document.baseURI); // , document.baseURI
|
|
236
|
+
if(typeof(LightningFS)!=="undefined") {
|
|
237
|
+
fs = new LightningFS(url.hostname + "_repl").promises;
|
|
238
|
+
}
|
|
239
|
+
try {
|
|
240
|
+
parseFullHTML(await loadFromFile());
|
|
241
|
+
canReset = true;
|
|
242
|
+
} catch (e) {
|
|
243
|
+
try {
|
|
244
|
+
parseFullHTML(await loadFromServer());
|
|
245
|
+
} catch (e) {
|
|
246
|
+
fullHTML = e.message;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
} else {
|
|
250
|
+
url = new URL(getPath(),document.baseURI);
|
|
251
|
+
if(typeof(LightningFS)!=="undefined") {
|
|
252
|
+
fs = new LightningFS(url.hostname + "_repl").promises;
|
|
253
|
+
}
|
|
254
|
+
try {
|
|
255
|
+
parseFullHTML(await loadFromFile());
|
|
256
|
+
canReset = true;
|
|
257
|
+
} catch (e) {
|
|
258
|
+
initFromTemplate(loadFromTemplate());
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// initialize variables
|
|
263
|
+
markdown = "";
|
|
264
|
+
|
|
265
|
+
const tabs = [...self.querySelectorAll("span[for]")]
|
|
266
|
+
.map((span) => {
|
|
267
|
+
const id = span.getAttribute("for");
|
|
268
|
+
if(id==="preview") {
|
|
269
|
+
const el = self.getElementById(id);
|
|
270
|
+
if(previewPinned) el.removeAttribute("hidden");
|
|
271
|
+
return [id, el];
|
|
272
|
+
}
|
|
273
|
+
const slot = self.querySelector(`[slot="${id}"]`);
|
|
274
|
+
if(slot) {
|
|
275
|
+
if(slot.hasAttribute("hidden")) self.querySelector(`slot[name="${id}"]`)?.setAttribute("hidden","");
|
|
276
|
+
else {
|
|
277
|
+
self.varsProxy[`${id}Pinned`] = true;
|
|
278
|
+
self.querySelector(`slot[name="${id}"]`)?.setAttribute("checked","");
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
self.querySelector(`slot[name="${id}"]`)?.setAttribute("hidden","");
|
|
282
|
+
span.style.display = "none";
|
|
283
|
+
}
|
|
284
|
+
return [id, slot];
|
|
285
|
+
}).filter(([id, slot]) => slot!=null);
|
|
286
|
+
|
|
287
|
+
const showTab = (targetid) => {
|
|
288
|
+
tabs.forEach(([id, el, label]) => {
|
|
289
|
+
if (id === targetid || self.varsProxy[`${id}Pinned`]) {
|
|
290
|
+
el.removeAttribute("hidden");
|
|
291
|
+
self.querySelector(`slot[name="${id}"]`)?.removeAttribute("hidden");
|
|
292
|
+
} else if (!self.varsProxy[`${id}Pinned`]) {
|
|
293
|
+
el.setAttribute("hidden","");
|
|
294
|
+
self.querySelector(`slot[name="${id}"]`)?.setAttribute("hidden","");
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
};
|
|
298
|
+
|
|
299
|
+
const hideTab = (targetid) => {
|
|
300
|
+
tabs.forEach(([id, el, label]) => {
|
|
301
|
+
if (id === targetid) {
|
|
302
|
+
el.setAttribute("hidden","");
|
|
303
|
+
self.querySelector(`slot[name="${id}"]`)?.setAttribute("hidden","");
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
const replaceEntities = (el) => {
|
|
309
|
+
[...el.childNodes].forEach((node) => {
|
|
310
|
+
if(node.nodeType===Node.TEXT_NODE) {
|
|
311
|
+
if(["<",">","&"].some((entity) => node.data.includes(entity))) {
|
|
312
|
+
node.data = node.data.replaceAll(/</g,"<")
|
|
313
|
+
.replaceAll(/>/g,">")
|
|
314
|
+
.replaceAll(/&/g,"&");
|
|
315
|
+
}
|
|
316
|
+
} else if(node.nodeType===Node.ELEMENT_NODE) {
|
|
317
|
+
replaceEntities(node);
|
|
318
|
+
}
|
|
319
|
+
})
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
onTabClick = (event) => {
|
|
323
|
+
showTab(event.target.getAttribute("for"))
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
onPinClick = (event) => {
|
|
327
|
+
const id = event.target.getAttribute("for"),
|
|
328
|
+
checked = self.varsProxy[`${id}Pinned`] = event.target.checked;
|
|
329
|
+
if (checked) onTabClick(event);
|
|
330
|
+
else hideTab(id);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
doSave = async () => {
|
|
334
|
+
const parts = url.pathname.split("/");
|
|
335
|
+
let dir = "";
|
|
336
|
+
parts.shift();
|
|
337
|
+
parts.pop();
|
|
338
|
+
for (const part of parts) {
|
|
339
|
+
dir = dir + "/" + part;
|
|
340
|
+
try {
|
|
341
|
+
await fs.mkdir(dir);
|
|
342
|
+
} catch (e) {
|
|
343
|
+
if (e.message === "EEXIST") continue;
|
|
344
|
+
throw e;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
await fs.writeFile(url.pathname, doPreview(), {encoding: "utf8"}, () => {
|
|
348
|
+
});
|
|
349
|
+
source = `IndexedDB://${url.hostname + "_repl"}${url.pathname}`;
|
|
350
|
+
canReset = true;
|
|
351
|
+
};
|
|
352
|
+
|
|
353
|
+
doReset = async () => {
|
|
354
|
+
originalHTML = null;
|
|
355
|
+
try {
|
|
356
|
+
await fs.unlink(url.pathname);
|
|
357
|
+
} catch (e) {
|
|
358
|
+
|
|
359
|
+
}
|
|
360
|
+
if (src) {
|
|
361
|
+
try {
|
|
362
|
+
parseFullHTML(await loadFromServer());
|
|
363
|
+
source = url.href;
|
|
364
|
+
createEditor();
|
|
365
|
+
} catch (e) {
|
|
366
|
+
previewEl.innerHTML = fullHTML = e.message;
|
|
367
|
+
}
|
|
368
|
+
} else {
|
|
369
|
+
try {
|
|
370
|
+
initFromTemplate(loadFromTemplate());
|
|
371
|
+
source = getPath();
|
|
372
|
+
createEditor();
|
|
373
|
+
} catch (e) {
|
|
374
|
+
previewEl.innerHTML = fullHTML = e.message;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
canReset = false;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
const content = self.getElementById("content");
|
|
381
|
+
let originalHTML;
|
|
382
|
+
const doPreview = () => {
|
|
383
|
+
head_el.innerHTML = `<base href=\"${document.baseURI}\"></base>` + trimContent(headhtml); //
|
|
384
|
+
body_el.innerHTML = trimContent(bodyhtml);
|
|
385
|
+
if(!maintainbody) {
|
|
386
|
+
style_el.innerText = trimContent(cssText);
|
|
387
|
+
script_el.innerHTML = "currentComponent ||= document.body;" + trimContent(scriptText);
|
|
388
|
+
body_el.appendChild(style_el);
|
|
389
|
+
body_el.appendChild(script_el);
|
|
390
|
+
style_el.innerText = style_el.innerText.replaceAll(/<br>/g,"\n");
|
|
391
|
+
}
|
|
392
|
+
const str = "<html>" + head_el.outerHTML + body_el.outerHTML + "</html>",
|
|
393
|
+
blob = new Blob([str], {type : 'text/html'}),
|
|
394
|
+
newurl = window.URL.createObjectURL(blob);
|
|
395
|
+
if(originalHTML) canReset = originalHTML!=str;
|
|
396
|
+
else originalHTML = str;
|
|
397
|
+
previewEl.src = newurl;
|
|
398
|
+
content.style.minWidth = self.style.minWidth;
|
|
399
|
+
content.style.maxWidth = self.style.maxWidth;
|
|
400
|
+
//content.style.width = tabs.reduce((min,tab) => Math.max(min,tab[1].clientWidth),0)+"px";
|
|
401
|
+
return str;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
const tabsEl = self.getElementById("tabs"),
|
|
405
|
+
headhtmlEl = self.querySelector('[slot="headhtml"]'),
|
|
406
|
+
bodyhtmlEl = self.querySelector('[slot="bodyhtml"]'),
|
|
407
|
+
markdownEl = self.getElementById("markdown"),
|
|
408
|
+
cssEl = self.querySelector('[slot="css"]'),
|
|
409
|
+
scriptEl = self.querySelector('[slot="script"]'),
|
|
410
|
+
previewEl = self.getElementById("preview");
|
|
411
|
+
|
|
412
|
+
const highlight = (el,...args) => {
|
|
413
|
+
hljs.highlightElement(el,...args);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const setCode = (el,code,language) => {
|
|
417
|
+
const pre = document.createElement("pre"),
|
|
418
|
+
div = document.createElement("div");
|
|
419
|
+
pre.style.margin = "5px";
|
|
420
|
+
div.className = `language-${language}`;
|
|
421
|
+
div.innerText = trimContent(code).replaceAll(/\n/g,"|newline|");
|
|
422
|
+
hljs.highlightElement(div);
|
|
423
|
+
pre.innerHTML = div.innerHTML.replaceAll(/\|newline\|/g,"\n");
|
|
424
|
+
while(el.lastChild) el.lastChild.remove();
|
|
425
|
+
replaceEntities(el);
|
|
426
|
+
el.append(pre);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
if(headhtmlEl) {
|
|
430
|
+
headhtmlEl.className = "language-html";
|
|
431
|
+
if(headhtmlEl.hasAttribute("readonly") || readonly) {
|
|
432
|
+
setCode(headhtmlEl,headhtml,"html");
|
|
433
|
+
} else {
|
|
434
|
+
editable = true;
|
|
435
|
+
const bodyJar = CJ(headhtmlEl, highlight);
|
|
436
|
+
bodyJar.updateCode(headhtml);
|
|
437
|
+
replaceEntities(headhtmlEl);
|
|
438
|
+
bodyJar.onUpdate(code => {
|
|
439
|
+
replaceEntities(headhtmlEl);
|
|
440
|
+
headhtml = code;
|
|
441
|
+
doPreview();
|
|
442
|
+
})
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
const createEditor = () => {
|
|
447
|
+
|
|
448
|
+
if (bodyhtmlEl) {
|
|
449
|
+
bodyhtmlEl.className = "language-html";
|
|
450
|
+
if (bodyhtmlEl.hasAttribute("readonly") || readonly) {
|
|
451
|
+
setCode(bodyhtmlEl, bodyhtml, "html");
|
|
452
|
+
} else {
|
|
453
|
+
editable = true;
|
|
454
|
+
const bodyJar = CJ(bodyhtmlEl, highlight);
|
|
455
|
+
bodyJar.updateCode(bodyhtml);
|
|
456
|
+
replaceEntities(bodyhtmlEl);
|
|
457
|
+
bodyJar.onUpdate(code => {
|
|
458
|
+
replaceEntities(bodyhtmlEl);
|
|
459
|
+
bodyhtml = code;
|
|
460
|
+
doPreview();
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if (cssEl) {
|
|
466
|
+
cssEl.className = "language-css";
|
|
467
|
+
if (cssEl.hasAttribute("readonly") || readonly) {
|
|
468
|
+
setCode(cssEl, cssText, "css");
|
|
469
|
+
//cssEl.innerText = cssText;
|
|
470
|
+
} else {
|
|
471
|
+
editable = true;
|
|
472
|
+
const bodyJar = CJ(cssEl, highlight);
|
|
473
|
+
bodyJar.updateCode(cssText);
|
|
474
|
+
bodyJar.onUpdate(code => {
|
|
475
|
+
cssText = code;
|
|
476
|
+
doPreview();
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
if (scriptEl) {
|
|
482
|
+
scriptEl.className = "language-javascript";
|
|
483
|
+
if (scriptEl.hasAttribute("readonly") || readonly) {
|
|
484
|
+
setCode(scriptEl, scriptText, "javascript");
|
|
485
|
+
//scriptEl.innerText = scriptText;
|
|
486
|
+
} else {
|
|
487
|
+
editable = true;
|
|
488
|
+
const bodyJar = CJ(scriptEl, highlight);
|
|
489
|
+
bodyJar.updateCode(scriptText);
|
|
490
|
+
replaceEntities(scriptEl);
|
|
491
|
+
bodyJar.onUpdate(code => {
|
|
492
|
+
replaceEntities(scriptEl);
|
|
493
|
+
scriptText = code;
|
|
494
|
+
doPreview();
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
doPreview();
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/*let prevmarkdown; // prevents indirect recursion
|
|
503
|
+
observe(() => {
|
|
504
|
+
const text = turndownService.turndown(bodyhtml).trim();
|
|
505
|
+
if (text && text !== prevtext) {
|
|
506
|
+
markdown = markdownEl.innerHTML = prevmarkdown = text;
|
|
507
|
+
}
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
let prevbodyhtml; // prevents indirect recursion
|
|
511
|
+
observe(() => {
|
|
512
|
+
const html = marked.parse(markdown).trim();
|
|
513
|
+
if (html && html !== prevbodyhtml) {
|
|
514
|
+
bodyhtml = bodyhtmlEl.innerText = prevbodyhtml = html;
|
|
515
|
+
}
|
|
516
|
+
});*/
|
|
517
|
+
|
|
518
|
+
|
|
519
|
+
self.addEventListener("mounted", () => {
|
|
520
|
+
tabsEl.removeAttribute("hidden");
|
|
521
|
+
if(contentbackground) content.style.background = contentbackground;
|
|
522
|
+
createEditor();
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
</script>
|
|
526
|
+
</body>
|
|
527
|
+
</html>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview:Components:Timeline</title>
|
|
6
|
+
<link href="../css/tutorial.css" rel="stylesheet">
|
|
7
|
+
<link href="../slidein.html" rel="module">
|
|
8
|
+
<link href="repl.html" rel="module">
|
|
9
|
+
<script src="../javascript/highlightjs.min.js"></script>
|
|
10
|
+
<script src="../javascript/marked.min.js"></script>
|
|
11
|
+
<script src="../javascript/utils.js"></script>
|
|
12
|
+
</head>
|
|
13
|
+
<body class="tutorial-body">
|
|
14
|
+
<script src="../javascript/lightview.js"></script>
|
|
15
|
+
<div class="tutorial-instructions">
|
|
16
|
+
<l-slidein src="./contents.html" class="toc"></l-slidein>
|
|
17
|
+
<div class="markdown">
|
|
18
|
+
## Timeline
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</div>
|
|
23
|
+
<button class="nav-previous"><a href="orgchart-repl.html" target="content">Previous</a></button>
|
|
24
|
+
<button class="nav-next"><a href="gauge-repl.html" target="content">Next</a></button>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="repl">
|
|
27
|
+
<h2></h2>
|
|
28
|
+
<l-repl id="repl" style="min-height:95vh;min-width:600px;" previewpinned path="$location" previewheight="400px">
|
|
29
|
+
<div slot="headhtml"></div>
|
|
30
|
+
<div slot="bodyhtml"></div>
|
|
31
|
+
<div slot="script"></div>
|
|
32
|
+
<template slot="src">
|
|
33
|
+
<l-head>
|
|
34
|
+
<link href="./timeline.html" rel="module">
|
|
35
|
+
<script src="../javascript/lightview.js"></script>
|
|
36
|
+
</l-head>
|
|
37
|
+
<l-body>
|
|
38
|
+
<l-timeline title="Presidents">
|
|
39
|
+
{
|
|
40
|
+
options: { showRowLabels: false },
|
|
41
|
+
rows: [
|
|
42
|
+
[ '1', 'George Washington','1789-03-30', '1797-2-04' ],
|
|
43
|
+
[ '2', 'John Adams', '1797-02-04', '1801-02-04' ],
|
|
44
|
+
[ '3', 'Thomas Jefferson', '1801-02-04', '1809-02-04']
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
</l-timeline>
|
|
48
|
+
<l-timeline title="Presidents and Vice Presidents">
|
|
49
|
+
{
|
|
50
|
+
options: { },
|
|
51
|
+
rows: [
|
|
52
|
+
[ 'President', 'George Washington','1789-03-30', '1797-2-04' ],
|
|
53
|
+
[ 'President', 'John Adams', '1797-02-04', '1801-02-04' ],
|
|
54
|
+
[ 'President', 'Thomas Jefferson', '1801-02-04', '1809-02-04'],
|
|
55
|
+
[ 'Vice President', 'John Adams','1789-03-21', '1797-02-04'],
|
|
56
|
+
[ 'Vice President', 'Thomas Jefferson','1797-02-04', '1801-02-04'],
|
|
57
|
+
[ 'Vice President', 'Aaron Burr','1801-02-04', '1805-02-04']
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
</l-timeline>
|
|
61
|
+
</l-body>
|
|
62
|
+
<script>
|
|
63
|
+
|
|
64
|
+
</script>
|
|
65
|
+
</template>
|
|
66
|
+
</l-repl>
|
|
67
|
+
</div>
|
|
68
|
+
<script>
|
|
69
|
+
processMarkdown();
|
|
70
|
+
</script>
|
|
71
|
+
</body>
|
|
72
|
+
</html>
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
<html>
|
|
3
3
|
<head>
|
|
4
4
|
<title>Lightview:Component:Timeline</title>
|
|
5
|
+
<script src="../javascript/json5.min.js"></script>
|
|
5
6
|
</head>
|
|
6
7
|
<body>
|
|
7
8
|
<div id="target"></div>
|
|
8
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
9
9
|
<script id="lightview">
|
|
10
10
|
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
11
|
-
const {chart} = await import(new URL("
|
|
11
|
+
const {chart} = await import(new URL("./components.js", this.componentBaseURI).href);
|
|
12
12
|
chart(self, {
|
|
13
13
|
packages: ["timeline"],
|
|
14
14
|
columns: [
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Lightview: Components</title>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<h2>Chart Components</h2>
|
|
9
|
+
<ul>
|
|
10
|
+
<li><a href="./components/chart/repl.html">Bar, Pie, Column</a></li>
|
|
11
|
+
<li><a href="./components/gantt/example.html">Gannt</a></li>
|
|
12
|
+
</ul>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
Theme: Default
|
|
3
|
+
Description: Original highlight.js style
|
|
4
|
+
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
|
|
5
|
+
Maintainer: @highlightjs/core-team
|
|
6
|
+
Website: https://highlightjs.org/
|
|
7
|
+
License: see project LICENSE
|
|
8
|
+
Touched: 2021
|
|
9
|
+
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.toc {
|
|
2
|
+
position:fixed;
|
|
3
|
+
background:white;
|
|
4
|
+
overflow-y:hidden;
|
|
5
|
+
overflow-x:hidden;
|
|
6
|
+
border:1px solid;
|
|
7
|
+
margin-right:5px;
|
|
8
|
+
margin-left: 0px;
|
|
9
|
+
height:100%;
|
|
10
|
+
min-width:10px;
|
|
11
|
+
max-width:250px;
|
|
12
|
+
top:0px;
|
|
13
|
+
bottom:0px;
|
|
14
|
+
}
|
|
15
|
+
.markdown {
|
|
16
|
+
margin-left:20px
|
|
17
|
+
}
|
|
18
|
+
.tutorial-body {
|
|
19
|
+
display:flex;
|
|
20
|
+
margin: 0px;
|
|
21
|
+
overflow: auto;
|
|
22
|
+
}
|
|
23
|
+
.tutorial-instructions {
|
|
24
|
+
margin-right:10px;
|
|
25
|
+
min-width: 500px
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.nav-previous {
|
|
29
|
+
float:left;
|
|
30
|
+
margin-left:20px
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.nav-next {
|
|
34
|
+
float:right;
|
|
35
|
+
}
|