konva 8.3.2 → 8.3.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 +3 -0
- package/cmj/Node.js +10 -8
- package/cmj/Shape.js +15 -16
- package/cmj/index-node.js +1 -0
- package/cmj/shapes/Arc.js +5 -5
- package/cmj/shapes/Path.d.ts +2 -2
- package/cmj/shapes/Path.js +4 -4
- package/cmj/shapes/Text.d.ts +1 -0
- package/cmj/shapes/Text.js +10 -3
- package/cmj/shapes/TextPath.js +1 -1
- package/cmj/shapes/Transformer.js +2 -2
- package/konva.js +65 -49
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.js +10 -8
- package/lib/Shape.js +15 -16
- package/lib/index-node.js +1 -0
- package/lib/shapes/Arc.js +5 -5
- package/lib/shapes/Path.d.ts +2 -2
- package/lib/shapes/Path.js +4 -4
- package/lib/shapes/Text.d.ts +1 -0
- package/lib/shapes/Text.js +10 -3
- package/lib/shapes/TextPath.js +1 -1
- package/lib/shapes/Transformer.js +2 -2
- package/package.json +15 -14
package/README.md
CHANGED
|
@@ -150,6 +150,9 @@ const Konva = require('konva/cmj').default;
|
|
|
150
150
|
|
|
151
151
|
# Backers
|
|
152
152
|
|
|
153
|
+

|
|
154
|
+

