efront 4.8.3 → 4.9.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.
@@ -1,3 +1,6 @@
1
+ - zh-CN: 这个文件内的测试代码暂不支持在线查看
2
+ en: The test code in this file does not currently support online viewing
3
+
1
4
  - zh-CN: 这个文件内的测试代码暂不支持
2
5
  en: The test code in this file is currently not supported
3
6
 
@@ -87,7 +87,8 @@ function filterTime(time, formater) {
87
87
  var [year1, month1, date1, hour1, minute1, second1, milli1, day1] = getSplitedDate(now);
88
88
  var today = new Date(year1, month1 - 1, date1);
89
89
  var thatday = new Date(year, month - 1, date);
90
- var delta = (today - thatday) / 24 / 3600000;
90
+ var delta = (today - thatday) / 24 / 3600000 | 0;
91
+ var deltaSeconds = (new Date(year1, month1 - 1, date1, hour1, minute1, second1) - new Date(year, month - 1, date, hour, minute, second)) / 1000;
91
92
  if (minute === 0 && second === 0) var time = hour + "点整";
92
93
  else if (minute === 30 && second === 0) time = hour + "点半";
93
94
  else time = `${hour}:${fixLength(minute)}`;
@@ -103,18 +104,25 @@ function filterTime(time, formater) {
103
104
  }
104
105
  return `星期` + days[day] + time;
105
106
  }
