Comparing version 9.2.1 to 9.2.2
@@ -5,3 +5,6 @@ import { Canvas } from './Canvas.js'; | ||
import type { Node } from './Node.js'; | ||
declare var CONTEXT_PROPERTIES: readonly ["fillStyle", "strokeStyle", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY", "lineCap", "lineDashOffset", "lineJoin", "lineWidth", "miterLimit", "font", "textAlign", "textBaseline", "globalAlpha", "globalCompositeOperation", "imageSmoothingEnabled"]; | ||
declare var CONTEXT_PROPERTIES: readonly ["fillStyle", "strokeStyle", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY", "letterSpacing", "lineCap", "lineDashOffset", "lineJoin", "lineWidth", "miterLimit", "direction", "font", "textAlign", "textBaseline", "globalAlpha", "globalCompositeOperation", "imageSmoothingEnabled"]; | ||
interface ExtendedCanvasRenderingContext2D extends CanvasRenderingContext2D { | ||
letterSpacing: string; | ||
} | ||
export declare class Context { | ||
@@ -68,3 +71,3 @@ canvas: Canvas; | ||
} | ||
type CanvasContextProps = Pick<CanvasRenderingContext2D, (typeof CONTEXT_PROPERTIES)[number]>; | ||
type CanvasContextProps = Pick<ExtendedCanvasRenderingContext2D, (typeof CONTEXT_PROPERTIES)[number]>; | ||
export interface Context extends CanvasContextProps { | ||
@@ -71,0 +74,0 @@ } |
@@ -60,2 +60,3 @@ "use strict"; | ||
'shadowOffsetY', | ||
'letterSpacing', | ||
'lineCap', | ||
@@ -66,2 +67,3 @@ 'lineDashOffset', | ||
'miterLimit', | ||
'direction', | ||
'font', | ||
@@ -68,0 +70,0 @@ 'textAlign', |
@@ -19,3 +19,3 @@ "use strict"; | ||
_global: exports.glob, | ||
version: '9.2.1', | ||
version: '9.2.2', | ||
isBrowser: detectBrowser(), | ||
@@ -22,0 +22,0 @@ isUnminified: /param/.test(function (param) { }.toString()), |
@@ -113,4 +113,4 @@ import { Node, NodeConfig } from './Node.js'; | ||
getClientRect(config?: ShapeGetClientRectConfig): { | ||
width: any; | ||
height: any; | ||
width: number; | ||
height: number; | ||
x: number; | ||
@@ -117,0 +117,0 @@ y: number; |
@@ -6,2 +6,3 @@ import { Context } from '../Context.js'; | ||
export interface TextConfig extends ShapeConfig { | ||
direction?: string; | ||
text?: string; | ||
@@ -52,2 +53,3 @@ fontFamily?: string; | ||
_useBufferCanvas(): boolean; | ||
direction: GetSet<string, this>; | ||
fontFamily: GetSet<string, this>; | ||
@@ -54,0 +56,0 @@ fontSize: GetSet<number, this>; |
@@ -13,3 +13,4 @@ "use strict"; | ||
exports.stringToArray = stringToArray; | ||
var AUTO = 'auto', CENTER = 'center', JUSTIFY = 'justify', CHANGE_KONVA = 'Change.konva', CONTEXT_2D = '2d', DASH = '-', LEFT = 'left', TEXT = 'text', TEXT_UPPER = 'Text', TOP = 'top', BOTTOM = 'bottom', MIDDLE = 'middle', NORMAL = 'normal', PX_SPACE = 'px ', SPACE = ' ', RIGHT = 'right', WORD = 'word', CHAR = 'char', NONE = 'none', ELLIPSIS = '…', ATTR_CHANGE_LIST = [ | ||
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 = [ | ||
'direction', | ||
'fontFamily', | ||
@@ -83,3 +84,4 @@ 'fontSize', | ||
} | ||
var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n; | ||
var padding = this.padding(), fontSize = this.fontSize(), lineHeightPx = this.lineHeight() * fontSize, verticalAlign = this.verticalAlign(), direction = this.direction(), alignY = 0, align = this.align(), totalWidth = this.getWidth(), letterSpacing = this.letterSpacing(), fill = this.fill(), textDecoration = this.textDecoration(), shouldUnderline = textDecoration.indexOf('underline') !== -1, shouldLineThrough = textDecoration.indexOf('line-through') !== -1, n; | ||
direction = direction === INHERIT ? context.direction : direction; | ||
var translateY = 0; | ||
@@ -89,2 +91,5 @@ var translateY = lineHeightPx / 2; | ||
var lineTranslateY = 0; | ||
if (direction === RTL) { | ||
context.setAttr('direction', direction); | ||
} | ||
context.setAttr('font', this._getContextFont()); | ||
@@ -143,3 +148,3 @@ context.setAttr('textBaseline', MIDDLE); | ||
} | ||
if (letterSpacing !== 0 || align === JUSTIFY) { | ||
if (direction !== RTL && (letterSpacing !== 0 || align === JUSTIFY)) { | ||
spacesNumber = text.split(' ').length - 1; | ||
@@ -160,2 +165,5 @@ var array = stringToArray(text); | ||
else { | ||
if (letterSpacing !== 0) { | ||
context.setAttr('letterSpacing', `${letterSpacing}px`); | ||
} | ||
this._partialTextX = lineTranslateX; | ||
@@ -376,2 +384,3 @@ this._partialTextY = translateY + lineTranslateY; | ||
Factory_1.Factory.overWriteSetter(Text, 'height', (0, Validators_1.getNumberOrAutoValidator)()); | ||
Factory_1.Factory.addGetterSetter(Text, 'direction', INHERIT); | ||
Factory_1.Factory.addGetterSetter(Text, 'fontFamily', 'Arial'); | ||
@@ -378,0 +387,0 @@ Factory_1.Factory.addGetterSetter(Text, 'fontSize', 12, (0, Validators_1.getNumberValidator)()); |
{ | ||
"name": "konva", | ||
"version": "9.2.1", | ||
"version": "9.2.2", | ||
"author": "Anton Lavrenov", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -25,3 +25,3 @@ <p align="center"> | ||
```html | ||
<script src="https://unpkg.com/konva@8/konva.min.js"></script> | ||
<script src="https://unpkg.com/konva@9/konva.min.js"></script> | ||
<div id="container"></div> | ||
@@ -75,3 +75,3 @@ <script> | ||
```html | ||
<script src="https://unpkg.com/konva@8/konva.min.js"></script> | ||
<script src="https://unpkg.com/konva@9/konva.min.js"></script> | ||
``` | ||
@@ -78,0 +78,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1393292
32492