fabric 6.0.0-beta12 → 6.0.0-beta13
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/.gitmodules +3 -0
- package/.prettierignore +4 -3
- package/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +3 -1
- package/dist/index.js +102 -77
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +102 -77
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +102 -77
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +102 -77
- package/dist/index.node.mjs.map +1 -1
- package/dist/src/Collection.d.ts +1 -1
- package/dist/src/EventTypeDefs.d.ts +1 -0
- package/dist/src/canvas/SelectableCanvas.d.ts +4 -4
- package/dist/src/shapes/ActiveSelection.d.ts +15 -3
- package/dist/src/shapes/IText/ITextBehavior.d.ts +1 -1
- package/dist/src/shapes/Object/ObjectOrigin.d.ts +0 -14
- package/dist/src/shapes/Object/types/ObjectProps.d.ts +9 -0
- package/dist/src/shapes/Text/Text.d.ts +2 -2
- package/dist/src/shapes/Textbox.d.ts +3 -1
- package/dist/src/util/animation/types.d.ts +1 -1
- package/jest.config.js +1 -1
- package/jest.extend.ts +123 -0
- package/jest.setup.ts +5 -0
- package/package.json +4 -3
- package/playwright.setup.ts +1 -1
- package/src/Collection.ts +1 -1
- package/src/EventTypeDefs.ts +1 -0
- package/src/canvas/Canvas.ts +15 -11
- package/src/canvas/SelectableCanvas.ts +5 -4
- package/src/canvas/__tests__/__snapshots__/eventData.test.ts.snap +581 -0
- package/src/canvas/__tests__/eventData.test.ts +102 -0
- package/src/controls/polyControl.ts +12 -14
- package/src/controls/scale.ts +1 -1
- package/src/controls/wrapWithFixedAnchor.spec.ts +122 -0
- package/src/controls/wrapWithFixedAnchor.ts +7 -1
- package/src/shapes/ActiveSelection.spec.ts +89 -0
- package/src/shapes/ActiveSelection.ts +33 -11
- package/src/shapes/IText/ITextBehavior.test.ts +3 -4
- package/src/shapes/IText/ITextBehavior.ts +2 -1
- package/src/shapes/Object/Object.spec.ts +61 -0
- package/src/shapes/Object/Object.ts +18 -8
- package/src/shapes/Object/ObjectOrigin.ts +0 -48
- package/src/shapes/Object/types/ObjectProps.ts +10 -0
- package/src/shapes/Text/Text.spec.ts +3 -3
- package/src/shapes/Text/Text.ts +5 -4
- package/src/shapes/Text/__snapshots__/Text.spec.ts.snap +1 -0
- package/src/shapes/Textbox.spec.ts +4 -5
- package/src/shapes/Textbox.ts +6 -4
- package/src/shapes/__snapshots__/ActiveSelection.spec.ts.snap +43 -0
- package/src/shapes/__snapshots__/Textbox.spec.ts.snap +2 -0
- package/src/util/animation/types.ts +2 -1
- package/src/util/dom_misc.ts +3 -2
- package/typedoc.json +10 -0
- package/toMatchRoundedSnapshot.ts +0 -66
package/.gitmodules
ADDED
package/.prettierignore
CHANGED
|
@@ -7,13 +7,14 @@ change-output.md
|
|
|
7
7
|
before_commit
|
|
8
8
|
/coverage/
|
|
9
9
|
.idea/
|
|
10
|
-
/dist/fabric.require.js
|
|
11
|
-
/dist/fabric.min.js.gz
|
|
12
10
|
/cli_output/
|
|
13
11
|
/scripts/cli_cache.json
|
|
14
|
-
|
|
12
|
+
**/dist/
|
|
15
13
|
/lib/
|
|
16
14
|
/test/
|
|
17
15
|
.next/
|
|
18
16
|
.parcel-cache/
|
|
19
17
|
/docs/
|
|
18
|
+
/e2e/test-results/
|
|
19
|
+
/e2e/test-report/
|
|
20
|
+
/e2e/tests/**/*-snapshots/*.json
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
## [next]
|
|
4
4
|
|
|
5
|
+
## [6.0.0-b3]
|
|
6
|
+
|
|
7
|
+
- fix(Textbox): implemente a fix for the style shifting issues on new lines [#9197](https://github.com/fabricjs/fabric.js/pull/9197)
|
|
8
|
+
- Fix(Control) fix a regression in `wrap with fixed anchor`, regression from #8400 [#9326](https://github.com/fabricjs/fabric.js/pull/9326)
|
|
9
|
+
- test(e2e): improve test case for line shifting and style with more colors [#9327](https://github.com/fabricjs/fabric.js/pull/9327)
|
|
10
|
+
- test(e2e): node canvas visual tests [#9134](https://github.com/fabricjs/fabric.js/pull/9134)
|
|
11
|
+
- fix(ActiveSelection): make sure canvas is in charge of setting initial coords [#9322](https://github.com/fabricjs/fabric.js/pull/9322)
|
|
12
|
+
- test(): Migrate json control tests [#9323](https://github.com/fabricjs/fabric.js/pull/9323)
|
|
13
|
+
- fix() Textbox inputs with new lines, regression from #9097 [#9192](https://github.com/fabricjs/fabric.js/pull/9192)
|
|
14
|
+
- docs(): add link to contributing guide [#8393](https://github.com/fabricjs/fabric.js/pull/8393)
|
|
15
|
+
- test(e2e): Drag&Drop tests [#9112](https://github.com/fabricjs/fabric.js/pull/9112)
|
|
16
|
+
- fix(CanvasEvents): regression of `getPointer` usages + BREAKING: drop event data [#9186](https://github.com/fabricjs/fabric.js/pull/9186)
|
|
17
|
+
- feat(Object): BREAKING rm \_setOriginToCenter and \_resetOrigin unuseful methods [#9179](https://github.com/fabricjs/fabric.js/pull/9179)
|
|
18
|
+
- fix(ActiveSelection): reset positioning when cleared [#9088](https://github.com/fabricjs/fabric.js/pull/9088)
|
|
19
|
+
- ci(): generate docs [#9169](https://github.com/fabricjs/fabric.js/pull/9169)
|
|
20
|
+
- fix(utils) Fixes the code for the anchor point in point controls for polygons [#9178](https://github.com/fabricjs/fabric.js/pull/9178)
|
|
21
|
+
- CD(): website submodule [#9165](https://github.com/fabricjs/fabric.js/pull/9165)
|
|
22
|
+
|
|
5
23
|
## [6.0.0-beta12]
|
|
6
24
|
|
|
7
25
|
- fix(Object): border rendering with padding under group [#9161](https://github.com/fabricjs/fabric.js/pull/9161)
|
package/CONTRIBUTING.md
CHANGED
|
@@ -108,7 +108,8 @@ Fabric is an open source project 🦄 and as such depends on the **genuine effor
|
|
|
108
108
|
PRs must be backed with relevant tests, follow [TESTING](#-testing). If you never wrote a test or you find our tests unclear to extend, just ask for help.
|
|
109
109
|
Aim to cover 100% of the changes.
|
|
110
110
|
- **Docs** \
|
|
111
|
-
|
|
111
|
+
Update guides if necessary.\
|
|
112
|
+
Add relevant comments to your code using [JSDoc3][jsdoc], [JSDoc reference supported by TS][tsjsdoc].\
|
|
112
113
|
The generated documentation can be found at [fabricjs.com][docs], see [DOCS](#-improving-docs).
|
|
113
114
|
- **Changelog**\
|
|
114
115
|
Add a concise listing to the [**CHANGELOG**](CHANGELOG.md) describing what has changed or let github actions add the PR title for you.
|
|
@@ -263,6 +264,7 @@ Don't forget to unlink the package once you're done.
|
|
|
263
264
|
[prettier_extension]: https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
|
|
264
265
|
[eslint]: https://eslint.org/
|
|
265
266
|
[jsdoc]: https://jsdoc.app/
|
|
267
|
+
[tsjsdoc]: https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
|
|
266
268
|
[playwright]: https://playwright.dev/
|
|
267
269
|
[jest]: https://jestjs.io/
|
|
268
270
|
[qunit]: https://qunitjs.com/
|
package/dist/index.js
CHANGED
|
@@ -399,7 +399,7 @@
|
|
|
399
399
|
}
|
|
400
400
|
const cache = new Cache();
|
|
401
401
|
|
|
402
|
-
var version = "6.0.0-
|
|
402
|
+
var version = "6.0.0-beta13";
|
|
403
403
|
|
|
404
404
|
// use this syntax so babel plugin see this import here
|
|
405
405
|
const VERSION = version;
|
|
@@ -1258,7 +1258,7 @@
|
|
|
1258
1258
|
|
|
1259
1259
|
/**
|
|
1260
1260
|
* Returns true if collection contains an object.\
|
|
1261
|
-
* **Prefer using {@link
|
|
1261
|
+
* **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**
|
|
1262
1262
|
* instead of `a.contains(b)` use `b.isDescendantOf(a)`
|
|
1263
1263
|
* @param {Object} object Object to check against
|
|
1264
1264
|
* @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`
|
|
@@ -2771,15 +2771,15 @@
|
|
|
2771
2771
|
* @return {Object} Object with left/top values
|
|
2772
2772
|
*/
|
|
2773
2773
|
function getScrollLeftTop(element) {
|
|
2774
|
+
const doc = element && getDocumentFromElement(element);
|
|
2774
2775
|
let left = 0,
|
|
2775
2776
|
top = 0;
|
|
2776
|
-
if (!element) {
|
|
2777
|
+
if (!element || !doc) {
|
|
2777
2778
|
return {
|
|
2778
2779
|
left,
|
|
2779
2780
|
top
|
|
2780
2781
|
};
|
|
2781
2782
|
}
|
|
2782
|
-
const doc = getDocumentFromElement(element);
|
|
2783
2783
|
const docElement = doc.documentElement,
|
|
2784
2784
|
body = doc.body || {
|
|
2785
2785
|
scrollLeft: 0,
|
|
@@ -5920,38 +5920,6 @@
|
|
|
5920
5920
|
});
|
|
5921
5921
|
}
|
|
5922
5922
|
|
|
5923
|
-
/**
|
|
5924
|
-
* Sets the origin/position of the object to it's center point
|
|
5925
|
-
* @private
|
|
5926
|
-
* @return {void}
|
|
5927
|
-
*/
|
|
5928
|
-
_setOriginToCenter() {
|
|
5929
|
-
this._originalOriginX = this.originX;
|
|
5930
|
-
this._originalOriginY = this.originY;
|
|
5931
|
-
const center = this.getRelativeCenterPoint();
|
|
5932
|
-
this.originX = CENTER;
|
|
5933
|
-
this.originY = CENTER;
|
|
5934
|
-
this.left = center.x;
|
|
5935
|
-
this.top = center.y;
|
|
5936
|
-
}
|
|
5937
|
-
|
|
5938
|
-
/**
|
|
5939
|
-
* Resets the origin/position of the object to it's original origin
|
|
5940
|
-
* @private
|
|
5941
|
-
* @return {void}
|
|
5942
|
-
*/
|
|
5943
|
-
_resetOrigin() {
|
|
5944
|
-
if (this._originalOriginX !== undefined && this._originalOriginY !== undefined) {
|
|
5945
|
-
const originPoint = this.translateToOriginPoint(this.getRelativeCenterPoint(), this._originalOriginX, this._originalOriginY);
|
|
5946
|
-
this.left = originPoint.x;
|
|
5947
|
-
this.top = originPoint.y;
|
|
5948
|
-
this.originX = this._originalOriginX;
|
|
5949
|
-
this.originY = this._originalOriginY;
|
|
5950
|
-
this._originalOriginX = undefined;
|
|
5951
|
-
this._originalOriginY = undefined;
|
|
5952
|
-
}
|
|
5953
|
-
}
|
|
5954
|
-
|
|
5955
5923
|
/**
|
|
5956
5924
|
* @private
|
|
5957
5925
|
*/
|
|
@@ -8216,13 +8184,31 @@
|
|
|
8216
8184
|
* @param {TDegree} angle Angle value (in degrees)
|
|
8217
8185
|
*/
|
|
8218
8186
|
rotate(angle) {
|
|
8219
|
-
const
|
|
8220
|
-
|
|
8221
|
-
|
|
8187
|
+
const {
|
|
8188
|
+
centeredRotation,
|
|
8189
|
+
originX,
|
|
8190
|
+
originY
|
|
8191
|
+
} = this;
|
|
8192
|
+
if (centeredRotation) {
|
|
8193
|
+
const {
|
|
8194
|
+
x,
|
|
8195
|
+
y
|
|
8196
|
+
} = this.getRelativeCenterPoint();
|
|
8197
|
+
this.originX = CENTER;
|
|
8198
|
+
this.originY = CENTER;
|
|
8199
|
+
this.left = x;
|
|
8200
|
+
this.top = y;
|
|
8222
8201
|
}
|
|
8223
8202
|
this.set('angle', angle);
|
|
8224
|
-
if (
|
|
8225
|
-
|
|
8203
|
+
if (centeredRotation) {
|
|
8204
|
+
const {
|
|
8205
|
+
x,
|
|
8206
|
+
y
|
|
8207
|
+
} = this.translateToOriginPoint(this.getRelativeCenterPoint(), originX, originY);
|
|
8208
|
+
this.left = x;
|
|
8209
|
+
this.top = y;
|
|
8210
|
+
this.originX = originX;
|
|
8211
|
+
this.originY = originY;
|
|
8226
8212
|
}
|
|
8227
8213
|
}
|
|
8228
8214
|
|
|
@@ -8356,7 +8342,9 @@
|
|
|
8356
8342
|
centerPoint = target.getRelativeCenterPoint(),
|
|
8357
8343
|
constraint = target.translateToOriginPoint(centerPoint, originX, originY),
|
|
8358
8344
|
actionPerformed = actionHandler(eventData, transform, x, y);
|
|
8359
|
-
|
|
8345
|
+
// flipping requires to change the transform origin, so we read from the mutated transform
|
|
8346
|
+
// instead of leveraging the one destructured before
|
|
8347
|
+
target.setPositionByOrigin(constraint, transform.originX, transform.originY);
|
|
8360
8348
|
return actionPerformed;
|
|
8361
8349
|
};
|
|
8362
8350
|
}
|
|
@@ -8962,7 +8950,7 @@
|
|
|
8962
8950
|
transform.signY = signY;
|
|
8963
8951
|
}
|
|
8964
8952
|
}
|
|
8965
|
-
// minScale is taken
|
|
8953
|
+
// minScale is taken care of in the setter.
|
|
8966
8954
|
const oldScaleX = target.scaleX,
|
|
8967
8955
|
oldScaleY = target.scaleY;
|
|
8968
8956
|
if (!by) {
|
|
@@ -11351,9 +11339,22 @@
|
|
|
11351
11339
|
_defineProperty(Group, "ownDefaults", groupDefaultValues);
|
|
11352
11340
|
classRegistry.setClass(Group);
|
|
11353
11341
|
|
|
11342
|
+
/**
|
|
11343
|
+
* Used by Canvas to manage selection.
|
|
11344
|
+
* Canvas accepts an `activeSelection` option allowing overriding and customization.
|
|
11345
|
+
*
|
|
11346
|
+
* @example
|
|
11347
|
+
* class MyActiveSelection extends ActiveSelection {
|
|
11348
|
+
* ...
|
|
11349
|
+
* }
|
|
11350
|
+
*
|
|
11351
|
+
* const canvas = new Canvas(el, {
|
|
11352
|
+
* activeSelection: new MyActiveSelection()
|
|
11353
|
+
* })
|
|
11354
|
+
*/
|
|
11354
11355
|
class ActiveSelection extends Group {
|
|
11355
|
-
constructor(
|
|
11356
|
-
super(
|
|
11356
|
+
constructor() {
|
|
11357
|
+
super(...arguments);
|
|
11357
11358
|
/**
|
|
11358
11359
|
* controls how selected objects are added during a multiselection event
|
|
11359
11360
|
* - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order
|
|
@@ -11363,9 +11364,7 @@
|
|
|
11363
11364
|
*/
|
|
11364
11365
|
// TODO FIX THIS WITH THE DEFAULTS LOGIC
|
|
11365
11366
|
_defineProperty(this, "multiSelectionStacking", 'canvas-stacking');
|
|
11366
|
-
this.setCoords();
|
|
11367
11367
|
}
|
|
11368
|
-
|
|
11369
11368
|
/**
|
|
11370
11369
|
* @private
|
|
11371
11370
|
*/
|
|
@@ -11470,6 +11469,24 @@
|
|
|
11470
11469
|
this.removeAll();
|
|
11471
11470
|
return false;
|
|
11472
11471
|
}
|
|
11472
|
+
_applyLayoutStrategy(context) {
|
|
11473
|
+
super._applyLayoutStrategy(context);
|
|
11474
|
+
if (this._objects.length === 0) {
|
|
11475
|
+
// in this case layout was skipped
|
|
11476
|
+
// we reset transform for the next selection
|
|
11477
|
+
Object.assign(this, {
|
|
11478
|
+
left: 0,
|
|
11479
|
+
top: 0,
|
|
11480
|
+
angle: 0,
|
|
11481
|
+
scaleX: 1,
|
|
11482
|
+
scaleY: 1,
|
|
11483
|
+
skewX: 0,
|
|
11484
|
+
skewY: 0,
|
|
11485
|
+
flipX: false,
|
|
11486
|
+
flipY: false
|
|
11487
|
+
});
|
|
11488
|
+
}
|
|
11489
|
+
}
|
|
11473
11490
|
|
|
11474
11491
|
/**
|
|
11475
11492
|
* Returns string representation of a group
|
|
@@ -13522,6 +13539,7 @@
|
|
|
13522
13539
|
_defineProperty(this, "_activeSelection", void 0);
|
|
13523
13540
|
this._activeSelection = activeSelection;
|
|
13524
13541
|
this._activeSelection.set('canvas', this);
|
|
13542
|
+
this._activeSelection.setCoords();
|
|
13525
13543
|
}
|
|
13526
13544
|
initElements(el) {
|
|
13527
13545
|
this.elements = new CanvasDOMManager(el, {
|
|
@@ -13966,7 +13984,7 @@
|
|
|
13966
13984
|
|
|
13967
13985
|
/**
|
|
13968
13986
|
* Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted
|
|
13969
|
-
* @see {@link
|
|
13987
|
+
* @see {@link _searchPossibleTargets}
|
|
13970
13988
|
* @param {FabricObject[]} [objects] objects array to look into
|
|
13971
13989
|
* @param {Object} [pointer] x,y object of point coordinates we want to check.
|
|
13972
13990
|
* @return {FabricObject} **top most object on screen** that contains pointer
|
|
@@ -13997,9 +14015,9 @@
|
|
|
13997
14015
|
* by the viewportTransform ( sort of coordinates of what is displayed
|
|
13998
14016
|
* on the canvas where you are clicking.
|
|
13999
14017
|
* ignoreVpt true = HTMLElement coordinates relative to top,left
|
|
14000
|
-
* ignoreVpt false, default = fabric space coordinates, the same used for shape position
|
|
14001
|
-
* To interact with your shapes top and left you want to use ignoreVpt
|
|
14002
|
-
* most of the time, while ignoreVpt
|
|
14018
|
+
* ignoreVpt false, default = fabric space coordinates, the same used for shape position.
|
|
14019
|
+
* To interact with your shapes top and left you want to use ignoreVpt false
|
|
14020
|
+
* most of the time, while ignoreVpt true will give you coordinates
|
|
14003
14021
|
* compatible with the object.oCoords system.
|
|
14004
14022
|
* of the time.
|
|
14005
14023
|
* @param {Event} e
|
|
@@ -14586,8 +14604,8 @@
|
|
|
14586
14604
|
const shared = {
|
|
14587
14605
|
e,
|
|
14588
14606
|
isClick: false,
|
|
14589
|
-
pointer: this.getPointer(e),
|
|
14590
|
-
absolutePointer: this.getPointer(e
|
|
14607
|
+
pointer: this.getPointer(e, true),
|
|
14608
|
+
absolutePointer: this.getPointer(e)
|
|
14591
14609
|
};
|
|
14592
14610
|
this.fire('mouse:out', _objectSpread2(_objectSpread2({}, shared), {}, {
|
|
14593
14611
|
target
|
|
@@ -14618,8 +14636,8 @@
|
|
|
14618
14636
|
this.fire('mouse:over', {
|
|
14619
14637
|
e,
|
|
14620
14638
|
isClick: false,
|
|
14621
|
-
pointer: this.getPointer(e),
|
|
14622
|
-
absolutePointer: this.getPointer(e
|
|
14639
|
+
pointer: this.getPointer(e, true),
|
|
14640
|
+
absolutePointer: this.getPointer(e)
|
|
14623
14641
|
});
|
|
14624
14642
|
this._hoveredTarget = undefined;
|
|
14625
14643
|
this._hoveredTargets = [];
|
|
@@ -14851,7 +14869,8 @@
|
|
|
14851
14869
|
target,
|
|
14852
14870
|
subTargets: targets,
|
|
14853
14871
|
dragSource: this._dragSource,
|
|
14854
|
-
pointer: this.getPointer(e)
|
|
14872
|
+
pointer: this.getPointer(e, true),
|
|
14873
|
+
absolutePointer: this.getPointer(e)
|
|
14855
14874
|
});
|
|
14856
14875
|
// will be set by the drop target
|
|
14857
14876
|
options.didDrop = false;
|
|
@@ -15168,8 +15187,8 @@
|
|
|
15168
15187
|
subTargets: targets,
|
|
15169
15188
|
button,
|
|
15170
15189
|
isClick,
|
|
15171
|
-
pointer: this.getPointer(e),
|
|
15172
|
-
absolutePointer: this.getPointer(e
|
|
15190
|
+
pointer: this.getPointer(e, true),
|
|
15191
|
+
absolutePointer: this.getPointer(e),
|
|
15173
15192
|
transform: this._currentTransform
|
|
15174
15193
|
};
|
|
15175
15194
|
if (eventType === 'up') {
|
|
@@ -15233,6 +15252,7 @@
|
|
|
15233
15252
|
this.discardActiveObject(e);
|
|
15234
15253
|
this.requestRenderAll();
|
|
15235
15254
|
}
|
|
15255
|
+
// this is an absolute pointer, the naming is wrong
|
|
15236
15256
|
const pointer = this.getPointer(e);
|
|
15237
15257
|
this.freeDrawingBrush && this.freeDrawingBrush.onMouseDown(pointer, {
|
|
15238
15258
|
e,
|
|
@@ -15250,6 +15270,7 @@
|
|
|
15250
15270
|
const pointer = this.getPointer(e);
|
|
15251
15271
|
this.freeDrawingBrush && this.freeDrawingBrush.onMouseMove(pointer, {
|
|
15252
15272
|
e,
|
|
15273
|
+
// this is an absolute pointer, the naming is wrong
|
|
15253
15274
|
pointer
|
|
15254
15275
|
});
|
|
15255
15276
|
}
|
|
@@ -15266,6 +15287,7 @@
|
|
|
15266
15287
|
if (this.freeDrawingBrush) {
|
|
15267
15288
|
this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({
|
|
15268
15289
|
e: e,
|
|
15290
|
+
// this is an absolute pointer, the naming is wrong
|
|
15269
15291
|
pointer: pointer
|
|
15270
15292
|
});
|
|
15271
15293
|
} else {
|
|
@@ -15521,8 +15543,8 @@
|
|
|
15521
15543
|
target: oldTarget,
|
|
15522
15544
|
nextTarget: target,
|
|
15523
15545
|
isClick: false,
|
|
15524
|
-
pointer: this.getPointer(e),
|
|
15525
|
-
absolutePointer: this.getPointer(e
|
|
15546
|
+
pointer: this.getPointer(e, true),
|
|
15547
|
+
absolutePointer: this.getPointer(e)
|
|
15526
15548
|
});
|
|
15527
15549
|
fireCanvas && this.fire(canvasIn, outOpt);
|
|
15528
15550
|
oldTarget.fire(targetOut, outOpt);
|
|
@@ -15533,8 +15555,8 @@
|
|
|
15533
15555
|
target,
|
|
15534
15556
|
previousTarget: oldTarget,
|
|
15535
15557
|
isClick: false,
|
|
15536
|
-
pointer: this.getPointer(e),
|
|
15537
|
-
absolutePointer: this.getPointer(e
|
|
15558
|
+
pointer: this.getPointer(e, true),
|
|
15559
|
+
absolutePointer: this.getPointer(e)
|
|
15538
15560
|
});
|
|
15539
15561
|
fireCanvas && this.fire(canvasOut, inOpt);
|
|
15540
15562
|
target.fire(targetIn, inOpt);
|
|
@@ -19065,10 +19087,10 @@
|
|
|
19065
19087
|
/**
|
|
19066
19088
|
* Detect if a line has a linebreak and so we need to account for it when moving
|
|
19067
19089
|
* and counting style.
|
|
19068
|
-
* It return always for text and Itext.
|
|
19090
|
+
* It return always 1 for text and Itext. Textbox has its own implementation
|
|
19069
19091
|
* @return Number
|
|
19070
19092
|
*/
|
|
19071
|
-
|
|
19093
|
+
|
|
19072
19094
|
missingNewlineOffset(lineIndex) {
|
|
19073
19095
|
return 1;
|
|
19074
19096
|
}
|
|
@@ -19088,7 +19110,7 @@
|
|
|
19088
19110
|
charIndex: selectionStart
|
|
19089
19111
|
};
|
|
19090
19112
|
}
|
|
19091
|
-
selectionStart -= lines[i].length + this.missingNewlineOffset(i);
|
|
19113
|
+
selectionStart -= lines[i].length + this.missingNewlineOffset(i, skipWrapping);
|
|
19092
19114
|
}
|
|
19093
19115
|
return {
|
|
19094
19116
|
lineIndex: i - 1,
|
|
@@ -20552,8 +20574,7 @@
|
|
|
20552
20574
|
* - `!` Matches a "!" character (char code 33).
|
|
20553
20575
|
* - `\?` Matches a "?" character (char code 63).
|
|
20554
20576
|
* - `\-` Matches a "-" character (char code 45).
|
|
20555
|
-
*/
|
|
20556
|
-
// eslint-disable-next-line no-useless-escape
|
|
20577
|
+
*/ // eslint-disable-next-line no-useless-escape
|
|
20557
20578
|
const reNonWord = /[ \n\.,;!\?\-]/;
|
|
20558
20579
|
class ITextBehavior extends Text {
|
|
20559
20580
|
constructor() {
|
|
@@ -20840,7 +20861,7 @@
|
|
|
20840
20861
|
}
|
|
20841
20862
|
|
|
20842
20863
|
/**
|
|
20843
|
-
* called by {@link
|
|
20864
|
+
* called by {@link Canvas#textEditingManager}
|
|
20844
20865
|
*/
|
|
20845
20866
|
updateSelectionOnMouseMove(e) {
|
|
20846
20867
|
if (this.getActiveControl()) {
|
|
@@ -23095,14 +23116,17 @@
|
|
|
23095
23116
|
let offset = 0;
|
|
23096
23117
|
const wordsOrGraphemes = splitByGrapheme ? this.graphemeSplit(line) : this.wordSplit(line);
|
|
23097
23118
|
if (wordsOrGraphemes.length === 0) {
|
|
23098
|
-
return [
|
|
23119
|
+
return [{
|
|
23120
|
+
word: [],
|
|
23121
|
+
width: 0
|
|
23122
|
+
}];
|
|
23099
23123
|
}
|
|
23100
23124
|
return wordsOrGraphemes.map(word => {
|
|
23101
23125
|
// if using splitByGrapheme words are already in graphemes.
|
|
23102
23126
|
const graphemeArray = splitByGrapheme ? [word] : this.graphemeSplit(word);
|
|
23103
23127
|
const width = this._measureWord(graphemeArray, lineIndex, offset);
|
|
23104
23128
|
largestWordWidth = Math.max(width, largestWordWidth);
|
|
23105
|
-
offset +=
|
|
23129
|
+
offset += graphemeArray.length + infix.length;
|
|
23106
23130
|
return {
|
|
23107
23131
|
word: graphemeArray,
|
|
23108
23132
|
width
|
|
@@ -23238,10 +23262,12 @@
|
|
|
23238
23262
|
/**
|
|
23239
23263
|
* Detect if a line has a linebreak and so we need to account for it when moving
|
|
23240
23264
|
* and counting style.
|
|
23265
|
+
* This is important only for splitByGrapheme at the end of wrapping.
|
|
23266
|
+
* If we are not wrapping the offset is always 1
|
|
23241
23267
|
* @return Number
|
|
23242
23268
|
*/
|
|
23243
|
-
missingNewlineOffset(lineIndex) {
|
|
23244
|
-
if (this.splitByGrapheme) {
|
|
23269
|
+
missingNewlineOffset(lineIndex, skipWrapping) {
|
|
23270
|
+
if (this.splitByGrapheme && !skipWrapping) {
|
|
23245
23271
|
return this.isEndOfWrapping(lineIndex) ? 1 : 0;
|
|
23246
23272
|
}
|
|
23247
23273
|
return 1;
|
|
@@ -25017,15 +25043,14 @@
|
|
|
25017
25043
|
const anchorWrapper = (pointIndex, fn) => {
|
|
25018
25044
|
return function (eventData, transform, x, y) {
|
|
25019
25045
|
const poly = transform.target,
|
|
25020
|
-
|
|
25021
|
-
|
|
25046
|
+
anchorPoint = new Point(poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1]),
|
|
25047
|
+
anchorPointInParentPlane = anchorPoint.subtract(poly.pathOffset).transform(poly.calcOwnMatrix()),
|
|
25022
25048
|
actionPerformed = fn(eventData, _objectSpread2(_objectSpread2({}, transform), {}, {
|
|
25023
25049
|
pointIndex
|
|
25024
25050
|
}), x, y),
|
|
25025
|
-
polygonBaseSize = getSize(poly),
|
|
25026
25051
|
adjustFlip = new Point(poly.flipX ? -1 : 1, poly.flipY ? -1 : 1);
|
|
25027
|
-
const
|
|
25028
|
-
poly.setPositionByOrigin(
|
|
25052
|
+
const newPositionNormalized = anchorPoint.subtract(poly.pathOffset).divide(poly._getNonTransformedDimensions()).multiply(adjustFlip);
|
|
25053
|
+
poly.setPositionByOrigin(anchorPointInParentPlane, newPositionNormalized.x + 0.5, newPositionNormalized.y + 0.5);
|
|
25029
25054
|
return actionPerformed;
|
|
25030
25055
|
};
|
|
25031
25056
|
};
|