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