leafer-ui 1.0.0-rc.26 → 1.0.0-rc.28
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/README.md +7 -3
- package/dist/web.esm.js +43 -12
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +135 -67
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +135 -68
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -11,8 +11,15 @@ const Platform = {
|
|
|
11
11
|
hitCanvasSize: 100,
|
|
12
12
|
maxCacheSize: 2560 * 1600,
|
|
13
13
|
maxPatternSize: 4096 * 2160,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
crossOrigin: 'anonymous',
|
|
15
|
+
getRealURL(url) {
|
|
16
|
+
const { prefix, suffix } = Platform.image;
|
|
17
|
+
if (suffix && !url.startsWith('data:') && !url.startsWith('blob:'))
|
|
18
|
+
url += (url.includes("?") ? "&" : "?") + suffix;
|
|
19
|
+
if (prefix && url[0] === '/')
|
|
20
|
+
url = prefix + url;
|
|
21
|
+
return url;
|
|
22
|
+
}
|
|
16
23
|
}
|
|
17
24
|
};
|
|
18
25
|
|
|
@@ -5126,6 +5133,7 @@ let Leaf = class Leaf {
|
|
|
5126
5133
|
get __worldFlipped() { return this.__world.scaleX < 0 || this.__world.scaleY < 0; }
|
|
5127
5134
|
get __onlyHitMask() { return this.__hasMask && !this.__.hitChildren; }
|
|
5128
5135
|
get __ignoreHitWorld() { return (this.__hasMask || this.__hasEraser) && this.__.hitChildren; }
|
|
5136
|
+
get __inLazyBounds() { const { leafer } = this; return leafer && leafer.created && leafer.lazyBounds.hit(this.__world); }
|
|
5129
5137
|
get pathInputed() { return this.__.__pathInputed; }
|
|
5130
5138
|
constructor(data) {
|
|
5131
5139
|
this.innerId = create(LEAF);
|
|
@@ -5189,6 +5197,9 @@ let Leaf = class Leaf {
|
|
|
5189
5197
|
}
|
|
5190
5198
|
set(_data) { }
|
|
5191
5199
|
get(_name) { return undefined; }
|
|
5200
|
+
setAttr(name, value) { this[name] = value; }
|
|
5201
|
+
getAttr(name) { return this[name]; }
|
|
5202
|
+
getComputedAttr(name) { return this.__[name]; }
|
|
5192
5203
|
toJSON() {
|
|
5193
5204
|
return this.__.__getInputData();
|
|
5194
5205
|
}
|
|
@@ -5207,6 +5218,9 @@ let Leaf = class Leaf {
|
|
|
5207
5218
|
findOne(_condition, _options) { return undefined; }
|
|
5208
5219
|
findId(_id) { return undefined; }
|
|
5209
5220
|
focus(_value) { }
|
|
5221
|
+
updateLayout() {
|
|
5222
|
+
this.__layout.update();
|
|
5223
|
+
}
|
|
5210
5224
|
forceUpdate(attrName) {
|
|
5211
5225
|
if (attrName === undefined)
|
|
5212
5226
|
attrName = 'width';
|
|
@@ -5216,8 +5230,8 @@ let Leaf = class Leaf {
|
|
|
5216
5230
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5217
5231
|
this[attrName] = value;
|
|
5218
5232
|
}
|
|
5219
|
-
|
|
5220
|
-
this.
|
|
5233
|
+
forceRender(_bounds) {
|
|
5234
|
+
this.forceUpdate('surface');
|
|
5221
5235
|
}
|
|
5222
5236
|
__updateWorldMatrix() { }
|
|
5223
5237
|
__updateLocalMatrix() { }
|
|
@@ -5749,11 +5763,29 @@ class LeafLevelList {
|
|
|
5749
5763
|
}
|
|
5750
5764
|
}
|
|
5751
5765
|
|
|
5752
|
-
const version = "1.0.0-rc.
|
|
5766
|
+
const version = "1.0.0-rc.27";
|
|
5753
5767
|
const inviteCode = {};
|
|
5754
5768
|
|
|
5755
5769
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5756
5770
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
5771
|
+
set zIndex(zIndex) {
|
|
5772
|
+
const { style } = this.view;
|
|
5773
|
+
style.zIndex = zIndex;
|
|
5774
|
+
this.setAbsolute(this.view);
|
|
5775
|
+
}
|
|
5776
|
+
set childIndex(index) {
|
|
5777
|
+
const { view, parentView } = this;
|
|
5778
|
+
if (view && parentView) {
|
|
5779
|
+
const beforeNode = parentView.children[index];
|
|
5780
|
+
if (beforeNode) {
|
|
5781
|
+
this.setAbsolute(beforeNode);
|
|
5782
|
+
parentView.insertBefore(view, beforeNode);
|
|
5783
|
+
}
|
|
5784
|
+
else {
|
|
5785
|
+
parentView.appendChild(beforeNode);
|
|
5786
|
+
}
|
|
5787
|
+
}
|
|
5788
|
+
}
|
|
5757
5789
|
init() {
|
|
5758
5790
|
const { view } = this.config;
|
|
5759
5791
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
@@ -5798,9 +5830,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5798
5830
|
this.__createView();
|
|
5799
5831
|
const view = this.view;
|
|
5800
5832
|
if (parent.hasChildNodes()) {
|
|
5801
|
-
|
|
5802
|
-
style.position = 'absolute';
|
|
5803
|
-
style.top = style.left = '0px';
|
|
5833
|
+
this.setAbsolute(view);
|
|
5804
5834
|
parent.style.position || (parent.style.position = 'relative');
|
|
5805
5835
|
}
|
|
5806
5836
|
parent.appendChild(view);
|
|
@@ -5811,6 +5841,11 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5811
5841
|
this.__createView();
|
|
5812
5842
|
}
|
|
5813
5843
|
}
|
|
5844
|
+
setAbsolute(view) {
|
|
5845
|
+
const { style } = view;
|
|
5846
|
+
style.position = 'absolute';
|
|
5847
|
+
style.top = style.left = '0px';
|
|
5848
|
+
}
|
|
5814
5849
|
updateViewSize() {
|
|
5815
5850
|
const { width, height, pixelRatio } = this;
|
|
5816
5851
|
const { style } = this.view;
|
|
@@ -5930,16 +5965,14 @@ function useCanvas(_canvasType, _power) {
|
|
|
5930
5965
|
loadImage(src) {
|
|
5931
5966
|
return new Promise((resolve, reject) => {
|
|
5932
5967
|
const img = new Image();
|
|
5933
|
-
const {
|
|
5968
|
+
const { crossOrigin } = Platform.image;
|
|
5934
5969
|
if (crossOrigin) {
|
|
5935
5970
|
img.setAttribute('crossOrigin', crossOrigin);
|
|
5936
5971
|
img.crossOrigin = crossOrigin;
|
|
5937
5972
|
}
|
|
5938
5973
|
img.onload = () => { resolve(img); };
|
|
5939
5974
|
img.onerror = (e) => { reject(e); };
|
|
5940
|
-
|
|
5941
|
-
src += (src.includes("?") ? "&" : "?") + suffix;
|
|
5942
|
-
img.src = src;
|
|
5975
|
+
img.src = Platform.image.getRealURL(src);
|
|
5943
5976
|
});
|
|
5944
5977
|
}
|
|
5945
5978
|
};
|
|
@@ -7224,6 +7257,8 @@ const UIRender = {
|
|
|
7224
7257
|
this.__drawRenderPath(canvas);
|
|
7225
7258
|
if (fill && !ignoreFill)
|
|
7226
7259
|
this.__.__pixelFill ? Paint.fills(fill, this, canvas) : Paint.fill('#000000', this, canvas);
|
|
7260
|
+
if (this.__.__isCanvas)
|
|
7261
|
+
this.__drawAfterFill(canvas, options);
|
|
7227
7262
|
if (stroke && !ignoreStroke)
|
|
7228
7263
|
this.__.__pixelStroke ? Paint.strokes(stroke, this, canvas) : Paint.stroke('#000000', this, canvas);
|
|
7229
7264
|
}
|
|
@@ -7337,7 +7372,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7337
7372
|
__onUpdateSize() {
|
|
7338
7373
|
if (this.__.__input) {
|
|
7339
7374
|
const data = this.__;
|
|
7340
|
-
(data.lazy && this.
|
|
7375
|
+
(data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
|
|
7341
7376
|
}
|
|
7342
7377
|
}
|
|
7343
7378
|
__updateRenderPath() {
|
|
@@ -7646,6 +7681,9 @@ __decorate([
|
|
|
7646
7681
|
__decorate([
|
|
7647
7682
|
dataType()
|
|
7648
7683
|
], UI.prototype, "disabledStyle", void 0);
|
|
7684
|
+
__decorate([
|
|
7685
|
+
dataType({})
|
|
7686
|
+
], UI.prototype, "data", void 0);
|
|
7649
7687
|
__decorate([
|
|
7650
7688
|
rewrite(Leaf.prototype.reset)
|
|
7651
7689
|
], UI.prototype, "reset", null);
|
|
@@ -7892,6 +7930,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7892
7930
|
if (!this.parent)
|
|
7893
7931
|
this.canvas.hittable = newValue;
|
|
7894
7932
|
}
|
|
7933
|
+
else if (attrName === 'zIndex') {
|
|
7934
|
+
this.canvas.zIndex = newValue;
|
|
7935
|
+
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
7936
|
+
}
|
|
7895
7937
|
}
|
|
7896
7938
|
return super.__setAttr(attrName, newValue);
|
|
7897
7939
|
}
|
|
@@ -8488,7 +8530,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8488
8530
|
super(data);
|
|
8489
8531
|
this.canvas = Creator.canvas(this.__);
|
|
8490
8532
|
this.context = this.canvas.context;
|
|
8491
|
-
this.__.__drawAfterFill = true;
|
|
8533
|
+
this.__.__isCanvas = this.__.__drawAfterFill = true;
|
|
8492
8534
|
}
|
|
8493
8535
|
draw(ui, offset, scale, rotation) {
|
|
8494
8536
|
ui.__layout.update();
|
|
@@ -8510,7 +8552,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8510
8552
|
__drawAfterFill(canvas, _options) {
|
|
8511
8553
|
const origin = this.canvas.view;
|
|
8512
8554
|
const { width, height } = this;
|
|
8513
|
-
if (this.__.cornerRadius) {
|
|
8555
|
+
if (this.__.cornerRadius || this.pathInputed) {
|
|
8514
8556
|
canvas.save();
|
|
8515
8557
|
canvas.clip();
|
|
8516
8558
|
canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
|
|
@@ -8556,9 +8598,6 @@ __decorate([
|
|
|
8556
8598
|
__decorate([
|
|
8557
8599
|
resizeType()
|
|
8558
8600
|
], Canvas.prototype, "contextSettings", void 0);
|
|
8559
|
-
__decorate([
|
|
8560
|
-
hitType('all')
|
|
8561
|
-
], Canvas.prototype, "hitFill", void 0);
|
|
8562
8601
|
Canvas = __decorate([
|
|
8563
8602
|
registerUI()
|
|
8564
8603
|
], Canvas);
|
|
@@ -8855,15 +8894,17 @@ let App = class App extends Leafer {
|
|
|
8855
8894
|
this.add(leafer);
|
|
8856
8895
|
return leafer;
|
|
8857
8896
|
}
|
|
8858
|
-
add(leafer) {
|
|
8897
|
+
add(leafer, index) {
|
|
8859
8898
|
if (!leafer.view) {
|
|
8860
8899
|
if (this.realCanvas && !this.canvas.bounds) {
|
|
8861
|
-
setTimeout(() => this.add(leafer), 10);
|
|
8900
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
8862
8901
|
return;
|
|
8863
8902
|
}
|
|
8864
8903
|
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
8865
8904
|
}
|
|
8866
|
-
super.add(leafer);
|
|
8905
|
+
super.add(leafer, index);
|
|
8906
|
+
if (index !== undefined)
|
|
8907
|
+
leafer.canvas.childIndex = index;
|
|
8867
8908
|
this.__listenChildEvents(leafer);
|
|
8868
8909
|
}
|
|
8869
8910
|
__onPropertyChange() {
|
|
@@ -9025,20 +9066,32 @@ let DragEvent = class DragEvent extends PointerEvent {
|
|
|
9025
9066
|
move.x = 0;
|
|
9026
9067
|
return move;
|
|
9027
9068
|
}
|
|
9028
|
-
static getMoveInDragBounds(
|
|
9029
|
-
const x =
|
|
9030
|
-
const right = x +
|
|
9069
|
+
static getMoveInDragBounds(childBox, dragBounds, move, change) {
|
|
9070
|
+
const x = childBox.x + move.x, y = childBox.y + move.y;
|
|
9071
|
+
const right = x + childBox.width, bottom = y + childBox.height;
|
|
9031
9072
|
const boundsRight = dragBounds.x + dragBounds.width, boundsBottom = dragBounds.y + dragBounds.height;
|
|
9032
9073
|
if (!change)
|
|
9033
9074
|
move = Object.assign({}, move);
|
|
9034
|
-
if (
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9075
|
+
if (BoundsHelper.includes(childBox, dragBounds)) {
|
|
9076
|
+
if (x > dragBounds.x)
|
|
9077
|
+
move.x += dragBounds.x - x;
|
|
9078
|
+
else if (right < boundsRight)
|
|
9079
|
+
move.x += boundsRight - right;
|
|
9080
|
+
if (y > dragBounds.y)
|
|
9081
|
+
move.y += dragBounds.y - y;
|
|
9082
|
+
else if (bottom < boundsBottom)
|
|
9083
|
+
move.y += boundsBottom - bottom;
|
|
9084
|
+
}
|
|
9085
|
+
else {
|
|
9086
|
+
if (x < dragBounds.x)
|
|
9087
|
+
move.x += dragBounds.x - x;
|
|
9088
|
+
else if (right > boundsRight)
|
|
9089
|
+
move.x += boundsRight - right;
|
|
9090
|
+
if (y < dragBounds.y)
|
|
9091
|
+
move.y += dragBounds.y - y;
|
|
9092
|
+
else if (bottom > boundsBottom)
|
|
9093
|
+
move.y += boundsBottom - bottom;
|
|
9094
|
+
}
|
|
9042
9095
|
return move;
|
|
9043
9096
|
}
|
|
9044
9097
|
getPageMove(total) {
|
|
@@ -9198,13 +9251,15 @@ const LeaferTypeCreator = {
|
|
|
9198
9251
|
};
|
|
9199
9252
|
const { list, register } = LeaferTypeCreator;
|
|
9200
9253
|
register('draw', () => { });
|
|
9254
|
+
register('custom', () => { });
|
|
9201
9255
|
register('design', addInteractionWindow);
|
|
9202
9256
|
register('document', document$1);
|
|
9203
9257
|
|
|
9204
|
-
Leafer.prototype
|
|
9258
|
+
const leafer = Leafer.prototype;
|
|
9259
|
+
leafer.initType = function (type) {
|
|
9205
9260
|
LeaferTypeCreator.run(type, this);
|
|
9206
9261
|
};
|
|
9207
|
-
|
|
9262
|
+
leafer.getValidMove = function (moveX, moveY) {
|
|
9208
9263
|
const { scroll, disabled } = this.app.config.move;
|
|
9209
9264
|
if (scroll) {
|
|
9210
9265
|
if (Math.abs(moveX) > Math.abs(moveY))
|
|
@@ -9234,7 +9289,7 @@ Leafer.prototype.getValidMove = function (moveX, moveY) {
|
|
|
9234
9289
|
}
|
|
9235
9290
|
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9236
9291
|
};
|
|
9237
|
-
|
|
9292
|
+
leafer.getValidScale = function (changeScale) {
|
|
9238
9293
|
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9239
9294
|
if (absScale < min)
|
|
9240
9295
|
changeScale = min / scaleX;
|
|
@@ -9690,7 +9745,7 @@ const config = {
|
|
|
9690
9745
|
swipeDistance: 20,
|
|
9691
9746
|
preventDefaultMenu: true
|
|
9692
9747
|
},
|
|
9693
|
-
cursor:
|
|
9748
|
+
cursor: true,
|
|
9694
9749
|
keyEvent: true
|
|
9695
9750
|
};
|
|
9696
9751
|
|
|
@@ -10003,7 +10058,7 @@ class InteractionBase {
|
|
|
10003
10058
|
this.hoverData = data;
|
|
10004
10059
|
}
|
|
10005
10060
|
updateCursor(data) {
|
|
10006
|
-
if (this.config.cursor
|
|
10061
|
+
if (!this.config.cursor || !this.config.pointer.hover)
|
|
10007
10062
|
return;
|
|
10008
10063
|
if (!data) {
|
|
10009
10064
|
this.updateHoverData();
|
|
@@ -10158,27 +10213,6 @@ class HitCanvasManager extends CanvasManager {
|
|
|
10158
10213
|
}
|
|
10159
10214
|
}
|
|
10160
10215
|
|
|
10161
|
-
const canvas$1 = LeaferCanvasBase.prototype;
|
|
10162
|
-
canvas$1.hitFill = function (point, fillRule) {
|
|
10163
|
-
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
10164
|
-
};
|
|
10165
|
-
canvas$1.hitStroke = function (point, strokeWidth) {
|
|
10166
|
-
this.strokeWidth = strokeWidth;
|
|
10167
|
-
return this.context.isPointInStroke(point.x, point.y);
|
|
10168
|
-
};
|
|
10169
|
-
canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
10170
|
-
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
10171
|
-
if (offset)
|
|
10172
|
-
x -= offset.x, y -= offset.y;
|
|
10173
|
-
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
10174
|
-
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width, tempBounds$1.height);
|
|
10175
|
-
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
10176
|
-
if (data[i + 3] > 0)
|
|
10177
|
-
return true;
|
|
10178
|
-
}
|
|
10179
|
-
return data[3] > 0;
|
|
10180
|
-
};
|
|
10181
|
-
|
|
10182
10216
|
const { toInnerRadiusPointOf, copy: copy$2, setRadius } = PointHelper;
|
|
10183
10217
|
const inner = {};
|
|
10184
10218
|
const leaf = Leaf.prototype;
|
|
@@ -10215,7 +10249,7 @@ const matrix = new Matrix();
|
|
|
10215
10249
|
const ui$2 = UI.prototype;
|
|
10216
10250
|
ui$2.__updateHitCanvas = function () {
|
|
10217
10251
|
const data = this.__, { hitCanvasManager } = this.leafer;
|
|
10218
|
-
const isHitPixelFill = data.__pixelFill && data.hitFill === 'pixel';
|
|
10252
|
+
const isHitPixelFill = (data.__pixelFill || data.__isCanvas) && data.hitFill === 'pixel';
|
|
10219
10253
|
const isHitPixelStroke = data.__pixelStroke && data.hitStroke === 'pixel';
|
|
10220
10254
|
const isHitPixel = isHitPixelFill || isHitPixelStroke;
|
|
10221
10255
|
if (!this.__hitCanvas)
|
|
@@ -10247,11 +10281,11 @@ ui$2.__hit = function (inner) {
|
|
|
10247
10281
|
if (data.__isHitPixel && this.__hitPixel(inner))
|
|
10248
10282
|
return true;
|
|
10249
10283
|
const { hitFill } = data;
|
|
10250
|
-
const needHitFillPath = (data.fill && hitFill
|
|
10284
|
+
const needHitFillPath = ((data.fill || data.__isCanvas) && (hitFill === 'path' || (hitFill === 'pixel' && !(data.__pixelFill || data.__isCanvas)))) || hitFill === 'all';
|
|
10251
10285
|
if (needHitFillPath && this.__hitFill(inner))
|
|
10252
10286
|
return true;
|
|
10253
10287
|
const { hitStroke, __strokeWidth } = data;
|
|
10254
|
-
const needHitStrokePath = (data.stroke &&
|
|
10288
|
+
const needHitStrokePath = (data.stroke && (hitStroke === 'path' || (hitStroke === 'pixel' && !data.__pixelStroke))) || hitStroke === 'all';
|
|
10255
10289
|
if (!needHitFillPath && !needHitStrokePath)
|
|
10256
10290
|
return false;
|
|
10257
10291
|
const radiusWidth = inner.radiusX * 2;
|
|
@@ -10283,7 +10317,7 @@ ui$2.__hit = function (inner) {
|
|
|
10283
10317
|
const ui$1 = new UI();
|
|
10284
10318
|
const rect = Rect.prototype;
|
|
10285
10319
|
rect.__updateHitCanvas = function () {
|
|
10286
|
-
if (this.stroke || this.cornerRadius || (this.fill && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10320
|
+
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10287
10321
|
ui$1.__updateHitCanvas.call(this);
|
|
10288
10322
|
else if (this.__hitCanvas)
|
|
10289
10323
|
this.__hitCanvas = null;
|
|
@@ -10306,6 +10340,27 @@ group.pick = function (hitPoint, options) {
|
|
|
10306
10340
|
return this.leafer ? this.leafer.selector.getByPoint(hitPoint, options.hitRadius || 0, Object.assign(Object.assign({}, options), { target: this })) : null;
|
|
10307
10341
|
};
|
|
10308
10342
|
|
|
10343
|
+
const canvas$1 = LeaferCanvasBase.prototype;
|
|
10344
|
+
canvas$1.hitFill = function (point, fillRule) {
|
|
10345
|
+
return fillRule ? this.context.isPointInPath(point.x, point.y, fillRule) : this.context.isPointInPath(point.x, point.y);
|
|
10346
|
+
};
|
|
10347
|
+
canvas$1.hitStroke = function (point, strokeWidth) {
|
|
10348
|
+
this.strokeWidth = strokeWidth;
|
|
10349
|
+
return this.context.isPointInStroke(point.x, point.y);
|
|
10350
|
+
};
|
|
10351
|
+
canvas$1.hitPixel = function (radiusPoint, offset, scale = 1) {
|
|
10352
|
+
let { x, y, radiusX, radiusY } = radiusPoint;
|
|
10353
|
+
if (offset)
|
|
10354
|
+
x -= offset.x, y -= offset.y;
|
|
10355
|
+
tempBounds$1.set(x - radiusX, y - radiusY, radiusX * 2, radiusY * 2).scale(scale).ceil();
|
|
10356
|
+
const { data } = this.context.getImageData(tempBounds$1.x, tempBounds$1.y, tempBounds$1.width || 1, tempBounds$1.height || 1);
|
|
10357
|
+
for (let i = 0, len = data.length; i < len; i += 4) {
|
|
10358
|
+
if (data[i + 3] > 0)
|
|
10359
|
+
return true;
|
|
10360
|
+
}
|
|
10361
|
+
return data[3] > 0;
|
|
10362
|
+
};
|
|
10363
|
+
|
|
10309
10364
|
const PointerEventHelper = {
|
|
10310
10365
|
convert(e, local) {
|
|
10311
10366
|
const base = InteractionHelper.getBase(e);
|
|
@@ -11252,7 +11307,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11252
11307
|
width *= data.scaleX;
|
|
11253
11308
|
height *= data.scaleY;
|
|
11254
11309
|
}
|
|
11255
|
-
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
11310
|
+
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
11256
11311
|
}
|
|
11257
11312
|
else {
|
|
11258
11313
|
allowPaint = false;
|
|
@@ -11764,7 +11819,8 @@ function createRows(drawData, content, style) {
|
|
|
11764
11819
|
if (breakAll) {
|
|
11765
11820
|
if (wordWidth)
|
|
11766
11821
|
addWord();
|
|
11767
|
-
|
|
11822
|
+
if (rowWidth)
|
|
11823
|
+
addRow();
|
|
11768
11824
|
}
|
|
11769
11825
|
else {
|
|
11770
11826
|
if (!afterBreak)
|
|
@@ -11772,10 +11828,12 @@ function createRows(drawData, content, style) {
|
|
|
11772
11828
|
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
11773
11829
|
if (wordWidth)
|
|
11774
11830
|
addWord();
|
|
11775
|
-
|
|
11831
|
+
if (rowWidth)
|
|
11832
|
+
addRow();
|
|
11776
11833
|
}
|
|
11777
11834
|
else {
|
|
11778
|
-
|
|
11835
|
+
if (rowWidth)
|
|
11836
|
+
addRow();
|
|
11779
11837
|
}
|
|
11780
11838
|
}
|
|
11781
11839
|
}
|
|
@@ -12161,6 +12219,7 @@ const ExportModule = {
|
|
|
12161
12219
|
}
|
|
12162
12220
|
const { leafer } = leaf;
|
|
12163
12221
|
if (leafer) {
|
|
12222
|
+
checkLazy(leaf);
|
|
12164
12223
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
12165
12224
|
options = FileHelper.getExportOptions(options);
|
|
12166
12225
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
@@ -12168,6 +12227,8 @@ const ExportModule = {
|
|
|
12168
12227
|
const { slice, trim, onCanvas } = options;
|
|
12169
12228
|
let scale = options.scale || 1;
|
|
12170
12229
|
let pixelRatio = options.pixelRatio || 1;
|
|
12230
|
+
const smooth = options.smooth === undefined ? leafer.config.smooth : options.smooth;
|
|
12231
|
+
const contextSettings = options.contextSettings || leafer.config.contextSettings;
|
|
12171
12232
|
if (leaf.isApp) {
|
|
12172
12233
|
scale *= pixelRatio;
|
|
12173
12234
|
pixelRatio = leaf.app.pixelRatio;
|
|
@@ -12206,7 +12267,7 @@ const ExportModule = {
|
|
|
12206
12267
|
renderBounds = leaf.getBounds('render', relative);
|
|
12207
12268
|
}
|
|
12208
12269
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
12209
|
-
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio });
|
|
12270
|
+
let canvas = Creator.canvas({ width: Math.round(width), height: Math.round(height), pixelRatio, smooth, contextSettings });
|
|
12210
12271
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
12211
12272
|
if (slice) {
|
|
12212
12273
|
leaf = leafer;
|
|
@@ -12252,6 +12313,12 @@ function addTask(task) {
|
|
|
12252
12313
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
12253
12314
|
});
|
|
12254
12315
|
}
|
|
12316
|
+
function checkLazy(leaf) {
|
|
12317
|
+
if (leaf.__.__needComputePaint)
|
|
12318
|
+
leaf.__.__computePaint();
|
|
12319
|
+
if (leaf.isBranch)
|
|
12320
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
12321
|
+
}
|
|
12255
12322
|
|
|
12256
12323
|
const canvas = LeaferCanvasBase.prototype;
|
|
12257
12324
|
const debug = Debug.get('@leafer-ui/export');
|
|
@@ -12306,4 +12373,4 @@ Object.assign(Creator, {
|
|
|
12306
12373
|
});
|
|
12307
12374
|
useCanvas();
|
|
12308
12375
|
|
|
12309
|
-
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, 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, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, 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, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|
|
12376
|
+
export { AlignHelper, AnimateEvent, Answer, App, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsHelper, Box, BoxData, Branch, BranchHelper, BranchRender, Canvas, CanvasData, CanvasManager, ChildEvent, ColorConvert, Creator, Cursor, DataHelper, Debug, Direction4, Direction9, DragEvent, DropEvent, Effect, Ellipse, EllipseData, EllipseHelper, Event, EventCreator, Export, FileHelper, Frame, FrameData, Group, GroupData, HitCanvasManager, Image$1 as Image, ImageData, ImageEvent, ImageManager, IncrementId, Interaction, 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, MathHelper, Matrix, MatrixHelper, MoveEvent, MultiTouchHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, Paint, PaintGradient, PaintImage, Path, PathArrow, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathData, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Pen, PenData, Platform, Point, PointHelper, PointerButton, PointerEvent, Polygon, PolygonData, PropertyEvent, Rect, RectData, RectHelper, RectRender, RenderEvent, Renderer, ResizeEvent, RotateEvent, Run, Selector, Star, StarData, State, StringNumberMap, SwipeEvent, TaskItem, TaskProcessor, Text, TextConvert, TextData, TwoPointBoundsHelper, UI, UIBounds, UICreator, UIData, UIEvent, UIRender, UnitConvert, WaitHelper, WatchEvent, Watcher, ZoomEvent, addInteractionWindow, 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, inviteCode, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, resizeType, rewrite, rewriteAble, rotationType, scaleType, sortType, stateType, strokeType, surfaceType, tempBounds$1 as tempBounds, tempMatrix, tempPoint$3 as tempPoint, useCanvas, useModule, version, visibleType, zoomLayerType };
|