efront 4.23.8 → 4.23.9

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.
@@ -80,7 +80,6 @@
80
80
  var modify = async function (m) {
81
81
  var elem = document.createElement('jsoncode');
82
82
  elem.type = 'json';
83
- elem.contentEditable = true;
84
83
  elem.setAttribute('nodrag', '');
85
84
  茨菰$编辑框(elem);
86
85
  elem.setValue(JSON.stringify(m, null, 4));
@@ -105,9 +104,9 @@
105
104
  var add = async function () {
106
105
  var elem = document.createElement('jsoncode');
107
106
  elem.type = 'json';
108
- elem.contentEditable = true;
107
+ 茨菰$编辑框(elem);
109
108
  var changed = false;
110
- await prompt(茨菰$编辑框(elem), '输入JSON格式的数据', function (text) {
109
+ await prompt(elem, '输入JSON格式的数据', function (text) {
111
110
  try {
112
111
  JSON.parse(text);
113
112
  return true;
@@ -156,11 +156,19 @@ function translate([imap, supports], code) {
156
156
  var a = v.replace(/^[\$&]+/, '');
157
157
  var a = (a << 1) - 1;
158
158
  if (a in t) v = t[a];
159
- else v = scanner2(JSON.stringify(v));
159
+ else v = scanner2(`(${JSON.stringify(v)})`)[0];
160
160
  }
161
161
  else if (/^(name|holder|comment)$/.test(k)) v = ctn('i18n' + getm(v, t.nodup, t.warn), t);
162
- else v = scanner2(JSON.stringify(v));
163
- o.push({ type: PROPERTY, isprop: true, text: JSON.stringify(k) }, { type: STAMP, text: ':' }, ...v, { type: STAMP, text: ',' });
162
+ else v = scanner2(`(${JSON.stringify(v)})`)[0];
163
+ o.push({
164
+ type: PROPERTY,
165
+ isprop: true,
166
+ text: JSON.stringify(k),
167
+ }, {
168
+ type: STAMP, text: ':'
169
+ }, ...v, {
170
+ type: STAMP, text: ','
171
+ });
164
172
  })
165
173
  o.pop();
166
174
  setqueue(o);
@@ -56,7 +56,13 @@ function confirm() {
56
56
  element.style.width = fromPixel(width + 260);
57
57
  body.innerHTML = message;
58
58
  } else if (isNode(message)) {
59
- appendChild(body, message);
59
+ if (message.nodeType === 1) {
60
+ addClass(message, 'body');
61
+ appendChild.replace(body, message);
62
+ }
63
+ else {
64
+ appendChild(body, message);
65
+ }
60
66
  } else {
61
67
  throw new Error(i18n`消息体不合法!`);
62
68
  }
@@ -6,7 +6,9 @@
6
6
  padding: 8px 0;
7
7
  border-bottom: 1px solid #0001;
8
8
  }
9
-
9
+ &:empty{
10
+ display: none;
11
+ }
10
12
  >.head,
11
13
  >.foot {
12
14
  padding: 2px 16px;
@@ -13,9 +13,9 @@ var getCursorPosition = function () {
13
13
  focusNode.nodeValue = nodeValue.slice(0, focusOffset);
14
14
  focusNode.parentNode.insertBefore(cursor, focusNode.nextSibling);
15
15
  position = getScreenPosition(cursor);
16
- cursor.parentNode.removeChild(cursor);
17
16
  focusNode.nodeValue = nodeValue;
18
17
  }
18
+ if (cursor.parentNode) cursor.parentNode.removeChild(cursor);
19
19
  selection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset)
20
20
  return position;
21
21
  };
@@ -187,7 +187,7 @@ function main() {
187
187
  if (s.actived) {
188
188
  elem.selected = s.actived;
189
189
  }
190
- else if (direction === 't') {
190
+ else if (direction === 't' || istag) {
191
191
  elem.selected = s[0];
192
192
  if (elem.selected) elem.selected.setActive(true);
193
193
  }
@@ -17,6 +17,18 @@ var validate = function (text, checker, tip) {
17
17
  valid = settip(tip, valid);
18
18
  return valid;
19
19
  };
20
+ var fixContainer = function (elem, ipt) {
21
+ var lastChild = ipt.lastChild;
22
+ if (!lastChild) return;
23
+ var deltaHeight = lastChild.offsetHeight + lastChild.offsetTop - ipt.clientHeight;
24
+ if (Math.abs(deltaHeight) < 1) return;
25
+ var offsetHeight = elem.offsetHeight;
26
+ var targetHeight = offsetHeight + deltaHeight;
27
+ if (targetHeight > innerHeight) targetHeight = +innerHeight;
28
+ else if (offsetHeight > 260 && targetHeight < 260) targetHeight = 260;
29
+ css(elem, { height: targetHeight });
30
+ move.fixPosition(elem);
31
+ };
20
32
  function prompt() {
21
33
  var msg = i18n`请输入`, check, ipt;
22
34
  var opts = [];
@@ -53,30 +65,7 @@ function prompt() {
53
65
  var getValue = () => isFunction(ipt.getValue) ? ipt.getValue() : ipt.value;
54
66
  if (check || wrap) {
55
67
  var setDisable = function (event) {
56
- var bd = c.body;
57
- if (wrap && bd) {
58
- if (p) move.setPosition(c, p);
59
- var cp = getCursorPosition();
60
- var bp = getScreenPosition(bd);
61
- var s = getComputedStyle(ipt);
62
- var pl = parseFloat(s.paddingLeft) * 2 + ipt.clientLeft + ipt.offsetLeft;
63
- var pr = parseFloat(s.borderRightWidth) + parseFloat(s.paddingRight) * 2 + (bd.scrollWidth - ipt.offsetLeft - ipt.offsetWidth);
64
- var pt = parseFloat(s.paddingTop) * 2 + ipt.clientTop + ipt.offsetTop;
65
- var pb = parseFloat(s.borderBottomWidth) + parseFloat(s.paddingBottom) * 2 + (bd.scrollHeight - ipt.offsetTop - ipt.offsetHeight);
66
-
67
- if (cp.left < bp.left + pl) {
68
- bd.scrollLeft -= bp.left + pl - cp.left;
69
- }
70
- if (cp.right > bp.right - pr) {
71
- bd.scrollLeft += cp.right + pr - bp.right;
72
- }
73
- if (cp.top < bp.top + pt) {
74
- bd.scrollTop -= bp.top + pt - cp.top;
75
- }
76
- if (cp.bottom > bp.bottom - pb) {
77
- bd.scrollTop += cp.bottom + pb - cp.bottom;
78
- }
79
- }
68
+ fixContainer(c, ipt);
80
69
  if (!check) return;
81
70
  var valid = validate(getValue(), check, tip);
82
71
  if (event) attr(body, "error", !valid);
@@ -120,11 +109,15 @@ function prompt() {
120
109
  oncemount(c, function () {
121
110
  requestAnimationFrame(function () {
122
111
  p = move.getPosition(c);
112
+ css(c, {
113
+ height: c.offsetHeight
114
+ });
123
115
  });
124
116
  once('dragend')(c, function () {
125
117
  p = move.getPosition(c);
126
- })
127
- })
118
+ });
119
+ });
120
+ resize.on(c);
128
121
  }
129
122
  return c;
130
123
  }
@@ -12,23 +12,36 @@ tip {
12
12
  }
13
13
  }
14
14
 
15
- [body],
16
- .body {
17
- >div {
15
+ >[body],
16
+ >.body {
17
+ height: 100%;
18
+ >[textarea] {
18
19
  height: 100%;
19
20
  }
20
- }
21
21
 
22
+ >.编辑框 {
23
+ margin: 0 -16px;
24
+ width: auto;
25
+ height: 100%;
26
+ >list{
27
+ min-height: auto;
28
+ }
29
+ }
30
+ }
22
31
  textarea,
23
32
  [textarea] {
24
33
  width: 100%;
25
34
  resize: none;
35
+ border: 1px solid #ddd;
36
+
37
+ &:focus {
38
+ border-color: #09c;
39
+ outline: none;
40
+ }
26
41
  }
27
42
 
28
43
  >[body],
29
- >.body {
30
- max-height: 360px;
31
- }
44
+ >.body {}
32
45
 
33
46
  [textarea] {
34
47
  min-height: 80px;
@@ -32,7 +32,8 @@ var createTemplateNodes = function (text) {
32
32
  this.with = [node];
33
33
  return;
34
34
  } else {
35
- var node = document.createElement(this.parentNode.tagName || "div");
35
+ var parentNode = this.parentNode;
36
+ var node = parentNode ? parentNode.cloneNode(false) : document.createElement("div");
36
37
  node.innerHTML = text;
37
38
  this.with = Array.apply(null, node.childNodes);
38
39
  }
@@ -53,7 +54,10 @@ var createCloner = function (node) {
53
54
  };
54
55
 
55
56
  presets.template = function (t) {
56
- var comment = document.createComment('template');
57
+ var comment = document.createComment('');
58
+ // <!--
59
+ comment = document.createComment('template');
60
+ // -->
57
61
  $scoped.set(comment, $scoped.get(t));
58
62
  $parented.set(comment, $parented.get(t));
59
63
  t.$comment = comment;
@@ -215,7 +219,10 @@ var createGetter = function (target, search, isprop = true) {
215
219
  return toUndefined;
216
220
  };
217
221
  var createComment = function (type, expression) {
218
- var comment = document.createComment(`${type} ${expression}`);
222
+ var comment = document.createComment(``);
223
+ //<!--
224
+ comment = document.createComment(`${type} ${expression}`);
225
+ // -->
219
226
  $scoped.set(comment, $scoped.get(this));
220
227
  $structed.set(comment, $structed.get(this));
221
228
  $parented.set(comment, $parented.get(this));
@@ -402,9 +409,10 @@ var createRepeat = function (search, id = 0, struct) {
402
409
  initialComment(comment, renders, struct);
403
410
  return comment;
404
411
  };
412
+ var $elements = new WeakMap;
405
413
 
406
414
  var ifget = function () {
407
- var elements = this.$elements;
415
+ var elements = $elements.get(this);
408
416
  var shouldMount = -1;
409
417
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
410
418
  var getter = elements[cx + 1];
@@ -416,7 +424,7 @@ var ifget = function () {
416
424
  return shouldMount;
417
425
  }
418
426
  var ifset = function (shouldMount) {
419
- var elements = this.$elements;
427
+ var elements = $elements.get(this);
420
428
  for (var cx = 0, dx = elements.length; cx < dx; cx += 2) {
421
429
  var c = elements[cx];
422
430
  if (cx === shouldMount) {
@@ -444,7 +452,7 @@ var createIf = function (search, id = 0, struct) {
444
452
  var renders = [new Binder2(ifget, ifset)];
445
453
  var comment = elements[0] = createComment.call(element, 'if', search);
446
454
  comment.$id = id;
447
- comment.$elements = elements;
455
+ $elements.set(comment, elements);
448
456
  if (struct.once) renders.r1 = true;
449
457
  initialComment(comment, renders, struct);
450
458
  return comment;
@@ -128,6 +128,7 @@ function go(pagepath, args, history_name, oldpagepath) {
128
128
  return zimoli(pagepath, args, history_name, oldpagepath);
129
129
  }
130
130
  var page = create(pagepath, args, oldpagepath, roles, params, history_name);
131
+ if (!page) return;
131
132
  zimoliad = zimoliid;
132
133
  var isRecover = pushstate(pagepath, history_name, oldpagepath);
133
134
  if (isNode(history_name)) {
@@ -511,6 +512,7 @@ var pushstate = function (path_name, history_name) {
511
512
  if (_history[_history.index] !== path_name) {
512
513
  _history.splice(_history.index, _history.length - _history.index);
513
514
  _history[_history.index] = path_name;
515
+ index = _history.index;
514
516
  }
515
517
  _history.lastIndex = index;
516
518
  }
@@ -137,6 +137,7 @@ return function (elem, forcetab) {
137
137
  return;
138
138
  }
139
139
  if (forcetab === false) {
140
+ if (!rowNode) return;
140
141
  if (!rowNode.innerText) remove(rowNode.childNodes);
141
142
  [parentNode, child, spaceSize] = getPrevEnsp(rowNode);
142
143
  if (!spaceSize) return;
@@ -5,6 +5,8 @@
5
5
  border-bottom: 0;
6
6
  display: block;
7
7
  padding: 0;
8
+ max-height: 100%;
9
+ min-height: 6em;
8
10
  }
9
11
 
10
12
  &.noinput {
@@ -33,7 +35,6 @@
33
35
  >[clist] {
34
36
  display: inline-block;
35
37
  vertical-align: top;
36
- min-height: 100%;
37
38
  outline: none;
38
39
 
39
40
  >n,
@@ -48,7 +49,7 @@
48
49
  margin-left:-@{w}em;
49
50
  border-left: @{w}em solid transparent;
50
51
  width: 100%;
51
- overflow-x: scroll;
52
+ overflow-x: auto;
52
53
  }
53
54
 
54
55
  >[nlist] {
@@ -73,6 +74,7 @@
73
74
 
74
75
  >list {
75
76
  display: inline-block;
77
+ min-height: 100%;
76
78
  border-top: 6px solid #2c2d2c;
77
79
 
78
80
  &[nlist] {
@@ -80,6 +82,10 @@
80
82
  border-color: #222;
81
83
  }
82
84
 
85
+ &[clist] {
86
+ border-right: 2px solid transparent;
87
+ }
88
+
83
89
  >d {
84
90
  outline: none;
85
91
  border: none;
@@ -104,7 +110,7 @@
104
110
  <list contenteditable="false" nlist# :src="(r,i) in coderows" -style="{height:codeHeight}">
105
111
  <n current:="isCurrent(i)" -bind="i+1"></n>
106
112
  </list>
107
- <list clist# contenteditable="true" :src="(r,i) in coderows" -style="{height:codeHeight}">
113
+ <list clist# body contenteditable="true" :src="(r,i) in coderows" -style="{height:codeHeight}">
108
114
  <d -html="r"></d>
109
115
  </list>
110
116
  </编辑框>
@@ -130,8 +136,10 @@
130
136
  if (typeof text === 'string') coder.innerHTML = 渲染.encode(text);
131
137
  }
132
138
  });
133
- var refresh = function () {
134
- codeHeight = coderows.length * 1.36 + 10 + 'em';
139
+ var reshape = function () {
140
+ codeHeight = coderows.length * 1.36 + 2;
141
+ if (codeHeight < 6) codeHeight = 6;
142
+ codeHeight += 'em';
135
143
  codeSpan = (coderows.length).toString().length;
136
144
  };
137
145
  on('scroll')(coder, function () {
@@ -142,7 +150,7 @@
142
150
  if (!selection) return false;
143
151
  return i >= selection[0] && i <= selection[2];
144
152
  };
145
- var coderows = [], codetext = '';
153
+ var coderows = [""], codetext = '';
146
154
  coder.setValue = async function (text) {
147
155
  codetext = text;
148
156
  var id = ++coderid;
@@ -151,7 +159,7 @@
151
159
  coderows = colored;
152
160
  codeHistory = [[codetext]];
153
161
  historyIndex = 0;
154
- refresh();
162
+ reshape();
155
163
  render.refresh(coder);
156
164
  };
157
165
  coder.getValue = function () {
@@ -200,17 +208,37 @@
200
208
  if (!c) return [d, d.childNodes.length];
201
209
  return [c, col - inc];
202
210
  }
211
+ var anchor = document.createElement('span');
203
212
  var unmarkAnchorOffset = function () {
204
213
  if (!selection) return;
205
214
  var [an, ai, fn, fi] = selection;
206
215
  [fn, fi] = getNodeAt(fn, fi);
207
216
  [an, ai] = fn === an && fi === ai ? [fn, fi] : getNodeAt(an, ai);
208
- document_selection.setBaseAndExtent(an, ai, fn, fi);
217
+ if (an && an === fn && ai === fi) {
218
+ var d = getTargetIn(clist, an, false);
219
+ if (an === d) {
220
+ d.insertBefore(anchor, d.childNodes[ai]);
221
+ }
222
+ else {
223
+ an.parentNode.insertBefore(anchor, an.nextSibling);
224
+ }
225
+ if (anchor.offsetLeft > clist.clientWidth + clist.scrollLeft + d.offsetLeft) {
226
+ clist.scrollLeft = anchor.offsetLeft - clist.clientWidth + 6;
227
+ }
228
+ else if (anchor.offsetLeft < clist.scrollLeft) {
229
+ clist.scrollLeft = anchor.offsetLeft;
230
+ }
231
+ anchor.parentNode.removeChild(anchor);
232
+ if (d.offsetTop < coder.scrollTop + clist.offsetTop) {
233
+ coder.scrollTop = d.offsetTop - clist.offsetTop;
234
+ }
235
+ }
236
+ if (an && fn) document_selection.setBaseAndExtent(an, ai, fn, fi);
209
237
  }
210
238
  var trimspace = (_, a) => a ? "" : " ";
211
239
  var 更新 = function () {
212
240
  var { scrollTop, scrollLeft } = clist;
213
- refresh();
241
+ reshape();
214
242
  render.refresh(coder);
215
243
  clist.scrollTop = scrollTop;
216
244
  clist.scrollLeft = scrollLeft;
@@ -220,6 +248,8 @@
220
248
  var fixpace = function (event) {
221
249
  event.preventDefault();
222
250
  insertText(' ', false);
251
+ markAnchorOffset();
252
+ unmarkAnchorOffset();
223
253
  };
224
254
  var updatechar = function (event) {
225
255
  if (event.defaultPrevented) return;
@@ -242,6 +272,7 @@
242
272
  }
243
273
  else {
244
274
  anchorNode = anchorNode.previousSibling;
275
+ if (!anchorNode) return;
245
276
  if (anchorNode.nodeType === 1) anchorOffset = anchorNode.childNodes.length;
246
277
  else anchorOffset = anchorNode.nodeValue.length;
247
278
  }
@@ -318,7 +349,7 @@
318
349
  var [k, p] = a.split('');
319
350
  pairsmap[k] = p;
320
351
  });
321
- var codeHistory = [""];
352
+ var codeHistory = [[""]];
322
353
  var historyIndex = 0;
323
354
  var getRow = function (node) {
324
355
  var d = getTargetIn(clist, node, false);
@@ -545,5 +576,13 @@
545
576
  on('keydown.ctrl.z.prevent.only')(coder, undo);
546
577
  on('keydown.ctrl.shift.z.prevent.only')(coder, redo);
547
578
  on('keydown.ctrl.y.prevent.only')(coder, redo);
548
- on('keydown')(coder, updatechar)
579
+ on('keydown.backspace')(coder, function (event) {
580
+ var { firstChild, lastChild } = clist;
581
+ if (firstChild === lastChild && !firstChild.childNodes.length) {
582
+ event.preventDefault();
583
+ return;
584
+ }
585
+ });
586
+ on('keydown')(coder, updatechar);
587
+ reshape();
549
588
  </script>
@@ -10,7 +10,7 @@
10
10
  z-index: 2;
11
11
  }
12
12
 
13
- [body] {
13
+ >[body] {
14
14
  border-top: 42px solid transparent;
15
15
  padding-top: 40px;
16
16
  overflow: auto;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "efront",
3
- "version": "4.23.8",
3
+ "version": "4.23.9",
4
4
  "description": "一个开发环境,提供一种自由的前端开发模式,也可作为辅助工具使用。",
5
5
  "main": "public/efront.js",
6
6
  "directories": {