@logicflow/extension 2.1.3 → 2.1.5

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.
@@ -35,6 +35,14 @@ export type ToImageOptions = {
35
35
  * - `true`:只导出画面区域内的可见元素
36
36
  */
37
37
  partial?: boolean
38
+ /**
39
+ * 导出图片时的安全系数,用于确保导出的图片能够容纳所有元素,默认值为 1.1
40
+ */
41
+ safetyFactor?: number
42
+ /**
43
+ * 导出图片时的安全边距,用于确保导出的图片能够容纳所有元素,默认值为 40
44
+ */
45
+ safetyMargin?: number
38
46
  }
39
47
 
40
48
  // Blob | base64
@@ -381,7 +389,7 @@ export class Snapshot {
381
389
  // 计算实际宽高,考虑缩放因素
382
390
  // 在宽画布情况下,getBoundingClientRect可能无法获取到所有元素的边界
383
391
  // 因此我们添加一个安全系数来确保能够容纳所有元素
384
- const safetyFactor = 1.1 // 安全系数,增加20%的空间
392
+ const safetyFactor = toImageOptions.safetyFactor || 1.1 // 安全系数,增加10%的空间
385
393
  const actualWidth = (bbox.width / SCALE_X) * safetyFactor
386
394
  const actualHeight = (bbox.height / SCALE_Y) * safetyFactor
387
395
 
@@ -394,7 +402,7 @@ export class Snapshot {
394
402
 
395
403
  // 宽高值 默认加padding 40,保证图形不会紧贴着下载图片
396
404
  // 为宽画布添加额外的安全边距,确保不会裁剪
397
- const safetyMargin = 40 // 额外的安全边距
405
+ const safetyMargin = toImageOptions.safetyMargin || 40 // 额外的安全边距
398
406
 
399
407
  // 获取当前浏览器类型,不同浏览器对canvas的限制不同
400
408
  const { maxCanvasDimension, otherMaxCanvasDimension } =