@leafer-editor/worker 1.2.2 → 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 +14 -0
- package/dist/worker.esm.js +2 -0
- package/dist/worker.esm.min.js +1 -1
- package/dist/worker.js +476 -442
- package/dist/worker.min.cjs +1 -1
- package/dist/worker.min.js +1 -1
- package/dist/worker.module.js +475 -443
- package/dist/worker.module.min.js +1 -1
- package/package.json +15 -13
package/dist/worker.js
CHANGED
|
@@ -1405,21 +1405,24 @@ var LeaferUI = (function (exports) {
|
|
|
1405
1405
|
};
|
|
1406
1406
|
const R = Run;
|
|
1407
1407
|
|
|
1408
|
+
const check = [];
|
|
1408
1409
|
const Plugin = {
|
|
1409
1410
|
list: {},
|
|
1410
|
-
add(name) {
|
|
1411
|
+
add(name, ...needPlugins) {
|
|
1411
1412
|
this.list[name] = true;
|
|
1413
|
+
check.push(...needPlugins);
|
|
1412
1414
|
},
|
|
1413
|
-
|
|
1415
|
+
has(name, tip) {
|
|
1414
1416
|
const rs = this.list[name];
|
|
1415
1417
|
if (!rs && tip)
|
|
1416
1418
|
this.need(name);
|
|
1417
1419
|
return rs;
|
|
1418
1420
|
},
|
|
1419
1421
|
need(name) {
|
|
1420
|
-
console.error('need plugin: @leafer-in/' + name);
|
|
1422
|
+
console.error('need plugin: ' + (name.includes('-x') ? '' : '@leafer-in/') + name);
|
|
1421
1423
|
}
|
|
1422
1424
|
};
|
|
1425
|
+
setTimeout(() => check.forEach(name => Plugin.has(name, true)));
|
|
1423
1426
|
|
|
1424
1427
|
const debug$g = Debug.get('UICreator');
|
|
1425
1428
|
const UICreator = {
|
|
@@ -4811,7 +4814,6 @@ var LeaferUI = (function (exports) {
|
|
|
4811
4814
|
}
|
|
4812
4815
|
}
|
|
4813
4816
|
}
|
|
4814
|
-
LayoutEvent.CHECK_UPDATE = 'layout.check_update';
|
|
4815
4817
|
LayoutEvent.REQUEST = 'layout.request';
|
|
4816
4818
|
LayoutEvent.START = 'layout.start';
|
|
4817
4819
|
LayoutEvent.BEFORE = 'layout.before';
|
|
@@ -6008,7 +6010,7 @@ var LeaferUI = (function (exports) {
|
|
|
6008
6010
|
}
|
|
6009
6011
|
}
|
|
6010
6012
|
|
|
6011
|
-
const version = "1.
|
|
6013
|
+
const version = "1.3.1";
|
|
6012
6014
|
|
|
6013
6015
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
6014
6016
|
get allowBackgroundColor() { return true; }
|
|
@@ -6076,6 +6078,7 @@ var LeaferUI = (function (exports) {
|
|
|
6076
6078
|
}
|
|
6077
6079
|
Platform.name = 'web';
|
|
6078
6080
|
Platform.isWorker = true;
|
|
6081
|
+
Platform.backgrounder = true;
|
|
6079
6082
|
Platform.requestRender = function (render) { requestAnimationFrame(render); };
|
|
6080
6083
|
defineKey(Platform, 'devicePixelRatio', { get() { return 1; } });
|
|
6081
6084
|
const { userAgent } = navigator;
|
|
@@ -6808,143 +6811,26 @@ var LeaferUI = (function (exports) {
|
|
|
6808
6811
|
}
|
|
6809
6812
|
}
|
|
6810
6813
|
|
|
6811
|
-
const { Yes: Yes$1, NoAndSkip: NoAndSkip$1, YesAndSkip: YesAndSkip$1 } = exports.Answer;
|
|
6812
|
-
const idCondition = {}, classNameCondition = {}, tagCondition = {};
|
|
6813
6814
|
class Selector {
|
|
6814
6815
|
constructor(target, userConfig) {
|
|
6815
6816
|
this.config = {};
|
|
6816
|
-
this.innerIdMap = {};
|
|
6817
|
-
this.idMap = {};
|
|
6818
|
-
this.methods = {
|
|
6819
|
-
id: (leaf, name) => leaf.id === name ? (this.target && (this.idMap[name] = leaf), 1) : 0,
|
|
6820
|
-
innerId: (leaf, innerId) => leaf.innerId === innerId ? (this.target && (this.innerIdMap[innerId] = leaf), 1) : 0,
|
|
6821
|
-
className: (leaf, name) => leaf.className === name ? 1 : 0,
|
|
6822
|
-
tag: (leaf, name) => leaf.__tag === name ? 1 : 0,
|
|
6823
|
-
tags: (leaf, nameMap) => nameMap[leaf.__tag] ? 1 : 0
|
|
6824
|
-
};
|
|
6825
|
-
this.target = target;
|
|
6826
6817
|
if (userConfig)
|
|
6827
6818
|
this.config = DataHelper.default(userConfig, this.config);
|
|
6828
|
-
this.picker = new Picker(target, this);
|
|
6829
|
-
|
|
6830
|
-
this.__listenEvents();
|
|
6831
|
-
}
|
|
6832
|
-
getBy(condition, branch, one, options) {
|
|
6833
|
-
switch (typeof condition) {
|
|
6834
|
-
case 'number':
|
|
6835
|
-
const leaf = this.getByInnerId(condition, branch);
|
|
6836
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
6837
|
-
case 'string':
|
|
6838
|
-
switch (condition[0]) {
|
|
6839
|
-
case '#':
|
|
6840
|
-
idCondition.id = condition.substring(1), condition = idCondition;
|
|
6841
|
-
break;
|
|
6842
|
-
case '.':
|
|
6843
|
-
classNameCondition.className = condition.substring(1), condition = classNameCondition;
|
|
6844
|
-
break;
|
|
6845
|
-
default:
|
|
6846
|
-
tagCondition.tag = condition, condition = tagCondition;
|
|
6847
|
-
}
|
|
6848
|
-
case 'object':
|
|
6849
|
-
if (condition.id !== undefined) {
|
|
6850
|
-
const leaf = this.getById(condition.id, branch);
|
|
6851
|
-
return one ? leaf : (leaf ? [leaf] : []);
|
|
6852
|
-
}
|
|
6853
|
-
else if (condition.tag) {
|
|
6854
|
-
const { tag } = condition, isArray = tag instanceof Array;
|
|
6855
|
-
return this.getByMethod(isArray ? this.methods.tags : this.methods.tag, branch, one, isArray ? DataHelper.toMap(tag) : tag);
|
|
6856
|
-
}
|
|
6857
|
-
else {
|
|
6858
|
-
return this.getByMethod(this.methods.className, branch, one, condition.className);
|
|
6859
|
-
}
|
|
6860
|
-
case 'function':
|
|
6861
|
-
return this.getByMethod(condition, branch, one, options);
|
|
6862
|
-
}
|
|
6819
|
+
this.picker = new Picker(this.target = target, this);
|
|
6820
|
+
this.finder = Creator.finder && Creator.finder();
|
|
6863
6821
|
}
|
|
6864
6822
|
getByPoint(hitPoint, hitRadius, options) {
|
|
6865
|
-
if (Platform.
|
|
6866
|
-
this.target.
|
|
6823
|
+
if (Platform.backgrounder && this.target)
|
|
6824
|
+
this.target.updateLayout();
|
|
6867
6825
|
return this.picker.getByPoint(hitPoint, hitRadius, options);
|
|
6868
6826
|
}
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
if (cache)
|
|
6872
|
-
return cache;
|
|
6873
|
-
this.eachFind(this.toChildren(branch), this.methods.innerId, null, innerId);
|
|
6874
|
-
return this.findLeaf;
|
|
6875
|
-
}
|
|
6876
|
-
getById(id, branch) {
|
|
6877
|
-
const cache = this.idMap[id];
|
|
6878
|
-
if (cache && LeafHelper.hasParent(cache, branch || this.target))
|
|
6879
|
-
return cache;
|
|
6880
|
-
this.eachFind(this.toChildren(branch), this.methods.id, null, id);
|
|
6881
|
-
return this.findLeaf;
|
|
6882
|
-
}
|
|
6883
|
-
getByClassName(className, branch) {
|
|
6884
|
-
return this.getByMethod(this.methods.className, branch, false, className);
|
|
6885
|
-
}
|
|
6886
|
-
getByTag(tag, branch) {
|
|
6887
|
-
return this.getByMethod(this.methods.tag, branch, false, tag);
|
|
6888
|
-
}
|
|
6889
|
-
getByMethod(method, branch, one, options) {
|
|
6890
|
-
const list = one ? null : [];
|
|
6891
|
-
this.eachFind(this.toChildren(branch), method, list, options);
|
|
6892
|
-
return list || this.findLeaf;
|
|
6893
|
-
}
|
|
6894
|
-
eachFind(children, method, list, options) {
|
|
6895
|
-
let child, result;
|
|
6896
|
-
for (let i = 0, len = children.length; i < len; i++) {
|
|
6897
|
-
child = children[i];
|
|
6898
|
-
result = method(child, options);
|
|
6899
|
-
if (result === Yes$1 || result === YesAndSkip$1) {
|
|
6900
|
-
if (list) {
|
|
6901
|
-
list.push(child);
|
|
6902
|
-
}
|
|
6903
|
-
else {
|
|
6904
|
-
this.findLeaf = child;
|
|
6905
|
-
return;
|
|
6906
|
-
}
|
|
6907
|
-
}
|
|
6908
|
-
if (child.isBranch && result < NoAndSkip$1)
|
|
6909
|
-
this.eachFind(child.children, method, list, options);
|
|
6910
|
-
}
|
|
6911
|
-
}
|
|
6912
|
-
toChildren(branch) {
|
|
6913
|
-
this.findLeaf = null;
|
|
6914
|
-
return [branch || this.target];
|
|
6915
|
-
}
|
|
6916
|
-
__onRemoveChild(event) {
|
|
6917
|
-
const { id, innerId } = event.child;
|
|
6918
|
-
if (this.idMap[id])
|
|
6919
|
-
delete this.idMap[id];
|
|
6920
|
-
if (this.innerIdMap[innerId])
|
|
6921
|
-
delete this.innerIdMap[innerId];
|
|
6922
|
-
}
|
|
6923
|
-
__checkIdChange(event) {
|
|
6924
|
-
if (event.attrName === 'id') {
|
|
6925
|
-
const id = event.oldValue;
|
|
6926
|
-
if (this.idMap[id])
|
|
6927
|
-
delete this.idMap[id];
|
|
6928
|
-
}
|
|
6929
|
-
}
|
|
6930
|
-
__listenEvents() {
|
|
6931
|
-
this.__eventIds = [
|
|
6932
|
-
this.target.on_(ChildEvent.REMOVE, this.__onRemoveChild, this),
|
|
6933
|
-
this.target.on_(PropertyEvent.CHANGE, this.__checkIdChange, this)
|
|
6934
|
-
];
|
|
6935
|
-
}
|
|
6936
|
-
__removeListenEvents() {
|
|
6937
|
-
this.target.off_(this.__eventIds);
|
|
6938
|
-
this.__eventIds.length = 0;
|
|
6827
|
+
getBy(condition, branch, one, options) {
|
|
6828
|
+
return this.finder ? this.finder.getBy(condition, branch, one, options) : Plugin.need('find');
|
|
6939
6829
|
}
|
|
6940
6830
|
destroy() {
|
|
6941
|
-
|
|
6942
|
-
|
|
6943
|
-
this.
|
|
6944
|
-
this.findLeaf = null;
|
|
6945
|
-
this.innerIdMap = {};
|
|
6946
|
-
this.idMap = {};
|
|
6947
|
-
}
|
|
6831
|
+
this.picker.destroy();
|
|
6832
|
+
if (this.finder)
|
|
6833
|
+
this.finder.destroy();
|
|
6948
6834
|
}
|
|
6949
6835
|
}
|
|
6950
6836
|
|
|
@@ -7440,25 +7326,27 @@ var LeaferUI = (function (exports) {
|
|
|
7440
7326
|
}
|
|
7441
7327
|
reset(_data) { }
|
|
7442
7328
|
set(data, transition) {
|
|
7443
|
-
if (
|
|
7444
|
-
if (transition
|
|
7445
|
-
|
|
7446
|
-
|
|
7447
|
-
|
|
7329
|
+
if (data) {
|
|
7330
|
+
if (transition) {
|
|
7331
|
+
if (transition === 'temp') {
|
|
7332
|
+
this.lockNormalStyle = true;
|
|
7333
|
+
Object.assign(this, data);
|
|
7334
|
+
this.lockNormalStyle = false;
|
|
7335
|
+
}
|
|
7336
|
+
else
|
|
7337
|
+
this.animate(data, transition);
|
|
7448
7338
|
}
|
|
7449
7339
|
else
|
|
7450
|
-
|
|
7340
|
+
Object.assign(this, data);
|
|
7451
7341
|
}
|
|
7452
|
-
else
|
|
7453
|
-
Object.assign(this, data);
|
|
7454
7342
|
}
|
|
7455
7343
|
get(name) {
|
|
7456
7344
|
return typeof name === 'string' ? this.__.__getInput(name) : this.__.__getInputData(name);
|
|
7457
7345
|
}
|
|
7458
7346
|
createProxyData() { return undefined; }
|
|
7459
|
-
find(_condition, _options) { return
|
|
7347
|
+
find(_condition, _options) { return Plugin.need('find'); }
|
|
7460
7348
|
findTag(tag) { return this.find({ tag }); }
|
|
7461
|
-
findOne(_condition, _options) { return
|
|
7349
|
+
findOne(_condition, _options) { return Plugin.need('find'); }
|
|
7462
7350
|
findId(id) { return this.findOne({ id }); }
|
|
7463
7351
|
getPath(curve, pathForRender) {
|
|
7464
7352
|
this.__layout.update();
|
|
@@ -7510,9 +7398,9 @@ var LeaferUI = (function (exports) {
|
|
|
7510
7398
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7511
7399
|
return Plugin.need('animate');
|
|
7512
7400
|
}
|
|
7513
|
-
killAnimate(_type) { }
|
|
7514
|
-
export(
|
|
7515
|
-
return
|
|
7401
|
+
killAnimate(_type, _killStyle) { }
|
|
7402
|
+
export(_filename, _options) {
|
|
7403
|
+
return Plugin.need('export');
|
|
7516
7404
|
}
|
|
7517
7405
|
clone(data) {
|
|
7518
7406
|
const json = this.toJSON();
|
|
@@ -7758,16 +7646,18 @@ var LeaferUI = (function (exports) {
|
|
|
7758
7646
|
this.children = [];
|
|
7759
7647
|
}
|
|
7760
7648
|
set(data, transition) {
|
|
7761
|
-
if (data
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7649
|
+
if (data) {
|
|
7650
|
+
if (data.children) {
|
|
7651
|
+
const { children } = data;
|
|
7652
|
+
delete data.children;
|
|
7653
|
+
this.children ? this.clear() : this.__setBranch();
|
|
7654
|
+
super.set(data, transition);
|
|
7655
|
+
children.forEach(child => this.add(child));
|
|
7656
|
+
data.children = children;
|
|
7657
|
+
}
|
|
7658
|
+
else
|
|
7659
|
+
super.set(data, transition);
|
|
7768
7660
|
}
|
|
7769
|
-
else
|
|
7770
|
-
super.set(data, transition);
|
|
7771
7661
|
}
|
|
7772
7662
|
toJSON(options) {
|
|
7773
7663
|
const data = super.toJSON(options);
|
|
@@ -8105,9 +7995,6 @@ var LeaferUI = (function (exports) {
|
|
|
8105
7995
|
this.canvas && this.canvas.updateClientBounds();
|
|
8106
7996
|
}
|
|
8107
7997
|
receiveEvent(_event) { }
|
|
8108
|
-
__checkUpdateLayout() {
|
|
8109
|
-
this.__layout.update();
|
|
8110
|
-
}
|
|
8111
7998
|
emitLeafer(type) {
|
|
8112
7999
|
this.emitEvent(new LeaferEvent(type, this));
|
|
8113
8000
|
}
|
|
@@ -8118,7 +8005,7 @@ var LeaferUI = (function (exports) {
|
|
|
8118
8005
|
this.once(LayoutEvent.END, () => this.__onReady());
|
|
8119
8006
|
this.once(RenderEvent.START, () => this.__onCreated());
|
|
8120
8007
|
this.once(RenderEvent.END, () => this.__onViewReady());
|
|
8121
|
-
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this)
|
|
8008
|
+
this.__eventIds.push(this.on_(WatchEvent.DATA, this.__onWatchData, this), this.on_(RenderEvent.NEXT, this.__onNextRender, this));
|
|
8122
8009
|
}
|
|
8123
8010
|
__removeListenEvents() {
|
|
8124
8011
|
this.off_(this.__eventIds);
|
|
@@ -8183,7 +8070,7 @@ var LeaferUI = (function (exports) {
|
|
|
8183
8070
|
], exports.Rect);
|
|
8184
8071
|
|
|
8185
8072
|
const { copy: copy$6, add, includes: includes$1 } = BoundsHelper;
|
|
8186
|
-
const rect$1 = exports.Rect.prototype, group
|
|
8073
|
+
const rect$1 = exports.Rect.prototype, group = exports.Group.prototype;
|
|
8187
8074
|
const childrenRenderBounds = {};
|
|
8188
8075
|
exports.Box = class Box extends exports.Group {
|
|
8189
8076
|
get __tag() { return 'Box'; }
|
|
@@ -8293,7 +8180,7 @@ var LeaferUI = (function (exports) {
|
|
|
8293
8180
|
rewrite(rect$1.__render)
|
|
8294
8181
|
], exports.Box.prototype, "__renderRect", null);
|
|
8295
8182
|
__decorate([
|
|
8296
|
-
rewrite(group
|
|
8183
|
+
rewrite(group.__render)
|
|
8297
8184
|
], exports.Box.prototype, "__renderGroup", null);
|
|
8298
8185
|
exports.Box = __decorate([
|
|
8299
8186
|
rewriteAble(),
|
|
@@ -8774,6 +8661,9 @@ var LeaferUI = (function (exports) {
|
|
|
8774
8661
|
__decorate([
|
|
8775
8662
|
boundsType(0)
|
|
8776
8663
|
], exports.Text.prototype, "paraSpacing", void 0);
|
|
8664
|
+
__decorate([
|
|
8665
|
+
boundsType('x')
|
|
8666
|
+
], exports.Text.prototype, "writingMode", void 0);
|
|
8777
8667
|
__decorate([
|
|
8778
8668
|
boundsType('left')
|
|
8779
8669
|
], exports.Text.prototype, "textAlign", void 0);
|
|
@@ -8960,8 +8850,8 @@ var LeaferUI = (function (exports) {
|
|
|
8960
8850
|
this.children.forEach(leafer => leafer.resize(event));
|
|
8961
8851
|
super.__onResize(event);
|
|
8962
8852
|
}
|
|
8963
|
-
|
|
8964
|
-
this.children.forEach(leafer => leafer.
|
|
8853
|
+
updateLayout() {
|
|
8854
|
+
this.children.forEach(leafer => leafer.updateLayout());
|
|
8965
8855
|
}
|
|
8966
8856
|
__getChildConfig(userConfig) {
|
|
8967
8857
|
let config = Object.assign({}, this.config);
|
|
@@ -10117,21 +10007,13 @@ var LeaferUI = (function (exports) {
|
|
|
10117
10007
|
return this.__hitCanvas ? ui$2.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10118
10008
|
};
|
|
10119
10009
|
|
|
10120
|
-
|
|
10121
|
-
function getSelector(ui) {
|
|
10010
|
+
function getSelector$1(ui) {
|
|
10122
10011
|
return ui.leafer ? ui.leafer.selector : (Platform.selector || (Platform.selector = Creator.selector()));
|
|
10123
10012
|
}
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
return getSelector(this).getBy(condition, this, true, options);
|
|
10129
|
-
};
|
|
10130
|
-
group.pick = function (hitPoint, options) {
|
|
10131
|
-
this.__layout.update();
|
|
10132
|
-
if (!options)
|
|
10133
|
-
options = {};
|
|
10134
|
-
return getSelector(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10013
|
+
exports.Group.prototype.pick = function (hitPoint, options) {
|
|
10014
|
+
this.leafer || this.updateLayout();
|
|
10015
|
+
options || (options = emptyData);
|
|
10016
|
+
return getSelector$1(this).getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this }));
|
|
10135
10017
|
};
|
|
10136
10018
|
|
|
10137
10019
|
const canvas$1 = LeaferCanvasBase.prototype;
|
|
@@ -11634,257 +11516,72 @@ var LeaferUI = (function (exports) {
|
|
|
11634
11516
|
string
|
|
11635
11517
|
};
|
|
11636
11518
|
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11519
|
+
Object.assign(TextConvert, TextConvertModule);
|
|
11520
|
+
Object.assign(ColorConvert, ColorConvertModule);
|
|
11521
|
+
Object.assign(Paint, PaintModule);
|
|
11522
|
+
Object.assign(PaintImage, PaintImageModule);
|
|
11523
|
+
Object.assign(PaintGradient, PaintGradientModule);
|
|
11524
|
+
Object.assign(Effect, EffectModule);
|
|
11525
|
+
|
|
11526
|
+
Object.assign(Creator, {
|
|
11527
|
+
interaction: (target, canvas, selector, options) => new InteractionBase(target, canvas, selector, options),
|
|
11528
|
+
hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
11529
|
+
hitCanvasManager: () => new HitCanvasManager()
|
|
11530
|
+
});
|
|
11531
|
+
useCanvas();
|
|
11532
|
+
|
|
11533
|
+
function toList(value) {
|
|
11534
|
+
return value ? (value instanceof Array ? value : [value]) : [];
|
|
11535
|
+
}
|
|
11536
|
+
class EditorEvent extends Event {
|
|
11537
|
+
get list() { return toList(this.value); }
|
|
11538
|
+
get oldList() { return toList(this.oldValue); }
|
|
11539
|
+
constructor(type, data) {
|
|
11540
|
+
super(type);
|
|
11541
|
+
if (data)
|
|
11542
|
+
Object.assign(this, data);
|
|
11649
11543
|
}
|
|
11650
|
-
const bounds = new Bounds();
|
|
11651
|
-
toBounds(pointBounds, bounds);
|
|
11652
|
-
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
11653
11544
|
}
|
|
11545
|
+
EditorEvent.SELECT = 'editor.select';
|
|
11546
|
+
EditorEvent.HOVER = 'editor.hover';
|
|
11654
11547
|
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11669
|
-
|
|
11670
|
-
|
|
11671
|
-
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
|
|
11675
|
-
|
|
11676
|
-
|
|
11677
|
-
|
|
11678
|
-
|
|
11679
|
-
|
|
11680
|
-
|
|
11681
|
-
|
|
11682
|
-
|
|
11683
|
-
|
|
11684
|
-
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
else {
|
|
11693
|
-
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
11694
|
-
scaleX = worldTransform.scaleX;
|
|
11695
|
-
scaleY = worldTransform.scaleY;
|
|
11696
|
-
switch (relative) {
|
|
11697
|
-
case 'inner':
|
|
11698
|
-
matrix.set(worldTransform);
|
|
11699
|
-
break;
|
|
11700
|
-
case 'local':
|
|
11701
|
-
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
11702
|
-
scaleX /= leaf.scaleX;
|
|
11703
|
-
scaleY /= leaf.scaleY;
|
|
11704
|
-
break;
|
|
11705
|
-
case 'world':
|
|
11706
|
-
scaleX = 1;
|
|
11707
|
-
scaleY = 1;
|
|
11708
|
-
break;
|
|
11709
|
-
case 'page':
|
|
11710
|
-
relative = leaf.leafer;
|
|
11711
|
-
default:
|
|
11712
|
-
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
11713
|
-
const l = relative.worldTransform;
|
|
11714
|
-
scaleX /= scaleX / l.scaleX;
|
|
11715
|
-
scaleY /= scaleY / l.scaleY;
|
|
11716
|
-
}
|
|
11717
|
-
renderBounds = leaf.getBounds('render', relative);
|
|
11718
|
-
}
|
|
11719
|
-
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
11720
|
-
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
11721
|
-
let pixelRatio = options.pixelRatio || 1;
|
|
11722
|
-
if (leaf.isApp) {
|
|
11723
|
-
scaleData.scaleX *= pixelRatio;
|
|
11724
|
-
scaleData.scaleY *= pixelRatio;
|
|
11725
|
-
pixelRatio = leaf.app.pixelRatio;
|
|
11726
|
-
}
|
|
11727
|
-
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
11728
|
-
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
11729
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
11730
|
-
let sliceLeaf;
|
|
11731
|
-
if (slice) {
|
|
11732
|
-
sliceLeaf = leaf;
|
|
11733
|
-
sliceLeaf.__worldOpacity = 0;
|
|
11734
|
-
leaf = leafer;
|
|
11735
|
-
renderOptions.bounds = canvas.bounds;
|
|
11736
|
-
}
|
|
11737
|
-
canvas.save();
|
|
11738
|
-
if (isFrame && fill !== undefined) {
|
|
11739
|
-
const oldFill = leaf.get('fill');
|
|
11740
|
-
leaf.fill = '';
|
|
11741
|
-
leaf.__render(canvas, renderOptions);
|
|
11742
|
-
leaf.fill = oldFill;
|
|
11743
|
-
}
|
|
11744
|
-
else {
|
|
11745
|
-
leaf.__render(canvas, renderOptions);
|
|
11746
|
-
}
|
|
11747
|
-
canvas.restore();
|
|
11748
|
-
if (sliceLeaf)
|
|
11749
|
-
sliceLeaf.__updateWorldOpacity();
|
|
11750
|
-
if (trim) {
|
|
11751
|
-
trimBounds = getTrimBounds(canvas);
|
|
11752
|
-
const old = canvas, { width, height } = trimBounds;
|
|
11753
|
-
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
11754
|
-
canvas = Creator.canvas(config);
|
|
11755
|
-
canvas.copyWorld(old, trimBounds, config);
|
|
11756
|
-
}
|
|
11757
|
-
if (needFill)
|
|
11758
|
-
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
11759
|
-
if (onCanvas)
|
|
11760
|
-
onCanvas(canvas);
|
|
11761
|
-
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
11762
|
-
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
11763
|
-
}));
|
|
11764
|
-
}
|
|
11765
|
-
else {
|
|
11766
|
-
over({ data: false });
|
|
11767
|
-
}
|
|
11768
|
-
}));
|
|
11769
|
-
}
|
|
11770
|
-
};
|
|
11771
|
-
let tasker;
|
|
11772
|
-
function addTask(task) {
|
|
11773
|
-
if (!tasker)
|
|
11774
|
-
tasker = new TaskProcessor();
|
|
11775
|
-
return new Promise((resolve) => {
|
|
11776
|
-
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
11777
|
-
});
|
|
11778
|
-
}
|
|
11779
|
-
function checkLazy(leaf) {
|
|
11780
|
-
if (leaf.__.__needComputePaint)
|
|
11781
|
-
leaf.__.__computePaint();
|
|
11782
|
-
if (leaf.isBranch)
|
|
11783
|
-
leaf.children.forEach(child => checkLazy(child));
|
|
11784
|
-
}
|
|
11785
|
-
|
|
11786
|
-
const canvas = LeaferCanvasBase.prototype;
|
|
11787
|
-
const debug$2 = Debug.get('@leafer-ui/export');
|
|
11788
|
-
canvas.export = function (filename, options) {
|
|
11789
|
-
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
11790
|
-
if (filename.includes('.'))
|
|
11791
|
-
return this.saveAs(filename, quality);
|
|
11792
|
-
else if (blob)
|
|
11793
|
-
return this.toBlob(filename, quality);
|
|
11794
|
-
else
|
|
11795
|
-
return this.toDataURL(filename, quality);
|
|
11796
|
-
};
|
|
11797
|
-
canvas.toBlob = function (type, quality) {
|
|
11798
|
-
return new Promise((resolve) => {
|
|
11799
|
-
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
11800
|
-
resolve(blob);
|
|
11801
|
-
}).catch((e) => {
|
|
11802
|
-
debug$2.error(e);
|
|
11803
|
-
resolve(null);
|
|
11804
|
-
});
|
|
11805
|
-
});
|
|
11806
|
-
};
|
|
11807
|
-
canvas.toDataURL = function (type, quality) {
|
|
11808
|
-
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
11809
|
-
};
|
|
11810
|
-
canvas.saveAs = function (filename, quality) {
|
|
11811
|
-
return new Promise((resolve) => {
|
|
11812
|
-
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
11813
|
-
resolve(true);
|
|
11814
|
-
}).catch((e) => {
|
|
11815
|
-
debug$2.error(e);
|
|
11816
|
-
resolve(false);
|
|
11817
|
-
});
|
|
11818
|
-
});
|
|
11819
|
-
};
|
|
11820
|
-
|
|
11821
|
-
Object.assign(TextConvert, TextConvertModule);
|
|
11822
|
-
Object.assign(ColorConvert, ColorConvertModule);
|
|
11823
|
-
Object.assign(Paint, PaintModule);
|
|
11824
|
-
Object.assign(PaintImage, PaintImageModule);
|
|
11825
|
-
Object.assign(PaintGradient, PaintGradientModule);
|
|
11826
|
-
Object.assign(Effect, EffectModule);
|
|
11827
|
-
Object.assign(Export, ExportModule);
|
|
11828
|
-
|
|
11829
|
-
Object.assign(Creator, {
|
|
11830
|
-
interaction: (target, canvas, selector, options) => new InteractionBase(target, canvas, selector, options),
|
|
11831
|
-
hitCanvas: (options, manager) => new LeaferCanvas(options, manager),
|
|
11832
|
-
hitCanvasManager: () => new HitCanvasManager()
|
|
11833
|
-
});
|
|
11834
|
-
useCanvas();
|
|
11835
|
-
|
|
11836
|
-
function toList(value) {
|
|
11837
|
-
return value ? (value instanceof Array ? value : [value]) : [];
|
|
11838
|
-
}
|
|
11839
|
-
class EditorEvent extends Event {
|
|
11840
|
-
get list() { return toList(this.value); }
|
|
11841
|
-
get oldList() { return toList(this.oldValue); }
|
|
11842
|
-
constructor(type, data) {
|
|
11843
|
-
super(type);
|
|
11844
|
-
if (data)
|
|
11845
|
-
Object.assign(this, data);
|
|
11846
|
-
}
|
|
11847
|
-
}
|
|
11848
|
-
EditorEvent.SELECT = 'editor.select';
|
|
11849
|
-
EditorEvent.HOVER = 'editor.hover';
|
|
11850
|
-
|
|
11851
|
-
class EditorMoveEvent extends EditorEvent {
|
|
11852
|
-
constructor(type, data) {
|
|
11853
|
-
super(type, data);
|
|
11854
|
-
}
|
|
11855
|
-
}
|
|
11856
|
-
EditorMoveEvent.MOVE = 'editor.move';
|
|
11857
|
-
|
|
11858
|
-
class EditorScaleEvent extends EditorEvent {
|
|
11859
|
-
constructor(type, data) {
|
|
11860
|
-
super(type, data);
|
|
11861
|
-
}
|
|
11862
|
-
}
|
|
11863
|
-
EditorScaleEvent.SCALE = 'editor.scale';
|
|
11864
|
-
|
|
11865
|
-
class EditorRotateEvent extends EditorEvent {
|
|
11866
|
-
constructor(type, data) {
|
|
11867
|
-
super(type, data);
|
|
11868
|
-
}
|
|
11869
|
-
}
|
|
11870
|
-
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
11871
|
-
|
|
11872
|
-
class EditorSkewEvent extends EditorEvent {
|
|
11873
|
-
constructor(type, data) {
|
|
11874
|
-
super(type, data);
|
|
11875
|
-
}
|
|
11876
|
-
}
|
|
11877
|
-
EditorSkewEvent.SKEW = 'editor.skew';
|
|
11878
|
-
|
|
11879
|
-
function targetAttr(fn) {
|
|
11880
|
-
return (target, key) => {
|
|
11881
|
-
const privateKey = '_' + key;
|
|
11882
|
-
defineKey(target, key, {
|
|
11883
|
-
get() { return this[privateKey]; },
|
|
11884
|
-
set(value) {
|
|
11885
|
-
const old = this[privateKey];
|
|
11886
|
-
if (old !== value)
|
|
11887
|
-
this[privateKey] = value, fn(this, old);
|
|
11548
|
+
class EditorMoveEvent extends EditorEvent {
|
|
11549
|
+
constructor(type, data) {
|
|
11550
|
+
super(type, data);
|
|
11551
|
+
}
|
|
11552
|
+
}
|
|
11553
|
+
EditorMoveEvent.MOVE = 'editor.move';
|
|
11554
|
+
|
|
11555
|
+
class EditorScaleEvent extends EditorEvent {
|
|
11556
|
+
constructor(type, data) {
|
|
11557
|
+
super(type, data);
|
|
11558
|
+
}
|
|
11559
|
+
}
|
|
11560
|
+
EditorScaleEvent.SCALE = 'editor.scale';
|
|
11561
|
+
|
|
11562
|
+
class EditorRotateEvent extends EditorEvent {
|
|
11563
|
+
constructor(type, data) {
|
|
11564
|
+
super(type, data);
|
|
11565
|
+
}
|
|
11566
|
+
}
|
|
11567
|
+
EditorRotateEvent.ROTATE = 'editor.rotate';
|
|
11568
|
+
|
|
11569
|
+
class EditorSkewEvent extends EditorEvent {
|
|
11570
|
+
constructor(type, data) {
|
|
11571
|
+
super(type, data);
|
|
11572
|
+
}
|
|
11573
|
+
}
|
|
11574
|
+
EditorSkewEvent.SKEW = 'editor.skew';
|
|
11575
|
+
|
|
11576
|
+
function targetAttr(fn) {
|
|
11577
|
+
return (target, key) => {
|
|
11578
|
+
const privateKey = '_' + key;
|
|
11579
|
+
defineKey(target, key, {
|
|
11580
|
+
get() { return this[privateKey]; },
|
|
11581
|
+
set(value) {
|
|
11582
|
+
const old = this[privateKey];
|
|
11583
|
+
if (old !== value)
|
|
11584
|
+
this[privateKey] = value, fn(this, old);
|
|
11888
11585
|
}
|
|
11889
11586
|
});
|
|
11890
11587
|
};
|
|
@@ -11988,7 +11685,7 @@ var LeaferUI = (function (exports) {
|
|
|
11988
11685
|
}
|
|
11989
11686
|
}
|
|
11990
11687
|
|
|
11991
|
-
const { No, Yes, NoAndSkip, YesAndSkip } = exports.Answer;
|
|
11688
|
+
const { No, Yes: Yes$1, NoAndSkip: NoAndSkip$1, YesAndSkip: YesAndSkip$1 } = exports.Answer;
|
|
11992
11689
|
const EditSelectHelper = {
|
|
11993
11690
|
findOne(path) {
|
|
11994
11691
|
return path.list.find((leaf) => leaf.editable);
|
|
@@ -11997,20 +11694,20 @@ var LeaferUI = (function (exports) {
|
|
|
11997
11694
|
if (leaf.__.hittable && leaf.__.visible && !leaf.__.locked && bounds.hit(leaf.__world)) {
|
|
11998
11695
|
if (leaf.__.editable) {
|
|
11999
11696
|
if (leaf.isBranch && !leaf.__.hitChildren) {
|
|
12000
|
-
return leaf.__.hitSelf ? YesAndSkip : NoAndSkip;
|
|
11697
|
+
return leaf.__.hitSelf ? YesAndSkip$1 : NoAndSkip$1;
|
|
12001
11698
|
}
|
|
12002
11699
|
else if (leaf.isFrame) {
|
|
12003
|
-
return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No;
|
|
11700
|
+
return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip$1 : No;
|
|
12004
11701
|
}
|
|
12005
11702
|
else {
|
|
12006
11703
|
if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf)
|
|
12007
|
-
return Yes;
|
|
11704
|
+
return Yes$1;
|
|
12008
11705
|
}
|
|
12009
11706
|
}
|
|
12010
11707
|
return No;
|
|
12011
11708
|
}
|
|
12012
11709
|
else {
|
|
12013
|
-
return leaf.isBranch ? NoAndSkip : No;
|
|
11710
|
+
return leaf.isBranch ? NoAndSkip$1 : No;
|
|
12014
11711
|
}
|
|
12015
11712
|
}
|
|
12016
11713
|
};
|
|
@@ -12174,7 +11871,7 @@ var LeaferUI = (function (exports) {
|
|
|
12174
11871
|
return target.leafer !== this.editor.leafer;
|
|
12175
11872
|
}
|
|
12176
11873
|
allowDrag(e) {
|
|
12177
|
-
if (this.running && this.editor.mergeConfig.boxSelect && !e.target.draggable) {
|
|
11874
|
+
if (this.running && (this.editor.mergeConfig.boxSelect && Plugin.has('find')) && !e.target.draggable) {
|
|
12178
11875
|
return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path));
|
|
12179
11876
|
}
|
|
12180
11877
|
else {
|
|
@@ -12969,7 +12666,7 @@ ${filterStyle}
|
|
|
12969
12666
|
}
|
|
12970
12667
|
};
|
|
12971
12668
|
|
|
12972
|
-
const debug$
|
|
12669
|
+
const debug$2 = Debug.get('EditToolCreator');
|
|
12973
12670
|
function registerEditTool() {
|
|
12974
12671
|
return (target) => {
|
|
12975
12672
|
EditToolCreator.register(target);
|
|
@@ -12980,7 +12677,7 @@ ${filterStyle}
|
|
|
12980
12677
|
list: {},
|
|
12981
12678
|
register(EditTool) {
|
|
12982
12679
|
const { tag } = EditTool.prototype;
|
|
12983
|
-
list$1[tag] && debug$
|
|
12680
|
+
list$1[tag] && debug$2.repeat(tag);
|
|
12984
12681
|
list$1[tag] = EditTool;
|
|
12985
12682
|
},
|
|
12986
12683
|
get(tag, editor) {
|
|
@@ -13097,7 +12794,7 @@ ${filterStyle}
|
|
|
13097
12794
|
if (userConfig)
|
|
13098
12795
|
this.config = DataHelper.default(userConfig, this.config);
|
|
13099
12796
|
this.addMany(this.editMask, this.selector, this.editBox);
|
|
13100
|
-
if (!Plugin.
|
|
12797
|
+
if (!Plugin.has('resize'))
|
|
13101
12798
|
this.config.editSize = 'scale';
|
|
13102
12799
|
}
|
|
13103
12800
|
select(target) {
|
|
@@ -13890,7 +13587,153 @@ ${filterStyle}
|
|
|
13890
13587
|
|
|
13891
13588
|
Plugin.add('resize');
|
|
13892
13589
|
|
|
13893
|
-
|
|
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');
|
|
13894
13737
|
Creator.editor = function (options) { return new Editor(options); };
|
|
13895
13738
|
dataType(false)(exports.Box.prototype, 'textBox');
|
|
13896
13739
|
defineKey(exports.UI.prototype, 'editOuter', {
|
|
@@ -13971,11 +13814,11 @@ ${filterStyle}
|
|
|
13971
13814
|
});
|
|
13972
13815
|
}
|
|
13973
13816
|
|
|
13974
|
-
const debug = Debug.get('LeaferTypeCreator');
|
|
13817
|
+
const debug$1 = Debug.get('LeaferTypeCreator');
|
|
13975
13818
|
const LeaferTypeCreator = {
|
|
13976
13819
|
list: {},
|
|
13977
13820
|
register(name, fn) {
|
|
13978
|
-
list[name] && debug.repeat(name);
|
|
13821
|
+
list[name] && debug$1.repeat(name);
|
|
13979
13822
|
list[name] = fn;
|
|
13980
13823
|
},
|
|
13981
13824
|
run(name, leafer) {
|
|
@@ -14500,17 +14343,17 @@ ${filterStyle}
|
|
|
14500
14343
|
switch (command) {
|
|
14501
14344
|
case M$1:
|
|
14502
14345
|
case L$1:
|
|
14503
|
-
setPoint$
|
|
14346
|
+
setPoint$2(data, i + 1, x, y, scaleX, scaleY, rotation, origin);
|
|
14504
14347
|
i += 3;
|
|
14505
14348
|
break;
|
|
14506
14349
|
case C$1:
|
|
14507
14350
|
for (j = 1; j < 6; j += 2)
|
|
14508
|
-
setPoint$
|
|
14351
|
+
setPoint$2(data, i + j, x, y, scaleX, scaleY, rotation, origin);
|
|
14509
14352
|
i += 7;
|
|
14510
14353
|
break;
|
|
14511
14354
|
case Q$1:
|
|
14512
14355
|
for (j = 1; j < 4; j += 2)
|
|
14513
|
-
setPoint$
|
|
14356
|
+
setPoint$2(data, i + j, x, y, scaleX, scaleY, rotation, origin);
|
|
14514
14357
|
i += 5;
|
|
14515
14358
|
break;
|
|
14516
14359
|
case O$1:
|
|
@@ -14531,7 +14374,7 @@ ${filterStyle}
|
|
|
14531
14374
|
PathMatrixHelper.layout(data, 0, 0, 1, 1, rotation, center);
|
|
14532
14375
|
}
|
|
14533
14376
|
};
|
|
14534
|
-
function setPoint$
|
|
14377
|
+
function setPoint$2(data, startIndex, x, y, scaleX, scaleY, rotation, origin) {
|
|
14535
14378
|
copyFrom$1(point, data[startIndex], data[startIndex + 1]);
|
|
14536
14379
|
if (rotation)
|
|
14537
14380
|
rotate$1(point, rotation, origin);
|
|
@@ -14697,7 +14540,7 @@ ${filterStyle}
|
|
|
14697
14540
|
break;
|
|
14698
14541
|
}
|
|
14699
14542
|
if (index)
|
|
14700
|
-
setPoint(path, last, index);
|
|
14543
|
+
setPoint$1(path, last, index);
|
|
14701
14544
|
}
|
|
14702
14545
|
}
|
|
14703
14546
|
}
|
|
@@ -14711,7 +14554,7 @@ ${filterStyle}
|
|
|
14711
14554
|
copyFrom(from, data[startIndex], data[startIndex + 1]);
|
|
14712
14555
|
copyFrom(to, data[startIndex + 2], data[startIndex + 3]);
|
|
14713
14556
|
}
|
|
14714
|
-
function setPoint(data, point, startIndex) {
|
|
14557
|
+
function setPoint$1(data, point, startIndex) {
|
|
14715
14558
|
data[startIndex] = point.x;
|
|
14716
14559
|
data[startIndex + 1] = point.y;
|
|
14717
14560
|
}
|
|
@@ -14734,6 +14577,196 @@ ${filterStyle}
|
|
|
14734
14577
|
arrowType('none')(ui, 'endArrow');
|
|
14735
14578
|
Object.assign(PathArrow, PathArrowModule);
|
|
14736
14579
|
|
|
14580
|
+
const { setPoint, addPoint, toBounds } = TwoPointBoundsHelper;
|
|
14581
|
+
function getTrimBounds(canvas) {
|
|
14582
|
+
const { width, height } = canvas.view;
|
|
14583
|
+
const { data } = canvas.context.getImageData(0, 0, width, height);
|
|
14584
|
+
let x, y, pointBounds, index = 0;
|
|
14585
|
+
for (let i = 0; i < data.length; i += 4) {
|
|
14586
|
+
if (data[i + 3] !== 0) {
|
|
14587
|
+
x = index % width;
|
|
14588
|
+
y = (index - x) / width;
|
|
14589
|
+
pointBounds ? addPoint(pointBounds, x, y) : setPoint(pointBounds = {}, x, y);
|
|
14590
|
+
}
|
|
14591
|
+
index++;
|
|
14592
|
+
}
|
|
14593
|
+
const bounds = new Bounds();
|
|
14594
|
+
toBounds(pointBounds, bounds);
|
|
14595
|
+
return bounds.scale(1 / canvas.pixelRatio).ceil();
|
|
14596
|
+
}
|
|
14597
|
+
|
|
14598
|
+
const ExportModule = {
|
|
14599
|
+
export(leaf, filename, options) {
|
|
14600
|
+
this.running = true;
|
|
14601
|
+
const fileType = FileHelper.fileType(filename);
|
|
14602
|
+
const isDownload = filename.includes('.');
|
|
14603
|
+
options = FileHelper.getExportOptions(options);
|
|
14604
|
+
return addTask((success) => new Promise((resolve) => {
|
|
14605
|
+
const over = (result) => {
|
|
14606
|
+
success(result);
|
|
14607
|
+
resolve();
|
|
14608
|
+
this.running = false;
|
|
14609
|
+
};
|
|
14610
|
+
const { toURL } = Platform;
|
|
14611
|
+
const { download } = Platform.origin;
|
|
14612
|
+
if (fileType === 'json') {
|
|
14613
|
+
isDownload && download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
14614
|
+
return over({ data: isDownload ? true : leaf.toJSON(options.json) });
|
|
14615
|
+
}
|
|
14616
|
+
if (fileType === 'svg') {
|
|
14617
|
+
isDownload && download(toURL(leaf.toSVG(), 'svg'), filename);
|
|
14618
|
+
return over({ data: isDownload ? true : leaf.toSVG() });
|
|
14619
|
+
}
|
|
14620
|
+
const { leafer } = leaf;
|
|
14621
|
+
if (leafer) {
|
|
14622
|
+
checkLazy(leaf);
|
|
14623
|
+
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
14624
|
+
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
14625
|
+
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
14626
|
+
const { slice, trim, onCanvas } = options;
|
|
14627
|
+
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
14628
|
+
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
14629
|
+
const screenshot = options.screenshot || leaf.isApp;
|
|
14630
|
+
const fill = (isLeafer && screenshot) ? (options.fill === undefined ? leaf.fill : options.fill) : options.fill;
|
|
14631
|
+
const needFill = FileHelper.isOpaqueImage(filename) || fill, matrix = new Matrix();
|
|
14632
|
+
if (screenshot) {
|
|
14633
|
+
renderBounds = screenshot === true ? (isLeafer ? leafer.canvas.bounds : leaf.worldRenderBounds) : screenshot;
|
|
14634
|
+
}
|
|
14635
|
+
else {
|
|
14636
|
+
let relative = options.relative || (isLeafer ? 'inner' : 'local');
|
|
14637
|
+
scaleX = worldTransform.scaleX;
|
|
14638
|
+
scaleY = worldTransform.scaleY;
|
|
14639
|
+
switch (relative) {
|
|
14640
|
+
case 'inner':
|
|
14641
|
+
matrix.set(worldTransform);
|
|
14642
|
+
break;
|
|
14643
|
+
case 'local':
|
|
14644
|
+
matrix.set(worldTransform).divide(leaf.localTransform);
|
|
14645
|
+
scaleX /= leaf.scaleX;
|
|
14646
|
+
scaleY /= leaf.scaleY;
|
|
14647
|
+
break;
|
|
14648
|
+
case 'world':
|
|
14649
|
+
scaleX = 1;
|
|
14650
|
+
scaleY = 1;
|
|
14651
|
+
break;
|
|
14652
|
+
case 'page':
|
|
14653
|
+
relative = leaf.leafer;
|
|
14654
|
+
default:
|
|
14655
|
+
matrix.set(worldTransform).divide(leaf.getTransform(relative));
|
|
14656
|
+
const l = relative.worldTransform;
|
|
14657
|
+
scaleX /= scaleX / l.scaleX;
|
|
14658
|
+
scaleY /= scaleY / l.scaleY;
|
|
14659
|
+
}
|
|
14660
|
+
renderBounds = leaf.getBounds('render', relative);
|
|
14661
|
+
}
|
|
14662
|
+
const scaleData = { scaleX: 1, scaleY: 1 };
|
|
14663
|
+
MathHelper.getScaleData(options.scale, options.size, renderBounds, scaleData);
|
|
14664
|
+
let pixelRatio = options.pixelRatio || 1;
|
|
14665
|
+
if (leaf.isApp) {
|
|
14666
|
+
scaleData.scaleX *= pixelRatio;
|
|
14667
|
+
scaleData.scaleY *= pixelRatio;
|
|
14668
|
+
pixelRatio = leaf.app.pixelRatio;
|
|
14669
|
+
}
|
|
14670
|
+
const { x, y, width, height } = new Bounds(renderBounds).scale(scaleData.scaleX, scaleData.scaleY);
|
|
14671
|
+
const renderOptions = { matrix: matrix.scale(1 / scaleData.scaleX, 1 / scaleData.scaleY).invert().translate(-x, -y).withScale(1 / scaleX * scaleData.scaleX, 1 / scaleY * scaleData.scaleY) };
|
|
14672
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
14673
|
+
let sliceLeaf;
|
|
14674
|
+
if (slice) {
|
|
14675
|
+
sliceLeaf = leaf;
|
|
14676
|
+
sliceLeaf.__worldOpacity = 0;
|
|
14677
|
+
leaf = leafer;
|
|
14678
|
+
renderOptions.bounds = canvas.bounds;
|
|
14679
|
+
}
|
|
14680
|
+
canvas.save();
|
|
14681
|
+
if (isFrame && fill !== undefined) {
|
|
14682
|
+
const oldFill = leaf.get('fill');
|
|
14683
|
+
leaf.fill = '';
|
|
14684
|
+
leaf.__render(canvas, renderOptions);
|
|
14685
|
+
leaf.fill = oldFill;
|
|
14686
|
+
}
|
|
14687
|
+
else {
|
|
14688
|
+
leaf.__render(canvas, renderOptions);
|
|
14689
|
+
}
|
|
14690
|
+
canvas.restore();
|
|
14691
|
+
if (sliceLeaf)
|
|
14692
|
+
sliceLeaf.__updateWorldOpacity();
|
|
14693
|
+
if (trim) {
|
|
14694
|
+
trimBounds = getTrimBounds(canvas);
|
|
14695
|
+
const old = canvas, { width, height } = trimBounds;
|
|
14696
|
+
const config = { x: 0, y: 0, width, height, pixelRatio };
|
|
14697
|
+
canvas = Creator.canvas(config);
|
|
14698
|
+
canvas.copyWorld(old, trimBounds, config);
|
|
14699
|
+
}
|
|
14700
|
+
if (needFill)
|
|
14701
|
+
canvas.fillWorld(canvas.bounds, fill || '#FFFFFF', 'destination-over');
|
|
14702
|
+
if (onCanvas)
|
|
14703
|
+
onCanvas(canvas);
|
|
14704
|
+
const data = filename === 'canvas' ? canvas : yield canvas.export(filename, options);
|
|
14705
|
+
over({ data, width: canvas.pixelWidth, height: canvas.pixelHeight, renderBounds, trimBounds });
|
|
14706
|
+
}));
|
|
14707
|
+
}
|
|
14708
|
+
else {
|
|
14709
|
+
over({ data: false });
|
|
14710
|
+
}
|
|
14711
|
+
}));
|
|
14712
|
+
}
|
|
14713
|
+
};
|
|
14714
|
+
let tasker;
|
|
14715
|
+
function addTask(task) {
|
|
14716
|
+
if (!tasker)
|
|
14717
|
+
tasker = new TaskProcessor();
|
|
14718
|
+
return new Promise((resolve) => {
|
|
14719
|
+
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
14720
|
+
});
|
|
14721
|
+
}
|
|
14722
|
+
function checkLazy(leaf) {
|
|
14723
|
+
if (leaf.__.__needComputePaint)
|
|
14724
|
+
leaf.__.__computePaint();
|
|
14725
|
+
if (leaf.isBranch)
|
|
14726
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
14727
|
+
}
|
|
14728
|
+
|
|
14729
|
+
const canvas = LeaferCanvasBase.prototype;
|
|
14730
|
+
const debug = Debug.get('@leafer-in/export');
|
|
14731
|
+
canvas.export = function (filename, options) {
|
|
14732
|
+
const { quality, blob } = FileHelper.getExportOptions(options);
|
|
14733
|
+
if (filename.includes('.'))
|
|
14734
|
+
return this.saveAs(filename, quality);
|
|
14735
|
+
else if (blob)
|
|
14736
|
+
return this.toBlob(filename, quality);
|
|
14737
|
+
else
|
|
14738
|
+
return this.toDataURL(filename, quality);
|
|
14739
|
+
};
|
|
14740
|
+
canvas.toBlob = function (type, quality) {
|
|
14741
|
+
return new Promise((resolve) => {
|
|
14742
|
+
Platform.origin.canvasToBolb(this.view, type, quality).then((blob) => {
|
|
14743
|
+
resolve(blob);
|
|
14744
|
+
}).catch((e) => {
|
|
14745
|
+
debug.error(e);
|
|
14746
|
+
resolve(null);
|
|
14747
|
+
});
|
|
14748
|
+
});
|
|
14749
|
+
};
|
|
14750
|
+
canvas.toDataURL = function (type, quality) {
|
|
14751
|
+
return Platform.origin.canvasToDataURL(this.view, type, quality);
|
|
14752
|
+
};
|
|
14753
|
+
canvas.saveAs = function (filename, quality) {
|
|
14754
|
+
return new Promise((resolve) => {
|
|
14755
|
+
Platform.origin.canvasSaveAs(this.view, filename, quality).then(() => {
|
|
14756
|
+
resolve(true);
|
|
14757
|
+
}).catch((e) => {
|
|
14758
|
+
debug.error(e);
|
|
14759
|
+
resolve(false);
|
|
14760
|
+
});
|
|
14761
|
+
});
|
|
14762
|
+
};
|
|
14763
|
+
|
|
14764
|
+
Plugin.add('export');
|
|
14765
|
+
Object.assign(Export, ExportModule);
|
|
14766
|
+
exports.UI.prototype.export = function (filename, options) {
|
|
14767
|
+
return Export.export(this, filename, options);
|
|
14768
|
+
};
|
|
14769
|
+
|
|
14737
14770
|
const textCaseMap = {
|
|
14738
14771
|
'none': 'none',
|
|
14739
14772
|
'title': 'capitalize',
|
|
@@ -14936,8 +14969,7 @@ ${filterStyle}
|
|
|
14936
14969
|
registerInnerEditor()
|
|
14937
14970
|
], exports.TextEditor);
|
|
14938
14971
|
|
|
14939
|
-
Plugin.add('text-editor');
|
|
14940
|
-
setTimeout(() => Plugin.check('editor', true));
|
|
14972
|
+
Plugin.add('text-editor', 'editor');
|
|
14941
14973
|
|
|
14942
14974
|
class HTMLTextData extends ImageData {
|
|
14943
14975
|
setText(value) {
|
|
@@ -15040,6 +15072,7 @@ ${filterStyle}
|
|
|
15040
15072
|
exports.Eventer = Eventer;
|
|
15041
15073
|
exports.Export = Export;
|
|
15042
15074
|
exports.FileHelper = FileHelper;
|
|
15075
|
+
exports.Finder = Finder;
|
|
15043
15076
|
exports.FrameData = FrameData;
|
|
15044
15077
|
exports.GroupData = GroupData;
|
|
15045
15078
|
exports.HTMLTextData = HTMLTextData;
|
|
@@ -15102,6 +15135,7 @@ ${filterStyle}
|
|
|
15102
15135
|
exports.PathNumberCommandLengthMap = PathNumberCommandLengthMap;
|
|
15103
15136
|
exports.PathNumberCommandMap = PathNumberCommandMap;
|
|
15104
15137
|
exports.PenData = PenData;
|
|
15138
|
+
exports.Picker = Picker;
|
|
15105
15139
|
exports.Platform = Platform;
|
|
15106
15140
|
exports.Plugin = Plugin;
|
|
15107
15141
|
exports.Point = Point;
|