@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.
- package/dist/worker.cjs +7 -0
- package/dist/worker.esm.js +1 -0
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +164 -16
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +164 -17
- package/dist/worker.module.min.js +1 -1
- package/package.json +15 -14
package/dist/worker.cjs
CHANGED
|
@@ -6,6 +6,7 @@ var viewport = require('@leafer-in/viewport');
|
|
|
6
6
|
var view = require('@leafer-in/view');
|
|
7
7
|
var scroll = require('@leafer-in/scroll');
|
|
8
8
|
var arrow = require('@leafer-in/arrow');
|
|
9
|
+
var find = require('@leafer-in/find');
|
|
9
10
|
var _export = require('@leafer-in/export');
|
|
10
11
|
var textEditor = require('@leafer-in/text-editor');
|
|
11
12
|
var html = require('@leafer-in/html');
|
|
@@ -48,6 +49,12 @@ Object.keys(arrow).forEach(function (k) {
|
|
|
48
49
|
get: function () { return arrow[k]; }
|
|
49
50
|
});
|
|
50
51
|
});
|
|
52
|
+
Object.keys(find).forEach(function (k) {
|
|
53
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () { return find[k]; }
|
|
56
|
+
});
|
|
57
|
+
});
|
|
51
58
|
Object.keys(_export).forEach(function (k) {
|
|
52
59
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
53
60
|
enumerable: true,
|
package/dist/worker.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ export * from '@leafer-in/viewport';
|
|
|
4
4
|
export * from '@leafer-in/view';
|
|
5
5
|
export * from '@leafer-in/scroll';
|
|
6
6
|
export * from '@leafer-in/arrow';
|
|
7
|
+
export * from '@leafer-in/find';
|
|
7
8
|
export * from '@leafer-in/export';
|
|
8
9
|
export * from '@leafer-in/text-editor';
|
|
9
10
|
export * from '@leafer-in/html';
|
package/dist/worker.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export*from"@leafer-ui/worker";export*from"@leafer-in/editor";export*from"@leafer-in/viewport";export*from"@leafer-in/view";export*from"@leafer-in/scroll";export*from"@leafer-in/arrow";export*from"@leafer-in/export";export*from"@leafer-in/text-editor";export*from"@leafer-in/html";
|
|
1
|
+
export*from"@leafer-ui/worker";export*from"@leafer-in/editor";export*from"@leafer-in/viewport";export*from"@leafer-in/view";export*from"@leafer-in/scroll";export*from"@leafer-in/arrow";export*from"@leafer-in/find";export*from"@leafer-in/export";export*from"@leafer-in/text-editor";export*from"@leafer-in/html";
|
package/dist/worker.js
CHANGED
|
@@ -6010,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6010
6010
|
}
|
|
6011
6011
|
}
|
|
6012
6012
|
|
|
6013
|
-
const version = "1.3.
|
|
6013
|
+
const version = "1.3.1";
|
|
6014
6014
|
|
|
6015
6015
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6016
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -9928,8 +9928,8 @@ var LeaferUI = (function (exports) {
|
|
|
9928
9928
|
this.__drawRenderPath(canvas); };
|
|
9929
9929
|
|
|
9930
9930
|
const matrix$2 = new Matrix();
|
|
9931
|
-
const ui$
|
|
9932
|
-
ui$
|
|
9931
|
+
const ui$3 = exports.UI.prototype;
|
|
9932
|
+
ui$3.__updateHitCanvas = function () {
|
|
9933
9933
|
const data = this.__, { hitCanvasManager } = this.leafer;
|
|
9934
9934
|
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
9935
9935
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
@@ -9956,7 +9956,7 @@ var LeaferUI = (function (exports) {
|
|
|
9956
9956
|
this.__drawHitPath(h);
|
|
9957
9957
|
h.setStrokeOptions(data);
|
|
9958
9958
|
};
|
|
9959
|
-
ui$
|
|
9959
|
+
ui$3.__hit = function (inner) {
|
|
9960
9960
|
if (Platform.name === 'miniapp')
|
|
9961
9961
|
this.__drawHitPath(this.__hitCanvas);
|
|
9962
9962
|
const data = this.__;
|
|
@@ -9996,24 +9996,24 @@ var LeaferUI = (function (exports) {
|
|
|
9996
9996
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
9997
9997
|
};
|
|
9998
9998
|
|
|
9999
|
-
const ui$
|
|
9999
|
+
const ui$2 = exports.UI.prototype, rect = exports.Rect.prototype, box$1 = exports.Box.prototype;
|
|
10000
10000
|
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10001
10001
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10002
|
-
ui$
|
|
10002
|
+
ui$2.__updateHitCanvas.call(this);
|
|
10003
10003
|
else if (this.__hitCanvas)
|
|
10004
10004
|
this.__hitCanvas = null;
|
|
10005
10005
|
};
|
|
10006
10006
|
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10007
|
-
return this.__hitCanvas ? ui$
|
|
10007
|
+
return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10008
10008
|
};
|
|
10009
10009
|
|
|
10010
|
-
function getSelector(ui) {
|
|
10010
|
+
function getSelector$1(ui) {
|
|
10011
10011
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10012
10012
|
}
|
|
10013
10013
|
exports.Group.prototype.pick = function (hitPoint, options) {
|
|
10014
10014
|
this.leafer || this.updateLayout();
|
|
10015
10015
|
options || (options = emptyData);
|
|
10016
|
-
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10016
|
+
return getSelector$1(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10017
10017
|
};
|
|
10018
10018
|
|
|
10019
10019
|
const canvas$1 = LeaferCanvasBase.prototype;
|
|
@@ -11685,7 +11685,7 @@ var LeaferUI = (function (exports) {
|
|
|
11685
11685
|
}
|
|
11686
11686
|
}
|
|
11687
11687
|
|
|
11688
|
-
const { No, Yes, NoAndSkip, YesAndSkip } = exports.Answer;
|
|
11688
|
+
const { No, Yes: Yes$1, NoAndSkip: NoAndSkip$1, YesAndSkip: YesAndSkip$1 } = exports.Answer;
|
|
11689
11689
|
const EditSelectHelper = {
|
|
11690
11690
|
findOne(path) {
|
|
11691
11691
|
return path.list.find((leaf) => leaf.editable);
|
|
@@ -11694,20 +11694,20 @@ var LeaferUI = (function (exports) {
|
|
|
11694
11694
|
if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
|
|
11695
11695
|
if (leaf.__.editable) {
|
|
11696
11696
|
if (leaf.isBranch && !leaf.__.hitChildren) {
|
|
11697
|
-
return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
|
|
11697
|
+
return leaf.__.hitSelf ? YesAndSkip$1 : NoAndSkip$1;
|
|
11698
11698
|
}
|
|
11699
11699
|
else if (leaf.isFrame) {
|
|
11700
|
-
return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
|
|
11700
|
+
return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip$1 : No;
|
|
11701
11701
|
}
|
|
11702
11702
|
else {
|
|
11703
11703
|
if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
|
|
11704
|
-
return Yes;
|
|
11704
|
+
return Yes$1;
|
|
11705
11705
|
}
|
|
11706
11706
|
}
|
|
11707
11707
|
return No;
|
|
11708
11708
|
}
|
|
11709
11709
|
else {
|
|
11710
|
-
return leaf.isBranch ? NoAndSkip : No;
|
|
11710
|
+
return leaf.isBranch ? NoAndSkip$1 : No;
|
|
11711
11711
|
}
|
|
11712
11712
|
}
|
|
11713
11713
|
};
|
|
@@ -11871,7 +11871,7 @@ var LeaferUI = (function (exports) {
|
|
|
11871
11871
|
return target.leafer !== this.editor.leafer;
|
|
11872
11872
|
}
|
|
11873
11873
|
allowDrag(e) {
|
|
11874
|
-
if (this.running && this.editor.mergeConfig.boxSelect && !e.target.draggable) {
|
|
11874
|
+
if (this.running && (this.editor.mergeConfig.boxSelect && Plugin.has('find')) && !e.target.draggable) {
|
|
11875
11875
|
return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
|
|
11876
11876
|
}
|
|
11877
11877
|
else {
|
|
@@ -13587,7 +13587,153 @@ ${filterStyle}
|
|
|
13587
13587
|
|
|
13588
13588
|
Plugin.add('resize');
|
|
13589
13589
|
|
|
13590
|
-
|
|
13590
|
+
const { Yes, NoAndSkip, YesAndSkip } = exports.Answer;
|
|
13591
|
+
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
13592
|
+
class Finder {
|
|
13593
|
+
constructor(target) {
|
|
13594
|
+
this.innerIdMap = {};
|
|
13595
|
+
this.idMap = {};
|
|
13596
|
+
this.methods = {
|
|
13597
|
+
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
13598
|
+
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
13599
|
+
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
13600
|
+
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
13601
|
+
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
13602
|
+
};
|
|
13603
|
+
if (this.target = target)
|
|
13604
|
+
this.__listenEvents();
|
|
13605
|
+
}
|
|
13606
|
+
getBy(condition, branch, one, options) {
|
|
13607
|
+
switch (typeof condition) {
|
|
13608
|
+
case 'number':
|
|
13609
|
+
const leaf = this.getByInnerId(condition, branch);
|
|
13610
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
13611
|
+
case 'string':
|
|
13612
|
+
switch (condition[0]) {
|
|
13613
|
+
case '#':
|
|
13614
|
+
idCondition.id = condition.substring(1), condition = idCondition;
|
|
13615
|
+
break;
|
|
13616
|
+
case '.':
|
|
13617
|
+
classNameCondition.className = condition.substring(1), condition = classNameCondition;
|
|
13618
|
+
break;
|
|
13619
|
+
default:
|
|
13620
|
+
tagCondition.tag = condition, condition = tagCondition;
|
|
13621
|
+
}
|
|
13622
|
+
case 'object':
|
|
13623
|
+
if (condition.id !== undefined) {
|
|
13624
|
+
const leaf = this.getById(condition.id, branch);
|
|
13625
|
+
return one ? leaf : (leaf ? [leaf] : []);
|
|
13626
|
+
}
|
|
13627
|
+
else if (condition.tag) {
|
|
13628
|
+
const { tag } = condition, isArray = tag instanceof Array;
|
|
13629
|
+
return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
|
|
13630
|
+
}
|
|
13631
|
+
else {
|
|
13632
|
+
return this.getByMethod(this.methods.className, branch, one, condition.className);
|
|
13633
|
+
}
|
|
13634
|
+
case 'function':
|
|
13635
|
+
return this.getByMethod(condition, branch, one, options);
|
|
13636
|
+
}
|
|
13637
|
+
}
|
|
13638
|
+
getByInnerId(innerId, branch) {
|
|
13639
|
+
const cache = this.innerIdMap[innerId];
|
|
13640
|
+
if (cache)
|
|
13641
|
+
return cache;
|
|
13642
|
+
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
13643
|
+
return this.findLeaf;
|
|
13644
|
+
}
|
|
13645
|
+
getById(id, branch) {
|
|
13646
|
+
const cache = this.idMap[id];
|
|
13647
|
+
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
13648
|
+
return cache;
|
|
13649
|
+
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
13650
|
+
return this.findLeaf;
|
|
13651
|
+
}
|
|
13652
|
+
getByClassName(className, branch) {
|
|
13653
|
+
return this.getByMethod(this.methods.className, branch, false, className);
|
|
13654
|
+
}
|
|
13655
|
+
getByTag(tag, branch) {
|
|
13656
|
+
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
13657
|
+
}
|
|
13658
|
+
getByMethod(method, branch, one, options) {
|
|
13659
|
+
const list = one ? null : [];
|
|
13660
|
+
this.eachFind(this.toChildren(branch), method, list, options);
|
|
13661
|
+
return list || this.findLeaf;
|
|
13662
|
+
}
|
|
13663
|
+
eachFind(children, method, list, options) {
|
|
13664
|
+
let child, result;
|
|
13665
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
13666
|
+
child = children[i];
|
|
13667
|
+
result = method(child, options);
|
|
13668
|
+
if (result === Yes || result === YesAndSkip) {
|
|
13669
|
+
if (list) {
|
|
13670
|
+
list.push(child);
|
|
13671
|
+
}
|
|
13672
|
+
else {
|
|
13673
|
+
this.findLeaf = child;
|
|
13674
|
+
return;
|
|
13675
|
+
}
|
|
13676
|
+
}
|
|
13677
|
+
if (child.isBranch && result < NoAndSkip)
|
|
13678
|
+
this.eachFind(child.children, method, list, options);
|
|
13679
|
+
}
|
|
13680
|
+
}
|
|
13681
|
+
toChildren(branch) {
|
|
13682
|
+
this.findLeaf = null;
|
|
13683
|
+
return [branch || this.target];
|
|
13684
|
+
}
|
|
13685
|
+
__onRemoveChild(event) {
|
|
13686
|
+
const { id, innerId } = event.child;
|
|
13687
|
+
if (this.idMap[id])
|
|
13688
|
+
delete this.idMap[id];
|
|
13689
|
+
if (this.innerIdMap[innerId])
|
|
13690
|
+
delete this.innerIdMap[innerId];
|
|
13691
|
+
}
|
|
13692
|
+
__checkIdChange(event) {
|
|
13693
|
+
if (event.attrName === 'id') {
|
|
13694
|
+
const id = event.oldValue;
|
|
13695
|
+
if (this.idMap[id])
|
|
13696
|
+
delete this.idMap[id];
|
|
13697
|
+
}
|
|
13698
|
+
}
|
|
13699
|
+
__listenEvents() {
|
|
13700
|
+
this.__eventIds = [
|
|
13701
|
+
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
13702
|
+
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
13703
|
+
];
|
|
13704
|
+
}
|
|
13705
|
+
__removeListenEvents() {
|
|
13706
|
+
this.target.off_(this.__eventIds);
|
|
13707
|
+
this.__eventIds.length = 0;
|
|
13708
|
+
}
|
|
13709
|
+
destroy() {
|
|
13710
|
+
const { __eventIds } = this;
|
|
13711
|
+
if (__eventIds && __eventIds.length) {
|
|
13712
|
+
this.__removeListenEvents();
|
|
13713
|
+
this.innerIdMap = {};
|
|
13714
|
+
this.idMap = {};
|
|
13715
|
+
}
|
|
13716
|
+
this.findLeaf = null;
|
|
13717
|
+
}
|
|
13718
|
+
}
|
|
13719
|
+
|
|
13720
|
+
const ui$1 = exports.UI.prototype;
|
|
13721
|
+
function getSelector(ui) {
|
|
13722
|
+
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
13723
|
+
}
|
|
13724
|
+
ui$1.find = function (condition, options) {
|
|
13725
|
+
return getSelector(this).getBy(condition, this, false, options);
|
|
13726
|
+
};
|
|
13727
|
+
ui$1.findOne = function (condition, options) {
|
|
13728
|
+
return getSelector(this).getBy(condition, this, true, options);
|
|
13729
|
+
};
|
|
13730
|
+
|
|
13731
|
+
Plugin.add('find');
|
|
13732
|
+
Creator.finder = function (target) {
|
|
13733
|
+
return new Finder(target);
|
|
13734
|
+
};
|
|
13735
|
+
|
|
13736
|
+
Plugin.add('editor', 'resize', 'find');
|
|
13591
13737
|
Creator.editor = function (options) { return new Editor(options); };
|
|
13592
13738
|
dataType(false)(exports.Box.prototype, 'textBox');
|
|
13593
13739
|
defineKey(exports.UI.prototype, 'editOuter', {
|
|
@@ -14615,6 +14761,7 @@ ${filterStyle}
|
|
|
14615
14761
|
});
|
|
14616
14762
|
};
|
|
14617
14763
|
|
|
14764
|
+
Plugin.add('export');
|
|
14618
14765
|
Object.assign(Export, ExportModule);
|
|
14619
14766
|
exports.UI.prototype.export = function (filename, options) {
|
|
14620
14767
|
return Export.export(this, filename, options);
|
|
@@ -14925,6 +15072,7 @@ ${filterStyle}
|
|
|
14925
15072
|
exports.Eventer = Eventer;
|
|
14926
15073
|
exports.Export = Export;
|
|
14927
15074
|
exports.FileHelper = FileHelper;
|
|
15075
|
+
exports.Finder = Finder;
|
|
14928
15076
|
exports.FrameData = FrameData;
|
|
14929
15077
|
exports.GroupData = GroupData;
|
|
14930
15078
|
exports.HTMLTextData = HTMLTextData;
|
package/dist/worker.min.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@leafer-ui/worker"),r=require("@leafer-in/editor"),t=require("@leafer-in/viewport"),o=require("@leafer-in/view"),n=require("@leafer-in/scroll"),c=require("@leafer-in/arrow"),a=require("@leafer-in/
|
|
1
|
+
"use strict";var e=require("@leafer-ui/worker"),r=require("@leafer-in/editor"),t=require("@leafer-in/viewport"),o=require("@leafer-in/view"),n=require("@leafer-in/scroll"),c=require("@leafer-in/arrow"),a=require("@leafer-in/find"),p=require("@leafer-in/export"),u=require("@leafer-in/text-editor"),f=require("@leafer-in/html");Object.keys(e).forEach((function(r){"default"===r||Object.prototype.hasOwnProperty.call(exports,r)||Object.defineProperty(exports,r,{enumerable:!0,get:function(){return e[r]}})})),Object.keys(r).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return r[e]}})})),Object.keys(t).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return t[e]}})})),Object.keys(o).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return o[e]}})})),Object.keys(n).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return n[e]}})})),Object.keys(c).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return c[e]}})})),Object.keys(a).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return a[e]}})})),Object.keys(p).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return p[e]}})})),Object.keys(u).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return u[e]}})})),Object.keys(f).forEach((function(e){"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:function(){return f[e]}})}));
|