@leafer-editor/worker 1.3.0 → 1.3.1

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.
@@ -6007,7 +6007,7 @@ class LeafLevelList {
6007
6007
  }
6008
6008
  }
6009
6009
 
6010
- const version = "1.3.0";
6010
+ const version = "1.3.1";
6011
6011
 
6012
6012
  class LeaferCanvas extends LeaferCanvasBase {
6013
6013
  get allowBackgroundColor() { return true; }
@@ -9925,8 +9925,8 @@ leaf$1.__drawHitPath = function (canvas) { if (canvas)
9925
9925
  this.__drawRenderPath(canvas); };
9926
9926
 
9927
9927
  const matrix$2 = new Matrix();
9928
- const ui$2 = UI.prototype;
9929
- ui$2.__updateHitCanvas = function () {
9928
+ const ui$3 = UI.prototype;
9929
+ ui$3.__updateHitCanvas = function () {
9930
9930
  const data = this.__, { hitCanvasManager } = this.leafer;
9931
9931
  const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
9932
9932
  const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
@@ -9953,7 +9953,7 @@ ui$2.__updateHitCanvas = function () {
9953
9953
  this.__drawHitPath(h);
9954
9954
  h.setStrokeOptions(data);
9955
9955
  };
9956
- ui$2.__hit = function (inner) {
9956
+ ui$3.__hit = function (inner) {
9957
9957
  if (Platform.name === 'miniapp')
9958
9958
  this.__drawHitPath(this.__hitCanvas);
9959
9959
  const data = this.__;
@@ -9993,24 +9993,24 @@ ui$2.__hit = function (inner) {
9993
9993
  return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
9994
9994
  };
9995
9995
 
9996
- const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
9996
+ const ui$2 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
9997
9997
  rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
9998
9998
  if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
9999
- ui$1.__updateHitCanvas.call(this);
9999
+ ui$2.__updateHitCanvas.call(this);
10000
10000
  else if (this.__hitCanvas)
10001
10001
  this.__hitCanvas = null;
10002
10002
  };
10003
10003
  rect.__hitFill = box$1.__hitFill = function (inner) {
10004
- return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10004
+ return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
10005
10005
  };
10006
10006
 
10007
- function getSelector(ui) {
10007
+ function getSelector$1(ui) {
10008
10008
  return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
10009
10009
  }
10010
10010
  Group.prototype.pick = function (hitPoint, options) {
10011
10011
  this.leafer || this.updateLayout();
10012
10012
  options || (options = emptyData);
10013
- return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10013
+ return getSelector$1(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
10014
10014
  };
10015
10015
 
10016
10016
  const canvas$1 = LeaferCanvasBase.prototype;
@@ -11682,7 +11682,7 @@ class SelectArea extends Group {
11682
11682
  }
11683
11683
  }
11684
11684
 
11685
- const { No, Yes, NoAndSkip, YesAndSkip } = Answer;
11685
+ const { No, Yes: Yes$1, NoAndSkip: NoAndSkip$1, YesAndSkip: YesAndSkip$1 } = Answer;
11686
11686
  const EditSelectHelper = {
11687
11687
  findOne(path) {
11688
11688
  return path.list.find((leaf) => leaf.editable);
@@ -11691,20 +11691,20 @@ const EditSelectHelper = {
11691
11691
  if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
11692
11692
  if (leaf.__.editable) {
11693
11693
  if (leaf.isBranch && !leaf.__.hitChildren) {
11694
- return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
11694
+ return leaf.__.hitSelf ? YesAndSkip$1 : NoAndSkip$1;
11695
11695
  }
11696
11696
  else if (leaf.isFrame) {
11697
- return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
11697
+ return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip$1 : No;
11698
11698
  }
11699
11699
  else {
11700
11700
  if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
11701
- return Yes;
11701
+ return Yes$1;
11702
11702
  }
11703
11703
  }
11704
11704
  return No;
11705
11705
  }
11706
11706
  else {
11707
- return leaf.isBranch ? NoAndSkip : No;
11707
+ return leaf.isBranch ? NoAndSkip$1 : No;
11708
11708
  }
11709
11709
  }
11710
11710
  };
@@ -11868,7 +11868,7 @@ class EditSelect extends Group {
11868
11868
  return target.leafer !== this.editor.leafer;
11869
11869
  }
11870
11870
  allowDrag(e) {
11871
- if (this.running && this.editor.mergeConfig.boxSelect && !e.target.draggable) {
11871
+ if (this.running && (this.editor.mergeConfig.boxSelect && Plugin.has('find')) && !e.target.draggable) {
11872
11872
  return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
11873
11873
  }
11874
11874
  else {
@@ -13584,7 +13584,153 @@ Box.prototype.__scaleResize = function (scaleX, scaleY) {
13584
13584
 
13585
13585
  Plugin.add('resize');
13586
13586
 
13587
- Plugin.add('editor', 'resize');
13587
+ const { Yes, NoAndSkip, YesAndSkip } = Answer;
13588
+ const idCondition = {}, classNameCondition = {}, tagCondition = {};
13589
+ class Finder {
13590
+ constructor(target) {
13591
+ this.innerIdMap = {};
13592
+ this.idMap = {};
13593
+ this.methods = {
13594
+ id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
13595
+ innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
13596
+ className: (leaf, name) => leaf.className === name ? 1 : 0,
13597
+ tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
13598
+ tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
13599
+ };
13600
+ if (this.target = target)
13601
+ this.__listenEvents();
13602
+ }
13603
+ getBy(condition, branch, one, options) {
13604
+ switch (typeof condition) {
13605
+ case 'number':
13606
+ const leaf = this.getByInnerId(condition, branch);
13607
+ return one ? leaf : (leaf ? [leaf] : []);
13608
+ case 'string':
13609
+ switch (condition[0]) {
13610
+ case '#':
13611
+ idCondition.id = condition.substring(1), condition = idCondition;
13612
+ break;
13613
+ case '.':
13614
+ classNameCondition.className = condition.substring(1), condition = classNameCondition;
13615
+ break;
13616
+ default:
13617
+ tagCondition.tag = condition, condition = tagCondition;
13618
+ }
13619
+ case 'object':
13620
+ if (condition.id !== undefined) {
13621
+ const leaf = this.getById(condition.id, branch);
13622
+ return one ? leaf : (leaf ? [leaf] : []);
13623
+ }
13624
+ else if (condition.tag) {
13625
+ const { tag } = condition, isArray = tag instanceof Array;
13626
+ return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
13627
+ }
13628
+ else {
13629
+ return this.getByMethod(this.methods.className, branch, one, condition.className);
13630
+ }
13631
+ case 'function':
13632
+ return this.getByMethod(condition, branch, one, options);
13633
+ }
13634
+ }
13635
+ getByInnerId(innerId, branch) {
13636
+ const cache = this.innerIdMap[innerId];
13637
+ if (cache)
13638
+ return cache;
13639
+ this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
13640
+ return this.findLeaf;
13641
+ }
13642
+ getById(id, branch) {
13643
+ const cache = this.idMap[id];
13644
+ if (cache && LeafHelper.hasParent(cache, branch || this.target))
13645
+ return cache;
13646
+ this.eachFind(this.toChildren(branch), this.methods.id, null, id);
13647
+ return this.findLeaf;
13648
+ }
13649
+ getByClassName(className, branch) {
13650
+ return this.getByMethod(this.methods.className, branch, false, className);
13651
+ }
13652
+ getByTag(tag, branch) {
13653
+ return this.getByMethod(this.methods.tag, branch, false, tag);
13654
+ }
13655
+ getByMethod(method, branch, one, options) {
13656
+ const list = one ? null : [];
13657
+ this.eachFind(this.toChildren(branch), method, list, options);
13658
+ return list || this.findLeaf;
13659
+ }
13660
+ eachFind(children, method, list, options) {
13661
+ let child, result;
13662
+ for (let i = 0, len = children.length; i < len; i++) {
13663
+ child = children[i];
13664
+ result = method(child, options);
13665
+ if (result === Yes || result === YesAndSkip) {
13666
+ if (list) {
13667
+ list.push(child);
13668
+ }
13669
+ else {
13670
+ this.findLeaf = child;
13671
+ return;
13672
+ }
13673
+ }
13674
+ if (child.isBranch && result < NoAndSkip)
13675
+ this.eachFind(child.children, method, list, options);
13676
+ }
13677
+ }
13678
+ toChildren(branch) {
13679
+ this.findLeaf = null;
13680
+ return [branch || this.target];
13681
+ }
13682
+ __onRemoveChild(event) {
13683
+ const { id, innerId } = event.child;
13684
+ if (this.idMap[id])
13685
+ delete this.idMap[id];
13686
+ if (this.innerIdMap[innerId])
13687
+ delete this.innerIdMap[innerId];
13688
+ }
13689
+ __checkIdChange(event) {
13690
+ if (event.attrName === 'id') {
13691
+ const id = event.oldValue;
13692
+ if (this.idMap[id])
13693
+ delete this.idMap[id];
13694
+ }
13695
+ }
13696
+ __listenEvents() {
13697
+ this.__eventIds = [
13698
+ this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
13699
+ this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
13700
+ ];
13701
+ }
13702
+ __removeListenEvents() {
13703
+ this.target.off_(this.__eventIds);
13704
+ this.__eventIds.length = 0;
13705
+ }
13706
+ destroy() {
13707
+ const { __eventIds } = this;
13708
+ if (__eventIds && __eventIds.length) {
13709
+ this.__removeListenEvents();
13710
+ this.innerIdMap = {};
13711
+ this.idMap = {};
13712
+ }
13713
+ this.findLeaf = null;
13714
+ }
13715
+ }
13716
+
13717
+ const ui$1 = UI.prototype;
13718
+ function getSelector(ui) {
13719
+ return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
13720
+ }
13721
+ ui$1.find = function (condition, options) {
13722
+ return getSelector(this).getBy(condition, this, false, options);
13723
+ };
13724
+ ui$1.findOne = function (condition, options) {
13725
+ return getSelector(this).getBy(condition, this, true, options);
13726
+ };
13727
+
13728
+ Plugin.add('find');
13729
+ Creator.finder = function (target) {
13730
+ return new Finder(target);
13731
+ };
13732
+
13733
+ Plugin.add('editor', 'resize', 'find');
13588
13734
  Creator.editor = function (options) { return new Editor(options); };
13589
13735
  dataType(false)(Box.prototype, 'textBox');
13590
13736
  defineKey(UI.prototype, 'editOuter', {
@@ -14612,6 +14758,7 @@ canvas.saveAs = function (filename, quality) {
14612
14758
  });
14613
14759
  };
14614
14760
 
14761
+ Plugin.add('export');
14615
14762
  Object.assign(Export, ExportModule);
14616
14763
  UI.prototype.export = function (filename, options) {
14617
14764
  return Export.export(this, filename, options);
@@ -14881,4 +15028,4 @@ HTMLText = __decorate([
14881
15028
 
14882
15029
  Plugin.add('html');
14883
15030
 
14884
- export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
15031
+ export { AlignHelper, Answer, App, AroundHelper, Arrow, ArrowData, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, Dragger, DropEvent, EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Eventer, Export, FileHelper, Finder, Frame, FrameData, Group, GroupData, HTMLText, HTMLTextData, HitCanvasManager, Image, ImageData, ImageEvent, ImageManager, IncrementId, InnerEditor, InnerEditorEvent, InteractionBase, InteractionHelper, KeyEvent, Keyboard, LayoutEvent, Layouter, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, Leafer, LeaferCanvas, LeaferCanvasBase, LeaferData, LeaferEvent, LeaferImage, LeaferTypeCreator, Line, LineData, LineEditTool, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, MyDragEvent, MyImage, MyPointerEvent, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathArrowModule, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathMatrixHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Picker, Platform, Plugin, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, ScrollBar, SelectArea, Selector, Star, StarData, State, StringNumberMap, Stroker, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TextEditor, Transformer, Transition, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, WheelEventHelper, ZoomEvent, addViewport, addViewportConfig, affectRenderBoundsType, affectStrokeBoundsType, arrowType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, effectType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerEditTool, registerInnerEditor, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };