efront 4.23.3 → 4.23.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.
Files changed (33) hide show
  1. package/apps/pivot/link/index.html +5 -0
  2. package/apps/pivot/link/list.html +23 -2
  3. package/coms/basic/spaces.js +6 -0
  4. package/coms/compile/Program.js +3 -1
  5. package/coms/compile/formatcode.js +6 -4
  6. package/coms/compile/rescan.js +2 -2
  7. package/coms/compile//347/264/240/351/246/250.js +1 -1
  8. package/coms/zimoli/list.js +0 -1
  9. package/coms/zimoli/menu.js +1 -8
  10. package/coms/zimoli/menuList.js +3 -3
  11. package/coms/zimoli/render.js +18 -12
  12. package/coms/zimoli/scrollbar.js +2 -1
  13. package/coms/zimoli/touchList.js +2 -2
  14. package/coms/zimoli/user.js +1 -0
  15. package/coms/zimoli/zimoli.js +10 -3
  16. package/coms//350/214/250/350/217/260/list.js +59 -0
  17. package/coms//350/214/250/350/217/260/list.less +3 -0
  18. package/coms//350/214/250/350/217/260/tab.js +128 -40
  19. package/coms//350/214/250/350/217/260//346/240/207/347/255/276/345/214/226.js +2 -2
  20. package/coms//350/214/250/350/217/260//346/270/262/346/237/223.js +0 -2
  21. package/coms//350/214/250/350/217/260//347/274/226/350/276/221/346/241/206.xht +299 -113
  22. package/docs//347/273/204/344/273/266.xht +7 -4
  23. package/package.json +1 -1
  24. package/public/efront.js +1 -1
  25. package/public/pivot/page/auth/login.txt +1 -1
  26. package/public/pivot/page/cert/main.txt +1 -1
  27. package/public/pivot/page/cert/orders.txt +1 -1
  28. package/public/pivot/page/cert/update.txt +1 -1
  29. package/public/pivot/page/db/act.txt +1 -1
  30. package/public/pivot/page/db/config.txt +1 -1
  31. package/public/pivot/page/db/edit.txt +1 -1
  32. package/public/pivot/page/db/list.txt +1 -1
  33. package/public/pivot//344/270/273/351/241/265.html +2 -2
@@ -1,11 +1,10 @@
1
1
  <style>
2
2
  & {
3
3
  overflow: auto;
4
- border: 6px solid transparent;
5
4
  border-top: 0;
6
5
  border-bottom: 0;
7
6
  display: block;
8
- padding: 6px 0;
7
+ padding: 0;
9
8
  }
10
9
 
11
10
  &.noinput {
@@ -23,13 +22,91 @@
23
22
  content: "当前浏览器编辑会造成异常";
24
23
  }
25
24
  }
25
+
26
+ @ntype(@len) {
27
+
28
+ &[ntype="@{len}"] {
29
+ @w: @len/2+2;
30
+ @bg: --bgcolor;
31
+
32
+ >[nlist],
33
+ >[clist] {
34
+ display: inline-block;
35
+ vertical-align: top;
36
+ min-height: 100%;
37
+ outline: none;
38
+
39
+ >r,
40
+ >d {
41
+ display: block;
42
+ }
43
+
44
+ }
45
+
46
+ >[clist] {
47
+ background: #2c2d2c;
48
+ margin-left:-@{w}em;
49
+ border-left: @{w}em solid transparent;
50
+ width: 100%;
51
+ overflow-x: scroll;
52
+ }
53
+
54
+ >[nlist] {
55
+ z-index: 1;
56
+ width: @{w}em;
57
+ text-align: right;
58
+ padding-right: .6em;
59
+ color: #666;
60
+ position: relative;
61
+ }
62
+ }
63
+ }
64
+
65
+ @ntype(0);
66
+ @ntype(1);
67
+ @ntype(2);
68
+ @ntype(3);
69
+ @ntype(4);
70
+ @ntype(5);
71
+ @ntype(6);
72
+ @ntype(7);
73
+
74
+ >list {
75
+ display: inline-block;
76
+ border-top: 6px solid #2c2d2c;
77
+
78
+ &[nlist] {
79
+ background: #222;
80
+ border-color: #222;
81
+ }
82
+
83
+ >d {
84
+ outline: none;
85
+ border: none;
86
+
87
+ &:focus {
88
+ outline: 1px solid #fff3;
89
+ }
90
+ }
91
+
92
+ >n,
93
+ >d {
94
+ display: block;
95
+ height: 1.36em;
96
+ }
97
+ }
26
98
  </style>
27
- <编辑框 spellcheck=false e-class="上色.className" e-style="{whiteSpace:'pre'}" onkeydown="updatechar"
28
- onkeydown.tab.prevent.only="keytab(1)" onkeydown.tab.shift.prevent.only="keytab(-1)" onkeyup.enter.only="tab(false)"
29
- oninput='!event.isComposing&&updatecode(event)' onkeydown.space.only='fixpace'>
99
+ <编辑框 spellcheck=false e-class="上色.className" e-style="{whiteSpace:'pre'}" ntype:="codeSpan">
100
+ <list contenteditable="false" nlist# :src="(r,i) in coderows" -style="{height:codeHeight}">
101
+ <n -bind="i+1"></n>
102
+ </list>
103
+ <list clist# contenteditable="true" :src="(r,i) in coderows" -style="{height:codeHeight}">
104
+ <d -html="r"></d>
105
+ </list>
30
106
  </编辑框>
31
107
  <script>
32
108
  var coder = this;
109
+ vbox(this);
33
110
  if (!('oninput' in document)) {
34
111
  on('focus')(this, function () {
35
112
  if (this.contentEditable) addClass(this, "noinput");
@@ -38,6 +115,8 @@
38
115
  removeClass(this, 'noinput');
39
116
  })
40
117
  }
118
+ var codeHeight = '';
119
+ var codeSpan = 1;
41
120
  var coderid = 0;
42
121
  care(coder, async function ([text, type]) {
43
122
  try {
@@ -47,113 +126,85 @@
47
126
  if (typeof text === 'string') coder.innerHTML = 渲染.encode(text);
48
127
  }
49
128
  });
129
+ var refresh = function () {
130
+ codeHeight = coderows.length * 1.36 + 10 + 'em';
131
+ codeSpan = (coderows.length).toString().length;
132
+ };
133
+ on('scroll')(coder, function () {
134
+ nlist.refresh();
135
+ clist.refresh();
136
+ })
137
+ var coderows = [], codetext = '';
50
138
  coder.setValue = async function (text) {
139
+ codetext = text;
51
140
  var id = ++coderid;
52
- var colored = await 上色.text(this.type, text);
141
+ var colored = 上色.rows(this.type, text);
53
142
  if (id !== coderid) return;
54
- coder.innerHTML = colored;
143
+ coderows = colored;
144
+ codeHistory = [[codetext]];
145
+ historyIndex = 0;
146
+ render.refresh();
55
147
  };
56
148
  coder.getValue = function () {
57
- return coder.innerText;
149
+ return codetext;
58
150
  };
