efront 3.36.3 → 3.36.5
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/coms/basic/#loader.js +50 -35
- package/coms/compile/Program.js +6 -1
- package/coms/compile/richcss.js +3 -5
- package/coms/compile/richcss_test.js +2 -1
- package/coms/docs/codetext.xht +78 -17
- package/coms/docs/markdown.js +6 -1
- package/coms/zimoli/AudioContext_test.less +1 -1
- package/coms/zimoli/alert.js +6 -6
- package/coms/zimoli/alert.less +2 -0
- package/coms/zimoli/getGenerator.js +1 -1
- package/coms/zimoli/render.js +1 -0
- package/coms/zimoli/zimoli.js +2 -1
- package/docs/main.xht +2 -2
- package/docs//347/273/204/344/273/266.xht +104 -22
- package/package.json +1 -1
- package/public/efront.js +1 -1
- package/coms/zimoli/onhistoryback.js +0 -0
|
@@ -18,10 +18,6 @@
|
|
|
18
18
|
border-bottom: 46px solid transparent;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
textarea {
|
|
22
|
-
outline: none;
|
|
23
|
-
white-space: nowrap;
|
|
24
|
-
}
|
|
25
21
|
|
|
26
22
|
p4 {
|
|
27
23
|
line-height: 1.8;
|
|
@@ -75,15 +71,16 @@
|
|
|
75
71
|
overflow: auto;
|
|
76
72
|
width: 100%;
|
|
77
73
|
height: 100%;
|
|
78
|
-
padding
|
|
74
|
+
padding: 10px 20px 600px 20px;
|
|
79
75
|
white-space: nowrap;
|
|
76
|
+
outline: none;
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
markdown {
|
|
83
80
|
margin: -6px -20px 0 -10px;
|
|
84
81
|
}
|
|
85
82
|
|
|
86
|
-
button {
|
|
83
|
+
[foot]>button {
|
|
87
84
|
padding: 0 20px;
|
|
88
85
|
}
|
|
89
86
|
|
|
@@ -125,7 +122,7 @@
|
|
|
125
122
|
</p4>
|
|
126
123
|
</div>
|
|
127
124
|
<div body -elseif="tags[1].actived">
|
|
128
|
-
<div codearea #coder onkeyup="updatecode()"></div>
|
|
125
|
+
<div codearea #coder onkeyup="!event.isComposing&&updatecode()" onkeydown.tab="keytab(event)"></div>
|
|
129
126
|
<resultpad .result #coderesult></resultpad>
|
|
130
127
|
</div>
|
|
131
128
|
<div foot -if="tags[1].actived">
|
|
@@ -134,6 +131,38 @@
|
|
|
134
131
|
<btn @click="execute()">运行</btn>
|
|
135
132
|
</div>
|
|
136
133
|
<script>
|
|
134
|
+
var commaps = Object.create(null);
|
|
135
|
+
var initCommap = function (live) {
|
|
136
|
+
var commap = commaps[live];
|
|
137
|
+
if (!commap) {
|
|
138
|
+
commap = commaps[live] = Object.create(null);
|
|
139
|
+
var lives = data.getInstance("components");
|
|
140
|
+
if (live) {
|
|
141
|
+
lives = lives.slice().sort((a, b) => {
|
|
142
|
+
if (a.name === live) return -1;
|
|
143
|
+
return 0;
|
|
144
|
+
});
|
|
145
|
+
lives.forEach(a => {
|
|
146
|
+
for (var c of a.children) {
|
|
147
|
+
var name = c.name.replace(/\.[^\.]+$/, '');
|
|
148
|
+
var real = `${a.name}$${name}`;
|
|
149
|
+
if (!commap[name]) commap[name] = real;
|
|
150
|
+
commap[real] = real;
|
|
151
|
+
}
|
|
152
|
+
})
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return commap;
|
|
156
|
+
};
|
|
157
|
+
var request = modules["get request"]();
|
|
158
|
+
modules["set request"](function (url, onload, onerror, version) {
|
|
159
|
+
if (!/[\*~]/.test(url)) return request(url, onload, onerror, version);
|
|
160
|
+
var name = url.replace(/[\*~][\s\S]*$/, '');
|
|
161
|
+
var live = url.slice(name.length + 1);
|
|
162
|
+
var commap = initCommap(live);
|
|
163
|
+
name = name.replace(/[^\/]+$/g, a => commap[a] || a);
|
|
164
|
+
return request(name, onload, onerror, version)
|
|
165
|
+
});
|
|
137
166
|
var 分析 = lazy(async function (com, props) {
|
|
138
167
|
if (props.mark) props.url = '/mark/coms/' + com.replace(/\.js$/i, '.md');
|
|
139
168
|
scope.doc = props;
|
|
@@ -206,7 +235,43 @@
|
|
|
206
235
|
scope.codetext = scope.coder.innerText;
|
|
207
236
|
execute();
|
|
208
237
|
};
|
|
209
|
-
|
|
238
|
+
var blink = "\u0080";
|
|
239
|
+
var markAnchorOffset = function () {
|
|
240
|
+
var { anchorNode, anchorOffset } = document.getSelection();
|
|
241
|
+
if (!anchorNode || !scope.coder) return;
|
|
242
|
+
var [c] = scope.coder.children;
|
|
243
|
+
if (anchorNode.nodeType === 1) {
|
|
244
|
+
var node = document.createTextNode(blink);
|
|
245
|
+
anchorNode.insertBefore(node, anchorNode.childNodes[anchorOffset])
|
|
246
|
+
}
|
|
247
|
+
else if (anchorNode.nodeType === 3) {
|
|
248
|
+
anchorNode.nodeValue = anchorNode.nodeValue.slice(0, anchorOffset) + blink + anchorNode.nodeValue.slice(anchorOffset);
|
|
249
|
+
}
|
|
250
|
+
};
|
|
251
|
+
var unmarkAnchorOffset = function () {
|
|
252
|
+
var [c] = scope.coder.children;
|
|
253
|
+
var node = c.firstChild;
|
|
254
|
+
while (node) {
|
|
255
|
+
if (node.nodeType === 1) {
|
|
256
|
+
if (node.innerText.indexOf(blink) >= 0) {
|
|
257
|
+
node = node.firstChild;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else if (node.nodeType === 3) {
|
|
262
|
+
if (node.nodeValue.indexOf(blink) >= 0) break;
|
|
263
|
+
}
|
|
264
|
+
node = node.nextSibling;
|
|
265
|
+
}
|
|
266
|
+
if (node) {
|
|
267
|
+
var offset = node.nodeValue.indexOf(blink);
|
|
268
|
+
node.nodeValue = node.nodeValue.slice(0, offset) + node.nodeValue.slice(offset + 1);
|
|
269
|
+
document.getSelection().setBaseAndExtent(node, offset, node, offset);
|
|
270
|
+
if (!node.nodeValue) {
|
|
271
|
+
remove(node);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
210
275
|
var getAnchorOffset = function () {
|
|
211
276
|
var { anchorNode, anchorOffset } = document.getSelection();
|
|
212
277
|
var [c] = scope.coder.children;
|
|
@@ -246,8 +311,12 @@
|
|
|
246
311
|
}
|
|
247
312
|
if (delta >= offset) {
|
|
248
313
|
if (child.nodeType === 1) {
|
|
249
|
-
|
|
250
|
-
|
|
314
|
+
if (child.firstChild) {
|
|
315
|
+
child = child.firstChild;
|
|
316
|
+
continue;
|
|
317
|
+
}
|
|
318
|
+
offset -= 1;
|
|
319
|
+
break;
|
|
251
320
|
}
|
|
252
321
|
break;
|
|
253
322
|
}
|
|
@@ -259,36 +328,44 @@
|
|
|
259
328
|
return document.getSelection().setBaseAndExtent(child, offset, child, offset);
|
|
260
329
|
}
|
|
261
330
|
var initcode = function (innerText) {
|
|
262
|
-
|
|
263
|
-
|
|
331
|
+
try {
|
|
332
|
+
var colored = codetext("js", innerText, blink);
|
|
333
|
+
} catch { return; }
|
|
264
334
|
var innerHTML = scope.coder.innerHTML.replace(/\s*contenteditable\=[^\s\>]+/i, '');
|
|
265
335
|
if (innerHTML === colored) return;
|
|
266
336
|
var [c0] = scope.coder.children;
|
|
267
|
-
var
|
|
337
|
+
var contentLength = c0 ? innerText.length : 0;
|
|
338
|
+
var scrollTop = c0 ? c0.scrollTop : 0;
|
|
339
|
+
var scrollLeft = c0 ? c0.scrollLeft : 0;
|
|
268
340
|
scope.coder.innerHTML = colored;
|
|
269
341
|
var [c] = scope.coder.children;
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
else if (offset > 0) offset++;
|
|
273
|
-
}
|
|
342
|
+
c.scrollTop = scrollTop;
|
|
343
|
+
c.scrollLeft = scrollLeft;
|
|
274
344
|
c.contentEditable = true;
|
|
275
|
-
setAnchorOffset(offset);
|
|
276
345
|
};
|
|
277
|
-
var updatecode = lazy(function (
|
|
346
|
+
var updatecode = lazy(function () {
|
|
347
|
+
markAnchorOffset();
|
|
278
348
|
var innerText = scope.coder.innerText;
|
|
279
|
-
|
|
349
|
+
var trimspace = (_, a) => a ? "" : " ";
|
|
350
|
+
var trimreg = /[\s\u00a0\u2002\u0080]+([\}\{\;\[\]\(\)\,\>\<\+\-\*\&\^\/%!~:?])*/g;
|
|
351
|
+
unmarkAnchorOffset();
|
|
352
|
+
if (scope.codetext.replace(trimreg, trimspace).trim() === innerText.replace(trimreg, trimspace).trim()) return;
|
|
280
353
|
initcode(innerText);
|
|
354
|
+
unmarkAnchorOffset();
|
|
281
355
|
scope.codetext = scope.coder.innerText;
|
|
282
356
|
});
|
|
283
357
|
var execute = async function () {
|
|
284
358
|
try {
|
|
359
|
+
var live = /^([\s\S]+)\//.exec(scope.name);
|
|
360
|
+
if (live) live = live[1];
|
|
361
|
+
var commap = initCommap(live);
|
|
285
362
|
remove(scope.coderesult.childNodes);
|
|
286
363
|
var codetext = scope.codetext.replace(/[\u2002\u00a0]/g, ' ');
|
|
287
364
|
data.patchInstance("docscode", { codetext: codetext })
|
|
288
365
|
var code = compile$scanner2(codetext);
|
|
289
366
|
var envs = code.envs;
|
|
290
367
|
var argNames = Object.keys(envs);
|
|
291
|
-
var args = await Promise.all(argNames.map(a => init(a)));
|
|
368
|
+
var args = await Promise.all(argNames.map(a => init(a + "*" + live, null, { ["init*" + live]: init, ["put*" + live]: put, ["zimoli*" + live]: zimoli, ["appendChild*" + live]: appendChild, ["remove*" + live]: remove })));
|
|
292
369
|
var func = createFunction("", codetext, argNames, code.async, code.yield);
|
|
293
370
|
var res = func.apply(window, args);
|
|
294
371
|
if (isFunction(res)) {
|
|
@@ -299,6 +376,7 @@
|
|
|
299
376
|
}
|
|
300
377
|
} catch (e) {
|
|
301
378
|
alert(String(e), 'error');
|
|
379
|
+
throw e;
|
|
302
380
|
}
|
|
303
381
|
};
|
|
304
382
|
var tags = [
|
|
@@ -309,6 +387,7 @@
|
|
|
309
387
|
var actived = tags.map(t => t.actived);
|
|
310
388
|
var xmenu = menu;
|
|
311
389
|
var page = view();
|
|
390
|
+
on("submit")(page, e => e.preventDefault());
|
|
312
391
|
page.innerHTML = template;
|
|
313
392
|
var scope = {
|
|
314
393
|
btn: button,
|
|
@@ -326,8 +405,11 @@
|
|
|
326
405
|
updatecode,
|
|
327
406
|
saveTagIndex(i) {
|
|
328
407
|
data.setInstance("docscode", { tagIndex: i });
|
|
329
|
-
if (i === 1 && !scope.codetext) loadcode
|
|
408
|
+
if (i === 1 && !scope.codetext) requestAnimationFrame(loadcode);
|
|
330
409
|
},
|
|
410
|
+
keytab(event) {
|
|
411
|
+
event.preventDefault();
|
|
412
|
+
}
|
|
331
413
|
};
|
|
332
414
|
render(page, scope);
|
|
333
415
|
function main(name) {
|