efront 4.22.3 → 4.22.4

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.
@@ -8,7 +8,7 @@ model.setReader('jscode', "text");
8
8
  return plist.bind(null, '任务管理', "task", refilm`
9
9
  *任务ID/key 100
10
10
  *任务名/name 100
11
- *是否启用/status radio 不启用,启用
11
+ *是否启用/status radio 不启用#ccc,启用#396
12
12
  任务代码/code jscode
13
13
  / $ ${[
14
14
  {
@@ -19,11 +19,16 @@ function scanBlock(piece) {
19
19
  res.push(a);
20
20
  };
21
21
  var avoid = false;
22
+ var instr = null;
22
23
  for (var cx = 0, dx = piece.length; cx < dx; cx++) {
23
24
  reg.lastIndex = cx;
24
25
  var m = reg.exec(piece);
25
26
  if (m) {
26
27
  var s = m[0];
28
+ if (instr) {
29
+ if (instr === s) instr = null;
30
+ continue;
31
+ }
27
32
  if (/^(\s+|\^)$/.test(s)) {
28
33
  if (s === '^') {
29
34
  avoid = res.length;
@@ -32,12 +37,10 @@ function scanBlock(piece) {
32
37
  save(piece.slice(lastIndex, reg.lastIndex));
33
38
  }
34
39
  lastIndex = reg.lastIndex;
35
- } else if (/^["']$/i.test(s)) {
36
- var i = piece.indexOf(s, cx + 1);
37
- if (i > 0) {
38
- cx = i;
39
- continue;
40
- }
40
+ }
41
+ else if (/^[`"']$/i.test(s)) {
42
+ instr = s;
43
+ continue;
41
44
  }
42
45
  cx = m.index + s.length - 1;
