fabric-vectr 6.7.14 → 6.7.15
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 +86 -11
- 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 +86 -11
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +86 -11
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +86 -11
- 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-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/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/dist/index.mjs
CHANGED
|
@@ -360,7 +360,7 @@ class Cache {
|
|
|
360
360
|
}
|
|
361
361
|
const cache = new Cache();
|
|
362
362
|
|
|
363
|
-
var version = "6.7.
|
|
363
|
+
var version = "6.7.15";
|
|
364
364
|
|
|
365
365
|
// use this syntax so babel plugin see this import here
|
|
366
366
|
const VERSION = version;
|
|
@@ -15814,11 +15814,16 @@ class Canvas extends SelectableCanvas {
|
|
|
15814
15814
|
shouldRender = true;
|
|
15815
15815
|
} else if (this._shouldClearSelection(e, target)) {
|
|
15816
15816
|
const objs = this.getActiveObjects();
|
|
15817
|
-
|
|
15818
|
-
//
|
|
15819
|
-
objs.
|
|
15820
|
-
if (!
|
|
15821
|
-
|
|
15817
|
+
// holding the selection key keeps the current selection alive so that the
|
|
15818
|
+
// following box selection (or click) can add to it instead of replacing it
|
|
15819
|
+
const additive = !!objs.length && !!this.selection && this._isSelectionKeyPressed(e);
|
|
15820
|
+
if (!additive) {
|
|
15821
|
+
this.discardActiveObject(e);
|
|
15822
|
+
// 多选取消,重置Coords, 防止无法再次选中
|
|
15823
|
+
objs.forEach(obj => obj.setCoords());
|
|
15824
|
+
if (!target && this.switchIsolateObject(e)) {
|
|
15825
|
+
return;
|
|
15826
|
+
}
|
|
15822
15827
|
}
|
|
15823
15828
|
}
|
|
15824
15829
|
// we start a group selector rectangle if
|
|
@@ -15833,7 +15838,12 @@ class Canvas extends SelectableCanvas {
|
|
|
15833
15838
|
x: p.x,
|
|
15834
15839
|
y: p.y,
|
|
15835
15840
|
deltaY: 0,
|
|
15836
|
-
deltaX: 0
|
|
15841
|
+
deltaX: 0,
|
|
15842
|
+
// capture the modifier now: releasing the key during the drag
|
|
15843
|
+
// must not turn an additive selection into a replacing one
|
|
15844
|
+
...(this._isSelectionKeyPressed(e) ? {
|
|
15845
|
+
additive: true
|
|
15846
|
+
} : {})
|
|
15837
15847
|
};
|
|
15838
15848
|
}
|
|
15839
15849
|
|
|
@@ -16216,13 +16226,17 @@ class Canvas extends SelectableCanvas {
|
|
|
16216
16226
|
x,
|
|
16217
16227
|
y,
|
|
16218
16228
|
deltaX,
|
|
16219
|
-
deltaY
|
|
16229
|
+
deltaY,
|
|
16230
|
+
additive
|
|
16220
16231
|
} = this._groupSelector,
|
|
16221
16232
|
point1 = new Point(x, y),
|
|
16222
16233
|
point2 = point1.add(new Point(deltaX, deltaY)),
|
|
16223
16234
|
tl = point1.min(point2),
|
|
16224
16235
|
br = point1.max(point2),
|
|
16225
16236
|
size = br.subtract(tl);
|
|
16237
|
+
|
|
16238
|
+
// the box only collects the first level objects of the current selection scope,
|
|
16239
|
+
// meaning the children of the isolated group, or the canvas root objects
|
|
16226
16240
|
const collectedObjects = this.collectObjects(this.getSearchTargets(), {
|
|
16227
16241
|
left: tl.x,
|
|
16228
16242
|
top: tl.y,
|
|
@@ -16231,6 +16245,16 @@ class Canvas extends SelectableCanvas {
|
|
|
16231
16245
|
}, {
|
|
16232
16246
|
includeIntersecting: !this.selectionFullyContained
|
|
16233
16247
|
});
|
|
16248
|
+
|
|
16249
|
+
// cleanup
|
|
16250
|
+
this._groupSelector = null;
|
|
16251
|
+
|
|
16252
|
+
// the selection key was held while dragging and there is something to add to:
|
|
16253
|
+
// keep the current selection and merge the collected objects into it
|
|
16254
|
+
if (additive && this.getActiveObjects().length) {
|
|
16255
|
+
this.addToActiveSelection(e, collectedObjects);
|
|
16256
|
+
return true;
|
|
16257
|
+
}
|
|
16234
16258
|
const objects =
|
|
16235
16259
|
// though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down
|
|
16236
16260
|
// should it be handled as is?
|
|
@@ -16251,12 +16275,63 @@ class Canvas extends SelectableCanvas {
|
|
|
16251
16275
|
canvas: this
|
|
16252
16276
|
}), e);
|
|
16253
16277
|
}
|
|
16254
|
-
|
|
16255
|
-
// cleanup
|
|
16256
|
-
this._groupSelector = null;
|
|
16257
16278
|
return true;
|
|
16258
16279
|
}
|
|
16259
16280
|
|
|
16281
|
+
/**
|
|
16282
|
+
* Merges the objects collected by a box selection into the current selection.
|
|
16283
|
+
* Only objects belonging to the current selection scope are taken into account:
|
|
16284
|
+
* the first level children of the isolated group, or the canvas root objects
|
|
16285
|
+
* when no group is isolated. Previously selected objects outside of that scope
|
|
16286
|
+
* are removed from the selection, since a selection can't mix objects coming
|
|
16287
|
+
* from different containers.
|
|
16288
|
+
* @private
|
|
16289
|
+
*/
|
|
16290
|
+
addToActiveSelection(e, collectedObjects) {
|
|
16291
|
+
const prevActiveObjects = this.getActiveObjects(),
|
|
16292
|
+
scope = this.getSearchTargets(),
|
|
16293
|
+
kept = prevActiveObjects.filter(object => scope.includes(object)),
|
|
16294
|
+
dropped = prevActiveObjects.filter(object => !scope.includes(object)),
|
|
16295
|
+
added = collectedObjects.filter(object => !prevActiveObjects.includes(object) && !object.onSelect({
|
|
16296
|
+
e
|
|
16297
|
+
}));
|
|
16298
|
+
if (!kept.length && !added.length) {
|
|
16299
|
+
// the box didn't add anything and nothing of the current selection
|
|
16300
|
+
// belongs to this scope
|
|
16301
|
+
dropped.length && this.discardActiveObject(e);
|
|
16302
|
+
return;
|
|
16303
|
+
}
|
|
16304
|
+
const activeObject = this._activeObject;
|
|
16305
|
+
if (isActiveSelection(activeObject)) {
|
|
16306
|
+
dropped.length && activeObject.remove(...dropped);
|
|
16307
|
+
added.length && activeObject.multiSelectAdd(...added);
|
|
16308
|
+
if (activeObject.size() === 1) {
|
|
16309
|
+
// deselecting the active selection returns the last remaining object to the canvas
|
|
16310
|
+
this._setActiveObject(activeObject.item(0), e);
|
|
16311
|
+
}
|
|
16312
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16313
|
+
return;
|
|
16314
|
+
}
|
|
16315
|
+
const objects = kept.concat(added);
|
|
16316
|
+
if (objects.length === 1) {
|
|
16317
|
+
objects[0] !== activeObject && this.setActiveObject(objects[0], e);
|
|
16318
|
+
return;
|
|
16319
|
+
}
|
|
16320
|
+
|
|
16321
|
+
// build the active selection out of the kept and the newly collected objects
|
|
16322
|
+
const klass = classRegistry.getClass('ActiveSelection');
|
|
16323
|
+
const newActiveSelection = new klass([], {
|
|
16324
|
+
/**
|
|
16325
|
+
* it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}
|
|
16326
|
+
* since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref
|
|
16327
|
+
*/
|
|
16328
|
+
canvas: this
|
|
16329
|
+
});
|
|
16330
|
+
newActiveSelection.multiSelectAdd(...objects);
|
|
16331
|
+
this._setActiveObject(newActiveSelection, e);
|
|
16332
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16333
|
+
}
|
|
16334
|
+
|
|
16260
16335
|
/**
|
|
16261
16336
|
* @override clear {@link textEditingManager}
|
|
16262
16337
|
*/
|