@leafer-ui/draw 1.4.1 → 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/lib/draw.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, Debug, LeafData, canvasSizeAttrs, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, UICreator, registerUI, Branch, LeafList, Resource, DataHelper, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, ImageEvent, LeaferImage, Matrix, PathCreator } from '@leafer/core';
1
+ import { defineKey, decorateLeafAttr, attr, Plugin, PathConvert, Debug, LeafData, canvasSizeAttrs, dataProcessor, dataType, surfaceType, opacityType, visibleType, sortType, maskType, eraserType, positionType, boundsType, scaleType, rotationType, autoLayoutType, naturalBoundsType, pathInputType, pathType, hitType, strokeType, cursorType, rewrite, Leaf, useModule, rewriteAble, MathHelper, pen, PathCorner, PathDrawer, DataHelper, UICreator, registerUI, Branch, LeafList, Resource, getBoundsData, Creator, CanvasManager, WaitHelper, LeaferEvent, Bounds, ResizeEvent, AutoBounds, Run, LayoutEvent, RenderEvent, WatchEvent, ImageManager, BoundsHelper, affectRenderBoundsType, PathCommandDataHelper, Platform, PointHelper, PathBounds, affectStrokeBoundsType, getPointData, ImageEvent, LeaferImage, Matrix, PathCreator } from '@leafer/core';
2
2
  export * from '@leafer/core';
3
3
 
4
4
  /******************************************************************************
@@ -84,7 +84,11 @@ const State = {
84
84
  setStyleName() { return Plugin.need('state'); },
85
85
  set() { return Plugin.need('state'); }
86
86
  };
87
- const Transition = {};
87
+ const Transition = {
88
+ list: {},
89
+ register(attrName, fn) { Transition.list[attrName] = fn; },
90
+ get(attrName) { return Transition.list[attrName]; }
91
+ };
88
92
 
89
93
  const { parse, objectToCanvasData } = PathConvert;
90
94
  const emptyPaint = {};
@@ -508,9 +512,6 @@ let UI = UI_1 = class UI extends Leaf {
508
512
  this.__drawPathByBox(pen);
509
513
  return pen;
510
514
  }
511
- get editConfig() { return undefined; }
512
- get editOuter() { return ''; }
513
- get editInner() { return ''; }
514
515
  constructor(data) {
515
516
  super(data);
516
517
  }
@@ -592,8 +593,11 @@ let UI = UI_1 = class UI extends Leaf {
592
593
  export(_filename, _options) {
593
594
  return Plugin.need('export');
594
595
  }
596
+ syncExport(_filename, _options) {
597
+ return Plugin.need('export');
598
+ }
595
599
  clone(data) {
596
- const json = this.toJSON();
600
+ const json = DataHelper.clone(this.toJSON());
597
601
  if (data)
598
602
  Object.assign(json, data);
599
603
  return UI_1.one(json);
@@ -892,7 +896,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
892
896
  get layoutLocked() { return !this.layouter.running; }
893
897
  get FPS() { return this.renderer ? this.renderer.FPS : 60; }
894
898
  get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
895
- get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
899
+ get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
896
900
  constructor(userConfig, data) {
897
901
  super(data);
898
902
  this.config = {
@@ -1194,6 +1198,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
1194
1198
  getPagePointByClient(clientPoint, updateClient) {
1195
1199
  return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
1196
1200
  }
1201
+ getClientPointByWorld(worldPoint) {
1202
+ const { x, y } = this.clientBounds;
1203
+ return { x: x + worldPoint.x, y: y + worldPoint.y };
1204
+ }
1197
1205
  updateClientBounds() {
1198
1206
  this.canvas && this.canvas.updateClientBounds();
1199
1207
  }