@visactor/vrender-core 0.22.0-vstory.12 → 0.22.0-vstory.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 (70) hide show
  1. package/cjs/common/inversify/annotation/optional.d.ts +2 -0
  2. package/cjs/common/inversify/annotation/optional.js +14 -0
  3. package/cjs/common/inversify/annotation/optional.js.map +1 -0
  4. package/cjs/common/inversify/container.js +9 -6
  5. package/cjs/common/inversify/container.js.map +1 -1
  6. package/cjs/core/contributions/textMeasure/AtextMeasure.js +10 -0
  7. package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  8. package/cjs/graphic/bounds.d.ts +2 -2
  9. package/cjs/graphic/bounds.js.map +1 -1
  10. package/cjs/graphic/config.js +1 -0
  11. package/cjs/graphic/config.js.map +1 -1
  12. package/cjs/graphic/richtext.d.ts +1 -1
  13. package/cjs/graphic/richtext.js +22 -5
  14. package/cjs/graphic/richtext.js.map +1 -1
  15. package/cjs/interface/graphic/richText.d.ts +1 -0
  16. package/cjs/interface/graphic/richText.js.map +1 -1
  17. package/cjs/interface/graphic.d.ts +1 -0
  18. package/cjs/interface/graphic.js.map +1 -1
  19. package/cjs/plugins/builtin-plugin/edit-module.js +2 -1
  20. package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
  21. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.d.ts +8 -4
  22. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +124 -81
  23. package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  24. package/cjs/render/contributions/render/contributions/base-contribution-render.d.ts +1 -0
  25. package/cjs/render/contributions/render/contributions/base-contribution-render.js +7 -3
  26. package/cjs/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  27. package/cjs/render/contributions/render/contributions/group-contribution-render.js +2 -1
  28. package/cjs/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  29. package/cjs/render/contributions/render/contributions/text-contribution-render.js +3 -2
  30. package/cjs/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  31. package/cjs/render/contributions/render/draw-contribution.js +1 -0
  32. package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
  33. package/cjs/resource-loader/loader.d.ts +2 -2
  34. package/cjs/resource-loader/loader.js.map +1 -1
  35. package/dist/index.es.js +150 -65
  36. package/es/common/inversify/annotation/optional.d.ts +2 -0
  37. package/es/common/inversify/annotation/optional.js +12 -0
  38. package/es/common/inversify/annotation/optional.js.map +1 -0
  39. package/es/common/inversify/container.js +9 -6
  40. package/es/common/inversify/container.js.map +1 -1
  41. package/es/core/contributions/textMeasure/AtextMeasure.js +10 -0
  42. package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
  43. package/es/graphic/bounds.d.ts +2 -2
  44. package/es/graphic/bounds.js.map +1 -1
  45. package/es/graphic/config.js +1 -0
  46. package/es/graphic/config.js.map +1 -1
  47. package/es/graphic/richtext.d.ts +1 -1
  48. package/es/graphic/richtext.js +19 -4
  49. package/es/graphic/richtext.js.map +1 -1
  50. package/es/interface/graphic/richText.d.ts +1 -0
  51. package/es/interface/graphic/richText.js.map +1 -1
  52. package/es/interface/graphic.d.ts +1 -0
  53. package/es/interface/graphic.js.map +1 -1
  54. package/es/plugins/builtin-plugin/edit-module.js +2 -1
  55. package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
  56. package/es/plugins/builtin-plugin/richtext-edit-plugin.d.ts +8 -4
  57. package/es/plugins/builtin-plugin/richtext-edit-plugin.js +124 -81
  58. package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
  59. package/es/render/contributions/render/contributions/base-contribution-render.d.ts +1 -0
  60. package/es/render/contributions/render/contributions/base-contribution-render.js +7 -3
  61. package/es/render/contributions/render/contributions/base-contribution-render.js.map +1 -1
  62. package/es/render/contributions/render/contributions/group-contribution-render.js +2 -1
  63. package/es/render/contributions/render/contributions/group-contribution-render.js.map +1 -1
  64. package/es/render/contributions/render/contributions/text-contribution-render.js +3 -2
  65. package/es/render/contributions/render/contributions/text-contribution-render.js.map +1 -1
  66. package/es/render/contributions/render/draw-contribution.js +3 -2
  67. package/es/render/contributions/render/draw-contribution.js.map +1 -1
  68. package/es/resource-loader/loader.d.ts +2 -2
  69. package/es/resource-loader/loader.js.map +1 -1
  70. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/graphic/richtext.ts"],"names":[],"mappings":";;;;;;AACA,6CAAsD;AAkBtD,uCAAiF;AACjF,qCAAoD;AACpD,6DAAqC;AACrC,qEAA6C;AAC7C,iEAAyC;AACzC,mCAAmC;AACnC,0CAA+C;AAE/C,gDAA6C;AAC7C,2CAAmD;AAEnD,MAAM,uBAAuB,GAAG;IAC9B,OAAO;IACP,QAAQ;IACR,UAAU;IACV,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,MAAM;IACN,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,eAAe;IACf,GAAG,gCAAsB;CAC1B,CAAC;AAEF,MAAa,QAAS,SAAQ,iBAAkC;IAiB9D,YAAY,MAAkC;QAC5C,KAAK,CAAC,MAAM,CAAC,CAAC;QAjBhB,SAAI,GAAe,UAAU,CAAC;QAG9B,sBAAiB,GAAyB,IAAI,CAAC;QAe7C,IAAI,CAAC,UAAU,GAAG,gCAAoB,CAAC;QAEvC,IAAI,CAAC,uBAAuB,GAAG,CAAC,CAAC,GAAQ,EAAE,UAAe,EAAE,GAA6B,EAAE,EAAE;YAC3F,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;gBACrB,IAAI,GAAG,KAAK,aAAa,EAAE;oBACzB,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,UAAU,CAAC,GAAG,CAAC,EAAE;wBAChC,SAAS;qBACV;oBACD,MAAM,IAAI,GAAG,IAAI,CA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C,EACpB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,EACb,eAAe,EAAE,CAAC,IACf,6BAAmB,EACtB;AAglBJ,SAAgB,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC","file":"richtext.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isNumber, isString } from '@visactor/vutils';\nimport type {\n IRichText,\n IRichTextCharacter,\n RichTextGlobalAlignType,\n RichTextGlobalBaselineType,\n RichTextVerticalDirection,\n RichTextWordBreak,\n IRichTextGraphicAttribute,\n IRichTextImageCharacter,\n IRichTextParagraphCharacter,\n IStage,\n ILayer,\n IRichTextIcon,\n EventPoint,\n IRichTextFrame,\n ISetAttributeContext\n} from '../interface';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { DefaultRichTextAttribute } from './config';\nimport Frame from './richtext/frame';\nimport Paragraph from './richtext/paragraph';\nimport Wrapper from './richtext/wrapper';\nimport { getTheme } from './theme';\nimport { RichTextIcon } from './richtext/icon';\nimport type { FederatedMouseEvent } from '../event';\nimport { application } from '../application';\nimport { RICHTEXT_NUMBER_TYPE } from './constants';\n\nconst RICHTEXT_UPDATE_TAG_KEY = [\n 'width',\n 'height',\n 'ellipsis',\n 'wordBreak',\n 'verticalDirection',\n 'maxHeight',\n 'maxWidth',\n 'textAlign',\n 'textBaseline',\n 'textConfig',\n 'layoutDirection',\n 'fill',\n 'stroke',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'fontWeight',\n 'lineWidth',\n 'opacity',\n 'fillOpacity',\n 'strokeOpacity',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\nexport class RichText extends Graphic<IRichTextGraphicAttribute> implements IRichText {\n type: 'richtext' = 'richtext';\n\n _frameCache: Frame; // 富文本布局画布\n _currentHoverIcon: IRichTextIcon | null = null;\n\n static NOWORK_ANIMATE_ATTR = {\n ellipsis: 1,\n wordBreak: 1,\n verticalDirection: 1,\n textAlign: 1,\n textBaseline: 1,\n textConfig: 1,\n layoutDirection: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params?: IRichTextGraphicAttribute) {\n super(params);\n this.numberType = RICHTEXT_NUMBER_TYPE;\n\n this.onBeforeAttributeUpdate = ((val: any, attributes: any, key: null | string | string[]) => {\n for (const key in val) {\n if (key === 'hoverIconId') {\n if (val[key] === attributes[key]) {\n continue;\n }\n const icon = this._frameCache.icons.get(val[key]);\n this.updateHoverIconState(icon);\n }\n }\n }) as any;\n }\n\n get width(): number {\n return this.attribute.width ?? DefaultRichTextAttribute.width;\n }\n set width(w: number) {\n if (this.attribute.width === w) {\n return;\n }\n this.attribute.width = w;\n this.addUpdateShapeAndBoundsTag();\n }\n get height(): number {\n return this.attribute.height ?? DefaultRichTextAttribute.height;\n }\n set height(h: number) {\n if (this.attribute.height === h) {\n return;\n }\n this.attribute.height = h;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxWidth(): number | undefined {\n return this.attribute.maxWidth;\n }\n set maxWidth(mw: number | undefined) {\n if (this.attribute.maxWidth === mw) {\n return;\n }\n this.attribute.maxWidth = mw;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxHeight(): number | undefined {\n return this.attribute.maxHeight;\n }\n set maxHeight(mh: number | undefined) {\n if (this.attribute.maxHeight === mh) {\n return;\n }\n this.attribute.maxHeight = mh;\n this.addUpdateShapeAndBoundsTag();\n }\n get ellipsis(): boolean | string {\n return this.attribute.ellipsis ?? DefaultRichTextAttribute.ellipsis;\n }\n set ellipsis(e: boolean | string) {\n if (this.attribute.ellipsis === e) {\n return;\n }\n this.attribute.ellipsis = e;\n this.addUpdateShapeAndBoundsTag();\n }\n get wordBreak(): RichTextWordBreak {\n return this.attribute.wordBreak ?? DefaultRichTextAttribute.wordBreak;\n }\n set wordBreak(wb: RichTextWordBreak) {\n if (this.attribute.wordBreak === wb) {\n return;\n }\n this.attribute.wordBreak = wb;\n this.addUpdateShapeAndBoundsTag();\n }\n get verticalDirection(): RichTextVerticalDirection {\n return this.attribute.verticalDirection ?? DefaultRichTextAttribute.verticalDirection;\n }\n set verticalDirection(vd: RichTextVerticalDirection) {\n if (this.attribute.verticalDirection === vd) {\n return;\n }\n this.attribute.verticalDirection = vd;\n this.addUpdateShapeAndBoundsTag();\n }\n get textAlign(): RichTextGlobalAlignType {\n return this.attribute.textAlign ?? DefaultRichTextAttribute.textAlign;\n }\n set textAlign(align: RichTextGlobalAlignType) {\n if (this.attribute.textAlign === align) {\n return;\n }\n this.attribute.textAlign = align;\n this.addUpdateShapeAndBoundsTag();\n }\n get textBaseline(): RichTextGlobalBaselineType {\n return this.attribute.textBaseline ?? DefaultRichTextAttribute.textBaseline;\n }\n set textBaseline(baseline: RichTextGlobalBaselineType) {\n if (this.attribute.textBaseline === baseline) {\n return;\n }\n this.attribute.textBaseline = baseline;\n this.addUpdateShapeAndBoundsTag();\n }\n get textConfig(): IRichTextCharacter[] {\n return this.attribute.textConfig ?? DefaultRichTextAttribute.textConfig;\n }\n set textConfig(config: IRichTextCharacter[]) {\n this.attribute.textConfig = config;\n this.addUpdateShapeAndBoundsTag();\n }\n\n getGraphicTheme(): Required<IRichTextGraphicAttribute> {\n return getTheme(this).richtext;\n }\n\n static AllSingleCharacter(cache: IRichTextFrame | IRichTextGraphicAttribute['textConfig']) {\n if ((cache as IRichTextFrame).lines) {\n const frame = cache as IRichTextFrame;\n return frame.lines.every(line =>\n line.paragraphs.every(item => !(item.text && isString(item.text) && RichText.splitText(item.text).length > 1))\n );\n }\n // isComposing的不算\n const tc = cache as IRichTextGraphicAttribute['textConfig'];\n return tc.every(\n item =>\n (item as any).isComposing ||\n !((item as any).text && isString((item as any).text) && RichText.splitText((item as any).text).length > 1)\n );\n }\n\n static splitText(text: string) {\n // 😁这种emoji长度算两个,所以得处理一下\n return Array.from(text);\n }\n\n static TransformTextConfig2SingleCharacter(textConfig: IRichTextGraphicAttribute['textConfig']) {\n const tc: IRichTextGraphicAttribute['textConfig'] = [];\n textConfig.forEach((item: IRichTextParagraphCharacter) => {\n const textList = RichText.splitText(item.text.toString());\n if (isString(item.text) && textList.length > 1) {\n // 拆分\n for (let i = 0; i < textList.length; i++) {\n const t = textList[i];\n tc.push({ ...item, text: t });\n }\n } else {\n tc.push(item);\n }\n });\n\n return tc;\n }\n\n protected updateAABBBounds(\n attribute: IRichTextGraphicAttribute,\n richtextTheme: Required<IRichTextGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n const {\n width = richtextTheme.width,\n height = richtextTheme.height,\n maxWidth = richtextTheme.maxWidth,\n maxHeight = richtextTheme.maxHeight,\n textAlign = richtextTheme.textAlign,\n textBaseline = richtextTheme.textBaseline,\n editOptions\n } = attribute;\n\n if (width > 0 && height > 0) {\n // 外部设置宽高\n aabbBounds.set(0, 0, width, height);\n } else {\n // 获取内容宽高\n const frameCache = this.getFrameCache();\n const { width: actualWidth, height: actualHeight } = frameCache.getActualSize();\n let contentWidth = width || actualWidth || 0;\n let contentHeight = height || actualHeight || 0;\n\n contentHeight = typeof maxHeight === 'number' && contentHeight > maxHeight ? maxHeight : contentHeight || 0;\n contentWidth = typeof maxWidth === 'number' && contentWidth > maxWidth ? maxWidth : contentWidth || 0;\n\n aabbBounds.set(0, 0, contentWidth, contentHeight);\n }\n\n // 如果是可编辑状态,且没有设置高度,就用fontSize,否则就完全选不到了\n if (editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !attribute.textConfig?.length) {\n aabbBounds.y2 = aabbBounds.y1 + (attribute.fontSize ?? 12);\n aabbBounds.x2 = aabbBounds.x1 + 2;\n }\n\n // 调整对齐方式\n let deltaY = 0;\n switch (textBaseline) {\n case 'top':\n deltaY = 0;\n break;\n case 'middle':\n deltaY = -aabbBounds.height() / 2;\n break;\n case 'bottom':\n deltaY = -aabbBounds.height();\n break;\n default:\n break;\n }\n let deltaX = 0;\n switch (textAlign) {\n case 'left':\n deltaX = 0;\n break;\n case 'center':\n deltaX = -aabbBounds.width() / 2;\n break;\n case 'right':\n deltaX = -aabbBounds.width();\n break;\n default:\n break;\n }\n aabbBounds.translate(deltaX, deltaY);\n\n application.graphicService.updateTempAABBBounds(aabbBounds);\n\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds);\n }\n application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, false, this);\n return aabbBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, RICHTEXT_UPDATE_TAG_KEY);\n }\n getFrameCache(): IRichTextFrame {\n if (this.shouldUpdateShape()) {\n this.doUpdateFrameCache();\n this.clearUpdateShapeTag();\n }\n return this._frameCache as IRichTextFrame;\n }\n\n get cliped() {\n const frameCache = this.getFrameCache();\n if (frameCache.actualHeight > frameCache.height) {\n return true;\n }\n const { disableAutoWrapLine } = this.attribute;\n if (disableAutoWrapLine) {\n for (let i = 0; i < frameCache.lines.length; i++) {\n const l = frameCache.lines[i];\n for (let j = 0; j < l.paragraphs.length; j++) {\n const p = l.paragraphs[j];\n if ((p as any).overflow && (p as any).text !== '') {\n return true;\n }\n }\n }\n }\n return false;\n // if (height < this.attribute.height || )\n }\n combinedStyleToCharacter(config: IRichTextImageCharacter | IRichTextParagraphCharacter) {\n const {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity\n } = this.attribute;\n return {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity,\n ...config\n };\n }\n doUpdateFrameCache(tc?: IRichTextCharacter[]) {\n // 1. 测量,生成paragraph\n const {\n maxWidth,\n maxHeight,\n width,\n height,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection,\n singleLine,\n disableAutoWrapLine,\n editable,\n ascentDescentMode\n } = this.attribute;\n\n let { textConfig: _tc = [] } = this.attribute;\n\n // 预处理editable,将textConfig中的text转换为单个字符\n if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {\n _tc = RichText.TransformTextConfig2SingleCharacter(_tc);\n this.attribute.textConfig = _tc;\n }\n\n const paragraphs: (Paragraph | RichTextIcon)[] = [];\n\n const textConfig = tc ?? _tc;\n\n for (let i = 0; i < textConfig.length; i++) {\n if ('image' in textConfig[i]) {\n const config = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextImageCharacter\n ) as IRichTextImageCharacter;\n (config as any).lineWidth = undefined; // for icon bounds\n // 直接创建icon Mark\n const iconCache =\n config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);\n if (iconCache) {\n paragraphs.push(iconCache as RichTextIcon);\n } else {\n const icon = new RichTextIcon(config);\n icon.successCallback = () => {\n this.addUpdateBoundTag();\n this.stage?.renderNextFrame();\n };\n icon.richtextId = config.id;\n paragraphs.push(icon);\n }\n } else {\n const richTextConfig = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextParagraphCharacter\n ) as IRichTextParagraphCharacter;\n if (isNumber(richTextConfig.text)) {\n richTextConfig.text = `${richTextConfig.text}`;\n }\n if (richTextConfig.text && richTextConfig.text.includes('\\n')) {\n // 如果有文字内有换行符,将该段文字切为多段,并在后一段加入newLine标记\n const textParts = richTextConfig.text.split('\\n');\n for (let j = 0; j < textParts.length; j++) {\n paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));\n }\n } else if (richTextConfig.text) {\n paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));\n }\n }\n }\n\n // 2. 布局,生成frame\n // const frameHeight =\n // typeof maxHeight === 'number' && (!height || height > maxHeight) // height = 0或height>maxHeight,使用maxHeight布局\n // ? maxHeight\n // : height;\n // const frameWidth =\n // typeof maxWidth === 'number' && (!width || width > maxWidth) // height = 0或height>maxWidth,使用maxWidth布局\n // ? maxWidth\n // : width;\n\n const maxWidthFinite = typeof maxWidth === 'number' && Number.isFinite(maxWidth) && maxWidth > 0;\n const maxHeightFinite = typeof maxHeight === 'number' && Number.isFinite(maxHeight) && maxHeight > 0;\n\n const richTextWidthEnable =\n typeof width === 'number' &&\n Number.isFinite(width) &&\n width > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxWidthFinite || width <= maxWidth);\n const richTextHeightEnable =\n typeof height === 'number' &&\n Number.isFinite(height) &&\n height > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxHeightFinite || height <= maxHeight);\n\n const frameWidth = richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0;\n const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;\n\n const frame = new Frame(\n 0,\n 0,\n frameWidth || 0,\n frameHeight || 0,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection || 'horizontal',\n // typeof maxWidth === 'number' && (!width || width > maxWidth),\n // typeof maxHeight === 'number' && (!height || height > maxHeight),\n !richTextWidthEnable && maxWidthFinite,\n !richTextHeightEnable && maxHeightFinite,\n singleLine || false,\n this._frameCache?.icons\n );\n const wrapper = new Wrapper(frame);\n // @since 0.22.0\n // 如果可编辑的话,则支持多换行符\n wrapper.newLine = editable;\n if (disableAutoWrapLine) {\n let lineCount = 0;\n let skip = false;\n for (let i = 0; i < paragraphs.length; i++) {\n const p = paragraphs[i];\n if (skip) {\n (p as Paragraph).overflow = true;\n (p as Paragraph).left = Infinity;\n (p as Paragraph).top = Infinity;\n !(p as Paragraph).newLine && frame.lines[frame.lines.length - 1].paragraphs.push(p);\n } else {\n wrapper.deal(p, true);\n }\n if (frame.lines.length !== lineCount) {\n lineCount = frame.lines.length;\n wrapper.lineBuffer.length = 0;\n (p as Paragraph).overflow = true;\n (p as Paragraph).left = 1000;\n (p as Paragraph).top = 1000;\n frame.lines[frame.lines.length - 1].paragraphs.push(p);\n skip = true;\n }\n if ((p as Paragraph).newLine) {\n skip = false;\n wrapper.lineWidth = 0;\n }\n wrapper.send();\n }\n } else {\n for (let i = 0; i < paragraphs.length; i++) {\n wrapper.deal(paragraphs[i]);\n }\n }\n\n wrapper.send(); // 最后一行手动输出\n\n // 如果对应的配置宽度不可用,那么需要额外进行一次对齐\n const directionEnable = frame.layoutDirection === 'horizontal' ? richTextWidthEnable : richTextHeightEnable;\n if (!directionEnable) {\n // 使用实际宽度\n const frameSize = frame.getActualSizeWidthEllipsis();\n let offsetSize = frame.layoutDirection === 'horizontal' ? frameSize.width : frameSize.height;\n // 如果最大值可用\n if (frame.layoutDirection === 'horizontal' ? maxWidthFinite : maxHeightFinite) {\n // 取2者中的较小值\n offsetSize = Math.min(\n offsetSize,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n frame.layoutDirection === 'horizontal' ? maxWidth : maxHeight\n );\n }\n\n frame.lines.forEach(function (l) {\n l.calcOffset(offsetSize, false);\n });\n }\n\n // 处理空行\n if (editable) {\n frame.lines.forEach(item => {\n const lastParagraphs = item.paragraphs;\n item.paragraphs = item.paragraphs.filter(p => (p as any).text !== '');\n if (item.paragraphs.length === 0 && lastParagraphs.length) {\n (lastParagraphs[0] as any).text = '\\n';\n item.paragraphs.push(lastParagraphs[0]);\n }\n });\n }\n\n this._frameCache = frame;\n\n // this.bindIconEvent();\n }\n\n clone() {\n return new RichText({ ...this.attribute });\n }\n\n setStage(stage?: IStage, layer?: ILayer) {\n super.setStage(stage, layer);\n const frameCache = this.getFrameCache();\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // icon.setStage(stage, layer);\n // }\n frameCache.icons.forEach(icon => {\n icon.setStage(stage, layer);\n });\n }\n\n // richtext绑定icon交互事件,供外部调用\n bindIconEvent() {\n this.addEventListener('pointermove', (e: FederatedMouseEvent) => {\n const pickedIcon = this.pickIcon(e.global);\n if (pickedIcon && pickedIcon === this._currentHoverIcon) {\n // do nothing\n } else if (pickedIcon) {\n this.setAttribute('hoverIconId', pickedIcon.richtextId);\n\n // this._currentHoverIcon?.setHoverState(false);\n // this._currentHoverIcon = pickedIcon;\n // this._currentHoverIcon.setHoverState(true);\n // this.stage?.setCursor(pickedIcon.attribute.cursor);\n // this.stage?.renderNextFrame();\n } else if (!pickedIcon && this._currentHoverIcon) {\n this.setAttribute('hoverIconId', undefined);\n\n // this._currentHoverIcon.setHoverState(false);\n // this._currentHoverIcon = null;\n // this.stage?.setCursor();\n // this.stage?.renderNextFrame();\n }\n });\n\n this.addEventListener('pointerleave', (e: FederatedMouseEvent) => {\n if (this._currentHoverIcon) {\n this.setAttribute('hoverIconId', undefined);\n\n // this._currentHoverIcon.setHoverState(false);\n // this._currentHoverIcon = null;\n // this.stage?.setCursor();\n // this.stage?.renderNextFrame();\n }\n });\n }\n\n updateHoverIconState(pickedIcon?: IRichTextIcon) {\n if (pickedIcon) {\n this._currentHoverIcon?.setHoverState(false);\n this._currentHoverIcon = pickedIcon;\n this._currentHoverIcon.setHoverState(true);\n this.stage?.setCursor(pickedIcon.attribute.cursor);\n this.stage?.renderNextFrame();\n } else {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n this.stage?.renderNextFrame();\n }\n }\n\n pickIcon(point: EventPoint): IRichTextIcon | undefined {\n const frameCache = this.getFrameCache();\n const { e: x, f: y } = this.globalTransMatrix;\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // if (icon.containsPoint(point.x - x, point.y - y)) {\n // return icon;\n // }\n // }\n let pickIcon: IRichTextIcon | undefined;\n frameCache.icons.forEach((icon, key) => {\n const bounds = icon.AABBBounds.clone();\n bounds.translate(icon._marginArray[3], icon._marginArray[0]);\n if (bounds.containsPoint({ x: point.x - x, y: point.y - y })) {\n pickIcon = icon;\n\n pickIcon.globalX = (pickIcon.attribute.x ?? 0) + x + icon._marginArray[3];\n pickIcon.globalY = (pickIcon.attribute.y ?? 0) + y + icon._marginArray[0];\n }\n });\n\n return pickIcon;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return RichText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createRichText(attributes: IRichTextGraphicAttribute): IRichText {\n return new RichText(attributes);\n}\n"]}
1
+ {"version":3,"sources":["../src/graphic/richtext.ts"],"names":[],"mappings":";;;;;;AACA,6CAAsD;AAkBtD,uCAAiF;AACjF,qCAAoD;AACpD,6DAAqC;AACrC,qEAA6C;AAC7C,iEAAyC;AACzC,mCAAmC;AACnC,0CAA+C;AAE/C,gDAA6C;AAC7C,2CAAmD;AAEnD,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI;IACF,WAAW,GAAG,IAAI,IAAI,OAAQ,IAAY,CAAC,SAAS,KAAK,UAAU,CAAC;CACrE;AAAC,OAAO,CAAC,EAAE;IACV,WAAW,GAAG,KAAK,CAAC;CACrB;AAED,MAAM,uBAAuB,GAAG;IAC9B,OAAO;IACP,QAAQ;IACR,UAAU;IACV,WAAW;IACX,mBAAmB;IACnB,WAAW;IACX,UAAU;IACV,WAAW;IACX,cAAc;IACd,YAAY;IACZ,iBAAiB;IACjB,MAAM;IACN,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,WAAW;IACX,YAAY;IACZ,WAAW;IACX,SAAS;IACT,aAAa;IACb,eAAe;IACf,GAAG,gCAAsB;CAC1B,CAAC;AAEF,MAAa,QAAS,SAAQ,iBAAkC;IAiB9D,YAAY,MAAkC;QAC5C,KAAK,CAAC,MAAM,CAAC,CAAC;QAjBhB,SAAI,GAAe,UAAU,CAAC;QAG9B,sBAAiB,GAAyB,IAAI,CAAC;QAe7C,IAAI,CAAC,UAAU,GAA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,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAC5D,QAAQ,GAAG,IAAI,CAAC;gBAEhB,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;gBAC1E,QAAQ,CAAC,OAAO,GAAG,CAAC,MAAA,QAAQ,CAAC,SAAS,CAAC,CAAC,mCAAI,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;aAC3E;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;;AArmBH,4BAsmBC;AAhmBQ,4BAAmB,mBACxB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,CAAC,EACZ,iBAAiB,EAAE,CAAC,EACpB,SAAS,EAAE,CAAC,EACZ,YAAY,EAAE,CAAC,EACf,UAAU,EAAE,CAAC,EACb,eAAe,EAAE,CAAC,IACf,6BAAmB,EACtB;AAylBJ,SAAgB,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC;AAFD,wCAEC","file":"richtext.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { isNumber, isString } from '@visactor/vutils';\nimport type {\n IRichText,\n IRichTextCharacter,\n RichTextGlobalAlignType,\n RichTextGlobalBaselineType,\n RichTextVerticalDirection,\n RichTextWordBreak,\n IRichTextGraphicAttribute,\n IRichTextImageCharacter,\n IRichTextParagraphCharacter,\n IStage,\n ILayer,\n IRichTextIcon,\n EventPoint,\n IRichTextFrame,\n ISetAttributeContext\n} from '../interface';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { DefaultRichTextAttribute } from './config';\nimport Frame from './richtext/frame';\nimport Paragraph from './richtext/paragraph';\nimport Wrapper from './richtext/wrapper';\nimport { getTheme } from './theme';\nimport { RichTextIcon } from './richtext/icon';\nimport type { FederatedMouseEvent } from '../event';\nimport { application } from '../application';\nimport { RICHTEXT_NUMBER_TYPE } from './constants';\n\nlet supportIntl = false;\ntry {\n supportIntl = Intl && typeof (Intl as any).Segmenter === 'function';\n} catch (e) {\n supportIntl = false;\n}\n\nconst RICHTEXT_UPDATE_TAG_KEY = [\n 'width',\n 'height',\n 'ellipsis',\n 'wordBreak',\n 'verticalDirection',\n 'maxHeight',\n 'maxWidth',\n 'textAlign',\n 'textBaseline',\n 'textConfig',\n 'layoutDirection',\n 'fill',\n 'stroke',\n 'fontSize',\n 'fontFamily',\n 'fontStyle',\n 'fontWeight',\n 'lineWidth',\n 'opacity',\n 'fillOpacity',\n 'strokeOpacity',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\nexport class RichText extends Graphic<IRichTextGraphicAttribute> implements IRichText {\n type: 'richtext' = 'richtext';\n\n _frameCache: Frame; // 富文本布局画布\n _currentHoverIcon: IRichTextIcon | null = null;\n\n static NOWORK_ANIMATE_ATTR = {\n ellipsis: 1,\n wordBreak: 1,\n verticalDirection: 1,\n textAlign: 1,\n textBaseline: 1,\n textConfig: 1,\n layoutDirection: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n constructor(params?: IRichTextGraphicAttribute) {\n super(params);\n this.numberType = RICHTEXT_NUMBER_TYPE;\n\n this.onBeforeAttributeUpdate = ((val: any, attributes: any, key: null | string | string[]) => {\n for (const key in val) {\n if (key === 'hoverIconId') {\n if (val[key] === attributes[key]) {\n continue;\n }\n const icon = this._frameCache.icons.get(val[key]);\n this.updateHoverIconState(icon);\n }\n }\n }) as any;\n }\n\n get width(): number {\n return this.attribute.width ?? DefaultRichTextAttribute.width;\n }\n set width(w: number) {\n if (this.attribute.width === w) {\n return;\n }\n this.attribute.width = w;\n this.addUpdateShapeAndBoundsTag();\n }\n get height(): number {\n return this.attribute.height ?? DefaultRichTextAttribute.height;\n }\n set height(h: number) {\n if (this.attribute.height === h) {\n return;\n }\n this.attribute.height = h;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxWidth(): number | undefined {\n return this.attribute.maxWidth;\n }\n set maxWidth(mw: number | undefined) {\n if (this.attribute.maxWidth === mw) {\n return;\n }\n this.attribute.maxWidth = mw;\n this.addUpdateShapeAndBoundsTag();\n }\n get maxHeight(): number | undefined {\n return this.attribute.maxHeight;\n }\n set maxHeight(mh: number | undefined) {\n if (this.attribute.maxHeight === mh) {\n return;\n }\n this.attribute.maxHeight = mh;\n this.addUpdateShapeAndBoundsTag();\n }\n get ellipsis(): boolean | string {\n return this.attribute.ellipsis ?? DefaultRichTextAttribute.ellipsis;\n }\n set ellipsis(e: boolean | string) {\n if (this.attribute.ellipsis === e) {\n return;\n }\n this.attribute.ellipsis = e;\n this.addUpdateShapeAndBoundsTag();\n }\n get wordBreak(): RichTextWordBreak {\n return this.attribute.wordBreak ?? DefaultRichTextAttribute.wordBreak;\n }\n set wordBreak(wb: RichTextWordBreak) {\n if (this.attribute.wordBreak === wb) {\n return;\n }\n this.attribute.wordBreak = wb;\n this.addUpdateShapeAndBoundsTag();\n }\n get verticalDirection(): RichTextVerticalDirection {\n return this.attribute.verticalDirection ?? DefaultRichTextAttribute.verticalDirection;\n }\n set verticalDirection(vd: RichTextVerticalDirection) {\n if (this.attribute.verticalDirection === vd) {\n return;\n }\n this.attribute.verticalDirection = vd;\n this.addUpdateShapeAndBoundsTag();\n }\n get textAlign(): RichTextGlobalAlignType {\n return this.attribute.textAlign ?? DefaultRichTextAttribute.textAlign;\n }\n set textAlign(align: RichTextGlobalAlignType) {\n if (this.attribute.textAlign === align) {\n return;\n }\n this.attribute.textAlign = align;\n this.addUpdateShapeAndBoundsTag();\n }\n get textBaseline(): RichTextGlobalBaselineType {\n return this.attribute.textBaseline ?? DefaultRichTextAttribute.textBaseline;\n }\n set textBaseline(baseline: RichTextGlobalBaselineType) {\n if (this.attribute.textBaseline === baseline) {\n return;\n }\n this.attribute.textBaseline = baseline;\n this.addUpdateShapeAndBoundsTag();\n }\n get textConfig(): IRichTextCharacter[] {\n return this.attribute.textConfig ?? DefaultRichTextAttribute.textConfig;\n }\n set textConfig(config: IRichTextCharacter[]) {\n this.attribute.textConfig = config;\n this.addUpdateShapeAndBoundsTag();\n }\n\n getGraphicTheme(): Required<IRichTextGraphicAttribute> {\n return getTheme(this).richtext;\n }\n\n static AllSingleCharacter(cache: IRichTextFrame | IRichTextGraphicAttribute['textConfig']) {\n if ((cache as IRichTextFrame).lines) {\n const frame = cache as IRichTextFrame;\n return frame.lines.every(line =>\n line.paragraphs.every(item => !(item.text && isString(item.text) && RichText.splitText(item.text).length > 1))\n );\n }\n // isComposing的不算\n const tc = cache as IRichTextGraphicAttribute['textConfig'];\n return tc.every(\n item =>\n (item as any).isComposing ||\n !((item as any).text && isString((item as any).text) && RichText.splitText((item as any).text).length > 1)\n );\n }\n\n static splitText(text: string) {\n if (supportIntl) {\n // 不传入具体语言标签,使用默认设置\n const segmenter = new (Intl as any).Segmenter(undefined, { granularity: 'grapheme' });\n const segments = [];\n for (const { segment } of segmenter.segment(text)) {\n segments.push(segment);\n }\n return segments;\n }\n // 如果不支持 Intl.Segmenter,则使用旧方法\n return Array.from(text);\n }\n\n static TransformTextConfig2SingleCharacter(textConfig: IRichTextGraphicAttribute['textConfig']) {\n const tc: IRichTextGraphicAttribute['textConfig'] = [];\n textConfig.forEach((item: IRichTextParagraphCharacter) => {\n const textList = RichText.splitText(item.text.toString());\n if (isString(item.text) && textList.length > 1) {\n // 拆分\n for (let i = 0; i < textList.length; i++) {\n const t = textList[i];\n tc.push({ ...item, text: t });\n }\n } else {\n tc.push(item);\n }\n });\n\n return tc;\n }\n\n protected updateAABBBounds(\n attribute: IRichTextGraphicAttribute,\n richtextTheme: Required<IRichTextGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n const {\n width = richtextTheme.width,\n height = richtextTheme.height,\n maxWidth = richtextTheme.maxWidth,\n maxHeight = richtextTheme.maxHeight,\n textAlign = richtextTheme.textAlign,\n verticalDirection = attribute.textBaseline ?? richtextTheme.textBaseline ?? richtextTheme.verticalDirection,\n editOptions\n } = attribute;\n\n if (width > 0 && height > 0) {\n // 外部设置宽高\n aabbBounds.set(0, 0, width, height);\n } else {\n // 获取内容宽高\n const frameCache = this.getFrameCache();\n const { width: actualWidth, height: actualHeight } = frameCache.getActualSize();\n let contentWidth = width || actualWidth || 0;\n let contentHeight = height || actualHeight || 0;\n\n contentHeight = typeof maxHeight === 'number' && contentHeight > maxHeight ? maxHeight : contentHeight || 0;\n contentWidth = typeof maxWidth === 'number' && contentWidth > maxWidth ? maxWidth : contentWidth || 0;\n\n aabbBounds.set(0, 0, contentWidth, contentHeight);\n }\n\n // 如果是可编辑状态,且没有设置高度,就用fontSize,否则就完全选不到了\n if (editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !attribute.textConfig?.length) {\n aabbBounds.y2 = aabbBounds.y1 + (attribute.fontSize ?? 12);\n aabbBounds.x2 = aabbBounds.x1 + 2;\n }\n\n // 调整对齐方式\n let deltaY = 0;\n switch (verticalDirection) {\n case 'top':\n deltaY = 0;\n break;\n case 'middle':\n deltaY = -aabbBounds.height() / 2;\n break;\n case 'bottom':\n deltaY = -aabbBounds.height();\n break;\n default:\n break;\n }\n let deltaX = 0;\n switch (textAlign) {\n case 'left':\n deltaX = 0;\n break;\n case 'center':\n deltaX = -aabbBounds.width() / 2;\n break;\n case 'right':\n deltaX = -aabbBounds.width();\n break;\n default:\n break;\n }\n aabbBounds.translate(deltaX, deltaY);\n\n application.graphicService.updateTempAABBBounds(aabbBounds);\n\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds);\n }\n application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, false, this);\n return aabbBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n return super.needUpdateTags(keys, RICHTEXT_UPDATE_TAG_KEY);\n }\n protected needUpdateTag(key: string): boolean {\n return super.needUpdateTag(key, RICHTEXT_UPDATE_TAG_KEY);\n }\n getFrameCache(): IRichTextFrame {\n if (this.shouldUpdateShape()) {\n this.doUpdateFrameCache();\n this.clearUpdateShapeTag();\n }\n return this._frameCache as IRichTextFrame;\n }\n\n get cliped() {\n const frameCache = this.getFrameCache();\n if (frameCache.actualHeight > frameCache.height) {\n return true;\n }\n const { disableAutoWrapLine } = this.attribute;\n if (disableAutoWrapLine) {\n for (let i = 0; i < frameCache.lines.length; i++) {\n const l = frameCache.lines[i];\n for (let j = 0; j < l.paragraphs.length; j++) {\n const p = l.paragraphs[j];\n if ((p as any).overflow && (p as any).text !== '') {\n return true;\n }\n }\n }\n }\n return false;\n // if (height < this.attribute.height || )\n }\n combinedStyleToCharacter(config: IRichTextImageCharacter | IRichTextParagraphCharacter) {\n const {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity\n } = this.attribute;\n return {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity,\n ...config\n };\n }\n doUpdateFrameCache(tc?: IRichTextCharacter[]) {\n // 1. 测量,生成paragraph\n const {\n maxWidth,\n maxHeight,\n width,\n height,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection,\n singleLine,\n disableAutoWrapLine,\n editable,\n ascentDescentMode\n } = this.attribute;\n\n let { textConfig: _tc = [] } = this.attribute;\n\n // 预处理editable,将textConfig中的text转换为单个字符\n if (editable && _tc.length > 0 && !RichText.AllSingleCharacter(_tc)) {\n _tc = RichText.TransformTextConfig2SingleCharacter(_tc);\n this.attribute.textConfig = _tc;\n }\n\n const paragraphs: (Paragraph | RichTextIcon)[] = [];\n\n const textConfig = tc ?? _tc;\n\n for (let i = 0; i < textConfig.length; i++) {\n if ('image' in textConfig[i]) {\n const config = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextImageCharacter\n ) as IRichTextImageCharacter;\n (config as any).lineWidth = undefined; // for icon bounds\n // 直接创建icon Mark\n const iconCache =\n config.id && this._frameCache && this._frameCache.icons && this._frameCache.icons.get(config.id);\n if (iconCache) {\n paragraphs.push(iconCache as RichTextIcon);\n } else {\n const icon = new RichTextIcon(config);\n icon.successCallback = () => {\n this.addUpdateBoundTag();\n this.stage?.renderNextFrame();\n };\n icon.richtextId = config.id;\n paragraphs.push(icon);\n }\n } else {\n const richTextConfig = this.combinedStyleToCharacter(\n textConfig[i] as IRichTextParagraphCharacter\n ) as IRichTextParagraphCharacter;\n if (isNumber(richTextConfig.text)) {\n richTextConfig.text = `${richTextConfig.text}`;\n }\n if (richTextConfig.text && richTextConfig.text.includes('\\n')) {\n // 如果有文字内有换行符,将该段文字切为多段,并在后一段加入newLine标记\n const textParts = richTextConfig.text.split('\\n');\n for (let j = 0; j < textParts.length; j++) {\n paragraphs.push(new Paragraph(textParts[j], j !== 0, richTextConfig, ascentDescentMode));\n }\n } else if (richTextConfig.text) {\n paragraphs.push(new Paragraph(richTextConfig.text, false, richTextConfig, ascentDescentMode));\n }\n }\n }\n\n // 2. 布局,生成frame\n // const frameHeight =\n // typeof maxHeight === 'number' && (!height || height > maxHeight) // height = 0或height>maxHeight,使用maxHeight布局\n // ? maxHeight\n // : height;\n // const frameWidth =\n // typeof maxWidth === 'number' && (!width || width > maxWidth) // height = 0或height>maxWidth,使用maxWidth布局\n // ? maxWidth\n // : width;\n\n const maxWidthFinite = typeof maxWidth === 'number' && Number.isFinite(maxWidth) && maxWidth > 0;\n const maxHeightFinite = typeof maxHeight === 'number' && Number.isFinite(maxHeight) && maxHeight > 0;\n\n const richTextWidthEnable =\n typeof width === 'number' &&\n Number.isFinite(width) &&\n width > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxWidthFinite || width <= maxWidth);\n const richTextHeightEnable =\n typeof height === 'number' &&\n Number.isFinite(height) &&\n height > 0 &&\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n (!maxHeightFinite || height <= maxHeight);\n\n const frameWidth = richTextWidthEnable ? width : maxWidthFinite ? maxWidth : 0;\n const frameHeight = richTextHeightEnable ? height : maxHeightFinite ? maxHeight : 0;\n\n const frame = new Frame(\n 0,\n 0,\n frameWidth || 0,\n frameHeight || 0,\n ellipsis,\n wordBreak,\n verticalDirection,\n textAlign,\n textBaseline,\n layoutDirection || 'horizontal',\n // typeof maxWidth === 'number' && (!width || width > maxWidth),\n // typeof maxHeight === 'number' && (!height || height > maxHeight),\n !richTextWidthEnable && maxWidthFinite,\n !richTextHeightEnable && maxHeightFinite,\n singleLine || false,\n this._frameCache?.icons\n );\n const wrapper = new Wrapper(frame);\n // @since 0.22.0\n // 如果可编辑的话,则支持多换行符\n wrapper.newLine = editable;\n if (disableAutoWrapLine) {\n let lineCount = 0;\n let skip = false;\n for (let i = 0; i < paragraphs.length; i++) {\n const p = paragraphs[i];\n if (skip) {\n (p as Paragraph).overflow = true;\n (p as Paragraph).left = Infinity;\n (p as Paragraph).top = Infinity;\n !(p as Paragraph).newLine && frame.lines[frame.lines.length - 1].paragraphs.push(p);\n } else {\n wrapper.deal(p, true);\n }\n if (frame.lines.length !== lineCount) {\n lineCount = frame.lines.length;\n wrapper.lineBuffer.length = 0;\n (p as Paragraph).overflow = true;\n (p as Paragraph).left = 1000;\n (p as Paragraph).top = 1000;\n frame.lines[frame.lines.length - 1].paragraphs.push(p);\n skip = true;\n }\n if ((p as Paragraph).newLine) {\n skip = false;\n wrapper.lineWidth = 0;\n }\n wrapper.send();\n }\n } else {\n for (let i = 0; i < paragraphs.length; i++) {\n wrapper.deal(paragraphs[i]);\n }\n }\n\n wrapper.send(); // 最后一行手动输出\n\n // 如果对应的配置宽度不可用,那么需要额外进行一次对齐\n const directionEnable = frame.layoutDirection === 'horizontal' ? richTextWidthEnable : richTextHeightEnable;\n if (!directionEnable) {\n // 使用实际宽度\n const frameSize = frame.getActualSizeWidthEllipsis();\n let offsetSize = frame.layoutDirection === 'horizontal' ? frameSize.width : frameSize.height;\n // 如果最大值可用\n if (frame.layoutDirection === 'horizontal' ? maxWidthFinite : maxHeightFinite) {\n // 取2者中的较小值\n offsetSize = Math.min(\n offsetSize,\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n frame.layoutDirection === 'horizontal' ? maxWidth : maxHeight\n );\n }\n\n frame.lines.forEach(function (l) {\n l.calcOffset(offsetSize, false);\n });\n }\n\n // 处理空行\n if (editable) {\n frame.lines.forEach(item => {\n const lastParagraphs = item.paragraphs;\n item.paragraphs = item.paragraphs.filter(p => (p as any).text !== '');\n if (item.paragraphs.length === 0 && lastParagraphs.length) {\n (lastParagraphs[0] as any).text = '\\n';\n item.paragraphs.push(lastParagraphs[0]);\n }\n });\n }\n\n this._frameCache = frame;\n\n // this.bindIconEvent();\n }\n\n clone() {\n return new RichText({ ...this.attribute });\n }\n\n setStage(stage?: IStage, layer?: ILayer) {\n super.setStage(stage, layer);\n const frameCache = this.getFrameCache();\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // icon.setStage(stage, layer);\n // }\n frameCache.icons.forEach(icon => {\n icon.setStage(stage, layer);\n });\n }\n\n // richtext绑定icon交互事件,供外部调用\n bindIconEvent() {\n this.addEventListener('pointermove', (e: FederatedMouseEvent) => {\n const pickedIcon = this.pickIcon(e.global);\n if (pickedIcon && pickedIcon === this._currentHoverIcon) {\n // do nothing\n } else if (pickedIcon) {\n this.setAttribute('hoverIconId', pickedIcon.richtextId);\n\n // this._currentHoverIcon?.setHoverState(false);\n // this._currentHoverIcon = pickedIcon;\n // this._currentHoverIcon.setHoverState(true);\n // this.stage?.setCursor(pickedIcon.attribute.cursor);\n // this.stage?.renderNextFrame();\n } else if (!pickedIcon && this._currentHoverIcon) {\n this.setAttribute('hoverIconId', undefined);\n\n // this._currentHoverIcon.setHoverState(false);\n // this._currentHoverIcon = null;\n // this.stage?.setCursor();\n // this.stage?.renderNextFrame();\n }\n });\n\n this.addEventListener('pointerleave', (e: FederatedMouseEvent) => {\n if (this._currentHoverIcon) {\n this.setAttribute('hoverIconId', undefined);\n\n // this._currentHoverIcon.setHoverState(false);\n // this._currentHoverIcon = null;\n // this.stage?.setCursor();\n // this.stage?.renderNextFrame();\n }\n });\n }\n\n updateHoverIconState(pickedIcon?: IRichTextIcon) {\n if (pickedIcon) {\n this._currentHoverIcon?.setHoverState(false);\n this._currentHoverIcon = pickedIcon;\n this._currentHoverIcon.setHoverState(true);\n this.stage?.setCursor(pickedIcon.attribute.cursor);\n this.stage?.renderNextFrame();\n } else {\n this._currentHoverIcon.setHoverState(false);\n this._currentHoverIcon = null;\n this.stage?.setCursor();\n this.stage?.renderNextFrame();\n }\n }\n\n pickIcon(point: EventPoint): IRichTextIcon | undefined {\n const frameCache = this.getFrameCache();\n const { e: x, f: y } = this.globalTransMatrix;\n // for (let i = 0; i < frameCache.icons.length; i++) {\n // const icon = frameCache.icons[i];\n // if (icon.containsPoint(point.x - x, point.y - y)) {\n // return icon;\n // }\n // }\n let pickIcon: IRichTextIcon | undefined;\n frameCache.icons.forEach((icon, key) => {\n const bounds = icon.AABBBounds.clone();\n bounds.translate(icon._marginArray[3], icon._marginArray[0]);\n if (bounds.containsPoint({ x: point.x - x, y: point.y - y })) {\n pickIcon = icon;\n\n pickIcon.globalX = (pickIcon.attribute.x ?? 0) + x + icon._marginArray[3];\n pickIcon.globalY = (pickIcon.attribute.y ?? 0) + y + icon._marginArray[0];\n }\n });\n\n return pickIcon;\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return RichText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createRichText(attributes: IRichTextGraphicAttribute): IRichText {\n return new RichText(attributes);\n}\n"]}
@@ -11,6 +11,7 @@ export type IRichTextEditOptionsType = {
11
11
  syncPlaceholderToTextConfig?: boolean;
12
12
  keepHeightWhileEmpty?: boolean;
13
13
  boundsStrokeWhenInput?: string;
14
+ stopPropagation?: boolean;
14
15
  };
15
16
  export type IRichTextAttribute = {
16
17
  width: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\nimport type { ITextGraphicAttribute } from './text';\n\nexport type IRichTextEditOptionsType = {\n placeholder?: string;\n placeholderColor?: string;\n placeholderFontSize?: number;\n placeholderFontFamily?: string;\n // 是否将placeholder同步到textConfig中\n syncPlaceholderToTextConfig?: boolean;\n // 即使是空文本,是否也保持高度\n keepHeightWhileEmpty?: boolean;\n // 是否在输入的时候展示包围框,不传默认是false,可以传入颜色\n boundsStrokeWhenInput?: string;\n};\n\nexport type IRichTextAttribute = {\n /**\n * 富文本的总宽度\n */\n width: number;\n /**\n * 富文本的总高度\n */\n height: number;\n /**\n * 是否可编辑\n */\n editable: boolean;\n /**\n * 测量ascent和descent的模式,预览的时候actual比较合适,而如果需要编辑的话,font比较合适\n */\n ascentDescentMode?: 'actual' | 'font';\n /**\n * 富文本的编辑配置\n */\n editOptions: IRichTextEditOptionsType | null;\n /**\n * 文本超长的时候是否显示省略字符串\n * 1. boolean类型,true 表示将截断后的省略字符串设置为..., false 表示不显示省略字符串\n * 2. string类型,表示显示省略字符串,并将省略字符串设置为指定的值\n */\n ellipsis: boolean | string;\n /**\n * 文字换行类型\n */\n wordBreak: RichTextWordBreak;\n /**\n * 文字垂直方向\n */\n verticalDirection: RichTextVerticalDirection;\n /**\n * 富文本的最大高度,超过这个高度根据ellipsis的配置展示省略字符串或者直接截断\n */\n maxHeight: number;\n /**\n * 富文本的最大宽度,超过这个宽度根据ellipsis的配置展示省略字符串或者直接截断\n */\n maxWidth: number;\n /**\n * 文字对齐方式\n */\n textAlign: RichTextGlobalAlignType;\n /**\n * 文字基线\n */\n textBaseline: RichTextGlobalBaselineType;\n /**\n * 富文本的布局方向\n */\n layoutDirection: RichTextLayoutDirectionType;\n /**\n * 富文本的内容配置\n */\n textConfig: IRichTextCharacter[];\n /**\n * 不自动换行,仅当用户设置了换行符的时候才换行\n */\n disableAutoWrapLine: boolean;\n /**\n * 是否强制单行显示\n */\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute & ITextGraphicAttribute> &\n Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n /**\n * 行高\n */\n lineHeight?: number | string;\n /**\n * 文字对齐方式\n * left, right, center\n */\n textAlign?: CanvasTextAlign;\n /**\n * 文字基线\n */\n textBaseline?: CanvasTextBaseline;\n /**\n * 文字方向\n */\n direction?: RichTextLayoutDirectionType;\n};\n\n/**\n * 富文本段落为文本类型时候的配置\n */\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n /**\n * 文本内容\n */\n text: string | number;\n /**\n * 富文本片段的字体大小\n */\n fontSize?: number;\n /**\n * 富文本片段的字体类型\n */\n fontFamily?: string;\n /**\n * 富文本片段的文字颜色\n */\n fill?: IColor | boolean;\n /**\n * 富文本片段的文字描边颜色\n */\n stroke?: IColor | boolean;\n /**\n * 富文本片段的文字字重\n */\n fontWeight?: string;\n /**\n * 富文本片段的文字描边宽度\n */\n lineWidth?: number;\n // lineHeight?: number;\n /**\n * 富文本片段的文字斜体设置,支持以下属性\n * normal, italic, oblique\n */\n fontStyle?: RichTextFontStyle;\n /**\n * 富文本片段的文字中划线设置,支持以下属性\n * none, underline, line-through\n */\n textDecoration?: RichTextTextDecoration;\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n /**\n * 富文本片段的文字下划线设置,是否显示下划线\n */\n underline?: boolean;\n /**\n * 富文本片段的文字中划线设置,是否显示中划线\n */\n lineThrough?: boolean;\n /**\n * 富文本片段的透明度\n */\n opacity?: number;\n /**\n * 富文本片段的文字填充透明度\n */\n fillOpacity?: number;\n /**\n * 富文本片段的文字描边透明度\n */\n strokeOpacity?: number;\n // 仅支持纯色背景\n background?: string;\n // 背景透明度\n backgroundOpacity?: number;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n /**\n * 设置图片的内容,\n * 支持三种格式:\n * 1. 图片的url\n * 2. 图片的Image对象\n * 3. 图片的Canvas对象\n */\n image: string | HTMLImageElement | HTMLCanvasElement;\n /**\n * 图片的宽度\n */\n width: number;\n /**\n * 图片的高度\n */\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n /**\n * 背景的展示模式,支持以下属性\n * always: 一直显示\n * hover: 鼠标hover时显示\n */\n backgroundShowMode?: 'always' | 'hover';\n /**\n * 背景矩形填充颜色\n */\n backgroundFill?: boolean | IColor;\n /**\n * 背景矩形填充透明度\n */\n backgroundFillOpacity?: number;\n /**\n * 背景矩形边框颜色\n */\n backgroundStroke?: boolean | IColor;\n /**\n * 背景矩形边框透明度\n */\n backgroundStrokeOpacity?: number;\n /**\n * 背景矩形圆角\n */\n backgroundRadius?: number;\n // background size 同时控制了该icon的响应范围\n /**\n * 背景矩形的宽度\n */\n backgroundWidth?: number;\n /**\n * 背景矩形的高度\n */\n backgroundHeight?: number;\n\n /**\n * 唯一标识符\n */\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n /**\n * 图片与相邻节点的间距\n */\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n/**\n * 富文本的字符类型\n */\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n /**\n * 唯一id\n */\n id?: string;\n /**\n * 背景的展示模式,支持以下属性\n * always: 一直显示\n * hover: 鼠标hover时显示\n * never: 不显示\n */\n backgroundShowMode?: 'always' | 'hover' | 'never';\n /**\n * 背景矩形填充颜色\n */\n backgroundFill?: boolean | IColor;\n /**\n * 背景矩形填充透明度\n */\n backgroundFillOpacity?: number;\n /**\n * 背景矩形边框颜色\n */\n backgroundStroke?: boolean | IColor;\n /**\n * 背景矩形边框透明度\n */\n backgroundStrokeOpacity?: number;\n /**\n * 背景矩形圆角\n */\n backgroundRadius?: number;\n /**\n * 背景矩形的宽度\n */\n backgroundWidth?: number;\n /**\n * 背景矩形的高度\n */\n backgroundHeight?: number;\n\n // lineHeight?: number;\n /**\n * 文字对齐方式\n * left, right, center\n */\n textAlign?: CanvasTextAlign;\n /**\n * 文字基线\n * top, middle, bottom\n */\n textBaseline?: CanvasTextBaseline;\n /**\n * 文字方向\n * horizontal, vertical\n */\n direction?: RichTextLayoutDirectionType;\n /**\n * 图片与相邻节点的间距\n */\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawEllipsis: boolean | string,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: (ellipsis: string) => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n cliped?: boolean;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic/richText.ts"],"names":[],"mappings":"","file":"richText.js","sourcesContent":["import type { IColor } from '../color';\nimport type { IContext2d } from '../context';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\nimport type { IImage, IImageGraphicAttribute } from './image';\nimport type { ITextGraphicAttribute } from './text';\n\nexport type IRichTextEditOptionsType = {\n placeholder?: string;\n placeholderColor?: string;\n placeholderFontSize?: number;\n placeholderFontFamily?: string;\n // 是否将placeholder同步到textConfig中\n syncPlaceholderToTextConfig?: boolean;\n // 即使是空文本,是否也保持高度\n keepHeightWhileEmpty?: boolean;\n // 是否在输入的时候展示包围框,不传默认是false,可以传入颜色\n boundsStrokeWhenInput?: string;\n stopPropagation?: boolean;\n};\n\nexport type IRichTextAttribute = {\n /**\n * 富文本的总宽度\n */\n width: number;\n /**\n * 富文本的总高度\n */\n height: number;\n /**\n * 是否可编辑\n */\n editable: boolean;\n /**\n * 测量ascent和descent的模式,预览的时候actual比较合适,而如果需要编辑的话,font比较合适\n */\n ascentDescentMode?: 'actual' | 'font';\n /**\n * 富文本的编辑配置\n */\n editOptions: IRichTextEditOptionsType | null;\n /**\n * 文本超长的时候是否显示省略字符串\n * 1. boolean类型,true 表示将截断后的省略字符串设置为..., false 表示不显示省略字符串\n * 2. string类型,表示显示省略字符串,并将省略字符串设置为指定的值\n */\n ellipsis: boolean | string;\n /**\n * 文字换行类型\n */\n wordBreak: RichTextWordBreak;\n /**\n * 文字垂直方向\n */\n verticalDirection: RichTextVerticalDirection;\n /**\n * 富文本的最大高度,超过这个高度根据ellipsis的配置展示省略字符串或者直接截断\n */\n maxHeight: number;\n /**\n * 富文本的最大宽度,超过这个宽度根据ellipsis的配置展示省略字符串或者直接截断\n */\n maxWidth: number;\n /**\n * 文字对齐方式\n */\n textAlign: RichTextGlobalAlignType;\n /**\n * 文字基线\n */\n textBaseline: RichTextGlobalBaselineType;\n /**\n * 富文本的布局方向\n */\n layoutDirection: RichTextLayoutDirectionType;\n /**\n * 富文本的内容配置\n */\n textConfig: IRichTextCharacter[];\n /**\n * 不自动换行,仅当用户设置了换行符的时候才换行\n */\n disableAutoWrapLine: boolean;\n /**\n * 是否强制单行显示\n */\n singleLine: boolean;\n};\n\nexport type IRichTextGraphicAttribute = Partial<IGraphicAttribute & ITextGraphicAttribute> &\n Partial<IRichTextAttribute>;\n\nexport type RichTextWordBreak = 'break-word' | 'break-all';\nexport type RichTextVerticalDirection = 'top' | 'middle' | 'bottom';\nexport type RichTextGlobalAlignType = 'left' | 'right' | 'center';\nexport type RichTextGlobalBaselineType = 'top' | 'middle' | 'bottom';\nexport type RichTextLayoutDirectionType = 'horizontal' | 'vertical';\nexport type RichTextFontStyle = 'normal' | 'italic' | 'oblique';\nexport type RichTextTextDecoration = 'none' | 'underline' | 'line-through';\n// export type RichTextTextAlign = 'left' | 'right' | 'center';\nexport type RichTextScript = 'normal' | 'sub' | 'super';\n\nexport type IRichTextBasicCharacter = {\n /**\n * 行高\n */\n lineHeight?: number | string;\n /**\n * 文字对齐方式\n * left, right, center\n */\n textAlign?: CanvasTextAlign;\n /**\n * 文字基线\n */\n textBaseline?: CanvasTextBaseline;\n /**\n * 文字方向\n */\n direction?: RichTextLayoutDirectionType;\n};\n\n/**\n * 富文本段落为文本类型时候的配置\n */\nexport type IRichTextParagraphCharacter = IRichTextBasicCharacter & {\n /**\n * 文本内容\n */\n text: string | number;\n /**\n * 富文本片段的字体大小\n */\n fontSize?: number;\n /**\n * 富文本片段的字体类型\n */\n fontFamily?: string;\n /**\n * 富文本片段的文字颜色\n */\n fill?: IColor | boolean;\n /**\n * 富文本片段的文字描边颜色\n */\n stroke?: IColor | boolean;\n /**\n * 富文本片段的文字字重\n */\n fontWeight?: string;\n /**\n * 富文本片段的文字描边宽度\n */\n lineWidth?: number;\n // lineHeight?: number;\n /**\n * 富文本片段的文字斜体设置,支持以下属性\n * normal, italic, oblique\n */\n fontStyle?: RichTextFontStyle;\n /**\n * 富文本片段的文字中划线设置,支持以下属性\n * none, underline, line-through\n */\n textDecoration?: RichTextTextDecoration;\n // textAlign?: RichTextTextAlign; // left, right, center\n script?: RichTextScript; // normal, sub, super\n /**\n * 富文本片段的文字下划线设置,是否显示下划线\n */\n underline?: boolean;\n /**\n * 富文本片段的文字中划线设置,是否显示中划线\n */\n lineThrough?: boolean;\n /**\n * 富文本片段的透明度\n */\n opacity?: number;\n /**\n * 富文本片段的文字填充透明度\n */\n fillOpacity?: number;\n /**\n * 富文本片段的文字描边透明度\n */\n strokeOpacity?: number;\n // 仅支持纯色背景\n background?: string;\n // 背景透明度\n backgroundOpacity?: number;\n // direction?: RichTextLayoutDirectionType;\n};\n\nexport type IRichTextImageCharacter = IRichTextBasicCharacter & {\n /**\n * 设置图片的内容,\n * 支持三种格式:\n * 1. 图片的url\n * 2. 图片的Image对象\n * 3. 图片的Canvas对象\n */\n image: string | HTMLImageElement | HTMLCanvasElement;\n /**\n * 图片的宽度\n */\n width: number;\n /**\n * 图片的高度\n */\n height: number;\n\n // hover相关属性\n // backgroundShow?: boolean; // 是否显示background\n /**\n * 背景的展示模式,支持以下属性\n * always: 一直显示\n * hover: 鼠标hover时显示\n */\n backgroundShowMode?: 'always' | 'hover';\n /**\n * 背景矩形填充颜色\n */\n backgroundFill?: boolean | IColor;\n /**\n * 背景矩形填充透明度\n */\n backgroundFillOpacity?: number;\n /**\n * 背景矩形边框颜色\n */\n backgroundStroke?: boolean | IColor;\n /**\n * 背景矩形边框透明度\n */\n backgroundStrokeOpacity?: number;\n /**\n * 背景矩形圆角\n */\n backgroundRadius?: number;\n // background size 同时控制了该icon的响应范围\n /**\n * 背景矩形的宽度\n */\n backgroundWidth?: number;\n /**\n * 背景矩形的高度\n */\n backgroundHeight?: number;\n\n /**\n * 唯一标识符\n */\n id?: string;\n\n // lineHeight?: number;\n // textAlign?: RichTextTextAlign; // left, right, center\n // direction?: RichTextLayoutDirectionType;\n /**\n * 图片与相邻节点的间距\n */\n margin?: number | number[];\n\n funcType?: string;\n hoverImage?: string | HTMLImageElement | HTMLCanvasElement;\n};\n/**\n * 富文本的字符类型\n */\nexport type IRichTextCharacter = IRichTextParagraphCharacter | IRichTextImageCharacter;\n\nexport type IRichTextIconGraphicAttribute = IImageGraphicAttribute & {\n /**\n * 唯一id\n */\n id?: string;\n /**\n * 背景的展示模式,支持以下属性\n * always: 一直显示\n * hover: 鼠标hover时显示\n * never: 不显示\n */\n backgroundShowMode?: 'always' | 'hover' | 'never';\n /**\n * 背景矩形填充颜色\n */\n backgroundFill?: boolean | IColor;\n /**\n * 背景矩形填充透明度\n */\n backgroundFillOpacity?: number;\n /**\n * 背景矩形边框颜色\n */\n backgroundStroke?: boolean | IColor;\n /**\n * 背景矩形边框透明度\n */\n backgroundStrokeOpacity?: number;\n /**\n * 背景矩形圆角\n */\n backgroundRadius?: number;\n /**\n * 背景矩形的宽度\n */\n backgroundWidth?: number;\n /**\n * 背景矩形的高度\n */\n backgroundHeight?: number;\n\n // lineHeight?: number;\n /**\n * 文字对齐方式\n * left, right, center\n */\n textAlign?: CanvasTextAlign;\n /**\n * 文字基线\n * top, middle, bottom\n */\n textBaseline?: CanvasTextBaseline;\n /**\n * 文字方向\n * horizontal, vertical\n */\n direction?: RichTextLayoutDirectionType;\n /**\n * 图片与相邻节点的间距\n */\n margin?: number | number[];\n\n // backgroundShow?: boolean;\n};\n\nexport interface IRichTextParagraph {\n text: string;\n ascent: number;\n descent: number;\n width: number;\n height: number;\n lineHeight: number;\n fontSize: number;\n length: number;\n newLine: boolean;\n character: IRichTextParagraphCharacter;\n left: number;\n top: number;\n direction?: 'horizontal' | 'vertical';\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n updateWidth: () => void;\n draw: (ctx: IContext2d, baseline: number, deltaLeft: number, isLineFirst: boolean, textAlign: string) => void;\n getWidthWithEllips: (direction: string) => number;\n}\n\nexport interface IRichTextLine {\n left: number;\n top: number;\n width: number;\n height: number;\n baseline: number;\n ascent: number;\n descent: number;\n paragraphs: (IRichTextParagraph | IRichTextIcon)[];\n actualWidth: number;\n blankWidth: number;\n textAlign: string;\n direction: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n x: string;\n y: string;\n };\n draw: (\n ctx: IContext2d,\n lastLine: boolean,\n x: number,\n y: number,\n drawEllipsis: boolean | string,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => void;\n getWidthWithEllips: (ellipsis: string) => number;\n}\n\nexport interface IRichTextFrame {\n left: number;\n top: number;\n bottom: number;\n right: number;\n width: number;\n height: number;\n actualHeight: number;\n ellipsis: boolean | string;\n wordBreak: 'break-word' | 'break-all';\n verticalDirection: 'top' | 'middle' | 'bottom';\n lines: IRichTextLine[];\n globalAlign: 'left' | 'center' | 'right' | 'start' | 'end';\n globalBaseline: 'top' | 'middle' | 'bottom';\n layoutDirection: 'horizontal' | 'vertical';\n directionKey: {\n width: string;\n height: string;\n left: string;\n top: string;\n bottom: string;\n };\n isWidthMax: boolean;\n isHeightMax: boolean;\n singleLine: boolean;\n icons: Map<string, IRichTextIcon>;\n draw: (\n ctx: IContext2d,\n drawIcon: (icon: IRichTextIcon, context: IContext2d, x: number, y: number, baseline: number) => void\n ) => boolean;\n getActualSize: () => {\n width: number;\n height: number;\n };\n getRawActualSize: () => {\n width: number;\n height: number;\n };\n getActualSizeWidthEllipsis: () => {\n width: number;\n height: number;\n };\n}\n\nexport interface IRichText extends IGraphic<IRichTextGraphicAttribute> {\n getFrameCache: () => IRichTextFrame;\n cliped?: boolean;\n}\n\nexport interface IRichTextIcon extends IImage {\n attribute: IRichTextIconGraphicAttribute;\n richtextId?: string;\n globalX?: number;\n globalY?: number;\n\n _x: number;\n _y: number;\n _hovered: boolean;\n _marginArray: [number, number, number, number];\n\n setHoverState: (hovered: boolean) => void;\n}\n"]}
@@ -119,6 +119,7 @@ export type IGraphicStyle = ILayout & IFillStyle & IStrokeStyle & IPickStyle & {
119
119
  shadowGraphic?: IGraphic | undefined;
120
120
  backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
121
121
  backgroundFit: boolean;
122
+ backgroundKeepAspectRatio: boolean;
122
123
  backgroundScale: number;
123
124
  backgroundOffsetX: number;
124
125
  backgroundOffsetY: number;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget, ITimeline } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\n\ntype IStrokeSeg = {\n /**\n * 百分比\n */\n start: number;\n /**\n * 百分比\n * end和length二选一\n */\n end: number;\n /**\n * 像素长度\n */\n length: number;\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph'\n | string;\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n /**\n * x坐标\n */\n x: number;\n /**\n * y坐标\n */\n y: number;\n /**\n * z坐标\n */\n z: number;\n /**\n * x方向偏移量\n */\n dx: number;\n /**\n * y方向偏移量\n */\n dy: number;\n /**\n * z方向偏移量\n */\n dz: number;\n /**\n * x方向的滚动值\n */\n scrollX: number;\n /**\n * y方向的滚动值\n */\n scrollY: number;\n /**\n * x方向的缩放值\n */\n scaleX: number;\n /**\n * y方向的缩放值\n */\n scaleY: number;\n /**\n * z方向的缩放值\n */\n scaleZ: number;\n /**\n * 绕z轴的转角,即xy平面上的旋转角度\n */\n angle: number;\n /**\n * 绕x轴的转角\n */\n alpha: number;\n /**\n * 绕y轴的转角\n */\n beta: number;\n /**\n * 应用缩放的中心\n */\n scaleCenter: [number | string, number | string];\n /**\n * 基于AABB的锚点位置,用于简单的定位某些path\n */\n anchor: [number | string, number | string];\n /**\n * 3d的锚点位置\n */\n anchor3d: [number | string, number | string, number] | [number | string, number | string];\n /**\n * 处理矩阵,在正常计算完变换矩阵之后,会将该矩阵乘到变换矩阵上得到最终的变换矩阵\n */\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n /**\n * 图形的填充透明度\n */\n fillOpacity: number;\n /**\n * 图形模糊效果程度\n */\n shadowBlur: number;\n /**\n * 图形的阴影颜色\n */\n shadowColor: string;\n /**\n * 阴影水平偏移距离\n */\n shadowOffsetX: number;\n /**\n * 阴影垂直偏移距离\n */\n shadowOffsetY: number;\n /**\n * 图形的填充颜色\n */\n fill: IFillType;\n};\n\nexport type ILayout = {\n /**\n * 设置对齐方式\n */\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n /**\n * 边距离边缘的距离\n */\n distance: number | string;\n /**\n * 是否显示边框,默认是不显示的\n */\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n /**\n * 外部边框的样式配置,默认不展示外部边框\n */\n outerBorder: Partial<IBorderStyle>;\n /**\n * 内部边框的样式配置\n */\n innerBorder: Partial<IBorderStyle>;\n /**\n * 描边的透明度\n */\n strokeOpacity: number;\n /**\n * 设置线条虚线样式的属性,它通过定义实线和空白的交替长度来创建虚线效果\n */\n lineDash: number[];\n\n /**\n * 设置虚线样式的起始偏移量\n */\n lineDashOffset: number;\n\n /**\n * 设置线条的宽度\n */\n lineWidth: number;\n\n /**\n * 设置线条末端的样式\n */\n lineCap: CanvasLineCap;\n\n /**\n * 设置线条拐角的样式\n */\n lineJoin: CanvasLineJoin;\n\n /**\n * 设置线条拐角处的斜接限制\n */\n miterLimit: number;\n /**\n * 描边的boundsBuffer,用于控制bounds的buffer\n */\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n /**\n * 连接,取零或者断开\n */\n connectedType: 'connect' | 'none';\n /**\n * 连接线的样式配置\n */\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n /**\n * 容器的宽度\n */\n width: number;\n /**\n * 容器的高度\n */\n height: number;\n /**\n * 容器的样式设置\n */\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n /**\n * 全局唯一的id\n */\n id?: string;\n /**\n * 容器元素的id或者dom元素\n */\n container: string | HTMLElement | null;\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 是否支持事件冒泡\n */\n pointerEvents?: boolean | string;\n /**\n * 可穿透的事件列表\n * @since 0.21.2\n */\n penetrateEventList?: string[];\n /**\n * 定位类型\n * 'position' - 根据挂载图形节点的坐标也就是x,y进行定位\n * 'boundsLeftTop' - 定位到挂载图形节点bounds的左上角\n * 'left' - 定位到挂载图形节点bounds 的左侧\n * 'right' - 定位到挂载图形节点bounds 的右侧\n * 'bottom' - 定位到挂载图形节点bounds 的底部\n * 'top' - 定位到挂载图形节点bounds 的顶部\n * 'center' - 定位到挂载图形节点bounds 的中心\n * 'top-left' - 定位到挂载图形节点bounds 的左上角\n * 'top-right' - 定位到挂载图形节点bounds 的右上角\n * 'bottom-left' - 定位到挂载图形节点bounds 的左下角\n * 'bottom-right' - 定位到挂载图形节点bounds 的右下角\n */\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n /**\n * 强制设置的bounds宽度,主要用于使用html或者react展示图形的时候,设置一个固定的宽度\n */\n forceBoundsWidth: number | (() => number) | undefined;\n /**\n * 强制设置的bounds高度,主要用于使用html或者react展示图形的时候,设置一个固定的高度\n */\n forceBoundsHeight: number | (() => number) | undefined;\n /**\n * 透明度,会同时影响填充和描边\n */\n opacity: number;\n /**\n * 影子节点\n */\n shadowGraphic?: IGraphic | undefined;\n /**\n * 背景填充模式(与具体图元有关)\n */\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n /**\n * 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n */\n backgroundFit: boolean;\n\n /**\n * 背景图缩放,只在no-repeat的时候生效\n */\n backgroundScale: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetX: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetY: number;\n /**\n * 背景图是否裁切\n */\n backgroundClip: boolean;\n /**\n * 背景圆角半径\n */\n backgroundCornerRadius: number | number[];\n /**\n * 背景透明度\n */\n backgroundOpacity: number;\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n // 纹理是否自动做动画\n autoAnimateTexture: boolean;\n // 如果做动画的话,这里代表ratio\n textureRatio: number;\n textureOptions: any;\n background:\n | IBackgroundType\n | {\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n background: IBackgroundType;\n /**\n * 背景的x方向偏移量\n */\n dx?: number;\n /**\n * 背景的y方向偏移量\n */\n dy?: number;\n /**\n * 背景宽度\n */\n width?: number;\n /**\n * 背景高度\n */\n height?: number;\n /**\n * 背景的x坐标\n */\n x?: number;\n /**\n * 背景的y坐标\n */\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n /**\n * 纹理的类型\n */\n texture: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor: string;\n /**\n * 纹理的大小\n */\n textureSize: number;\n /**\n * 纹理的间隙\n */\n texturePadding: number;\n\n blur: number;\n /**\n * 设置图形对应的鼠标样式\n */\n cursor: Cursor | null;\n filter: string;\n renderStyle?: 'default' | 'rough' | any;\n /**\n * HTML的dom或者string\n */\n html:\n | ({\n /**\n * dom字符串或者dom\n */\n dom: string | HTMLElement;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n /**\n * 使用react元素渲染内容\n */\n react:\n | ({\n /**\n * react场景节点\n */\n element: any;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n /**\n * 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n */\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n /**\n * 包围盒的padding\n */\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise' | 'empty';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n /**\n * 分组下的层级,层级越小越先绘制\n */\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n /**\n * 全局范围的层级,设置了这个属性的图形,会提取到交互层进行渲染\n */\n globalZIndex: number;\n /**\n * canvas 的合成方式\n */\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n /**\n * 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n */\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n /**\n * 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n */\n fillStrokeOrder: number;\n /**\n * @since 0.20.15\n * 保持stroke的scale,默认为false,为true的话stroke显示的宽度会随着scale变化\n */\n keepStrokeScale: boolean;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n timeline?: ITimeline;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
1
+ {"version":3,"sources":["../src/interface/graphic.ts"],"names":[],"mappings":"","file":"graphic.js","sourcesContent":["import type { IAABBBounds, IMatrix, IPointLike, IPoint, BoundsAnchorType, IOBBBounds } from '@visactor/vutils';\nimport type { IAnimate, IStep, EasingType, IAnimateTarget, ITimeline } from './animate';\nimport type { IColor } from './color';\nimport type { IGroup } from './graphic/group';\nimport type { IShadowRoot } from './graphic/shadow-root';\nimport type { ILayer } from './layer';\nimport type { INode } from './node-tree';\nimport type { ICustomPath2D } from './path';\nimport type { IStage } from './stage';\nimport type { IGlyphGraphicAttribute } from './graphic/glyph';\nimport type { IContainPointMode } from '../common/enums';\nimport type { IFace3d } from './graphic/face3d';\nimport type { IPickerService } from './picker';\n\ntype IStrokeSeg = {\n /**\n * 百分比\n */\n start: number;\n /**\n * 百分比\n * end和length二选一\n */\n end: number;\n /**\n * 像素长度\n */\n length: number;\n};\n\n// TODO 最后加一个any\nexport type GraphicType =\n | 'area'\n | 'circle'\n | 'ellipse'\n | 'line'\n | 'rect'\n | 'rect3d'\n | 'path'\n | 'richtext'\n | 'text'\n | 'arc'\n | 'arc3d'\n | 'image'\n | 'symbol'\n | 'group'\n | 'shadowroot'\n | 'polygon'\n | 'pyramid3d'\n | 'glyph'\n | string;\n\n// Cursor style\n// See: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor\nexport type Cursor =\n | 'auto'\n | 'default'\n | 'none'\n | 'context-menu'\n | 'help'\n | 'pointer'\n | 'progress'\n | 'wait'\n | 'cell'\n | 'crosshair'\n | 'text'\n | 'vertical-text'\n | 'alias'\n | 'copy'\n | 'move'\n | 'no-drop'\n | 'not-allowed'\n | 'grab'\n | 'grabbing'\n | 'all-scroll'\n | 'col-resize'\n | 'row-resize'\n | 'n-resize'\n | 'e-resize'\n | 's-resize'\n | 'w-resize'\n | 'ne-resize'\n | 'nw-resize'\n | 'se-resize'\n | 'sw-resize'\n | 'ew-resize'\n | 'ns-resize'\n | 'nesw-resize'\n | 'nwse-resize'\n | 'zoom-in'\n | 'zoom-out';\n\nexport type ITransform = {\n /**\n * x坐标\n */\n x: number;\n /**\n * y坐标\n */\n y: number;\n /**\n * z坐标\n */\n z: number;\n /**\n * x方向偏移量\n */\n dx: number;\n /**\n * y方向偏移量\n */\n dy: number;\n /**\n * z方向偏移量\n */\n dz: number;\n /**\n * x方向的滚动值\n */\n scrollX: number;\n /**\n * y方向的滚动值\n */\n scrollY: number;\n /**\n * x方向的缩放值\n */\n scaleX: number;\n /**\n * y方向的缩放值\n */\n scaleY: number;\n /**\n * z方向的缩放值\n */\n scaleZ: number;\n /**\n * 绕z轴的转角,即xy平面上的旋转角度\n */\n angle: number;\n /**\n * 绕x轴的转角\n */\n alpha: number;\n /**\n * 绕y轴的转角\n */\n beta: number;\n /**\n * 应用缩放的中心\n */\n scaleCenter: [number | string, number | string];\n /**\n * 基于AABB的锚点位置,用于简单的定位某些path\n */\n anchor: [number | string, number | string];\n /**\n * 3d的锚点位置\n */\n anchor3d: [number | string, number | string, number] | [number | string, number | string];\n /**\n * 处理矩阵,在正常计算完变换矩阵之后,会将该矩阵乘到变换矩阵上得到最终的变换矩阵\n */\n postMatrix: IMatrix;\n};\n\nexport type IFillType = boolean | string | IColor;\nexport type IFillStyle = {\n /**\n * 图形的填充透明度\n */\n fillOpacity: number;\n /**\n * 图形模糊效果程度\n */\n shadowBlur: number;\n /**\n * 图形的阴影颜色\n */\n shadowColor: string;\n /**\n * 阴影水平偏移距离\n */\n shadowOffsetX: number;\n /**\n * 阴影垂直偏移距离\n */\n shadowOffsetY: number;\n /**\n * 图形的填充颜色\n */\n fill: IFillType;\n};\n\nexport type ILayout = {\n /**\n * 设置对齐方式\n */\n alignSelf: 'auto' | 'flex-start' | 'flex-end' | 'center';\n};\n\nexport type IBorderStyle = Omit<IStrokeStyle, 'outerBorder' | 'innerBorder'> & {\n /**\n * 边距离边缘的距离\n */\n distance: number | string;\n /**\n * 是否显示边框,默认是不显示的\n */\n visible?: boolean;\n};\n\nexport type IStrokeType = boolean | string | IColor | null;\nexport type IStrokeStyle = {\n /**\n * 外部边框的样式配置,默认不展示外部边框\n */\n outerBorder: Partial<IBorderStyle>;\n /**\n * 内部边框的样式配置\n */\n innerBorder: Partial<IBorderStyle>;\n /**\n * 描边的透明度\n */\n strokeOpacity: number;\n /**\n * 设置线条虚线样式的属性,它通过定义实线和空白的交替长度来创建虚线效果\n */\n lineDash: number[];\n\n /**\n * 设置虚线样式的起始偏移量\n */\n lineDashOffset: number;\n\n /**\n * 设置线条的宽度\n */\n lineWidth: number;\n\n /**\n * 设置线条末端的样式\n */\n lineCap: CanvasLineCap;\n\n /**\n * 设置线条拐角的样式\n */\n lineJoin: CanvasLineJoin;\n\n /**\n * 设置线条拐角处的斜接限制\n */\n miterLimit: number;\n /**\n * 描边的boundsBuffer,用于控制bounds的buffer\n */\n strokeBoundsBuffer: number;\n /**\n * stroke - true 全描边\n * stroke - false 不描边\n * stroke 为数值类型,适用于rect\\arc等图形,用于配置部分描边的场景,其中\n *\n * 0b00000 - 不描边\n * 0b000001 - top\n * 0b000010 - right\n * 0b000100 - bottom\n * 0b001000 - left\n * 相应的:\n * 0b000011 - top + right\n * 0b000111 - top + right + bottom\n * 0b001111 - 全描边\n *\n * stroke - boolean[],适用于rect\\arc等图形,用于配置部分描边的场景\n */\n stroke: IStrokeType[] | IStrokeType;\n};\n\ntype TextureType = 'circle' | 'diamond' | 'rect' | 'vertical-line' | 'horizontal-line' | 'bias-lr' | 'bias-rl' | 'grid';\n\nexport type IConnectedStyle = {\n /**\n * 连接,取零或者断开\n */\n connectedType: 'connect' | 'none';\n /**\n * 连接线的样式配置\n */\n connectedStyle: {\n stroke: IStrokeStyle['stroke'];\n strokeOpacity: IStrokeStyle['strokeOpacity'];\n lineDash: IStrokeStyle['lineDash'];\n lineDashOffset: IStrokeStyle['lineDashOffset'];\n lineCap: IStrokeStyle['lineCap'];\n lineJoin: IStrokeStyle['lineJoin'];\n lineWidth: IStrokeStyle['lineWidth'];\n fill: IFillStyle['fill'];\n fillOpacity: IFillStyle['fillOpacity'];\n };\n connectedX: number;\n connectedY: number;\n};\n\nexport type IBackgroundConfig = {\n stroke?: string | boolean;\n fill?: string | boolean;\n lineWidth?: number;\n cornerRadius?: number;\n expandX?: number;\n expandY?: number;\n};\n\ntype IBackgroundType = string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig;\n\nexport interface SimpleDomStyleOptions {\n /**\n * 容器的宽度\n */\n width: number;\n /**\n * 容器的高度\n */\n height: number;\n /**\n * 容器的样式设置\n */\n style?:\n | string\n | Record<string, any>\n | ((\n pos: { top: number; left: number; width: number; height: number },\n graphic: IGraphic,\n wrapContainer: HTMLElement\n ) => Record<string, any>); // 容器的样式\n}\n\nexport interface CommonDomOptions {\n /**\n * 全局唯一的id\n */\n id?: string;\n /**\n * 容器元素的id或者dom元素\n */\n container: string | HTMLElement | null;\n /**\n * 是否显示\n */\n visible?: boolean;\n /**\n * 是否支持事件冒泡\n */\n pointerEvents?: boolean | string;\n /**\n * 可穿透的事件列表\n * @since 0.21.2\n */\n penetrateEventList?: string[];\n /**\n * 定位类型\n * 'position' - 根据挂载图形节点的坐标也就是x,y进行定位\n * 'boundsLeftTop' - 定位到挂载图形节点bounds的左上角\n * 'left' - 定位到挂载图形节点bounds 的左侧\n * 'right' - 定位到挂载图形节点bounds 的右侧\n * 'bottom' - 定位到挂载图形节点bounds 的底部\n * 'top' - 定位到挂载图形节点bounds 的顶部\n * 'center' - 定位到挂载图形节点bounds 的中心\n * 'top-left' - 定位到挂载图形节点bounds 的左上角\n * 'top-right' - 定位到挂载图形节点bounds 的右上角\n * 'bottom-left' - 定位到挂载图形节点bounds 的左下角\n * 'bottom-right' - 定位到挂载图形节点bounds 的右下角\n */\n anchorType?: 'position' | 'boundsLeftTop' | BoundsAnchorType;\n}\n\nexport type IGraphicStyle = ILayout &\n IFillStyle &\n IStrokeStyle &\n IPickStyle & {\n /**\n * 强制设置的bounds宽度,主要用于使用html或者react展示图形的时候,设置一个固定的宽度\n */\n forceBoundsWidth: number | (() => number) | undefined;\n /**\n * 强制设置的bounds高度,主要用于使用html或者react展示图形的时候,设置一个固定的高度\n */\n forceBoundsHeight: number | (() => number) | undefined;\n /**\n * 透明度,会同时影响填充和描边\n */\n opacity: number;\n /**\n * 影子节点\n */\n shadowGraphic?: IGraphic | undefined;\n /**\n * 背景填充模式(与具体图元有关)\n */\n backgroundMode: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';\n /**\n * 是否正好填充,只在repeat-x或者repeat-y以及no-repeat的时候生效\n */\n backgroundFit: boolean;\n /**\n * 是否保持背景图的宽高比\n */\n backgroundKeepAspectRatio: boolean;\n /**\n * 背景图缩放,只在no-repeat的时候生效\n */\n backgroundScale: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetX: number;\n /**\n * 背景图偏移,只在no-repeat的时候生效\n */\n backgroundOffsetY: number;\n /**\n * 背景图是否裁切,是否调用clip避免绘制到图元外部\n */\n backgroundClip: boolean;\n /**\n * 背景圆角半径\n */\n backgroundCornerRadius: number | number[];\n /**\n * 背景透明度\n */\n backgroundOpacity: number;\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n // 纹理是否自动做动画\n autoAnimateTexture: boolean;\n // 如果做动画的话,这里代表ratio\n textureRatio: number;\n textureOptions: any;\n background:\n | IBackgroundType\n | {\n /**\n * 背景,支持颜色字符串、html image元素、html canvas元素\n */\n background: IBackgroundType;\n /**\n * 背景的x方向偏移量\n */\n dx?: number;\n /**\n * 背景的y方向偏移量\n */\n dy?: number;\n /**\n * 背景宽度\n */\n width?: number;\n /**\n * 背景高度\n */\n height?: number;\n /**\n * 背景的x坐标\n */\n x?: number;\n /**\n * 背景的y坐标\n */\n y?: number;\n }\n | null; // 背景,可以与fill同时存在\n /**\n * 纹理的类型\n */\n texture: TextureType | string;\n /**\n * 纹理的颜色\n */\n textureColor: string;\n /**\n * 纹理的大小\n */\n textureSize: number;\n /**\n * 纹理的间隙\n */\n texturePadding: number;\n\n blur: number;\n /**\n * 设置图形对应的鼠标样式\n */\n cursor: Cursor | null;\n filter: string;\n renderStyle?: 'default' | 'rough' | any;\n /**\n * HTML的dom或者string\n */\n html:\n | ({\n /**\n * dom字符串或者dom\n */\n dom: string | HTMLElement;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n /**\n * 使用react元素渲染内容\n */\n react:\n | ({\n /**\n * react场景节点\n */\n element: any;\n } & SimpleDomStyleOptions &\n CommonDomOptions)\n | null;\n };\n\nexport type IPickStyle = {\n /**\n * 给stroke模式的pick额外加的buffer,用于外界控制stroke区域的pick范围\n */\n pickStrokeBuffer: number;\n};\n\nexport type IDebugType = {\n _debug_bounds: boolean | ((c: any, g: any) => void);\n};\nexport type IGraphicAttribute = IDebugType &\n IGraphicStyle &\n ITransform & {\n /**\n * stroke百分比\n */\n strokeSeg: IStrokeSeg | null;\n /**\n * 包围盒的padding\n */\n boundsPadding: number | number[];\n /**\n * 选择模式,精确模式,粗糙模式(包围盒模式),自定义模式\n */\n pickMode: 'accurate' | 'imprecise' | 'custom';\n boundsMode: 'accurate' | 'imprecise' | 'empty';\n customPickShape: () => boolean | null;\n /**\n * 是否支持事件拾取,默认为 true。\n * @default true\n */\n pickable: boolean;\n /**\n * 是否支持fill拾取,默认为 true。\n * @experimental\n * @default true\n */\n fillPickable: boolean;\n /**\n * 是否支持stroke拾取,默认为 true。\n * @experimental\n * @default true\n */\n strokePickable: boolean;\n /**\n * 对于 group 节点,是否支持其子元素的事件拾取,默认为 true。\n * 如果 group `pickable` 关闭,`childrenPickable` 开启,那么 group 的子节点仍参与事件拾取\n * @default true\n */\n childrenPickable: boolean;\n /**\n * 元素是否可见。\n * @default true\n */\n visible: boolean;\n /**\n * 分组下的层级,层级越小越先绘制\n */\n zIndex: number;\n layout: any;\n /**\n * 是否隐藏元素(只是绘制的时候不绘制)\n */\n renderable: boolean;\n /**\n * 是否在3d中控制方向\n * false: 不控制方向\n * true: 始终控制方向朝摄像机\n */\n keepDirIn3d?: boolean;\n shadowRootIdx: number;\n shadowPickMode?: 'full' | 'graphic';\n /**\n * 全局范围的层级,设置了这个属性的图形,会提取到交互层进行渲染\n */\n globalZIndex: number;\n /**\n * canvas 的合成方式\n */\n globalCompositeOperation: CanvasRenderingContext2D['globalCompositeOperation'] | '';\n /**\n * 完全支持滚动 | 完全不支持滚动 | 支持x方向的滚动 | 支持y方向的滚动\n */\n overflow: 'scroll' | 'hidden' | 'scroll-x' | 'scroll-y';\n /**\n * 绘制fill和stroke的顺序,为0表示fill先绘制,1表示stroke先绘制\n */\n fillStrokeOrder: number;\n /**\n * @since 0.20.15\n * 保持stroke的scale,默认为false,为true的话stroke显示的宽度会随着scale变化\n */\n keepStrokeScale: boolean;\n };\n\nexport interface IGraphicJson<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>> {\n attribute: Partial<T>;\n _uid: number;\n type: string;\n name: string;\n children: IGraphicJson<T>[];\n}\n\n/** the context of setAttribute */\nexport type ISetAttributeContext = {\n /** type of setAttribute */\n type?: number;\n animationState?: {\n step?: IStep;\n isFirstFrameOfStep?: boolean;\n /** ratio of animation */\n ratio?: number;\n /** is animation end? */\n end?: boolean;\n };\n skipUpdateCallback?: boolean;\n};\n\nexport type IGraphicAnimateParams = {\n slience?: boolean;\n id?: number | string;\n timeline?: ITimeline;\n onStart?: () => void;\n onFrame?: (step: IStep, ratio: number) => void;\n onEnd?: () => void;\n onRemove?: () => void;\n interpolate?: (key: string, ratio: number, from: any, to: any, nextAttributes: any) => boolean;\n};\n\nexport interface IGraphic<T extends Partial<IGraphicAttribute> = Partial<IGraphicAttribute>>\n extends INode,\n IAnimateTarget {\n type?: GraphicType;\n numberType?: number;\n stage?: IStage;\n layer?: ILayer;\n shadowRoot?: IShadowRoot;\n glyphHost?: IGraphic<IGlyphGraphicAttribute>;\n backgroundImg?: boolean;\n attachedThemeGraphic?: IGraphic<any>;\n\n bindDom?: Map<\n string | HTMLElement,\n { container: HTMLElement | string; dom: HTMLElement | any; wrapGroup: HTMLDivElement | any; root?: any }\n >;\n\n valid: boolean;\n parent: IGroup | null;\n isContainer?: boolean;\n // 是否是3d模式(是否应用3d视角)\n in3dMode?: boolean;\n\n // 上次更新的stamp\n stamp?: number;\n animationBackUps?: {\n from: Record<string, any>;\n to: Record<string, any>;\n };\n\n attribute: Partial<T>;\n\n /** 用于实现morph动画场景,转换成bezier曲线渲染 */\n pathProxy?: ICustomPath2D | ((attrs: T) => ICustomPath2D);\n incremental?: number;\n incrementalAt?: number;\n\n /** 记录state对应的图形属性 */\n states?: Record<string, Partial<T>>;\n normalAttrs?: Partial<T>;\n stateProxy?: (stateName: string, targetStates?: string[]) => Partial<T>;\n findFace?: () => IFace3d;\n toggleState: (stateName: string, hasAnimation?: boolean) => void;\n removeState: (stateName: string, hasAnimation?: boolean) => void;\n clearStates: (hasAnimation?: boolean) => void;\n useStates: (states: string[], hasAnimation?: boolean) => void;\n addState: (stateName: string, keepCurrentStates?: boolean, hasAnimation?: boolean) => void;\n hasState: (stateName?: string) => boolean;\n getState: (stateName: string) => Partial<T>;\n onBeforeAttributeUpdate?: (\n val: any,\n attributes: Partial<T>,\n key: null | string | string[],\n context?: ISetAttributeContext\n ) => T | undefined;\n applyStateAttrs: (attrs: Partial<T>, stateNames: string[], hasAnimation?: boolean, isClear?: boolean) => void;\n updateNormalAttrs: (stateAttrs: Partial<T>) => void;\n\n // get\n readonly AABBBounds: IAABBBounds; // 用于获取当前节点的AABB包围盒\n readonly OBBBounds: IOBBBounds; // 获取OBB包围盒,旋转防重叠需要用\n readonly globalAABBBounds: IAABBBounds; // 全局AABB包围盒\n readonly transMatrix: IMatrix; // 变换矩阵,动态计算\n readonly globalTransMatrix: IMatrix; // 变换矩阵,动态计算\n\n getOffsetXY: (attr?: ITransform) => IPoint;\n\n // function\n containsPoint: (x: number, y: number, mode?: IContainPointMode, picker?: IPickerService) => boolean;\n\n setMode: (mode: '3d' | '2d') => void;\n isValid: () => boolean;\n\n // TODO: transform API\n // 基于当前transform的变换,普通用户尽量别用,拿捏不住的~\n translate: (x: number, y: number) => this;\n translateTo: (x: number, y: number) => this;\n scale: (scaleX: number, scaleY: number, scaleCenter?: IPointLike) => this;\n scaleTo: (scaleX: number, scaleY: number) => this;\n rotate: (angle: number, rotateCenter?: IPointLike) => this;\n rotateTo: (angle: number) => this;\n skewTo: (b: number, c: number) => this;\n addUpdateBoundTag: () => void;\n addUpdateShapeAndBoundsTag: () => void;\n addUpdateLayoutTag: () => void;\n\n update: (d?: { bounds: boolean; trans: boolean }) => void;\n\n // animate\n animate: (params?: IGraphicAnimateParams) => IAnimate;\n\n // 语法糖,可有可无,有的为了首屏性能考虑做成get方法,有的由外界直接托管,内部不赋值\n name?: string;\n\n // 供render处理shape缓存tag\n shouldUpdateShape: () => boolean;\n clearUpdateShapeTag: () => void;\n\n // // 供render缓存shape\n // cacheShape?: ICustomPath2D;\n // // 线段使用的path2D\n // cacheLine?: ISegPath2D | ISegPath2D[];\n // // 面积图使用的path2D\n // cacheArea?: IAreaCacheItem | IAreaCacheItem[];\n\n setAttributes: (params: Partial<T>, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n initAttributes: (params: Partial<T>) => void;\n\n setAttribute: (key: string, value: any, forceUpdateTag?: boolean, context?: ISetAttributeContext) => void;\n\n setStage: (stage?: IStage, layer?: ILayer) => void;\n onSetStage: (cb: (g: IGraphic, stage: IStage) => void) => void;\n\n shouldUpdateAABBBounds: () => boolean;\n shouldSelfChangeUpdateAABBBounds: () => boolean;\n shouldUpdateGlobalMatrix: () => boolean;\n\n addUpdatePositionTag: () => void;\n addUpdateGlobalPositionTag: () => void;\n\n attachShadow: () => IShadowRoot;\n detachShadow: () => void;\n\n toJson: () => IGraphicJson;\n\n /** 创建pathProxy */\n createPathProxy: (path?: string) => void;\n /** 将图形转换成CustomPath2D */\n toCustomPath?: () => ICustomPath2D;\n\n resources?: Map<\n string | HTMLImageElement | HTMLCanvasElement | IBackgroundConfig,\n { state: 'init' | 'loading' | 'success' | 'fail'; data?: HTMLImageElement | HTMLCanvasElement }\n >;\n imageLoadSuccess: (url: string, data: HTMLImageElement) => void;\n imageLoadFail: (url: string) => void;\n\n clone: () => IGraphic;\n stopAnimates: (stopChildren?: boolean) => void;\n getNoWorkAnimateAttr: () => Record<string, number>;\n getGraphicTheme: () => T;\n}\n\nexport interface IRoot extends IGraphic {\n pick: (x: number, y: number) => IGraphic;\n}\n\n/**\n * 动画配置\n */\nexport type IAnimateConfig = {\n duration?: number;\n easing?: EasingType;\n};\n\nexport type GraphicReleaseStatus = 'released' | 'willRelease';\n"]}
@@ -151,7 +151,8 @@ class EditModule {
151
151
  textAreaDom.addEventListener("focusout", this.handleFocusOut), application_1.application.global.addEventListener("keydown", this.handleKeyDown);
152
152
  }
153
153
  parseCompositionStr(configIdx) {
154
- const {textConfig: textConfig = []} = this.currRt.attribute, lastConfig = textConfig[configIdx];
154
+ var _a;
155
+ const {textConfig: textConfig = []} = this.currRt.attribute, lastConfig = null !== (_a = textConfig[configIdx]) && void 0 !== _a ? _a : {};
155
156
  textConfig.splice(configIdx, 1);
156
157
  const text = lastConfig.text, textList = text ? Array.from(text.toString()) : [];
157
158
  for (let i = 0; i < textList.length; i++) textConfig.splice(i + configIdx, 0, Object.assign(Object.assign({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/edit-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mDAAgD;AAmBhD,SAAgB,yBAAyB,CAAC,SAAoC;IAC5E,MAAM,EAAE,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,UAAU,GAAG,QAAQ,EAAE,UAAU,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;IAClG,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACvB,QAAQ,GAAG,EAAE,CAAC;KACf;IACD,OAAO;QACL,IAAI;QACJ,MAAM;QACN,QAAQ;QACR,UAAU;QACV,UAAU;KACJ,CAAC;AACX,CAAC;AAbD,8DAaC;AAQD,SAAgB,0BAA0B,CAAC,UAAgC,EAAE,WAAmB;IAC9F,IAAI,WAAW,GAAG,CAAC,EAAE;QACnB,OAAO,CAAC,CAAC;KACV;IAGD,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/C,IAAI,eAAe,GAAG,cAAc,CA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I,CAAC;QACtC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YACzB,IAAI,CAAC,WAAW,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QAEjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAC;IACzD,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAChE,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACtF,IAAI,CAAC,WAAW,CAAC,mBAAmB,CAAC,gBAAgB,EAAE,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAClF,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACnE,yBAAW,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACxE,CAAC;CACF;AAnRD,gCAmRC","file":"edit-module.js","sourcesContent":["import { application } from '../../application';\nimport type {\n IRichText,\n IRichTextCharacter,\n IRichTextGraphicAttribute,\n IRichTextParagraphCharacter\n} from '../../interface';\n\n// function getMaxConfigIndexIgnoreLinebreak(textConfig: IRichTextCharacter[]) {\n// let idx = 0;\n// for (let i = 0; i < textConfig.length; i++) {\n// const c = textConfig[i] as IRichTextParagraphCharacter;\n// if (c.text !== '\\n') {\n// idx++;\n// }\n// }\n// return Math.max(idx - 1, 0);\n// }\n\nexport function getDefaultCharacterConfig(attribute: IRichTextGraphicAttribute) {\n const { fill = 'black', stroke = false, fontWeight = 'normal', fontFamily = 'Arial' } = attribute;\n let { fontSize = 12 } = attribute;\n if (!isFinite(fontSize)) {\n fontSize = 12;\n }\n return {\n fill,\n stroke,\n fontSize,\n fontWeight,\n fontFamily\n } as any;\n}\n\n/**\n * 找到cursorIndex所在的textConfig的位置,给出的index就是要插入的准确位置\n * @param textConfig\n * @param cursorIndex\n * @returns\n */\nexport function findConfigIndexByCursorIdx(textConfig: IRichTextCharacter[], cursorIndex: number): number {\n if (cursorIndex < 0) {\n return 0;\n }\n\n // 排序找到对应的元素\n const intCursorIndex = Math.round(cursorIndex);\n let tempCursorIndex = intCursorIndex;\n // 跳过连续换行符中的第一个换行符\n let lineBreak = false;\n let configIdx = 0;\n for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {\n const c = textConfig[configIdx] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n tempCursorIndex -= Number(lineBreak);\n lineBreak = true;\n } else {\n tempCursorIndex--;\n lineBreak = false;\n }\n }\n // 说明过限了\n if (tempCursorIndex >= 0) {\n return textConfig.length;\n }\n configIdx -= 1;\n\n // 如果有换行,一定在换行符左边写\n if (cursorIndex > intCursorIndex && !lineBreak) {\n configIdx += 1;\n }\n return configIdx;\n}\n\n/**\n * 根据configIndex找到cursorIndex的位置,忽略单个换行符,连续换行符的时候只忽略第一个\n * @param textConfig\n * @param configIndex\n * @returns\n */\nexport function findCursorIdxByConfigIndex(textConfig: IRichTextCharacter[], configIndex: number): number {\n let cursorIndex = 0;\n if (configIndex < 0) {\n return -0.1;\n }\n // 仅有一个\\n,那不算\n // 如果有连续的\\n,那就少算一个\n let lastLineBreak = false;\n\n for (let i = 0; i <= configIndex && i < textConfig.length; i++) {\n const c = textConfig[i] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n cursorIndex += Number(lastLineBreak);\n lastLineBreak = true;\n } else {\n cursorIndex++;\n lastLineBreak = false;\n }\n }\n cursorIndex = Math.max(cursorIndex - 1, 0);\n\n // 超出区间了直接设置到尾部,configIndex超过区间,cursorIndex不会超过\n if (configIndex > textConfig.length - 1) {\n // 如果最后一行是一个换行符,那么就得是xx.9否则就是xx.1\n if ((textConfig[textConfig.length - 1] as any)?.text === '\\n') {\n return cursorIndex + 0.9;\n }\n return cursorIndex + 0.1;\n }\n\n // 如果是这个configIdx对应到的是单个换行的话,那么算到下一个字符上\n const lineBreak = (textConfig[configIndex] as any)?.text === '\\n';\n if (configIndex >= textConfig.length - 1 && lineBreak) {\n return cursorIndex + 1 - 0.1;\n }\n const singleLineBreak = lineBreak && (textConfig[configIndex - 1] as any)?.text !== '\\n';\n\n // 光标往左放\n cursorIndex -= 0.1;\n\n // 如果是单行,那么这一个换行符没有算字符,光标要往右放\n if (singleLineBreak) {\n cursorIndex += 0.2;\n }\n return cursorIndex;\n}\n\nexport class EditModule {\n container: HTMLElement;\n textAreaDom: HTMLTextAreaElement;\n currRt: IRichText;\n isComposing: boolean;\n composingConfigIdx: number;\n cursorIndex: number;\n selectionStartCursorIdx: number;\n // 输入的回调(composing的时候每次也会触发)\n onInputCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n // change的回调(composing确认才会触发)\n onChangeCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n onFocusInList: Array<() => void>;\n onFocusOutList: Array<() => void>;\n focusOutTimer: number;\n\n constructor(container?: HTMLElement) {\n this.container = container ?? document.body;\n\n const textAreaDom = document.createElement('textarea');\n textAreaDom.autocomplete = 'off';\n textAreaDom.innerText = '';\n this.applyStyle(textAreaDom);\n this.container.append(textAreaDom);\n this.textAreaDom = textAreaDom;\n this.isComposing = false;\n this.composingConfigIdx = -1;\n this.onInputCbList = [];\n this.onChangeCbList = [];\n this.onFocusInList = [];\n this.onFocusOutList = [];\n }\n\n onInput(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onInputCbList.push(cb);\n }\n\n onChange(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onChangeCbList.push(cb);\n }\n\n onFocusIn(cb: () => void) {\n this.onFocusInList.push(cb);\n }\n\n onFocusOut(cb: () => void) {\n this.onFocusOutList.push(cb);\n }\n\n applyStyle(textAreaDom: HTMLTextAreaElement) {\n textAreaDom.setAttribute(\n 'style',\n `width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;`\n );\n\n textAreaDom.addEventListener('input', this.handleInput);\n textAreaDom.addEventListener('compositionstart', this.handleCompositionStart);\n textAreaDom.addEventListener('compositionend', this.handleCompositionEnd);\n // 监听焦点\n textAreaDom.addEventListener('focusin', this.handleFocusIn);\n textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.addEventListener('keydown', this.handleKeyDown);\n }\n\n handleFocusIn = () => {\n // this.focusOutTimer && clearTimeout(this.focusOutTimer);\n // this.focusOutTimer = 0;\n // this.onFocusInList && this.onFocusInList.forEach(cb => cb());\n };\n handleFocusOut = () => {\n // 暂时注释,会导致非期待情况下的误关闭\n // // 延时触发,避免误关闭\n // this.focusOutTimer = setTimeout(() => {\n // this.onFocusOutList && this.onFocusOutList.forEach(cb => cb());\n // }, 100);\n };\n\n handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n this.handleInput({ data: null, type: 'Backspace' });\n }\n };\n\n handleCompositionStart = () => {\n this.isComposing = true;\n const { textConfig = [] } = this.currRt.attribute;\n this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n if (this.cursorIndex < 0) {\n const config = textConfig[0];\n textConfig.unshift({ fill: 'black', ...getDefaultCharacterConfig(this.currRt.attribute), ...config, text: '' });\n } else {\n const configIdx = this.composingConfigIdx;\n const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];\n textConfig.splice(configIdx, 0, { fill: 'black', ...lastConfig, text: '' });\n }\n };\n handleCompositionEnd = () => {\n this.isComposing = false;\n\n const text = this.parseCompositionStr(this.composingConfigIdx);\n // 拆分上一次的内容\n // const { textConfig = [] } = this.currRt.attribute;\n // const configIdx = this.composingConfigIdx;\n\n // const lastConfig = textConfig[configIdx];\n // textConfig.splice(configIdx, 1);\n // const text = (lastConfig as any).text;\n // const textList: string[] = text ? Array.from(text.toString()) : [];\n // for (let i = 0; i < textList.length; i++) {\n // textConfig.splice(i + configIdx, 0, { ...lastConfig, isComposing: false, text: textList[i] } as any);\n // }\n // this.currRt.setAttributes({ textConfig });\n // const nextConfigIdx = configIdx + textList.length;\n // this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n this.composingConfigIdx = -1;\n\n this.onChangeCbList.forEach(cb => {\n cb(\n text,\n this.isComposing,\n // TODO 当换行后刚开始输入会有问题,后续看这里具体Cursor变换逻辑\n this.cursorIndex,\n this.currRt\n );\n });\n };\n\n /**\n * 复合输入以及粘贴,都会复制出一大段内容,这时候需要重新处理textConfig和cursorIndex\n * 1. 拆分text到textConfig\n * 2. 计算新的cursorIndex\n * @param configIdx\n */\n parseCompositionStr(configIdx: number) {\n const { textConfig = [] } = this.currRt.attribute;\n\n const lastConfig = textConfig[configIdx];\n textConfig.splice(configIdx, 1);\n const text = (lastConfig as any).text;\n const textList: string[] = text ? Array.from(text.toString()) : [];\n for (let i = 0; i < textList.length; i++) {\n textConfig.splice(i + configIdx, 0, {\n fill: 'black',\n ...lastConfig,\n isComposing: false,\n text: textList[i]\n } as any);\n }\n this.currRt.setAttributes({ textConfig });\n const nextConfigIdx = configIdx + textList.length;\n this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n return text;\n }\n\n handleInput = (ev: any) => {\n if (!this.currRt) {\n return;\n }\n if (ev.inputType === 'historyUndo') {\n return;\n }\n const { textConfig = [], ...rest } = this.currRt.attribute;\n // 删完了,直接返回\n if (ev.type === 'Backspace' && !textConfig.length) {\n return;\n }\n\n let str = (ev as any).data;\n if (!this.isComposing && ev.type !== 'Backspace' && !str) {\n str = '\\n';\n }\n\n // 处理正反选\n if (this.selectionStartCursorIdx > this.cursorIndex) {\n [this.cursorIndex, this.selectionStartCursorIdx] = [this.selectionStartCursorIdx, this.cursorIndex];\n }\n\n const startIdx = findConfigIndexByCursorIdx(textConfig, this.selectionStartCursorIdx);\n const endIdx = findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n\n // composing的话会插入一个字符,所以往右加一个\n const lastConfigIdx = this.isComposing ? this.composingConfigIdx : Math.max(startIdx - 1, 0);\n // 算一个默认属性\n let lastConfig: any = textConfig[lastConfigIdx];\n if (!lastConfig) {\n lastConfig = getDefaultCharacterConfig(rest);\n }\n let nextConfig = lastConfig;\n\n if (startIdx !== endIdx) {\n textConfig.splice(startIdx, endIdx - startIdx);\n if (this.isComposing) {\n this.composingConfigIdx = startIdx;\n }\n }\n\n let nextConfigIdx = startIdx;\n\n // 删除键\n if (ev.type === 'Backspace' && !this.isComposing) {\n if (startIdx === endIdx) {\n if (startIdx <= 0) {\n return;\n }\n // 删除\n textConfig.splice(startIdx - 1, 1);\n nextConfigIdx = Math.max(startIdx - 1, 0);\n } else {\n // 不插入内容\n }\n } else {\n // 插入\n if (!this.isComposing) {\n nextConfig = { fill: 'black', ...lastConfig, text: '' };\n textConfig.splice(startIdx, 0, nextConfig);\n nextConfigIdx++;\n }\n // 插入\n nextConfig.text = str;\n // 标记isComposing,用来判定是否应该拆分成单个字符\n nextConfig.isComposing = this.isComposing;\n }\n\n this.currRt.setAttributes({ textConfig });\n // 重新计算cursorIdx\n // nextConfigIdx = Math.min(nextConfigIdx, textConfig.length - 1);\n\n let cursorIndex = this.cursorIndex;\n if (str && str.length > 1 && !this.isComposing) {\n // 如果字符长度大于1且不是composing,那说明是粘贴\n // 拆分\n this.parseCompositionStr(nextConfigIdx - 1);\n cursorIndex = this.cursorIndex;\n } else {\n // composing的时候不偏移,只有完整输入后才偏移\n cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n if (!this.isComposing) {\n this.cursorIndex = cursorIndex;\n } else {\n this.cursorIndex = this.selectionStartCursorIdx;\n }\n }\n\n if (!this.isComposing) {\n this.onChangeCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n } else {\n this.onInputCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n }\n };\n\n moveTo(x: number, y: number, rt: IRichText, cursorIndex: number, selectionStartCursorIdx: number) {\n this.textAreaDom.style.left = `${x}px`;\n this.textAreaDom.style.top = `${y}px`;\n setTimeout(() => {\n this.textAreaDom.focus();\n this.textAreaDom.setSelectionRange(0, 0);\n });\n this.currRt = rt;\n\n this.cursorIndex = cursorIndex;\n this.selectionStartCursorIdx = selectionStartCursorIdx;\n }\n\n release() {\n this.textAreaDom.removeEventListener('input', this.handleInput);\n this.textAreaDom.removeEventListener('compositionstart', this.handleCompositionStart);\n this.textAreaDom.removeEventListener('compositionend', this.handleCompositionEnd);\n this.textAreaDom.addEventListener('focusin', this.handleFocusOut);\n this.textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.removeEventListener('keydown', this.handleKeyDown);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/edit-module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mDAAgD;AAmBhD,SAAgB,yBAAyB,CAAC,SAAoC;IAC5E,MAAM,EAAE,IAAI,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,UAAU,GAAG,QAAQ,EAAE,UAAU,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;IAClG,IAAI,EAAE,QAAQ,GAAG,EAAE,EAAE,GAAG,SAAS,CAAC;IAClC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACvB,QAAQ,GAAG,EAAE,CAAC;KACf;IACD,OAAO;QACL,IAA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js","sourcesContent":["import { application } from '../../application';\nimport type {\n IRichText,\n IRichTextCharacter,\n IRichTextGraphicAttribute,\n IRichTextParagraphCharacter\n} from '../../interface';\n\n// function getMaxConfigIndexIgnoreLinebreak(textConfig: IRichTextCharacter[]) {\n// let idx = 0;\n// for (let i = 0; i < textConfig.length; i++) {\n// const c = textConfig[i] as IRichTextParagraphCharacter;\n// if (c.text !== '\\n') {\n// idx++;\n// }\n// }\n// return Math.max(idx - 1, 0);\n// }\n\nexport function getDefaultCharacterConfig(attribute: IRichTextGraphicAttribute) {\n const { fill = 'black', stroke = false, fontWeight = 'normal', fontFamily = 'Arial' } = attribute;\n let { fontSize = 12 } = attribute;\n if (!isFinite(fontSize)) {\n fontSize = 12;\n }\n return {\n fill,\n stroke,\n fontSize,\n fontWeight,\n fontFamily\n } as any;\n}\n\n/**\n * 找到cursorIndex所在的textConfig的位置,给出的index就是要插入的准确位置\n * @param textConfig\n * @param cursorIndex\n * @returns\n */\nexport function findConfigIndexByCursorIdx(textConfig: IRichTextCharacter[], cursorIndex: number): number {\n if (cursorIndex < 0) {\n return 0;\n }\n\n // 排序找到对应的元素\n const intCursorIndex = Math.round(cursorIndex);\n let tempCursorIndex = intCursorIndex;\n // 跳过连续换行符中的第一个换行符\n let lineBreak = false;\n let configIdx = 0;\n for (configIdx = 0; configIdx < textConfig.length && tempCursorIndex >= 0; configIdx++) {\n const c = textConfig[configIdx] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n tempCursorIndex -= Number(lineBreak);\n lineBreak = true;\n } else {\n tempCursorIndex--;\n lineBreak = false;\n }\n }\n // 说明过限了\n if (tempCursorIndex >= 0) {\n return textConfig.length;\n }\n configIdx -= 1;\n\n // 如果有换行,一定在换行符左边写\n if (cursorIndex > intCursorIndex && !lineBreak) {\n configIdx += 1;\n }\n return configIdx;\n}\n\n/**\n * 根据configIndex找到cursorIndex的位置,忽略单个换行符,连续换行符的时候只忽略第一个\n * @param textConfig\n * @param configIndex\n * @returns\n */\nexport function findCursorIdxByConfigIndex(textConfig: IRichTextCharacter[], configIndex: number): number {\n let cursorIndex = 0;\n if (configIndex < 0) {\n return -0.1;\n }\n // 仅有一个\\n,那不算\n // 如果有连续的\\n,那就少算一个\n let lastLineBreak = false;\n\n for (let i = 0; i <= configIndex && i < textConfig.length; i++) {\n const c = textConfig[i] as IRichTextParagraphCharacter;\n if (c.text === '\\n') {\n cursorIndex += Number(lastLineBreak);\n lastLineBreak = true;\n } else {\n cursorIndex++;\n lastLineBreak = false;\n }\n }\n cursorIndex = Math.max(cursorIndex - 1, 0);\n\n // 超出区间了直接设置到尾部,configIndex超过区间,cursorIndex不会超过\n if (configIndex > textConfig.length - 1) {\n // 如果最后一行是一个换行符,那么就得是xx.9否则就是xx.1\n if ((textConfig[textConfig.length - 1] as any)?.text === '\\n') {\n return cursorIndex + 0.9;\n }\n return cursorIndex + 0.1;\n }\n\n // 如果是这个configIdx对应到的是单个换行的话,那么算到下一个字符上\n const lineBreak = (textConfig[configIndex] as any)?.text === '\\n';\n if (configIndex >= textConfig.length - 1 && lineBreak) {\n return cursorIndex + 1 - 0.1;\n }\n const singleLineBreak = lineBreak && (textConfig[configIndex - 1] as any)?.text !== '\\n';\n\n // 光标往左放\n cursorIndex -= 0.1;\n\n // 如果是单行,那么这一个换行符没有算字符,光标要往右放\n if (singleLineBreak) {\n cursorIndex += 0.2;\n }\n return cursorIndex;\n}\n\nexport class EditModule {\n container: HTMLElement;\n textAreaDom: HTMLTextAreaElement;\n currRt: IRichText;\n isComposing: boolean;\n composingConfigIdx: number;\n cursorIndex: number;\n selectionStartCursorIdx: number;\n // 输入的回调(composing的时候每次也会触发)\n onInputCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n // change的回调(composing确认才会触发)\n onChangeCbList: Array<(text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void>;\n onFocusInList: Array<() => void>;\n onFocusOutList: Array<() => void>;\n focusOutTimer: number;\n\n constructor(container?: HTMLElement) {\n this.container = container ?? document.body;\n\n const textAreaDom = document.createElement('textarea');\n textAreaDom.autocomplete = 'off';\n textAreaDom.innerText = '';\n this.applyStyle(textAreaDom);\n this.container.append(textAreaDom);\n this.textAreaDom = textAreaDom;\n this.isComposing = false;\n this.composingConfigIdx = -1;\n this.onInputCbList = [];\n this.onChangeCbList = [];\n this.onFocusInList = [];\n this.onFocusOutList = [];\n }\n\n onInput(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onInputCbList.push(cb);\n }\n\n onChange(cb: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void) {\n this.onChangeCbList.push(cb);\n }\n\n onFocusIn(cb: () => void) {\n this.onFocusInList.push(cb);\n }\n\n onFocusOut(cb: () => void) {\n this.onFocusOutList.push(cb);\n }\n\n applyStyle(textAreaDom: HTMLTextAreaElement) {\n textAreaDom.setAttribute(\n 'style',\n `width: 100px; height: 30px; left: 0; top: 0; position: absolute; z-index: -1; outline: none; resize: none; border: none; overflow: hidden; color: transparent; user-select: none; caret-color: transparent;background-color: transparent;`\n );\n\n textAreaDom.addEventListener('input', this.handleInput);\n textAreaDom.addEventListener('compositionstart', this.handleCompositionStart);\n textAreaDom.addEventListener('compositionend', this.handleCompositionEnd);\n // 监听焦点\n textAreaDom.addEventListener('focusin', this.handleFocusIn);\n textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.addEventListener('keydown', this.handleKeyDown);\n }\n\n handleFocusIn = () => {\n // this.focusOutTimer && clearTimeout(this.focusOutTimer);\n // this.focusOutTimer = 0;\n // this.onFocusInList && this.onFocusInList.forEach(cb => cb());\n };\n handleFocusOut = () => {\n // 暂时注释,会导致非期待情况下的误关闭\n // // 延时触发,避免误关闭\n // this.focusOutTimer = setTimeout(() => {\n // this.onFocusOutList && this.onFocusOutList.forEach(cb => cb());\n // }, 100);\n };\n\n handleKeyDown = (e: KeyboardEvent) => {\n if (e.key === 'Delete' || e.key === 'Backspace') {\n this.handleInput({ data: null, type: 'Backspace' });\n }\n };\n\n handleCompositionStart = () => {\n this.isComposing = true;\n const { textConfig = [] } = this.currRt.attribute;\n this.composingConfigIdx = this.cursorIndex < 0 ? 0 : findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n if (this.cursorIndex < 0) {\n const config = textConfig[0];\n textConfig.unshift({ fill: 'black', ...getDefaultCharacterConfig(this.currRt.attribute), ...config, text: '' });\n } else {\n const configIdx = this.composingConfigIdx;\n const lastConfig = textConfig[configIdx] || textConfig[configIdx - 1];\n textConfig.splice(configIdx, 0, { fill: 'black', ...lastConfig, text: '' });\n }\n };\n handleCompositionEnd = () => {\n this.isComposing = false;\n\n const text = this.parseCompositionStr(this.composingConfigIdx);\n // 拆分上一次的内容\n // const { textConfig = [] } = this.currRt.attribute;\n // const configIdx = this.composingConfigIdx;\n\n // const lastConfig = textConfig[configIdx];\n // textConfig.splice(configIdx, 1);\n // const text = (lastConfig as any).text;\n // const textList: string[] = text ? Array.from(text.toString()) : [];\n // for (let i = 0; i < textList.length; i++) {\n // textConfig.splice(i + configIdx, 0, { ...lastConfig, isComposing: false, text: textList[i] } as any);\n // }\n // this.currRt.setAttributes({ textConfig });\n // const nextConfigIdx = configIdx + textList.length;\n // this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n this.composingConfigIdx = -1;\n\n this.onChangeCbList.forEach(cb => {\n cb(\n text,\n this.isComposing,\n // TODO 当换行后刚开始输入会有问题,后续看这里具体Cursor变换逻辑\n this.cursorIndex,\n this.currRt\n );\n });\n };\n\n /**\n * 复合输入以及粘贴,都会复制出一大段内容,这时候需要重新处理textConfig和cursorIndex\n * 1. 拆分text到textConfig\n * 2. 计算新的cursorIndex\n * @param configIdx\n */\n parseCompositionStr(configIdx: number) {\n const { textConfig = [] } = this.currRt.attribute;\n\n const lastConfig = textConfig[configIdx] ?? {};\n textConfig.splice(configIdx, 1);\n const text = (lastConfig as any).text;\n const textList: string[] = text ? Array.from(text.toString()) : [];\n for (let i = 0; i < textList.length; i++) {\n textConfig.splice(i + configIdx, 0, {\n fill: 'black',\n ...lastConfig,\n isComposing: false,\n text: textList[i]\n } as any);\n }\n this.currRt.setAttributes({ textConfig });\n const nextConfigIdx = configIdx + textList.length;\n this.cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n return text;\n }\n\n handleInput = (ev: any) => {\n if (!this.currRt) {\n return;\n }\n if (ev.inputType === 'historyUndo') {\n return;\n }\n const { textConfig = [], ...rest } = this.currRt.attribute;\n // 删完了,直接返回\n if (ev.type === 'Backspace' && !textConfig.length) {\n return;\n }\n\n let str = (ev as any).data;\n if (!this.isComposing && ev.type !== 'Backspace' && !str) {\n str = '\\n';\n }\n\n // 处理正反选\n if (this.selectionStartCursorIdx > this.cursorIndex) {\n [this.cursorIndex, this.selectionStartCursorIdx] = [this.selectionStartCursorIdx, this.cursorIndex];\n }\n\n const startIdx = findConfigIndexByCursorIdx(textConfig, this.selectionStartCursorIdx);\n const endIdx = findConfigIndexByCursorIdx(textConfig, this.cursorIndex);\n\n // composing的话会插入一个字符,所以往右加一个\n const lastConfigIdx = this.isComposing ? this.composingConfigIdx : Math.max(startIdx - 1, 0);\n // 算一个默认属性\n let lastConfig: any = textConfig[lastConfigIdx];\n if (!lastConfig) {\n lastConfig = getDefaultCharacterConfig(rest);\n }\n let nextConfig = lastConfig;\n\n if (startIdx !== endIdx) {\n textConfig.splice(startIdx, endIdx - startIdx);\n if (this.isComposing) {\n this.composingConfigIdx = startIdx;\n }\n }\n\n let nextConfigIdx = startIdx;\n\n // 删除键\n if (ev.type === 'Backspace' && !this.isComposing) {\n if (startIdx === endIdx) {\n if (startIdx <= 0) {\n return;\n }\n // 删除\n textConfig.splice(startIdx - 1, 1);\n nextConfigIdx = Math.max(startIdx - 1, 0);\n } else {\n // 不插入内容\n }\n } else {\n // 插入\n if (!this.isComposing) {\n nextConfig = { fill: 'black', ...lastConfig, text: '' };\n textConfig.splice(startIdx, 0, nextConfig);\n nextConfigIdx++;\n }\n // 插入\n nextConfig.text = str;\n // 标记isComposing,用来判定是否应该拆分成单个字符\n nextConfig.isComposing = this.isComposing;\n }\n\n this.currRt.setAttributes({ textConfig });\n // 重新计算cursorIdx\n // nextConfigIdx = Math.min(nextConfigIdx, textConfig.length - 1);\n\n let cursorIndex = this.cursorIndex;\n if (str && str.length > 1 && !this.isComposing) {\n // 如果字符长度大于1且不是composing,那说明是粘贴\n // 拆分\n this.parseCompositionStr(nextConfigIdx - 1);\n cursorIndex = this.cursorIndex;\n } else {\n // composing的时候不偏移,只有完整输入后才偏移\n cursorIndex = findCursorIdxByConfigIndex(textConfig, nextConfigIdx);\n if (!this.isComposing) {\n this.cursorIndex = cursorIndex;\n } else {\n this.cursorIndex = this.selectionStartCursorIdx;\n }\n }\n\n if (!this.isComposing) {\n this.onChangeCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n } else {\n this.onInputCbList.forEach(cb => {\n cb(str, this.isComposing, cursorIndex, this.currRt);\n });\n }\n };\n\n moveTo(x: number, y: number, rt: IRichText, cursorIndex: number, selectionStartCursorIdx: number) {\n this.textAreaDom.style.left = `${x}px`;\n this.textAreaDom.style.top = `${y}px`;\n setTimeout(() => {\n this.textAreaDom.focus();\n this.textAreaDom.setSelectionRange(0, 0);\n });\n this.currRt = rt;\n\n this.cursorIndex = cursorIndex;\n this.selectionStartCursorIdx = selectionStartCursorIdx;\n }\n\n release() {\n this.textAreaDom.removeEventListener('input', this.handleInput);\n this.textAreaDom.removeEventListener('compositionstart', this.handleCompositionStart);\n this.textAreaDom.removeEventListener('compositionend', this.handleCompositionEnd);\n this.textAreaDom.addEventListener('focusin', this.handleFocusOut);\n this.textAreaDom.addEventListener('focusout', this.handleFocusOut);\n application.global.removeEventListener('keydown', this.handleKeyDown);\n }\n}\n"]}
@@ -11,8 +11,8 @@ declare class Selection {
11
11
  getSelectionPureText(): string;
12
12
  hasFormat(key: string): boolean;
13
13
  _getFormat(key: string, cursorIdx: number): any;
14
- getFormat(key: string): any;
15
- getAllFormat(key: string): any;
14
+ getFormat(key: string, supportOutAttr?: boolean): any;
15
+ getAllFormat(key: string, supportOutAttr?: boolean): any;
16
16
  }
17
17
  export declare const FORMAT_TEXT_COMMAND = "FORMAT_TEXT_COMMAND";
18
18
  export declare const FORMAT_ALL_TEXT_COMMAND = "FORMAT_ALL_TEXT_COMMAND";
@@ -56,12 +56,14 @@ export declare class RichTextEditPlugin implements IPlugin {
56
56
  copyToClipboard(e: KeyboardEvent): boolean;
57
57
  selectionRange(startIdx: number, endIdx: number): void;
58
58
  selectionRangeByCursorIdx(startCursorIdx: number, endCursorIdx: number, cache: IRichTextFrame): void;
59
- fullSelection(e: KeyboardEvent): boolean;
60
- directKey(e: KeyboardEvent): boolean;
59
+ fullSelection(): void;
60
+ protected fullSelectionKeyHandler(e: KeyboardEvent): boolean;
61
+ directKeyHandler(e: KeyboardEvent): boolean;
61
62
  handleKeyDown: (e: KeyboardEvent) => void;
62
63
  handleInput: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void;
63
64
  handleChange: (text: string, isComposing: boolean, cursorIdx: number, rt: IRichText) => void;
64
65
  tryShowShadowPlaceholder(): void;
66
+ getRichTextAABBBounds(rt: IRichText): any;
65
67
  tryShowInputBounds(): void;
66
68
  trySyncPlaceholderToTextConfig(): void;
67
69
  handleFocusIn: () => never;
@@ -73,7 +75,9 @@ export declare class RichTextEditPlugin implements IPlugin {
73
75
  handlePointerDown: (e: PointerEvent) => void;
74
76
  handlePointerUp: (e: PointerEvent) => void;
75
77
  handleDBLClick: (e: PointerEvent) => void;
78
+ protected stopPropagation(e: Event): void;
76
79
  onFocus(e: PointerEvent, data?: any): void;
80
+ offsetShadowRoot(rt?: IRichText): void;
77
81
  protected offsetLineBgAndShadowBounds(): void;
78
82
  protected deFocus(trulyDeFocus?: boolean): void;
79
83
  protected addAnimateToLine(line: ILine): void;