fabric 6.6.2 → 6.6.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/CHANGELOG.md +12 -0
- package/dist/index.js +43 -17
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.min.mjs +1 -1
- package/dist/index.min.mjs.map +1 -1
- package/dist/index.mjs +43 -17
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +43 -17
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +43 -17
- package/dist/index.node.mjs.map +1 -1
- package/dist/package.json.min.mjs +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/Intersection.d.ts +1 -1
- package/dist/src/Intersection.min.mjs.map +1 -1
- package/dist/src/Intersection.mjs +1 -1
- package/dist/src/Intersection.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.d.ts +16 -14
- package/dist/src/shapes/Object/ObjectGeometry.d.ts.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.min.mjs.map +1 -1
- package/dist/src/shapes/Object/ObjectGeometry.mjs +16 -14
- package/dist/src/shapes/Object/ObjectGeometry.mjs.map +1 -1
- package/dist/src/shapes/Object/types/BaseProps.d.ts +2 -2
- package/dist/src/util/lang_string.d.ts.map +1 -1
- package/dist/src/util/lang_string.min.mjs +1 -1
- package/dist/src/util/lang_string.min.mjs.map +1 -1
- package/dist/src/util/lang_string.mjs +26 -0
- package/dist/src/util/lang_string.mjs.map +1 -1
- package/dist/src/util/misc/matrix.d.ts +1 -1
- package/dist/src/util/misc/matrix.min.mjs.map +1 -1
- package/dist/src/util/misc/matrix.mjs +1 -1
- package/dist/src/util/misc/matrix.mjs.map +1 -1
- package/dist-extensions/src/Intersection.d.ts +1 -1
- package/dist-extensions/src/shapes/Object/ObjectGeometry.d.ts +16 -14
- package/dist-extensions/src/shapes/Object/ObjectGeometry.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/types/BaseProps.d.ts +2 -2
- package/dist-extensions/src/util/lang_string.d.ts.map +1 -1
- package/dist-extensions/src/util/misc/matrix.d.ts +1 -1
- package/package.json +1 -1
- package/src/Intersection.ts +1 -1
- package/src/shapes/Object/ObjectGeometry.ts +16 -14
- package/src/shapes/Object/types/BaseProps.ts +2 -2
- package/src/util/lang_string.spec.ts +50 -0
- package/src/util/lang_string.ts +29 -2
- package/src/util/misc/matrix.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [6.6.5]
|
|
4
|
+
|
|
5
|
+
- feat(Text): Support for intl.segmenter in fabric.Text [#10595](https://github.com/fabricjs/fabric.js/pull/10595)
|
|
6
|
+
|
|
7
|
+
## [6.6.4]
|
|
8
|
+
|
|
9
|
+
- chore(): properly updated version number
|
|
10
|
+
|
|
11
|
+
## [6.6.3]
|
|
12
|
+
|
|
13
|
+
- docs(): Fixed JSDOCS for astro and typedoc
|
|
14
|
+
|
|
3
15
|
## [6.6.2]
|
|
4
16
|
|
|
5
17
|
- feat(IText): Allow text or container clipPath to clip the text selection or cursor [#104634](https://github.com/fabricjs/fabric.js/pull/10434)
|
package/dist/index.js
CHANGED
|
@@ -411,7 +411,7 @@
|
|
|
411
411
|
}
|
|
412
412
|
const cache = new Cache();
|
|
413
413
|
|
|
414
|
-
var version = "6.6.
|
|
414
|
+
var version = "6.6.5";
|
|
415
415
|
|
|
416
416
|
// use this syntax so babel plugin see this import here
|
|
417
417
|
const VERSION = version;
|
|
@@ -1648,7 +1648,7 @@
|
|
|
1648
1648
|
const multiplyTransformMatrices = (a, b, is2x2) => [a[0] * b[0] + a[2] * b[1], a[1] * b[0] + a[3] * b[1], a[0] * b[2] + a[2] * b[3], a[1] * b[2] + a[3] * b[3], is2x2 ? 0 : a[0] * b[4] + a[2] * b[5] + a[4], is2x2 ? 0 : a[1] * b[4] + a[3] * b[5] + a[5]];
|
|
1649
1649
|
|
|
1650
1650
|
/**
|
|
1651
|
-
* Multiplies {@link
|
|
1651
|
+
* Multiplies {@link TMat2D} such that a matrix defines the plane for the rest of the matrices **after** it
|
|
1652
1652
|
*
|
|
1653
1653
|
* `multiplyTransformMatrixArray([A, B, C, D])` is equivalent to `A(B(C(D)))`
|
|
1654
1654
|
*
|
|
@@ -5870,7 +5870,7 @@
|
|
|
5870
5870
|
}
|
|
5871
5871
|
|
|
5872
5872
|
/**
|
|
5873
|
-
* Use the ray casting algorithm to determine if {@link
|
|
5873
|
+
* Use the ray casting algorithm to determine if {@link Point} is in the polygon defined by [points]{@link Point}
|
|
5874
5874
|
* @see https://en.wikipedia.org/wiki/Point_in_polygon
|
|
5875
5875
|
* @param point
|
|
5876
5876
|
* @param points polygon points
|
|
@@ -6089,35 +6089,35 @@
|
|
|
6089
6089
|
*/
|
|
6090
6090
|
|
|
6091
6091
|
/**
|
|
6092
|
-
* @returns {number} x position according to object's {@link originX} property in canvas coordinate plane
|
|
6092
|
+
* @returns {number} x position according to object's {@link FabricObject#originX} property in canvas coordinate plane
|
|
6093
6093
|
*/
|
|
6094
6094
|
getX() {
|
|
6095
6095
|
return this.getXY().x;
|
|
6096
6096
|
}
|
|
6097
6097
|
|
|
6098
6098
|
/**
|
|
6099
|
-
* @param {number} value x position according to object's {@link originX} property in canvas coordinate plane
|
|
6099
|
+
* @param {number} value x position according to object's {@link FabricObject#originX} property in canvas coordinate plane
|
|
6100
6100
|
*/
|
|
6101
6101
|
setX(value) {
|
|
6102
6102
|
this.setXY(this.getXY().setX(value));
|
|
6103
6103
|
}
|
|
6104
6104
|
|
|
6105
6105
|
/**
|
|
6106
|
-
* @returns {number} y position according to object's {@link originY} property in canvas coordinate plane
|
|
6106
|
+
* @returns {number} y position according to object's {@link FabricObject#originY} property in canvas coordinate plane
|
|
6107
6107
|
*/
|
|
6108
6108
|
getY() {
|
|
6109
6109
|
return this.getXY().y;
|
|
6110
6110
|
}
|
|
6111
6111
|
|
|
6112
6112
|
/**
|
|
6113
|
-
* @param {number} value y position according to object's {@link originY} property in canvas coordinate plane
|
|
6113
|
+
* @param {number} value y position according to object's {@link FabricObject#originY} property in canvas coordinate plane
|
|
6114
6114
|
*/
|
|
6115
6115
|
setY(value) {
|
|
6116
6116
|
this.setXY(this.getXY().setY(value));
|
|
6117
6117
|
}
|
|
6118
6118
|
|
|
6119
6119
|
/**
|
|
6120
|
-
* @returns {number} x position according to object's {@link originX} property in parent's coordinate plane\
|
|
6120
|
+
* @returns {number} x position according to object's {@link FabricObject#originX} property in parent's coordinate plane\
|
|
6121
6121
|
* if parent is canvas then this property is identical to {@link getX}
|
|
6122
6122
|
*/
|
|
6123
6123
|
getRelativeX() {
|
|
@@ -6125,7 +6125,7 @@
|
|
|
6125
6125
|
}
|
|
6126
6126
|
|
|
6127
6127
|
/**
|
|
6128
|
-
* @param {number} value x position according to object's {@link originX} property in parent's coordinate plane\
|
|
6128
|
+
* @param {number} value x position according to object's {@link FabricObject#originX} property in parent's coordinate plane\
|
|
6129
6129
|
* if parent is canvas then this method is identical to {@link setX}
|
|
6130
6130
|
*/
|
|
6131
6131
|
setRelativeX(value) {
|
|
@@ -6133,7 +6133,7 @@
|
|
|
6133
6133
|
}
|
|
6134
6134
|
|
|
6135
6135
|
/**
|
|
6136
|
-
* @returns {number} y position according to object's {@link originY} property in parent's coordinate plane\
|
|
6136
|
+
* @returns {number} y position according to object's {@link FabricObject#originY} property in parent's coordinate plane\
|
|
6137
6137
|
* if parent is canvas then this property is identical to {@link getY}
|
|
6138
6138
|
*/
|
|
6139
6139
|
getRelativeY() {
|
|
@@ -6141,7 +6141,7 @@
|
|
|
6141
6141
|
}
|
|
6142
6142
|
|
|
6143
6143
|
/**
|
|
6144
|
-
* @param {number} value y position according to object's {@link originY} property in parent's coordinate plane\
|
|
6144
|
+
* @param {number} value y position according to object's {@link FabricObject#originY} property in parent's coordinate plane\
|
|
6145
6145
|
* if parent is canvas then this property is identical to {@link setY}
|
|
6146
6146
|
*/
|
|
6147
6147
|
setRelativeY(value) {
|
|
@@ -6149,7 +6149,7 @@
|
|
|
6149
6149
|
}
|
|
6150
6150
|
|
|
6151
6151
|
/**
|
|
6152
|
-
* @returns {Point} x position according to object's {@link originX} {@link originY} properties in canvas coordinate plane
|
|
6152
|
+
* @returns {Point} x position according to object's {@link FabricObject#originX} {@link FabricObject#originY} properties in canvas coordinate plane
|
|
6153
6153
|
*/
|
|
6154
6154
|
getXY() {
|
|
6155
6155
|
const relativePosition = this.getRelativeXY();
|
|
@@ -6158,7 +6158,7 @@
|
|
|
6158
6158
|
|
|
6159
6159
|
/**
|
|
6160
6160
|
* Set an object position to a particular point, the point is intended in absolute ( canvas ) coordinate.
|
|
6161
|
-
* You can specify {@link originX} and {@link originY} values,
|
|
6161
|
+
* You can specify {@link FabricObject#originX} and {@link FabricObject#originY} values,
|
|
6162
6162
|
* that otherwise are the object's current values.
|
|
6163
6163
|
* @example <caption>Set object's bottom left corner to point (5,5) on canvas</caption>
|
|
6164
6164
|
* object.setXY(new Point(5, 5), 'left', 'bottom').
|
|
@@ -6174,7 +6174,7 @@
|
|
|
6174
6174
|
}
|
|
6175
6175
|
|
|
6176
6176
|
/**
|
|
6177
|
-
* @returns {Point} x,y position according to object's {@link originX} {@link originY} properties in parent's coordinate plane
|
|
6177
|
+
* @returns {Point} x,y position according to object's {@link FabricObject#originX} {@link FabricObject#originY} properties in parent's coordinate plane
|
|
6178
6178
|
*/
|
|
6179
6179
|
getRelativeXY() {
|
|
6180
6180
|
return new Point(this.left, this.top);
|
|
@@ -6182,7 +6182,7 @@
|
|
|
6182
6182
|
|
|
6183
6183
|
/**
|
|
6184
6184
|
* As {@link setXY}, but in current parent's coordinate plane (the current group if any or the canvas)
|
|
6185
|
-
* @param {Point} point position according to object's {@link originX} {@link originY} properties in parent's coordinate plane
|
|
6185
|
+
* @param {Point} point position according to object's {@link FabricObject#originX} {@link FabricObject#originY} properties in parent's coordinate plane
|
|
6186
6186
|
* @param {TOriginX} [originX] Horizontal origin: 'left', 'center' or 'right'
|
|
6187
6187
|
* @param {TOriginY} [originY] Vertical origin: 'top', 'center' or 'bottom'
|
|
6188
6188
|
*/
|
|
@@ -6218,7 +6218,9 @@
|
|
|
6218
6218
|
}
|
|
6219
6219
|
|
|
6220
6220
|
/**
|
|
6221
|
-
* Checks if object intersects with the scene rect formed by
|
|
6221
|
+
* Checks if object intersects with the scene rect formed by TL and BR
|
|
6222
|
+
* In this case the rect is meant aligned with the axis of the canvas.
|
|
6223
|
+
* TL is the TOP LEFT point while br is the BOTTOM RIGHT point
|
|
6222
6224
|
*/
|
|
6223
6225
|
intersectsWithRect(tl, br) {
|
|
6224
6226
|
const intersection = Intersection.intersectPolygonRectangle(this.getCoords(), tl, br);
|
|
@@ -6246,7 +6248,7 @@
|
|
|
6246
6248
|
}
|
|
6247
6249
|
|
|
6248
6250
|
/**
|
|
6249
|
-
* Checks if object is fully contained within the scene rect formed by
|
|
6251
|
+
* Checks if object is fully contained within the scene rect formed by TL and BR
|
|
6250
6252
|
*/
|
|
6251
6253
|
isContainedWithinRect(tl, br) {
|
|
6252
6254
|
const {
|
|
@@ -10269,6 +10271,15 @@
|
|
|
10269
10271
|
* @return {String} Escaped version of a string
|
|
10270
10272
|
*/
|
|
10271
10273
|
const escapeXml = string => string.replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, ''').replace(/</g, '<').replace(/>/g, '>');
|
|
10274
|
+
let segmenter;
|
|
10275
|
+
const getSegmenter = () => {
|
|
10276
|
+
if (!segmenter) {
|
|
10277
|
+
segmenter = 'Intl' in getFabricWindow() && 'Segmenter' in Intl && new Intl.Segmenter(undefined, {
|
|
10278
|
+
granularity: 'grapheme'
|
|
10279
|
+
});
|
|
10280
|
+
}
|
|
10281
|
+
return segmenter;
|
|
10282
|
+
};
|
|
10272
10283
|
|
|
10273
10284
|
/**
|
|
10274
10285
|
* Divide a string in the user perceived single units
|
|
@@ -10276,6 +10287,21 @@
|
|
|
10276
10287
|
* @return {Array} array containing the graphemes
|
|
10277
10288
|
*/
|
|
10278
10289
|
const graphemeSplit = textstring => {
|
|
10290
|
+
segmenter || getSegmenter();
|
|
10291
|
+
if (segmenter) {
|
|
10292
|
+
const segments = segmenter.segment(textstring);
|
|
10293
|
+
return Array.from(segments).map(_ref => {
|
|
10294
|
+
let {
|
|
10295
|
+
segment
|
|
10296
|
+
} = _ref;
|
|
10297
|
+
return segment;
|
|
10298
|
+
});
|
|
10299
|
+
}
|
|
10300
|
+
|
|
10301
|
+
//Fallback
|
|
10302
|
+
return graphemeSplitImpl(textstring);
|
|
10303
|
+
};
|
|
10304
|
+
const graphemeSplitImpl = textstring => {
|
|
10279
10305
|
const graphemes = [];
|
|
10280
10306
|
for (let i = 0, chr; i < textstring.length; i++) {
|
|
10281
10307
|
if ((chr = getWholeChar(textstring, i)) === false) {
|