107
+ if (deltaSeconds >= 0 && deltaSeconds < 60) {
108
+ return `刚刚`;
109
+ }
110
+ if (deltaSeconds < 0) {
111
+ if (deltaSeconds > -60) {
112
+ return `${-deltaSeconds | 0}秒后`;
113
+ }
114
+ if (deltaSeconds >= -3600) {
115
+ return `还有${-deltaSeconds / 60 | 0}分钟`;
116
+ }
117
+ if (deltaSeconds > -86400) {
118
+ var a = -deltaSeconds / 3600 | 0;
119
+ var b = (-deltaSeconds + (deltaSeconds / 3600 | 0) * 3600) / 60 | 0;
120
+ if (b === 0) return `还有${a}小时`;
121
+ return `还有${a}小时${b}分钟`;
122
+ }
123
+ }
106
124
  switch (delta) {
107
125
  case 0:
108
- if (minute === minute1 && hour === hour1) {
109
- if (second <= second1) return `刚刚`;
110
- return `${second - second1}秒后`;
111
- }
112
- else if (value > now) {
113
- if (hour === hour1) {
114
- return `${minute - minute1}分钟后`;
115
- }
116
- return `还有${hour - hour1}小时${minute - minute1}分钟`;
117
- }
118
126
  return time;
119
127
  case -1:
120
128
  return "明天" + time;
@@ -2,6 +2,17 @@ assert(filterTime(''), ``);
2
2
  assert(filterTime(null), '');
3
3
  assert(filterTime(undefined), '');
4
4
  assert(filterTime("我出生的第二年"), `我出生的第二年`);
5
+ assert(filterTime(+new Date + 86300000), '还有23小时58分钟');
6
+ assert(filterTime(+new Date + 110000), '还有1分钟');
7
+ assert(filterTime(+new Date + 120000), '还有2分钟');
8
+ assert(filterTime(+new Date + 60000), '还有1分钟');
9
+ assert(filterTime(+new Date + 59000), '59秒后');
10
+ assert(filterTime(+new Date + 58000), '58秒后');
11
+ assert(filterTime(+new Date + 8000), '8秒后');
12
+ assert(filterTime(+new Date + 1000), '1秒后');
13
+ assert(filterTime(+new Date), '刚刚');
14
+ assert(filterTime(+new Date), '刚刚');
15
+ assert(filterTime(+new Date - 59000), '刚刚');
5
16
  assert(filterTime(new Date(2024, 3, 3), `y年M月d日 h:mm`), '2024年4月3日 0:00');
6
17
  assert(filterTime(new Date(2024, 3, 3), `y年M月d日 h:mm`), '2024年4月3日 0:00');
7
18
  assert(filterTime(new Date(2024, 3, 3, 19, 26, 2, 100), `y年M月d日 h:mm:ss.SSS`), '2024年4月3日 19:26:02.100');
@@ -20,3 +20,7 @@ test('<!--<input ng-model=data.name/>-->');
20
20
  test('<div><!--<input ng-model=data.name/>--></div>');
21
21
  test('<div><div>{</div><div>}</div></div>');
22
22
  test('<div>${`<div></div>`}</div>');
23
+ test('<div>\\${${`<div></div>`}</div>');
24
+ test('<div>$\\{${`<div></div>`}</div>');
25
+ test('<div>$\\{${typeof `<div></div>`}</div>');
26
+ test('<div>$\\{${\\a+typeof`<div></div>`}</div>','<div>$\\{${\\a + typeof `<div></div>`}</div>');
@@ -91,7 +91,7 @@ class Program {
91
91
  ["`", "`", /\\[\s\S]/, ["${", "}"]],
92
92
  ]
93
93
  tags = [
94
- [["<", "</"], /\/?>/, null, "'", '"', "<!--", ["${", "}"]]
94
+ [["<", "</"], /\/?>/, /\\[\s\S]/, "'", '"', "<!--", ["${", "}"]]
95
95
  ];
96
96
  scriptTags = [];
97
97
  ignoreTags = ["STYLE", "SCRIPT"];
@@ -187,6 +187,10 @@ class Program {
187
187
  };
188
188
  var row = 1, colstart = -1;
189
189
  var save = (type) => {
190
+ if (type & (SPACE | COMMENT | PIECE | QUOTED)) {
191
+ row += m.replace(/[^\r\n\u2028\u2029]+/g, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, ' ').length;
192
+ colstart = start + m.length - m.replace(/^[\s\S]*?([^\r\n\u2028\u2029]*)$/, '$1').length - 1;
193
+ }
190
194
  if (lasttype === STAMP && type === STAMP && !/[,;\:]/.test(m)) {
191
195
  var scope = queue[queue.length - 1];
192
196
  if (/=>$/i.test(scope.text) ||
@@ -511,7 +515,6 @@ class Program {
511
515
  queue.inExpress = true;
512
516
  queue.end = index;
513
517
  queue.text = text.slice(queue.start, index);
514
- row += queue.text.replace(/[^\r\n\u2028\u2029]+/g, ':').replace(/\r\n/g, ',').replace(/:/g, '').length;
515
518
  pop_parents();
516
519
  continue;
517
520
  }
@@ -525,9 +528,6 @@ class Program {
525
528
  }
526
529
  if (this.space_reg.test(m)) {
527
530
  if (/[\r\n\u2028\u2029]/.test(m)) {
528
- m = m.replace(/^[^\r\n\u2028\u2029]+/, '').replace(/\r\n|\r|\n|\u2028|\u2029/g, "\r\n");
529
- row += m.replace(/[^\r\n]+/g, '').length >> 1;
530
- colstart = match.index + m.replace(/[^\r\n]+$/, '').length - 1;
531
531
  var last = queue.last;
532
532
  if (last && last.isend === false) {
533
533
  last.isend = true;
@@ -141,13 +141,22 @@ var suggest = {
141
141
  var { used, args } = body.scoped;
142
142
  if (!args?.length) return;
143
143
  var access_start = body.reststart ?? args?.length;
144
+ var checkNames = ["arguments"];
144
145
  a: if (access_start > 0) {
145
146
  for (var a of used.arguments) {
146
147
  if (a.text !== 'arguments') continue;
147
148
  var n = a.next;
148
149
  if (!n || n.type !== SCOPED || n.entry !== '[') {
149
150
  access_start = 0;
150
- break a;
151
+ var p = a.prev;
152
+ while (p && p.type === STAMP && p.text === '=') {
153
+ var pp = p.prev;
154
+ if (pp?.type === EXPRESS) {
155
+ checkNames.push(pp.text);
156
+ }
157
+ p = pp.prev;
158
+ }
159
+ continue;
151
160
  }
152
161
  if (n.last && n.last === n.first) {
153
162
  if (n.last.isdigit) {
@@ -159,7 +168,6 @@ var suggest = {
159
168
  }
160
169
  if (access_start >= args.length) return;
161
170
  var broken = false;
162
- var arguments = used.arguments;
163
171
  var arg_start = Infinity;
164
172
  a: for (var a of args) {
165
173
  if (access_start > 0) {
@@ -185,8 +193,14 @@ var suggest = {
185
193
  }
186
194
  }
187
195
  if (!broken) return;
188
- arguments = arguments.filter(a => a.start >= arg_start);
189
- if (!arguments.length) return;
196
+ a: {
197
+ for (var a of checkNames) {
198
+ var args = used[a];
199
+ args = args.filter(a => a.start >= arg_start);
200
+ if (args.length) break a;
201
+ }
202
+ return;
203
+ }
190
204
  var h = snapSentenceHead(body);
191
205
  var matched = [];
192
206
  while (h && h !== body) {
@@ -1089,8 +1089,8 @@ var breakSpace = function (o) {
1089
1089
  };
1090
1090
  var hasBreakBetween = function (prev, next) {
1091
1091
  if (!prev || !next) return true;
1092
- if (prev.type === STAMP && /^[,;]$/.test(prev.text)) return true;
1093
- if (next.type === STAMP && /^[,;]$/.test(next.text)) return true;
1092
+ if (prev.type === STAMP && /^[,;]/.test(prev.text)) return true;
1093
+ if (next.type === STAMP && /^[,;]/.test(next.text)) return true;
1094
1094
  if (prev.type === EXPRESS && /\.$/.test(prev.text)) return true;
1095
1095
  if (next.type === EXPRESS && /^[\.\[]/.test(next.text)) return true;
1096
1096
  };
@@ -1328,7 +1328,7 @@ var createString = function (parsed) {
1328
1328
  else if ((STRAP | EXPRESS | PROPERTY | COMMENT | VALUE) & lasttype && (STRAP | EXPRESS | PROPERTY | VALUE | LABEL) & o.type) {
1329
1329
  if (autospace) result.push(" ");
1330
1330
  }
1331
- else if (o.prev && o.type === STAMP && !/^([,;])$/.test(o.text)) {
1331
+ else if (o.prev && o.type === STAMP && !/^[,;]/.test(o.text)) {
1332
1332
  if (result[result.length - 1] === " " || (lasttype === PROPERTY || !o.isExpress && o.prev && o.prev.type !== LABEL) && o.text === ':') { }
1333
1333
  else if (lasttype === STAMP) {
1334
1334
  var prev = o.prev;
@@ -9,6 +9,27 @@ predefs.Promise = true;
9
9
  var codecolor = function (c, encode) {
10
10
  var envs = c.envs;
11
11
  var deep = 0;
12
+ var used = c.used;
13
+ var setExpress = function (o, label) {
14
+ var text = o.text;
15
+ var keys = o.text.split(".");
16
+ var next = o.next;
17
+ if (next && next.type === SCOPED && next.entry === '(') {
18
+ keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
19
+ }
20
+ var [name0] = text.split(".");
21
+ var [name] = keys;
22
+ if (/^</.test(name0));
23
+ else if (/^(arguments|this|super|Infinity|NaN)$/.test(name0)) name = `<strap>${name}</strap>`;
24
+ keys[0] = name;
25
+ o.text = keys.map(k => /^\</.test(k) || !k ? k : `<${label}>${k}</${label}>`).join(".");
26
+ }
27
+ var setPredef = o => setExpress(o, 'predef');
28
+ var setOutside = o => setExpress(o, 'outside');
29
+ if (used) for (var k in envs) {
30
+ used[k].forEach(k in predefs ? setPredef : setOutside);
31
+ }
32
+
12
33
  var setcolor = function (o) {
13
34
  var text = o.text;
14
35
  switch (o.type) {
@@ -61,18 +82,7 @@ var codecolor = function (c, encode) {
61
82
 
62
83
  break;
63
84
  case EXPRESS:
64
- var keys = o.text.split(".");
65
- var next = o.next;
66
- if (next && next.type === SCOPED && next.entry === '(') {
67
- keys[keys.length - 1] = `<invoke>${keys[keys.length - 1]}</invoke>`;
68
- }
69
- var [name0] = text.split(".");
70
- var [name] = keys;
71
- if (/^</.test(name0));
72
- else if (/^(arguments|this|super|Infinity|NaN)$/.test(name0)) name = `<strap>${name}</strap>`;
73
- else if (name0 in envs) name = name0 in predefs ? `<predef>${name}</predef>` : `<outside>${name}</outside>`;
74
- keys[0] = name;
75
- o.text = keys.map(k => /^\</.test(k) || !k ? k : `<express>${k}</express>`).join(".");
85
+ setExpress(o, 'express');
76
86
  break;
77
87
  case STRAP:
78
88
  if (/^(if|else|switch|case|do|while|for|break|continue|default|import|from|as|export|try|catch|finally|throw|await|yield|return)$/.test(text))
@@ -7,6 +7,7 @@
7
7
  color: #d4d4d4;
8
8
  font-family: Consolas, "Courier New", monospace;
9
9
  vertical-align: top;
10
+ text-decoration-line: none;
10
11
  }
11
12
 
12
13
  stamp {
@@ -94,13 +95,12 @@
94
95
  typescript.tags[0].push(["{", "}"]);
95
96
  var js = new compile$Javascript;
96
97
  js.tags[0].push(["{", "}"]);
97
- js.keepspace = true;
98
98
  var codesupports = {
99
99
  javascript(a, blink) {
100
100
  if (blink) var index = a.indexOf(blink);
101
101
  if (index >= 0) a = a.slice(0, index) + a.slice(index + 1);
102
- js.keepspace = !!blink;
103
102
  var c = compile$scanner2(a, js);
103
+ c.scoped;
104
104
  if (index >= 0) {
105
105
  var patched = patchBlink(c, index, blink);
106
106
  }
@@ -137,7 +137,7 @@
137
137
  codesupports.jsx = codesupports.js = codesupports.javascript;
138
138
  codesupports.tsx = codesupports.ts = codesupports.typescript;
139
139
  codesupports.xml = codesupports.html;
140
- var { SCOPED, QUOTED } = compile$common;
140
+ var { SCOPED, QUOTED, SPACE, EXPRESS } = compile$common;
141
141
  var patchBlink = function (code, index, blink) {
142
142
  for (var cx = 0, dx = code.length; cx < dx; cx++) {
143
143
  var c = code[cx];
@@ -169,6 +169,7 @@
169
169
  }
170
170
  else {
171
171
  c.blink = c.text.length;
172
+ c.text += blink;
172
173
  }
173
174
  return true;
174
175
  }
@@ -194,6 +195,7 @@
194
195
  code.leave = blink + code.leave;
195
196
  return true;
196
197
  }
198
+ if (c) return c.text += blink, true;
197
199
  return false;
198
200
  };
199
201
  function codetext(type, text, blink) {
@@ -58,8 +58,8 @@ var touch = {
58
58
  if (!drag.tip) {
59
59
  var t = document.createElement('dragtip');
60
60
  drag.tip = t;
61
- drag.target.appendChild(t);
62
- drag.target.style.zIndex = zIndex(0) + 2;
61
+ drag.shadow.appendChild(t);
62
+ drag.shadow.style.zIndex = zIndex(0) + 2;
63
63
  css(t, {
64
64
  display: "bock",
65
65
  padding: "6px 10px",
@@ -14,7 +14,7 @@ var moveMarginX = function moveMarginX(element, movePixels) {
14
14
  }
15
15
  };
16
16
  var moveChildrenX = function (targetBox, previousElements, followedElements, moveMargin, recover) {
17
- var dragTarget = drag.target;
17
+ var dragTarget = drag.shadow;
18
18
  if (dragTarget) {
19
19
  var area = overlap(dragTarget, targetBox);
20
20
  if (area > 0) {
@@ -55,7 +55,7 @@ var moveChildrenX = function (targetBox, previousElements, followedElements, mov
55
55
  }
56
56
  };
57
57
  var scrollX = function (targetBox, moveChildren) {
58
- var dragTarget = drag.target;
58
+ var dragTarget = drag.shadow;
59
59
  if (!dragTarget || !targetBox) return;
60
60
  targetBox = getTargetIn(function (a) {
61
61
  var computed = getComputedStyle(a);
@@ -203,8 +203,14 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
203
203
  var dst, appendSibling, delta;
204
204
  var k0 = -1;
205
205
  for (var k0 in previousElements) break;
206
- if (previousElements.length) var src = previousElements.length - k0;
207
- else var src = 0;
206
+ var target = drag.target;
207
+ if (isMounted(target)) {
208
+ if (previousElements.length) var src = previousElements.length - k0;
209
+ else var src = 0;
210
+ }
211
+ else {
212
+ var src = target.index;
213
+ }
208
214
  if (k0 >= 0 && previousElements[k0].moved) for (var k in previousElements) {
209
215
  var cx = +k + 1;
210
216
  if (!previousElements[cx]) {
@@ -235,7 +241,7 @@ var hooka = function (matcher, move, event, targetChild, isMovingSource) {
235
241
  }
236
242
  if (appendSibling) {
237
243
  var children = targetBox.children;
238
- var srcElement = children[src];
244
+ var srcElement = target;
239
245
  var dstElement = children[dst + delta];
240
246
  if (srcElement) {
241
247
  src = bindTarget(src, isMovingSource ? targetChild : srcElement);
@@ -53,6 +53,7 @@ var cloneChildren = function (td, copy, clone) {
53
53
  break;
54
54
  case "img":
55
55
  copy.src = td.src;
56
+ case "canvas":
56
57
  break;
57
58
  case "svg":
58
59
  case "math":
@@ -214,6 +215,9 @@ var createElementFromNode = function (node) {
214
215
  if (node.namespaceURI && !/html$/i.test(node.namespaceURI)) {
215
216
  return document.createElementNS(node.namespaceURI, node.tagName);
216
217
  }
218
+ if (/^canvas$/i.test(node.tagName)) {
219
+ return cloneCanvas(node);
220
+ }
217
221
  return document.createElement(node.tagName);
218
222
  }
219
223
 
@@ -3,7 +3,7 @@
3
3
  strong{
4
4
  color: #666;
5
5
  }
6
- div span:before{
6
+ td:first-child span:before{
7
7
  content: '<a>pseudo</a>';
8
8
  display: 'inline-block';
9
9
  padding: 0 16px;
@@ -14,6 +14,9 @@
14
14
  padding: 10px 16px;
15
15
  background: #fff;
16
16
  }
17
+ *{
18
+ box-sizing: border-box;
19
+ }
17
20
 
18
21
  clone,
19
22
  canvas {
@@ -27,7 +27,10 @@ var prototype = {
27
27
  return child;
28
28
  },
29
29
  appendChild(child) {
30
+ var _appendChild = this.appendChild
31
+ delete this.appendChild;
30
32
  appendChild(this, child, false);
33
+ if (_appendChild) this.appendChild = _appendChild;
31
34
  return child;
32
35
  },
33
36
  appendTo(target) {
@@ -87,7 +87,6 @@ function drag(target, initialEvent, preventOverflow, isMovingSource) {
87
87
  dispatch("dragstart", target);
88
88
  }
89
89
  event.moveLocked = true;
90
- drag.target = clone;
91
90
  var offsetLeft = saved_delta.x + event.screenX;
92
91
  var offsetTop = saved_delta.y + event.screenY;
93
92
  var [c_left, c_top] = getOffset(clone);
@@ -297,6 +297,7 @@ function grid(breakpoints) {
297
297
  }
298
298
  } else {
299
299
  grid.setData(breakpoints);
300
+ grid.forEachCell(e => e.target = document.createElement('cell'));
300
301
  grid.reshape();
301
302
  }
302
303
  grid.setAttribute("grid", "");
@@ -448,7 +449,7 @@ var grid_prototype = {
448
449
  if (points instanceof Array) {
449
450
  points.forEach(run);
450
451
  }
451
- if (points.target) {
452
+ if (!points.length) {
452
453
  call.call(thisObj, points);
453
454
  }
454
455
  };
@@ -547,9 +548,6 @@ var grid_prototype = {
547
548
  current_b = temp_b;
548
549
  } else {
549
550
  var _div = point.target;
550
- if (!_div) {
551
- // point.target = _div = document.createElement('cell');
552
- }
553
551
  if (_div && _div.parentNode !== grid) appendChild(grid, _div);
554
552
  var current_value;
555
553
  if (current_d === "x") {
@@ -2,5 +2,7 @@ function main() {
2
2
  var page = grid([0, [0, 50, [0, 33.3333, 66.6667]]]);
3
3
  css(page, "width:500px;height:400px;background:#f2f080;");
4
4
  page.editable = true;
5
+ page.reshape();
6
+ console.log(page.children.length)
5
7
  return page;
6
8
  }
@@ -6,7 +6,7 @@ var assert = function (a, b) {
6
6
  else return console.info(i18n`验证通过`), 1;
7
7
  }
8
8
  var getElement = function (left, top, width, height) {
9
- var element1 = createElement(sample)
9
+ var element1 = sample.cloneNode();
10
10
  var cssText = `left:${left}px;top:${top}px;width:${width}px;height:${height}px;background:${color.random()};opacity:.6`;
11
11
  text(element1, cssText);
12
12
  css(element1, cssText);
@@ -1,4 +1,5 @@
1
- function remove(node, transition) {
1
+ function remove() {
2
+ var [node, transition] = arguments;
2
3
  if (!node) return;
3
4
  if (isNode(node)) {
4
5
  if (transition !== false) {
@@ -12,7 +12,7 @@ var abs = Math.abs;
12
12
  */
13
13
  function slider() {
14
14
  var [autoplay, circle = true] = arguments;
15
- var outter = container.cloneNode();
15
+ var outter = null;
16
16
  {
17
17
  for (let cx = 0, dx = arguments.length; cx < dx; cx++) {
18
18
  let arg = arguments[cx];
@@ -25,6 +25,7 @@ function slider() {
25
25
  }
26
26
  }
27
27
  }
28
+ if (!outter) outter = container.cloneNode();
28
29
  var _imageMain = _slider.cloneNode();
29
30
  var _imageHelp = _slider.cloneNode();
30
31
  outter.src = function (index) {
@@ -5,7 +5,7 @@ render(page, {
5
5
  btn: button,
6
6
  slider(element) {
7
7
  var images = [1, 2, 3].map(function (i) {
8
- var ele = createElement(div);
8
+ var ele = document.createElement("div");
9
9
  text(ele, i);
10
10
  return ele;
11
11
  });
@@ -1,12 +1,11 @@
1
1
  & {
2
- height: 100px;
3
2
  width: 100%;
4
3
  background: #000;
5
4
  color: #fff;
6
5
  text-align: center;
7
6
  line-height: 100px;
8
7
  font-size: 60px;
9
- position: absolute;
8
+ position: relative;
10
9
  >div{
11
10
  position: relative;
12
11
  display: inline-block;
@@ -14,6 +13,9 @@
14
13
  height: 80px;
15
14
  }
16
15
  }
16
+ btn{
17
+ font-size: 14px;
18
+ }
17
19
 
18
20
  .slider {
19
21
  width: 100%;
@@ -8,6 +8,7 @@ onappend(listY, function () {
8
8
  listY.go(0);
9
9
  });
10
10
  touchList(listY);
11
+ css(listY, "max-height", '360px');
11
12
  function touchList_test() {
12
13
  return listY;
13
14
  }
@@ -99,7 +99,7 @@
99
99
  z-index: 1;
100
100
  }
101
101
  </style>
102
- <form onclick="event.preventDefault()">
102
+ <form onsubmit="event.preventDefault()">
103
103
  <xmenu -src="(t,i) in tags" @active="saveTagIndex(i)"></xmenu>
104
104
  <h2 head>
105
105
  <span -bind="name"></span>
@@ -125,8 +125,8 @@
125
125
  </span>
126
126
  </p4>
127
127
  </div>
128
- <div body onkeyup="!event.isComposing&&updatecode()" onkeydown.tab="keytab(event)" #coder codearea
129
- -elseif="tags[1].actived">
128
+ <div body onkeyup="!event.isComposing&&updatecode(event)" onkeydown.tab="keytab(event)" onkeyup.enter="ontab(false)"
129
+ #coder codearea -elseif="tags[1].actived">
130
130
  </div>
131
131
  <resultpad -if="tags[1].actived" .result #coderesult></resultpad>
132
132
  <div foot -if="tags[1].actived">
@@ -197,31 +197,24 @@
197
197
  jschanged = false;
198
198
  var modName = name.replace(/\.js$/i, '_test');
199
199
  if (doc.test) {
200
- var jstext = [], lessdata = [], htmldata = [];
200
+ var lessdata = [], htmldata = [];
201
+ jstext = [];
201
202
  for (var f of doc.test) {
202
- var xhr = await cross("get", "./components:" + name.replace(/[^\\\/]+$/, '') + f);
203
- if (/\.js$/i.test(f)) {
204
- jstext.push(xhr.response);
203
+ if (/\.xht$/i.test(f)) {
204
+ if (isProduction) alert(i18n`这个文件内的测试代码暂不支持在线查看`, 'error');
205
+ else jstext.push(`return ${modName.replace(/\//g, '$')}`);
205
206
  }
206
- else if (/\.less$/i.test(f)) {
207
- lessdata.push(xhr.response);
208
- }
209
- else if (/\.html$/i.test(f)) {
210
- htmldata.push(xhr.response);
211
- }
212
- else if (/\.xht$/i.test(f)) {
213
- alert(i18n`这个文件内的测试代码暂不支持`, 'error');
214
- break;
215
- htmldata.push(xhr.response
216
- .replace(/\<script\>([\s\S]*?)\<\/script\>/ig, function (_, s) {
217
- jstext.push(s);
218
- return '';
219
- })
220
- .replace(/\<style\>([\s\S]*?)\<\/style\>/ig, function (_, s) {
221
- lessdata.push(s);
222
- return '';
223
- }));
224
-
207
+ else {
208
+ var xhr = await cross("get", "./components:" + name.replace(/[^\\\/]+$/, '') + f);
209
+ if (/\.js$/i.test(f)) {
210
+ jstext.push(xhr.response);
211
+ }
212
+ else if (/\.less$/i.test(f)) {
213
+ lessdata.push(xhr.response);
214
+ }
215
+ else if (/\.html$/i.test(f)) {
216
+ htmldata.push(xhr.response);
217
+ }
225
218
  }
226
219
  }
227
220
  jstext = jstext.join("\r\n");
@@ -252,7 +245,7 @@
252
245
  else if (vars.main) jstext += '\r\nreturn main';
253
246
  else if (vars.Main) jstext += '\r\nreturn Main';
254
247
  else if (vars.MAIN) jstext += "\r\nreturn MAIN";
255
- else if (vars[modName]) jstext += "\r\nreturn " + modName;
248
+ else if (vars[commName]) jstext += "\r\nreturn " + commName;
256
249
  }
257
250
  var templateName = commName;
258
251
  if (envs.template) templateName = 'template';
@@ -376,13 +369,48 @@
376
369
  c.scrollLeft = scrollLeft;
377
370
  c.contentEditable = true;
378
371
  };
379
- var updatecode = lazy(function () {
372
+ var trimspace = (_, a) => a ? "" : " ";
373
+ var ensp = s => Array(s + 1).join("\u2002"/*&ensp*/);
374
+ var getEnspBefore = function (node) {
375
+ if (!node) return 0;
376
+ while (node && (node.nodeType !== 1 || !/^br$/i.test(node.tagName))) {
377
+ console.log(node)
378
+ node = node.previousSibling;
379
+ }
380
+ if (node) {
381
+ var next = node.nextSibling;
382
+ if (next) {
383
+ next = /^\u2002+/.exec(next.nodeValue);
384
+ if (next) return next[0].length;
385
+ }
386
+ }
387
+ };
388
+ var ontab = function (forcetab) {
389
+ var selection = document.getSelection();
390
+ var { anchorNode, anchorOffset } = selection;
391
+ if (anchorNode.nodeType === 1) {
392
+ var child = anchorNode.childNodes[anchorOffset];
393
+ var spaceSize = 4;
394
+ if (child.nodeType === 1) spaceSize = getEnspBefore(child?.previousSibling?.previousSibling || anchorNode);
395
+ if (!spaceSize && forcetab !== false) spaceSize = 4;
396
+ if (!spaceSize) return;
397
+ var space = document.createTextNode(ensp(spaceSize));
398
+ anchorNode.insertBefore(space, child);
399
+ selection.setBaseAndExtent(space, spaceSize, space, spaceSize);
400
+ }
401
+ else if (anchorNode.nodeType === 3) {
402
+ if (forcetab === 0) return;
403
+ anchorNode.nodeValue = anchorNode.nodeValue.slice(0, anchorOffset) + ensp(4) + anchorNode.nodeValue.slice(anchorOffset);
404
+ anchorOffset += 4;
405
+ selection.setBaseAndExtent(anchorNode, anchorOffset, anchorNode, anchorOffset);
406
+ }
407
+ };
408
+ var updatecode = lazy(function (event) {
380
409
  var trimreg = /[\s\u00a0\u2002\u0080]+([\}\{\;\[\]\(\)\,\>\<\+\-\*\&\^\/%!~:?])*/g;
381
410
  var innerText = coder.innerText;
382
411
  if (jstext.replace(trimreg, trimspace).trim() === innerText.replace(trimreg, trimspace).trim()) return;
383
412
  markAnchorOffset();
384
413
  var innerText = coder.innerText;
385
- var trimspace = (_, a) => a ? "" : " ";
386
414
  unmarkAnchorOffset();
387
415
  initcode(innerText);
388
416
  unmarkAnchorOffset();
@@ -431,6 +459,7 @@
431
459
  };
432
460
  var keytab = function (event) {
433
461
  event.preventDefault();
462
+ ontab();
434
463
  };
435
464
 
436
465
  var saveTagIndex = function (i) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.8.3",
3
+ "version": "4.9.2",
4
4
  "description": "简化前端开发,优化web性能",
5
5
  "main": "public/efront.js",
6
6
  "directories": {