fabric-vectr 6.7.14 → 6.7.16
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/dist/index.js +90 -12
- 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 +90 -12
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +90 -12
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +90 -12
- 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/canvas/Canvas.d.ts +10 -0
- package/dist/src/canvas/Canvas.d.ts.map +1 -1
- package/dist/src/canvas/Canvas.min.mjs +1 -1
- package/dist/src/canvas/Canvas.min.mjs.map +1 -1
- package/dist/src/canvas/Canvas.mjs +85 -10
- package/dist/src/canvas/Canvas.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.d.ts +6 -0
- package/dist/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist/src/canvas/SelectableCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/SelectableCanvas.mjs.map +1 -1
- package/dist/src/shapes/Textbox.d.ts.map +1 -1
- package/dist/src/shapes/Textbox.min.mjs +1 -1
- package/dist/src/shapes/Textbox.min.mjs.map +1 -1
- package/dist/src/shapes/Textbox.mjs +4 -1
- package/dist/src/shapes/Textbox.mjs.map +1 -1
- package/dist-extensions/src/canvas/Canvas.d.ts +10 -0
- package/dist-extensions/src/canvas/Canvas.d.ts.map +1 -1
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts +6 -0
- package/dist-extensions/src/canvas/SelectableCanvas.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Textbox.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/canvas/Canvas.ts +89 -8
- package/src/canvas/SelectableCanvas.ts +6 -0
- package/src/canvas/__tests__/additiveSelection.test.ts +118 -0
- package/src/shapes/Textbox.ts +4 -1
package/dist/index.node.cjs
CHANGED
|
@@ -418,7 +418,7 @@ class Cache {
|
|
|
418
418
|
}
|
|
419
419
|
const cache = new Cache();
|
|
420
420
|
|
|
421
|
-
var version = "6.7.
|
|
421
|
+
var version = "6.7.16";
|
|
422
422
|
|
|
423
423
|
// use this syntax so babel plugin see this import here
|
|
424
424
|
const VERSION = version;
|
|
@@ -15872,11 +15872,16 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15872
15872
|
shouldRender = true;
|
|
15873
15873
|
} else if (this._shouldClearSelection(e, target)) {
|
|
15874
15874
|
const objs = this.getActiveObjects();
|
|
15875
|
-
|
|
15876
|
-
//
|
|
15877
|
-
objs.
|
|
15878
|
-
if (!
|
|
15879
|
-
|
|
15875
|
+
// holding the selection key keeps the current selection alive so that the
|
|
15876
|
+
// following box selection (or click) can add to it instead of replacing it
|
|
15877
|
+
const additive = !!objs.length && !!this.selection && this._isSelectionKeyPressed(e);
|
|
15878
|
+
if (!additive) {
|
|
15879
|
+
this.discardActiveObject(e);
|
|
15880
|
+
// 多选取消,重置Coords, 防止无法再次选中
|
|
15881
|
+
objs.forEach(obj => obj.setCoords());
|
|
15882
|
+
if (!target && this.switchIsolateObject(e)) {
|
|
15883
|
+
return;
|
|
15884
|
+
}
|
|
15880
15885
|
}
|
|
15881
15886
|
}
|
|
15882
15887
|
// we start a group selector rectangle if
|
|
@@ -15891,7 +15896,12 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
15891
15896
|
x: p.x,
|
|
15892
15897
|
y: p.y,
|
|
15893
15898
|
deltaY: 0,
|
|
15894
|
-
deltaX: 0
|
|
15899
|
+
deltaX: 0,
|
|
15900
|
+
// capture the modifier now: releasing the key during the drag
|
|
15901
|
+
// must not turn an additive selection into a replacing one
|
|
15902
|
+
...(this._isSelectionKeyPressed(e) ? {
|
|
15903
|
+
additive: true
|
|
15904
|
+
} : {})
|
|
15895
15905
|
};
|
|
15896
15906
|
}
|
|
15897
15907
|
|
|
@@ -16274,13 +16284,17 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
16274
16284
|
x,
|
|
16275
16285
|
y,
|
|
16276
16286
|
deltaX,
|
|
16277
|
-
deltaY
|
|
16287
|
+
deltaY,
|
|
16288
|
+
additive
|
|
16278
16289
|
} = this._groupSelector,
|
|
16279
16290
|
point1 = new Point(x, y),
|
|
16280
16291
|
point2 = point1.add(new Point(deltaX, deltaY)),
|
|
16281
16292
|
tl = point1.min(point2),
|
|
16282
16293
|
br = point1.max(point2),
|
|
16283
16294
|
size = br.subtract(tl);
|
|
16295
|
+
|
|
16296
|
+
// the box only collects the first level objects of the current selection scope,
|
|
16297
|
+
// meaning the children of the isolated group, or the canvas root objects
|
|
16284
16298
|
const collectedObjects = this.collectObjects(this.getSearchTargets(), {
|
|
16285
16299
|
left: tl.x,
|
|
16286
16300
|
top: tl.y,
|
|
@@ -16289,6 +16303,16 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
16289
16303
|
}, {
|
|
16290
16304
|
includeIntersecting: !this.selectionFullyContained
|
|
16291
16305
|
});
|
|
16306
|
+
|
|
16307
|
+
// cleanup
|
|
16308
|
+
this._groupSelector = null;
|
|
16309
|
+
|
|
16310
|
+
// the selection key was held while dragging and there is something to add to:
|
|
16311
|
+
// keep the current selection and merge the collected objects into it
|
|
16312
|
+
if (additive && this.getActiveObjects().length) {
|
|
16313
|
+
this.addToActiveSelection(e, collectedObjects);
|
|
16314
|
+
return true;
|
|
16315
|
+
}
|
|
16292
16316
|
const objects =
|
|
16293
16317
|
// though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down
|
|
16294
16318
|
// should it be handled as is?
|
|
@@ -16309,12 +16333,63 @@ let Canvas$1 = class Canvas extends SelectableCanvas {
|
|
|
16309
16333
|
canvas: this
|
|
16310
16334
|
}), e);
|
|
16311
16335
|
}
|
|
16312
|
-
|
|
16313
|
-
// cleanup
|
|
16314
|
-
this._groupSelector = null;
|
|
16315
16336
|
return true;
|
|
16316
16337
|
}
|
|
16317
16338
|
|
|
16339
|
+
/**
|
|
16340
|
+
* Merges the objects collected by a box selection into the current selection.
|
|
16341
|
+
* Only objects belonging to the current selection scope are taken into account:
|
|
16342
|
+
* the first level children of the isolated group, or the canvas root objects
|
|
16343
|
+
* when no group is isolated. Previously selected objects outside of that scope
|
|
16344
|
+
* are removed from the selection, since a selection can't mix objects coming
|
|
16345
|
+
* from different containers.
|
|
16346
|
+
* @private
|
|
16347
|
+
*/
|
|
16348
|
+
addToActiveSelection(e, collectedObjects) {
|
|
16349
|
+
const prevActiveObjects = this.getActiveObjects(),
|
|
16350
|
+
scope = this.getSearchTargets(),
|
|
16351
|
+
kept = prevActiveObjects.filter(object => scope.includes(object)),
|
|
16352
|
+
dropped = prevActiveObjects.filter(object => !scope.includes(object)),
|
|
16353
|
+
added = collectedObjects.filter(object => !prevActiveObjects.includes(object) && !object.onSelect({
|
|
16354
|
+
e
|
|
16355
|
+
}));
|
|
16356
|
+
if (!kept.length && !added.length) {
|
|
16357
|
+
// the box didn't add anything and nothing of the current selection
|
|
16358
|
+
// belongs to this scope
|
|
16359
|
+
dropped.length && this.discardActiveObject(e);
|
|
16360
|
+
return;
|
|
16361
|
+
}
|
|
16362
|
+
const activeObject = this._activeObject;
|
|
16363
|
+
if (isActiveSelection(activeObject)) {
|
|
16364
|
+
dropped.length && activeObject.remove(...dropped);
|
|
16365
|
+
added.length && activeObject.multiSelectAdd(...added);
|
|
16366
|
+
if (activeObject.size() === 1) {
|
|
16367
|
+
// deselecting the active selection returns the last remaining object to the canvas
|
|
16368
|
+
this._setActiveObject(activeObject.item(0), e);
|
|
16369
|
+
}
|
|
16370
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16371
|
+
return;
|
|
16372
|
+
}
|
|
16373
|
+
const objects = kept.concat(added);
|
|
16374
|
+
if (objects.length === 1) {
|
|
16375
|
+
objects[0] !== activeObject && this.setActiveObject(objects[0], e);
|
|
16376
|
+
return;
|
|
16377
|
+
}
|
|
16378
|
+
|
|
16379
|
+
// build the active selection out of the kept and the newly collected objects
|
|
16380
|
+
const klass = classRegistry.getClass('ActiveSelection');
|
|
16381
|
+
const newActiveSelection = new klass([], {
|
|
16382
|
+
/**
|
|
16383
|
+
* it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}
|
|
16384
|
+
* since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref
|
|
16385
|
+
*/
|
|
16386
|
+
canvas: this
|
|
16387
|
+
});
|
|
16388
|
+
newActiveSelection.multiSelectAdd(...objects);
|
|
16389
|
+
this._setActiveObject(newActiveSelection, e);
|
|
16390
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16391
|
+
}
|
|
16392
|
+
|
|
16318
16393
|
/**
|
|
16319
16394
|
* @override clear {@link textEditingManager}
|
|
16320
16395
|
*/
|
|
@@ -24516,7 +24591,10 @@ class Textbox extends IText {
|
|
|
24516
24591
|
}
|
|
24517
24592
|
|
|
24518
24593
|
// 处理文字的水平偏移
|
|
24519
|
-
|
|
24594
|
+
// 只有当 tspan 显式携带 x/dx 位置(minSpanX 非空)时,tspan 的 x 才是相对
|
|
24595
|
+
// <text> 原点的偏移量,需要换算成绝对坐标;否则 <text> 上的 x 本身就是绝对坐标,
|
|
24596
|
+
// 直接使用,避免把整个 left 减掉导致 X 轴整体偏移(GPT 等标准 SVG 常见)。
|
|
24597
|
+
spanOffX = minSpanX != null ? options.left - minSpanX : 0;
|
|
24520
24598
|
|
|
24521
24599
|
// textAlign保持和parsedAnchor一致
|
|
24522
24600
|
options.textAlign = parsedAnchor;
|