leafer-ui 1.0.0-rc.28 → 1.0.0-rc.30
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 +11 -7
- package/dist/web.esm.js +15 -7
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +40 -36
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +40 -36
- package/dist/web.module.min.js +1 -1
- package/package.json +11 -11
package/dist/web.module.js
CHANGED
|
@@ -1555,7 +1555,7 @@ class LeafData {
|
|
|
1555
1555
|
if (this.__input && this.__input[name] !== undefined)
|
|
1556
1556
|
this.__input[name] = undefined;
|
|
1557
1557
|
}
|
|
1558
|
-
__getInputData(names) {
|
|
1558
|
+
__getInputData(names, options) {
|
|
1559
1559
|
const data = {};
|
|
1560
1560
|
if (names) {
|
|
1561
1561
|
if (names instanceof Array) {
|
|
@@ -1582,6 +1582,12 @@ class LeafData {
|
|
|
1582
1582
|
}
|
|
1583
1583
|
}
|
|
1584
1584
|
}
|
|
1585
|
+
if (options) {
|
|
1586
|
+
if (options.matrix) {
|
|
1587
|
+
const { a, b, c, d, e, f } = this.__leaf.__localMatrix;
|
|
1588
|
+
data.matrix = { a, b, c, d, e, f };
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1585
1591
|
return data;
|
|
1586
1592
|
}
|
|
1587
1593
|
__setMiddle(name, value) {
|
|
@@ -5200,11 +5206,13 @@ let Leaf = class Leaf {
|
|
|
5200
5206
|
setAttr(name, value) { this[name] = value; }
|
|
5201
5207
|
getAttr(name) { return this[name]; }
|
|
5202
5208
|
getComputedAttr(name) { return this.__[name]; }
|
|
5203
|
-
toJSON() {
|
|
5204
|
-
|
|
5209
|
+
toJSON(options) {
|
|
5210
|
+
if (options)
|
|
5211
|
+
this.__layout.update();
|
|
5212
|
+
return this.__.__getInputData(null, options);
|
|
5205
5213
|
}
|
|
5206
|
-
toString() {
|
|
5207
|
-
return JSON.stringify(this.toJSON());
|
|
5214
|
+
toString(options) {
|
|
5215
|
+
return JSON.stringify(this.toJSON(options));
|
|
5208
5216
|
}
|
|
5209
5217
|
toSVG() { return undefined; }
|
|
5210
5218
|
__SVG(_data) { }
|
|
@@ -5277,14 +5285,6 @@ let Leaf = class Leaf {
|
|
|
5277
5285
|
return this.__world;
|
|
5278
5286
|
}
|
|
5279
5287
|
}
|
|
5280
|
-
getWorld(attrName) {
|
|
5281
|
-
this.__layout.update();
|
|
5282
|
-
if (attrName === 'x')
|
|
5283
|
-
return this.__world.e;
|
|
5284
|
-
if (attrName === 'y')
|
|
5285
|
-
return this.__world.f;
|
|
5286
|
-
return this.getLayoutBounds()[attrName];
|
|
5287
|
-
}
|
|
5288
5288
|
getTransform(relative) {
|
|
5289
5289
|
return this.__layout.getTransform(relative || 'local');
|
|
5290
5290
|
}
|
|
@@ -5405,14 +5405,8 @@ let Leaf = class Leaf {
|
|
|
5405
5405
|
this.scaleY *= scaleY;
|
|
5406
5406
|
}
|
|
5407
5407
|
__scaleResize(_scaleX, _scaleY) { }
|
|
5408
|
-
resizeWidth(
|
|
5409
|
-
|
|
5410
|
-
this.scaleResize(scale, this.__.lockRatio ? scale : 1);
|
|
5411
|
-
}
|
|
5412
|
-
resizeHeight(height) {
|
|
5413
|
-
const scale = height / this.__localBoxBounds.height;
|
|
5414
|
-
this.scaleResize(this.__.lockRatio ? scale : 1, scale);
|
|
5415
|
-
}
|
|
5408
|
+
resizeWidth(_width) { }
|
|
5409
|
+
resizeHeight(_height) { }
|
|
5416
5410
|
__hitWorld(_point) { return true; }
|
|
5417
5411
|
__hit(_local) { return true; }
|
|
5418
5412
|
__hitFill(_inner) { return true; }
|
|
@@ -5763,7 +5757,7 @@ class LeafLevelList {
|
|
|
5763
5757
|
}
|
|
5764
5758
|
}
|
|
5765
5759
|
|
|
5766
|
-
const version = "1.0.0-rc.
|
|
5760
|
+
const version = "1.0.0-rc.30";
|
|
5767
5761
|
const inviteCode = {};
|
|
5768
5762
|
|
|
5769
5763
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
@@ -5871,6 +5865,10 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
5871
5865
|
this.resizeObserver.observe(parent);
|
|
5872
5866
|
this.checkAutoBounds(parent.getBoundingClientRect());
|
|
5873
5867
|
}
|
|
5868
|
+
else {
|
|
5869
|
+
this.checkAutoBounds(this.view);
|
|
5870
|
+
debug$7.warn('no parent');
|
|
5871
|
+
}
|
|
5874
5872
|
}
|
|
5875
5873
|
catch (_a) {
|
|
5876
5874
|
this.imitateResizeObserver();
|
|
@@ -7729,9 +7727,9 @@ let Group = class Group extends UI {
|
|
|
7729
7727
|
super.set(data);
|
|
7730
7728
|
}
|
|
7731
7729
|
}
|
|
7732
|
-
toJSON() {
|
|
7733
|
-
const data = super.toJSON();
|
|
7734
|
-
data.children = this.children.map(child => child.toJSON());
|
|
7730
|
+
toJSON(options) {
|
|
7731
|
+
const data = super.toJSON(options);
|
|
7732
|
+
data.children = this.children.map(child => child.toJSON(options));
|
|
7735
7733
|
return data;
|
|
7736
7734
|
}
|
|
7737
7735
|
pick(_hitPoint, _options) { return undefined; }
|
|
@@ -7898,6 +7896,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7898
7896
|
__onResize(event) {
|
|
7899
7897
|
this.emitEvent(event);
|
|
7900
7898
|
DataHelper.copyAttrs(this.__, event, canvasSizeAttrs);
|
|
7899
|
+
if (!event.width || !event.height)
|
|
7900
|
+
debug$3.warn('w = 0 or h = 0');
|
|
7901
7901
|
setTimeout(() => { if (this.canvasManager)
|
|
7902
7902
|
this.canvasManager.clearRecycled(); }, 0);
|
|
7903
7903
|
}
|
|
@@ -7921,6 +7921,8 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7921
7921
|
__setAttr(attrName, newValue) {
|
|
7922
7922
|
if (this.canvas) {
|
|
7923
7923
|
if (canvasSizeAttrs.includes(attrName)) {
|
|
7924
|
+
if (!newValue)
|
|
7925
|
+
debug$3.warn(attrName + ' is 0');
|
|
7924
7926
|
this.__changeCanvasSize(attrName, newValue);
|
|
7925
7927
|
}
|
|
7926
7928
|
else if (attrName === 'fill') {
|
|
@@ -9693,7 +9695,7 @@ function emitAppChildren(leaf, type, data, capture, excludePath) {
|
|
|
9693
9695
|
}
|
|
9694
9696
|
function emitEvent(leaf, type, data, capture, excludePath) {
|
|
9695
9697
|
if (leaf.destroyed)
|
|
9696
|
-
return
|
|
9698
|
+
return false;
|
|
9697
9699
|
if (leaf.__.hitSelf && !exclude(leaf, excludePath)) {
|
|
9698
9700
|
if (State.updateEventStyle)
|
|
9699
9701
|
State.updateEventStyle(leaf, type);
|
|
@@ -9795,9 +9797,7 @@ class InteractionBase {
|
|
|
9795
9797
|
this.tapWait();
|
|
9796
9798
|
this.longPressWait(data);
|
|
9797
9799
|
}
|
|
9798
|
-
|
|
9799
|
-
this.waitMenuTap = true;
|
|
9800
|
-
}
|
|
9800
|
+
this.waitMenuTap = PointerButton.right(data);
|
|
9801
9801
|
this.dragger.setDragData(data);
|
|
9802
9802
|
if (!this.isHoldRightKey)
|
|
9803
9803
|
this.updateCursor(data);
|
|
@@ -10643,6 +10643,8 @@ class Interaction extends InteractionBase {
|
|
|
10643
10643
|
onWheel(e) {
|
|
10644
10644
|
this.preventDefaultWheel(e);
|
|
10645
10645
|
const { wheel } = this.config;
|
|
10646
|
+
if (wheel.disabled)
|
|
10647
|
+
return;
|
|
10646
10648
|
const scale = wheel.getScale ? wheel.getScale(e, wheel) : WheelEventHelper.getScale(e, wheel);
|
|
10647
10649
|
const local = this.getLocal(e);
|
|
10648
10650
|
const eventBase = InteractionHelper.getBase(e);
|
|
@@ -12036,7 +12038,9 @@ function layoutText(drawData, style) {
|
|
|
12036
12038
|
bounds.height = realHeight;
|
|
12037
12039
|
}
|
|
12038
12040
|
|
|
12039
|
-
function clipText(drawData, style) {
|
|
12041
|
+
function clipText(drawData, style, x, width) {
|
|
12042
|
+
if (!width)
|
|
12043
|
+
return;
|
|
12040
12044
|
const { rows, overflow } = drawData;
|
|
12041
12045
|
let { textOverflow } = style;
|
|
12042
12046
|
rows.splice(overflow);
|
|
@@ -12047,7 +12051,7 @@ function clipText(drawData, style) {
|
|
|
12047
12051
|
textOverflow = '...';
|
|
12048
12052
|
let char, charRight;
|
|
12049
12053
|
const ellipsisWidth = textOverflow ? Platform.canvas.measureText(textOverflow).width : 0;
|
|
12050
|
-
const right =
|
|
12054
|
+
const right = x + width - ellipsisWidth;
|
|
12051
12055
|
const list = style.textWrap === 'none' ? rows : [rows[overflow - 1]];
|
|
12052
12056
|
list.forEach(row => {
|
|
12053
12057
|
if (row.isOverflow && row.data) {
|
|
@@ -12123,7 +12127,7 @@ function getDrawData(content, style) {
|
|
|
12123
12127
|
layoutText(drawData, style);
|
|
12124
12128
|
layoutChar(drawData, style, width);
|
|
12125
12129
|
if (drawData.overflow)
|
|
12126
|
-
clipText(drawData, style);
|
|
12130
|
+
clipText(drawData, style, x, width);
|
|
12127
12131
|
if (textDecoration !== 'none')
|
|
12128
12132
|
decorationText(drawData, style);
|
|
12129
12133
|
return drawData;
|
|
@@ -12194,6 +12198,8 @@ function getTrimBounds(canvas) {
|
|
|
12194
12198
|
const ExportModule = {
|
|
12195
12199
|
export(leaf, filename, options) {
|
|
12196
12200
|
this.running = true;
|
|
12201
|
+
const fileType = FileHelper.fileType(filename);
|
|
12202
|
+
options = FileHelper.getExportOptions(options);
|
|
12197
12203
|
return addTask((success) => new Promise((resolve) => {
|
|
12198
12204
|
const over = (result) => {
|
|
12199
12205
|
success(result);
|
|
@@ -12202,12 +12208,11 @@ const ExportModule = {
|
|
|
12202
12208
|
};
|
|
12203
12209
|
const { toURL } = Platform;
|
|
12204
12210
|
const { download } = Platform.origin;
|
|
12205
|
-
const fileType = FileHelper.fileType(filename);
|
|
12206
12211
|
if (filename === 'json') {
|
|
12207
|
-
return over({ data: leaf.toJSON() });
|
|
12212
|
+
return over({ data: leaf.toJSON(options.json) });
|
|
12208
12213
|
}
|
|
12209
12214
|
else if (fileType === 'json') {
|
|
12210
|
-
download(toURL(JSON.stringify(leaf.toJSON()), 'text'), filename);
|
|
12215
|
+
download(toURL(JSON.stringify(leaf.toJSON(options.json)), 'text'), filename);
|
|
12211
12216
|
return over({ data: true });
|
|
12212
12217
|
}
|
|
12213
12218
|
if (filename === 'svg') {
|
|
@@ -12221,7 +12226,6 @@ const ExportModule = {
|
|
|
12221
12226
|
if (leafer) {
|
|
12222
12227
|
checkLazy(leaf);
|
|
12223
12228
|
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
12224
|
-
options = FileHelper.getExportOptions(options);
|
|
12225
12229
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
12226
12230
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
12227
12231
|
const { slice, trim, onCanvas } = options;
|