{"version":3,"file":"TextSVGExportMixin.min.mjs","sources":["../../../../src/shapes/Text/TextSVGExportMixin.ts"],"sourcesContent":["import { config } from '../../config';\nimport type { TSVGReviver } from '../../typedefs';\nimport { escapeXml } from '../../util/lang_string';\nimport { colorPropToSVG, createSVGRect } from '../../util/misc/svgParsing';\nimport { hasStyleChanged } from '../../util/misc/textStyles';\nimport { toFixed } from '../../util/misc/toFixed';\nimport { FabricObjectSVGExportMixin } from '../Object/FabricObjectSVGExportMixin';\nimport { type TextStyleDeclaration } from './StyledText';\nimport { JUSTIFY } from '../Text/constants';\nimport type { FabricText, GraphemeBBox } from './Text';\nimport { STROKE, FILL } from '../../constants';\nimport { Path } from '../Path';\nimport { createRotateMatrix } from '../../util/misc/matrix';\nimport { radiansToDegrees } from '../../util/misc/radiansDegreesConversion';\nimport { Point } from '../../Point';\nimport { matrixToSVG } from '../../util/misc/svgExport';\n\nconst multipleSpacesRegex = /  +/g;\nconst dblQuoteRegex = /\"/g;\n\nfunction createSVGInlineRect(\n  color: string,\n  left: number,\n  top: number,\n  width: number,\n  height: number,\n) {\n  return `\\t\\t${createSVGRect(color, { left, top, width, height })}\\n`;\n}\n\nexport class TextSVGExportMixin extends FabricObjectSVGExportMixin {\n  _toSVG(this: TextSVGExportMixin & FabricText): string[] {\n    const offsets = this._getSVGLeftTopOffsets();\n    let textAndBg;\n    if (this.path) {\n      // James added\n      textAndBg = this._getTextPath();\n    } else {\n      textAndBg = this._getSVGTextAndBg(offsets.textTop, offsets.textLeft);\n    }\n    return this._wrapSVGTextAndBg(textAndBg);\n  }\n\n  toSVG(this: TextSVGExportMixin & FabricText, reviver?: TSVGReviver): string {\n    const textSvg = this._createBaseSVGMarkup(this._toSVG(), {\n        reviver,\n        noStyle: true,\n        withShadow: true,\n      }),\n      path = this.path;\n    if (path) {\n      return (\n        textSvg +\n        path._createBaseSVGMarkup(path._toSVG(), {\n          reviver,\n          withShadow: true,\n          additionalTransform: matrixToSVG(this.calcOwnMatrix()),\n        })\n      );\n    }\n    return textSvg;\n  }\n\n  /**\n   * James added\n   * @param this\n   * @returns\n   */\n  private _getTextPath(\n    this: TextSVGExportMixin & FabricText & { id?: string },\n  ) {\n    const textSpans: string[] = [];\n    const textBgRects: string[] = [];\n    const content = this._textLines.map((v) => v.join('')).join('');\n\n    let visibleContent = '';\n    // 隐藏状态的文字 __charBounds 为空\n    if (this.__charBounds.length) {\n      Array.from(content).forEach((c, i) => {\n        const charBox = this.__charBounds[0][i];\n        if (!charBox || !charBox.visible) return;\n        visibleContent += c;\n      });\n    }\n\n    const align: string[] = [];\n    const alignMap: { [key: string]: { anchor: string; offset: string } } = {\n      center: { anchor: 'middle', offset: '50%' },\n      right: { anchor: 'end', offset: '100%' },\n    };\n    if (this.textAlign === 'center' || this.textAlign === 'right') {\n      align.push(\n        `text-anchor=\"${alignMap[this.textAlign].anchor}\" `,\n        `startOffset=\"${alignMap[this.textAlign].offset}\" `,\n      );\n    }\n\n    const pathId = `TEXTPATH_${this.id}`;\n    const textPath = [\n      `<textPath href=\"#${pathId}\" `,\n      align.join(''),\n      '>',\n      escapeXml(visibleContent),\n      '</textPath>',\n    ].join('');\n\n    textSpans.push(textPath);\n    return {\n      textSpans,\n      textBgRects,\n    };\n  }\n\n  private _getSVGLeftTopOffsets(this: TextSVGExportMixin & FabricText) {\n    return {\n      textLeft: -this.width / 2,\n      textTop: -this.height / 2,\n      lineTop: this.getHeightOfLine(0),\n    };\n  }\n\n  private _wrapSVGTextAndBg(\n    this: TextSVGExportMixin & FabricText,\n    {\n      textBgRects,\n      textSpans,\n    }: {\n      textSpans: string[];\n      textBgRects: string[];\n    },\n  ) {\n    const noShadow = true,\n      textDecoration = this.getSvgTextDecoration(this);\n    return [\n      textBgRects.join(''),\n      '\\t\\t<text xml:space=\"preserve\" ',\n      `font-family=\"${this.fontFamily.replace(dblQuoteRegex, \"'\")}\" `,\n      `font-size=\"${this.fontSize}\" `,\n      this.fontStyle ? `font-style=\"${this.fontStyle}\" ` : '',\n      this.fontWeight ? `font-weight=\"${this.fontWeight}\" ` : '',\n      // James modified\n      // 增加 letter-space line-height textalign，用于 Vectr2.0导入\n      this.charSpacing\n        ? 'letter-spacing=\"' + this._getWidthOfCharSpacing() + '\" '\n        : '',\n      // svg 暂时不支持该属性，只能用于 Vectr2.0导入\n      this.lineHeight ? 'line-height=\"' + this.lineHeight + '\" ' : '',\n      textDecoration ? `text-decoration=\"${textDecoration}\" ` : '',\n      this.direction === 'rtl' ? `direction=\"${this.direction}\" ` : '',\n      'style=\"',\n      this.getSvgStyles(noShadow),\n      '\"',\n      this.addPaintOrder(),\n      ' >',\n      textSpans.join(''),\n      '</text>\\n',\n    ];\n  }\n\n  /**\n   * @private\n   * @param {Number} textTopOffset Text top offset\n   * @param {Number} textLeftOffset Text left offset\n   * @return {Object}\n   */\n  private _getSVGTextAndBg(\n    this: TextSVGExportMixin & FabricText,\n    textTopOffset: number,\n    textLeftOffset: number,\n  ) {\n    const textSpans: string[] = [],\n      textBgRects: string[] = [];\n    let height = textTopOffset,\n      lineOffset;\n\n    // bounding-box background\n    this.backgroundColor &&\n      textBgRects.push(\n        ...createSVGInlineRect(\n          this.backgroundColor,\n          -this.width / 2,\n          -this.height / 2,\n          this.width,\n          this.height,\n        ),\n      );\n\n    // text and text-background\n    for (let i = 0, len = this._textLines.length; i < len; i++) {\n      // James modified\n      let heightOfLine = this.getHeightOfLine(i);\n      let realHeightOfLine = heightOfLine / this.lineHeight;\n\n      // 2022.3.1 超过box高度，不显示 text\n      if (height + realHeightOfLine * 0.8 > this.height / 2) {\n        break;\n      }\n\n      lineOffset = this._getLineLeftOffset(i);\n      if (this.direction === 'rtl') {\n        lineOffset += this.width;\n      }\n      if (this.textBackgroundColor || this.styleHas('textBackgroundColor', i)) {\n        this._setSVGTextLineBg(\n          textBgRects,\n          i,\n          textLeftOffset + lineOffset,\n          height,\n        );\n      }\n      this._setSVGTextLineText(\n        textSpans,\n        i,\n        textLeftOffset + lineOffset,\n        height,\n      );\n      height += heightOfLine;\n    }\n\n    return {\n      textSpans,\n      textBgRects,\n    };\n  }\n\n  private _createTextCharSpan(\n    this: TextSVGExportMixin & FabricText,\n    char: string,\n    styleDecl: TextStyleDeclaration,\n    left: number,\n    top: number,\n    charBox: GraphemeBBox,\n  ) {\n    const numFractionDigit = config.NUM_FRACTION_DIGITS;\n    const styleProps = this.getSvgSpanStyles(\n        styleDecl,\n        char !== char.trim() || !!char.match(multipleSpacesRegex),\n      ),\n      fillStyles = styleProps ? `style=\"${styleProps}\"` : '',\n      dy = styleDecl.deltaY,\n      dySpan = dy ? ` dy=\"${toFixed(dy, numFractionDigit)}\" ` : '',\n      { angle, renderLeft, renderTop, width } = charBox;\n    let angleAttr = '';\n    if (renderLeft !== undefined) {\n      const wBy2 = width / 2;\n      angle &&\n        (angleAttr = ` rotate=\"${toFixed(radiansToDegrees(angle), numFractionDigit)}\"`);\n      const m = createRotateMatrix({ angle: radiansToDegrees(angle!) });\n      m[4] = renderLeft!;\n      m[5] = renderTop!;\n      const renderPoint = new Point(-wBy2, 0).transform(m);\n      left = renderPoint.x;\n      top = renderPoint.y;\n    }\n\n    return `<tspan x=\"${toFixed(left, numFractionDigit)}\" y=\"${toFixed(\n      top,\n      numFractionDigit,\n    )}\" ${dySpan}${angleAttr}${fillStyles}>${escapeXml(char)}</tspan>`;\n  }\n  /**\n   * James modified\n   */\n  private _setSVGTextLineText(\n    this: TextSVGExportMixin & FabricText,\n    textSpans: string[],\n    lineIndex: number,\n    textLeftOffset: number,\n    textTopOffset: number,\n  ) {\n    const lineHeight = this.getHeightOfLine(lineIndex),\n      isJustify = this.textAlign.includes(JUSTIFY),\n      line = this._textLines[lineIndex];\n    let actualStyle,\n      nextStyle,\n      charsToRender = '',\n      charBox,\n      style,\n      boxWidth = 0,\n      timeToRender;\n\n    textTopOffset +=\n      (lineHeight * (1 - this._fontSizeFraction)) / this.lineHeight;\n\n    // James modified\n    // 空行增加空tspan用于 Vectr2.0导入时表示空行\n    if (line.length === 0) {\n      style = {};\n      textSpans.push(\n        this._createTextCharSpan(\n          '',\n          style,\n          textLeftOffset,\n          textTopOffset,\n          {} as GraphemeBBox,\n        ),\n      );\n    }\n\n    for (let i = 0, len = line.length - 1; i <= len; i++) {\n      timeToRender = i === len || this.charSpacing || this.path;\n      charsToRender += line[i];\n      charBox = this.__charBounds[lineIndex][i];\n      if (boxWidth === 0) {\n        textLeftOffset += charBox.kernedWidth - charBox.width;\n        boxWidth += charBox.width;\n      } else {\n        boxWidth += charBox.kernedWidth;\n      }\n      if (isJustify && !timeToRender) {\n        if (this._reSpaceAndTab.test(line[i])) {\n          timeToRender = true;\n        }\n      }\n      if (!timeToRender) {\n        // if we have charSpacing or a path, we render char by char\n        actualStyle =\n          actualStyle || this.getCompleteStyleDeclaration(lineIndex, i);\n        nextStyle = this.getCompleteStyleDeclaration(lineIndex, i + 1);\n        // James modified forTextSpan = false\n        timeToRender = hasStyleChanged(actualStyle, nextStyle, false);\n      }\n      if (timeToRender) {\n        style = this._getStyleDeclaration(lineIndex, i);\n        textSpans.push(\n          this._createTextCharSpan(\n            charsToRender,\n            style,\n            textLeftOffset,\n            textTopOffset,\n            charBox,\n          ),\n        );\n        charsToRender = '';\n        actualStyle = nextStyle;\n        if (this.direction === 'rtl') {\n          textLeftOffset -= boxWidth;\n        } else {\n          textLeftOffset += boxWidth;\n        }\n        boxWidth = 0;\n      }\n    }\n  }\n\n  private _setSVGTextLineBg(\n    this: TextSVGExportMixin & FabricText,\n    textBgRects: (string | number)[],\n    i: number,\n    leftOffset: number,\n    textTopOffset: number,\n  ) {\n    const line = this._textLines[i],\n      heightOfLine = this.getHeightOfLine(i) / this.lineHeight;\n    let boxWidth = 0,\n      boxStart = 0,\n      currentColor,\n      lastColor = this.getValueOfPropertyAt(i, 0, 'textBackgroundColor');\n    for (let j = 0; j < line.length; j++) {\n      const { left, width, kernedWidth } = this.__charBounds[i][j];\n      currentColor = this.getValueOfPropertyAt(i, j, 'textBackgroundColor');\n      if (currentColor !== lastColor) {\n        lastColor &&\n          textBgRects.push(\n            ...createSVGInlineRect(\n              lastColor,\n              leftOffset + boxStart,\n              textTopOffset,\n              boxWidth,\n              heightOfLine,\n            ),\n          );\n        boxStart = left;\n        boxWidth = width;\n        lastColor = currentColor;\n      } else {\n        boxWidth += kernedWidth;\n      }\n    }\n    currentColor &&\n      textBgRects.push(\n        ...createSVGInlineRect(\n          lastColor,\n          leftOffset + boxStart,\n          textTopOffset,\n          boxWidth,\n          heightOfLine,\n        ),\n      );\n  }\n\n  /**\n   * @deprecated unused\n   */\n  _getSVGLineTopOffset(\n    this: TextSVGExportMixin & FabricText,\n    lineIndex: number,\n  ) {\n    let lineTopOffset = 0,\n      j;\n    for (j = 0; j < lineIndex; j++) {\n      lineTopOffset += this.getHeightOfLine(j);\n    }\n    const lastHeight = this.getHeightOfLine(j);\n    return {\n      lineTop: lineTopOffset,\n      offset:\n        ((this._fontSizeMult - this._fontSizeFraction) * lastHeight) /\n        (this.lineHeight * this._fontSizeMult),\n    };\n  }\n\n  /**\n   * Returns styles-string for svg-export\n   * @param {Boolean} skipShadow a boolean to skip shadow filter output\n   * @return {String}\n   */\n  getSvgStyles(this: TextSVGExportMixin & FabricText, skipShadow?: boolean) {\n    return `${super.getSvgStyles(skipShadow)} text-decoration-thickness: ${toFixed((this.textDecorationThickness * this.getObjectScaling().y) / 10, config.NUM_FRACTION_DIGITS)}%; white-space: pre;`;\n  }\n\n  /**\n   * Returns styles-string for svg-export\n   * @param {Object} style the object from which to retrieve style properties\n   * @param {Boolean} useWhiteSpace a boolean to include an additional attribute in the style.\n   * @return {String}\n   */\n  getSvgSpanStyles(\n    this: TextSVGExportMixin & FabricText,\n    style: TextStyleDeclaration,\n    useWhiteSpace?: boolean,\n  ) {\n    const {\n      fontFamily,\n      strokeWidth,\n      stroke,\n      fill,\n      fontSize,\n      fontStyle,\n      fontWeight,\n      deltaY,\n      textDecorationThickness,\n      linethrough,\n      overline,\n      underline,\n    } = style;\n\n    const textDecoration = this.getSvgTextDecoration({\n      underline: underline ?? this.underline,\n      overline: overline ?? this.overline,\n      linethrough: linethrough ?? this.linethrough,\n    });\n    const thickness = textDecorationThickness || this.textDecorationThickness;\n    return [\n      stroke ? colorPropToSVG(STROKE, stroke) : '',\n      strokeWidth ? `stroke-width: ${strokeWidth}; ` : '',\n      fontFamily\n        ? `font-family: ${\n            !fontFamily.includes(\"'\") && !fontFamily.includes('\"')\n              ? `'${fontFamily}'`\n              : fontFamily\n          }; `\n        : '',\n      fontSize ? `font-size: ${fontSize}px; ` : '',\n      fontStyle ? `font-style: ${fontStyle}; ` : '',\n      fontWeight ? `font-weight: ${fontWeight}; ` : '',\n      textDecoration\n        ? `text-decoration: ${textDecoration}; text-decoration-thickness: ${toFixed((thickness * this.getObjectScaling().y) / 10, config.NUM_FRACTION_DIGITS)}%; `\n        : '',\n      fill ? colorPropToSVG(FILL, fill) : '',\n      deltaY ? `baseline-shift: ${-deltaY}; ` : '',\n      useWhiteSpace ? 'white-space: pre; ' : '',\n    ].join('');\n  }\n\n  /**\n   * Returns text-decoration property for svg-export\n   * @param {Object} style the object from which to retrieve style properties\n   * @return {String}\n   */\n  getSvgTextDecoration(\n    this: TextSVGExportMixin & FabricText,\n    style: TextStyleDeclaration,\n  ) {\n    return (['overline', 'underline', 'line-through'] as const)\n      .filter(\n        (decoration) =>\n          style[\n            decoration.replace('-', '') as\n              | 'overline'\n              | 'underline'\n              | 'linethrough'\n          ],\n      )\n      .join(' ');\n  }\n}\n"],"names":["multipleSpacesRegex","dblQuoteRegex","createSVGInlineRect","color","left","top","width","height","createSVGRect","TextSVGExportMixin","FabricObjectSVGExportMixin","_toSVG","offsets","this","_getSVGLeftTopOffsets","textAndBg","path","_getTextPath","_getSVGTextAndBg","textTop","textLeft","_wrapSVGTextAndBg","toSVG","reviver","textSvg","_createBaseSVGMarkup","noStyle","withShadow","additionalTransform","matrixToSVG","calcOwnMatrix","textSpans","content","_textLines","map","v","join","visibleContent","__charBounds","length","Array","from","forEach","c","i","charBox","visible","align","alignMap","center","anchor","offset","right","textAlign","push","textPath","id","escapeXml","textBgRects","lineTop","getHeightOfLine","_ref","textDecoration","getSvgTextDecoration","fontFamily","replace","fontSize","fontStyle","fontWeight","charSpacing","_getWidthOfCharSpacing","lineHeight","direction","getSvgStyles","addPaintOrder","textTopOffset","textLeftOffset","lineOffset","backgroundColor","len","heightOfLine","_getLineLeftOffset","textBackgroundColor","styleHas","_setSVGTextLineBg","_setSVGTextLineText","_createTextCharSpan","char","styleDecl","numFractionDigit","config","NUM_FRACTION_DIGITS","styleProps","getSvgSpanStyles","trim","match","fillStyles","dy","deltaY","dySpan","toFixed","angle","renderLeft","renderTop","angleAttr","undefined","wBy2","radiansToDegrees","m","createRotateMatrix","renderPoint","Point","transform","x","y","lineIndex","isJustify","includes","JUSTIFY","line","actualStyle","nextStyle","style","timeToRender","charsToRender","boxWidth","_fontSizeFraction","kernedWidth","_reSpaceAndTab","test","getCompleteStyleDeclaration","hasStyleChanged","_getStyleDeclaration","leftOffset","currentColor","boxStart","lastColor","getValueOfPropertyAt","j","_getSVGLineTopOffset","lineTopOffset","lastHeight","_fontSizeMult","skipShadow","super","textDecorationThickness","getObjectScaling","useWhiteSpace","strokeWidth","stroke","fill","linethrough","overline","underline","thickness","colorPropToSVG","STROKE","FILL","filter","decoration"],"mappings":"swBAiBA,MAAMA,EAAsB,OACtBC,EAAgB,KAEtB,SAASC,EACPC,EACAC,EACAC,EACAC,EACAC,GAEA,MAAO,OAAOC,EAAcL,EAAO,CAAEC,OAAMC,MAAKC,QAAOC,cACzD,CAEO,MAAME,UAA2BC,EACtCC,MAAAA,GACE,MAAMC,EAAUC,KAAKC,wBACrB,IAAIC,EAOJ,OAJEA,EAFEF,KAAKG,KAEKH,KAAKI,eAELJ,KAAKK,iBAAiBN,EAAQO,QAASP,EAAQQ,UAEtDP,KAAKQ,kBAAkBN,EAChC,CAEAO,KAAAA,CAA6CC,GAC3C,MAAMC,EAAUX,KAAKY,qBAAqB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