leafer-ui 1.0.0-rc.27 → 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 +1 -1
- package/dist/web.esm.js +43 -12
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +77 -26
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +77 -27
- 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);
|
|
@@ -5210,6 +5218,9 @@ let Leaf = class Leaf {
|
|
|
5210
5218
|
findOne(_condition, _options) { return undefined; }
|
|
5211
5219
|
findId(_id) { return undefined; }
|
|
5212
5220
|
focus(_value) { }
|
|
5221
|
+
updateLayout() {
|
|
5222
|
+
this.__layout.update();
|
|
5223
|
+
}
|
|
5213
5224
|
forceUpdate(attrName) {
|
|
5214
5225
|
if (attrName === undefined)
|
|
5215
5226
|
attrName = 'width';
|
|
@@ -5219,8 +5230,8 @@ let Leaf = class Leaf {
|
|
|
5219
5230
|
this.__[attrName] = value === undefined ? null : undefined;
|
|
5220
5231
|
this[attrName] = value;
|
|
5221
5232
|
}
|
|
5222
|
-
|
|
5223
|
-
this.
|
|
5233
|
+
forceRender(_bounds) {
|
|
5234
|
+
this.forceUpdate('surface');
|
|
5224
5235
|
}
|
|
5225
5236
|
__updateWorldMatrix() { }
|
|
5226
5237
|
__updateLocalMatrix() { }
|
|
@@ -5757,6 +5768,24 @@ const inviteCode = {};
|
|
|
5757
5768
|
|
|
5758
5769
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5759
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
|
+
}
|
|
5760
5789
|
init() {
|
|
5761
5790
|
const { view } = this.config;
|
|
5762
5791
|
view ? this.__createViewFrom(view) : this.__createView();
|
|
@@ -5801,9 +5830,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5801
5830
|
this.__createView();
|
|
5802
5831
|
const view = this.view;
|
|
5803
5832
|
if (parent.hasChildNodes()) {
|
|
5804
|
-
|
|
5805
|
-
style.position = 'absolute';
|
|
5806
|
-
style.top = style.left = '0px';
|
|
5833
|
+
this.setAbsolute(view);
|
|
5807
5834
|
parent.style.position || (parent.style.position = 'relative');
|
|
5808
5835
|
}
|
|
5809
5836
|
parent.appendChild(view);
|
|
@@ -5814,6 +5841,11 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5814
5841
|
this.__createView();
|
|
5815
5842
|
}
|
|
5816
5843
|
}
|
|
5844
|
+
setAbsolute(view) {
|
|
5845
|
+
const { style } = view;
|
|
5846
|
+
style.position = 'absolute';
|
|
5847
|
+
style.top = style.left = '0px';
|
|
5848
|
+
}
|
|
5817
5849
|
updateViewSize() {
|
|
5818
5850
|
const { width, height, pixelRatio } = this;
|
|
5819
5851
|
const { style } = this.view;
|
|
@@ -5933,16 +5965,14 @@ function useCanvas(_canvasType, _power) {
|
|
|
5933
5965
|
loadImage(src) {
|
|
5934
5966
|
return new Promise((resolve, reject) => {
|
|
5935
5967
|
const img = new Image();
|
|
5936
|
-
const {
|
|
5968
|
+
const { crossOrigin } = Platform.image;
|
|
5937
5969
|
if (crossOrigin) {
|
|
5938
5970
|
img.setAttribute('crossOrigin', crossOrigin);
|
|
5939
5971
|
img.crossOrigin = crossOrigin;
|
|
5940
5972
|
}
|
|
5941
5973
|
img.onload = () => { resolve(img); };
|
|
5942
5974
|
img.onerror = (e) => { reject(e); };
|
|
5943
|
-
|
|
5944
|
-
src += (src.includes("?") ? "&" : "?") + suffix;
|
|
5945
|
-
img.src = src;
|
|
5975
|
+
img.src = Platform.image.getRealURL(src);
|
|
5946
5976
|
});
|
|
5947
5977
|
}
|
|
5948
5978
|
};
|
|
@@ -7342,7 +7372,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7342
7372
|
__onUpdateSize() {
|
|
7343
7373
|
if (this.__.__input) {
|
|
7344
7374
|
const data = this.__;
|
|
7345
|
-
(data.lazy && this.
|
|
7375
|
+
(data.lazy && !this.__inLazyBounds && !Export.running) ? data.__needComputePaint = true : data.__computePaint();
|
|
7346
7376
|
}
|
|
7347
7377
|
}
|
|
7348
7378
|
__updateRenderPath() {
|
|
@@ -7900,6 +7930,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7900
7930
|
if (!this.parent)
|
|
7901
7931
|
this.canvas.hittable = newValue;
|
|
7902
7932
|
}
|
|
7933
|
+
else if (attrName === 'zIndex') {
|
|
7934
|
+
this.canvas.zIndex = newValue;
|
|
7935
|
+
setTimeout(() => this.parent && this.parent.__updateSortChildren());
|
|
7936
|
+
}
|
|
7903
7937
|
}
|
|
7904
7938
|
return super.__setAttr(attrName, newValue);
|
|
7905
7939
|
}
|
|
@@ -8518,7 +8552,7 @@ let Canvas = class Canvas extends Rect {
|
|
|
8518
8552
|
__drawAfterFill(canvas, _options) {
|
|
8519
8553
|
const origin = this.canvas.view;
|
|
8520
8554
|
const { width, height } = this;
|
|
8521
|
-
if (this.__.cornerRadius) {
|
|
8555
|
+
if (this.__.cornerRadius || this.pathInputed) {
|
|
8522
8556
|
canvas.save();
|
|
8523
8557
|
canvas.clip();
|
|
8524
8558
|
canvas.drawImage(this.canvas.view, 0, 0, origin.width, origin.height, 0, 0, width, height);
|
|
@@ -8860,15 +8894,17 @@ let App = class App extends Leafer {
|
|
|
8860
8894
|
this.add(leafer);
|
|
8861
8895
|
return leafer;
|
|
8862
8896
|
}
|
|
8863
|
-
add(leafer) {
|
|
8897
|
+
add(leafer, index) {
|
|
8864
8898
|
if (!leafer.view) {
|
|
8865
8899
|
if (this.realCanvas && !this.canvas.bounds) {
|
|
8866
|
-
setTimeout(() => this.add(leafer), 10);
|
|
8900
|
+
setTimeout(() => this.add(leafer, index), 10);
|
|
8867
8901
|
return;
|
|
8868
8902
|
}
|
|
8869
8903
|
leafer.init(this.__getChildConfig(leafer.userConfig), this);
|
|
8870
8904
|
}
|
|
8871
|
-
super.add(leafer);
|
|
8905
|
+
super.add(leafer, index);
|
|
8906
|
+
if (index !== undefined)
|
|
8907
|
+
leafer.canvas.childIndex = index;
|
|
8872
8908
|
this.__listenChildEvents(leafer);
|
|
8873
8909
|
}
|
|
8874
8910
|
__onPropertyChange() {
|
|
@@ -9215,13 +9251,15 @@ const LeaferTypeCreator = {
|
|
|
9215
9251
|
};
|
|
9216
9252
|
const { list, register } = LeaferTypeCreator;
|
|
9217
9253
|
register('draw', () => { });
|
|
9254
|
+
register('custom', () => { });
|
|
9218
9255
|
register('design', addInteractionWindow);
|
|
9219
9256
|
register('document', document$1);
|
|
9220
9257
|
|
|
9221
|
-
Leafer.prototype
|
|
9258
|
+
const leafer = Leafer.prototype;
|
|
9259
|
+
leafer.initType = function (type) {
|
|
9222
9260
|
LeaferTypeCreator.run(type, this);
|
|
9223
9261
|
};
|
|
9224
|
-
|
|
9262
|
+
leafer.getValidMove = function (moveX, moveY) {
|
|
9225
9263
|
const { scroll, disabled } = this.app.config.move;
|
|
9226
9264
|
if (scroll) {
|
|
9227
9265
|
if (Math.abs(moveX) > Math.abs(moveY))
|
|
@@ -9251,7 +9289,7 @@ Leafer.prototype.getValidMove = function (moveX, moveY) {
|
|
|
9251
9289
|
}
|
|
9252
9290
|
return { x: disabled ? 0 : moveX, y: disabled ? 0 : moveY };
|
|
9253
9291
|
};
|
|
9254
|
-
|
|
9292
|
+
leafer.getValidScale = function (changeScale) {
|
|
9255
9293
|
const { scaleX } = this.zoomLayer.__, { min, max, disabled } = this.app.config.zoom, absScale = Math.abs(scaleX * changeScale);
|
|
9256
9294
|
if (absScale < min)
|
|
9257
9295
|
changeScale = min / scaleX;
|
|
@@ -9707,7 +9745,7 @@ const config = {
|
|
|
9707
9745
|
swipeDistance: 20,
|
|
9708
9746
|
preventDefaultMenu: true
|
|
9709
9747
|
},
|
|
9710
|
-
cursor:
|
|
9748
|
+
cursor: true,
|
|
9711
9749
|
keyEvent: true
|
|
9712
9750
|
};
|
|
9713
9751
|
|
|
@@ -10020,7 +10058,7 @@ class InteractionBase {
|
|
|
10020
10058
|
this.hoverData = data;
|
|
10021
10059
|
}
|
|
10022
10060
|
updateCursor(data) {
|
|
10023
|
-
if (this.config.cursor
|
|
10061
|
+
if (!this.config.cursor || !this.config.pointer.hover)
|
|
10024
10062
|
return;
|
|
10025
10063
|
if (!data) {
|
|
10026
10064
|
this.updateHoverData();
|
|
@@ -11269,7 +11307,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
11269
11307
|
width *= data.scaleX;
|
|
11270
11308
|
height *= data.scaleY;
|
|
11271
11309
|
}
|
|
11272
|
-
allowPaint = width * height > Platform.image.maxCacheSize;
|
|
11310
|
+
allowPaint = (width * height > Platform.image.maxCacheSize) || Export.running;
|
|
11273
11311
|
}
|
|
11274
11312
|
else {
|
|
11275
11313
|
allowPaint = false;
|
|
@@ -11781,7 +11819,8 @@ function createRows(drawData, content, style) {
|
|
|
11781
11819
|
if (breakAll) {
|
|
11782
11820
|
if (wordWidth)
|
|
11783
11821
|
addWord();
|
|
11784
|
-
|
|
11822
|
+
if (rowWidth)
|
|
11823
|
+
addRow();
|
|
11785
11824
|
}
|
|
11786
11825
|
else {
|
|
11787
11826
|
if (!afterBreak)
|
|
@@ -11789,10 +11828,12 @@ function createRows(drawData, content, style) {
|
|
|
11789
11828
|
if (langBreak || afterBreak || charType === Break || charType === Before || charType === Single || (wordWidth + charWidth > realWidth)) {
|
|
11790
11829
|
if (wordWidth)
|
|
11791
11830
|
addWord();
|
|
11792
|
-
|
|
11831
|
+
if (rowWidth)
|
|
11832
|
+
addRow();
|
|
11793
11833
|
}
|
|
11794
11834
|
else {
|
|
11795
|
-
|
|
11835
|
+
if (rowWidth)
|
|
11836
|
+
addRow();
|
|
11796
11837
|
}
|
|
11797
11838
|
}
|
|
11798
11839
|
}
|
|
@@ -12178,6 +12219,7 @@ const ExportModule = {
|
|
|
12178
12219
|
}
|
|
12179
12220
|
const { leafer } = leaf;
|
|
12180
12221
|
if (leafer) {
|
|
12222
|
+
checkLazy(leaf);
|
|
12181
12223
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
12182
12224
|
options = FileHelper.getExportOptions(options);
|
|
12183
12225
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
@@ -12185,6 +12227,8 @@ const ExportModule = {
|
|
|
12185
12227
|
const { slice, trim, onCanvas } = options;
|
|
12186
12228
|
let scale = options.scale || 1;
|
|
12187
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;
|
|
12188
12232
|
if (leaf.isApp) {
|
|
12189
12233
|
scale *= pixelRatio;
|
|
12190
12234
|
pixelRatio = leaf.app.pixelRatio;
|
|
@@ -12223,7 +12267,7 @@ const ExportModule = {
|
|
|
12223
12267
|
renderBounds = leaf.getBounds('render', relative);
|
|
12224
12268
|
}
|
|
12225
12269
|
const { x, y, width, height } = new Bounds(renderBounds).scale(scale);
|
|
12226
|
-
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 });
|
|
12227
12271
|
const renderOptions = { matrix: matrix.scale(1 / scale).invert().translate(-x, -y).withScale(1 / scaleX * scale, 1 / scaleY * scale) };
|
|
12228
12272
|
if (slice) {
|
|
12229
12273
|
leaf = leafer;
|
|
@@ -12269,6 +12313,12 @@ function addTask(task) {
|
|
|
12269
12313
|
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
12270
12314
|
});
|
|
12271
12315
|
}
|
|
12316
|
+
function checkLazy(leaf) {
|
|
12317
|
+
if (leaf.__.__needComputePaint)
|
|
12318
|
+
leaf.__.__computePaint();
|
|
12319
|
+
if (leaf.isBranch)
|
|
12320
|
+
leaf.children.forEach(child => checkLazy(child));
|
|
12321
|
+
}
|
|
12272
12322
|
|
|
12273
12323
|
const canvas = LeaferCanvasBase.prototype;
|
|
12274
12324
|
const debug = Debug.get('@leafer-ui/export');
|
|
@@ -12323,4 +12373,4 @@ Object.assign(Creator, {
|
|
|
12323
12373
|
});
|
|
12324
12374
|
useCanvas();
|
|
12325
12375
|
|
|
12326
|
-
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 };
|