leafer-draw 1.4.2 → 1.5.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/web.js CHANGED
@@ -4073,12 +4073,11 @@ var LeaferUI = (function (exports) {
4073
4073
  if (defaultValue === undefined) {
4074
4074
  property.get = function () { return this[computedKey]; };
4075
4075
  }
4076
- else if (typeof defaultValue === 'object') {
4077
- const { clone } = DataHelper;
4076
+ else if (typeof defaultValue === 'function') {
4078
4077
  property.get = function () {
4079
4078
  let v = this[computedKey];
4080
4079
  if (v === undefined)
4081
- this[computedKey] = v = clone(defaultValue);
4080
+ this[computedKey] = v = defaultValue(this.__leaf);
4082
4081
  return v;
4083
4082
  };
4084
4083
  }
@@ -5725,10 +5724,10 @@ var LeaferUI = (function (exports) {
5725
5724
  static changeAttr(attrName, defaultValue, fn) {
5726
5725
  fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
5727
5726
  }
5728
- static addAttr(attrName, defaultValue, fn) {
5727
+ static addAttr(attrName, defaultValue, fn, helpValue) {
5729
5728
  if (!fn)
5730
5729
  fn = boundsType;
5731
- fn(defaultValue)(this.prototype, attrName);
5730
+ fn(defaultValue, helpValue)(this.prototype, attrName);
5732
5731
  }
5733
5732
  __emitLifeEvent(type) {
5734
5733
  if (this.hasEvent(type))
@@ -6055,7 +6054,7 @@ var LeaferUI = (function (exports) {
6055
6054
  }
6056
6055
  }
6057
6056
 
6058
- const version = "1.4.2";
6057
+ const version = "1.5.0";
6059
6058
 
6060
6059
  const debug$4 = Debug.get('LeaferCanvas');
6061
6060
  class LeaferCanvas extends LeaferCanvasBase {
@@ -6966,7 +6965,11 @@ var LeaferUI = (function (exports) {
6966
6965
  setStyleName() { return Plugin.need('state'); },
6967
6966
  set() { return Plugin.need('state'); }
6968
6967
  };
6969
- const Transition = {};
6968
+ const Transition = {
6969
+ list: {},
6970
+ register(attrName, fn) { Transition.list[attrName] = fn; },
6971
+ get(attrName) { return Transition.list[attrName]; }
6972
+ };
6970
6973
 
6971
6974
  const { parse, objectToCanvasData } = PathConvert;
6972
6975
  const emptyPaint = {};
@@ -7390,9 +7393,6 @@ var LeaferUI = (function (exports) {
7390
7393
  this.__drawPathByBox(pen);
7391
7394
  return pen;
7392
7395
  }
7393
- get editConfig() { return undefined; }
7394
- get editOuter() { return ''; }
7395
- get editInner() { return ''; }
7396
7396
  constructor(data) {
7397
7397
  super(data);
7398
7398
  }
@@ -7474,8 +7474,11 @@ var LeaferUI = (function (exports) {
7474
7474
  export(_filename, _options) {
7475
7475
  return Plugin.need('export');
7476
7476
  }
7477
+ syncExport(_filename, _options) {
7478
+ return Plugin.need('export');
7479
+ }
7477
7480
  clone(data) {
7478
- const json = this.toJSON();
7481
+ const json = DataHelper.clone(this.toJSON());
7479
7482
  if (data)
7480
7483
  Object.assign(json, data);
7481
7484
  return UI_1.one(json);
@@ -7774,7 +7777,7 @@ var LeaferUI = (function (exports) {
7774
7777
  get layoutLocked() { return !this.layouter.running; }
7775
7778
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
7776
7779
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
7777
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
7780
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
7778
7781
  constructor(userConfig, data) {
7779
7782
  super(data);
7780
7783
  this.config = {
@@ -8076,6 +8079,10 @@ var LeaferUI = (function (exports) {
8076
8079
  getPagePointByClient(clientPoint, updateClient) {
8077
8080
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
8078
8081
  }
8082
+ getClientPointByWorld(worldPoint) {
8083
+ const { x, y } = this.clientBounds;
8084
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
8085
+ }
8079
8086
  updateClientBounds() {
8080
8087
  this.canvas && this.canvas.updateClientBounds();
8081
8088
  }
@@ -10111,13 +10118,14 @@ var LeaferUI = (function (exports) {
10111
10118
  }
10112
10119
 
10113
10120
  function layoutText(drawData, style) {
10114
- const { rows, bounds } = drawData;
10121
+ const { rows, bounds } = drawData, countRows = rows.length;
10115
10122
  const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
10116
- let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
10123
+ let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
10117
10124
  let starY = __baseLine;
10118
10125
  if (__clipText && realHeight > height) {
10119
10126
  realHeight = Math.max(height, __lineHeight);
10120
- drawData.overflow = rows.length;
10127
+ if (countRows > 1)
10128
+ drawData.overflow = countRows;
10121
10129
  }
10122
10130
  else if (height || autoSizeAlign) {
10123
10131
  switch (verticalAlign) {
@@ -10129,7 +10137,7 @@ var LeaferUI = (function (exports) {
10129
10137
  }
10130
10138
  starY += y;
10131
10139
  let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
10132
- for (let i = 0, len = rows.length; i < len; i++) {
10140
+ for (let i = 0, len = countRows; i < len; i++) {
10133
10141
  row = rows[i];
10134
10142
  row.x = x;
10135
10143
  if (row.width < width || (row.width > width && !__clipText)) {
@@ -10198,7 +10206,7 @@ var LeaferUI = (function (exports) {
10198
10206
  if (i === end && charRight < right) {
10199
10207
  break;
10200
10208
  }
10201
- else if (charRight < right && char.char !== ' ') {
10209
+ else if ((charRight < right && char.char !== ' ') || !i) {
10202
10210
  row.data.splice(i + 1);
10203
10211
  row.width -= char.width;
10204
10212
  break;