fabric-vectr 6.7.13 → 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 +106 -24
- 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 +106 -24
- package/dist/index.mjs.map +1 -1
- package/dist/index.node.cjs +106 -24
- package/dist/index.node.cjs.map +1 -1
- package/dist/index.node.mjs +106 -24
- 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/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
- package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
- package/dist/src/canvas/StaticCanvas.mjs +15 -12
- package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +5 -1
- package/dist/src/shapes/Object/FabricObjectSVGExportMixin.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/canvas/StaticCanvas.d.ts.map +1 -1
- package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/canvas/Canvas.ts +89 -8
- package/src/canvas/SelectableCanvas.ts +6 -0
- package/src/canvas/StaticCanvas.spec.ts +23 -0
- package/src/canvas/StaticCanvas.ts +19 -12
- package/src/canvas/__tests__/additiveSelection.test.ts +118 -0
- package/src/shapes/Object/FabricObjectSVGExportMixin.ts +5 -1
- package/src/shapes/Text/TextSVGExportMixin.spec.ts +16 -0
package/dist/index.js
CHANGED
|
@@ -366,7 +366,7 @@
|
|
|
366
366
|
}
|
|
367
367
|
const cache = new Cache();
|
|
368
368
|
|
|
369
|
-
var version = "6.7.
|
|
369
|
+
var version = "6.7.15";
|
|
370
370
|
|
|
371
371
|
// use this syntax so babel plugin see this import here
|
|
372
372
|
const VERSION = version;
|
|
@@ -3080,25 +3080,28 @@
|
|
|
3080
3080
|
*/
|
|
3081
3081
|
_createPathForText() {
|
|
3082
3082
|
const pathMarkups = [];
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3083
|
+
const objects = [];
|
|
3084
|
+
this._objects.forEach(function add(object) {
|
|
3085
|
+
objects.push(object);
|
|
3086
|
+
if (isCollection(object)) {
|
|
3087
|
+
object._objects.forEach(add);
|
|
3088
|
+
}
|
|
3089
|
+
});
|
|
3090
|
+
objects.forEach(instance => {
|
|
3089
3091
|
if (instance.excludeFromExport) {
|
|
3090
|
-
|
|
3092
|
+
return;
|
|
3091
3093
|
}
|
|
3092
3094
|
if (!isTextObject(instance) || !instance.path) {
|
|
3093
|
-
|
|
3095
|
+
return;
|
|
3094
3096
|
}
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3097
|
+
const pathId = `TEXTPATH_${instance.id}`;
|
|
3098
|
+
const pathMarkup = instance.path._toSVG();
|
|
3099
|
+
const index = pathMarkup.indexOf('COMMON_PARTS');
|
|
3100
|
+
|
|
3098
3101
|
// 加上id, 和路径偏移
|
|
3099
3102
|
pathMarkup[index] = ['id="' + pathId + '" ', 'transform="translate(' + -instance.path.pathOffset.x + ',' + -instance.path.pathOffset.y + ')" '].join('');
|
|
3100
3103
|
pathMarkups.push(pathMarkup.join(''));
|
|
3101
|
-
}
|
|
3104
|
+
});
|
|
3102
3105
|
return pathMarkups.join('\n');
|
|
3103
3106
|
}
|
|
3104
3107
|
createSVGClipPathMarkup(options) {
|
|
@@ -5051,13 +5054,17 @@
|
|
|
5051
5054
|
commonPieces = [styleInfo, vectorEffect, noStyle ? '' : this.addPaintOrder(), ' ', additionalTransform ? `transform="${additionalTransform}" ` : ''].join('');
|
|
5052
5055
|
|
|
5053
5056
|
// James added shadow 放在上面
|
|
5057
|
+
// 文本等调用方已经通过 withShadow 挂载 filter 时,避免再额外复制一份可见对象,
|
|
5058
|
+
// 但仍然需要输出 filter 定义,否则普通 SVG 会丢失阴影。
|
|
5054
5059
|
if (shadow) {
|
|
5060
|
+
markup.push(shadow.toSVG(this));
|
|
5061
|
+
}
|
|
5062
|
+
if (shadow && !withShadow) {
|
|
5055
5063
|
const styleInfoWithShadow = 'style="' + this.getSvgStyles(false) + '" ';
|
|
5056
5064
|
const commonPiecesWithShadow = [styleInfoWithShadow, vectorEffect, noStyle ? '' : this.addPaintOrder(), ' ', additionalTransform ? 'transform="' + additionalTransform + '" ' : ''].join('');
|
|
5057
5065
|
const objectMarkupCopy = JSON.parse(JSON.stringify(objectMarkup));
|
|
5058
5066
|
objectMarkupCopy[index] = commonPiecesWithShadow;
|
|
5059
5067
|
markup.push(objectMarkupCopy.join(''));
|
|
5060
|
-
markup.push(shadow.toSVG(this));
|
|
5061
5068
|
}
|
|
5062
5069
|
// objectMarkup中是导出主对象(如path)的svg,index下标是style,放在commonPieces
|
|
5063
5070
|
objectMarkup[index] = commonPieces;
|
|
@@ -15813,11 +15820,16 @@
|
|
|
15813
15820
|
shouldRender = true;
|
|
15814
15821
|
} else if (this._shouldClearSelection(e, target)) {
|
|
15815
15822
|
const objs = this.getActiveObjects();
|
|
15816
|
-
|
|
15817
|
-
//
|
|
15818
|
-
objs.
|
|
15819
|
-
if (!
|
|
15820
|
-
|
|
15823
|
+
// holding the selection key keeps the current selection alive so that the
|
|
15824
|
+
// following box selection (or click) can add to it instead of replacing it
|
|
15825
|
+
const additive = !!objs.length && !!this.selection && this._isSelectionKeyPressed(e);
|
|
15826
|
+
if (!additive) {
|
|
15827
|
+
this.discardActiveObject(e);
|
|
15828
|
+
// 多选取消,重置Coords, 防止无法再次选中
|
|
15829
|
+
objs.forEach(obj => obj.setCoords());
|
|
15830
|
+
if (!target && this.switchIsolateObject(e)) {
|
|
15831
|
+
return;
|
|
15832
|
+
}
|
|
15821
15833
|
}
|
|
15822
15834
|
}
|
|
15823
15835
|
// we start a group selector rectangle if
|
|
@@ -15832,7 +15844,12 @@
|
|
|
15832
15844
|
x: p.x,
|
|
15833
15845
|
y: p.y,
|
|
15834
15846
|
deltaY: 0,
|
|
15835
|
-
deltaX: 0
|
|
15847
|
+
deltaX: 0,
|
|
15848
|
+
// capture the modifier now: releasing the key during the drag
|
|
15849
|
+
// must not turn an additive selection into a replacing one
|
|
15850
|
+
...(this._isSelectionKeyPressed(e) ? {
|
|
15851
|
+
additive: true
|
|
15852
|
+
} : {})
|
|
15836
15853
|
};
|
|
15837
15854
|
}
|
|
15838
15855
|
|
|
@@ -16215,13 +16232,17 @@
|
|
|
16215
16232
|
x,
|
|
16216
16233
|
y,
|
|
16217
16234
|
deltaX,
|
|
16218
|
-
deltaY
|
|
16235
|
+
deltaY,
|
|
16236
|
+
additive
|
|
16219
16237
|
} = this._groupSelector,
|
|
16220
16238
|
point1 = new Point(x, y),
|
|
16221
16239
|
point2 = point1.add(new Point(deltaX, deltaY)),
|
|
16222
16240
|
tl = point1.min(point2),
|
|
16223
16241
|
br = point1.max(point2),
|
|
16224
16242
|
size = br.subtract(tl);
|
|
16243
|
+
|
|
16244
|
+
// the box only collects the first level objects of the current selection scope,
|
|
16245
|
+
// meaning the children of the isolated group, or the canvas root objects
|
|
16225
16246
|
const collectedObjects = this.collectObjects(this.getSearchTargets(), {
|
|
16226
16247
|
left: tl.x,
|
|
16227
16248
|
top: tl.y,
|
|
@@ -16230,6 +16251,16 @@
|
|
|
16230
16251
|
}, {
|
|
16231
16252
|
includeIntersecting: !this.selectionFullyContained
|
|
16232
16253
|
});
|
|
16254
|
+
|
|
16255
|
+
// cleanup
|
|
16256
|
+
this._groupSelector = null;
|
|
16257
|
+
|
|
16258
|
+
// the selection key was held while dragging and there is something to add to:
|
|
16259
|
+
// keep the current selection and merge the collected objects into it
|
|
16260
|
+
if (additive && this.getActiveObjects().length) {
|
|
16261
|
+
this.addToActiveSelection(e, collectedObjects);
|
|
16262
|
+
return true;
|
|
16263
|
+
}
|
|
16233
16264
|
const objects =
|
|
16234
16265
|
// though this method runs only after mouse move the pointer could do a mouse up on the same position as mouse down
|
|
16235
16266
|
// should it be handled as is?
|
|
@@ -16250,12 +16281,63 @@
|
|
|
16250
16281
|
canvas: this
|
|
16251
16282
|
}), e);
|
|
16252
16283
|
}
|
|
16253
|
-
|
|
16254
|
-
// cleanup
|
|
16255
|
-
this._groupSelector = null;
|
|
16256
16284
|
return true;
|
|
16257
16285
|
}
|
|
16258
16286
|
|
|
16287
|
+
/**
|
|
16288
|
+
* Merges the objects collected by a box selection into the current selection.
|
|
16289
|
+
* Only objects belonging to the current selection scope are taken into account:
|
|
16290
|
+
* the first level children of the isolated group, or the canvas root objects
|
|
16291
|
+
* when no group is isolated. Previously selected objects outside of that scope
|
|
16292
|
+
* are removed from the selection, since a selection can't mix objects coming
|
|
16293
|
+
* from different containers.
|
|
16294
|
+
* @private
|
|
16295
|
+
*/
|
|
16296
|
+
addToActiveSelection(e, collectedObjects) {
|
|
16297
|
+
const prevActiveObjects = this.getActiveObjects(),
|
|
16298
|
+
scope = this.getSearchTargets(),
|
|
16299
|
+
kept = prevActiveObjects.filter(object => scope.includes(object)),
|
|
16300
|
+
dropped = prevActiveObjects.filter(object => !scope.includes(object)),
|
|
16301
|
+
added = collectedObjects.filter(object => !prevActiveObjects.includes(object) && !object.onSelect({
|
|
16302
|
+
e
|
|
16303
|
+
}));
|
|
16304
|
+
if (!kept.length && !added.length) {
|
|
16305
|
+
// the box didn't add anything and nothing of the current selection
|
|
16306
|
+
// belongs to this scope
|
|
16307
|
+
dropped.length && this.discardActiveObject(e);
|
|
16308
|
+
return;
|
|
16309
|
+
}
|
|
16310
|
+
const activeObject = this._activeObject;
|
|
16311
|
+
if (isActiveSelection(activeObject)) {
|
|
16312
|
+
dropped.length && activeObject.remove(...dropped);
|
|
16313
|
+
added.length && activeObject.multiSelectAdd(...added);
|
|
16314
|
+
if (activeObject.size() === 1) {
|
|
16315
|
+
// deselecting the active selection returns the last remaining object to the canvas
|
|
16316
|
+
this._setActiveObject(activeObject.item(0), e);
|
|
16317
|
+
}
|
|
16318
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16319
|
+
return;
|
|
16320
|
+
}
|
|
16321
|
+
const objects = kept.concat(added);
|
|
16322
|
+
if (objects.length === 1) {
|
|
16323
|
+
objects[0] !== activeObject && this.setActiveObject(objects[0], e);
|
|
16324
|
+
return;
|
|
16325
|
+
}
|
|
16326
|
+
|
|
16327
|
+
// build the active selection out of the kept and the newly collected objects
|
|
16328
|
+
const klass = classRegistry.getClass('ActiveSelection');
|
|
16329
|
+
const newActiveSelection = new klass([], {
|
|
16330
|
+
/**
|
|
16331
|
+
* it is crucial to pass the canvas ref before calling {@link ActiveSelection#multiSelectAdd}
|
|
16332
|
+
* since it uses {@link FabricObject#isInFrontOf} which relies on the canvas ref
|
|
16333
|
+
*/
|
|
16334
|
+
canvas: this
|
|
16335
|
+
});
|
|
16336
|
+
newActiveSelection.multiSelectAdd(...objects);
|
|
16337
|
+
this._setActiveObject(newActiveSelection, e);
|
|
16338
|
+
this._fireSelectionEvents(prevActiveObjects, e);
|
|
16339
|
+
}
|
|
16340
|
+
|
|
16259
16341
|
/**
|
|
16260
16342
|
* @override clear {@link textEditingManager}
|
|
16261
16343
|
*/
|