leafer-draw 1.4.2 → 1.5.1
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 +8 -7
- package/dist/web.cjs.map +1 -1
- package/dist/web.esm.js +8 -7
- 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 +29 -25
- 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 +29 -25
- 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
|
@@ -2029,13 +2029,11 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2029
2029
|
this.worldTransform = {};
|
|
2030
2030
|
if (!config)
|
|
2031
2031
|
config = minSize;
|
|
2032
|
-
if (!config.pixelRatio)
|
|
2033
|
-
config.pixelRatio = Platform.devicePixelRatio;
|
|
2034
2032
|
this.manager = manager;
|
|
2035
2033
|
this.innerId = IncrementId.create(IncrementId.CNAVAS);
|
|
2036
2034
|
const { width, height, pixelRatio } = config;
|
|
2037
2035
|
this.autoLayout = !width || !height;
|
|
2038
|
-
this.size.pixelRatio = pixelRatio;
|
|
2036
|
+
this.size.pixelRatio = pixelRatio | Platform.devicePixelRatio;
|
|
2039
2037
|
this.config = config;
|
|
2040
2038
|
this.init();
|
|
2041
2039
|
}
|
|
@@ -2232,7 +2230,7 @@ class LeaferCanvasBase extends Canvas$1 {
|
|
|
2232
2230
|
tempBounds$1.ceil();
|
|
2233
2231
|
}
|
|
2234
2232
|
isSameSize(size) {
|
|
2235
|
-
return this.width === size.width && this.height === size.height && this.pixelRatio === size.pixelRatio;
|
|
2233
|
+
return this.width === size.width && this.height === size.height && (!size.pixelRatio || this.pixelRatio === size.pixelRatio);
|
|
2236
2234
|
}
|
|
2237
2235
|
getSameCanvas(useSameWorldTransform, useSameSmooth) {
|
|
2238
2236
|
const canvas = this.manager ? this.manager.get(this.size) : Creator.canvas(Object.assign({}, this.size));
|
|
@@ -4070,13 +4068,10 @@ function defineDataProcessor(target, key, defaultValue) {
|
|
|
4070
4068
|
if (defaultValue === undefined) {
|
|
4071
4069
|
property.get = function () { return this[computedKey]; };
|
|
4072
4070
|
}
|
|
4073
|
-
else if (typeof defaultValue === '
|
|
4074
|
-
const { clone } = DataHelper;
|
|
4071
|
+
else if (typeof defaultValue === 'function') {
|
|
4075
4072
|
property.get = function () {
|
|
4076
4073
|
let v = this[computedKey];
|
|
4077
|
-
|
|
4078
|
-
this[computedKey] = v = clone(defaultValue);
|
|
4079
|
-
return v;
|
|
4074
|
+
return v === undefined ? defaultValue(this.__leaf) : v;
|
|
4080
4075
|
};
|
|
4081
4076
|
}
|
|
4082
4077
|
if (key === 'width') {
|
|
@@ -5722,10 +5717,10 @@ let Leaf = class Leaf {
|
|
|
5722
5717
|
static changeAttr(attrName, defaultValue, fn) {
|
|
5723
5718
|
fn ? this.addAttr(attrName, defaultValue, fn) : defineDataProcessor(this.prototype, attrName, defaultValue);
|
|
5724
5719
|
}
|
|
5725
|
-
static addAttr(attrName, defaultValue, fn) {
|
|
5720
|
+
static addAttr(attrName, defaultValue, fn, helpValue) {
|
|
5726
5721
|
if (!fn)
|
|
5727
5722
|
fn = boundsType;
|
|
5728
|
-
fn(defaultValue)(this.prototype, attrName);
|
|
5723
|
+
fn(defaultValue, helpValue)(this.prototype, attrName);
|
|
5729
5724
|
}
|
|
5730
5725
|
__emitLifeEvent(type) {
|
|
5731
5726
|
if (this.hasEvent(type))
|
|
@@ -6052,7 +6047,7 @@ class LeafLevelList {
|
|
|
6052
6047
|
}
|
|
6053
6048
|
}
|
|
6054
6049
|
|
|
6055
|
-
const version = "1.
|
|
6050
|
+
const version = "1.5.1";
|
|
6056
6051
|
|
|
6057
6052
|
const debug$4 = Debug.get('LeaferCanvas');
|
|
6058
6053
|
class LeaferCanvas extends LeaferCanvasBase {
|
|
@@ -6174,7 +6169,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6174
6169
|
else {
|
|
6175
6170
|
window.addEventListener('resize', this.windowListener = () => {
|
|
6176
6171
|
const pixelRatio = Platform.devicePixelRatio;
|
|
6177
|
-
if (this.pixelRatio !== pixelRatio) {
|
|
6172
|
+
if (!this.config.pixelRatio && this.pixelRatio !== pixelRatio) {
|
|
6178
6173
|
const { width, height } = this;
|
|
6179
6174
|
this.emitResize({ width, height, pixelRatio });
|
|
6180
6175
|
}
|
|
@@ -6191,7 +6186,7 @@ class LeaferCanvas extends LeaferCanvasBase {
|
|
|
6191
6186
|
checkAutoBounds(parentSize) {
|
|
6192
6187
|
const view = this.view;
|
|
6193
6188
|
const { x, y, width, height } = this.autoBounds.getBoundsFrom(parentSize);
|
|
6194
|
-
const size = { width, height, pixelRatio: Platform.devicePixelRatio };
|
|
6189
|
+
const size = { width, height, pixelRatio: this.config.pixelRatio ? this.pixelRatio : Platform.devicePixelRatio };
|
|
6195
6190
|
if (!this.isSameSize(size)) {
|
|
6196
6191
|
const { style } = view;
|
|
6197
6192
|
style.marginLeft = x + 'px';
|
|
@@ -6963,7 +6958,11 @@ const State = {
|
|
|
6963
6958
|
setStyleName() { return Plugin.need('state'); },
|
|
6964
6959
|
set() { return Plugin.need('state'); }
|
|
6965
6960
|
};
|
|
6966
|
-
const Transition = {
|
|
6961
|
+
const Transition = {
|
|
6962
|
+
list: {},
|
|
6963
|
+
register(attrName, fn) { Transition.list[attrName] = fn; },
|
|
6964
|
+
get(attrName) { return Transition.list[attrName]; }
|
|
6965
|
+
};
|
|
6967
6966
|
|
|
6968
6967
|
const { parse, objectToCanvasData } = PathConvert;
|
|
6969
6968
|
const emptyPaint = {};
|
|
@@ -7387,9 +7386,6 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7387
7386
|
this.__drawPathByBox(pen);
|
|
7388
7387
|
return pen;
|
|
7389
7388
|
}
|
|
7390
|
-
get editConfig() { return undefined; }
|
|
7391
|
-
get editOuter() { return ''; }
|
|
7392
|
-
get editInner() { return ''; }
|
|
7393
7389
|
constructor(data) {
|
|
7394
7390
|
super(data);
|
|
7395
7391
|
}
|
|
@@ -7471,8 +7467,11 @@ let UI = UI_1 = class UI extends Leaf {
|
|
|
7471
7467
|
export(_filename, _options) {
|
|
7472
7468
|
return Plugin.need('export');
|
|
7473
7469
|
}
|
|
7470
|
+
syncExport(_filename, _options) {
|
|
7471
|
+
return Plugin.need('export');
|
|
7472
|
+
}
|
|
7474
7473
|
clone(data) {
|
|
7475
|
-
const json = this.toJSON();
|
|
7474
|
+
const json = DataHelper.clone(this.toJSON());
|
|
7476
7475
|
if (data)
|
|
7477
7476
|
Object.assign(json, data);
|
|
7478
7477
|
return UI_1.one(json);
|
|
@@ -7771,7 +7770,7 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
7771
7770
|
get layoutLocked() { return !this.layouter.running; }
|
|
7772
7771
|
get FPS() { return this.renderer ? this.renderer.FPS : 60; }
|
|
7773
7772
|
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(); }
|
|
7773
|
+
get clientBounds() { return (this.canvas && this.canvas.getClientBounds(true)) || getBoundsData(); }
|
|
7775
7774
|
constructor(userConfig, data) {
|
|
7776
7775
|
super(data);
|
|
7777
7776
|
this.config = {
|
|
@@ -8073,6 +8072,10 @@ let Leafer = Leafer_1 = class Leafer extends Group {
|
|
|
8073
8072
|
getPagePointByClient(clientPoint, updateClient) {
|
|
8074
8073
|
return this.getPagePoint(this.getWorldPointByClient(clientPoint, updateClient));
|
|
8075
8074
|
}
|
|
8075
|
+
getClientPointByWorld(worldPoint) {
|
|
8076
|
+
const { x, y } = this.clientBounds;
|
|
8077
|
+
return { x: x + worldPoint.x, y: y + worldPoint.y };
|
|
8078
|
+
}
|
|
8076
8079
|
updateClientBounds() {
|
|
8077
8080
|
this.canvas && this.canvas.updateClientBounds();
|
|
8078
8081
|
}
|
|
@@ -10108,13 +10111,14 @@ function toChar(data, charX, rowData, isOverflow) {
|
|
|
10108
10111
|
}
|
|
10109
10112
|
|
|
10110
10113
|
function layoutText(drawData, style) {
|
|
10111
|
-
const { rows, bounds } = drawData;
|
|
10114
|
+
const { rows, bounds } = drawData, countRows = rows.length;
|
|
10112
10115
|
const { __lineHeight, __baseLine, __letterSpacing, __clipText, textAlign, verticalAlign, paraSpacing, autoSizeAlign } = style;
|
|
10113
|
-
let { x, y, width, height } = bounds, realHeight = __lineHeight *
|
|
10116
|
+
let { x, y, width, height } = bounds, realHeight = __lineHeight * countRows + (paraSpacing ? paraSpacing * (drawData.paraNumber - 1) : 0);
|
|
10114
10117
|
let starY = __baseLine;
|
|
10115
10118
|
if (__clipText && realHeight > height) {
|
|
10116
10119
|
realHeight = Math.max(height, __lineHeight);
|
|
10117
|
-
|
|
10120
|
+
if (countRows > 1)
|
|
10121
|
+
drawData.overflow = countRows;
|
|
10118
10122
|
}
|
|
10119
10123
|
else if (height || autoSizeAlign) {
|
|
10120
10124
|
switch (verticalAlign) {
|
|
@@ -10126,7 +10130,7 @@ function layoutText(drawData, style) {
|
|
|
10126
10130
|
}
|
|
10127
10131
|
starY += y;
|
|
10128
10132
|
let row, rowX, rowWidth, layoutWidth = (width || autoSizeAlign) ? width : drawData.maxWidth;
|
|
10129
|
-
for (let i = 0, len =
|
|
10133
|
+
for (let i = 0, len = countRows; i < len; i++) {
|
|
10130
10134
|
row = rows[i];
|
|
10131
10135
|
row.x = x;
|
|
10132
10136
|
if (row.width < width || (row.width > width && !__clipText)) {
|
|
@@ -10195,7 +10199,7 @@ function clipText(drawData, style, x, width) {
|
|
|
10195
10199
|
if (i === end && charRight < right) {
|
|
10196
10200
|
break;
|
|
10197
10201
|
}
|
|
10198
|
-
else if (charRight < right && char.char !== ' ') {
|
|
10202
|
+
else if ((charRight < right && char.char !== ' ') || !i) {
|
|
10199
10203
|
row.data.splice(i + 1);
|
|
10200
10204
|
row.width -= char.width;
|
|
10201
10205
|
break;
|