leafer-draw 1.4.2 → 1.5.0
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/web.cjs +6 -5
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +6 -5
- package/dist/web.esm.js.map +1 -1
- package/dist/web.esm.min.js +1 -1
- package/dist/web.esm.min.js.map +1 -1
- package/dist/web.js +25 -17
- package/dist/web.js.map +1 -1
- package/dist/web.min.cjs +1 -1
- package/dist/web.min.cjs.map +1 -1
- package/dist/web.min.js +1 -1
- package/dist/web.min.js.map +1 -1
- package/dist/web.module.js +25 -17
- package/dist/web.module.js.map +1 -1
- package/dist/web.module.min.js +1 -1
- package/dist/web.module.min.js.map +1 -1
- package/package.json +2 -2
package/dist/web.module.js
CHANGED
|
@@ -4070,12 +4070,11 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4070
4070
|
if (defaultValue === undefined) {
|
|
4071
4071
|
property.get = function () { return this[computedKey]; };
|
|
4072
4072
|
}
|
|
4073
|
-
else if (typeof defaultValue === '
|
|
4074
|
-
const { clone } = DataHelper;
|
|
4073
|
+
else if (typeof defaultValue === 'function') {
|
|
4075
4074
|
property.get = function () {
|
|
4076
4075
|
let v = this[computedKey];
|
|
4077
4076
|
if (v === undefined)
|
|
4078
|
-
this[computedKey] = v =
|
|
4077
|
+
this[computedKey] = v = defaultValue(this.__leaf);
|
|
4079
4078
|
return v;
|
|
4080
4079
|
};
|
|
4081
4080
|
}
|
|
@@ -5722,10 +5721,10 @@ let Leaf = class Leaf {
|
|
|
5722
5721
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5723
5722
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5724
5723
|
}
|
|
5725
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5724
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5726
5725
|
if (!fn)
|
|
5727
5726
|
fn = boundsType;
|
|
5728
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5727
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5729
5728
|
}
|
|
5730
5729
|
__emitLifeEvent(type) {
|
|
5731
5730
|
if (this.hasEvent(type))
|
|
@@ -6052,7 +6051,7 @@ class LeafLevelList {
|
|
|
6052
6051
|
}
|
|
6053
6052
|
}
|
|
6054
6053
|
|
|
6055
|
-
const version = "1.
|
|
6054
|
+
const version = "1.5.0";
|
|
6056
6055
|
|
|
6057
6056
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6058
6057
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6963,7 +6962,11 @@ const State = {
|
|
|
6963
6962
|
setStyleName() { return Plugin.need('state'); },
|
|
6964
6963
|
set() { return Plugin.need('state'); }
|
|
6965
6964
|
};
|
|
6966
|
-
const Transition = {
|
|
6965
|
+
const Transition = {
|
|
6966
|
+
list: {},
|
|
6967
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6968
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6969
|
+
};
|
|
6967
6970
|
|
|
6968
6971
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6969
6972
|
const emptyPaint = {};
|
|
@@ -7387,9 +7390,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7387
7390
|
this.__drawPathByBox(pen);
|
|
7388
7391
|
return pen;
|
|
7389
7392
|
}
|
|
7390
|
-
get editConfig() { return undefined; }
|
|
7391
|
-
get editOuter() { return ''; }
|
|
7392
|
-
get editInner() { return ''; }
|
|
7393
7393
|
constructor(data) {
|
|
7394
7394
|
super(data);
|
|
7395
7395
|
}
|
|
@@ -7471,8 +7471,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7471
7471
|
export(_filename, _options) {
|
|
7472
7472
|
return Plugin.need('export');
|
|
7473
7473
|
}
|
|
7474
|
+
syncExport(_filename, _options) {
|
|
7475
|
+
return Plugin.need('export');
|
|
7476
|
+
}
|
|
7474
7477
|
clone(data) {
|
|
7475
|
-
const json = this.toJSON();
|
|
7478
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7476
7479
|
if (data)
|
|
7477
7480
|
Object.assign(json, data);
|
|
7478
7481
|
return UI_1.one(json);
|
|
@@ -7771,7 +7774,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7771
7774
|
get layoutLocked() { return !this.layouter.running; }
|
|
7772
7775
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7773
7776
|
get cursorPoint() { return (this.interaction && this.interaction.hoverData) || { x: this.width / 2, y: this.height / 2 }; }
|
|
7774
|
-
get clientBounds() { return this.canvas && this.canvas.getClientBounds(); }
|
|
7777
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7775
7778
|
constructor(userConfig, data) {
|
|
7776
7779
|
super(data);
|
|
7777
7780
|
this.config = {
|
|
@@ -8073,6 +8076,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8073
8076
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8074
8077
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8075
8078
|
}
|
|
8079
|
+
getClientPointByWorld(worldPoint) {
|
|
8080
|
+
const { x, y } = this.clientBounds;
|
|
8081
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8082
|
+
}
|
|
8076
8083
|
updateClientBounds() {
|
|
8077
8084
|
this.canvas && this.canvas.updateClientBounds();
|
|
8078
8085
|
}
|
|
@@ -10108,13 +10115,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
10108
10115
|
}
|
|
10109
10116
|
|
|
10110
10117
|
function layoutText(drawData, style) {
|
|
10111
|
-
const { rows, bounds } = drawData;
|
|
10118
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
10112
10119
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
10113
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
10120
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
10114
10121
|
let starY = __baseLine;
|
|
10115
10122
|
if (__clipText && realHeight > height) {
|
|
10116
10123
|
realHeight = Math.max(height, __lineHeight);
|
|
10117
|
-
|
|
10124
|
+
if (countRows > 1)
|
|
10125
|
+
drawData.overflow = countRows;
|
|
10118
10126
|
}
|
|
10119
10127
|
else if (height || autoSizeAlign) {
|
|
10120
10128
|
switch (verticalAlign) {
|
|
@@ -10126,7 +10134,7 @@ function layoutText(drawData, style) {
|
|
|
10126
10134
|
}
|
|
10127
10135
|
starY += y;
|
|
10128
10136
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
10129
|
-
for (let i = 0, len =
|
|
10137
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
10130
10138
|
row = rows[i];
|
|
10131
10139
|
row.x = x;
|
|
10132
10140
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -10195,7 +10203,7 @@ function clipText(drawData, style, x, width) {
|
|
|
10195
10203
|
if (i === end && charRight < right) {
|
|
10196
10204
|
break;
|
|
10197
10205
|
}
|
|
10198
|
-
else if (charRight < right && char.char !== ' ') {
|
|
10206
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
10199
10207
|
row.data.splice(i + 1);
|
|
10200
10208
|
row.width -= char.width;
|
|
10201
10209
|
break;
|