43
46
  } else {
@@ -51,29 +54,39 @@ function scanBlock(piece) {
51
54
 
52
55
  function scanSlant(str, s, lastIndex = 0, end = str.length) {
53
56
  s = s.replace(/[\/]/g, '\\$&');
54
- var reg = new RegExp(`${/\\[\s\S]/.source}|${s}`, 'g');
57
+ var reg = new RegExp(`${/\\[\s\S]/.source}|[${s}'"\`]`, 'g');
55
58
  var reg1 = new RegExp(`^${s}$`);
56
59
  var res = [];
57
60
  var start = lastIndex, start;
61
+ var instr = false;
58
62
  while (lastIndex < end) {
59
63
  reg.lastIndex = lastIndex;
60
64
  var match = reg.exec(str);
61
65
  if (!match) {
62
66
  break;
63
67
  }
68
+ var [s] = match;
69
+ if (instr) {
70
+ if (instr === s) instr = null;
71
+ continue;
72
+ }
73
+ if (/^['"`]$/.test(s)) {
74
+ instr = s;
75
+ continue;
76
+ }
64
77
  lastIndex = match.index + match[0].length;
65
- if (!reg1.test(match[0])) {
78
+ if (!reg1.test(s)) {
66
79
  continue;
67
80
  }
68
81
  if (lastIndex === start) {
69
82
  lastIndex++;
70
83
  continue;
71
84
  }
72
- res.push(str.slice(start, match.index).replace(/\\([\s\S])/g, '$1'));
85
+ res.push(strings.decode(str.slice(start, match.index)));
73
86
  start = lastIndex;
74
87
  }
75
88
  if (start < end) {
76
- res.push(str.slice(start, end).replace(/\\([\s\S])/g, '$1'));
89
+ res.push(strings.decode(str.slice(start, end)));
77
90
  }
78
91
  return res;
79
92
  }
@@ -121,15 +134,28 @@ var createEval = function (express, value) {
121
134
  name: express
122
135
  });
123
136
  };
124
-
125
- var createOption = function (o) {
137
+ var getColorFromTail = function (o) {
138
+ var m;
139
+ if (m = /\#(?:[0-9a-f]{3,4}){1,2}$/.exec(o)) {
140
+ o = o.slice(0, m.index);
141
+ return [o, color.format(m[0])];
142
+ }
143
+ return [o];
144
+ }
145
+ var createOption = function (o, i) {
126
146
  if (isObject(o)) {
147
+ if (!o.color) [o.name, o.color] = getColorFromTail(o.name);
127
148
  o.toString = toName;
128
149
  o.valueOf = toValue;
129
150
  return o;
130
151
  }
152
+ var [name, color] = getColorFromTail(o);
153
+ if (!color && !/[,\/]/.test(o)) return name;
154
+ var [name, key = i] = spreadkey(name);
131
155
  return {
132
- name: o,
156
+ name,
157
+ key,
158
+ color,
133
159
  valueOf: toValue,
134
160
  toString: toName
135
161
  };
@@ -139,9 +165,9 @@ function unfoldOptions(size, options) {
139
165
  for (var cx = 0, dx = options.length; cx < dx; cx++) {
140
166
  var o = options[cx];
141
167
  if (typeof o === 'string') {
142
- var [name, key = name] = spreadkey(o);
168
+ var [name, key = name, needs, color] = spreadkey(o);
143
169
  if (parseInt(key) === +key) key = +key;
144
- o = { name, key };
170
+ o = { name, key, color, needs };
145
171
  }
146
172
  var range = rangereg.exec(o.name);
147
173
  if (range) {
@@ -269,13 +295,14 @@ function spreadkey(name) {
269
295
  }
270
296
  return [name, key, needs, holder];
271
297
  }
272
- function parseOptions(options) {
273
- if (typeof options === "string" && !/^[\$#]+\d+$/.test(options)) {
298
+ function parseOptions(size, options) {
299
+ if (typeof options === "string" && !/^[\$&]+\d+$/.test(options)) {
274
300
  var needUnfold = /^\[|\]$/.test(options);
275
301
  options = options.replace(/^\[|\]$/g, '');
276
302
  if (needUnfold || /,/.test(options)) options = scanSlant(options, ',');
277
303
  else options = scanSlant(options, "");
278
304
  if (needUnfold) unfoldOptions(size, options);
305
+ else options = options.map(createOption);
279
306
  }
280
307
  return options;
281
308
  }
@@ -333,7 +360,7 @@ function parse(piece) {
333
360
  return [, a];
334
361
  };
335
362
  var is = function (a) {
336
- var reg = /^\$(?!\d)|[\*\+\-\!\-\$&\?\~\:;]|^[\*\+\-\!\-&\?\~]$/;
363
+ var reg = /^\$(?!\d)|\$$|^[\*\+\-\!\-&\?\~]|[\*\+\-\!\-&\?\~\:;]$|^[\*\+\-\!\-&\?\~]$/;
337
364
  if (!reg.test(a)) return a;
338
365
  [colon, a] = test(/\;$/, a);
339
366
  if (colon) colon = false;
@@ -342,9 +369,10 @@ function parse(piece) {
342
369
  [inlist, a] = test(/^[\+]|[\+]$/, a);
343
370
  [inlist, a] = test(/^[\!]|[\!]$/, a);
344
371
  [hidden, a] = test(/^\-|\-$/, a);
345
- [readonly, a] = test(/^&|\$(?!\d)|[\$&]$/, a);
372
+ [readonly, a] = test(/^&|^\$(?!\d)|[\$&]$/, a);
346
373
  [delete_onempty, a] = test(/^\?|\?$/, a);
347
374
  [delete_onsubmit, a] = test(/^\~|\~$/, a);
375
+
348
376
  return a.replace(reg, '');
349
377
  };
350
378
  var type1 = is(type);
@@ -451,8 +479,8 @@ function parse(piece) {
451
479
  editable = true;
452
480
  options = options.replace(/^[\+\-\*]|[\+\*\-]$/g, '');
453
481
  }
454
- options = parseOptions(options);
455
- avoid = parseOptions(avoid1 || avoid);
482
+ options = parseOptions(size, options);
483
+ avoid = parseOptions(size, avoid1 || avoid);
456
484
  name = is(name);
457
485
  key = is(key);
458
486
  }
@@ -22,3 +22,4 @@ test(refilm`连城剑法 别名 ^[唐诗剑法/0,躺尸剑法/1]`, ['avoid', 1,
22
22
  test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^[a,b]`, ['options', 1, 'key'], 1);
23
23
  test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^[a,b]`, ['avoid', 1, 'key'], 'b');
24
24
  test(refilm`连城剑法 别名 [唐诗剑法/0,躺尸剑法/1] ^${[{ key: 'a' }, { key: 'c' }]}`, ['avoid', 1, 'key'], 'c');
25
+ test(refilm`连城剑法 别名 [唐诗剑法/0/#c29,躺尸剑法/1]`, ['options', 0, 'color'], '#c29');
@@ -75,7 +75,7 @@ function getI18nPrefixedText(code, dist = []) {
75
75
  return dist;
76
76
  }
77
77
  var ctn = function (tt, t) {
78
- var tn = scanner2(tt.replace(/[\$#]+(\d+)/g, (_, i) => {
78
+ var tn = scanner2(tt.replace(/[\$&]+(\d+)/g, (_, i) => {
79
79
  var a = (i << 1) - 1;
80
80
  if (a in t) return `\${${a}}`;
81
81
  return _;
@@ -152,8 +152,8 @@ function translate([imap, supports], code) {
152
152
  var o = scanner2('={}')[1];
153
153
  Object.keys(f).forEach(k => {
154
154
  var v = f[k];
155
- if (/[\$#]\d+/.test(v)) {
156
- var a = v.replace(/^[\$#]+/, '');
155
+ if (/[\$&]\d+/.test(v)) {
156
+ var a = v.replace(/^[\$&]+/, '');
157
157
  var a = (a << 1) - 1;
158
158
  if (a in t) v = t[a];
159
159
  else v = scanner2(JSON.stringify(v));
@@ -27,7 +27,7 @@ function button(texter, type) {
27
27
  _texter = _label.cloneNode();
28
28
  if (isString(texter)) {
29
29
  if (!type) {
30
- texter = texter.replace(/#\w*/, function (w) {
30
+ texter = texter.replace(/#\w*$/, function (w) {
31
31
  if (/^#([a-f\d]{3,4}){1,2}$/.test(w)) {
32
32
  type = w;
33
33
  }
@@ -222,7 +222,15 @@ var readonly_types = {
222
222
  if (!field.optionsMap) field.optionsMap = createOptionsMap(field.options);
223
223
  var o = field.optionsMap[v];
224
224
  try { this.setAttribute(field.key, v); } catch { }
225
- if (isObject(o)) return `<s></s>` + o.name;
225
+ if (isObject(o)) {
226
+ if (o.color) {
227
+ css(this, { color: o.color });
228
+ var b = document.createElement('label');
229
+ b.innerText = o.name;
230
+ return b;
231
+ }
232
+ return o.name;
233
+ }
226
234
  if (isHandled(o)) return o;
227
235
  }
228
236
  if (isEmpty(v)) v = '';
@@ -293,6 +301,19 @@ var getOptionsFrom = function () {
293
301
  var { data, field } = this;
294
302
  return data[field.options_from];
295
303
  };
304
+ function setModel(ipt) {
305
+ var elem = this;
306
+ if (isHandled(ipt) && ipt !== elem) {
307
+ if (isNode(ipt)) {
308
+ var model = new Model(getScopeValue, setScopeValue, ipt);
309
+ model.hook(elem, elem.field.option_to ? copyOptionData : true);
310
+ appendChild(elem, ipt);
311
+ }
312
+ else {
313
+ elem.innerText = ipt;
314
+ }
315
+ }
316
+ }
296
317
  function setBinder(elem, binder) {
297
318
  if (binder === elem.$binder) return;
298
319
  removeFromList(elem.$renders, elem.$binder);
@@ -303,17 +324,11 @@ function setBinder(elem, binder) {
303
324
  }
304
325
  else {
305
326
  var ipt = binder(elem);
306
- binder = null;
307
- if (isHandled(ipt) && ipt !== elem) {
308
- if (isNode(ipt)) {
309
- var model = new Model(getScopeValue, setScopeValue, ipt);
310
- model.hook(elem, elem.field.option_to ? copyOptionData : true);
311
- appendChild(elem, ipt);
312
- }
313
- else {
314
- elem.innerHTML = ipt;
315
- }
327
+ if (ipt && isFunction(ipt.then)) {
328
+ ipt.then(setModel.bind(elem));
316
329
  }
330
+ else setModel.call(elem, ipt);
331
+ binder = null;
317
332
  }
318
333
  elem.$binder = binder;
319
334
  }
@@ -78,4 +78,23 @@
78
78
  @u(3);
79
79
  @u(4);
80
80
  @u(5);
81
- @u(6);
81
+ @u(6);
82
+
83
+ &[readonly] {
84
+
85
+ &[type=radio] {
86
+ &:before {
87
+ vertical-align: middle;
88
+ content: '';
89
+ border-radius: 50%;
90
+ box-sizing: border-box;
91
+ border: 6px solid;
92
+ display: inline-block;
93
+ margin: 0 6px;
94
+ }
95
+
96
+ label {
97
+ color: #333;
98
+ }
99
+ }
100
+ }
@@ -244,4 +244,22 @@ thead {
244
244
  [type=number],
245
245
  [type=price] {
246
246
  float: right;
247
+ }
248
+
249
+ tbody,
250
+ [tbody] {
251
+
252
+ [type=jscode],
253
+ [type=function] {
254
+ display: -webkit-box;
255
+ -webkit-box-orient: vertical;
256
+ -webkit-line-clamp: 2;
257
+ text-overflow: ellipsis;
258
+ line-height: 16px;
259
+ font-size: 14px;
260
+ white-space: pre;
261
+ font-family: Consolas, "Courier New", monospace;
262
+ color: #666;
263
+ overflow: hidden;
264
+ }
247
265
  }
@@ -221,7 +221,8 @@
221
221
  }
222
222
  if (anchorOffset >= anchorNode.nodeValue.length) {
223
223
  followChar = anchorNode.nextSibling || anchorNode.parentNode.nextSibling;
224
- if (followChar.nodeType === 1) {
224
+ if (!followChar) followChar = '';
225
+ else if (followChar.nodeType === 1) {
225
226
  beforeText = /^text$/i.test(followChar.tagName);
226
227
  followChar = followChar.innerText.charAt(0);
227
228
  }
@@ -263,7 +264,6 @@
263
264
  var { data, inputType } = event;
264
265
  coderid++;
265
266
  var patchAfter = '';
266
- console.log("follow-char", followChar, 'data', data, 'anchor-char', anchorChar);
267
267
  switch (inputType) {
268
268
  case "insertText":
269
269
  if (data === ' ') return;
@@ -289,10 +289,7 @@
289
289
  if (anchorChar in pairsmap && followChar === pairsmap[anchorChar]) {
290
290
  document.execCommand('forwardDelete');
291
291
  }
292
- if (inText) return;
293
- updatechar();
294
- if (inText) return;
295
- break;
292
+ return;
296
293
 
297
294
  }
298
295
  markAnchorOffset(光标 + patchAfter);
@@ -307,7 +304,6 @@
307
304
  markedText = await 上色.text(coder.type, markedText);
308
305
  if (coderid !== id) return;
309
306
  更新(markedText);
310
- dispatch(coder, 'change');
311
307
  return;
312
308
  }, -60);
313
309
  var keytab = function (direction) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.22.3",
3
+ "version": "4.22.4",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {