konva 10.2.4 → 10.3.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/lib/Global.js CHANGED
@@ -13,7 +13,7 @@ export const glob = typeof global !== 'undefined'
13
13
  : {};
14
14
  export const Konva = {
15
15
  _global: glob,
16
- version: '10.2.4',
16
+ version: '10.3.0',
17
17
  isBrowser: detectBrowser(),
18
18
  isUnminified: /param/.test(function (param) { }.toString()),
19
19
  dblClickWindow: 400,
@@ -45,6 +45,39 @@ const AUTO = 'auto', CENTER = 'center', INHERIT = 'inherit', JUSTIFY = 'justify'
45
45
  'ellipsis',
46
46
  'letterSpacing',
47
47
  ], attrChangeListLen = ATTR_CHANGE_LIST.length;
48
+ let _shadowOpacityBuggy = null;
49
+ function hasShadowOpacityBug() {
50
+ if (_shadowOpacityBuggy !== null) {
51
+ return _shadowOpacityBuggy;
52
+ }
53
+ _shadowOpacityBuggy = false;
54
+ try {
55
+ const c = document.createElement('canvas');
56
+ c.width = 10;
57
+ c.height = 10;
58
+ const ctx = c.getContext(CONTEXT_2D);
59
+ if (ctx) {
60
+ ctx.globalAlpha = 0;
61
+ ctx.shadowColor = 'black';
62
+ ctx.shadowBlur = 5;
63
+ ctx.shadowOffsetX = 5;
64
+ ctx.shadowOffsetY = 5;
65
+ ctx.fillStyle = 'black';
66
+ ctx.font = '10px Arial';
67
+ ctx.fillText('X', 0, 10);
68
+ const data = ctx.getImageData(0, 0, 10, 10).data;
69
+ for (let i = 3; i < data.length; i += 4) {
70
+ if (data[i] > 0) {
71
+ _shadowOpacityBuggy = true;
72
+ break;
73
+ }
74
+ }
75
+ }
76
+ }
77
+ catch (e) {
78
+ }
79
+ return _shadowOpacityBuggy;
80
+ }
48
81
  function normalizeFontFamily(fontFamily) {
49
82
  return fontFamily
50
83
  .split(',')
@@ -427,6 +460,9 @@ export class Text extends Shape {
427
460
  if (hasLine && hasShadow) {
428
461
  return true;
429
462
  }
463
+ if (hasShadow && this.getAbsoluteOpacity() !== 1 && hasShadowOpacityBug()) {
464
+ return true;
465
+ }
430
466
  return super._useBufferCanvas();
431
467
  }
432
468
  }
@@ -14,6 +14,7 @@ export interface TextPathConfig extends ShapeConfig {
14
14
  letterSpacing?: number;
15
15
  textBaseline?: string;
16
16
  textDecoration?: string;
17
+ direction?: string;
17
18
  kerningFunc?: (leftChar: string, rightChar: string) => number;
18
19
  lineHeight?: number;
19
20
  }
@@ -69,4 +70,5 @@ export declare class TextPath extends Shape<TextPathConfig> {
69
70
  kerningFunc: GetSet<(leftChar: string, rightChar: string) => number, this>;
70
71
  textBaseline: GetSet<string, this>;
71
72
  textDecoration: GetSet<string, this>;
73
+ direction: GetSet<string, this>;
72
74
  }
@@ -22,7 +22,7 @@ export class TextPath extends Shape {
22
22
  this._readDataAttribute();
23
23
  this._setTextData();
24
24
  });
25
- this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva', this._setTextData);
25
+ this.on('textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva directionChange.konva', this._setTextData);
26
26
  this._setTextData();
27
27
  }
28
28
  _getTextPathLength() {
@@ -137,6 +137,9 @@ export class TextPath extends Shape {
137
137
  }
138
138
  _setTextData() {
139
139
  const charArr = stringToArray(this.text());
140
+ if (this.direction() === 'rtl') {
141
+ charArr.reverse();
142
+ }
140
143
  const chars = [];
141
144
  let width = 0;
142
145
  for (let i = 0; i < charArr.length; i++) {
@@ -271,3 +274,4 @@ Factory.addGetterSetter(TextPath, 'fontVariant', NORMAL);
271
274
  Factory.addGetterSetter(TextPath, 'text', EMPTY_STRING);
272
275
  Factory.addGetterSetter(TextPath, 'textDecoration', '');
273
276
  Factory.addGetterSetter(TextPath, 'kerningFunc', undefined);
277
+ Factory.addGetterSetter(TextPath, 'direction', 'inherit');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "konva",
3
- "version": "10.2.4",
3
+ "version": "10.3.0",
4
4
  "description": "HTML5 2d canvas library.",
5
5
  "author": "Anton Lavrenov",
6
6
  "type": "module",
@@ -109,7 +109,7 @@
109
109
  "process": "^0.11.10",
110
110
  "rimraf": "^6.1.2",
111
111
  "rollup": "^4.55.1",
112
- "rollup-plugin-typescript2": "^0.36.0",
112
+ "rollup-plugin-typescript2": "^0.37.0",
113
113
  "size-limit": "^11.2.0",
114
114
  "skia-canvas": "^3.0.4",
115
115
  "ts-mocha": "^11.1.0",