fabric 6.0.0-beta11 → 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 +24 -0
- package/CONTRIBUTING.md +3 -1
- package/dist/index.js +110 -80
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.mjs +110 -80
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +110 -80
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +110 -80
- 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 +22 -16
- 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/IText/__snapshots__/ITextBehavior.test.ts.snap +0 -6
- package/src/shapes/Object/InteractiveObject.ts +4 -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 -1
- 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 -3
- 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/dist/index.node.mjs
CHANGED
|
@@ -453,7 +453,7 @@ class Cache {
|
|
|
453
453
|
}
|
|
454
454
|
const cache = new Cache();
|
|
455
455
|
|
|
456
|
-
var version = "6.0.0-
|
|
456
|
+
var version = "6.0.0-beta13";
|
|
457
457
|
|
|
458
458
|
// use this syntax so babel plugin see this import here
|
|
459
459
|
const VERSION = version;
|
|
@@ -1312,7 +1312,7 @@ function createCollectionMixin(Base) {
|
|
|
1312
1312
|
|
|
1313
1313
|
/**
|
|
1314
1314
|
* Returns true if collection contains an object.\
|
|
1315
|
-
* **Prefer using {@link
|
|
1315
|
+
* **Prefer using {@link FabricObject#isDescendantOf} for performance reasons**
|
|
1316
1316
|
* instead of `a.contains(b)` use `b.isDescendantOf(a)`
|
|
1317
1317
|
* @param {Object} object Object to check against
|
|
1318
1318
|
* @param {Boolean} [deep=false] `true` to check all descendants, `false` to check only `_objects`
|
|
@@ -2825,15 +2825,15 @@ const isFabricObjectWithDragSupport = fabricObject => {
|
|
|
2825
2825
|
* @return {Object} Object with left/top values
|
|
2826
2826
|
*/
|
|
2827
2827
|
function getScrollLeftTop(element) {
|
|
2828
|
+
const doc = element && getDocumentFromElement(element);
|
|
2828
2829
|
let left = 0,
|
|
2829
2830
|
top = 0;
|
|
2830
|
-
if (!element) {
|
|
2831
|
+
if (!element || !doc) {
|
|
2831
2832
|
return {
|
|
2832
2833
|
left,
|
|
2833
2834
|
top
|
|
2834
2835
|
};
|
|
2835
2836
|
}
|
|
2836
|
-
const doc = getDocumentFromElement(element);
|
|
2837
2837
|
const docElement = doc.documentElement,
|
|
2838
2838
|
body = doc.body || {
|
|
2839
2839
|
scrollLeft: 0,
|
|
@@ -5974,38 +5974,6 @@ class ObjectOrigin extends CommonMethods {
|
|
|
5974
5974
|
});
|
|
5975
5975
|
}
|
|
5976
5976
|
|
|
5977
|
-
/**
|
|
5978
|
-
* Sets the origin/position of the object to it's center point
|
|
5979
|
-
* @private
|
|
5980
|
-
* @return {void}
|
|
5981
|
-
*/
|
|
5982
|
-
_setOriginToCenter() {
|
|
5983
|
-
this._originalOriginX = this.originX;
|
|
5984
|
-
this._originalOriginY = this.originY;
|
|
5985
|
-
const center = this.getRelativeCenterPoint();
|
|
5986
|
-
this.originX = CENTER;
|
|
5987
|
-
this.originY = CENTER;
|
|
5988
|
-
this.left = center.x;
|
|
5989
|
-
this.top = center.y;
|
|
5990
|
-
}
|
|
5991
|
-
|
|
5992
|
-
/**
|
|
5993
|
-
* Resets the origin/position of the object to it's original origin
|
|
5994
|
-
* @private
|
|
5995
|
-
* @return {void}
|
|
5996
|
-
*/
|
|
5997
|
-
_resetOrigin() {
|
|
5998
|
-
if (this._originalOriginX !== undefined && this._originalOriginY !== undefined) {
|
|
5999
|
-
const originPoint = this.translateToOriginPoint(this.getRelativeCenterPoint(), this._originalOriginX, this._originalOriginY);
|
|
6000
|
-
this.left = originPoint.x;
|
|
6001
|
-
this.top = originPoint.y;
|
|
6002
|
-
this.originX = this._originalOriginX;
|
|
6003
|
-
this.originY = this._originalOriginY;
|
|
6004
|
-
this._originalOriginX = undefined;
|
|
6005
|
-
this._originalOriginY = undefined;
|
|
6006
|
-
}
|
|
6007
|
-
}
|
|
6008
|
-
|
|
6009
5977
|
/**
|
|
6010
5978
|
* @private
|
|
6011
5979
|
*/
|
|
@@ -8270,13 +8238,31 @@ let FabricObject$1 = class FabricObject extends AnimatableObject {
|
|
|
8270
8238
|
* @param {TDegree} angle Angle value (in degrees)
|
|
8271
8239
|
*/
|
|
8272
8240
|
rotate(angle) {
|
|
8273
|
-
const
|
|
8274
|
-
|
|
8275
|
-
|
|
8241
|
+
const {
|
|
8242
|
+
centeredRotation,
|
|
8243
|
+
originX,
|
|
8244
|
+
originY
|
|
8245
|
+
} = this;
|
|
8246
|
+
if (centeredRotation) {
|
|
8247
|
+
const {
|
|
8248
|
+
x,
|
|
8249
|
+
y
|
|
8250
|
+
} = this.getRelativeCenterPoint();
|
|
8251
|
+
this.originX = CENTER;
|
|
8252
|
+
this.originY = CENTER;
|
|
8253
|
+
this.left = x;
|
|
8254
|
+
this.top = y;
|
|
8276
8255
|
}
|
|
8277
8256
|
this.set('angle', angle);
|
|
8278
|
-
if (
|
|
8279
|
-
|
|
8257
|
+
if (centeredRotation) {
|
|
8258
|
+
const {
|
|
8259
|
+
x,
|
|
8260
|
+
y
|
|
8261
|
+
} = this.translateToOriginPoint(this.getRelativeCenterPoint(), originX, originY);
|
|
8262
|
+
this.left = x;
|
|
8263
|
+
this.top = y;
|
|
8264
|
+
this.originX = originX;
|
|
8265
|
+
this.originY = originY;
|
|
8280
8266
|
}
|
|
8281
8267
|
}
|
|
8282
8268
|
|
|
@@ -8410,7 +8396,9 @@ function wrapWithFixedAnchor(actionHandler) {
|
|
|
8410
8396
|
centerPoint = target.getRelativeCenterPoint(),
|
|
8411
8397
|
constraint = target.translateToOriginPoint(centerPoint, originX, originY),
|
|
8412
8398
|
actionPerformed = actionHandler(eventData, transform, x, y);
|
|
8413
|
-
|
|
8399
|
+
// flipping requires to change the transform origin, so we read from the mutated transform
|
|
8400
|
+
// instead of leveraging the one destructured before
|
|
8401
|
+
target.setPositionByOrigin(constraint, transform.originX, transform.originY);
|
|
8414
8402
|
return actionPerformed;
|
|
8415
8403
|
};
|
|
8416
8404
|
}
|
|
@@ -9016,7 +9004,7 @@ function scaleObject(eventData, transform, x, y) {
|
|
|
9016
9004
|
transform.signY = signY;
|
|
9017
9005
|
}
|
|
9018
9006
|
}
|
|
9019
|
-
// minScale is taken
|
|
9007
|
+
// minScale is taken care of in the setter.
|
|
9020
9008
|
const oldScaleX = target.scaleX,
|
|
9021
9009
|
oldScaleY = target.scaleY;
|
|
9022
9010
|
if (!by) {
|
|
@@ -9660,7 +9648,7 @@ class InteractiveFabricObject extends FabricObject$1 {
|
|
|
9660
9648
|
// this is extremely confusing. options comes from the upper function
|
|
9661
9649
|
// and is the qrDecompose of a matrix that takes in account zoom too
|
|
9662
9650
|
new Point(options.scaleX, options.scaleY)).scalarMultiply(this.strokeWidth);
|
|
9663
|
-
size = bbox.add(stroke).scalarAdd(this.borderScaleFactor);
|
|
9651
|
+
size = bbox.add(stroke).scalarAdd(this.borderScaleFactor).scalarAdd(this.padding * 2);
|
|
9664
9652
|
} else {
|
|
9665
9653
|
size = this._calculateCurrentDimensions().scalarAdd(this.borderScaleFactor);
|
|
9666
9654
|
}
|
|
@@ -11405,9 +11393,22 @@ _defineProperty(Group, "type", 'Group');
|
|
|
11405
11393
|
_defineProperty(Group, "ownDefaults", groupDefaultValues);
|
|
11406
11394
|
classRegistry.setClass(Group);
|
|
11407
11395
|
|
|
11396
|
+
/**
|
|
11397
|
+
* Used by Canvas to manage selection.
|
|
11398
|
+
* Canvas accepts an `activeSelection` option allowing overriding and customization.
|
|
11399
|
+
*
|
|
11400
|
+
* @example
|
|
11401
|
+
* class MyActiveSelection extends ActiveSelection {
|
|
11402
|
+
* ...
|
|
11403
|
+
* }
|
|
11404
|
+
*
|
|
11405
|
+
* const canvas = new Canvas(el, {
|
|
11406
|
+
* activeSelection: new MyActiveSelection()
|
|
11407
|
+
* })
|
|
11408
|
+
*/
|
|
11408
11409
|
class ActiveSelection extends Group {
|
|
11409
|
-
constructor(
|
|
11410
|
-
super(
|
|
11410
|
+
constructor() {
|
|
11411
|
+
super(...arguments);
|
|
11411
11412
|
/**
|
|
11412
11413
|
* controls how selected objects are added during a multiselection event
|
|
11413
11414
|
* - `canvas-stacking` adds the selected object to the active selection while respecting canvas object stacking order
|
|
@@ -11417,9 +11418,7 @@ class ActiveSelection extends Group {
|
|
|
11417
11418
|
*/
|
|
11418
11419
|
// TODO FIX THIS WITH THE DEFAULTS LOGIC
|
|
11419
11420
|
_defineProperty(this, "multiSelectionStacking", 'canvas-stacking');
|
|
11420
|
-
this.setCoords();
|
|
11421
11421
|
}
|
|
11422
|
-
|
|
11423
11422
|
/**
|
|
11424
11423
|
* @private
|
|
11425
11424
|
*/
|
|
@@ -11524,6 +11523,24 @@ class ActiveSelection extends Group {
|
|
|
11524
11523
|
this.removeAll();
|
|
11525
11524
|
return false;
|
|
11526
11525
|
}
|
|
11526
|
+
_applyLayoutStrategy(context) {
|
|
11527
|
+
super._applyLayoutStrategy(context);
|
|
11528
|
+
if (this._objects.length === 0) {
|
|
11529
|
+
// in this case layout was skipped
|
|
11530
|
+
// we reset transform for the next selection
|
|
11531
|
+
Object.assign(this, {
|
|
11532
|
+
left: 0,
|
|
11533
|
+
top: 0,
|
|
11534
|
+
angle: 0,
|
|
11535
|
+
scaleX: 1,
|
|
11536
|
+
scaleY: 1,
|
|
11537
|
+
skewX: 0,
|
|
11538
|
+
skewY: 0,
|
|
11539
|
+
flipX: false,
|
|
11540
|
+
flipY: false
|
|
11541
|
+
});
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11527
11544
|
|
|
11528
11545
|
/**
|
|
11529
11546
|
* Returns string representation of a group
|
|
@@ -13576,6 +13593,7 @@ class SelectableCanvas extends StaticCanvas$1 {
|
|
|
13576
13593
|
_defineProperty(this, "_activeSelection", void 0);
|
|
13577
13594
|
this._activeSelection = activeSelection;
|
|
13578
13595
|
this._activeSelection.set('canvas', this);
|
|
13596
|
+
this._activeSelection.setCoords();
|
|
13579
13597
|
}
|
|
13580
13598
|
initElements(el) {
|
|
13581
13599
|
this.elements = new CanvasDOMManager(el, {
|
|
@@ -14020,7 +14038,7 @@ class SelectableCanvas extends StaticCanvas$1 {
|
|
|
14020
14038
|
|
|
14021
14039
|
/**
|
|
14022
14040
|
* Function used to search inside objects an object that contains pointer in bounding box or that contains pointerOnCanvas when painted
|
|
14023
|
-
* @see {@link
|
|
14041
|
+
* @see {@link _searchPossibleTargets}
|
|
14024
14042
|
* @param {FabricObject[]} [objects] objects array to look into
|
|
14025
14043
|
* @param {Object} [pointer] x,y object of point coordinates we want to check.
|
|
14026
14044
|
* @return {FabricObject} **top most object on screen** that contains pointer
|
|
@@ -14051,9 +14069,9 @@ class SelectableCanvas extends StaticCanvas$1 {
|
|
|
14051
14069
|
* by the viewportTransform ( sort of coordinates of what is displayed
|
|
14052
14070
|
* on the canvas where you are clicking.
|
|
14053
14071
|
* ignoreVpt true = HTMLElement coordinates relative to top,left
|
|
14054
|
-
* ignoreVpt false, default = fabric space coordinates, the same used for shape position
|
|
14055
|
-
* To interact with your shapes top and left you want to use ignoreVpt
|
|
14056
|
-
* most of the time, while ignoreVpt
|
|
14072
|
+
* ignoreVpt false, default = fabric space coordinates, the same used for shape position.
|
|
14073
|
+
* To interact with your shapes top and left you want to use ignoreVpt false
|
|
14074
|
+
* most of the time, while ignoreVpt true will give you coordinates
|
|
14057
14075
|
* compatible with the object.oCoords system.
|
|
14058
14076
|
* of the time.
|
|
14059
14077
|
* @param {Event} e
|
|
@@ -14640,8 +14658,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
14640
14658
|
const shared = {
|
|
14641
14659
|
e,
|
|
14642
14660
|
isClick: false,
|
|
14643
|
-
pointer: this.getPointer(e),
|
|
14644
|
-
absolutePointer: this.getPointer(e
|
|
14661
|
+
pointer: this.getPointer(e, true),
|
|
14662
|
+
absolutePointer: this.getPointer(e)
|
|
14645
14663
|
};
|
|
14646
14664
|
this.fire('mouse:out', _objectSpread2(_objectSpread2({}, shared), {}, {
|
|
14647
14665
|
target
|
|
@@ -14672,8 +14690,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
14672
14690
|
this.fire('mouse:over', {
|
|
14673
14691
|
e,
|
|
14674
14692
|
isClick: false,
|
|
14675
|
-
pointer: this.getPointer(e),
|
|
14676
|
-
absolutePointer: this.getPointer(e
|
|
14693
|
+
pointer: this.getPointer(e, true),
|
|
14694
|
+
absolutePointer: this.getPointer(e)
|
|
14677
14695
|
});
|
|
14678
14696
|
this._hoveredTarget = undefined;
|
|
14679
14697
|
this._hoveredTargets = [];
|
|
@@ -14905,7 +14923,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
14905
14923
|
target,
|
|
14906
14924
|
subTargets: targets,
|
|
14907
14925
|
dragSource: this._dragSource,
|
|
14908
|
-
pointer: this.getPointer(e)
|
|
14926
|
+
pointer: this.getPointer(e, true),
|
|
14927
|
+
absolutePointer: this.getPointer(e)
|
|
14909
14928
|
});
|
|
14910
14929
|
// will be set by the drop target
|
|
14911
14930
|
options.didDrop = false;
|
|
@@ -15222,8 +15241,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15222
15241
|
subTargets: targets,
|
|
15223
15242
|
button,
|
|
15224
15243
|
isClick,
|
|
15225
|
-
pointer: this.getPointer(e),
|
|
15226
|
-
absolutePointer: this.getPointer(e
|
|
15244
|
+
pointer: this.getPointer(e, true),
|
|
15245
|
+
absolutePointer: this.getPointer(e),
|
|
15227
15246
|
transform: this._currentTransform
|
|
15228
15247
|
};
|
|
15229
15248
|
if (eventType === 'up') {
|
|
@@ -15287,6 +15306,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15287
15306
|
this.discardActiveObject(e);
|
|
15288
15307
|
this.requestRenderAll();
|
|
15289
15308
|
}
|
|
15309
|
+
// this is an absolute pointer, the naming is wrong
|
|
15290
15310
|
const pointer = this.getPointer(e);
|
|
15291
15311
|
this.freeDrawingBrush && this.freeDrawingBrush.onMouseDown(pointer, {
|
|
15292
15312
|
e,
|
|
@@ -15304,6 +15324,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15304
15324
|
const pointer = this.getPointer(e);
|
|
15305
15325
|
this.freeDrawingBrush && this.freeDrawingBrush.onMouseMove(pointer, {
|
|
15306
15326
|
e,
|
|
15327
|
+
// this is an absolute pointer, the naming is wrong
|
|
15307
15328
|
pointer
|
|
15308
15329
|
});
|
|
15309
15330
|
}
|
|
@@ -15320,6 +15341,7 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15320
15341
|
if (this.freeDrawingBrush) {
|
|
15321
15342
|
this._isCurrentlyDrawing = !!this.freeDrawingBrush.onMouseUp({
|
|
15322
15343
|
e: e,
|
|
15344
|
+
// this is an absolute pointer, the naming is wrong
|
|
15323
15345
|
pointer: pointer
|
|
15324
15346
|
});
|
|
15325
15347
|
} else {
|
|
@@ -15575,8 +15597,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15575
15597
|
target: oldTarget,
|
|
15576
15598
|
nextTarget: target,
|
|
15577
15599
|
isClick: false,
|
|
15578
|
-
pointer: this.getPointer(e),
|
|
15579
|
-
absolutePointer: this.getPointer(e
|
|
15600
|
+
pointer: this.getPointer(e, true),
|
|
15601
|
+
absolutePointer: this.getPointer(e)
|
|
15580
15602
|
});
|
|
15581
15603
|
fireCanvas && this.fire(canvasIn, outOpt);
|
|
15582
15604
|
oldTarget.fire(targetOut, outOpt);
|
|
@@ -15587,8 +15609,8 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15587
15609
|
target,
|
|
15588
15610
|
previousTarget: oldTarget,
|
|
15589
15611
|
isClick: false,
|
|
15590
|
-
pointer: this.getPointer(e),
|
|
15591
|
-
absolutePointer: this.getPointer(e
|
|
15612
|
+
pointer: this.getPointer(e, true),
|
|
15613
|
+
absolutePointer: this.getPointer(e)
|
|
15592
15614
|
});
|
|
15593
15615
|
fireCanvas && this.fire(canvasOut, inOpt);
|
|
15594
15616
|
target.fire(targetIn, inOpt);
|
|
@@ -15716,8 +15738,13 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15716
15738
|
if (isAS) {
|
|
15717
15739
|
const prevActiveObjects = activeSelection.getObjects();
|
|
15718
15740
|
if (target === activeSelection) {
|
|
15719
|
-
|
|
15720
|
-
target =
|
|
15741
|
+
const pointer = this.getPointer(e, true);
|
|
15742
|
+
target =
|
|
15743
|
+
// first search active objects for a target to remove
|
|
15744
|
+
this.searchPossibleTargets(prevActiveObjects, pointer) ||
|
|
15745
|
+
// if not found, search under active selection for a target to add
|
|
15746
|
+
// `prevActiveObjects` will be searched but we already know they will not be found
|
|
15747
|
+
this.searchPossibleTargets(this._objects, pointer);
|
|
15721
15748
|
// if nothing is found bail out
|
|
15722
15749
|
if (!target || !target.selectable) {
|
|
15723
15750
|
return false;
|
|
@@ -19114,10 +19141,10 @@ class Text extends StyledText {
|
|
|
19114
19141
|
/**
|
|
19115
19142
|
* Detect if a line has a linebreak and so we need to account for it when moving
|
|
19116
19143
|
* and counting style.
|
|
19117
|
-
* It return always for text and Itext.
|
|
19144
|
+
* It return always 1 for text and Itext. Textbox has its own implementation
|
|
19118
19145
|
* @return Number
|
|
19119
19146
|
*/
|
|
19120
|
-
|
|
19147
|
+
|
|
19121
19148
|
missingNewlineOffset(lineIndex) {
|
|
19122
19149
|
return 1;
|
|
19123
19150
|
}
|
|
@@ -19137,7 +19164,7 @@ class Text extends StyledText {
|
|
|
19137
19164
|
charIndex: selectionStart
|
|
19138
19165
|
};
|
|
19139
19166
|
}
|
|
19140
|
-
selectionStart -= lines[i].length + this.missingNewlineOffset(i);
|
|
19167
|
+
selectionStart -= lines[i].length + this.missingNewlineOffset(i, skipWrapping);
|
|
19141
19168
|
}
|
|
19142
19169
|
return {
|
|
19143
19170
|
lineIndex: i - 1,
|
|
@@ -20601,8 +20628,7 @@ class DraggableTextDelegate {
|
|
|
20601
20628
|
* - `!` Matches a "!" character (char code 33).
|
|
20602
20629
|
* - `\?` Matches a "?" character (char code 63).
|
|
20603
20630
|
* - `\-` Matches a "-" character (char code 45).
|
|
20604
|
-
*/
|
|
20605
|
-
// eslint-disable-next-line no-useless-escape
|
|
20631
|
+
*/ // eslint-disable-next-line no-useless-escape
|
|
20606
20632
|
const reNonWord = /[ \n\.,;!\?\-]/;
|
|
20607
20633
|
class ITextBehavior extends Text {
|
|
20608
20634
|
constructor() {
|
|
@@ -20889,7 +20915,7 @@ class ITextBehavior extends Text {
|
|
|
20889
20915
|
}
|
|
20890
20916
|
|
|
20891
20917
|
/**
|
|
20892
|
-
* called by {@link
|
|
20918
|
+
* called by {@link Canvas#textEditingManager}
|
|
20893
20919
|
*/
|
|
20894
20920
|
updateSelectionOnMouseMove(e) {
|
|
20895
20921
|
if (this.getActiveControl()) {
|
|
@@ -23144,14 +23170,17 @@ class Textbox extends IText {
|
|
|
23144
23170
|
let offset = 0;
|
|
23145
23171
|
const wordsOrGraphemes = splitByGrapheme ? this.graphemeSplit(line) : this.wordSplit(line);
|
|
23146
23172
|
if (wordsOrGraphemes.length === 0) {
|
|
23147
|
-
return [
|
|
23173
|
+
return [{
|
|
23174
|
+
word: [],
|
|
23175
|
+
width: 0
|
|
23176
|
+
}];
|
|
23148
23177
|
}
|
|
23149
23178
|
return wordsOrGraphemes.map(word => {
|
|
23150
23179
|
// if using splitByGrapheme words are already in graphemes.
|
|
23151
23180
|
const graphemeArray = splitByGrapheme ? [word] : this.graphemeSplit(word);
|
|
23152
23181
|
const width = this._measureWord(graphemeArray, lineIndex, offset);
|
|
23153
23182
|
largestWordWidth = Math.max(width, largestWordWidth);
|
|
23154
|
-
offset +=
|
|
23183
|
+
offset += graphemeArray.length + infix.length;
|
|
23155
23184
|
return {
|
|
23156
23185
|
word: graphemeArray,
|
|
23157
23186
|
width
|
|
@@ -23287,10 +23316,12 @@ class Textbox extends IText {
|
|
|
23287
23316
|
/**
|
|
23288
23317
|
* Detect if a line has a linebreak and so we need to account for it when moving
|
|
23289
23318
|
* and counting style.
|
|
23319
|
+
* This is important only for splitByGrapheme at the end of wrapping.
|
|
23320
|
+
* If we are not wrapping the offset is always 1
|
|
23290
23321
|
* @return Number
|
|
23291
23322
|
*/
|
|
23292
|
-
missingNewlineOffset(lineIndex) {
|
|
23293
|
-
if (this.splitByGrapheme) {
|
|
23323
|
+
missingNewlineOffset(lineIndex, skipWrapping) {
|
|
23324
|
+
if (this.splitByGrapheme && !skipWrapping) {
|
|
23294
23325
|
return this.isEndOfWrapping(lineIndex) ? 1 : 0;
|
|
23295
23326
|
}
|
|
23296
23327
|
return 1;
|
|
@@ -25066,15 +25097,14 @@ const polyActionHandler = (eventData, transform, x, y) => {
|
|
|
25066
25097
|
const anchorWrapper = (pointIndex, fn) => {
|
|
25067
25098
|
return function (eventData, transform, x, y) {
|
|
25068
25099
|
const poly = transform.target,
|
|
25069
|
-
|
|
25070
|
-
|
|
25100
|
+
anchorPoint = new Point(poly.points[(pointIndex > 0 ? pointIndex : poly.points.length) - 1]),
|
|
25101
|
+
anchorPointInParentPlane = anchorPoint.subtract(poly.pathOffset).transform(poly.calcOwnMatrix()),
|
|
25071
25102
|
actionPerformed = fn(eventData, _objectSpread2(_objectSpread2({}, transform), {}, {
|
|
25072
25103
|
pointIndex
|
|
25073
25104
|
}), x, y),
|
|
25074
|
-
polygonBaseSize = getSize(poly),
|
|
25075
25105
|
adjustFlip = new Point(poly.flipX ? -1 : 1, poly.flipY ? -1 : 1);
|
|
25076
|
-
const
|
|
25077
|
-
poly.setPositionByOrigin(
|
|
25106
|
+
const newPositionNormalized = anchorPoint.subtract(poly.pathOffset).divide(poly._getNonTransformedDimensions()).multiply(adjustFlip);
|
|
25107
|
+
poly.setPositionByOrigin(anchorPointInParentPlane, newPositionNormalized.x + 0.5, newPositionNormalized.y + 0.5);
|
|
25078
25108
|
return actionPerformed;
|
|
25079
25109
|
};
|
|
25080
25110
|
};
|