59
- var markAnchorOffset = function (光标) {
60
- var { anchorNode, anchorOffset } = document.getSelection();
61
- if (!anchorNode || !coder) return;
62
- var [c] = coder.children;
63
- if (anchorNode.nodeType === 1) {
64
- var node = document.createTextNode(光标);
65
- anchorNode.insertBefore(node, anchorNode.childNodes[anchorOffset])
66
- }
67
- else if (anchorNode.nodeType === 3) {
68
- anchorNode.nodeValue = anchorNode.nodeValue.slice(0, anchorOffset) + 光标 + anchorNode.nodeValue.slice(anchorOffset);
69
- }
151
+ var selection;
152
+ var markAnchorOffset = function () {
153
+ selection = getSelection();
70
154
  };
71
- var unmarkAnchorOffset = function () {
72
- var c = coder;
73
- var node = c.firstChild;
74
- while (node) {
75
- if (node.nodeType === 1) {
76
- if (node.innerText.indexOf(光标) >= 0) {
77
- node = node.firstChild;
155
+ var getNodeAt = function (row, col) {
156
+ var d = clist.at(row);
157
+ if (!d) return [];
158
+ var c = d.firstChild;
159
+ var inc = 0;
160
+ while (c) {
161
+ if (c.nodeType === 1) {
162
+ var t = c.innerText;
163
+ var tl = t.length;
164
+ if (inc + tl >= col) {
165
+ c = c.firstChild;
78
166
  continue;
79
167
  }
168
+ inc += tl;
169
+ c = c.nextSibling;
80
170
  }
81
- else if (node.nodeType === 3) {
82
- if (node.nodeValue.indexOf(光标) >= 0) break;
83
- }
84
- node = node.nextSibling;
85
- }
86
- if (node) {
87
- var offset = node.nodeValue.indexOf(光标);
88
- node.nodeValue = node.nodeValue.slice(0, offset) + node.nodeValue.slice(offset + 1);
89
- document.getSelection().setBaseAndExtent(node, offset, node, offset);
90
- if (!node.nodeValue) {
91
- remove(node);
92
- }
93
- }
94
- }
95
- var getAnchorOffset = function () {
96
- var { anchorNode, anchorOffset } = document.getSelection();
97
- var [c] = coder.children;
98
- if (anchorNode === c || !anchorNode) return -anchorOffset;
99
- var sibling = anchorNode.previousSibling ? anchorNode.previousSibling : anchorNode.parentNode.previousSibling;
100
- while (sibling && sibling !== c) {
101
- switch (sibling.nodeType) {
102
- case 1:
103
- anchorOffset += sibling.innerText.length || 1;
104
- break;
105
- case 3:
106
- anchorOffset += sibling.nodeValue.length;
107
- break;
108
- }
109
- sibling = sibling.previousSibling ? sibling.previousSibling : sibling.parentNode.previousSibling;
110
- }
111
- return anchorOffset;
112
- };
113
- var setAnchorOffset = function (anchorOffset) {
114
- var [c] = coder.children;
115
- if (anchorOffset < 0) {
116
- anchorOffset = -anchorOffset;
117
- if (anchorOffset > c.childNodes.length) anchorOffset = c.childNodes.length;
118
- return document.getSelection().setBaseAndExtent(c, anchorOffset, c, anchorOffset);
119
- }
120
- var offset = anchorOffset;
121
- var child = c.firstChild;
122
- while (child) {
123
- var delta = 0;
124
- switch (child.nodeType) {
125
- case 1:
126
- delta = child.innerText.length || 1;
127
- break;
128
- case 3:
129
- delta = child.nodeValue.length;
130
- break;
131
- }
132
- if (delta >= offset) {
133
- if (child.nodeType === 1) {
134
- if (child.firstChild) {
135
- child = child.firstChild;
136
- continue;
171
+ else if (c.nodeType === 3) {
172
+ var t = c.nodeValue;
173
+ var tl = t.length;
174
+ if (inc + tl > col) {
175
+ col -= inc;
176
+ inc = 0;
177
+ if (t.charAt(col - 1) === " ") {
178
+ col++;
137
179
  }
138
- offset -= 1;
139
180
  break;
140
181
  }
141
- break;
182
+ else if (inc + tl === col) {
183
+ if (t.charAt(col - inc - 1) === " ") col++;
184
+ else break;
185
+ }
186
+ inc += tl;
187
+ c = c.nextSibling;
142
188
  }
143
- offset -= delta;
144
- if (offset <= 0) break;
145
- child = child.nextSibling;
146
189
  }
147
- if (!child) child = c, offset = c.childNodes.length;
148
- return document.getSelection().setBaseAndExtent(child, offset, child, offset);
190
+ if (!c) return [d, d.childNodes.length];
191
+ return [c, col - inc];
192
+ }
193
+ var unmarkAnchorOffset = function () {
194
+ if (!selection) return;
195
+ var [an, ai, fn, fi] = selection;
196
+ [fn, fi] = getNodeAt(fn, fi);
197
+ [an, ai] = fn === an && fi === ai ? [fn, fi] : getNodeAt(an, ai);
198
+ document.getSelection().setBaseAndExtent(an, ai, fn, fi);
149
199
  }
150
200
  var trimspace = (_, a) => a ? "" : " ";
151
- var 更新 = function (colored) {
152
- var { scrollTop, scrollLeft } = coder;
153
- coder.innerHTML = colored;
154
- coder.scrollTop = scrollTop;
155
- coder.scrollLeft = scrollLeft;
156
- unmarkAnchorOffset();
201
+ var 更新 = function () {
202
+ var { scrollTop, scrollLeft } = clist;
203
+ refresh();
204
+ render.refresh(clist);
205
+ render.refresh(nlist);
206
+ clist.scrollTop = scrollTop;
207
+ clist.scrollLeft = scrollLeft;
157
208
  };
158
209
  var anchorChar = null, inText = false;
159
210
  var followChar = null, beforeText = false;
@@ -162,6 +213,7 @@
162
213
  document.execCommand('insertText', false, ' ');
163
214
  };
164
215
  var updatechar = function (event) {
216
+ if (event.defaultPrevented) return;
165
217
  coderid++;
166
218
  var { anchorNode, anchorOffset } = document.getSelection();
167
219
  if (!coder || !anchorNode) return;
@@ -187,8 +239,8 @@
187
239
  }
188
240
  if (anchorOffset === 0) {
189
241
  anchorNode = anchorNode.previousSibling || anchorNode.parentNode.previousSibling;
190
- if (!anchorNode) return;
191
242
  do {
243
+ if (!anchorNode) return;
192
244
  if (anchorNode.nodeType === 1) {
193
245
  if (anchorNode.lastChild) {
194
246
  anchorOffset = anchorNode.childNodes.length;
@@ -258,11 +310,57 @@
258
310
  var [k, p] = a.split('');
259
311
  pairsmap[k] = p;
260
312
  });
261
- var codeHistory = [];
313
+ var codeHistory = [""];
262
314
  var historyIndex = 0;
315
+ var getRow = function (node) {
316
+ var d = getTargetIn(clist, node, false);
317
+ if (!d) return;
318
+ var i = d.i;
319
+ if (isFinit(i)) return i;
320
+ if (d.previousSibling) i = d.previousSibling.i + 1;
321
+ else if (d.nextSibling) i = d.nextSibling.i - 1;
322
+ return i;
323
+ };
324
+ var getCol = function (node, offset) {
325
+ var d = getTargetIn(clist, node, false);
326
+ if (!d) return;
327
+ if (node.nodeType === 1) node = node.childNodes[offset], offset = 0;
328
+ while (node && node !== d) {
329
+ var p = node.previousSibling;
330
+ if (p) {
331
+ if (p.nodeType === 1) {
332
+ offset += p.innerText.length;
333
+ }
334
+ else if (p.nodeType === 3) {
335
+ offset += p.nodeValue.length;
336
+ }
337
+ node = p;
338
+ continue;
339
+ }
340
+ node = node.parentNode;
341
+ }
342
+ return offset;
343
+ };
344
+ var getFocusRow = function () {
345
+ var { focusNode } = document.getSelection();
346
+ return getRow(focusNode);
347
+ };
348
+ var getSelection = function () {
349
+ var { focusNode, anchorNode, focusOffset, anchorOffset } = document.getSelection();
350
+ var fn = getRow(focusNode);
351
+ var an = anchorNode === focusNode ? fn : getRow(anchorNode);
352
+ var fi = getCol(focusNode, focusOffset);
353
+ var ai = anchorNode == focusNode && anchorOffset === focusOffset ? fi : getCol(anchorNode, anchorOffset);
354
+ if (fn === an) {
355
+ if (ai > fi) [ai, fi] = [fi, ai];
356
+ }
357
+ else if (an > fn) {
358
+ [fn, an] = [an, fn];
359
+ }
360
+ return [an, ai, fn, fi];
361
+ };
263
362
  var updatecode = function (event) {
264
363
  var { data, inputType } = event;
265
- coderid++;
266
364
  var patchAfter = '';
267
365
  switch (inputType) {
268
366
  case "insertText":
@@ -283,7 +381,10 @@
283
381
  }
284
382
  }
285
383
  break;
286
- case "insertParagraph": return;
384
+ case "insertParagraph":
385
+ var i = getFocusRow();
386
+ tab(clist, false);
387
+ return;
287
388
  case "deleteContentForward": return;
288
389
  case "deleteContentBackward":
289
390
  if (anchorChar in pairsmap && followChar === pairsmap[anchorChar]) {
@@ -292,22 +393,107 @@
292
393
  return;
293
394
 
294
395
  }
295
- markAnchorOffset(光标 + patchAfter);
296
- var markedText = coder.innerText;
297
- historyIndex = codeHistory.length;
298
- codeHistory.push(coder.innerHTML);
396
+ if (patchAfter) {
397
+ document.execCommand("insertText", false, patchAfter);
398
+ }
399
+ return patchAfter;
400
+ };
401
+ var removeEndBR = function (d) {
402
+ var e = d.lastChild;
403
+ while (e) {
404
+ if (e.tagName === 'BR') {
405
+ remove(e);
406
+ return;
407
+ }
408
+ e = e.lastChild;
409
+ }
410
+ };
411
+ var patchRows = function (rows, k) {
412
+ var ds = clist.children;
413
+ ds = Array.apply(null, ds);
414
+ ds.forEach(removeEndBR);
415
+ var marked = ds.map(d => {
416
+ return d[k]
417
+ });
418
+ var i = clist.start;
419
+ var e = clist.end;
420
+ rows.splice(i, e - i, ...marked);
421
+ }
422
+ var getCodeText = function () {
423
+ var rows = codetext.split(/\r\n|\r|\n/);
424
+ patchRows(rows, 'innerText');
425
+ return rows.join('\r\n');
426
+ };
427
+ var updateCodeHtml = function () {
428
+ patchRows(coderows, "innerHTML");
429
+ };
430
+ var keytab = function (direction) {
431
+ tab(clist, direction);
432
+ markAnchorOffset();
433
+ pudo();
434
+ };
435
+ on("input")(coder, function (event) {
436
+ if (event.isComposing) return;
437
+ var id = ++coderid;
438
+ if (updatecode(event) == null) {
439
+ if (id !== coderid) return;
440
+ // codetext = getCodeText();
441
+ updateCodeHtml();
442
+ pudo();
443
+ 更新();
444
+ unmarkAnchorOffset();
445
+ return;
446
+ }
447
+ if (id !== coderid) return;
448
+ pudo();
449
+ coderows = 上色.rows(coder.type, codetext);
450
+ 更新();
451
+ unmarkAnchorOffset();
452
+ coderows.forEach(function (c, i) {
453
+ var d = c.indexOf(光标);
454
+ if (d > 0) coderows[i] = c.slice(0, d) + c.slice(d + 1);
455
+ });
456
+ });
457
+ on('keydown.space.only')(coder, fixpace);
458
+ on('keydown.tab.shift.prevent.only')(coder, function () {
459
+ keytab(-1);
460
+ });
461
+ on('keydown.tab.prevent.only')(coder, function () {
462
+ keytab(1);
463
+ });
464
+ var updo = function () {
465
+ [codetext, selection] = codeHistory[historyIndex];
466
+ coderows = 上色.rows(coder.type, codetext);
467
+ 更新();
299
468
  unmarkAnchorOffset();
300
- updateonly(coderid, markedText);
469
+ codetext = getCodeText();
301
470
  };
302
- var updateonly = lazy(async function (id, markedText) {
303
- if (coderid !== id) return;
304
- markedText = await 上色.text(coder.type, markedText);
305
- if (coderid !== id) return;
306
- 更新(markedText);
471
+ var pudo = function (markedText) {
472
+ markAnchorOffset();
473
+ codetext = getCodeText();
474
+ historyIndex++;
475
+ codeHistory.splice(historyIndex, codeHistory.length - historyIndex);
476
+ if (historyIndex > 6000) {
477
+ codeHistory.splice(0, 1000);
478
+ historyIndex -= 1000;
479
+ }
480
+ codeHistory.push([codetext, selection]);
307
481
  return;
308
- }, -60);
309
- var keytab = function (direction) {
310
- tab(direction);
311
482
  };
312
-
483
+ var undo = function () {
484
+ if (historyIndex > 0) {
485
+ historyIndex--;
486
+ updo();
487
+ }
488
+ };
489
+ var redo = function () {
490
+ if (historyIndex + 1 < codeHistory.length) {
491
+ historyIndex++;
492
+ updo();
493
+ }
494
+ };
495
+ on('keydown.ctrl.z.prevent.only')(coder, undo);
496
+ on('keydown.ctrl.shift.z.prevent.only')(coder, redo);
497
+ on('keydown.ctrl.y.prevent.only')(coder, redo);
498
+ on('keydown')(coder, updatechar)
313
499
  </script>
@@ -73,9 +73,8 @@
73
73
  overflow: auto;
74
74
  display: block;
75
75
  white-space: pre;
76
- height: auto;
76
+ height: 100%;
77
77
  min-height: 100%;
78
- border-width: 10px 20px 40px 20px;
79
78
  outline: none;
80
79
  }
81
80
 
@@ -125,7 +124,7 @@
125
124
  </p4>
126
125
  </div>
127
126
  <div body codearea -elseif="tags[1].actived">
128
- <cigu contenteditable #coder></cigu>
127
+ <cigu #coder></cigu>
129
128
  </div>
130
129
  <resultpad -if="tags[1].actived" .result #coderesult></resultpad>
131
130
  <div foot -if="tags[1].actived">
@@ -272,7 +271,7 @@
272
271
  if (live) live = live[1];
273
272
  var commap = initCommap(live);
274
273
  remove(coderesult.childNodes);
275
- var jstext = coder.innerText;
274
+ var jstext = coder.getValue();
276
275
  jstext = jstext.replace(/[\u2002\u00a0]/g, ' ');
277
276
  data.patchInstance("docscode", { codetext: jstext })
278
277
  var code = compile$scanner2(jstext);
@@ -299,6 +298,10 @@
299
298
  ["$mounted*" + live]: $mounted,
300
299
  ["$watches*" + live]: $watches,
301
300
  ["$renders*" + live]: $renders,
301
+ ["$cared*" + live]: $cared,
302
+ ["$casted*" + live]: $casted,
303
+ ["$eval*" + live]: $eval,
304
+ ["$upwith*" + live]: $upwith,
302
305
  })));
303
306
  var func = createFunction("", jstext, argNames, code.async, code.yield);
304
307
  var res = func.apply(window, args);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.23.3",
3
+ "version": "4.23.5",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {