konva 9.3.13 → 9.3.15
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/konva.js +49 -18
- package/konva.min.js +3 -3
- package/lib/Global.js +1 -1
- package/lib/Node.d.ts +3 -3
- package/lib/Shape.js +7 -1
- package/lib/Stage.d.ts +1 -1
- package/lib/shapes/Image.js +5 -0
- package/lib/shapes/Path.d.ts +8 -8
- package/lib/shapes/Path.js +7 -7
- package/lib/shapes/Text.d.ts +13 -13
- package/lib/shapes/Text.js +15 -1
- package/lib/shapes/TextPath.d.ts +2 -2
- package/package.json +1 -1
package/lib/Global.js
CHANGED
|
@@ -16,7 +16,7 @@ exports.glob = typeof global !== 'undefined'
|
|
|
16
16
|
: {};
|
|
17
17
|
exports.Konva = {
|
|
18
18
|
_global: exports.glob,
|
|
19
|
-
version: '9.3.
|
|
19
|
+
version: '9.3.15',
|
|
20
20
|
isBrowser: detectBrowser(),
|
|
21
21
|
isUnminified: /param/.test(function (param) { }.toString()),
|
|
22
22
|
dblClickWindow: 400,
|
package/lib/Node.d.ts
CHANGED
|
@@ -39,16 +39,16 @@ export interface NodeConfig {
|
|
|
39
39
|
type NodeEventMap = GlobalEventHandlersEventMap & {
|
|
40
40
|
[index: string]: any;
|
|
41
41
|
};
|
|
42
|
-
export interface KonvaEventObject<EventType> {
|
|
42
|
+
export interface KonvaEventObject<EventType, This = Node> {
|
|
43
43
|
type: string;
|
|
44
44
|
target: Shape | Stage;
|
|
45
45
|
evt: EventType;
|
|
46
46
|
pointerId: number;
|
|
47
|
-
currentTarget:
|
|
47
|
+
currentTarget: This;
|
|
48
48
|
cancelBubble: boolean;
|
|
49
49
|
child?: Node;
|
|
50
50
|
}
|
|
51
|
-
export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType>) => void;
|
|
51
|
+
export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType, This>) => void;
|
|
52
52
|
export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
|
|
53
53
|
_id: number;
|
|
54
54
|
eventListeners: {
|
package/lib/Shape.js
CHANGED
|
@@ -35,7 +35,13 @@ function _strokeFunc(context) {
|
|
|
35
35
|
context.stroke();
|
|
36
36
|
}
|
|
37
37
|
function _fillFuncHit(context) {
|
|
38
|
-
|
|
38
|
+
const fillRule = this.attrs.fillRule;
|
|
39
|
+
if (fillRule) {
|
|
40
|
+
context.fill(fillRule);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
context.fill();
|
|
44
|
+
}
|
|
39
45
|
}
|
|
40
46
|
function _strokeFuncHit(context) {
|
|
41
47
|
context.stroke();
|
package/lib/Stage.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { GetSet, Vector2d } from './types.js';
|
|
|
4
4
|
import { Shape } from './Shape.js';
|
|
5
5
|
import { Layer } from './Layer.js';
|
|
6
6
|
export interface StageConfig extends ContainerConfig {
|
|
7
|
-
container
|
|
7
|
+
container?: HTMLDivElement | string;
|
|
8
8
|
}
|
|
9
9
|
export declare const stages: Stage[];
|
|
10
10
|
export declare class Stage extends Container<Layer> {
|
package/lib/shapes/Image.js
CHANGED
|
@@ -29,6 +29,11 @@ class Image extends Shape_1.Shape {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
_useBufferCanvas() {
|
|
32
|
+
const hasCornerRadius = !!this.cornerRadius();
|
|
33
|
+
const hasShadow = this.hasShadow();
|
|
34
|
+
if (hasCornerRadius && hasShadow) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
32
37
|
return super._useBufferCanvas(true);
|
|
33
38
|
}
|
|
34
39
|
_sceneFunc(context) {
|
package/lib/shapes/Path.d.ts
CHANGED
|
@@ -17,19 +17,19 @@ export declare class Path extends Shape<PathConfig> {
|
|
|
17
17
|
};
|
|
18
18
|
getLength(): number;
|
|
19
19
|
getPointAtLength(length: any): {
|
|
20
|
-
x:
|
|
21
|
-
y:
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
22
|
} | null;
|
|
23
23
|
data: GetSet<string, this>;
|
|
24
24
|
static getLineLength(x1: any, y1: any, x2: any, y2: any): number;
|
|
25
25
|
static getPathLength(dataArray: PathSegment[]): number;
|
|
26
|
-
static getPointAtLengthOfDataArray(length: number, dataArray:
|
|
27
|
-
x:
|
|
28
|
-
y:
|
|
26
|
+
static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]): {
|
|
27
|
+
x: number;
|
|
28
|
+
y: number;
|
|
29
29
|
} | null;
|
|
30
|
-
static getPointOnLine(dist:
|
|
31
|
-
x:
|
|
32
|
-
y:
|
|
30
|
+
static getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number): {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
33
|
};
|
|
34
34
|
static getPointOnCubicBezier(pct: any, P1x: any, P1y: any, P2x: any, P2y: any, P3x: any, P3y: any, P4x: any, P4y: any): {
|
|
35
35
|
x: number;
|
package/lib/shapes/Path.js
CHANGED
|
@@ -140,7 +140,7 @@ class Path extends Shape_1.Shape {
|
|
|
140
140
|
return pathLength;
|
|
141
141
|
}
|
|
142
142
|
static getPointAtLengthOfDataArray(length, dataArray) {
|
|
143
|
-
var
|
|
143
|
+
var points, i = 0, ii = dataArray.length;
|
|
144
144
|
if (!ii) {
|
|
145
145
|
return null;
|
|
146
146
|
}
|
|
@@ -149,17 +149,17 @@ class Path extends Shape_1.Shape {
|
|
|
149
149
|
++i;
|
|
150
150
|
}
|
|
151
151
|
if (i === ii) {
|
|
152
|
-
|
|
152
|
+
points = dataArray[i - 1].points.slice(-2);
|
|
153
153
|
return {
|
|
154
|
-
x:
|
|
155
|
-
y:
|
|
154
|
+
x: points[0],
|
|
155
|
+
y: points[1],
|
|
156
156
|
};
|
|
157
157
|
}
|
|
158
158
|
if (length < 0.01) {
|
|
159
|
-
|
|
159
|
+
points = dataArray[i].points.slice(0, 2);
|
|
160
160
|
return {
|
|
161
|
-
x:
|
|
162
|
-
y:
|
|
161
|
+
x: points[0],
|
|
162
|
+
y: points[1],
|
|
163
163
|
};
|
|
164
164
|
}
|
|
165
165
|
var cp = dataArray[i];
|
package/lib/shapes/Text.d.ts
CHANGED
|
@@ -37,19 +37,19 @@ export declare class Text extends Shape<TextConfig> {
|
|
|
37
37
|
getHeight(): any;
|
|
38
38
|
getTextWidth(): number;
|
|
39
39
|
getTextHeight(): number;
|
|
40
|
-
measureSize(text:
|
|
41
|
-
actualBoundingBoxAscent:
|
|
42
|
-
actualBoundingBoxDescent:
|
|
43
|
-
actualBoundingBoxLeft:
|
|
44
|
-
actualBoundingBoxRight:
|
|
45
|
-
alphabeticBaseline:
|
|
46
|
-
emHeightAscent:
|
|
47
|
-
emHeightDescent:
|
|
48
|
-
fontBoundingBoxAscent:
|
|
49
|
-
fontBoundingBoxDescent:
|
|
50
|
-
hangingBaseline:
|
|
51
|
-
ideographicBaseline:
|
|
52
|
-
width:
|
|
40
|
+
measureSize(text: string): {
|
|
41
|
+
actualBoundingBoxAscent: number;
|
|
42
|
+
actualBoundingBoxDescent: number;
|
|
43
|
+
actualBoundingBoxLeft: number;
|
|
44
|
+
actualBoundingBoxRight: number;
|
|
45
|
+
alphabeticBaseline: number;
|
|
46
|
+
emHeightAscent: number;
|
|
47
|
+
emHeightDescent: number;
|
|
48
|
+
fontBoundingBoxAscent: number;
|
|
49
|
+
fontBoundingBoxDescent: number;
|
|
50
|
+
hangingBaseline: number;
|
|
51
|
+
ideographicBaseline: number;
|
|
52
|
+
width: number;
|
|
53
53
|
height: number;
|
|
54
54
|
};
|
|
55
55
|
_getContextFont(): string;
|
package/lib/shapes/Text.js
CHANGED
|
@@ -8,7 +8,21 @@ const Global_1 = require("../Global");
|
|
|
8
8
|
const Validators_1 = require("../Validators");
|
|
9
9
|
const Global_2 = require("../Global");
|
|
10
10
|
function stringToArray(string) {
|
|
11
|
-
return
|
|
11
|
+
return [...string].reduce((acc, char, index, array) => {
|
|
12
|
+
if (/\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?(?:\u200D\p{Emoji_Presentation})+/u.test(char)) {
|
|
13
|
+
acc.push(char);
|
|
14
|
+
}
|
|
15
|
+
else if (/\p{Regional_Indicator}{2}/u.test(char + (array[index + 1] || ''))) {
|
|
16
|
+
acc.push(char + array[index + 1]);
|
|
17
|
+
}
|
|
18
|
+
else if (index > 0 && /\p{Mn}|\p{Me}|\p{Mc}/u.test(char)) {
|
|
19
|
+
acc[acc.length - 1] += char;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
acc.push(char);
|
|
23
|
+
}
|
|
24
|
+
return acc;
|
|
25
|
+
}, []);
|
|
12
26
|
}
|
|
13
27
|
exports.stringToArray = stringToArray;
|
|
14
28
|
var AUTO = 'auto', CENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', LTR = 'ltr', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', RTL = 'rtl', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [
|
package/lib/shapes/TextPath.d.ts
CHANGED
|
@@ -28,8 +28,8 @@ export declare class TextPath extends Shape<TextPathConfig> {
|
|
|
28
28
|
constructor(config?: TextPathConfig);
|
|
29
29
|
_getTextPathLength(): number;
|
|
30
30
|
_getPointAtLength(length: number): {
|
|
31
|
-
x:
|
|
32
|
-
y:
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
33
33
|
} | null;
|
|
34
34
|
_readDataAttribute(): void;
|
|
35
35
|
_sceneFunc(context: Context): void;
|