fabric-vectr 6.7.13 → 6.7.14

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.
Files changed (31) hide show
  1. package/dist/index.js +21 -14
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.min.js +1 -1
  4. package/dist/index.min.js.map +1 -1
  5. package/dist/index.min.mjs +1 -1
  6. package/dist/index.min.mjs.map +1 -1
  7. package/dist/index.mjs +21 -14
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/index.node.cjs +21 -14
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.mjs +21 -14
  12. package/dist/index.node.mjs.map +1 -1
  13. package/dist/package.json.min.mjs +1 -1
  14. package/dist/package.json.mjs +1 -1
  15. package/dist/src/canvas/StaticCanvas.d.ts.map +1 -1
  16. package/dist/src/canvas/StaticCanvas.min.mjs +1 -1
  17. package/dist/src/canvas/StaticCanvas.min.mjs.map +1 -1
  18. package/dist/src/canvas/StaticCanvas.mjs +15 -12
  19. package/dist/src/canvas/StaticCanvas.mjs.map +1 -1
  20. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
  21. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs +1 -1
  22. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.min.mjs.map +1 -1
  23. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs +5 -1
  24. package/dist/src/shapes/Object/FabricObjectSVGExportMixin.mjs.map +1 -1
  25. package/dist-extensions/src/canvas/StaticCanvas.d.ts.map +1 -1
  26. package/dist-extensions/src/shapes/Object/FabricObjectSVGExportMixin.d.ts.map +1 -1
  27. package/package.json +33 -33
  28. package/src/canvas/StaticCanvas.spec.ts +23 -0
  29. package/src/canvas/StaticCanvas.ts +19 -12
  30. package/src/shapes/Object/FabricObjectSVGExportMixin.ts +5 -1
  31. package/src/shapes/Text/TextSVGExportMixin.spec.ts +16 -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.13";
363
+ var version = "6.7.14";
364
364
 
365
365
  // use this syntax so babel plugin see this import here
366
366
  const VERSION = version;
@@ -3074,25 +3074,28 @@ class StaticCanvas extends createCollectionMixin(CommonMethods) {
3074
3074
  */
3075
3075
  _createPathForText() {
3076
3076
  const pathMarkups = [];
3077
- let instance,
3078
- i,
3079
- len,
3080
- objects = this._objects;
3081
- for (i = 0, len = objects.length; i < len; i++) {
3082
- instance = objects[i];
3077
+ const objects = [];
3078
+ this._objects.forEach(function add(object) {
3079
+ objects.push(object);
3080
+ if (isCollection(object)) {
3081
+ object._objects.forEach(add);
3082
+ }
3083
+ });
3084
+ objects.forEach(instance => {
3083
3085
  if (instance.excludeFromExport) {
3084
- continue;
3086
+ return;
3085
3087
  }
3086
3088
  if (!isTextObject(instance) || !instance.path) {
3087
- continue;
3089
+ return;
3088
3090
  }
3089
- let pathId = `TEXTPATH_${instance.id}`;
3090
- let pathMarkup = instance.path._toSVG();
3091
- let index = pathMarkup.indexOf('COMMON_PARTS');
3091
+ const pathId = `TEXTPATH_${instance.id}`;
3092
+ const pathMarkup = instance.path._toSVG();
3093
+ const index = pathMarkup.indexOf('COMMON_PARTS');
3094
+
3092
3095
  // 加上id, 和路径偏移
3093
3096
  pathMarkup[index] = ['id="' + pathId + '" ', 'transform="translate(' + -instance.path.pathOffset.x + ',' + -instance.path.pathOffset.y + ')" '].join('');
3094
3097
  pathMarkups.push(pathMarkup.join(''));
3095
- }
3098
+ });
3096
3099
  return pathMarkups.join('\n');
3097
3100
  }
3098
3101
  createSVGClipPathMarkup(options) {
@@ -5045,13 +5048,17 @@ class FabricObjectSVGExportMixin {
5045
5048
  commonPieces = [styleInfo, vectorEffect, noStyle ? '' : this.addPaintOrder(), ' ', additionalTransform ? `transform="${additionalTransform}" ` : ''].join('');
5046
5049
 
5047
5050
  // James added shadow 放在上面
5051
+ // 文本等调用方已经通过 withShadow 挂载 filter 时,避免再额外复制一份可见对象,
5052
+ // 但仍然需要输出 filter 定义,否则普通 SVG 会丢失阴影。
5048
5053
  if (shadow) {
5054
+ markup.push(shadow.toSVG(this));
5055
+ }
5056
+ if (shadow && !withShadow) {
5049
5057
  const styleInfoWithShadow = 'style="' + this.getSvgStyles(false) + '" ';
5050
5058
  const commonPiecesWithShadow = [styleInfoWithShadow, vectorEffect, noStyle ? '' : this.addPaintOrder(), ' ', additionalTransform ? 'transform="' + additionalTransform + '" ' : ''].join('');
5051
5059
  const objectMarkupCopy = JSON.parse(JSON.stringify(objectMarkup));
5052
5060
  objectMarkupCopy[index] = commonPiecesWithShadow;
5053
5061
  markup.push(objectMarkupCopy.join(''));
5054
- markup.push(shadow.toSVG(this));
5055
5062
  }
5056
5063
  // objectMarkup中是导出主对象(如path)的svg,index下标是style,放在commonPieces
5057
5064
  objectMarkup[index] = commonPieces;