@leafer-editor/worker 1.0.9 → 1.1.0

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/dist/worker.js CHANGED
@@ -111,7 +111,7 @@ var LeaferUI = (function (exports) {
111
111
  return rotation - oldRotation;
112
112
  },
113
113
  float(num, maxLength) {
114
- const a = maxLength ? pow$1(10, maxLength) : 1000000000000;
114
+ const a = maxLength !== undefined ? pow$1(10, maxLength) : 1000000000000;
115
115
  num = round(num * a) / a;
116
116
  return num === -0 ? 0 : num;
117
117
  },
@@ -1414,14 +1414,13 @@ var LeaferUI = (function (exports) {
1414
1414
  list: {},
1415
1415
  register(UI) {
1416
1416
  const { __tag: tag } = UI.prototype;
1417
- if (list$3[tag]) {
1417
+ if (list$3[tag])
1418
1418
  debug$f.repeat(tag);
1419
- }
1420
- else {
1421
- list$3[tag] = UI;
1422
- }
1419
+ list$3[tag] = UI;
1423
1420
  },
1424
1421
  get(tag, data, x, y, width, height) {
1422
+ if (!list$3[tag])
1423
+ debug$f.error('not register ' + tag);
1425
1424
  const ui = new list$3[tag](data);
1426
1425
  if (x !== undefined) {
1427
1426
  ui.x = x;
@@ -1445,7 +1444,7 @@ var LeaferUI = (function (exports) {
1445
1444
  Object.keys(Event).forEach(key => {
1446
1445
  name = Event[key];
1447
1446
  if (typeof name === 'string')
1448
- nameList[name] ? debug$e.repeat(name) : nameList[name] = Event;
1447
+ nameList[name] && debug$e.repeat(name), nameList[name] = Event;
1449
1448
  });
1450
1449
  },
1451
1450
  changeName(oldName, newName) {
@@ -1647,7 +1646,7 @@ var LeaferUI = (function (exports) {
1647
1646
  const t = this;
1648
1647
  if (t.blendMode === 'pass-through') {
1649
1648
  const leaf = this.__leaf;
1650
- if ((t.opacity < 1 && leaf.isBranch) || leaf.__hasEraser || t.eraser) {
1649
+ if ((t.opacity < 1 && (leaf.isBranch || t.__hasMultiPaint)) || leaf.__hasEraser || t.eraser) {
1651
1650
  t.__single = true;
1652
1651
  }
1653
1652
  else if (t.__single) {
@@ -2045,8 +2044,9 @@ var LeaferUI = (function (exports) {
2045
2044
  takeCanvas = this.getSameCanvas();
2046
2045
  takeCanvas.copyWorld(this);
2047
2046
  }
2048
- DataHelper.copyAttrs(this.size, size, canvasSizeAttrs);
2049
- this.size.pixelRatio || (this.size.pixelRatio = 1);
2047
+ const s = this.size;
2048
+ DataHelper.copyAttrs(s, size, canvasSizeAttrs);
2049
+ canvasSizeAttrs.forEach(key => s[key] || (s[key] = 1));
2050
2050
  this.bounds = new Bounds(0, 0, this.width, this.height);
2051
2051
  if (this.context && !this.unreal) {
2052
2052
  this.updateViewSize();
@@ -2160,6 +2160,17 @@ var LeaferUI = (function (exports) {
2160
2160
  if (!onlyResetTransform)
2161
2161
  this.useWorldTransform();
2162
2162
  }
2163
+ useGrayscaleAlpha(bounds) {
2164
+ this.setTempBounds(bounds, true, true);
2165
+ let alpha, pixel;
2166
+ const { context } = this, imageData = context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height), { data } = imageData;
2167
+ for (let i = 0, len = data.length; i < len; i += 4) {
2168
+ pixel = data[i] * 0.299 + data[i + 1] * 0.587 + data[i + 2] * 0.114;
2169
+ if (alpha = data[i + 3])
2170
+ data[i + 3] = alpha === 255 ? pixel : alpha * (pixel / 255);
2171
+ }
2172
+ context.putImageData(imageData, tempBounds$1.x, tempBounds$1.y);
2173
+ }
2163
2174
  useMask(maskCanvas, fromBounds, toBounds) {
2164
2175
  this.copyWorld(maskCanvas, fromBounds, toBounds, 'destination-in');
2165
2176
  }
@@ -2170,7 +2181,7 @@ var LeaferUI = (function (exports) {
2170
2181
  if (blendMode)
2171
2182
  this.blendMode = blendMode;
2172
2183
  this.fillStyle = color;
2173
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2184
+ this.setTempBounds(bounds);
2174
2185
  this.fillRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2175
2186
  if (blendMode)
2176
2187
  this.blendMode = 'source-over';
@@ -2179,22 +2190,18 @@ var LeaferUI = (function (exports) {
2179
2190
  if (blendMode)
2180
2191
  this.blendMode = blendMode;
2181
2192
  this.strokeStyle = color;
2182
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2193
+ this.setTempBounds(bounds);
2183
2194
  this.strokeRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2184
2195
  if (blendMode)
2185
2196
  this.blendMode = 'source-over';
2186
2197
  }
2187
2198
  clearWorld(bounds, ceilPixel) {
2188
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2189
- if (ceilPixel)
2190
- tempBounds$1.ceil();
2199
+ this.setTempBounds(bounds, ceilPixel);
2191
2200
  this.clearRect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2192
2201
  }
2193
2202
  clipWorld(bounds, ceilPixel) {
2194
2203
  this.beginPath();
2195
- tempBounds$1.set(bounds).scale(this.pixelRatio);
2196
- if (ceilPixel)
2197
- tempBounds$1.ceil();
2204
+ this.setTempBounds(bounds, ceilPixel);
2198
2205
  this.rect(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
2199
2206
  this.clip();
2200
2207
  }
@@ -2202,6 +2209,14 @@ var LeaferUI = (function (exports) {
2202
2209
  const { pixelRatio } = this;
2203
2210
  this.clearRect(0, 0, this.width * pixelRatio + 2, this.height * pixelRatio + 2);
2204
2211
  }
2212
+ setTempBounds(bounds, ceil, intersect) {
2213
+ tempBounds$1.set(bounds);
2214
+ if (intersect)
2215
+ tempBounds$1.intersect(this.bounds);
2216
+ tempBounds$1.scale(this.pixelRatio);
2217
+ if (ceil)
2218
+ tempBounds$1.ceil();
2219
+ }
2205
2220
  isSameSize(size) {
2206
2221
  return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
2207
2222
  }
@@ -4153,20 +4168,17 @@ var LeaferUI = (function (exports) {
4153
4168
  }
4154
4169
  return true;
4155
4170
  },
4156
- moveWorld(t, x, y = 0, isInnerPoint) {
4171
+ moveWorld(t, x, y = 0, isInnerPoint, transition) {
4157
4172
  const local = typeof x === 'object' ? Object.assign({}, x) : { x, y };
4158
4173
  isInnerPoint ? toOuterPoint$1(t.localTransform, local, local, true) : (t.parent && toInnerPoint$1(t.parent.worldTransform, local, local, true));
4159
- L$3.moveLocal(t, local.x, local.y);
4174
+ L$3.moveLocal(t, local.x, local.y, transition);
4160
4175
  },
4161
- moveLocal(t, x, y = 0) {
4162
- if (typeof x === 'object') {
4163
- t.x += x.x;
4164
- t.y += x.y;
4165
- }
4166
- else {
4167
- t.x += x;
4168
- t.y += y;
4169
- }
4176
+ moveLocal(t, x, y = 0, transition) {
4177
+ if (typeof x === 'object')
4178
+ y = x.y, x = x.x;
4179
+ x += t.x;
4180
+ y += t.y;
4181
+ transition ? t.animate({ x, y }, transition) : (t.x = x, t.y = y);
4170
4182
  },
4171
4183
  zoomOfWorld(t, origin, scaleX, scaleY, resize) {
4172
4184
  L$3.zoomOfLocal(t, getTempLocal(t, origin), scaleX, scaleY, resize);
@@ -5215,13 +5227,14 @@ var LeaferUI = (function (exports) {
5215
5227
  this.__.__checkSingle();
5216
5228
  },
5217
5229
  __render(canvas, options) {
5230
+ this.__nowWorld = this.__getNowWorld(options);
5218
5231
  if (this.__worldOpacity) {
5219
5232
  if (this.__.__single) {
5220
5233
  if (this.__.eraser === 'path')
5221
5234
  return this.__renderEraser(canvas, options);
5222
5235
  const tempCanvas = canvas.getSameCanvas(false, true);
5223
5236
  this.__renderBranch(tempCanvas, options);
5224
- const nowWorld = this.__getNowWorld(options);
5237
+ const nowWorld = this.__nowWorld;
5225
5238
  canvas.opacity = this.__.opacity;
5226
5239
  canvas.copyWorldByReset(tempCanvas, nowWorld, nowWorld, this.__.__blendMode, true);
5227
5240
  tempCanvas.recycle(nowWorld);
@@ -5545,11 +5558,11 @@ var LeaferUI = (function (exports) {
5545
5558
  transform(matrix, resize) {
5546
5559
  transform(this, matrix, resize);
5547
5560
  }
5548
- move(x, y) {
5549
- moveLocal(this, x, y);
5561
+ move(x, y, transition) {
5562
+ moveLocal(this, x, y, transition);
5550
5563
  }
5551
- moveInner(x, y) {
5552
- moveWorld(this, x, y, true);
5564
+ moveInner(x, y, transition) {
5565
+ moveWorld(this, x, y, true, transition);
5553
5566
  }
5554
5567
  scaleOf(origin, scaleX, scaleY, resize) {
5555
5568
  zoomOfLocal(this, getLocalOrigin(this, origin), scaleX, scaleY, resize);
@@ -5563,8 +5576,8 @@ var LeaferUI = (function (exports) {
5563
5576
  transformWorld(worldTransform, resize) {
5564
5577
  transformWorld(this, worldTransform, resize);
5565
5578
  }
5566
- moveWorld(x, y) {
5567
- moveWorld(this, x, y);
5579
+ moveWorld(x, y, transition) {
5580
+ moveWorld(this, x, y, false, transition);
5568
5581
  }
5569
5582
  scaleOfWorld(worldOrigin, scaleX, scaleY, resize) {
5570
5583
  zoomOfWorld(this, worldOrigin, scaleX, scaleY, resize);
@@ -5962,7 +5975,7 @@ var LeaferUI = (function (exports) {
5962
5975
  }
5963
5976
  }
5964
5977
 
5965
- const version = "1.0.9";
5978
+ const version = "1.1.0";
5966
5979
 
5967
5980
  class LeaferCanvas extends LeaferCanvasBase {
5968
5981
  get allowBackgroundColor() { return true; }
@@ -6431,7 +6444,8 @@ var LeaferUI = (function (exports) {
6431
6444
  this.totalBounds = new Bounds();
6432
6445
  debug$6.log(target.innerName, '--->');
6433
6446
  try {
6434
- target.app.emit(RenderEvent.CHILD_START, target);
6447
+ if (!target.isApp)
6448
+ target.app.emit(RenderEvent.CHILD_START, target);
6435
6449
  this.emitRender(RenderEvent.START);
6436
6450
  this.renderOnce(callback);
6437
6451
  this.emitRender(RenderEvent.END, this.totalBounds);
@@ -6985,6 +6999,12 @@ var LeaferUI = (function (exports) {
6985
6999
  return strokeWidth;
6986
7000
  }
6987
7001
  get __hasStroke() { return this.stroke && this.strokeWidth; }
7002
+ get __hasMultiPaint() {
7003
+ const t = this;
7004
+ if ((t.__isFills && t.fill.length > 1) || (t.__isStrokes && t.stroke.length > 1) || t.__useEffect)
7005
+ return true;
7006
+ return t.fill && this.__hasStroke;
7007
+ }
6988
7008
  get __clipAfterFill() { return (this.cornerRadius || this.__pathInputed); }
6989
7009
  get __autoWidth() { return !this._width; }
6990
7010
  get __autoHeight() { return !this._height; }
@@ -7354,9 +7374,8 @@ var LeaferUI = (function (exports) {
7354
7374
  canvas.strokeRect(half, half, width, height);
7355
7375
  canvas.restore();
7356
7376
  }
7357
- else {
7377
+ else
7358
7378
  canvas.strokeRect(half, half, width, height);
7359
- }
7360
7379
  break;
7361
7380
  case 'outside':
7362
7381
  canvas.strokeRect(-half, -half, width + __strokeWidth, height + __strokeWidth);
@@ -7386,11 +7405,15 @@ var LeaferUI = (function (exports) {
7386
7405
  super(data);
7387
7406
  }
7388
7407
  reset(_data) { }
7389
- set(data, isTemp) {
7390
- if (isTemp) {
7391
- this.lockNormalStyle = true;
7392
- Object.assign(this, data);
7393
- this.lockNormalStyle = false;
7408
+ set(data, transition) {
7409
+ if (transition) {
7410
+ if (transition === 'temp') {
7411
+ this.lockNormalStyle = true;
7412
+ Object.assign(this, data);
7413
+ this.lockNormalStyle = false;
7414
+ }
7415
+ else
7416
+ this.animate(data, transition);
7394
7417
  }
7395
7418
  else
7396
7419
  Object.assign(this, data);
@@ -7581,6 +7604,15 @@ var LeaferUI = (function (exports) {
7581
7604
  __decorate([
7582
7605
  boundsType(0)
7583
7606
  ], exports.UI.prototype, "padding", void 0);
7607
+ __decorate([
7608
+ boundsType(false)
7609
+ ], exports.UI.prototype, "lockRatio", void 0);
7610
+ __decorate([
7611
+ boundsType()
7612
+ ], exports.UI.prototype, "widthRange", void 0);
7613
+ __decorate([
7614
+ boundsType()
7615
+ ], exports.UI.prototype, "heightRange", void 0);
7584
7616
  __decorate([
7585
7617
  dataType(false)
7586
7618
  ], exports.UI.prototype, "draggable", void 0);
@@ -7691,17 +7723,17 @@ var LeaferUI = (function (exports) {
7691
7723
  if (!this.children)
7692
7724
  this.children = [];
7693
7725
  }
7694
- set(data, isTemp) {
7726
+ set(data, transition) {
7695
7727
  if (data.children) {
7696
7728
  const { children } = data;
7697
7729
  delete data.children;
7698
7730
  this.children ? this.clear() : this.__setBranch();
7699
- super.set(data, isTemp);
7731
+ super.set(data, transition);
7700
7732
  children.forEach(child => this.add(child));
7701
7733
  data.children = children;
7702
7734
  }
7703
7735
  else
7704
- super.set(data, isTemp);
7736
+ super.set(data, transition);
7705
7737
  }
7706
7738
  toJSON(options) {
7707
7739
  const data = super.toJSON(options);
@@ -7814,8 +7846,8 @@ var LeaferUI = (function (exports) {
7814
7846
  }
7815
7847
  onInit() { }
7816
7848
  initType(_type) { }
7817
- set(data) {
7818
- this.waitInit(() => { super.set(data); });
7849
+ set(data, transition) {
7850
+ this.waitInit(() => { super.set(data, transition); });
7819
7851
  }
7820
7852
  start() {
7821
7853
  clearTimeout(this.__startTimer);
@@ -7872,8 +7904,6 @@ var LeaferUI = (function (exports) {
7872
7904
  __onResize(event) {
7873
7905
  this.emitEvent(event);
7874
7906
  DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
7875
- if (!event.width || !event.height)
7876
- debug$4.warn('w = 0 or h = 0');
7877
7907
  setTimeout(() => { if (this.canvasManager)
7878
7908
  this.canvasManager.clearRecycled(); }, 0);
7879
7909
  }
@@ -8198,9 +8228,6 @@ var LeaferUI = (function (exports) {
8198
8228
  __decorate([
8199
8229
  dataType(false)
8200
8230
  ], exports.Box.prototype, "resizeChildren", void 0);
8201
- __decorate([
8202
- dataType(false)
8203
- ], exports.Box.prototype, "textBox", void 0);
8204
8231
  __decorate([
8205
8232
  affectRenderBoundsType('show')
8206
8233
  ], exports.Box.prototype, "overflow", void 0);
@@ -8955,19 +8982,13 @@ var LeaferUI = (function (exports) {
8955
8982
  Object.assign(this, params);
8956
8983
  }
8957
8984
  getBoxPoint(relative) {
8958
- if (!relative)
8959
- relative = this.current;
8960
- return relative.getBoxPoint(this);
8985
+ return (relative || this.current).getBoxPoint(this);
8961
8986
  }
8962
8987
  getInnerPoint(relative) {
8963
- if (!relative)
8964
- relative = this.current;
8965
- return relative.getInnerPoint(this);
8988
+ return (relative || this.current).getInnerPoint(this);
8966
8989
  }
8967
8990
  getLocalPoint(relative) {
8968
- if (!relative)
8969
- relative = this.current;
8970
- return relative.getLocalPoint(this);
8991
+ return (relative || this.current).getLocalPoint(this);
8971
8992
  }
8972
8993
  getPagePoint() {
8973
8994
  return this.current.getPagePoint(this);
@@ -9015,10 +9036,8 @@ var LeaferUI = (function (exports) {
9015
9036
  this.data = data;
9016
9037
  }
9017
9038
  static getValidMove(leaf, start, total) {
9018
- const { draggable, dragBounds, x, y } = leaf;
9019
- const move = leaf.getLocalPoint(total, null, true);
9020
- move.x += start.x - x;
9021
- move.y += start.y - y;
9039
+ const { draggable, dragBounds } = leaf, move = leaf.getLocalPoint(total, null, true);
9040
+ PointHelper.move(move, start.x - leaf.x, start.y - leaf.y);
9022
9041
  if (dragBounds)
9023
9042
  this.getMoveInDragBounds(leaf.__local, dragBounds === 'parent' ? leaf.parent.boxBounds : dragBounds, move, true);
9024
9043
  if (draggable === 'x')
@@ -9028,8 +9047,7 @@ var LeaferUI = (function (exports) {
9028
9047
  return move;
9029
9048
  }
9030
9049
  static getMoveInDragBounds(childBox, dragBounds, move, change) {
9031
- const x = childBox.x + move.x, y = childBox.y + move.y;
9032
- const right = x + childBox.width, bottom = y + childBox.height;
9050
+ const x = childBox.x + move.x, y = childBox.y + move.y, right = x + childBox.width, bottom = y + childBox.height;
9033
9051
  const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
9034
9052
  if (!change)
9035
9053
  move = Object.assign({}, move);
@@ -9081,9 +9099,7 @@ var LeaferUI = (function (exports) {
9081
9099
  return this.getLocalMove(relative, true);
9082
9100
  }
9083
9101
  getPageBounds() {
9084
- const total = this.getPageTotal();
9085
- const start = this.getPagePoint();
9086
- const bounds = {};
9102
+ const total = this.getPageTotal(), start = this.getPagePoint(), bounds = {};
9087
9103
  BoundsHelper.set(bounds, start.x - total.x, start.y - total.y, total.x, total.y);
9088
9104
  BoundsHelper.unsign(bounds);
9089
9105
  return bounds;
@@ -9201,7 +9217,8 @@ var LeaferUI = (function (exports) {
9201
9217
  const LeaferTypeCreator = {
9202
9218
  list: {},
9203
9219
  register(name, fn) {
9204
- list$1[name] ? debug$3.repeat(name) : list$1[name] = fn;
9220
+ list$1[name] && debug$3.repeat(name);
9221
+ list$1[name] = fn;
9205
9222
  },
9206
9223
  run(name, leafer) {
9207
9224
  const fn = list$1[name];
@@ -10470,6 +10487,8 @@ var LeaferUI = (function (exports) {
10470
10487
  case 'center':
10471
10488
  canvas.setStroke(stroke, __strokeWidth, options);
10472
10489
  canvas.stroke();
10490
+ if (options.__useArrow)
10491
+ strokeArrow(ui, canvas);
10473
10492
  break;
10474
10493
  case 'inside':
10475
10494
  canvas.save();
@@ -10507,6 +10526,8 @@ var LeaferUI = (function (exports) {
10507
10526
  case 'center':
10508
10527
  canvas.setStroke(undefined, __strokeWidth, options);
10509
10528
  drawStrokesStyle(strokes, false, ui, canvas);
10529
+ if (options.__useArrow)
10530
+ strokeArrow(ui, canvas);
10510
10531
  break;
10511
10532
  case 'inside':
10512
10533
  canvas.save();
@@ -10532,6 +10553,14 @@ var LeaferUI = (function (exports) {
10532
10553
  }
10533
10554
  }
10534
10555
  }
10556
+ function strokeArrow(ui, canvas) {
10557
+ if (ui.__.dashPattern) {
10558
+ canvas.beginPath();
10559
+ ui.__drawPathByData(canvas, ui.__.__pathForArrow);
10560
+ canvas.dashPattern = null;
10561
+ canvas.stroke();
10562
+ }
10563
+ }
10535
10564
 
10536
10565
  const { getSpread, getOuterOf, getByMove, getIntersectData } = BoundsHelper;
10537
10566
  function shape(ui, current, options) {
@@ -11217,16 +11246,16 @@ var LeaferUI = (function (exports) {
11217
11246
 
11218
11247
  const { excludeRenderBounds } = LeafBoundsHelper;
11219
11248
  exports.Group.prototype.__renderMask = function (canvas, options) {
11220
- let child, maskCanvas, contentCanvas, maskOpacity, currentMask;
11249
+ let child, maskCanvas, contentCanvas, maskOpacity, currentMask, mask;
11221
11250
  const { children } = this;
11222
11251
  for (let i = 0, len = children.length; i < len; i++) {
11223
- child = children[i];
11224
- if (child.__.mask) {
11252
+ child = children[i], mask = child.__.mask;
11253
+ if (mask) {
11225
11254
  if (currentMask) {
11226
11255
  maskEnd(this, currentMask, canvas, contentCanvas, maskCanvas, maskOpacity);
11227
11256
  maskCanvas = contentCanvas = null;
11228
11257
  }
11229
- if (child.__.mask === 'path') {
11258
+ if (mask === 'path' || mask === 'clipping-path') {
11230
11259
  if (child.opacity < 1) {
11231
11260
  currentMask = 'opacity-path';
11232
11261
  maskOpacity = child.opacity;
@@ -11240,14 +11269,14 @@ var LeaferUI = (function (exports) {
11240
11269
  child.__clip(contentCanvas || canvas, options);
11241
11270
  }
11242
11271
  else {
11243
- currentMask = 'alpha';
11272
+ currentMask = mask === 'grayscale' ? 'grayscale' : 'alpha';
11244
11273
  if (!maskCanvas)
11245
11274
  maskCanvas = getCanvas(canvas);
11246
11275
  if (!contentCanvas)
11247
11276
  contentCanvas = getCanvas(canvas);
11248
11277
  child.__render(maskCanvas, options);
11249
11278
  }
11250
- if (child.__.mask !== 'clipping')
11279
+ if (!(mask === 'clipping' || mask === 'clipping-path'))
11251
11280
  continue;
11252
11281
  }
11253
11282
  if (excludeRenderBounds(child, options))
@@ -11258,6 +11287,8 @@ var LeaferUI = (function (exports) {
11258
11287
  };
11259
11288
  function maskEnd(leaf, maskMode, canvas, contentCanvas, maskCanvas, maskOpacity) {
11260
11289
  switch (maskMode) {
11290
+ case 'grayscale':
11291
+ maskCanvas.useGrayscaleAlpha(leaf.__nowWorld);
11261
11292
  case 'alpha':
11262
11293
  usePixelMask(leaf, canvas, contentCanvas, maskCanvas);
11263
11294
  break;
@@ -11962,15 +11993,12 @@ var LeaferUI = (function (exports) {
11962
11993
  const debug$1 = Debug.get('@leafer-ui/export');
11963
11994
  canvas.export = function (filename, options) {
11964
11995
  const { quality, blob } = FileHelper.getExportOptions(options);
11965
- if (filename.includes('.')) {
11996
+ if (filename.includes('.'))
11966
11997
  return this.saveAs(filename, quality);
11967
- }
11968
- else if (blob) {
11998
+ else if (blob)
11969
11999
  return this.toBlob(filename, quality);
11970
- }
11971
- else {
12000
+ else
11972
12001
  return this.toDataURL(filename, quality);
11973
- }
11974
12002
  };
11975
12003
  canvas.toBlob = function (type, quality) {
11976
12004
  return new Promise((resolve) => {
@@ -13012,7 +13040,7 @@ var LeaferUI = (function (exports) {
13012
13040
  }
13013
13041
  getPointStyle(userStyle) {
13014
13042
  const { stroke, strokeWidth, pointFill, pointSize, pointRadius } = this.editor.mergeConfig;
13015
- const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius };
13043
+ const defaultStyle = { fill: pointFill, stroke, strokeWidth, around: 'center', strokeAlign: 'center', width: pointSize, height: pointSize, cornerRadius: pointRadius, offsetX: 0, offsetY: 0 };
13016
13044
  return userStyle ? Object.assign(defaultStyle, userStyle) : defaultStyle;
13017
13045
  }
13018
13046
  getPointsStyle() {
@@ -13094,9 +13122,10 @@ var LeaferUI = (function (exports) {
13094
13122
  const { editor } = this;
13095
13123
  if (editor.single) {
13096
13124
  const { element } = editor;
13097
- if (element.isBranch) {
13125
+ if (element.isBranch && !element.editInner) {
13098
13126
  if (element.textBox) {
13099
- const find = element.children.find(item => item.editable && item instanceof exports.Text);
13127
+ const { children } = element;
13128
+ const find = children.find(item => item.editable && item instanceof exports.Text) || children.find(item => item instanceof exports.Text);
13100
13129
  if (find)
13101
13130
  return editor.openInnerEditor(find);
13102
13131
  }
@@ -13356,7 +13385,8 @@ ${filterStyle}
13356
13385
  list: {},
13357
13386
  register(EditTool) {
13358
13387
  const { tag } = EditTool.prototype;
13359
- list[tag] ? debug.repeat(tag) : (list[tag] = EditTool);
13388
+ list[tag] && debug.repeat(tag);
13389
+ list[tag] = EditTool;
13360
13390
  },
13361
13391
  get(tag, editor) {
13362
13392
  return new list[tag](editor);
@@ -14050,12 +14080,16 @@ ${filterStyle}
14050
14080
  ], exports.LineEditTool);
14051
14081
 
14052
14082
  Creator.editor = function (options) { return new Editor(options); };
14083
+ dataType(false)(exports.Box.prototype, 'textBox');
14053
14084
  defineKey(exports.UI.prototype, 'editOuter', {
14054
14085
  get() { return this.__.__isLinePath ? 'LineEditTool' : 'EditTool'; }
14055
14086
  });
14056
14087
  defineKey(exports.UI.prototype, 'editInner', {
14057
14088
  get() { return 'PathEditor'; }
14058
14089
  });
14090
+ defineKey(exports.Group.prototype, 'editInner', {
14091
+ get() { return ''; }
14092
+ });
14059
14093
  defineKey(exports.Text.prototype, 'editInner', {
14060
14094
  get() { return 'TextEditor'; }
14061
14095
  });
@@ -14352,13 +14386,13 @@ ${filterStyle}
14352
14386
  const angle = { connect: half, offset: { x: -0.71, bevelJoin: 0.36, roundJoin: 0.22 }, path: [1, -3, -3, 2, 0, 0, 2, -3, 3] };
14353
14387
  const angleSide = { connect: half, offset: { x: -1.207, bevelJoin: 0.854, roundJoin: 0.707 }, path: [1, -3, -3, 2, 0, 0, 2, -1, 0] };
14354
14388
  const triangleLinePath = [1, -3, 0, 2, -3, -2, 2, 0, 0, 2, -3, 2, 2, -3, 0];
14355
- const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1] };
14389
+ const triangle = { connect: half, offset: { x: -0.9, bevelJoin: 0.624, roundJoin: 0.4 }, path: [...triangleLinePath, 1, -2.05, 1.1, 2, -2.05, -1.1], dashPath: [1, -2, 0, 2, -0.5, 0] };
14356
14390
  const arrowLinePath = [1, -3, 0, 2, -3.5, -1.8, 2, 0, 0, 2, -3.5, 1.8, 2, -3, 0];
14357
- const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95] };
14358
- const triangleFlip = { offset: half, path: [...triangle.path], };
14391
+ const arrow = { connect: half, offset: { x: -1.1, bevelJoin: 0.872, roundJoin: 0.6 }, path: [...arrowLinePath, 1, -2.25, 0.95, 2, -2.25, -0.95], dashPath: [1, -3, 0, 2, -0.5, 0] };
14392
+ const triangleFlip = { offset: half, path: [...triangle.path], dashPath: [1, -2.5, 0, 2, -1, 0] };
14359
14393
  rotate(triangleFlip.path, 180, { x: -1.5, y: 0 });
14360
14394
  const circleLine = { connect: { x: -1.3 }, path: [1, 1.8, -0.1, 2, 1.8, 0, 26, 0, 0, 1.8, 0, 359, 0], };
14361
- const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0] };
14395
+ const circle = { connect: { x: 0.5 }, path: [...circleLine.path, 1, 0, 0, 26, 0, 0, 1, 0, 360, 0], dashPath: [1, -0.5, 0, 2, 0.5, 0] };
14362
14396
  const squareLine = { connect: { x: -1.3 }, path: [1, -1.4, 0, 2, -1.4, -1.4, 2, 1.4, -1.4, 2, 1.4, 1.4, 2, -1.4, 1.4, 2, -1.4, 0] };
14363
14397
  const square = { path: [...squareLine.path, 2, -1.4, -0.49, 2, 1, -0.49, 1, -1.4, 0.49, 2, 1, 0.49] };
14364
14398
  const diamondLine = DataHelper.clone(squareLine);
@@ -14380,12 +14414,14 @@ ${filterStyle}
14380
14414
  'diamond-line': diamondLine,
14381
14415
  mark,
14382
14416
  };
14383
- function getArrowPath(ui, arrow, from, to, scale, connectOffset) {
14417
+ function getArrowPath(ui, arrow, from, to, scale, connectOffset, hasDashPattern) {
14384
14418
  const { strokeCap, strokeJoin } = ui.__;
14385
- const { offset, connect, path } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
14419
+ const { offset, connect, path, dashPath } = (typeof arrow === 'object' ? arrow : arrows[arrow]);
14386
14420
  let connectX = connect ? connect.x : 0;
14387
14421
  let offsetX = offset ? offset.x : 0;
14388
14422
  const data = [...path];
14423
+ if (hasDashPattern && dashPath)
14424
+ data.push(...dashPath);
14389
14425
  if (strokeCap !== 'none')
14390
14426
  connectX -= 0.5;
14391
14427
  if (offset) {
@@ -14409,7 +14445,7 @@ ${filterStyle}
14409
14445
  const PathArrowModule = {
14410
14446
  list: arrows,
14411
14447
  addArrows(ui, changeRenderPath) {
14412
- const { startArrow, endArrow, strokeWidth, __pathForRender: data } = ui.__;
14448
+ const { startArrow, endArrow, strokeWidth, dashPattern, __pathForRender: data } = ui.__;
14413
14449
  let command, i = 0, len = data.length, count = 0, useStartArrow = startArrow && startArrow !== 'none';
14414
14450
  while (i < len) {
14415
14451
  command = data[i];
@@ -14468,17 +14504,20 @@ ${filterStyle}
14468
14504
  if (count === 2 && useStartArrow)
14469
14505
  copy(second, command === L ? now : last);
14470
14506
  if (i === len) {
14471
- const p = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
14507
+ const path = ui.__.__pathForRender = changeRenderPath ? [...data] : data;
14508
+ const pathForArrow = ui.__.__pathForArrow = [];
14472
14509
  if (useStartArrow) {
14473
- p.push(...getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint));
14510
+ const startArrowPath = getArrowPath(ui, startArrow, second, first, strokeWidth, connectPoint, !!dashPattern);
14511
+ dashPattern ? pathForArrow.push(...startArrowPath) : path.push(...startArrowPath);
14474
14512
  if (connectPoint.x) {
14475
14513
  getDistancePoint(first, second, -connectPoint.x, true);
14476
- p[1] = second.x;
14477
- p[2] = second.y;
14514
+ path[1] = second.x;
14515
+ path[2] = second.y;
14478
14516
  }
14479
14517
  }
14480
14518
  if (endArrow && endArrow !== 'none') {
14481
- p.push(...getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint));
14519
+ const endArrowPath = getArrowPath(ui, endArrow, last, now, strokeWidth, connectPoint, !!dashPattern);
14520
+ dashPattern ? pathForArrow.push(...endArrowPath) : path.push(...endArrowPath);
14482
14521
  if (connectPoint.x) {
14483
14522
  getDistancePoint(now, last, -connectPoint.x, true);
14484
14523
  let index;
@@ -14497,7 +14536,7 @@ ${filterStyle}
14497
14536
  break;
14498
14537
  }
14499
14538
  if (index)
14500
- setPoint(p, last, index);
14539
+ setPoint(path, last, index);
14501
14540
  }
14502
14541
  }
14503
14542
  }
@@ -14622,7 +14661,7 @@ ${filterStyle}
14622
14661
  style.position = 'fixed';
14623
14662
  style.transformOrigin = 'left top';
14624
14663
  style.boxSizing = 'border-box';
14625
- this.isHTMLText ? div.innerHTML = text.text : div.innerText = text.text;
14664
+ this.isHTMLText ? div.innerHTML = String(text.text) : div.innerText = String(text.text);
14626
14665
  const { view } = editor.app;
14627
14666
  (this.inBody = view instanceof HTMLCanvasElement) ? document.body.appendChild(div) : view.appendChild(div);
14628
14667
  this.eventIds = [
@@ -14683,8 +14722,10 @@ ${filterStyle}
14683
14722
  this.textScale = textScale;
14684
14723
  const { a, b, c, d, e, f } = new Matrix(text.worldTransform).scale(1 / textScale);
14685
14724
  let { x, y } = this.inBody ? text.app.clientBounds : text.app.tree.clientBounds;
14725
+ if (!this.inBody)
14726
+ x -= window.scrollX, y -= window.scrollY;
14686
14727
  let { width, height } = text;
14687
- x -= window.scrollX, y -= window.scrollY, width *= textScale, height *= textScale;
14728
+ width *= textScale, height *= textScale;
14688
14729
  const data = text.__;
14689
14730
  if (data.__autoWidth && data.autoSizeAlign) {
14690
14731
  width += 20;