leafer-ui 1.0.4 → 1.0.5
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 +30 -12
- package/dist/web.cjs +33 -25
- package/dist/web.esm.js +33 -25
- package/dist/web.esm.min.js +1 -1
- package/dist/web.js +89 -73
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.module.js +89 -73
- package/dist/web.module.min.js +1 -1
- package/package.json +14 -14
package/dist/web.module.js
CHANGED
|
@@ -4755,6 +4755,7 @@ class RenderEvent extends Event {
|
|
|
4755
4755
|
}
|
|
4756
4756
|
}
|
|
4757
4757
|
RenderEvent.REQUEST = 'render.request';
|
|
4758
|
+
RenderEvent.CHILD_START = 'render.child_start';
|
|
4758
4759
|
RenderEvent.START = 'render.start';
|
|
4759
4760
|
RenderEvent.BEFORE = 'render.before';
|
|
4760
4761
|
RenderEvent.RENDER = 'render';
|
|
@@ -4930,7 +4931,7 @@ const { isFinite } = Number;
|
|
|
4930
4931
|
const debug$8 = Debug.get('setAttr');
|
|
4931
4932
|
const LeafDataProxy = {
|
|
4932
4933
|
__setAttr(name, newValue, checkFiniteNumber) {
|
|
4933
|
-
if (this.
|
|
4934
|
+
if (this.leaferIsCreated) {
|
|
4934
4935
|
const oldValue = this.__.__getInput(name);
|
|
4935
4936
|
if (checkFiniteNumber && !isFinite(newValue) && newValue !== undefined) {
|
|
4936
4937
|
debug$8.warn(this.innerName, name, newValue);
|
|
@@ -5002,7 +5003,7 @@ const LeafMatrix = {
|
|
|
5002
5003
|
|
|
5003
5004
|
const { updateMatrix: updateMatrix$1, updateAllMatrix: updateAllMatrix$2 } = LeafHelper;
|
|
5004
5005
|
const { updateBounds: updateBounds$1 } = BranchHelper;
|
|
5005
|
-
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$
|
|
5006
|
+
const { toOuterOf: toOuterOf$1, copyAndSpread: copyAndSpread$1, copy: copy$5 } = BoundsHelper;
|
|
5006
5007
|
const { toBounds: toBounds$2 } = PathBounds;
|
|
5007
5008
|
const LeafBounds = {
|
|
5008
5009
|
__updateWorldBounds() {
|
|
@@ -5085,7 +5086,7 @@ const LeafBounds = {
|
|
|
5085
5086
|
const b = this.__layout.boxBounds;
|
|
5086
5087
|
const data = this.__;
|
|
5087
5088
|
if (data.__pathInputed) {
|
|
5088
|
-
toBounds$2(data.
|
|
5089
|
+
toBounds$2(data.path, b);
|
|
5089
5090
|
}
|
|
5090
5091
|
else {
|
|
5091
5092
|
b.x = 0;
|
|
@@ -5097,7 +5098,7 @@ const LeafBounds = {
|
|
|
5097
5098
|
__updateAutoLayout() {
|
|
5098
5099
|
this.__layout.matrixChanged = true;
|
|
5099
5100
|
if (this.isBranch) {
|
|
5100
|
-
if (this.
|
|
5101
|
+
if (this.leaferIsReady)
|
|
5101
5102
|
this.leafer.layouter.addExtra(this);
|
|
5102
5103
|
if (this.__.flow) {
|
|
5103
5104
|
if (this.__layout.boxChanged)
|
|
@@ -5123,11 +5124,11 @@ const LeafBounds = {
|
|
|
5123
5124
|
},
|
|
5124
5125
|
__updateStrokeBounds() {
|
|
5125
5126
|
const layout = this.__layout;
|
|
5126
|
-
copyAndSpread$
|
|
5127
|
+
copyAndSpread$1(layout.strokeBounds, layout.boxBounds, layout.strokeBoxSpread);
|
|
5127
5128
|
},
|
|
5128
5129
|
__updateRenderBounds() {
|
|
5129
5130
|
const layout = this.__layout;
|
|
5130
|
-
layout.renderSpread > 0 ? copyAndSpread$
|
|
5131
|
+
layout.renderSpread > 0 ? copyAndSpread$1(layout.renderBounds, layout.boxBounds, layout.renderSpread) : copy$5(layout.renderBounds, layout.strokeBounds);
|
|
5131
5132
|
}
|
|
5132
5133
|
};
|
|
5133
5134
|
|
|
@@ -5232,6 +5233,8 @@ let Leaf = class Leaf {
|
|
|
5232
5233
|
get innerName() { return this.__.name || this.tag + this.innerId; }
|
|
5233
5234
|
get __DataProcessor() { return LeafData; }
|
|
5234
5235
|
get __LayoutProcessor() { return LeafLayout; }
|
|
5236
|
+
get leaferIsCreated() { return this.leafer && this.leafer.created; }
|
|
5237
|
+
get leaferIsReady() { return this.leafer && this.leafer.ready; }
|
|
5235
5238
|
get isLeafer() { return false; }
|
|
5236
5239
|
get isBranch() { return false; }
|
|
5237
5240
|
get isBranchLeaf() { return false; }
|
|
@@ -5673,6 +5676,7 @@ let Branch = class Branch extends Leaf {
|
|
|
5673
5676
|
add(child, index) {
|
|
5674
5677
|
if (child === this)
|
|
5675
5678
|
return;
|
|
5679
|
+
child.__ || (child = UICreator.get(child.tag, child));
|
|
5676
5680
|
if (child.parent)
|
|
5677
5681
|
child.parent.remove(child);
|
|
5678
5682
|
child.parent = this;
|
|
@@ -5695,10 +5699,14 @@ let Branch = class Branch extends Leaf {
|
|
|
5695
5699
|
}
|
|
5696
5700
|
remove(child, destroy) {
|
|
5697
5701
|
if (child) {
|
|
5698
|
-
if (child.
|
|
5699
|
-
|
|
5702
|
+
if (child.__) {
|
|
5703
|
+
if (child.animationOut)
|
|
5704
|
+
child.__runAnimation('out', () => this.__remove(child, destroy));
|
|
5705
|
+
else
|
|
5706
|
+
this.__remove(child, destroy);
|
|
5707
|
+
}
|
|
5700
5708
|
else
|
|
5701
|
-
this.
|
|
5709
|
+
this.find(child).forEach(item => this.remove(item, destroy));
|
|
5702
5710
|
}
|
|
5703
5711
|
else if (child === undefined) {
|
|
5704
5712
|
super.remove(null, destroy);
|
|
@@ -5916,7 +5924,7 @@ class LeafLevelList {
|
|
|
5916
5924
|
}
|
|
5917
5925
|
}
|
|
5918
5926
|
|
|
5919
|
-
const version = "1.0.
|
|
5927
|
+
const version = "1.0.5";
|
|
5920
5928
|
|
|
5921
5929
|
const debug$7 = Debug.get('LeaferCanvas');
|
|
5922
5930
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6558,6 +6566,7 @@ class Renderer {
|
|
|
6558
6566
|
this.totalBounds = new Bounds();
|
|
6559
6567
|
debug$5.log(target.innerName, '--->');
|
|
6560
6568
|
try {
|
|
6569
|
+
target.app.emit(RenderEvent.CHILD_START, target);
|
|
6561
6570
|
this.emitRender(RenderEvent.START);
|
|
6562
6571
|
this.renderOnce(callback);
|
|
6563
6572
|
this.emitRender(RenderEvent.END, this.totalBounds);
|
|
@@ -6855,7 +6864,7 @@ class Picker {
|
|
|
6855
6864
|
if (child.isBranch) {
|
|
6856
6865
|
if (hit || child.__ignoreHitWorld) {
|
|
6857
6866
|
this.eachFind(child.children, child.__onlyHitMask);
|
|
6858
|
-
if (child.isBranchLeaf
|
|
6867
|
+
if (child.isBranchLeaf)
|
|
6859
6868
|
this.hitChild(child, point);
|
|
6860
6869
|
}
|
|
6861
6870
|
}
|
|
@@ -7565,12 +7574,7 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7565
7574
|
this.__drawPathByData(canvas, this.__.path);
|
|
7566
7575
|
}
|
|
7567
7576
|
__drawPathByData(drawer, data) {
|
|
7568
|
-
|
|
7569
|
-
PathDrawer.drawPathByData(drawer, data);
|
|
7570
|
-
}
|
|
7571
|
-
else {
|
|
7572
|
-
this.__drawPathByBox(drawer);
|
|
7573
|
-
}
|
|
7577
|
+
data ? PathDrawer.drawPathByData(drawer, data) : this.__drawPathByBox(drawer);
|
|
7574
7578
|
}
|
|
7575
7579
|
__drawPathByBox(drawer) {
|
|
7576
7580
|
const { x, y, width, height } = this.__layout.boxBounds;
|
|
@@ -7578,9 +7582,8 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7578
7582
|
const { cornerRadius } = this.__;
|
|
7579
7583
|
drawer.roundRect(x, y, width, height, typeof cornerRadius === 'number' ? [cornerRadius] : cornerRadius);
|
|
7580
7584
|
}
|
|
7581
|
-
else
|
|
7585
|
+
else
|
|
7582
7586
|
drawer.rect(x, y, width, height);
|
|
7583
|
-
}
|
|
7584
7587
|
}
|
|
7585
7588
|
animate(_keyframe, _options, _type, _isTemp) {
|
|
7586
7589
|
return needPlugin('animate');
|
|
@@ -8263,10 +8266,9 @@ Rect = __decorate([
|
|
|
8263
8266
|
registerUI()
|
|
8264
8267
|
], Rect);
|
|
8265
8268
|
|
|
8266
|
-
const
|
|
8267
|
-
const group$1 = Group.prototype;
|
|
8269
|
+
const { copy: copy$3, add, includes: includes$1 } = BoundsHelper;
|
|
8270
|
+
const rect$1 = Rect.prototype, group$1 = Group.prototype;
|
|
8268
8271
|
const childrenRenderBounds = {};
|
|
8269
|
-
const { copy: copy$3, add, includes: includes$1, copyAndSpread: copyAndSpread$1 } = BoundsHelper;
|
|
8270
8272
|
let Box = class Box extends Group {
|
|
8271
8273
|
get __tag() { return 'Box'; }
|
|
8272
8274
|
get isBranchLeaf() { return true; }
|
|
@@ -8280,29 +8282,27 @@ let Box = class Box extends Group {
|
|
|
8280
8282
|
return this.__updateRectRenderSpread() || -1;
|
|
8281
8283
|
}
|
|
8282
8284
|
__updateRectBoxBounds() { }
|
|
8283
|
-
__updateBoxBounds(
|
|
8285
|
+
__updateBoxBounds(_secondLayout) {
|
|
8284
8286
|
const data = this.__;
|
|
8285
8287
|
if (this.children.length) {
|
|
8286
8288
|
if (data.__autoSide) {
|
|
8287
|
-
if (this.leafer && this.leafer.ready)
|
|
8288
|
-
this.leafer.layouter.addExtra(this);
|
|
8289
8289
|
super.__updateBoxBounds();
|
|
8290
8290
|
const { boxBounds } = this.__layout;
|
|
8291
8291
|
if (!data.__autoSize) {
|
|
8292
|
-
if (data.__autoWidth)
|
|
8293
|
-
boxBounds.width += boxBounds.x, boxBounds.
|
|
8294
|
-
|
|
8295
|
-
|
|
8292
|
+
if (data.__autoWidth) {
|
|
8293
|
+
boxBounds.width += boxBounds.x, boxBounds.x = 0;
|
|
8294
|
+
boxBounds.height = data.height, boxBounds.y = 0;
|
|
8295
|
+
}
|
|
8296
|
+
else {
|
|
8297
|
+
boxBounds.height += boxBounds.y, boxBounds.y = 0;
|
|
8298
|
+
boxBounds.width = data.width, boxBounds.x = 0;
|
|
8299
|
+
}
|
|
8296
8300
|
}
|
|
8297
|
-
if (secondLayout && data.flow && data.padding)
|
|
8298
|
-
copyAndSpread$1(boxBounds, boxBounds, data.padding, false, data.__autoSize ? null : (data.__autoWidth ? 'width' : 'height'));
|
|
8299
8301
|
this.__updateNaturalSize();
|
|
8300
8302
|
}
|
|
8301
8303
|
else {
|
|
8302
8304
|
this.__updateRectBoxBounds();
|
|
8303
8305
|
}
|
|
8304
|
-
if (data.flow)
|
|
8305
|
-
this.__updateContentBounds();
|
|
8306
8306
|
}
|
|
8307
8307
|
else {
|
|
8308
8308
|
this.__updateRectBoxBounds();
|
|
@@ -8368,6 +8368,9 @@ __decorate([
|
|
|
8368
8368
|
__decorate([
|
|
8369
8369
|
dataType(false)
|
|
8370
8370
|
], Box.prototype, "resizeChildren", void 0);
|
|
8371
|
+
__decorate([
|
|
8372
|
+
dataType(false)
|
|
8373
|
+
], Box.prototype, "textBox", void 0);
|
|
8371
8374
|
__decorate([
|
|
8372
8375
|
affectRenderBoundsType('show')
|
|
8373
8376
|
], Box.prototype, "overflow", void 0);
|
|
@@ -8897,6 +8900,9 @@ __decorate([
|
|
|
8897
8900
|
__decorate([
|
|
8898
8901
|
boundsType('top')
|
|
8899
8902
|
], Text.prototype, "verticalAlign", void 0);
|
|
8903
|
+
__decorate([
|
|
8904
|
+
boundsType(true)
|
|
8905
|
+
], Text.prototype, "autoSizeAlign", void 0);
|
|
8900
8906
|
__decorate([
|
|
8901
8907
|
boundsType('normal')
|
|
8902
8908
|
], Text.prototype, "textWrap", void 0);
|
|
@@ -9617,9 +9623,10 @@ class Dragger {
|
|
|
9617
9623
|
this.dragData = getDragEventData(data, data, data);
|
|
9618
9624
|
this.canAnimate = this.canDragOut = true;
|
|
9619
9625
|
}
|
|
9620
|
-
getList() {
|
|
9626
|
+
getList(realDraggable, hover) {
|
|
9621
9627
|
const { proxy } = this.interaction.selector;
|
|
9622
|
-
|
|
9628
|
+
const hasProxyList = proxy && proxy.list.length, dragList = DragEvent.list || this.draggableList || emptyList;
|
|
9629
|
+
return this.dragging && (hasProxyList ? (realDraggable ? emptyList : new LeafList(hover ? [...proxy.list, ...proxy.dragHoverExclude] : proxy.list)) : dragList);
|
|
9623
9630
|
}
|
|
9624
9631
|
checkDrag(data, canDrag) {
|
|
9625
9632
|
const { interaction } = this;
|
|
@@ -9644,8 +9651,8 @@ class Dragger {
|
|
|
9644
9651
|
this.dragging = canDrag && PointerButton.left(data);
|
|
9645
9652
|
if (this.dragging) {
|
|
9646
9653
|
this.interaction.emit(DragEvent.START, this.dragData);
|
|
9647
|
-
this.
|
|
9648
|
-
this.setDragStartPoints(this.
|
|
9654
|
+
this.getDraggableList(this.dragData.path);
|
|
9655
|
+
this.setDragStartPoints(this.realDraggableList = this.getList(true));
|
|
9649
9656
|
}
|
|
9650
9657
|
}
|
|
9651
9658
|
}
|
|
@@ -9653,12 +9660,12 @@ class Dragger {
|
|
|
9653
9660
|
this.dragStartPoints = {};
|
|
9654
9661
|
list.forEach(leaf => this.dragStartPoints[leaf.innerId] = { x: leaf.x, y: leaf.y });
|
|
9655
9662
|
}
|
|
9656
|
-
|
|
9663
|
+
getDraggableList(path) {
|
|
9657
9664
|
let leaf;
|
|
9658
9665
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
9659
9666
|
leaf = path.list[i];
|
|
9660
|
-
if ((leaf.
|
|
9661
|
-
this.
|
|
9667
|
+
if ((leaf.draggable || leaf.editable) && leaf.hitSelf && !leaf.locked) {
|
|
9668
|
+
this.draggableList = new LeafList(leaf);
|
|
9662
9669
|
break;
|
|
9663
9670
|
}
|
|
9664
9671
|
}
|
|
@@ -9683,7 +9690,7 @@ class Dragger {
|
|
|
9683
9690
|
}
|
|
9684
9691
|
dragReal() {
|
|
9685
9692
|
const { running } = this.interaction;
|
|
9686
|
-
const list = this.
|
|
9693
|
+
const list = this.realDraggableList;
|
|
9687
9694
|
if (list.length && running) {
|
|
9688
9695
|
const { totalX, totalY } = this.dragData;
|
|
9689
9696
|
list.forEach(leaf => leaf.draggable && leaf.move(DragEvent.getValidMove(leaf, this.dragStartPoints[leaf.innerId], { x: totalX, y: totalY })));
|
|
@@ -9772,7 +9779,7 @@ class Dragger {
|
|
|
9772
9779
|
this.interaction.emit(DragEvent.LEAVE, data, dragEnterPath);
|
|
9773
9780
|
}
|
|
9774
9781
|
dragReset() {
|
|
9775
|
-
DragEvent.list = DragEvent.data = this.
|
|
9782
|
+
DragEvent.list = DragEvent.data = this.draggableList = this.dragData = this.downData = this.dragOverPath = this.dragEnterPath = null;
|
|
9776
9783
|
}
|
|
9777
9784
|
checkDragOut(data) {
|
|
9778
9785
|
const { interaction } = this;
|
|
@@ -9913,6 +9920,7 @@ const config = {
|
|
|
9913
9920
|
touch: {
|
|
9914
9921
|
preventDefault: true
|
|
9915
9922
|
},
|
|
9923
|
+
multiTouch: {},
|
|
9916
9924
|
cursor: true,
|
|
9917
9925
|
keyEvent: true
|
|
9918
9926
|
};
|
|
@@ -10039,6 +10047,8 @@ class InteractionBase {
|
|
|
10039
10047
|
this.pointerUp(data);
|
|
10040
10048
|
}
|
|
10041
10049
|
multiTouch(data, list) {
|
|
10050
|
+
if (this.config.multiTouch.disabled)
|
|
10051
|
+
return;
|
|
10042
10052
|
const { move, angle, scale, center } = MultiTouchHelper.getData(list);
|
|
10043
10053
|
this.rotate(getRotateEventData$1(center, angle, data));
|
|
10044
10054
|
this.zoom(getZoomEventData$1(center, scale, data));
|
|
@@ -10228,7 +10238,7 @@ class InteractionBase {
|
|
|
10228
10238
|
data = this.hoverData;
|
|
10229
10239
|
if (!data)
|
|
10230
10240
|
return;
|
|
10231
|
-
this.findPath(data, { exclude: this.dragger.getList(), name: PointerEvent.MOVE });
|
|
10241
|
+
this.findPath(data, { exclude: this.dragger.getList(false, true), name: PointerEvent.MOVE });
|
|
10232
10242
|
this.hoverData = data;
|
|
10233
10243
|
}
|
|
10234
10244
|
updateCursor(data) {
|
|
@@ -10250,7 +10260,7 @@ class InteractionBase {
|
|
|
10250
10260
|
const { path } = data;
|
|
10251
10261
|
for (let i = 0, len = path.length; i < len; i++) {
|
|
10252
10262
|
leaf = path.list[i];
|
|
10253
|
-
cursor = leaf.syncEventer
|
|
10263
|
+
cursor = (leaf.syncEventer && leaf.syncEventer.cursor) || leaf.cursor;
|
|
10254
10264
|
if (cursor)
|
|
10255
10265
|
break;
|
|
10256
10266
|
}
|
|
@@ -10432,7 +10442,7 @@ ui$2.__updateHitCanvas = function () {
|
|
|
10432
10442
|
if (isHitPixel) {
|
|
10433
10443
|
const { renderBounds } = this.__layout;
|
|
10434
10444
|
const size = Platform.image.hitCanvasSize;
|
|
10435
|
-
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds
|
|
10445
|
+
const scale = h.hitScale = tempBounds$1.set(0, 0, size, size).getFitMatrix(renderBounds).a;
|
|
10436
10446
|
const { x, y, width, height } = tempBounds$1.set(renderBounds).scale(scale);
|
|
10437
10447
|
h.resize({ width, height, pixelRatio: 1 });
|
|
10438
10448
|
h.clear();
|
|
@@ -10488,15 +10498,14 @@ ui$2.__hit = function (inner) {
|
|
|
10488
10498
|
return hitWidth ? this.__hitStroke(inner, hitWidth) : false;
|
|
10489
10499
|
};
|
|
10490
10500
|
|
|
10491
|
-
const ui$1 =
|
|
10492
|
-
|
|
10493
|
-
rect.__updateHitCanvas = function () {
|
|
10501
|
+
const ui$1 = UI.prototype, rect = Rect.prototype, box$1 = Box.prototype;
|
|
10502
|
+
rect.__updateHitCanvas = box$1.__updateHitCanvas = function () {
|
|
10494
10503
|
if (this.stroke || this.cornerRadius || ((this.fill || this.__.__isCanvas) && this.hitFill === 'pixel') || this.hitStroke === 'all')
|
|
10495
10504
|
ui$1.__updateHitCanvas.call(this);
|
|
10496
10505
|
else if (this.__hitCanvas)
|
|
10497
10506
|
this.__hitCanvas = null;
|
|
10498
10507
|
};
|
|
10499
|
-
rect.__hitFill = function (inner) {
|
|
10508
|
+
rect.__hitFill = box$1.__hitFill = function (inner) {
|
|
10500
10509
|
return this.__hitCanvas ? ui$1.__hitFill.call(this, inner) : BoundsHelper.hitRadiusPoint(this.__layout.boxBounds, inner);
|
|
10501
10510
|
};
|
|
10502
10511
|
|
|
@@ -11347,9 +11356,10 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
|
|
|
11347
11356
|
onLoadError(ui, event, image.error);
|
|
11348
11357
|
}
|
|
11349
11358
|
else {
|
|
11350
|
-
|
|
11351
|
-
|
|
11359
|
+
if (firstUse) {
|
|
11360
|
+
ignoreRender(ui, true);
|
|
11352
11361
|
onLoad(ui, event);
|
|
11362
|
+
}
|
|
11353
11363
|
leafPaint.loadId = image.load(() => {
|
|
11354
11364
|
ignoreRender(ui, false);
|
|
11355
11365
|
if (!ui.destroyed) {
|
|
@@ -11961,11 +11971,12 @@ const { trimRight } = TextRowHelper;
|
|
|
11961
11971
|
const { Letter, Single, Before, After, Symbol, Break } = CharType;
|
|
11962
11972
|
let word, row, wordWidth, rowWidth, realWidth;
|
|
11963
11973
|
let char, charWidth, startCharSize, charSize, charType, lastCharType, langBreak, afterBreak, paraStart;
|
|
11964
|
-
let textDrawData, rows = [], bounds;
|
|
11974
|
+
let textDrawData, rows = [], bounds, findMaxWidth;
|
|
11965
11975
|
function createRows(drawData, content, style) {
|
|
11966
11976
|
textDrawData = drawData;
|
|
11967
11977
|
rows = drawData.rows;
|
|
11968
11978
|
bounds = drawData.bounds;
|
|
11979
|
+
findMaxWidth = !bounds.width && !style.autoSizeAlign;
|
|
11969
11980
|
const { __letterSpacing, paraIndent, textCase } = style;
|
|
11970
11981
|
const { canvas } = Platform;
|
|
11971
11982
|
const { width, height } = bounds;
|
|
@@ -12050,7 +12061,10 @@ function createRows(drawData, content, style) {
|
|
|
12050
12061
|
else {
|
|
12051
12062
|
content.split('\n').forEach(content => {
|
|
12052
12063
|
textDrawData.paraNumber++;
|
|
12053
|
-
|
|
12064
|
+
rowWidth = canvas.measureText(content).width;
|
|
12065
|
+
rows.push({ x: paraIndent || 0, text: content, width: rowWidth, paraStart: true });
|
|
12066
|
+
if (findMaxWidth)
|
|
12067
|
+
setMaxWidth();
|
|
12054
12068
|
});
|
|
12055
12069
|
}
|
|
12056
12070
|
}
|
|
@@ -12081,10 +12095,16 @@ function addRow() {
|
|
|
12081
12095
|
row.width = rowWidth;
|
|
12082
12096
|
if (bounds.width)
|
|
12083
12097
|
trimRight(row);
|
|
12098
|
+
else if (findMaxWidth)
|
|
12099
|
+
setMaxWidth();
|
|
12084
12100
|
rows.push(row);
|
|
12085
12101
|
row = { words: [] };
|
|
12086
12102
|
rowWidth = 0;
|
|
12087
12103
|
}
|
|
12104
|
+
function setMaxWidth() {
|
|
12105
|
+
if (rowWidth > (textDrawData.maxWidth || 0))
|
|
12106
|
+
textDrawData.maxWidth = rowWidth;
|
|
12107
|
+
}
|
|
12088
12108
|
|
|
12089
12109
|
const CharMode = 0;
|
|
12090
12110
|
const WordMode = 1;
|
|
@@ -12156,34 +12176,32 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
12156
12176
|
|
|
12157
12177
|
function layoutText(drawData, style) {
|
|
12158
12178
|
const { rows, bounds } = drawData;
|
|
12159
|
-
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing } = style;
|
|
12179
|
+
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
12160
12180
|
let { x, y, width, height } = bounds, realHeight = __lineHeight * rows.length + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
12161
12181
|
let starY = __baseLine;
|
|
12162
12182
|
if (__clipText && realHeight > height) {
|
|
12163
12183
|
realHeight = Math.max(height, __lineHeight);
|
|
12164
12184
|
drawData.overflow = rows.length;
|
|
12165
12185
|
}
|
|
12166
|
-
else {
|
|
12186
|
+
else if (height || autoSizeAlign) {
|
|
12167
12187
|
switch (verticalAlign) {
|
|
12168
12188
|
case 'middle':
|
|
12169
12189
|
y += (height - realHeight) / 2;
|
|
12170
12190
|
break;
|
|
12171
|
-
case 'bottom':
|
|
12172
|
-
y += (height - realHeight);
|
|
12191
|
+
case 'bottom': y += (height - realHeight);
|
|
12173
12192
|
}
|
|
12174
12193
|
}
|
|
12175
12194
|
starY += y;
|
|
12176
|
-
let row, rowX, rowWidth;
|
|
12195
|
+
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
12177
12196
|
for (let i = 0, len = rows.length; i < len; i++) {
|
|
12178
12197
|
row = rows[i];
|
|
12179
12198
|
row.x = x;
|
|
12180
12199
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
12181
12200
|
switch (textAlign) {
|
|
12182
12201
|
case 'center':
|
|
12183
|
-
row.x += (
|
|
12202
|
+
row.x += (layoutWidth - row.width) / 2;
|
|
12184
12203
|
break;
|
|
12185
|
-
case 'right':
|
|
12186
|
-
row.x += width - row.width;
|
|
12204
|
+
case 'right': row.x += layoutWidth - row.width;
|
|
12187
12205
|
}
|
|
12188
12206
|
}
|
|
12189
12207
|
if (row.paraStart && paraSpacing && i > 0)
|
|
@@ -12288,14 +12306,14 @@ function getDrawData(content, style) {
|
|
|
12288
12306
|
let height = style.__getInput('height') || 0;
|
|
12289
12307
|
const { textDecoration, __font, __padding: padding } = style;
|
|
12290
12308
|
if (padding) {
|
|
12291
|
-
if (width)
|
|
12309
|
+
if (width)
|
|
12310
|
+
x = padding[left], width -= (padding[right] + padding[left]);
|
|
12311
|
+
else if (!style.autoSizeAlign)
|
|
12292
12312
|
x = padding[left];
|
|
12293
|
-
|
|
12294
|
-
|
|
12295
|
-
if (
|
|
12313
|
+
if (height)
|
|
12314
|
+
y = padding[top], height -= (padding[top] + padding[bottom]);
|
|
12315
|
+
else if (!style.autoSizeAlign)
|
|
12296
12316
|
y = padding[top];
|
|
12297
|
-
height -= (padding[top] + padding[bottom]);
|
|
12298
|
-
}
|
|
12299
12317
|
}
|
|
12300
12318
|
const drawData = {
|
|
12301
12319
|
bounds: { x, y, width, height },
|
|
@@ -12315,22 +12333,20 @@ function getDrawData(content, style) {
|
|
|
12315
12333
|
return drawData;
|
|
12316
12334
|
}
|
|
12317
12335
|
function padAutoText(padding, drawData, style, width, height) {
|
|
12318
|
-
if (!width) {
|
|
12336
|
+
if (!width && style.autoSizeAlign) {
|
|
12319
12337
|
switch (style.textAlign) {
|
|
12320
12338
|
case 'left':
|
|
12321
12339
|
offsetText(drawData, 'x', padding[left]);
|
|
12322
12340
|
break;
|
|
12323
|
-
case 'right':
|
|
12324
|
-
offsetText(drawData, 'x', -padding[right]);
|
|
12341
|
+
case 'right': offsetText(drawData, 'x', -padding[right]);
|
|
12325
12342
|
}
|
|
12326
12343
|
}
|
|
12327
|
-
if (!height) {
|
|
12344
|
+
if (!height && style.autoSizeAlign) {
|
|
12328
12345
|
switch (style.verticalAlign) {
|
|
12329
12346
|
case 'top':
|
|
12330
12347
|
offsetText(drawData, 'y', padding[top]);
|
|
12331
12348
|
break;
|
|
12332
|
-
case 'bottom':
|
|
12333
|
-
offsetText(drawData, 'y', -padding[bottom]);
|
|
12349
|
+
case 'bottom': offsetText(drawData, 'y', -padding[bottom]);
|
|
12334
12350
|
}
|
|
12335
12351
|
}
|
|
12336
12352
|
}
|