@visactor/vrender-core 0.23.0-alpha.3 → 1.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/animate/config.d.ts +0 -1
- package/cjs/animate/config.js +1 -5
- package/cjs/animate/config.js.map +1 -1
- package/cjs/application.d.ts +2 -1
- package/cjs/application.js.map +1 -1
- package/cjs/color-string/interpolate.js +5 -2
- package/cjs/color-string/interpolate.js.map +1 -1
- package/cjs/common/canvas-utils.js +6 -3
- package/cjs/common/canvas-utils.js.map +1 -1
- package/cjs/common/custom-path2d.js +2 -2
- package/cjs/common/custom-path2d.js.map +1 -1
- package/cjs/common/diff.d.ts +1 -0
- package/cjs/common/diff.js +19 -0
- package/cjs/common/diff.js.map +1 -0
- package/cjs/common/enums.d.ts +0 -16
- package/cjs/common/enums.js +4 -12
- package/cjs/common/enums.js.map +1 -1
- package/cjs/common/morphing-utils.js +32 -124
- package/cjs/common/morphing-utils.js.map +1 -1
- package/cjs/common/segment/index.d.ts +1 -0
- package/cjs/common/segment/index.js +4 -1
- package/cjs/common/segment/index.js.map +1 -1
- package/cjs/common/segment/step.d.ts +6 -0
- package/cjs/common/segment/step.js +19 -2
- package/cjs/common/segment/step.js.map +1 -1
- package/cjs/common/shape/arc.d.ts +1 -1
- package/cjs/common/shape/arc.js +7 -3
- package/cjs/common/shape/arc.js.map +1 -1
- package/cjs/common/split-path.js +2 -3
- package/cjs/common/split-path.js.map +1 -1
- package/cjs/common/store.js +2 -1
- package/cjs/common/utils.d.ts +0 -2
- package/cjs/common/utils.js +4 -8
- package/cjs/common/utils.js.map +1 -1
- package/cjs/core/global-module.js +2 -0
- package/cjs/core/stage.d.ts +5 -2
- package/cjs/core/stage.js +19 -10
- package/cjs/core/stage.js.map +1 -1
- package/cjs/event/event-system.js +6 -7
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/event/federated-event/base-event.js +1 -1
- package/cjs/event/federated-event/base-event.js.map +1 -1
- package/cjs/graphic/arc.d.ts +1 -2
- package/cjs/graphic/arc.js +4 -3
- package/cjs/graphic/arc.js.map +1 -1
- package/cjs/graphic/area.d.ts +1 -2
- package/cjs/graphic/area.js +5 -2
- package/cjs/graphic/area.js.map +1 -1
- package/cjs/graphic/circle.d.ts +1 -2
- package/cjs/graphic/circle.js +7 -3
- package/cjs/graphic/circle.js.map +1 -1
- package/cjs/graphic/config.d.ts +2 -1
- package/cjs/graphic/config.js +10 -3
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/constants.d.ts +1 -0
- package/cjs/graphic/constants.js +4 -3
- package/cjs/graphic/constants.js.map +1 -1
- package/cjs/graphic/graphic-service/graphic-module.js +1 -2
- package/cjs/graphic/graphic-service/graphic-module.js.map +1 -1
- package/cjs/graphic/graphic.d.ts +10 -10
- package/cjs/graphic/graphic.js +42 -98
- package/cjs/graphic/graphic.js.map +1 -1
- package/cjs/graphic/group.js +14 -7
- package/cjs/graphic/group.js.map +1 -1
- package/cjs/graphic/image.js +2 -1
- package/cjs/graphic/image.js.map +1 -1
- package/cjs/graphic/index.d.ts +1 -0
- package/cjs/graphic/index.js +8 -8
- package/cjs/graphic/index.js.map +1 -1
- package/cjs/graphic/line.d.ts +1 -2
- package/cjs/graphic/line.js +7 -2
- package/cjs/graphic/line.js.map +1 -1
- package/cjs/graphic/path.js +2 -1
- package/cjs/graphic/path.js.map +1 -1
- package/cjs/graphic/polygon.js +2 -1
- package/cjs/graphic/polygon.js.map +1 -1
- package/cjs/graphic/rect.js +7 -3
- package/cjs/graphic/rect.js.map +1 -1
- package/cjs/graphic/richtext/icon.d.ts +1 -1
- package/cjs/graphic/richtext/icon.js.map +1 -1
- package/cjs/graphic/richtext/paragraph.d.ts +3 -0
- package/cjs/graphic/richtext/paragraph.js +14 -10
- package/cjs/graphic/richtext/paragraph.js.map +1 -1
- package/cjs/graphic/richtext/utils.js +12 -2
- package/cjs/graphic/richtext/utils.js.map +1 -1
- package/cjs/graphic/richtext.d.ts +3 -0
- package/cjs/graphic/richtext.js +3 -2
- package/cjs/graphic/richtext.js.map +1 -1
- package/cjs/graphic/star.d.ts +52 -0
- package/cjs/graphic/star.js +78 -0
- package/cjs/graphic/star.js.map +1 -0
- package/cjs/graphic/symbol.js +3 -1
- package/cjs/graphic/symbol.js.map +1 -1
- package/cjs/graphic/text.js +1 -0
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/theme.js +2 -0
- package/cjs/graphic/theme.js.map +1 -1
- package/cjs/index.d.ts +3 -0
- package/cjs/index.js +14 -12
- package/cjs/index.js.map +1 -1
- package/cjs/interface/animate.d.ts +1 -165
- package/cjs/interface/animate.js +1 -4
- package/cjs/interface/animate.js.map +1 -1
- package/cjs/interface/animation/animate.d.ts +117 -0
- package/cjs/interface/animation/animate.js +10 -0
- package/cjs/interface/animation/animate.js.map +1 -0
- package/cjs/interface/animation/easing.d.ts +3 -0
- package/cjs/interface/animation/easing.js +6 -0
- package/cjs/interface/animation/easing.js.map +1 -0
- package/cjs/interface/animation/index.d.ts +5 -0
- package/cjs/interface/animation/index.js +23 -0
- package/cjs/interface/animation/index.js.map +1 -0
- package/cjs/interface/animation/ticker.d.ts +39 -0
- package/cjs/interface/animation/ticker.js +11 -0
- package/cjs/interface/animation/ticker.js.map +1 -0
- package/cjs/interface/animation/timeline.d.ts +17 -0
- package/cjs/interface/animation/timeline.js +6 -0
- package/cjs/interface/animation/timeline.js.map +1 -0
- package/cjs/interface/animation/type.d.ts +13 -0
- package/cjs/interface/animation/type.js +15 -0
- package/cjs/interface/animation/type.js.map +1 -0
- package/cjs/interface/common.d.ts +1 -1
- package/cjs/interface/common.js.map +1 -1
- package/cjs/interface/contribution.d.ts +2 -0
- package/cjs/interface/contribution.js.map +1 -1
- package/cjs/interface/graphic/index.d.ts +1 -0
- package/cjs/interface/graphic/index.js +3 -2
- package/cjs/interface/graphic/index.js.map +1 -1
- package/cjs/interface/graphic/richText.d.ts +3 -0
- package/cjs/interface/graphic/richText.js.map +1 -1
- package/cjs/interface/graphic/star.d.ts +12 -0
- package/cjs/interface/graphic/star.js +6 -0
- package/cjs/interface/graphic/star.js.map +1 -0
- package/cjs/interface/graphic/theme.d.ts +3 -0
- package/cjs/interface/graphic/theme.js.map +1 -1
- package/cjs/interface/graphic.d.ts +12 -1
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/index.d.ts +1 -1
- package/cjs/interface/index.js +1 -1
- package/cjs/interface/index.js.map +1 -1
- package/cjs/interface/render.d.ts +1 -0
- package/cjs/interface/render.js.map +1 -1
- package/cjs/interface/stage.d.ts +3 -1
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/modules.d.ts +2 -1
- package/cjs/modules.js +4 -3
- package/cjs/modules.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-render-plugin.js +9 -8
- package/cjs/plugins/builtin-plugin/auto-render-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js +14 -11
- package/cjs/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/edit-module.js +11 -8
- package/cjs/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js +13 -10
- package/cjs/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js +0 -1
- package/cjs/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js +8 -5
- package/cjs/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js +1 -1
- package/cjs/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/cjs/register/register-star.d.ts +1 -0
- package/cjs/register/register-star.js +14 -0
- package/cjs/register/register-star.js.map +1 -0
- package/cjs/render/contributions/render/area-render.js +2 -2
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/contributions/constants.d.ts +1 -0
- package/cjs/render/contributions/render/contributions/constants.js +3 -2
- package/cjs/render/contributions/render/contributions/constants.js.map +1 -1
- package/cjs/render/contributions/render/contributions/index.d.ts +1 -0
- package/cjs/render/contributions/render/contributions/index.js +2 -2
- package/cjs/render/contributions/render/contributions/index.js.map +1 -1
- package/cjs/render/contributions/render/contributions/star-contribution-render.d.ts +2 -0
- package/cjs/render/contributions/render/contributions/star-contribution-render.js +11 -0
- package/cjs/render/contributions/render/contributions/star-contribution-render.js.map +1 -0
- package/cjs/render/contributions/render/draw-contribution.js +1 -1
- package/cjs/render/contributions/render/draw-contribution.js.map +1 -1
- package/cjs/render/contributions/render/line-render.js +1 -1
- package/cjs/render/contributions/render/line-render.js.map +1 -1
- package/cjs/render/contributions/render/star-module.d.ts +2 -0
- package/cjs/render/contributions/render/star-module.js +15 -0
- package/cjs/render/contributions/render/star-module.js.map +1 -0
- package/cjs/render/contributions/render/star-render.d.ts +10 -0
- package/cjs/render/contributions/render/star-render.js +54 -0
- package/cjs/render/contributions/render/star-render.js.map +1 -0
- package/cjs/render/contributions/render/symbol.d.ts +1 -0
- package/cjs/render/contributions/render/symbol.js +2 -2
- package/cjs/render/contributions/render/symbol.js.map +1 -1
- package/cjs/render/render-service.d.ts +1 -1
- package/cjs/render/render-service.js.map +1 -1
- package/dist/index.es.js +12578 -12435
- package/es/animate/config.d.ts +0 -1
- package/es/animate/config.js +0 -5
- package/es/animate/config.js.map +1 -1
- package/es/application.d.ts +2 -1
- package/es/application.js.map +1 -1
- package/es/color-string/interpolate.js +4 -1
- package/es/color-string/interpolate.js.map +1 -1
- package/es/common/canvas-utils.js +6 -3
- package/es/common/canvas-utils.js.map +1 -1
- package/es/common/custom-path2d.js +2 -2
- package/es/common/custom-path2d.js.map +1 -1
- package/es/common/diff.d.ts +1 -0
- package/es/common/diff.js +11 -0
- package/es/common/diff.js.map +1 -0
- package/es/common/enums.d.ts +0 -16
- package/es/common/enums.js +2 -21
- package/es/common/enums.js.map +1 -1
- package/es/common/morphing-utils.js +29 -124
- package/es/common/morphing-utils.js.map +1 -1
- package/es/common/segment/index.d.ts +1 -0
- package/es/common/segment/index.js +6 -1
- package/es/common/segment/index.js.map +1 -1
- package/es/common/segment/step.d.ts +6 -0
- package/es/common/segment/step.js +13 -0
- package/es/common/segment/step.js.map +1 -1
- package/es/common/shape/arc.d.ts +1 -1
- package/es/common/shape/arc.js +7 -3
- package/es/common/shape/arc.js.map +1 -1
- package/es/common/split-path.js +2 -3
- package/es/common/split-path.js.map +1 -1
- package/es/common/store.js +2 -1
- package/es/common/utils.d.ts +0 -2
- package/es/common/utils.js +0 -4
- package/es/common/utils.js.map +1 -1
- package/es/core/global-module.js +2 -0
- package/es/core/stage.d.ts +5 -2
- package/es/core/stage.js +20 -9
- package/es/core/stage.js.map +1 -1
- package/es/event/event-system.js +6 -7
- package/es/event/event-system.js.map +1 -1
- package/es/event/federated-event/base-event.js +1 -1
- package/es/event/federated-event/base-event.js.map +1 -1
- package/es/graphic/arc.d.ts +1 -2
- package/es/graphic/arc.js +4 -3
- package/es/graphic/arc.js.map +1 -1
- package/es/graphic/area.d.ts +1 -2
- package/es/graphic/area.js +5 -2
- package/es/graphic/area.js.map +1 -1
- package/es/graphic/circle.d.ts +1 -2
- package/es/graphic/circle.js +6 -3
- package/es/graphic/circle.js.map +1 -1
- package/es/graphic/config.d.ts +2 -1
- package/es/graphic/config.js +11 -2
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/constants.d.ts +1 -0
- package/es/graphic/constants.js +2 -0
- package/es/graphic/constants.js.map +1 -1
- package/es/graphic/graphic-service/graphic-module.js +1 -1
- package/es/graphic/graphic-service/graphic-module.js.map +1 -1
- package/es/graphic/graphic.d.ts +10 -10
- package/es/graphic/graphic.js +44 -100
- package/es/graphic/graphic.js.map +1 -1
- package/es/graphic/group.js +15 -8
- package/es/graphic/group.js.map +1 -1
- package/es/graphic/image.js +2 -1
- package/es/graphic/image.js.map +1 -1
- package/es/graphic/index.d.ts +1 -0
- package/es/graphic/index.js +2 -0
- package/es/graphic/index.js.map +1 -1
- package/es/graphic/line.d.ts +1 -2
- package/es/graphic/line.js +7 -2
- package/es/graphic/line.js.map +1 -1
- package/es/graphic/path.js +2 -1
- package/es/graphic/path.js.map +1 -1
- package/es/graphic/polygon.js +2 -1
- package/es/graphic/polygon.js.map +1 -1
- package/es/graphic/rect.js +7 -3
- package/es/graphic/rect.js.map +1 -1
- package/es/graphic/richtext/icon.d.ts +1 -1
- package/es/graphic/richtext/icon.js.map +1 -1
- package/es/graphic/richtext/paragraph.d.ts +3 -0
- package/es/graphic/richtext/paragraph.js +14 -10
- package/es/graphic/richtext/paragraph.js.map +1 -1
- package/es/graphic/richtext/utils.js +12 -2
- package/es/graphic/richtext/utils.js.map +1 -1
- package/es/graphic/richtext.d.ts +3 -0
- package/es/graphic/richtext.js +3 -2
- package/es/graphic/richtext.js.map +1 -1
- package/es/graphic/star.d.ts +52 -0
- package/es/graphic/star.js +82 -0
- package/es/graphic/star.js.map +1 -0
- package/es/graphic/symbol.js +3 -1
- package/es/graphic/symbol.js.map +1 -1
- package/es/graphic/text.js +1 -0
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/theme.js +3 -1
- package/es/graphic/theme.js.map +1 -1
- package/es/index.d.ts +3 -0
- package/es/index.js +6 -0
- package/es/index.js.map +1 -1
- package/es/interface/animate.d.ts +1 -165
- package/es/interface/animate.js +2 -1
- package/es/interface/animate.js.map +1 -1
- package/es/interface/animation/animate.d.ts +117 -0
- package/es/interface/animation/animate.js +6 -0
- package/es/interface/animation/animate.js.map +1 -0
- package/es/interface/animation/easing.d.ts +3 -0
- package/es/interface/animation/easing.js +2 -0
- package/es/interface/animation/easing.js.map +1 -0
- package/es/interface/animation/index.d.ts +5 -0
- package/es/interface/animation/index.js +10 -0
- package/es/interface/animation/index.js.map +1 -0
- package/es/interface/animation/ticker.d.ts +39 -0
- package/es/interface/animation/ticker.js +7 -0
- package/es/interface/animation/ticker.js.map +1 -0
- package/es/interface/animation/timeline.d.ts +17 -0
- package/es/interface/animation/timeline.js +2 -0
- package/es/interface/animation/timeline.js.map +1 -0
- package/es/interface/animation/type.d.ts +13 -0
- package/es/interface/animation/type.js +14 -0
- package/es/interface/animation/type.js.map +1 -0
- package/es/interface/common.d.ts +1 -1
- package/es/interface/common.js.map +1 -1
- package/es/interface/contribution.d.ts +2 -0
- package/es/interface/contribution.js.map +1 -1
- package/es/interface/graphic/index.d.ts +1 -0
- package/es/interface/graphic/index.js +2 -0
- package/es/interface/graphic/index.js.map +1 -1
- package/es/interface/graphic/richText.d.ts +3 -0
- package/es/interface/graphic/richText.js.map +1 -1
- package/es/interface/graphic/star.d.ts +12 -0
- package/es/interface/graphic/star.js +2 -0
- package/es/interface/graphic/star.js.map +1 -0
- package/es/interface/graphic/theme.d.ts +3 -0
- package/es/interface/graphic/theme.js.map +1 -1
- package/es/interface/graphic.d.ts +12 -1
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/index.d.ts +1 -1
- package/es/interface/index.js +1 -1
- package/es/interface/index.js.map +1 -1
- package/es/interface/render.d.ts +1 -0
- package/es/interface/render.js.map +1 -1
- package/es/interface/stage.d.ts +3 -1
- package/es/interface/stage.js.map +1 -1
- package/es/modules.d.ts +2 -1
- package/es/modules.js +6 -0
- package/es/modules.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-render-plugin.js +8 -8
- package/es/plugins/builtin-plugin/auto-render-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js +13 -12
- package/es/plugins/builtin-plugin/dirty-bounds-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/edit-module.js +11 -8
- package/es/plugins/builtin-plugin/edit-module.js.map +1 -1
- package/es/plugins/builtin-plugin/flex-layout-plugin.js +12 -11
- package/es/plugins/builtin-plugin/flex-layout-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js +0 -1
- package/es/plugins/builtin-plugin/html-attribute-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js +8 -5
- package/es/plugins/builtin-plugin/incremental-auto-render-plugin.js.map +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js +1 -1
- package/es/plugins/builtin-plugin/richtext-edit-plugin.js.map +1 -1
- package/es/register/register-star.d.ts +1 -0
- package/es/register/register-star.js +8 -0
- package/es/register/register-star.js.map +1 -0
- package/es/render/contributions/render/area-render.js +2 -2
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/contributions/constants.d.ts +1 -0
- package/es/render/contributions/render/contributions/constants.js +2 -0
- package/es/render/contributions/render/contributions/constants.js.map +1 -1
- package/es/render/contributions/render/contributions/index.d.ts +1 -0
- package/es/render/contributions/render/contributions/index.js +2 -0
- package/es/render/contributions/render/contributions/index.js.map +1 -1
- package/es/render/contributions/render/contributions/star-contribution-render.d.ts +2 -0
- package/es/render/contributions/render/contributions/star-contribution-render.js +8 -0
- package/es/render/contributions/render/contributions/star-contribution-render.js.map +1 -0
- package/es/render/contributions/render/draw-contribution.js +1 -1
- package/es/render/contributions/render/draw-contribution.js.map +1 -1
- package/es/render/contributions/render/line-render.js +1 -1
- package/es/render/contributions/render/line-render.js.map +1 -1
- package/es/render/contributions/render/star-module.d.ts +2 -0
- package/es/render/contributions/render/star-module.js +13 -0
- package/es/render/contributions/render/star-module.js.map +1 -0
- package/es/render/contributions/render/star-render.d.ts +10 -0
- package/es/render/contributions/render/star-render.js +59 -0
- package/es/render/contributions/render/star-render.js.map +1 -0
- package/es/render/contributions/render/symbol.d.ts +1 -0
- package/es/render/contributions/render/symbol.js +2 -0
- package/es/render/contributions/render/symbol.js.map +1 -1
- package/es/render/render-service.d.ts +1 -1
- package/es/render/render-service.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/richtext/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAA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,CAAC;YAC5B,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC;YAEzB,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAClH,OAAO,KAAK,GAAG,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;SAClD;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,MAAM,UAAU,iBAAiB,CAAC,SAAoB,EAAE,KAAa;IACnE,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IACrG,MAAM,EAAE,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAExF,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC","file":"paragraph.js","sourcesContent":["import { calculateLineHeight } from '../../common/utils';\nimport type { IContext2d, IRichTextParagraphCharacter } from '../../interface';\nimport { measureTextCanvas, getStrByWithCanvas } from './utils';\n\nfunction getFixedLRTB(left: number, right: number, top: number, bottom: number) {\n const leftInt = Math.round(left);\n const topInt = Math.round(top);\n const rightInt = Math.round(right);\n const bottomInt = Math.round(bottom);\n const _left = left > leftInt ? leftInt : leftInt - 0.5;\n const _top = top > topInt ? topInt : topInt - 0.5;\n const _right = rightInt > right ? rightInt : rightInt + 0.5;\n const _bottom = bottomInt > bottom ? bottomInt : bottomInt + 0.5;\n return {\n left: _left,\n top: _top,\n right: _right,\n bottom: _bottom\n };\n}\n\n/**\n * 部分代码参考 https://github.com/danielearwicker/carota/\n * The MIT License (MIT)\n\n \"Carota\" - Copyright (c) 2013 Daniel Earwicker\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n// 文字段\n// 参考carota\n// https://github.com/danielearwicker/carota/blob/master/src/text.js\nexport default class Paragraph {\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 // rotate?: number;\n direction?: 'horizontal' | 'vertical';\n // bounds?: Bounds;\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ascentDescentMode?: 'actual' | 'font';\n\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisStr: string;\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n overflow?: boolean;\n\n constructor(\n text: string,\n newLine: boolean,\n character: IRichTextParagraphCharacter,\n ascentDescentMode?: 'actual' | 'font'\n ) {\n // 测量文字\n this.fontSize = character.fontSize || 16;\n this.textBaseline = character.textBaseline || 'alphabetic';\n this.ascentDescentMode = ascentDescentMode;\n\n // 处理行高:\n // lineHeight为数字时,大于fontSize取lineHeight,小于fontSize时取fontSize\n // lineHeight不为数字时,统一认为lineHeight为'normal',值取1.2 * fontSize\n const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);\n if (typeof lineHeight === 'number') {\n this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;\n } else {\n this.lineHeight = Math.floor(1.2 * this.fontSize);\n }\n\n this.height = this.lineHeight;\n\n const { ascent, height, descent, width } = measureTextCanvas(text, character, this.ascentDescentMode);\n\n let halfDetaHeight = 0;\n let deltaAscent = 0;\n let deltaDescent = 0;\n if (this.height > height) {\n // measureTextCanvas测量出的是纯文字高度,this.height是考虑行高后的高度\n // 如果this.height > height,将超过的高度平均分配到ascent和descent上\n halfDetaHeight = (this.height - height) / 2;\n deltaAscent = Math.ceil(halfDetaHeight);\n deltaDescent = Math.floor(halfDetaHeight);\n }\n\n if (this.textBaseline === 'top') {\n this.ascent = halfDetaHeight;\n this.descent = height - halfDetaHeight;\n } else if (this.textBaseline === 'bottom') {\n this.ascent = height - halfDetaHeight;\n this.descent = halfDetaHeight;\n } else if (this.textBaseline === 'middle') {\n this.ascent = this.height / 2;\n this.descent = this.height / 2;\n } else {\n this.ascent = ascent + deltaAscent;\n this.descent = descent + deltaDescent;\n }\n\n this.length = text.length;\n this.width = width || 0;\n this.text = text || '';\n this.newLine = newLine || false;\n this.character = character;\n\n this.left = 0;\n this.top = 0;\n\n this.ellipsis = 'normal';\n this.ellipsisWidth = 0;\n this.ellipsisOtherParagraphWidth = 0;\n\n // 处理旋转\n if (character.direction === 'vertical') {\n this.direction = character.direction;\n this.widthOrigin = this.width;\n this.heightOrigin = this.height;\n // const bounds = new Bounds();\n // bounds.set(0, 0, this.width, this.height);\n // bounds.rotate(Math.PI / 2, this.width / 2, this.height / 2);\n // this.bounds = bounds;\n // this.width = bounds.width();\n // this.height = bounds.height();\n this.width = this.heightOrigin;\n this.height = this.widthOrigin;\n this.lineHeight = this.height;\n }\n this.ellipsisStr = '...';\n }\n\n updateWidth() {\n const { width } = measureTextCanvas(this.text, this.character, this.ascentDescentMode);\n this.width = width;\n if (this.direction === 'vertical') {\n this.widthOrigin = this.width;\n this.width = this.heightOrigin;\n this.height = this.widthOrigin;\n }\n }\n\n drawBackground(\n ctx: IContext2d,\n top: number,\n ascent: number,\n deltaLeft: number,\n isLineFirst: boolean,\n textAlign: string,\n lineHeight: number\n ) {\n if (\n !(\n this.text !== '' &&\n this.text !== '\\n' &&\n this.character.background &&\n (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0)\n )\n ) {\n return;\n }\n let baseline = top + ascent;\n let text = this.text;\n let left = this.left + deltaLeft;\n baseline += this.top;\n let direction = this.direction;\n\n if (this.verticalEllipsis) {\n text = this.ellipsisStr;\n direction = 'vertical';\n baseline -= this.ellipsisWidth / 2;\n } else if (this.ellipsis === 'hide') {\n return;\n } else if (this.ellipsis === 'add') {\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n left -= this.ellipsisWidth;\n }\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, this.width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n (direction === 'vertical' ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n if (direction === 'vertical') {\n // baseline -= this.ellipsisWidth - width;\n } else {\n left -= this.ellipsisWidth - width;\n }\n }\n }\n // 背景稍微扩充一些buf,否则会出现白线\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + lineHeight;\n const lrtb = getFixedLRTB(left, right, top, bottom);\n\n return {\n ...lrtb,\n fillStyle: this.character.background,\n globalAlpha: this.character.backgroundOpacity\n };\n }\n\n draw(\n ctx: IContext2d,\n top: number,\n ascent: number,\n deltaLeft: number,\n isLineFirst: boolean,\n textAlign: string,\n lineHeight: number\n ) {\n let baseline = top + ascent;\n let text = this.text;\n let left = this.left + deltaLeft;\n baseline += this.top;\n let direction = this.direction;\n\n if (this.verticalEllipsis) {\n text = this.ellipsisStr;\n direction = 'vertical';\n baseline -= this.ellipsisWidth / 2;\n } else if (this.ellipsis === 'hide') {\n return;\n } else if (this.ellipsis === 'add') {\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n left -= this.ellipsisWidth;\n }\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, this.width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n (direction === 'vertical' ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n if (direction === 'vertical') {\n // baseline -= this.ellipsisWidth - width;\n } else {\n left -= this.ellipsisWidth - width;\n }\n }\n }\n\n // prepareContext(ctx);\n switch (this.character.script) {\n case 'super':\n baseline -= this.ascent * (1 / 3);\n break;\n case 'sub':\n baseline += this.descent / 2;\n break;\n }\n\n // if (isLineFirst) {\n // const result = regFirstSpace.exec(text);\n // if (result?.index !== 0) {\n // text = text.slice(result?.index);\n // }\n // }\n\n // 处理旋转\n if (direction === 'vertical') {\n ctx.save();\n ctx.rotateAbout(Math.PI / 2, left, baseline);\n ctx.translate(-(this.heightOrigin as number) || -this.lineHeight / 2, -this.descent / 2);\n ctx.translate(left, baseline);\n left = 0;\n baseline = 0;\n }\n\n // if (this.character.fill) {\n // if (this.character.background && (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0)) {\n // const fillStyle = ctx.fillStyle;\n // const globalAlpha = ctx.globalAlpha;\n // ctx.fillStyle = this.character.background;\n // if (this.character.backgroundOpacity !== void 0) {\n // ctx.globalAlpha = this.character.backgroundOpacity;\n // }\n // // 背景稍微扩充一些buf,否则会出现白线\n // const right = left + (this.widthOrigin || this.width);\n // const bottom = top + lineHeight;\n // const lrtb = getFixedLRTB(left, right, top, bottom);\n // ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);\n // ctx.fillStyle = fillStyle;\n // ctx.globalAlpha = globalAlpha;\n // }\n // }\n\n const { lineWidth = 1 } = this.character;\n if (this.character.stroke && lineWidth) {\n ctx.strokeText(text, left, baseline);\n }\n\n if (this.character.fill) {\n ctx.fillText(text, left, baseline);\n }\n\n if (this.character.fill) {\n if (this.character.lineThrough || this.character.underline) {\n if (this.character.underline) {\n const top = 1 + baseline;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n if (this.character.lineThrough) {\n const top = 1 + baseline - this.ascent / 2;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline - this.ascent / 2,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n } else if (this.character.textDecoration === 'underline') {\n const top = 1 + baseline;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n } else if (this.character.textDecoration === 'line-through') {\n const top = 1 + baseline - this.ascent / 2;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline - this.ascent / 2,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n }\n\n if (direction === 'vertical') {\n ctx.restore();\n }\n }\n\n getWidthWithEllips(direction: string): number {\n let text = this.text;\n // const direction = this.direction;\n const width = direction === 'vertical' ? this.height : this.width;\n // const height = direction === 'vertical' ? this.width: this.height;\n\n if (this.ellipsis === 'hide') {\n return width;\n } else if (this.ellipsis === 'add') {\n return width + this.ellipsisWidth;\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n return width + this.ellipsisWidth - measureWidth;\n }\n return width;\n }\n}\n\nexport function seperateParagraph(paragraph: Paragraph, index: number) {\n const text1 = paragraph.text.slice(0, index);\n const text2 = paragraph.text.slice(index);\n const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode);\n const p2 = new Paragraph(text2, true, paragraph.character, paragraph.ascentDescentMode);\n\n return [p1, p2];\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/richtext/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAEzD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAEhE,SAAS,YAAY,CAAC,IAAY,EAAE,KAAa,EAAE,GAAW,EAAE,MAAc;IAC5E,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC;IACvD,MAAM,IAAI,GAAG,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC;IAClD,MAAM,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,GAAG,GAAG,CAAC;IAC5D,MAAM,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC;IACjE,OAAO;QACL,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,IAAI;QACT,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,OAAO;KAChB,CAAC;AACJ,CAAC;AA8BD,MAAM,CAAC,OAAO,OAAO,SAAS;IA+B5B,YACE,IAAY,EACZ,OAA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AAM,EAAE,GAAG,IAAI,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC,iBAAiB,CAAC,CAAC;IAExF,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAClB,CAAC","file":"paragraph.js","sourcesContent":["import { calculateLineHeight } from '../../common/utils';\nimport type { IContext2d, IRichTextParagraphCharacter } from '../../interface';\nimport { measureTextCanvas, getStrByWithCanvas } from './utils';\n\nfunction getFixedLRTB(left: number, right: number, top: number, bottom: number) {\n const leftInt = Math.round(left);\n const topInt = Math.round(top);\n const rightInt = Math.round(right);\n const bottomInt = Math.round(bottom);\n const _left = left > leftInt ? leftInt : leftInt - 0.5;\n const _top = top > topInt ? topInt : topInt - 0.5;\n const _right = rightInt > right ? rightInt : rightInt + 0.5;\n const _bottom = bottomInt > bottom ? bottomInt : bottomInt + 0.5;\n return {\n left: _left,\n top: _top,\n right: _right,\n bottom: _bottom\n };\n}\n\n/**\n * 部分代码参考 https://github.com/danielearwicker/carota/\n * The MIT License (MIT)\n\n \"Carota\" - Copyright (c) 2013 Daniel Earwicker\n\n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to whom the Software is\n furnished to do so, subject to the following conditions:\n\n The above copyright notice and this permission notice shall be included in\n all copies or substantial portions of the Software.\n\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n THE SOFTWARE.\n */\n\n// 文字段\n// 参考carota\n// https://github.com/danielearwicker/carota/blob/master/src/text.js\nexport default class Paragraph {\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 // rotate?: number;\n direction?: 'horizontal' | 'vertical';\n // bounds?: Bounds;\n widthOrigin?: number;\n heightOrigin?: number;\n textBaseline?: CanvasTextBaseline;\n ascentDescentMode?: 'actual' | 'font';\n\n ellipsis: 'normal' | 'add' | 'replace' | 'hide';\n ellipsisStr: string;\n ellipsisWidth: number;\n ellipsisOtherParagraphWidth: number;\n verticalEllipsis?: boolean;\n overflow?: boolean;\n space?: number;\n dx?: number;\n dy?: number;\n\n constructor(\n text: string,\n newLine: boolean,\n character: IRichTextParagraphCharacter,\n ascentDescentMode?: 'actual' | 'font'\n ) {\n // 测量文字\n this.fontSize = character.fontSize || 16;\n this.textBaseline = character.textBaseline || 'alphabetic';\n this.ascentDescentMode = ascentDescentMode;\n\n // 处理行高:\n // lineHeight为数字时,大于fontSize取lineHeight,小于fontSize时取fontSize\n // lineHeight不为数字时,统一认为lineHeight为'normal',值取1.2 * fontSize\n const lineHeight = calculateLineHeight(character.lineHeight, this.fontSize);\n if (typeof lineHeight === 'number') {\n this.lineHeight = lineHeight > this.fontSize ? lineHeight : this.fontSize;\n } else {\n this.lineHeight = Math.floor(1.2 * this.fontSize);\n }\n\n this.height = this.lineHeight;\n\n const { ascent, height, descent, width } = measureTextCanvas(text, character, this.ascentDescentMode);\n\n let halfDetaHeight = 0;\n let deltaAscent = 0;\n let deltaDescent = 0;\n if (this.height > height) {\n // measureTextCanvas测量出的是纯文字高度,this.height是考虑行高后的高度\n // 如果this.height > height,将超过的高度平均分配到ascent和descent上\n halfDetaHeight = (this.height - height) / 2;\n deltaAscent = Math.ceil(halfDetaHeight);\n deltaDescent = Math.floor(halfDetaHeight);\n }\n\n if (this.textBaseline === 'top') {\n this.ascent = halfDetaHeight;\n this.descent = height - halfDetaHeight;\n } else if (this.textBaseline === 'bottom') {\n this.ascent = height - halfDetaHeight;\n this.descent = halfDetaHeight;\n } else if (this.textBaseline === 'middle') {\n this.ascent = this.height / 2;\n this.descent = this.height / 2;\n } else {\n this.ascent = ascent + deltaAscent;\n this.descent = descent + deltaDescent;\n }\n\n this.length = text.length;\n this.width = width || 0;\n this.text = text || '';\n this.newLine = newLine || false;\n this.character = character;\n\n this.left = 0;\n this.top = 0;\n\n this.ellipsis = 'normal';\n this.ellipsisWidth = 0;\n this.ellipsisOtherParagraphWidth = 0;\n this.space = character.space;\n this.dx = character.dx ?? 0;\n this.dy = character.dy ?? 0;\n\n // 处理旋转\n if (character.direction === 'vertical') {\n this.direction = character.direction;\n this.widthOrigin = this.width;\n this.heightOrigin = this.height;\n // const bounds = new Bounds();\n // bounds.set(0, 0, this.width, this.height);\n // bounds.rotate(Math.PI / 2, this.width / 2, this.height / 2);\n // this.bounds = bounds;\n // this.width = bounds.width();\n // this.height = bounds.height();\n this.width = this.heightOrigin;\n this.height = this.widthOrigin;\n this.lineHeight = this.height;\n }\n this.ellipsisStr = '...';\n }\n\n updateWidth() {\n const { width } = measureTextCanvas(this.text, this.character, this.ascentDescentMode);\n this.width = width;\n if (this.direction === 'vertical') {\n this.widthOrigin = this.width;\n this.width = this.heightOrigin;\n this.height = this.widthOrigin;\n }\n }\n\n drawBackground(\n ctx: IContext2d,\n top: number,\n ascent: number,\n deltaLeft: number,\n isLineFirst: boolean,\n textAlign: string,\n lineHeight: number\n ) {\n if (\n !(\n this.text !== '' &&\n this.text !== '\\n' &&\n this.character.background &&\n (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0)\n )\n ) {\n return;\n }\n let baseline = top + ascent;\n let text = this.text;\n let left = this.left + deltaLeft;\n baseline += this.top;\n let direction = this.direction;\n\n if (this.verticalEllipsis) {\n text = this.ellipsisStr;\n direction = 'vertical';\n baseline -= this.ellipsisWidth / 2;\n } else if (this.ellipsis === 'hide') {\n return;\n } else if (this.ellipsis === 'add') {\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n left -= this.ellipsisWidth;\n }\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, this.width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n (direction === 'vertical' ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n if (direction === 'vertical') {\n // baseline -= this.ellipsisWidth - width;\n } else {\n const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n left -= this.ellipsisWidth - width;\n }\n }\n }\n // 背景稍微扩充一些buf,否则会出现白线\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + lineHeight;\n const lrtb = getFixedLRTB(left, right, top, bottom);\n\n return {\n ...lrtb,\n fillStyle: this.character.background,\n globalAlpha: this.character.backgroundOpacity\n };\n }\n\n draw(\n ctx: IContext2d,\n top: number,\n ascent: number,\n deltaLeft: number,\n isLineFirst: boolean,\n textAlign: string,\n lineHeight: number\n ) {\n let baseline = top + ascent;\n let text = this.text;\n let left = this.left + deltaLeft + (this.space ?? 0) / 2;\n baseline += this.top;\n let direction = this.direction;\n\n if (this.verticalEllipsis) {\n text = this.ellipsisStr;\n direction = 'vertical';\n baseline -= this.ellipsisWidth / 2;\n } else if (this.ellipsis === 'hide') {\n return;\n } else if (this.ellipsis === 'add') {\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n left -= this.ellipsisWidth;\n }\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, this.width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n (direction === 'vertical' ? this.height : this.width) - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n if (textAlign === 'right' || textAlign === 'end') {\n if (direction === 'vertical') {\n // baseline -= this.ellipsisWidth - width;\n } else {\n const { width } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n left -= this.ellipsisWidth - width;\n }\n }\n }\n\n // prepareContext(ctx);\n switch (this.character.script) {\n case 'super':\n baseline -= this.ascent * (1 / 3);\n break;\n case 'sub':\n baseline += this.descent / 2;\n break;\n }\n\n // if (isLineFirst) {\n // const result = regFirstSpace.exec(text);\n // if (result?.index !== 0) {\n // text = text.slice(result?.index);\n // }\n // }\n\n // 处理旋转\n if (direction === 'vertical') {\n ctx.save();\n ctx.rotateAbout(Math.PI / 2, left, baseline);\n ctx.translate(-(this.heightOrigin as number) || -this.lineHeight / 2, -this.descent / 2);\n ctx.translate(left, baseline);\n left = 0;\n baseline = 0;\n }\n\n // if (this.character.fill) {\n // if (this.character.background && (!this.character.backgroundOpacity || this.character.backgroundOpacity > 0)) {\n // const fillStyle = ctx.fillStyle;\n // const globalAlpha = ctx.globalAlpha;\n // ctx.fillStyle = this.character.background;\n // if (this.character.backgroundOpacity !== void 0) {\n // ctx.globalAlpha = this.character.backgroundOpacity;\n // }\n // // 背景稍微扩充一些buf,否则会出现白线\n // const right = left + (this.widthOrigin || this.width);\n // const bottom = top + lineHeight;\n // const lrtb = getFixedLRTB(left, right, top, bottom);\n // ctx.fillRect(lrtb.left, lrtb.top, lrtb.right - lrtb.left, lrtb.bottom - lrtb.top);\n // ctx.fillStyle = fillStyle;\n // ctx.globalAlpha = globalAlpha;\n // }\n // }\n\n const { lineWidth = 1 } = this.character;\n if (this.character.stroke && lineWidth) {\n ctx.strokeText(text, left + this.dx, baseline + this.dy);\n }\n\n if (this.character.fill) {\n ctx.fillText(text, left + this.dx, baseline + this.dy);\n }\n\n if (this.character.fill) {\n if (this.character.lineThrough || this.character.underline) {\n if (this.character.underline) {\n const top = 1 + baseline;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n if (this.character.lineThrough) {\n const top = 1 + baseline - this.ascent / 2;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline - this.ascent / 2,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n } else if (this.character.textDecoration === 'underline') {\n const top = 1 + baseline;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n } else if (this.character.textDecoration === 'line-through') {\n const top = 1 + baseline - this.ascent / 2;\n const right = left + (this.widthOrigin || this.width);\n const bottom = top + (this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1);\n const lrtb = getFixedLRTB(left, right, top, bottom);\n ctx.fillRect(\n lrtb.left,\n 1 + baseline - this.ascent / 2,\n lrtb.right - lrtb.left,\n this.character.fontSize ? Math.max(1, Math.floor(this.character.fontSize / 10)) : 1\n );\n }\n }\n\n if (direction === 'vertical') {\n ctx.restore();\n }\n }\n\n getWidthWithEllips(direction: string): number {\n let text = this.text;\n // const direction = this.direction;\n const width = direction === 'vertical' ? this.height : this.width;\n // const height = direction === 'vertical' ? this.width: this.height;\n\n if (this.ellipsis === 'hide') {\n return width;\n } else if (this.ellipsis === 'add') {\n return width + this.ellipsisWidth;\n } else if (this.ellipsis === 'replace') {\n // 找到需要截断的字符长度\n // const index = getStrByWith(text, width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth, this.style, text.length - 1);\n const index = getStrByWithCanvas(\n text,\n width - this.ellipsisWidth + this.ellipsisOtherParagraphWidth,\n this.character,\n text.length - 1\n );\n text = text.slice(0, index);\n text += this.ellipsisStr;\n\n const { width: measureWidth } = measureTextCanvas(this.text.slice(index), this.character, this.ascentDescentMode);\n return width + this.ellipsisWidth - measureWidth;\n }\n return width;\n }\n}\n\nexport function seperateParagraph(paragraph: Paragraph, index: number) {\n const text1 = paragraph.text.slice(0, index);\n const text2 = paragraph.text.slice(index);\n const p1 = new Paragraph(text1, paragraph.newLine, paragraph.character, paragraph.ascentDescentMode);\n const p2 = new Paragraph(text2, true, paragraph.character, paragraph.ascentDescentMode);\n\n return [p1, p2];\n}\n"]}
|
|
@@ -103,6 +103,7 @@ export function getStrByWithDom(desc, width, style, guessIndex, needTestLetter)
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export function getStrByWithCanvas(desc, width, character, guessIndex, needTestLetter) {
|
|
106
|
+
if (desc.length <= 1) return 0;
|
|
106
107
|
if (!width || width <= 0) return 0;
|
|
107
108
|
const textMeasure = application.graphicUtil.textMeasure;
|
|
108
109
|
let index = guessIndex, temp = desc.slice(0, index), tempWidth = Math.floor(textMeasure.measureText(temp, character).width), tempNext = desc.slice(0, index + 1), tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character).width);
|
|
@@ -171,16 +172,25 @@ export function measureTextDom(text, style) {
|
|
|
171
172
|
}
|
|
172
173
|
|
|
173
174
|
export function measureTextCanvas(text, character, mode = "actual") {
|
|
175
|
+
var _a;
|
|
176
|
+
if ("" === text) return {
|
|
177
|
+
ascent: 0,
|
|
178
|
+
height: 0,
|
|
179
|
+
descent: 0,
|
|
180
|
+
width: 0
|
|
181
|
+
};
|
|
174
182
|
const measurement = application.graphicUtil.textMeasure.measureText(text, character), result = {
|
|
175
183
|
ascent: 0,
|
|
176
184
|
height: 0,
|
|
177
185
|
descent: 0,
|
|
178
186
|
width: 0
|
|
179
187
|
}, ascent = "actual" === mode ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent, descent = "actual" === mode ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;
|
|
180
|
-
|
|
188
|
+
"number" != typeof ascent || "number" != typeof descent ? (result.width = Math.floor(measurement.width),
|
|
181
189
|
result.height = character.fontSize || 0, result.ascent = result.height, result.descent = 0) : (result.width = Math.floor(measurement.width),
|
|
182
190
|
result.height = Math.floor(ascent + descent), result.ascent = Math.floor(ascent),
|
|
183
|
-
result.descent = result.height - result.ascent)
|
|
191
|
+
result.descent = result.height - result.ascent);
|
|
192
|
+
const space = null !== (_a = character.space) && void 0 !== _a ? _a : 0;
|
|
193
|
+
return result.width += space, result;
|
|
184
194
|
}
|
|
185
195
|
|
|
186
196
|
export function getFontString(character, ctx) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/richtext/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,GAAG;QACN,MA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ACF;IAED,OAAO,CACL,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;QAC1C,GAAG;QACH,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QAC3C,GAAG;QACH,CAAC,QAAQ,IAAI,EAAE,CAAC;QAChB,KAAK;QACL,CAAC,CAAC,SAAS,IAAI,SAAS,CAAC,UAAU,CAAC,IAAI,iBAAiB,CAAC,UAAU,CAAC,CACtE,CAAC;AACJ,CAAC","file":"utils.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { application } from '../../application';\nimport { createColor } from '../../common/canvas-utils';\nimport type { IContext2d, ITextStyleParams, IRichTextParagraphCharacter } from '../../interface';\nimport { DEFAULT_TEXT_FONT_FAMILY } from '../../constants';\n\nexport const DIRECTION_KEY = {\n horizontal: {\n width: 'width',\n height: 'height',\n left: 'left',\n top: 'top',\n x: 'x',\n y: 'y',\n bottom: 'bottom'\n },\n vertical: {\n width: 'height',\n height: 'width',\n left: 'top',\n top: 'left',\n x: 'y',\n y: 'x',\n bottom: 'right'\n }\n};\n\nconst defaultFormatting = {\n fontSize: 16,\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fill: true,\n stroke: false,\n fontWeight: 'normal',\n lineHeight: 'normal',\n fontStyle: 'normal', // normal, italic, oblique\n textDecoration: 'none', // none, underline, line-through\n textAlign: 'left', // left, right, center\n script: 'normal' // normal, sub, super\n};\nconst nbsp = String.fromCharCode(160);\n\nexport const regLetter = /\\w|\\(|\\)|-/;\nconst regPunctuation = /[.?!,;:/,。?!、;:]/;\nexport const regFirstSpace = /\\S/;\n\nconst setTextStyle = (ctx: IContext2d, character: IRichTextParagraphCharacter) => {\n let fontSize = character.fontSize || 16;\n switch (character.script) {\n case 'super':\n case 'sub':\n fontSize *= 0.8;\n break;\n }\n\n ctx.setTextStyle({\n textAlign: 'left',\n textBaseline: character.textBaseline || 'alphabetic',\n fontStyle: character.fontStyle || '',\n fontWeight: character.fontWeight || '',\n fontSize,\n fontFamily: character.fontFamily\n } as ITextStyleParams);\n};\n\n// Applies the style of a run to the canvas context\nexport function applyFillStyle(ctx: IContext2d, character: IRichTextParagraphCharacter, b?: IBoundsLike) {\n const fillStyle = (character && (character.fill as string)) || defaultFormatting.fill;\n if (!fillStyle) {\n ctx.globalAlpha = 0;\n return;\n }\n\n const { fillOpacity = 1, opacity = 1 } = character;\n\n ctx.globalAlpha = fillOpacity * opacity;\n ctx.fillStyle = b ? createColor(ctx, fillStyle, { AABBBounds: b }) : (fillStyle as string);\n\n setTextStyle(ctx, character);\n}\n\nexport function applyStrokeStyle(ctx: IContext2d, character: IRichTextParagraphCharacter) {\n const strokeStyle = (character && (character.stroke as string)) || (defaultFormatting.stroke as any);\n if (!strokeStyle) {\n ctx.globalAlpha = 0;\n return;\n }\n\n const { strokeOpacity = 1, opacity = 1 } = character;\n\n ctx.globalAlpha = strokeOpacity * opacity;\n ctx.lineWidth = character && typeof character.lineWidth === 'number' ? character.lineWidth : 1;\n ctx.strokeStyle = strokeStyle as string;\n\n setTextStyle(ctx, character);\n}\n\nexport function prepareContext(ctx: IContext2d) {\n ctx.setTextStyle({\n textAlign: 'left',\n textBaseline: 'bottom'\n });\n}\n\n// 确认达到availableWidth的字符串截取index\nexport function getStrByWithDom(\n desc: string,\n width: number,\n style: string,\n guessIndex: number,\n needTestLetter?: boolean\n): number {\n desc = desc.replace(/\\s/g, nbsp);\n\n // 测量用DOM\n const span = document.createElement('span');\n span.setAttribute('style', style);\n span.style.visibility = 'hidden';\n span.style.whiteSpace = 'nowrap';\n document.body.appendChild(span);\n\n // 测量从头到当前位置宽度以及从头到下一个字符位置宽度\n let index = guessIndex;\n let temp = desc.slice(0, index);\n span.innerText = temp;\n let tempWidth = span.offsetWidth;\n\n let tempNext = desc.slice(0, index + 1);\n span.innerText = tempNext;\n let tempWidthNext = span.offsetWidth;\n\n // 到当前位置宽度 < width && 到下一个字符位置宽度 > width时,认为找到准确阶段位置\n while (tempWidth > width || tempWidthNext <= width) {\n if (tempWidth > width) {\n index--;\n } else {\n index++;\n }\n\n temp = desc.slice(0, index);\n span.innerText = temp;\n tempWidth = span.offsetWidth;\n\n tempNext = desc.slice(0, index + 1);\n span.innerText = tempNext;\n tempWidthNext = span.offsetWidth;\n }\n\n // 处理特殊情况\n if (needTestLetter) {\n index = testLetter(desc, index);\n }\n\n document.body.removeChild(span);\n return index;\n}\nexport function getStrByWithCanvas(\n desc: string,\n width: number,\n character: IRichTextParagraphCharacter,\n // ctx: IContext2d,\n guessIndex: number,\n needTestLetter?: boolean\n): number {\n if (!width || width <= 0) {\n return 0;\n }\n const textMeasure = application.graphicUtil.textMeasure;\n // const measurement = textMeasure.measureText(text, character);\n\n // 测量从头到当前位置宽度以及从头到下一个字符位置宽度\n let index = guessIndex;\n let temp = desc.slice(0, index);\n let tempWidth = Math.floor(textMeasure.measureText(temp, character as any).width);\n\n let tempNext = desc.slice(0, index + 1);\n let tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character as any).width);\n\n // 到当前位置宽度 < width && 到下一个字符位置宽度 > width时,认为找到准确阶段位置\n while (tempWidth > width || tempWidthNext <= width) {\n if (tempWidth > width) {\n index--;\n } else {\n index++;\n }\n\n if (index > desc.length) {\n index = desc.length;\n break;\n } else if (index < 0) {\n index = 0;\n break;\n }\n\n temp = desc.slice(0, index);\n tempWidth = Math.floor(textMeasure.measureText(temp, character as any).width);\n\n tempNext = desc.slice(0, index + 1);\n tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character as any).width);\n }\n\n // 处理特殊情况\n if (needTestLetter) {\n index = testLetter(desc, index);\n }\n\n return index;\n}\n\nexport function getWordStartEndIdx(string: string, index: number) {\n let startIdx = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[startIdx - 1]) && regLetter.test(string[startIdx])) ||\n // 行首标点符号处理\n regPunctuation.test(string[startIdx])\n ) {\n startIdx--;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (startIdx <= 0) {\n break;\n }\n }\n\n let endIdx = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[endIdx + 1]) && regLetter.test(string[endIdx])) ||\n // 行首标点符号处理\n regPunctuation.test(string[endIdx])\n ) {\n endIdx++;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (endIdx >= string.length) {\n break;\n }\n }\n endIdx = Math.min(endIdx + 1, string.length);\n\n return {\n startIdx,\n endIdx\n };\n}\n\n/**\n * 向前找到单词结尾处换行\n * @param string\n * @param index\n * @param negativeWrongMatch 如果为true,那么如果无法匹配就会向后找到单词的结尾,否则就直接返回index\n * @returns\n */\nexport function testLetter(string: string, index: number, negativeWrongMatch: boolean = false): number {\n let i = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[i - 1]) && regLetter.test(string[i])) ||\n // 行首标点符号处理\n regPunctuation.test(string[i])\n ) {\n i--;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (i <= 0) {\n return negativeWrongMatch ? testLetter2(string, index) : index;\n }\n }\n return i;\n}\n\n/**\n * 向后找到单词结尾处换行\n * @param string\n * @param index\n * @returns\n */\nexport function testLetter2(string: string, index: number) {\n let i = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[i + 1]) && regLetter.test(string[i])) ||\n // 行首标点符号处理\n regPunctuation.test(string[i])\n ) {\n i++;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (i >= string.length) {\n return i;\n }\n }\n return i + 1;\n}\n\n// 测量文字详细信息\nexport function measureTextDom(\n text: string,\n style: string\n): { ascent?: number; height?: number; descent?: number; width?: number } {\n let div;\n\n const span = document.createElement('span');\n const block = document.createElement('div');\n div = document.createElement('div');\n\n block.style.display = 'inline-block';\n block.style.width = '1px';\n block.style.height = '0';\n\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.top = '0';\n div.style.left = '0';\n div.style.width = '500px';\n div.style.height = '200px';\n div.style.whiteSpace = 'nowrap';\n\n div.appendChild(span);\n div.appendChild(block);\n document.body.appendChild(div);\n\n const result: { ascent?: number; height?: number; descent?: number; width?: number } = {};\n try {\n span.setAttribute('style', style);\n span.style.whiteSpace = 'nowrap';\n span.style.display = 'inline-block';\n\n span.innerHTML = '';\n span.appendChild(document.createTextNode(text.replace(/\\s/g, nbsp)));\n\n block.style.verticalAlign = 'baseline';\n result.ascent = block.offsetTop - span.offsetTop;\n block.style.verticalAlign = 'bottom';\n result.height = block.offsetTop - span.offsetTop;\n result.descent = result.height - result.ascent;\n result.width = span.offsetWidth;\n } finally {\n div.parentNode?.removeChild(div);\n div = null;\n }\n return result;\n}\n\n// 测量文字详细信息\nexport function measureTextCanvas(\n text: string,\n character: IRichTextParagraphCharacter,\n mode: 'actual' | 'font' = 'actual'\n): { ascent: number; height: number; descent: number; width: number } {\n const textMeasure = application.graphicUtil.textMeasure;\n const measurement = textMeasure.measureText(text, character as any) as TextMetrics;\n const result: { ascent: number; height: number; descent: number; width: number } = {\n ascent: 0,\n height: 0,\n descent: 0,\n width: 0\n };\n const ascent = mode === 'actual' ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent;\n const descent = mode === 'actual' ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;\n if (typeof ascent !== 'number' || typeof descent !== 'number') {\n result.width = Math.floor(measurement.width);\n result.height = character.fontSize || 0;\n result.ascent = result.height;\n result.descent = 0;\n } else {\n result.width = Math.floor(measurement.width);\n result.height = Math.floor(ascent + descent);\n result.ascent = Math.floor(ascent);\n result.descent = result.height - result.ascent;\n }\n return result;\n}\n\nexport function getFontString(character: IRichTextParagraphCharacter, ctx: IContext2d | null) {\n let fontSize = (character && character.fontSize) || defaultFormatting.fontSize;\n\n if (character) {\n switch (character.script) {\n case 'super':\n case 'sub':\n fontSize *= 0.8;\n break;\n }\n }\n\n return (\n ((character && character.fontStyle) || '') +\n ' ' +\n ((character && character.fontWeight) || '') +\n ' ' +\n (fontSize || 12) +\n 'px ' +\n ((character && character.fontFamily) || defaultFormatting.fontFamily)\n );\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/richtext/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE;QACV,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,KAAK;QACV,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,GAAG;QACN,MAAM,EAAE,QAAQ;KACjB;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,QAAQ;QACf,MAAM,EAAE,OAAO;QACf,IAAI,EAAE,KAAK;QACX,GAAG,EAAE,MAAM;QACX,CAAC,EAAE,GAAG;QACN,CAAC,EAAE,GAAG;QACN,MAAM,EAAE,OAAO;KAChB;CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,QAAQ,EAAE,EAAE;IACZ,UAAU,EAAE,wBAAwB;IACpC,IAAI,EAAE,IAAI;IACV,MAAM,EAAE,KAAK;IACb,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,SAAS,EAAE,QAAQ;IACnB,cAAc,EAAE,MAAM;IACtB,SAAS,EAAE,MAAM;IACjB,MAAM,EAAE,QAAQ;CACjB,CAAC;AACF,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,SAAS,GAAG,YAAY,CAAC;AACtC,MAAM,cAAc,GAAG,kBAAkB,CAAC;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ACtE,CAAC;AACJ,CAAC","file":"utils.js","sourcesContent":["import type { IBoundsLike } from '@visactor/vutils';\nimport { application } from '../../application';\nimport { createColor } from '../../common/canvas-utils';\nimport type { IContext2d, ITextStyleParams, IRichTextParagraphCharacter } from '../../interface';\nimport { DEFAULT_TEXT_FONT_FAMILY } from '../../constants';\n\nexport const DIRECTION_KEY = {\n horizontal: {\n width: 'width',\n height: 'height',\n left: 'left',\n top: 'top',\n x: 'x',\n y: 'y',\n bottom: 'bottom'\n },\n vertical: {\n width: 'height',\n height: 'width',\n left: 'top',\n top: 'left',\n x: 'y',\n y: 'x',\n bottom: 'right'\n }\n};\n\nconst defaultFormatting = {\n fontSize: 16,\n fontFamily: DEFAULT_TEXT_FONT_FAMILY,\n fill: true,\n stroke: false,\n fontWeight: 'normal',\n lineHeight: 'normal',\n fontStyle: 'normal', // normal, italic, oblique\n textDecoration: 'none', // none, underline, line-through\n textAlign: 'left', // left, right, center\n script: 'normal' // normal, sub, super\n};\nconst nbsp = String.fromCharCode(160);\n\nexport const regLetter = /\\w|\\(|\\)|-/;\nconst regPunctuation = /[.?!,;:/,。?!、;:]/;\nexport const regFirstSpace = /\\S/;\n\nconst setTextStyle = (ctx: IContext2d, character: IRichTextParagraphCharacter) => {\n let fontSize = character.fontSize || 16;\n switch (character.script) {\n case 'super':\n case 'sub':\n fontSize *= 0.8;\n break;\n }\n\n ctx.setTextStyle({\n textAlign: 'left',\n textBaseline: character.textBaseline || 'alphabetic',\n fontStyle: character.fontStyle || '',\n fontWeight: character.fontWeight || '',\n fontSize,\n fontFamily: character.fontFamily\n } as ITextStyleParams);\n};\n\n// Applies the style of a run to the canvas context\nexport function applyFillStyle(ctx: IContext2d, character: IRichTextParagraphCharacter, b?: IBoundsLike) {\n const fillStyle = (character && (character.fill as string)) || defaultFormatting.fill;\n if (!fillStyle) {\n ctx.globalAlpha = 0;\n return;\n }\n\n const { fillOpacity = 1, opacity = 1 } = character;\n\n ctx.globalAlpha = fillOpacity * opacity;\n ctx.fillStyle = b ? createColor(ctx, fillStyle, { AABBBounds: b }) : (fillStyle as string);\n\n setTextStyle(ctx, character);\n}\n\nexport function applyStrokeStyle(ctx: IContext2d, character: IRichTextParagraphCharacter) {\n const strokeStyle = (character && (character.stroke as string)) || (defaultFormatting.stroke as any);\n if (!strokeStyle) {\n ctx.globalAlpha = 0;\n return;\n }\n\n const { strokeOpacity = 1, opacity = 1 } = character;\n\n ctx.globalAlpha = strokeOpacity * opacity;\n ctx.lineWidth = character && typeof character.lineWidth === 'number' ? character.lineWidth : 1;\n ctx.strokeStyle = strokeStyle as string;\n\n setTextStyle(ctx, character);\n}\n\nexport function prepareContext(ctx: IContext2d) {\n ctx.setTextStyle({\n textAlign: 'left',\n textBaseline: 'bottom'\n });\n}\n\n// 确认达到availableWidth的字符串截取index\nexport function getStrByWithDom(\n desc: string,\n width: number,\n style: string,\n guessIndex: number,\n needTestLetter?: boolean\n): number {\n desc = desc.replace(/\\s/g, nbsp);\n\n // 测量用DOM\n const span = document.createElement('span');\n span.setAttribute('style', style);\n span.style.visibility = 'hidden';\n span.style.whiteSpace = 'nowrap';\n document.body.appendChild(span);\n\n // 测量从头到当前位置宽度以及从头到下一个字符位置宽度\n let index = guessIndex;\n let temp = desc.slice(0, index);\n span.innerText = temp;\n let tempWidth = span.offsetWidth;\n\n let tempNext = desc.slice(0, index + 1);\n span.innerText = tempNext;\n let tempWidthNext = span.offsetWidth;\n\n // 到当前位置宽度 < width && 到下一个字符位置宽度 > width时,认为找到准确阶段位置\n while (tempWidth > width || tempWidthNext <= width) {\n if (tempWidth > width) {\n index--;\n } else {\n index++;\n }\n\n temp = desc.slice(0, index);\n span.innerText = temp;\n tempWidth = span.offsetWidth;\n\n tempNext = desc.slice(0, index + 1);\n span.innerText = tempNext;\n tempWidthNext = span.offsetWidth;\n }\n\n // 处理特殊情况\n if (needTestLetter) {\n index = testLetter(desc, index);\n }\n\n document.body.removeChild(span);\n return index;\n}\nexport function getStrByWithCanvas(\n desc: string,\n width: number,\n character: IRichTextParagraphCharacter,\n // ctx: IContext2d,\n guessIndex: number,\n needTestLetter?: boolean\n): number {\n if (desc.length <= 1) {\n return 0;\n }\n if (!width || width <= 0) {\n return 0;\n }\n const textMeasure = application.graphicUtil.textMeasure;\n // const measurement = textMeasure.measureText(text, character);\n\n // 测量从头到当前位置宽度以及从头到下一个字符位置宽度\n let index = guessIndex;\n let temp = desc.slice(0, index);\n let tempWidth = Math.floor(textMeasure.measureText(temp, character as any).width);\n\n let tempNext = desc.slice(0, index + 1);\n let tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character as any).width);\n\n // 到当前位置宽度 < width && 到下一个字符位置宽度 > width时,认为找到准确阶段位置\n while (tempWidth > width || tempWidthNext <= width) {\n if (tempWidth > width) {\n index--;\n } else {\n index++;\n }\n\n if (index > desc.length) {\n index = desc.length;\n break;\n } else if (index < 0) {\n index = 0;\n break;\n }\n\n temp = desc.slice(0, index);\n tempWidth = Math.floor(textMeasure.measureText(temp, character as any).width);\n\n tempNext = desc.slice(0, index + 1);\n tempWidthNext = Math.floor(textMeasure.measureText(tempNext, character as any).width);\n }\n\n // 处理特殊情况\n if (needTestLetter) {\n index = testLetter(desc, index);\n }\n\n return index;\n}\n\nexport function getWordStartEndIdx(string: string, index: number) {\n let startIdx = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[startIdx - 1]) && regLetter.test(string[startIdx])) ||\n // 行首标点符号处理\n regPunctuation.test(string[startIdx])\n ) {\n startIdx--;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (startIdx <= 0) {\n break;\n }\n }\n\n let endIdx = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[endIdx + 1]) && regLetter.test(string[endIdx])) ||\n // 行首标点符号处理\n regPunctuation.test(string[endIdx])\n ) {\n endIdx++;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (endIdx >= string.length) {\n break;\n }\n }\n endIdx = Math.min(endIdx + 1, string.length);\n\n return {\n startIdx,\n endIdx\n };\n}\n\n/**\n * 向前找到单词结尾处换行\n * @param string\n * @param index\n * @param negativeWrongMatch 如果为true,那么如果无法匹配就会向后找到单词的结尾,否则就直接返回index\n * @returns\n */\nexport function testLetter(string: string, index: number, negativeWrongMatch: boolean = false): number {\n let i = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[i - 1]) && regLetter.test(string[i])) ||\n // 行首标点符号处理\n regPunctuation.test(string[i])\n ) {\n i--;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (i <= 0) {\n return negativeWrongMatch ? testLetter2(string, index) : index;\n }\n }\n return i;\n}\n\n/**\n * 向后找到单词结尾处换行\n * @param string\n * @param index\n * @returns\n */\nexport function testLetter2(string: string, index: number) {\n let i = index;\n // 切分前后都是英文字母数字下划线,向前找到非英文字母处换行\n while (\n (regLetter.test(string[i + 1]) && regLetter.test(string[i])) ||\n // 行首标点符号处理\n regPunctuation.test(string[i])\n ) {\n i++;\n // 无法满足所有条件,放弃匹配,直接截断,避免陷入死循环\n if (i >= string.length) {\n return i;\n }\n }\n return i + 1;\n}\n\n// 测量文字详细信息\nexport function measureTextDom(\n text: string,\n style: string\n): { ascent?: number; height?: number; descent?: number; width?: number } {\n let div;\n\n const span = document.createElement('span');\n const block = document.createElement('div');\n div = document.createElement('div');\n\n block.style.display = 'inline-block';\n block.style.width = '1px';\n block.style.height = '0';\n\n div.style.visibility = 'hidden';\n div.style.position = 'absolute';\n div.style.top = '0';\n div.style.left = '0';\n div.style.width = '500px';\n div.style.height = '200px';\n div.style.whiteSpace = 'nowrap';\n\n div.appendChild(span);\n div.appendChild(block);\n document.body.appendChild(div);\n\n const result: { ascent?: number; height?: number; descent?: number; width?: number } = {};\n try {\n span.setAttribute('style', style);\n span.style.whiteSpace = 'nowrap';\n span.style.display = 'inline-block';\n\n span.innerHTML = '';\n span.appendChild(document.createTextNode(text.replace(/\\s/g, nbsp)));\n\n block.style.verticalAlign = 'baseline';\n result.ascent = block.offsetTop - span.offsetTop;\n block.style.verticalAlign = 'bottom';\n result.height = block.offsetTop - span.offsetTop;\n result.descent = result.height - result.ascent;\n result.width = span.offsetWidth;\n } finally {\n div.parentNode?.removeChild(div);\n div = null;\n }\n return result;\n}\n\n// 测量文字详细信息\nexport function measureTextCanvas(\n text: string,\n character: IRichTextParagraphCharacter,\n mode: 'actual' | 'font' = 'actual'\n): { ascent: number; height: number; descent: number; width: number } {\n if (text === '') {\n return {\n ascent: 0,\n height: 0,\n descent: 0,\n width: 0\n };\n }\n const textMeasure = application.graphicUtil.textMeasure;\n const measurement = textMeasure.measureText(text, character as any) as TextMetrics;\n const result: { ascent: number; height: number; descent: number; width: number } = {\n ascent: 0,\n height: 0,\n descent: 0,\n width: 0\n };\n const ascent = mode === 'actual' ? measurement.actualBoundingBoxAscent : measurement.fontBoundingBoxAscent;\n const descent = mode === 'actual' ? measurement.actualBoundingBoxDescent : measurement.fontBoundingBoxDescent;\n if (typeof ascent !== 'number' || typeof descent !== 'number') {\n result.width = Math.floor(measurement.width);\n result.height = character.fontSize || 0;\n result.ascent = result.height;\n result.descent = 0;\n } else {\n result.width = Math.floor(measurement.width);\n result.height = Math.floor(ascent + descent);\n result.ascent = Math.floor(ascent);\n result.descent = result.height - result.ascent;\n }\n const space = character.space ?? 0;\n result.width += space;\n return result;\n}\n\nexport function getFontString(character: IRichTextParagraphCharacter, ctx: IContext2d | null) {\n let fontSize = (character && character.fontSize) || defaultFormatting.fontSize;\n\n if (character) {\n switch (character.script) {\n case 'super':\n case 'sub':\n fontSize *= 0.8;\n break;\n }\n }\n\n return (\n ((character && character.fontStyle) || '') +\n ' ' +\n ((character && character.fontWeight) || '') +\n ' ' +\n (fontSize || 12) +\n 'px ' +\n ((character && character.fontFamily) || defaultFormatting.fontFamily)\n );\n}\n"]}
|
package/es/graphic/richtext.d.ts
CHANGED
|
@@ -95,6 +95,9 @@ export declare class RichText extends Graphic<IRichTextGraphicAttribute> impleme
|
|
|
95
95
|
strokeOpacity: number;
|
|
96
96
|
background?: string;
|
|
97
97
|
backgroundOpacity?: number;
|
|
98
|
+
space?: number;
|
|
99
|
+
dx?: number;
|
|
100
|
+
dy?: number;
|
|
98
101
|
} | {
|
|
99
102
|
lineHeight?: string | number;
|
|
100
103
|
textAlign?: CanvasTextAlign;
|
package/es/graphic/richtext.js
CHANGED
|
@@ -142,7 +142,7 @@ export class RichText extends Graphic {
|
|
|
142
142
|
}
|
|
143
143
|
updateAABBBounds(attribute, richtextTheme, aabbBounds) {
|
|
144
144
|
var _a, _b, _c, _d;
|
|
145
|
-
const {width: width = richtextTheme.width, height: height = richtextTheme.height, maxWidth: maxWidth = richtextTheme.maxWidth, maxHeight: maxHeight = richtextTheme.maxHeight, textAlign: textAlign = richtextTheme.textAlign,
|
|
145
|
+
const {width: width = richtextTheme.width, height: height = richtextTheme.height, maxWidth: maxWidth = richtextTheme.maxWidth, maxHeight: maxHeight = richtextTheme.maxHeight, textAlign: textAlign = richtextTheme.textAlign, textBaseline: textBaseline = (null !== (_b = null !== (_a = attribute.textBaseline) && void 0 !== _a ? _a : richtextTheme.textBaseline) && void 0 !== _b ? _b : "top"), editOptions: editOptions} = attribute;
|
|
146
146
|
if (width > 0 && height > 0) aabbBounds.set(0, 0, width, height); else {
|
|
147
147
|
const frameCache = this.getFrameCache(), {width: actualWidth, height: actualHeight} = frameCache.getActualSize();
|
|
148
148
|
let contentWidth = width || actualWidth || 0, contentHeight = height || actualHeight || 0;
|
|
@@ -153,7 +153,7 @@ export class RichText extends Graphic {
|
|
|
153
153
|
editOptions && editOptions.keepHeightWhileEmpty && !aabbBounds.height() && !(null === (_c = attribute.textConfig) || void 0 === _c ? void 0 : _c.length) && (aabbBounds.y2 = aabbBounds.y1 + (null !== (_d = attribute.fontSize) && void 0 !== _d ? _d : 12),
|
|
154
154
|
aabbBounds.x2 = aabbBounds.x1 + 2);
|
|
155
155
|
let deltaY = 0;
|
|
156
|
-
switch (
|
|
156
|
+
switch (textBaseline) {
|
|
157
157
|
case "top":
|
|
158
158
|
deltaY = 0;
|
|
159
159
|
break;
|
|
@@ -180,6 +180,7 @@ export class RichText extends Graphic {
|
|
|
180
180
|
}
|
|
181
181
|
return aabbBounds.translate(deltaX, deltaY), application.graphicService.updateTempAABBBounds(aabbBounds),
|
|
182
182
|
null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, richtextTheme, aabbBounds),
|
|
183
|
+
this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1, this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1,
|
|
183
184
|
application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, !1, this),
|
|
184
185
|
0 === aabbBounds.width() && 0 === aabbBounds.height() && aabbBounds.clear(), aabbBounds;
|
|
185
186
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/richtext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAkBtD,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,OAAO,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnD,IAAI,WAAW,GAAG,KAAK,CAAC;AACxB,IAAI;IACF,WAAW,GAAG,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\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 // 都为0的话,就直接clear\n if (aabbBounds.width() === 0 && aabbBounds.height() === 0) {\n aabbBounds.clear();\n }\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 lineHeight,\n strokeOpacity,\n upgradeAttrs\n } = this.attribute;\n const out = {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity,\n ...config\n };\n if (upgradeAttrs?.lineHeight) {\n out.lineHeight = lineHeight;\n }\n return out;\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 upgradeAttrs\n } = this.attribute;\n\n const enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;\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 if (j === 0) {\n paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));\n } else if (textParts[j] || i === textConfig.length - 1) {\n paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));\n } else {\n // 空行的话,config应该要和下一行对齐\n const nextRichTextConfig = this.combinedStyleToCharacter(\n textConfig[i + 1] as IRichTextParagraphCharacter\n ) as IRichTextParagraphCharacter;\n paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));\n }\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 = enableMultiBreakLine;\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 (enableMultiBreakLine) {\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,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAkBtD,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,sBAAsB,CAAC;AAC7C,OAAO,OAAO,MAAM,o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AO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;;AA1nBM,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,mBAAmB,EACtB;AAonBJ,MAAM,UAAU,cAAc,CAAC,UAAqC;IAClE,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC","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 textBaseline = attribute.textBaseline ?? richtextTheme.textBaseline ?? 'top',\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 this.widthWithoutTransform = aabbBounds.x2 - aabbBounds.x1;\n this.heightWithoutTransform = aabbBounds.y2 - aabbBounds.y1;\n\n application.graphicService.transformAABBBounds(attribute, aabbBounds, richtextTheme, false, this);\n // 都为0的话,就直接clear\n if (aabbBounds.width() === 0 && aabbBounds.height() === 0) {\n aabbBounds.clear();\n }\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 lineHeight,\n strokeOpacity,\n upgradeAttrs\n } = this.attribute;\n const out = {\n fill,\n stroke,\n fontSize,\n fontFamily,\n fontStyle,\n fontWeight,\n lineWidth,\n opacity,\n fillOpacity,\n strokeOpacity,\n ...config\n };\n if (upgradeAttrs?.lineHeight) {\n out.lineHeight = lineHeight;\n }\n return out;\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 upgradeAttrs\n } = this.attribute;\n\n const enableMultiBreakLine = upgradeAttrs && upgradeAttrs.multiBreakLine;\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 if (j === 0) {\n paragraphs.push(new Paragraph(textParts[j], false, richTextConfig, ascentDescentMode));\n } else if (textParts[j] || i === textConfig.length - 1) {\n paragraphs.push(new Paragraph(textParts[j], true, richTextConfig, ascentDescentMode));\n } else {\n // 空行的话,config应该要和下一行对齐\n const nextRichTextConfig = this.combinedStyleToCharacter(\n textConfig[i + 1] as IRichTextParagraphCharacter\n ) as IRichTextParagraphCharacter;\n paragraphs.push(new Paragraph(textParts[j], true, nextRichTextConfig, ascentDescentMode));\n }\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 = enableMultiBreakLine;\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 (enableMultiBreakLine) {\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"]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { IAABBBounds, IPointLike } from '@visactor/vutils';
|
|
2
|
+
import { Graphic } from './graphic';
|
|
3
|
+
import type { IStar, IStarGraphicAttribute } from '../interface/graphic/star';
|
|
4
|
+
import type { GraphicType } from '../interface';
|
|
5
|
+
export declare class Star extends Graphic<IStarGraphicAttribute> implements IStar {
|
|
6
|
+
type: GraphicType;
|
|
7
|
+
static NOWORK_ANIMATE_ATTR: {
|
|
8
|
+
strokeSeg: number;
|
|
9
|
+
boundsPadding: number;
|
|
10
|
+
pickMode: number;
|
|
11
|
+
boundsMode: number;
|
|
12
|
+
customPickShape: number;
|
|
13
|
+
pickable: number;
|
|
14
|
+
childrenPickable: number;
|
|
15
|
+
visible: number;
|
|
16
|
+
zIndex: number;
|
|
17
|
+
layout: number;
|
|
18
|
+
keepDirIn3d: number;
|
|
19
|
+
globalZIndex: number;
|
|
20
|
+
outerBorder: number;
|
|
21
|
+
innerBorder: number;
|
|
22
|
+
lineDash: number;
|
|
23
|
+
lineCap: number;
|
|
24
|
+
lineJoin: number;
|
|
25
|
+
miterLimit: number;
|
|
26
|
+
strokeBoundsBuffer: number;
|
|
27
|
+
scaleCenter: number;
|
|
28
|
+
anchor: number;
|
|
29
|
+
anchor3d: number;
|
|
30
|
+
postMatrix: number;
|
|
31
|
+
backgroundMode: number;
|
|
32
|
+
background: number;
|
|
33
|
+
texture: number;
|
|
34
|
+
cursor: number;
|
|
35
|
+
html: number;
|
|
36
|
+
};
|
|
37
|
+
_cachedPoints: IPointLike[];
|
|
38
|
+
constructor(params: IStarGraphicAttribute);
|
|
39
|
+
isValid(): boolean;
|
|
40
|
+
protected _isValid(): boolean;
|
|
41
|
+
getGraphicTheme(): Required<IStarGraphicAttribute>;
|
|
42
|
+
protected updateAABBBounds(attribute: IStarGraphicAttribute, rectTheme: Required<IStarGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
|
|
43
|
+
getCachedPoints(): IPointLike[];
|
|
44
|
+
private getStarPoints;
|
|
45
|
+
protected _interpolate(key: string, ratio: number, lastStepVal: any, nextStepVal: any, nextAttributes: any): void;
|
|
46
|
+
protected needUpdateTags(keys: string[]): boolean;
|
|
47
|
+
protected needUpdateTag(key: string): boolean;
|
|
48
|
+
toCustomPath(): import("../interface").ICustomPath2D;
|
|
49
|
+
clone(): Star;
|
|
50
|
+
getNoWorkAnimateAttr(): Record<string, number>;
|
|
51
|
+
}
|
|
52
|
+
export declare function createStar(attributes: IStarGraphicAttribute): IStar;
|