|
|
155
|
+
|
|
153
156
|
- [myposter GmbH](https://www.myposter.de/)
|
|
154
157
|
- [queue.gg](https://queue.gg/)
|
|
155
158
|
|
package/cmj/Node.js
CHANGED
|
@@ -102,13 +102,13 @@ class Node {
|
|
|
102
102
|
relativeTo: this.getParent(),
|
|
103
103
|
});
|
|
104
104
|
}
|
|
105
|
-
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? rect.x : conf.x, y = conf.y === undefined ? rect.y : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
105
|
+
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
106
106
|
if (!width || !height) {
|
|
107
107
|
Util_1.Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
108
108
|
return;
|
|
109
109
|
}
|
|
110
|
-
width += offset * 2;
|
|
111
|
-
height += offset * 2;
|
|
110
|
+
width += offset * 2 + 1;
|
|
111
|
+
height += offset * 2 + 1;
|
|
112
112
|
x -= offset;
|
|
113
113
|
y -= offset;
|
|
114
114
|
var cachedSceneCanvas = new Canvas_1.SceneCanvas({
|
|
@@ -936,9 +936,11 @@ class Node {
|
|
|
936
936
|
_toKonvaCanvas(config) {
|
|
937
937
|
config = config || {};
|
|
938
938
|
var box = this.getClientRect();
|
|
939
|
-
var stage = this.getStage(), x = config.x !== undefined ? config.x : box.x, y = config.y !== undefined ? config.y : box.y, pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({
|
|
940
|
-
width: config.width || box.width || (stage ? stage.width() : 0),
|
|
941
|
-
height: config.height ||
|
|
939
|
+
var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new Canvas_1.SceneCanvas({
|
|
940
|
+
width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
|
|
941
|
+
height: config.height ||
|
|
942
|
+
Math.ceil(box.height) ||
|
|
943
|
+
(stage ? stage.height() : 0),
|
|
942
944
|
pixelRatio: pixelRatio,
|
|
943
945
|
}), context = canvas.getContext();
|
|
944
946
|
context.save();
|
|
@@ -1293,8 +1295,8 @@ class Node {
|
|
|
1293
1295
|
const screenRect = {
|
|
1294
1296
|
x: -margin.x,
|
|
1295
1297
|
y: -margin.y,
|
|
1296
|
-
width: stage.width() + margin.x,
|
|
1297
|
-
height: stage.height() + margin.y,
|
|
1298
|
+
width: stage.width() + 2 * margin.x,
|
|
1299
|
+
height: stage.height() + 2 * margin.y,
|
|
1298
1300
|
};
|
|
1299
1301
|
return Util_1.Util.haveIntersection(screenRect, this.getClientRect());
|
|
1300
1302
|
}
|
package/cmj/Shape.js
CHANGED
|
@@ -101,14 +101,17 @@ class Shape extends Node_1.Node {
|
|
|
101
101
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
102
102
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
103
103
|
const m = tr.getMatrix();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
104
|
+
const matrix = typeof DOMMatrix === 'undefined'
|
|
105
|
+
? {
|
|
106
|
+
a: m[0],
|
|
107
|
+
b: m[1],
|
|
108
|
+
c: m[2],
|
|
109
|
+
d: m[3],
|
|
110
|
+
e: m[4],
|
|
111
|
+
f: m[5],
|
|
112
|
+
}
|
|
113
|
+
: new DOMMatrix(m);
|
|
114
|
+
pattern.setTransform(matrix);
|
|
112
115
|
}
|
|
113
116
|
return pattern;
|
|
114
117
|
}
|
|
@@ -273,17 +276,13 @@ class Shape extends Node_1.Node {
|
|
|
273
276
|
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
274
277
|
const width = preWidth + blurRadius * 2;
|
|
275
278
|
const height = preHeight + blurRadius * 2;
|
|
276
|
-
let roundingOffset = 0;
|
|
277
|
-
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
278
|
-
roundingOffset = 1;
|
|
279
|
-
}
|
|
280
279
|
const rect = {
|
|
281
|
-
width: width
|
|
282
|
-
height: height
|
|
283
|
-
x: -
|
|
280
|
+
width: width,
|
|
281
|
+
height: height,
|
|
282
|
+
x: -(strokeWidth / 2 + blurRadius) +
|
|
284
283
|
Math.min(shadowOffsetX, 0) +
|
|
285
284
|
fillRect.x,
|
|
286
|
-
y: -
|
|
285
|
+
y: -(strokeWidth / 2 + blurRadius) +
|
|
287
286
|
Math.min(shadowOffsetY, 0) +
|
|
288
287
|
fillRect.y,
|
|
289
288
|
};
|
package/cmj/index-node.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const _FullInternals_1 = require("./_FullInternals");
|
|
4
4
|
const Canvas = require("canvas");
|
|
5
5
|
const canvas = Canvas['default'] || Canvas;
|
|
6
|
+
global.DOMMatrix = canvas.DOMMatrix;
|
|
6
7
|
const isNode = typeof global.document === 'undefined';
|
|
7
8
|
if (isNode) {
|
|
8
9
|
_FullInternals_1.Konva.Util['createCanvasElement'] = () => {
|
package/cmj/shapes/Arc.js
CHANGED
|
@@ -34,17 +34,17 @@ class Arc extends Shape_1.Shape {
|
|
|
34
34
|
const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
35
35
|
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
36
36
|
const boundRightRatio = 1;
|
|
37
|
-
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
37
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
38
38
|
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
39
39
|
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
40
40
|
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
|
|
41
41
|
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
42
42
|
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
43
43
|
return {
|
|
44
|
-
x:
|
|
45
|
-
y:
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
44
|
+
x: boundLeft,
|
|
45
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
46
|
+
width: boundRight - boundLeft,
|
|
47
|
+
height: boundBottom - boundTop,
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
}
|
package/cmj/shapes/Path.d.ts
CHANGED
package/cmj/shapes/Path.js
CHANGED
|
@@ -120,10 +120,10 @@ class Path extends Shape_1.Shape {
|
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
122
|
return {
|
|
123
|
-
x:
|
|
124
|
-
y:
|
|
125
|
-
width:
|
|
126
|
-
height:
|
|
123
|
+
x: minX,
|
|
124
|
+
y: minY,
|
|
125
|
+
width: maxX - minX,
|
|
126
|
+
height: maxY - minY,
|
|
127
127
|
};
|
|
128
128
|
}
|
|
129
129
|
getLength() {
|
package/cmj/shapes/Text.d.ts
CHANGED
package/cmj/shapes/Text.js
CHANGED
|
@@ -96,7 +96,7 @@ class Text extends Shape_1.Shape {
|
|
|
96
96
|
for (n = 0; n < textArrLen; n++) {
|
|
97
97
|
var lineTranslateX = 0;
|
|
98
98
|
var lineTranslateY = 0;
|
|
99
|
-
var obj = textArr[n], text = obj.text, width = obj.width, lastLine =
|
|
99
|
+
var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, oneWord, lineWidth;
|
|
100
100
|
context.save();
|
|
101
101
|
if (align === RIGHT) {
|
|
102
102
|
lineTranslateX += totalWidth - width - padding * 2;
|
|
@@ -141,7 +141,7 @@ class Text extends Shape_1.Shape {
|
|
|
141
141
|
var array = stringToArray(text);
|
|
142
142
|
for (var li = 0; li < array.length; li++) {
|
|
143
143
|
var letter = array[li];
|
|
144
|
-
if (letter === ' ' &&
|
|
144
|
+
if (letter === ' ' && !lastLine && align === JUSTIFY) {
|
|
145
145
|
lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;
|
|
146
146
|
}
|
|
147
147
|
this._partialTextX = lineTranslateX;
|
|
@@ -221,7 +221,11 @@ class Text extends Shape_1.Shape {
|
|
|
221
221
|
line = line.trim();
|
|
222
222
|
}
|
|
223
223
|
var width = this._getTextWidth(line);
|
|
224
|
-
return this.textArr.push({
|
|
224
|
+
return this.textArr.push({
|
|
225
|
+
text: line,
|
|
226
|
+
width: width,
|
|
227
|
+
lastInParagraph: false,
|
|
228
|
+
});
|
|
225
229
|
}
|
|
226
230
|
_getTextWidth(text) {
|
|
227
231
|
var letterSpacing = this.letterSpacing();
|
|
@@ -314,6 +318,9 @@ class Text extends Shape_1.Shape {
|
|
|
314
318
|
if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
|
|
315
319
|
break;
|
|
316
320
|
}
|
|
321
|
+
if (this.textArr[this.textArr.length - 1]) {
|
|
322
|
+
this.textArr[this.textArr.length - 1].lastInParagraph = true;
|
|
323
|
+
}
|
|
317
324
|
}
|
|
318
325
|
this.textHeight = fontSize;
|
|
319
326
|
this.textWidth = textWidth;
|
package/cmj/shapes/TextPath.js
CHANGED
|
@@ -25,7 +25,7 @@ class TextPath extends Shape_1.Shape {
|
|
|
25
25
|
this.dataArray = Path_1.Path.parsePathData(this.attrs.data);
|
|
26
26
|
this._setTextData();
|
|
27
27
|
});
|
|
28
|
-
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva', this._setTextData);
|
|
28
|
+
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
|
|
29
29
|
this._setTextData();
|
|
30
30
|
}
|
|
31
31
|
_sceneFunc(context) {
|
|
@@ -449,9 +449,9 @@ class Transformer extends Group_1.Group {
|
|
|
449
449
|
x: pos.x - ap.x,
|
|
450
450
|
y: pos.y - ap.y,
|
|
451
451
|
};
|
|
452
|
-
this._fire('transformstart', { evt: e, target: this.getNode() });
|
|
452
|
+
this._fire('transformstart', { evt: e.evt, target: this.getNode() });
|
|
453
453
|
this._nodes.forEach((target) => {
|
|
454
|
-
target._fire('transformstart', { evt: e, target });
|
|
454
|
+
target._fire('transformstart', { evt: e.evt, target });
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
457
|
_handleMouseMove(e) {
|
package/konva.js
CHANGED
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
})(this, (function () { 'use strict';
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
* Konva JavaScript Framework v8.3.
|
|
8
|
+
* Konva JavaScript Framework v8.3.5
|
|
9
9
|
* http://konvajs.org/
|
|
10
10
|
* Licensed under the MIT
|
|
11
|
-
* Date:
|
|
11
|
+
* Date: Mon Mar 21 2022
|
|
12
12
|
*
|
|
13
13
|
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
|
14
14
|
* Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
: {};
|
|
36
36
|
const Konva$2 = {
|
|
37
37
|
_global: glob,
|
|
38
|
-
version: '8.3.
|
|
38
|
+
version: '8.3.5',
|
|
39
39
|
isBrowser: detectBrowser(),
|
|
40
40
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
41
41
|
dblClickWindow: 400,
|
|
@@ -2599,15 +2599,26 @@
|
|
|
2599
2599
|
relativeTo: this.getParent(),
|
|
2600
2600
|
});
|
|
2601
2601
|
}
|
|
2602
|
-
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? rect.x : conf.x, y = conf.y === undefined ? rect.y : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
2602
|
+
var width = Math.ceil(conf.width || rect.width), height = Math.ceil(conf.height || rect.height), pixelRatio = conf.pixelRatio, x = conf.x === undefined ? Math.floor(rect.x) : conf.x, y = conf.y === undefined ? Math.floor(rect.y) : conf.y, offset = conf.offset || 0, drawBorder = conf.drawBorder || false, hitCanvasPixelRatio = conf.hitCanvasPixelRatio || 1;
|
|
2603
2603
|
if (!width || !height) {
|
|
2604
2604
|
Util.error('Can not cache the node. Width or height of the node equals 0. Caching is skipped.');
|
|
2605
2605
|
return;
|
|
2606
2606
|
}
|
|
2607
|
-
|
|
2608
|
-
|
|
2607
|
+
// let's just add 1 pixel extra,
|
|
2608
|
+
// because using Math.floor on x, y position may shift drawing
|
|
2609
|
+
width += offset * 2 + 1;
|
|
2610
|
+
height += offset * 2 + 1;
|
|
2609
2611
|
x -= offset;
|
|
2610
2612
|
y -= offset;
|
|
2613
|
+
// if (Math.floor(x) < x) {
|
|
2614
|
+
// x = Math.floor(x);
|
|
2615
|
+
// // width += 1;
|
|
2616
|
+
// }
|
|
2617
|
+
// if (Math.floor(y) < y) {
|
|
2618
|
+
// y = Math.floor(y);
|
|
2619
|
+
// // height += 1;
|
|
2620
|
+
// }
|
|
2621
|
+
// console.log({ x, y, width, height }, rect);
|
|
2611
2622
|
var cachedSceneCanvas = new SceneCanvas({
|
|
2612
2623
|
pixelRatio: pixelRatio,
|
|
2613
2624
|
width: width,
|
|
@@ -3964,9 +3975,11 @@
|
|
|
3964
3975
|
_toKonvaCanvas(config) {
|
|
3965
3976
|
config = config || {};
|
|
3966
3977
|
var box = this.getClientRect();
|
|
3967
|
-
var stage = this.getStage(), x = config.x !== undefined ? config.x : box.x, y = config.y !== undefined ? config.y : box.y, pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
|
|
3968
|
-
width: config.width || box.width || (stage ? stage.width() : 0),
|
|
3969
|
-
height: config.height ||
|
|
3978
|
+
var stage = this.getStage(), x = config.x !== undefined ? config.x : Math.floor(box.x), y = config.y !== undefined ? config.y : Math.floor(box.y), pixelRatio = config.pixelRatio || 1, canvas = new SceneCanvas({
|
|
3979
|
+
width: config.width || Math.ceil(box.width) || (stage ? stage.width() : 0),
|
|
3980
|
+
height: config.height ||
|
|
3981
|
+
Math.ceil(box.height) ||
|
|
3982
|
+
(stage ? stage.height() : 0),
|
|
3970
3983
|
pixelRatio: pixelRatio,
|
|
3971
3984
|
}), context = canvas.getContext();
|
|
3972
3985
|
context.save();
|
|
@@ -4504,8 +4517,8 @@
|
|
|
4504
4517
|
const screenRect = {
|
|
4505
4518
|
x: -margin.x,
|
|
4506
4519
|
y: -margin.y,
|
|
4507
|
-
width: stage.width() + margin.x,
|
|
4508
|
-
height: stage.height() + margin.y,
|
|
4520
|
+
width: stage.width() + 2 * margin.x,
|
|
4521
|
+
height: stage.height() + 2 * margin.y,
|
|
4509
4522
|
};
|
|
4510
4523
|
return Util.haveIntersection(screenRect, this.getClientRect());
|
|
4511
4524
|
}
|
|
@@ -6704,14 +6717,17 @@
|
|
|
6704
6717
|
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
|
|
6705
6718
|
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
|
|
6706
6719
|
const m = tr.getMatrix();
|
|
6707
|
-
|
|
6708
|
-
|
|
6709
|
-
|
|
6710
|
-
|
|
6711
|
-
|
|
6712
|
-
|
|
6713
|
-
|
|
6714
|
-
|
|
6720
|
+
const matrix = typeof DOMMatrix === 'undefined'
|
|
6721
|
+
? {
|
|
6722
|
+
a: m[0],
|
|
6723
|
+
b: m[1],
|
|
6724
|
+
c: m[2],
|
|
6725
|
+
d: m[3],
|
|
6726
|
+
e: m[4],
|
|
6727
|
+
f: m[5], // Vertical translation (moving).
|
|
6728
|
+
}
|
|
6729
|
+
: new DOMMatrix(m);
|
|
6730
|
+
pattern.setTransform(matrix);
|
|
6715
6731
|
}
|
|
6716
6732
|
return pattern;
|
|
6717
6733
|
}
|
|
@@ -6933,20 +6949,13 @@
|
|
|
6933
6949
|
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
|
|
6934
6950
|
const width = preWidth + blurRadius * 2;
|
|
6935
6951
|
const height = preHeight + blurRadius * 2;
|
|
6936
|
-
// if stroke, for example = 3
|
|
6937
|
-
// we need to set x to 1.5, but after Math.round it will be 2
|
|
6938
|
-
// as we have additional offset we need to increase width and height by 1 pixel
|
|
6939
|
-
let roundingOffset = 0;
|
|
6940
|
-
if (Math.round(strokeWidth / 2) !== strokeWidth / 2) {
|
|
6941
|
-
roundingOffset = 1;
|
|
6942
|
-
}
|
|
6943
6952
|
const rect = {
|
|
6944
|
-
width: width
|
|
6945
|
-
height: height
|
|
6946
|
-
x: -
|
|
6953
|
+
width: width,
|
|
6954
|
+
height: height,
|
|
6955
|
+
x: -(strokeWidth / 2 + blurRadius) +
|
|
6947
6956
|
Math.min(shadowOffsetX, 0) +
|
|
6948
6957
|
fillRect.x,
|
|
6949
|
-
y: -
|
|
6958
|
+
y: -(strokeWidth / 2 + blurRadius) +
|
|
6950
6959
|
Math.min(shadowOffsetY, 0) +
|
|
6951
6960
|
fillRect.y,
|
|
6952
6961
|
};
|
|
@@ -9732,17 +9741,17 @@
|
|
|
9732
9741
|
const angle = Konva$2.getAngle(clockwise ? 360 - this.angle() : this.angle());
|
|
9733
9742
|
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
|
|
9734
9743
|
const boundRightRatio = 1;
|
|
9735
|
-
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), 3 * Math.PI / 2));
|
|
9744
|
+
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
|
|
9736
9745
|
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
|
|
9737
9746
|
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
|
|
9738
9747
|
const boundRight = boundRightRatio * (outerRadius );
|
|
9739
9748
|
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
|
|
9740
9749
|
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
|
|
9741
9750
|
return {
|
|
9742
|
-
x:
|
|
9743
|
-
y:
|
|
9744
|
-
width:
|
|
9745
|
-
height:
|
|
9751
|
+
x: boundLeft,
|
|
9752
|
+
y: clockwise ? -1 * boundBottom : boundTop,
|
|
9753
|
+
width: boundRight - boundLeft,
|
|
9754
|
+
height: boundBottom - boundTop,
|
|
9746
9755
|
};
|
|
9747
9756
|
}
|
|
9748
9757
|
}
|
|
@@ -10341,10 +10350,10 @@
|
|
|
10341
10350
|
}
|
|
10342
10351
|
}
|
|
10343
10352
|
return {
|
|
10344
|
-
x:
|
|
10345
|
-
y:
|
|
10346
|
-
width:
|
|
10347
|
-
height:
|
|
10353
|
+
x: minX,
|
|
10354
|
+
y: minY,
|
|
10355
|
+
width: maxX - minX,
|
|
10356
|
+
height: maxY - minY,
|
|
10348
10357
|
};
|
|
10349
10358
|
}
|
|
10350
10359
|
/**
|
|
@@ -13300,7 +13309,7 @@
|
|
|
13300
13309
|
for (n = 0; n < textArrLen; n++) {
|
|
13301
13310
|
var lineTranslateX = 0;
|
|
13302
13311
|
var lineTranslateY = 0;
|
|
13303
|
-
var obj = textArr[n], text = obj.text, width = obj.width, lastLine =
|
|
13312
|
+
var obj = textArr[n], text = obj.text, width = obj.width, lastLine = obj.lastInParagraph, spacesNumber, oneWord, lineWidth;
|
|
13304
13313
|
// horizontal alignment
|
|
13305
13314
|
context.save();
|
|
13306
13315
|
if (align === RIGHT) {
|
|
@@ -13350,7 +13359,7 @@
|
|
|
13350
13359
|
for (var li = 0; li < array.length; li++) {
|
|
13351
13360
|
var letter = array[li];
|
|
13352
13361
|
// skip justify for the last line
|
|
13353
|
-
if (letter === ' ' &&
|
|
13362
|
+
if (letter === ' ' && !lastLine && align === JUSTIFY) {
|
|
13354
13363
|
lineTranslateX += (totalWidth - padding * 2 - width) / spacesNumber;
|
|
13355
13364
|
// context.translate(
|
|
13356
13365
|
// Math.floor((totalWidth - padding * 2 - width) / spacesNumber),
|
|
@@ -13449,7 +13458,11 @@
|
|
|
13449
13458
|
line = line.trim();
|
|
13450
13459
|
}
|
|
13451
13460
|
var width = this._getTextWidth(line);
|
|
13452
|
-
return this.textArr.push({
|
|
13461
|
+
return this.textArr.push({
|
|
13462
|
+
text: line,
|
|
13463
|
+
width: width,
|
|
13464
|
+
lastInParagraph: false,
|
|
13465
|
+
});
|
|
13453
13466
|
}
|
|
13454
13467
|
_getTextWidth(text) {
|
|
13455
13468
|
var letterSpacing = this.letterSpacing();
|
|
@@ -13571,6 +13584,9 @@
|
|
|
13571
13584
|
if (fixedHeight && currentHeightPx + lineHeightPx > maxHeightPx) {
|
|
13572
13585
|
break;
|
|
13573
13586
|
}
|
|
13587
|
+
if (this.textArr[this.textArr.length - 1]) {
|
|
13588
|
+
this.textArr[this.textArr.length - 1].lastInParagraph = true;
|
|
13589
|
+
}
|
|
13574
13590
|
}
|
|
13575
13591
|
this.textHeight = fontSize;
|
|
13576
13592
|
// var maxTextWidth = 0;
|
|
@@ -13957,7 +13973,7 @@
|
|
|
13957
13973
|
this._setTextData();
|
|
13958
13974
|
});
|
|
13959
13975
|
// update text data for certain attr changes
|
|
13960
|
-
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva', this._setTextData);
|
|
13976
|
+
this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
|
|
13961
13977
|
this._setTextData();
|
|
13962
13978
|
}
|
|
13963
13979
|
_sceneFunc(context) {
|
|
@@ -14379,10 +14395,10 @@
|
|
|
14379
14395
|
* @param {Number} letterSpacing
|
|
14380
14396
|
* @returns {Number}
|
|
14381
14397
|
* @example
|
|
14382
|
-
* // get
|
|
14398
|
+
* // get letter spacing value
|
|
14383
14399
|
* var letterSpacing = shape.letterSpacing();
|
|
14384
14400
|
*
|
|
14385
|
-
* // set the
|
|
14401
|
+
* // set the letter spacing value
|
|
14386
14402
|
* shape.letterSpacing(2);
|
|
14387
14403
|
*/
|
|
14388
14404
|
Factory.addGetterSetter(TextPath, 'letterSpacing', 0, getNumberValidator());
|
|
@@ -14393,10 +14409,10 @@
|
|
|
14393
14409
|
* @param {String} textBaseline
|
|
14394
14410
|
* @returns {String}
|
|
14395
14411
|
* @example
|
|
14396
|
-
* // get
|
|
14412
|
+
* // get current text baseline
|
|
14397
14413
|
* var textBaseline = shape.textBaseline();
|
|
14398
14414
|
*
|
|
14399
|
-
* // set
|
|
14415
|
+
* // set new text baseline
|
|
14400
14416
|
* shape.textBaseline('top');
|
|
14401
14417
|
*/
|
|
14402
14418
|
Factory.addGetterSetter(TextPath, 'textBaseline', 'middle');
|
|
@@ -14994,9 +15010,9 @@
|
|
|
14994
15010
|
x: pos.x - ap.x,
|
|
14995
15011
|
y: pos.y - ap.y,
|
|
14996
15012
|
};
|
|
14997
|
-
this._fire('transformstart', { evt: e, target: this.getNode() });
|
|
15013
|
+
this._fire('transformstart', { evt: e.evt, target: this.getNode() });
|
|
14998
15014
|
this._nodes.forEach((target) => {
|
|
14999
|
-
target._fire('transformstart', { evt: e, target });
|
|
15015
|
+
target._fire('transformstart', { evt: e.evt, target });
|
|
15000
15016
|
});
|
|
15001
15017
|
}
|
|
15002
15018
|
_handleMouseMove(e) {
|