@visactor/vrender-core 0.21.0-alpha.1 → 0.21.0-alpha.3
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/common/3d-interceptor.js +2 -1
- package/cjs/common/bounds-context.js +1 -2
- package/cjs/common/morphing-utils.js +1 -1
- package/cjs/common/path-svg.js +4 -4
- package/cjs/common/path-svg.js.map +1 -1
- package/cjs/common/polygon.js +2 -2
- package/cjs/common/rect-utils.js +1 -1
- package/cjs/common/render-area.js +1 -1
- package/cjs/common/render-command-list.js +2 -1
- package/cjs/common/render-curve.js +1 -1
- package/cjs/common/render-utils.js +1 -1
- package/cjs/common/seg-context.js +1 -1
- package/cjs/common/simplify.js +3 -4
- package/cjs/common/simplify.js.map +1 -1
- package/cjs/common/sort.js +1 -1
- package/cjs/common/split-path.js +1 -1
- package/cjs/common/store.js +1 -1
- package/cjs/common/text.js.map +1 -1
- package/cjs/core/application.js +1 -2
- package/cjs/core/camera.js +1 -1
- package/cjs/core/constants.js +1 -1
- package/cjs/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/cjs/core/contributions/textMeasure/AtextMeasure.js +105 -18
- package/cjs/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/cjs/core/contributions/textMeasure/layout.d.ts +0 -1
- package/cjs/core/contributions/textMeasure/layout.js +20 -30
- package/cjs/core/contributions/textMeasure/layout.js.map +1 -1
- package/cjs/core/core-modules.js +1 -1
- package/cjs/core/global-module.js +0 -2
- package/cjs/core/global.js +1 -1
- package/cjs/core/graphic-utils.js +1 -1
- package/cjs/core/index.js +1 -1
- package/cjs/core/layer-service.js +1 -1
- package/cjs/core/layer.js +1 -1
- package/cjs/core/light.js +1 -1
- package/cjs/core/stage.d.ts +3 -0
- package/cjs/core/stage.js +12 -3
- package/cjs/core/stage.js.map +1 -1
- package/cjs/core/window.js +4 -3
- package/cjs/core/window.js.map +1 -1
- package/cjs/event/event-manager.d.ts +1 -0
- package/cjs/event/event-manager.js +1 -1
- package/cjs/event/event-manager.js.map +1 -1
- package/cjs/event/event-system.js +2 -1
- package/cjs/event/event-system.js.map +1 -1
- package/cjs/graphic/config.js +3 -0
- package/cjs/graphic/config.js.map +1 -1
- package/cjs/graphic/text.d.ts +10 -11
- package/cjs/graphic/text.js +91 -174
- package/cjs/graphic/text.js.map +1 -1
- package/cjs/graphic/text2.d.ts +81 -0
- package/cjs/graphic/text2.js +288 -0
- package/cjs/graphic/text2.js.map +1 -0
- package/cjs/graphic/wrap-text.js +12 -4
- package/cjs/graphic/wrap-text.js.map +1 -1
- package/cjs/interface/graphic/text.d.ts +3 -3
- package/cjs/interface/graphic/text.js.map +1 -1
- package/cjs/interface/graphic.d.ts +1 -0
- package/cjs/interface/graphic.js.map +1 -1
- package/cjs/interface/stage.d.ts +1 -0
- package/cjs/interface/stage.js.map +1 -1
- package/cjs/interface/text.d.ts +6 -1
- package/cjs/interface/text.js.map +1 -1
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js +48 -0
- package/cjs/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/cjs/render/contributions/render/arc-render.js +30 -18
- package/cjs/render/contributions/render/arc-render.js.map +1 -1
- package/cjs/render/contributions/render/area-render.js +40 -36
- package/cjs/render/contributions/render/area-render.js.map +1 -1
- package/cjs/render/contributions/render/circle-render.js +10 -5
- package/cjs/render/contributions/render/circle-render.js.map +1 -1
- package/cjs/render/contributions/render/group-render.js +10 -5
- package/cjs/render/contributions/render/group-render.js.map +1 -1
- package/cjs/render/contributions/render/image-render.js +26 -22
- package/cjs/render/contributions/render/image-render.js.map +1 -1
- package/cjs/render/contributions/render/path-render.js +10 -5
- package/cjs/render/contributions/render/path-render.js.map +1 -1
- package/cjs/render/contributions/render/polygon-render.js +10 -5
- package/cjs/render/contributions/render/polygon-render.js.map +1 -1
- package/cjs/render/contributions/render/rect-render.js +10 -5
- package/cjs/render/contributions/render/rect-render.js.map +1 -1
- package/cjs/render/contributions/render/symbol-render.js +18 -8
- package/cjs/render/contributions/render/symbol-render.js.map +1 -1
- package/cjs/render/contributions/render/text-render.js +1 -23
- package/cjs/render/contributions/render/text-render.js.map +1 -1
- package/dist/index.es.js +804 -710
- package/es/common/3d-interceptor.js +2 -1
- package/es/common/bounds-context.js +1 -2
- package/es/common/morphing-utils.js +1 -1
- package/es/common/path-svg.js +4 -4
- package/es/common/path-svg.js.map +1 -1
- package/es/common/polygon.js +1 -1
- package/es/common/rect-utils.js +1 -1
- package/es/common/render-area.js +1 -1
- package/es/common/render-command-list.js +2 -1
- package/es/common/render-curve.js +1 -1
- package/es/common/render-utils.js +1 -1
- package/es/common/seg-context.js +1 -1
- package/es/common/simplify.js +3 -4
- package/es/common/simplify.js.map +1 -1
- package/es/common/sort.js +1 -1
- package/es/common/split-path.js +1 -1
- package/es/common/store.js +1 -1
- package/es/common/text.js.map +1 -1
- package/es/core/application.js +1 -2
- package/es/core/camera.js +1 -1
- package/es/core/constants.js +1 -1
- package/es/core/contributions/textMeasure/AtextMeasure.d.ts +55 -4
- package/es/core/contributions/textMeasure/AtextMeasure.js +106 -17
- package/es/core/contributions/textMeasure/AtextMeasure.js.map +1 -1
- package/es/core/contributions/textMeasure/layout.d.ts +0 -1
- package/es/core/contributions/textMeasure/layout.js +20 -30
- package/es/core/contributions/textMeasure/layout.js.map +1 -1
- package/es/core/core-modules.js +1 -1
- package/es/core/global-module.js +0 -2
- package/es/core/global.js +1 -1
- package/es/core/graphic-utils.js +1 -1
- package/es/core/index.js +1 -1
- package/es/core/layer-service.js +1 -1
- package/es/core/layer.js +1 -1
- package/es/core/light.js +1 -1
- package/es/core/stage.d.ts +3 -0
- package/es/core/stage.js +13 -2
- package/es/core/stage.js.map +1 -1
- package/es/core/window.js +4 -2
- package/es/core/window.js.map +1 -1
- package/es/event/event-manager.d.ts +1 -0
- package/es/event/event-manager.js +1 -1
- package/es/event/event-manager.js.map +1 -1
- package/es/event/event-system.js +2 -1
- package/es/event/event-system.js.map +1 -1
- package/es/graphic/config.js +3 -0
- package/es/graphic/config.js.map +1 -1
- package/es/graphic/text.d.ts +10 -11
- package/es/graphic/text.js +90 -169
- package/es/graphic/text.js.map +1 -1
- package/es/graphic/text2.d.ts +81 -0
- package/es/graphic/text2.js +293 -0
- package/es/graphic/text2.js.map +1 -0
- package/es/graphic/wrap-text.js +12 -4
- package/es/graphic/wrap-text.js.map +1 -1
- package/es/interface/graphic/text.d.ts +3 -3
- package/es/interface/graphic/text.js.map +1 -1
- package/es/interface/graphic.d.ts +1 -0
- package/es/interface/graphic.js.map +1 -1
- package/es/interface/stage.d.ts +1 -0
- package/es/interface/stage.js.map +1 -1
- package/es/interface/text.d.ts +6 -1
- package/es/interface/text.js.map +1 -1
- package/es/plugins/builtin-plugin/auto-refresh-plugin.d.ts +16 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js +41 -0
- package/es/plugins/builtin-plugin/auto-refresh-plugin.js.map +1 -0
- package/es/render/contributions/render/arc-render.js +30 -18
- package/es/render/contributions/render/arc-render.js.map +1 -1
- package/es/render/contributions/render/area-render.js +40 -36
- package/es/render/contributions/render/area-render.js.map +1 -1
- package/es/render/contributions/render/circle-render.js +10 -5
- package/es/render/contributions/render/circle-render.js.map +1 -1
- package/es/render/contributions/render/group-render.js +10 -5
- package/es/render/contributions/render/group-render.js.map +1 -1
- package/es/render/contributions/render/image-render.js +26 -22
- package/es/render/contributions/render/image-render.js.map +1 -1
- package/es/render/contributions/render/path-render.js +10 -5
- package/es/render/contributions/render/path-render.js.map +1 -1
- package/es/render/contributions/render/polygon-render.js +10 -5
- package/es/render/contributions/render/polygon-render.js.map +1 -1
- package/es/render/contributions/render/rect-render.js +10 -5
- package/es/render/contributions/render/rect-render.js.map +1 -1
- package/es/render/contributions/render/symbol-render.js +18 -8
- package/es/render/contributions/render/symbol-render.js.map +1 -1
- package/es/render/contributions/render/text-render.js +1 -23
- package/es/render/contributions/render/text-render.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { IAABBBounds } from '@visactor/vutils';
|
|
2
|
+
import type { IText, ITextCache, ITextGraphicAttribute, LayoutType } from '../interface';
|
|
3
|
+
import { Graphic } from './graphic';
|
|
4
|
+
export declare class Text extends Graphic<ITextGraphicAttribute> implements IText {
|
|
5
|
+
type: 'text';
|
|
6
|
+
static NOWORK_ANIMATE_ATTR: {
|
|
7
|
+
strokeSeg: number;
|
|
8
|
+
boundsPadding: number;
|
|
9
|
+
pickMode: number;
|
|
10
|
+
boundsMode: number;
|
|
11
|
+
customPickShape: number;
|
|
12
|
+
pickable: number;
|
|
13
|
+
childrenPickable: number;
|
|
14
|
+
visible: number;
|
|
15
|
+
zIndex: number;
|
|
16
|
+
layout: number;
|
|
17
|
+
keepDirIn3d: number;
|
|
18
|
+
globalZIndex: number;
|
|
19
|
+
outerBorder: number;
|
|
20
|
+
innerBorder: number;
|
|
21
|
+
lineDash: number;
|
|
22
|
+
lineCap: number;
|
|
23
|
+
lineJoin: number;
|
|
24
|
+
miterLimit: number;
|
|
25
|
+
strokeBoundsBuffer: number;
|
|
26
|
+
scaleCenter: number;
|
|
27
|
+
anchor: number;
|
|
28
|
+
anchor3d: number;
|
|
29
|
+
postMatrix: number;
|
|
30
|
+
backgroundMode: number;
|
|
31
|
+
background: number;
|
|
32
|
+
texture: number;
|
|
33
|
+
cursor: number;
|
|
34
|
+
html: number;
|
|
35
|
+
ellipsis: number;
|
|
36
|
+
wordBreak: number;
|
|
37
|
+
direction: number;
|
|
38
|
+
textAlign: number;
|
|
39
|
+
textBaseline: number;
|
|
40
|
+
fontFamily: number;
|
|
41
|
+
fontWeight: number;
|
|
42
|
+
};
|
|
43
|
+
cache: ITextCache;
|
|
44
|
+
_font: string;
|
|
45
|
+
get font(): string;
|
|
46
|
+
get clipedText(): string | undefined;
|
|
47
|
+
get clipedWidth(): number | undefined;
|
|
48
|
+
get cliped(): boolean | undefined;
|
|
49
|
+
get multilineLayout(): LayoutType | undefined;
|
|
50
|
+
get isMultiLine(): boolean;
|
|
51
|
+
constructor(params?: ITextGraphicAttribute);
|
|
52
|
+
isValid(): boolean;
|
|
53
|
+
protected _isValid(): boolean;
|
|
54
|
+
getGraphicTheme(): Required<ITextGraphicAttribute>;
|
|
55
|
+
protected updateAABBBounds(attribute: ITextGraphicAttribute, textTheme: Required<ITextGraphicAttribute>, aabbBounds: IAABBBounds): import("@visactor/vutils").IBounds;
|
|
56
|
+
updateSingallineAABBBounds(text: number | string): IAABBBounds;
|
|
57
|
+
protected updateMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
|
|
58
|
+
updateHorizontalMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
|
|
59
|
+
updateWrapAABBBounds(text: (number | string) | (number | string)[]): import("@visactor/vutils").IBounds;
|
|
60
|
+
updateVerticalMultilineAABBBounds(text: (number | string)[]): IAABBBounds;
|
|
61
|
+
protected isSinglelineAndHorizontal(): boolean;
|
|
62
|
+
protected getMaxWidth(theme: ITextGraphicAttribute): number;
|
|
63
|
+
protected getLineHeight(attribute: ITextGraphicAttribute, textTheme: ITextGraphicAttribute): number;
|
|
64
|
+
protected needUpdateTags(keys: string[], k?: string[]): boolean;
|
|
65
|
+
protected needUpdateTag(key: string, k?: string[]): boolean;
|
|
66
|
+
clone(): Text;
|
|
67
|
+
getNoWorkAnimateAttr(): Record<string, number>;
|
|
68
|
+
getBaselineMapAlign(): Record<string, string>;
|
|
69
|
+
getAlignMapBaseline(): Record<string, string>;
|
|
70
|
+
static baselineMapAlign: {
|
|
71
|
+
top: string;
|
|
72
|
+
bottom: string;
|
|
73
|
+
middle: string;
|
|
74
|
+
};
|
|
75
|
+
static alignMapBaseline: {
|
|
76
|
+
left: string;
|
|
77
|
+
right: string;
|
|
78
|
+
center: string;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export declare function createText(attributes: ITextGraphicAttribute): IText;
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { max, isArray, getContextFont, transformBoundsWithMatrix } from "@visactor/vutils";
|
|
2
|
+
|
|
3
|
+
import { textDrawOffsetX, textLayoutOffsetY } from "../common/text";
|
|
4
|
+
|
|
5
|
+
import { CanvasTextLayout } from "../core/contributions/textMeasure/layout";
|
|
6
|
+
|
|
7
|
+
import { application } from "../application";
|
|
8
|
+
|
|
9
|
+
import { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from "./graphic";
|
|
10
|
+
|
|
11
|
+
import { getTheme } from "./theme";
|
|
12
|
+
|
|
13
|
+
import { calculateLineHeight } from "../common/utils";
|
|
14
|
+
|
|
15
|
+
import { TEXT_NUMBER_TYPE } from "./constants";
|
|
16
|
+
|
|
17
|
+
import { boundStroke, TextDirection, verticalLayout } from "./tools";
|
|
18
|
+
|
|
19
|
+
const TEXT_UPDATE_TAG_KEY = [ "text", "maxLineWidth", "maxWidth", "textAlign", "textBaseline", "heightLimit", "lineClamp", "fontSize", "fontFamily", "fontWeight", "ellipsis", "lineHeight", "direction", "wordBreak", "heightLimit", "lineClamp", ...GRAPHIC_UPDATE_TAG_KEY ];
|
|
20
|
+
|
|
21
|
+
export class Text extends Graphic {
|
|
22
|
+
get font() {
|
|
23
|
+
const textTheme = this.getGraphicTheme();
|
|
24
|
+
return this._font || (this._font = getContextFont(this.attribute, textTheme)), this._font;
|
|
25
|
+
}
|
|
26
|
+
get clipedText() {
|
|
27
|
+
var _a;
|
|
28
|
+
const attribute = this.attribute, textTheme = this.getGraphicTheme();
|
|
29
|
+
if (!this.isSinglelineAndHorizontal()) return;
|
|
30
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
31
|
+
return Number.isFinite(maxWidth) ? (this.tryUpdateAABBBounds(), this.cache.clipedText) : (null !== (_a = attribute.text) && void 0 !== _a ? _a : textTheme.text).toString();
|
|
32
|
+
}
|
|
33
|
+
get clipedWidth() {
|
|
34
|
+
if (this.isSinglelineAndHorizontal()) return this.tryUpdateAABBBounds(), this.cache.clipedWidth;
|
|
35
|
+
}
|
|
36
|
+
get cliped() {
|
|
37
|
+
const textTheme = this.getGraphicTheme(), attribute = this.attribute;
|
|
38
|
+
if (this.isMultiLine) return;
|
|
39
|
+
const maxWidth = this.getMaxWidth(textTheme);
|
|
40
|
+
return !!Number.isFinite(maxWidth) && (this.tryUpdateAABBBounds(), "vertical" === attribute.direction && this.cache.verticalList && this.cache.verticalList[0] ? this.cache.verticalList[0].map((item => item.text)).join("") !== attribute.text.toString() : null != this.clipedText && this.clipedText !== attribute.text.toString());
|
|
41
|
+
}
|
|
42
|
+
get multilineLayout() {
|
|
43
|
+
return this.tryUpdateAABBBounds(), this.cache.layoutData;
|
|
44
|
+
}
|
|
45
|
+
get isMultiLine() {
|
|
46
|
+
return Array.isArray(this.attribute.text) || "normal" === this.attribute.whiteSpace;
|
|
47
|
+
}
|
|
48
|
+
constructor(params = {
|
|
49
|
+
text: "",
|
|
50
|
+
fontSize: 16
|
|
51
|
+
}) {
|
|
52
|
+
super(params), this.type = "text", this.numberType = TEXT_NUMBER_TYPE, this.cache = {};
|
|
53
|
+
}
|
|
54
|
+
isValid() {
|
|
55
|
+
return super.isValid() && this._isValid();
|
|
56
|
+
}
|
|
57
|
+
_isValid() {
|
|
58
|
+
const {text: text} = this.attribute;
|
|
59
|
+
return isArray(text) ? !text.every((t => null == t || "" === t)) : null != text && "" !== text;
|
|
60
|
+
}
|
|
61
|
+
getGraphicTheme() {
|
|
62
|
+
return getTheme(this).text;
|
|
63
|
+
}
|
|
64
|
+
updateAABBBounds(attribute, textTheme, aabbBounds) {
|
|
65
|
+
const {text: text = textTheme.text} = this.attribute;
|
|
66
|
+
Array.isArray(text) ? this.updateMultilineAABBBounds(text) : this.updateSingallineAABBBounds(text);
|
|
67
|
+
const {tb1: tb1} = application.graphicService.updateTempAABBBounds(aabbBounds), {scaleX: scaleX = textTheme.scaleX, scaleY: scaleY = textTheme.scaleY, shadowBlur: shadowBlur = textTheme.shadowBlur, strokeBoundsBuffer: strokeBoundsBuffer = textTheme.strokeBoundsBuffer} = attribute;
|
|
68
|
+
if (shadowBlur) {
|
|
69
|
+
const shadowBlurHalfWidth = shadowBlur / Math.abs(scaleX + scaleY);
|
|
70
|
+
boundStroke(tb1, shadowBlurHalfWidth, !0, strokeBoundsBuffer), aabbBounds.union(tb1);
|
|
71
|
+
}
|
|
72
|
+
return application.graphicService.combindShadowAABBBounds(aabbBounds, this), null == attribute.forceBoundsHeight && null == attribute.forceBoundsWidth || application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds),
|
|
73
|
+
transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix), aabbBounds;
|
|
74
|
+
}
|
|
75
|
+
updateSingallineAABBBounds(text) {
|
|
76
|
+
return this.updateMultilineAABBBounds([ text ]);
|
|
77
|
+
}
|
|
78
|
+
updateMultilineAABBBounds(text) {
|
|
79
|
+
const textTheme = this.getGraphicTheme(), {direction: direction = textTheme.direction, underlineOffset: underlineOffset = textTheme.underlineOffset} = this.attribute, b = "horizontal" === direction ? this.updateHorizontalMultilineAABBBounds(text) : this.updateVerticalMultilineAABBBounds(text);
|
|
80
|
+
return "horizontal" === direction && underlineOffset && this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset),
|
|
81
|
+
b;
|
|
82
|
+
}
|
|
83
|
+
updateHorizontalMultilineAABBBounds(text) {
|
|
84
|
+
var _a;
|
|
85
|
+
const textTheme = this.getGraphicTheme(), attribute = this.attribute, {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, fontWeight: fontWeight = textTheme.fontWeight, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, wrap: wrap = textTheme.wrap, lineWidth: lineWidth = textTheme.lineWidth, whiteSpace: whiteSpace = textTheme.whiteSpace, suffixPosition: suffixPosition = textTheme.suffixPosition} = attribute, lineHeight = this.getLineHeight(attribute, textTheme);
|
|
86
|
+
if ("normal" === whiteSpace || wrap) return this.updateWrapAABBBounds(text);
|
|
87
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
88
|
+
const bbox = this.cache.layoutData.bbox;
|
|
89
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
|
|
90
|
+
stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
91
|
+
}
|
|
92
|
+
const textMeasure = application.graphicUtil.textMeasure, layoutData = new CanvasTextLayout(fontFamily, {
|
|
93
|
+
fontSize: fontSize,
|
|
94
|
+
fontWeight: fontWeight,
|
|
95
|
+
fontFamily: fontFamily
|
|
96
|
+
}, textMeasure).GetLayoutByLines(text, textAlign, textBaseline, lineHeight, !0 === ellipsis ? textTheme.ellipsis : ellipsis || void 0, !1, maxLineWidth, suffixPosition), {bbox: bbox} = layoutData;
|
|
97
|
+
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
|
|
98
|
+
stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
99
|
+
}
|
|
100
|
+
updateWrapAABBBounds(text) {
|
|
101
|
+
var _a, _b, _c;
|
|
102
|
+
const textTheme = this.getGraphicTheme(), {fontFamily: fontFamily = textTheme.fontFamily, textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline, fontSize: fontSize = textTheme.fontSize, ellipsis: ellipsis = textTheme.ellipsis, maxLineWidth: maxLineWidth, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, wordBreak: wordBreak = textTheme.wordBreak, fontWeight: fontWeight = textTheme.fontWeight, ignoreBuf: ignoreBuf = textTheme.ignoreBuf, suffixPosition: suffixPosition = textTheme.suffixPosition, heightLimit: heightLimit = 0, lineClamp: lineClamp} = this.attribute, lineHeight = this.getLineHeight(this.attribute, textTheme);
|
|
103
|
+
if (!this.shouldUpdateShape() && (null === (_a = this.cache) || void 0 === _a ? void 0 : _a.layoutData)) {
|
|
104
|
+
const bbox = this.cache.layoutData.bbox;
|
|
105
|
+
return this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
|
|
106
|
+
stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
107
|
+
}
|
|
108
|
+
const textMeasure = application.graphicUtil.textMeasure, textOptions = {
|
|
109
|
+
fontSize: fontSize,
|
|
110
|
+
fontWeight: fontWeight,
|
|
111
|
+
fontFamily: fontFamily
|
|
112
|
+
}, layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure), lines = isArray(text) ? text.map((l => l.toString())) : [ text.toString() ], linesLayout = [], bboxWH = [ 0, 0 ];
|
|
113
|
+
let lineCountLimit = 1 / 0;
|
|
114
|
+
if (heightLimit > 0 && (lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1)),
|
|
115
|
+
lineClamp && (lineCountLimit = Math.min(lineCountLimit, lineClamp)), "number" == typeof maxLineWidth && maxLineWidth !== 1 / 0) {
|
|
116
|
+
if (maxLineWidth > 0) for (let i = 0; i < lines.length; i++) {
|
|
117
|
+
const str = lines[i];
|
|
118
|
+
let needCut = !0;
|
|
119
|
+
if (i === lineCountLimit - 1) {
|
|
120
|
+
const clip = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition, i !== lines.length - 1), matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
121
|
+
linesLayout.push({
|
|
122
|
+
str: clip.str,
|
|
123
|
+
width: clip.width,
|
|
124
|
+
ascent: matrics.ascent,
|
|
125
|
+
descent: matrics.descent
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
const clip = textMeasure.clipText(str, textOptions, maxLineWidth, "break-word" === wordBreak);
|
|
130
|
+
if ("" !== str && "" === clip.str) {
|
|
131
|
+
if (ellipsis) {
|
|
132
|
+
const clipEllipsis = textMeasure.clipTextWithSuffix(str, textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
133
|
+
clip.str = null !== (_b = clipEllipsis.str) && void 0 !== _b ? _b : "", clip.width = null !== (_c = clipEllipsis.width) && void 0 !== _c ? _c : 0;
|
|
134
|
+
} else clip.str = "", clip.width = 0;
|
|
135
|
+
needCut = !1;
|
|
136
|
+
}
|
|
137
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
138
|
+
if (linesLayout.push({
|
|
139
|
+
str: clip.str,
|
|
140
|
+
width: clip.width,
|
|
141
|
+
ascent: matrics.ascent,
|
|
142
|
+
descent: matrics.descent
|
|
143
|
+
}), clip.str.length === str.length) ; else if (needCut) {
|
|
144
|
+
const newStr = str.substring(clip.str.length);
|
|
145
|
+
lines.splice(i + 1, 0, newStr);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
let maxWidth = 0;
|
|
149
|
+
linesLayout.forEach((layout => {
|
|
150
|
+
maxWidth = Math.max(maxWidth, layout.width);
|
|
151
|
+
})), bboxWH[0] = maxWidth;
|
|
152
|
+
} else {
|
|
153
|
+
let width, text, lineWidth = 0;
|
|
154
|
+
for (let i = 0, len = lines.length; i < len; i++) {
|
|
155
|
+
if (i === lineCountLimit - 1) {
|
|
156
|
+
const clip = textMeasure.clipTextWithSuffix(lines[i], textOptions, maxLineWidth, ellipsis, !1, suffixPosition), matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);
|
|
157
|
+
linesLayout.push({
|
|
158
|
+
str: clip.str,
|
|
159
|
+
width: clip.width,
|
|
160
|
+
ascent: matrics.ascent,
|
|
161
|
+
descent: matrics.descent
|
|
162
|
+
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
text = lines[i], width = textMeasure.measureTextWidth(text, textOptions), lineWidth = Math.max(lineWidth, width);
|
|
166
|
+
const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);
|
|
167
|
+
linesLayout.push({
|
|
168
|
+
str: text,
|
|
169
|
+
width: width,
|
|
170
|
+
ascent: matrics.ascent,
|
|
171
|
+
descent: matrics.descent
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
bboxWH[0] = lineWidth;
|
|
175
|
+
}
|
|
176
|
+
bboxWH[1] = linesLayout.length * lineHeight;
|
|
177
|
+
const bbox = {
|
|
178
|
+
xOffset: 0,
|
|
179
|
+
yOffset: 0,
|
|
180
|
+
width: bboxWH[0],
|
|
181
|
+
height: bboxWH[1]
|
|
182
|
+
};
|
|
183
|
+
layoutObj.LayoutBBox(bbox, textAlign, textBaseline);
|
|
184
|
+
const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline, lineHeight);
|
|
185
|
+
return this.cache.layoutData = layoutData, this.clearUpdateShapeTag(), this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height),
|
|
186
|
+
stroke && this._AABBBounds.expand(lineWidth / 2), this._AABBBounds;
|
|
187
|
+
}
|
|
188
|
+
updateVerticalMultilineAABBBounds(text) {
|
|
189
|
+
var _a, _b;
|
|
190
|
+
const textTheme = this.getGraphicTheme(), textMeasure = application.graphicUtil.textMeasure;
|
|
191
|
+
let width;
|
|
192
|
+
const attribute = this.attribute, {maxLineWidth: maxLineWidth = textTheme.maxLineWidth, ellipsis: ellipsis = textTheme.ellipsis, fontFamily: fontFamily = textTheme.fontFamily, fontSize: fontSize = textTheme.fontSize, fontWeight: fontWeight = textTheme.fontWeight, stroke: stroke = textTheme.stroke, lineWidth: lineWidth = textTheme.lineWidth, verticalMode: verticalMode = textTheme.verticalMode, suffixPosition: suffixPosition = textTheme.suffixPosition} = attribute, lineHeight = this.getLineHeight(attribute, textTheme);
|
|
193
|
+
let {textAlign: textAlign = textTheme.textAlign, textBaseline: textBaseline = textTheme.textBaseline} = attribute;
|
|
194
|
+
if (!verticalMode) {
|
|
195
|
+
const t = textAlign;
|
|
196
|
+
textAlign = null !== (_a = Text.baselineMapAlign[textBaseline]) && void 0 !== _a ? _a : "left",
|
|
197
|
+
textBaseline = null !== (_b = Text.alignMapBaseline[t]) && void 0 !== _b ? _b : "top";
|
|
198
|
+
}
|
|
199
|
+
if (width = 0, !this.shouldUpdateShape() && this.cache) {
|
|
200
|
+
this.cache.verticalList.forEach((item => {
|
|
201
|
+
const w = item.reduce(((a, b) => a + b.width), 0);
|
|
202
|
+
width = max(w, width);
|
|
203
|
+
}));
|
|
204
|
+
const dx = textDrawOffsetX(textAlign, width), height = this.cache.verticalList.length * lineHeight, dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
205
|
+
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2),
|
|
206
|
+
this._AABBBounds;
|
|
207
|
+
}
|
|
208
|
+
const verticalLists = text.map((str => verticalLayout(str.toString())));
|
|
209
|
+
verticalLists.forEach(((verticalData, i) => {
|
|
210
|
+
if (Number.isFinite(maxLineWidth)) if (ellipsis) {
|
|
211
|
+
const strEllipsis = !0 === ellipsis ? textTheme.ellipsis : ellipsis, data = textMeasure.clipTextWithSuffixVertical(verticalData, {
|
|
212
|
+
fontSize: fontSize,
|
|
213
|
+
fontWeight: fontWeight,
|
|
214
|
+
fontFamily: fontFamily
|
|
215
|
+
}, maxLineWidth, strEllipsis, !1, suffixPosition);
|
|
216
|
+
verticalLists[i] = data.verticalList, width = data.width;
|
|
217
|
+
} else {
|
|
218
|
+
const data = textMeasure.clipTextVertical(verticalData, {
|
|
219
|
+
fontSize: fontSize,
|
|
220
|
+
fontWeight: fontWeight,
|
|
221
|
+
fontFamily: fontFamily
|
|
222
|
+
}, maxLineWidth, !1);
|
|
223
|
+
verticalLists[i] = data.verticalList, width = data.width;
|
|
224
|
+
} else width = 0, verticalData.forEach((t => {
|
|
225
|
+
const w = t.direction === TextDirection.HORIZONTAL ? fontSize : textMeasure.measureTextWidth(t.text, {
|
|
226
|
+
fontSize: fontSize,
|
|
227
|
+
fontWeight: fontWeight,
|
|
228
|
+
fontFamily: fontFamily
|
|
229
|
+
});
|
|
230
|
+
width += w, t.width = w;
|
|
231
|
+
}));
|
|
232
|
+
})), this.cache.verticalList = verticalLists, this.clearUpdateShapeTag(), this.cache.verticalList.forEach((item => {
|
|
233
|
+
const w = item.reduce(((a, b) => a + b.width), 0);
|
|
234
|
+
width = max(w, width);
|
|
235
|
+
}));
|
|
236
|
+
const dx = textDrawOffsetX(textAlign, width), height = this.cache.verticalList.length * lineHeight, dy = textLayoutOffsetY(textBaseline, height, fontSize);
|
|
237
|
+
return this._AABBBounds.set(dy, dx, dy + height, dx + width), stroke && this._AABBBounds.expand(lineWidth / 2),
|
|
238
|
+
this._AABBBounds;
|
|
239
|
+
}
|
|
240
|
+
isSinglelineAndHorizontal() {
|
|
241
|
+
return !this.isMultiLine && "vertical" !== this.attribute.direction;
|
|
242
|
+
}
|
|
243
|
+
getMaxWidth(theme) {
|
|
244
|
+
var _a, _b;
|
|
245
|
+
const attribute = this.attribute;
|
|
246
|
+
return null !== (_b = null !== (_a = attribute.maxLineWidth) && void 0 !== _a ? _a : attribute.maxWidth) && void 0 !== _b ? _b : theme.maxWidth;
|
|
247
|
+
}
|
|
248
|
+
getLineHeight(attribute, textTheme) {
|
|
249
|
+
var _a;
|
|
250
|
+
return null !== (_a = calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize)) && void 0 !== _a ? _a : attribute.fontSize || textTheme.fontSize;
|
|
251
|
+
}
|
|
252
|
+
needUpdateTags(keys, k = TEXT_UPDATE_TAG_KEY) {
|
|
253
|
+
return super.needUpdateTags(keys, k);
|
|
254
|
+
}
|
|
255
|
+
needUpdateTag(key, k = TEXT_UPDATE_TAG_KEY) {
|
|
256
|
+
return super.needUpdateTag(key, k);
|
|
257
|
+
}
|
|
258
|
+
clone() {
|
|
259
|
+
return new Text(Object.assign({}, this.attribute));
|
|
260
|
+
}
|
|
261
|
+
getNoWorkAnimateAttr() {
|
|
262
|
+
return Text.NOWORK_ANIMATE_ATTR;
|
|
263
|
+
}
|
|
264
|
+
getBaselineMapAlign() {
|
|
265
|
+
return Text.baselineMapAlign;
|
|
266
|
+
}
|
|
267
|
+
getAlignMapBaseline() {
|
|
268
|
+
return Text.alignMapBaseline;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
Text.NOWORK_ANIMATE_ATTR = Object.assign({
|
|
273
|
+
ellipsis: 1,
|
|
274
|
+
wordBreak: 1,
|
|
275
|
+
direction: 1,
|
|
276
|
+
textAlign: 1,
|
|
277
|
+
textBaseline: 1,
|
|
278
|
+
fontFamily: 1,
|
|
279
|
+
fontWeight: 1
|
|
280
|
+
}, NOWORK_ANIMATE_ATTR), Text.baselineMapAlign = {
|
|
281
|
+
top: "left",
|
|
282
|
+
bottom: "right",
|
|
283
|
+
middle: "center"
|
|
284
|
+
}, Text.alignMapBaseline = {
|
|
285
|
+
left: "top",
|
|
286
|
+
right: "bottom",
|
|
287
|
+
center: "middle"
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
export function createText(attributes) {
|
|
291
|
+
return new Text(attributes);
|
|
292
|
+
}
|
|
293
|
+
//# sourceMappingURL=text2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/graphic/text2.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,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OAAO;IACf,MAAM,EAAE,QAAQ;CACjB,CAAC;AAEK,qBAAgB,GAAG;IACxB,IAAI,EAAE,KAAK;IACX,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,QAAQ;CACjB,CAAC;AAGJ,MAAM,UAAU,UAAU,CAAC,UAAiC;IAC1D,OAAO,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;AAC9B,CAAC","file":"text2.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport { max, isArray, getContextFont, transformBoundsWithMatrix } from '@visactor/vutils';\nimport { textDrawOffsetX, textLayoutOffsetY } from '../common/text';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport { application } from '../application';\nimport type { IText, ITextCache, ITextGraphicAttribute, LayoutItemType, LayoutType } from '../interface';\nimport { Graphic, GRAPHIC_UPDATE_TAG_KEY, NOWORK_ANIMATE_ATTR } from './graphic';\nimport { getTheme } from './theme';\nimport { calculateLineHeight } from '../common/utils';\nimport { TEXT_NUMBER_TYPE } from './constants';\nimport { boundStroke, TextDirection, verticalLayout } from './tools';\n\nconst TEXT_UPDATE_TAG_KEY = [\n 'text',\n 'maxLineWidth',\n 'maxWidth',\n // 多行文本要用到\n 'textAlign',\n 'textBaseline',\n 'heightLimit',\n 'lineClamp',\n 'fontSize',\n 'fontFamily',\n 'fontWeight',\n 'ellipsis',\n 'lineHeight',\n 'direction',\n 'wordBreak',\n 'heightLimit',\n 'lineClamp',\n ...GRAPHIC_UPDATE_TAG_KEY\n];\n\nexport class Text extends Graphic<ITextGraphicAttribute> implements IText {\n type: 'text' = 'text';\n\n static NOWORK_ANIMATE_ATTR = {\n ellipsis: 1,\n wordBreak: 1,\n direction: 1,\n textAlign: 1,\n textBaseline: 1,\n fontFamily: 1,\n fontWeight: 1,\n ...NOWORK_ANIMATE_ATTR\n };\n\n cache: ITextCache;\n _font: string;\n\n /**\n * 获取font字符串\n */\n get font(): string {\n const textTheme = this.getGraphicTheme();\n if (!this._font) {\n this._font = getContextFont(this.attribute, textTheme);\n }\n return this._font as string;\n }\n\n get clipedText(): string | undefined {\n const attribute = this.attribute;\n const textTheme = this.getGraphicTheme();\n if (!this.isSinglelineAndHorizontal()) {\n return void 0;\n }\n const maxWidth = this.getMaxWidth(textTheme);\n if (!Number.isFinite(maxWidth)) {\n return (attribute.text ?? textTheme.text).toString();\n }\n this.tryUpdateAABBBounds();\n return this.cache.clipedText;\n }\n\n get clipedWidth(): number | undefined {\n if (!this.isSinglelineAndHorizontal()) {\n return void 0;\n }\n this.tryUpdateAABBBounds();\n return this.cache.clipedWidth;\n }\n\n /**\n * 支持单行文本,横排纵排均支持\n * TODO 支持多行文本\n */\n get cliped(): boolean | undefined {\n const textTheme = this.getGraphicTheme();\n const attribute = this.attribute;\n if (this.isMultiLine) {\n return void 0;\n }\n const maxWidth = this.getMaxWidth(textTheme);\n if (!Number.isFinite(maxWidth)) {\n return false;\n }\n this.tryUpdateAABBBounds();\n if (attribute.direction === 'vertical' && this.cache.verticalList && this.cache.verticalList[0]) {\n return this.cache.verticalList[0].map(item => item.text).join('') !== attribute.text.toString();\n }\n if (this.clipedText == null) {\n return false;\n }\n return this.clipedText !== attribute.text.toString();\n }\n\n get multilineLayout(): LayoutType | undefined {\n this.tryUpdateAABBBounds();\n return this.cache.layoutData;\n }\n /**\n * @deprecated 请勿使用,后续不再支持判定是否是单行还是多行,二者逻辑已经统一\n * 是否是多行文本\n */\n get isMultiLine(): boolean {\n return Array.isArray(this.attribute.text) || this.attribute.whiteSpace === 'normal';\n }\n\n constructor(params: ITextGraphicAttribute = { text: '', fontSize: 16 }) {\n super(params);\n this.numberType = TEXT_NUMBER_TYPE;\n this.cache = {};\n }\n\n /**\n * 图元属性合法,且文字不为空或者null/undefined\n * @returns\n */\n isValid(): boolean {\n return super.isValid() && this._isValid();\n }\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n getGraphicTheme(): Required<ITextGraphicAttribute> {\n return getTheme(this).text;\n }\n\n protected updateAABBBounds(\n attribute: ITextGraphicAttribute,\n textTheme: Required<ITextGraphicAttribute>,\n aabbBounds: IAABBBounds\n ) {\n const { text = textTheme.text } = this.attribute;\n if (Array.isArray(text)) {\n this.updateMultilineAABBBounds(text as (number | string)[]);\n } else {\n this.updateSingallineAABBBounds(text as number | string);\n }\n\n const { tb1 } = application.graphicService.updateTempAABBBounds(aabbBounds);\n\n const {\n scaleX = textTheme.scaleX,\n scaleY = textTheme.scaleY,\n shadowBlur = textTheme.shadowBlur,\n strokeBoundsBuffer = textTheme.strokeBoundsBuffer\n } = attribute;\n if (shadowBlur) {\n const shadowBlurHalfWidth = shadowBlur / Math.abs(scaleX + scaleY);\n boundStroke(tb1, shadowBlurHalfWidth, true, strokeBoundsBuffer);\n aabbBounds.union(tb1);\n }\n // 合并shadowRoot的bounds\n application.graphicService.combindShadowAABBBounds(aabbBounds, this);\n\n if (attribute.forceBoundsHeight != null || attribute.forceBoundsWidth != null) {\n application.graphicService.updateHTMLTextAABBBounds(attribute, textTheme, aabbBounds);\n }\n\n transformBoundsWithMatrix(aabbBounds, aabbBounds, this.transMatrix);\n return aabbBounds;\n }\n\n /**\n * 计算单行文字的bounds,可以缓存长度以及截取的文字\n * @param text\n */\n updateSingallineAABBBounds(text: number | string): IAABBBounds {\n return this.updateMultilineAABBBounds([text]);\n }\n\n /**\n * 计算单行文字的bounds,可以缓存长度以及截取的文字\n * @param text\n */\n protected updateMultilineAABBBounds(text: (number | string)[]): IAABBBounds {\n const textTheme = this.getGraphicTheme();\n const { direction = textTheme.direction, underlineOffset = textTheme.underlineOffset } = this.attribute;\n\n const b =\n direction === 'horizontal'\n ? this.updateHorizontalMultilineAABBBounds(text)\n : this.updateVerticalMultilineAABBBounds(text);\n\n if (direction === 'horizontal') {\n if (underlineOffset) {\n this._AABBBounds.add(this._AABBBounds.x1, this._AABBBounds.y2 + underlineOffset);\n }\n }\n return b;\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * @param text\n */\n updateHorizontalMultilineAABBBounds(text: (number | string)[]): IAABBBounds {\n const textTheme = this.getGraphicTheme();\n\n const attribute = this.attribute;\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n fontWeight = textTheme.fontWeight,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n wrap = textTheme.wrap,\n // ignoreBuf = textTheme.ignoreBuf,\n lineWidth = textTheme.lineWidth,\n whiteSpace = textTheme.whiteSpace,\n suffixPosition = textTheme.suffixPosition\n } = attribute;\n\n const lineHeight = this.getLineHeight(attribute, textTheme);\n\n if (whiteSpace === 'normal' || wrap) {\n return this.updateWrapAABBBounds(text);\n }\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure);\n const layoutData = layoutObj.GetLayoutByLines(\n text,\n textAlign,\n textBaseline as any,\n lineHeight,\n ellipsis === true ? (textTheme.ellipsis as string) : ellipsis || undefined,\n false,\n maxLineWidth,\n suffixPosition\n );\n const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateWrapAABBBounds(text: (number | string) | (number | string)[]) {\n const textTheme = this.getGraphicTheme();\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n suffixPosition = textTheme.suffixPosition,\n heightLimit = 0,\n lineClamp\n } = this.attribute;\n\n const lineHeight = this.getLineHeight(this.attribute, textTheme);\n\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const textOptions = { fontSize, fontWeight, fontFamily };\n const layoutObj = new CanvasTextLayout(fontFamily, textOptions, textMeasure as any);\n\n // layoutObj内逻辑\n const lines = isArray(text) ? (text.map(l => l.toString()) as string[]) : [text.toString()];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行,如果后面还有行,需要显示省略号\n const clip = textMeasure.clipTextWithSuffix(\n str,\n textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition,\n i !== lines.length - 1\n );\n const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: matrics.ascent,\n descent: matrics.descent\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = textMeasure.clipText(str, textOptions, maxLineWidth, wordBreak === 'break-word');\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = textMeasure.clipTextWithSuffix(\n str,\n textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: matrics.ascent,\n descent: matrics.descent\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = textMeasure.clipTextWithSuffix(\n lines[i],\n textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n const matrics = textMeasure.measureTextPixelADscentAndWidth(clip.str, textOptions);\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: matrics.ascent,\n descent: matrics.descent\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = textMeasure.measureTextWidth(text, textOptions);\n lineWidth = Math.max(lineWidth, width);\n const matrics = textMeasure.measureTextPixelADscentAndWidth(text, textOptions);\n linesLayout.push({ str: text, width, ascent: matrics.ascent, descent: matrics.descent });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * lineHeight;\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n /**\n * 计算垂直布局的多行文字的bounds,可以缓存长度以及截取的文字\n * @param text\n */\n updateVerticalMultilineAABBBounds(text: (number | string)[]): IAABBBounds {\n const textTheme = this.getGraphicTheme();\n const textMeasure = application.graphicUtil.textMeasure;\n let width: number;\n const attribute = this.attribute;\n const {\n maxLineWidth = textTheme.maxLineWidth,\n ellipsis = textTheme.ellipsis,\n fontFamily = textTheme.fontFamily,\n fontSize = textTheme.fontSize,\n fontWeight = textTheme.fontWeight,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n // wordBreak = textTheme.wordBreak,\n verticalMode = textTheme.verticalMode,\n suffixPosition = textTheme.suffixPosition\n } = attribute;\n\n const lineHeight = this.getLineHeight(attribute, textTheme);\n\n let { textAlign = textTheme.textAlign, textBaseline = textTheme.textBaseline } = attribute;\n if (!verticalMode) {\n const t = textAlign;\n textAlign = (Text.baselineMapAlign as any)[textBaseline] ?? 'left';\n textBaseline = (Text.alignMapBaseline as any)[t] ?? 'top';\n }\n width = 0;\n if (!this.shouldUpdateShape() && this.cache) {\n this.cache.verticalList.forEach(item => {\n const w = item.reduce((a, b) => a + b.width, 0);\n width = max(w, width);\n });\n const dx = textDrawOffsetX(textAlign, width);\n const height = this.cache.verticalList.length * lineHeight;\n const dy = textLayoutOffsetY(textBaseline, height, fontSize);\n this._AABBBounds.set(dy, dx, dy + height, dx + width);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const verticalLists: { text: string; width?: number; direction: TextDirection }[][] = text.map(str => {\n return verticalLayout(str.toString());\n });\n verticalLists.forEach((verticalData, i) => {\n if (Number.isFinite(maxLineWidth)) {\n if (ellipsis) {\n const strEllipsis = (ellipsis === true ? textTheme.ellipsis : ellipsis) as string;\n const data = textMeasure.clipTextWithSuffixVertical(\n verticalData,\n { fontSize, fontWeight, fontFamily },\n maxLineWidth,\n strEllipsis,\n false,\n suffixPosition\n );\n verticalLists[i] = data.verticalList;\n width = data.width;\n } else {\n const data = textMeasure.clipTextVertical(\n verticalData,\n { fontSize, fontWeight, fontFamily },\n maxLineWidth,\n false\n );\n verticalLists[i] = data.verticalList;\n width = data.width;\n }\n // this.cache.clipedWidth = width;\n // todo 计算原本的宽度\n } else {\n width = 0;\n verticalData.forEach(t => {\n const w =\n t.direction === TextDirection.HORIZONTAL\n ? fontSize\n : textMeasure.measureTextWidth(t.text, { fontSize, fontWeight, fontFamily });\n\n width += w;\n t.width = w;\n });\n }\n });\n this.cache.verticalList = verticalLists;\n this.clearUpdateShapeTag();\n\n this.cache.verticalList.forEach(item => {\n const w = item.reduce((a, b) => a + b.width, 0);\n width = max(w, width);\n });\n\n const dx = textDrawOffsetX(textAlign, width);\n const height = this.cache.verticalList.length * lineHeight;\n const dy = textLayoutOffsetY(textBaseline, height, fontSize);\n this._AABBBounds.set(dy, dx, dy + height, dx + width);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n /**\n * 是否是简单文字\n * 单行,横排\n * @returns\n */\n protected isSinglelineAndHorizontal(): boolean {\n return !this.isMultiLine && this.attribute.direction !== 'vertical';\n }\n\n protected getMaxWidth(theme: ITextGraphicAttribute): number {\n // 传入了maxLineWidth就优先使用,否则使用maxWidth\n const attribute = this.attribute;\n return attribute.maxLineWidth ?? attribute.maxWidth ?? theme.maxWidth;\n }\n\n protected getLineHeight(attribute: ITextGraphicAttribute, textTheme: ITextGraphicAttribute) {\n return (\n calculateLineHeight(attribute.lineHeight, attribute.fontSize || textTheme.fontSize) ??\n (attribute.fontSize || textTheme.fontSize)\n );\n }\n\n protected needUpdateTags(keys: string[], k = TEXT_UPDATE_TAG_KEY): boolean {\n return super.needUpdateTags(keys, k);\n }\n protected needUpdateTag(key: string, k = TEXT_UPDATE_TAG_KEY): boolean {\n return super.needUpdateTag(key, k);\n }\n\n clone(): Text {\n return new Text({ ...this.attribute });\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return Text.NOWORK_ANIMATE_ATTR;\n }\n\n /**\n * 用于垂直布局时align和baseline相互转换\n * @returns\n */\n getBaselineMapAlign(): Record<string, string> {\n return Text.baselineMapAlign;\n }\n\n /**\n * 用于垂直布局时align和baseline相互转换\n * @returns\n */\n getAlignMapBaseline(): Record<string, string> {\n return Text.alignMapBaseline;\n }\n\n static baselineMapAlign = {\n top: 'left',\n bottom: 'right',\n middle: 'center'\n };\n\n static alignMapBaseline = {\n left: 'top',\n right: 'bottom',\n center: 'middle'\n };\n}\n\nexport function createText(attributes: ITextGraphicAttribute): IText {\n return new Text(attributes);\n}\n\n// addAttributeToPrototype(DefaultLineStyle, Text, PURE_STYLE_KEY);\n"]}
|
package/es/graphic/wrap-text.js
CHANGED
|
@@ -43,7 +43,9 @@ export class WrapText extends Text {
|
|
|
43
43
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(str, layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
44
44
|
linesLayout.push({
|
|
45
45
|
str: clip.str,
|
|
46
|
-
width: clip.width
|
|
46
|
+
width: clip.width,
|
|
47
|
+
ascent: 0,
|
|
48
|
+
descent: 0
|
|
47
49
|
});
|
|
48
50
|
break;
|
|
49
51
|
}
|
|
@@ -57,7 +59,9 @@ export class WrapText extends Text {
|
|
|
57
59
|
}
|
|
58
60
|
if (linesLayout.push({
|
|
59
61
|
str: clip.str,
|
|
60
|
-
width: clip.width
|
|
62
|
+
width: clip.width,
|
|
63
|
+
ascent: 0,
|
|
64
|
+
descent: 0
|
|
61
65
|
}), clip.str.length === str.length) ; else if (needCut) {
|
|
62
66
|
const newStr = str.substring(clip.str.length);
|
|
63
67
|
lines.splice(i + 1, 0, newStr);
|
|
@@ -74,14 +78,18 @@ export class WrapText extends Text {
|
|
|
74
78
|
const clip = layoutObj.textMeasure.clipTextWithSuffix(lines[i], layoutObj.textOptions, maxLineWidth, ellipsis, !1, suffixPosition);
|
|
75
79
|
linesLayout.push({
|
|
76
80
|
str: clip.str,
|
|
77
|
-
width: clip.width
|
|
81
|
+
width: clip.width,
|
|
82
|
+
ascent: 0,
|
|
83
|
+
descent: 0
|
|
78
84
|
}), lineWidth = Math.max(lineWidth, clip.width);
|
|
79
85
|
break;
|
|
80
86
|
}
|
|
81
87
|
text = lines[i], width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, "break-word" === wordBreak),
|
|
82
88
|
lineWidth = Math.max(lineWidth, width), linesLayout.push({
|
|
83
89
|
str: text,
|
|
84
|
-
width: width
|
|
90
|
+
width: width,
|
|
91
|
+
ascent: 0,
|
|
92
|
+
descent: 0
|
|
85
93
|
});
|
|
86
94
|
}
|
|
87
95
|
bboxWH[0] = lineWidth;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,O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cAAc,CAAC,UAAiC;IAC9D,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IText, ITextGraphicAttribute, IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\nimport { calculateLineHeight } from '../common/utils';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n constructor(params: ITextGraphicAttribute) {\n super({ ...params, wrap: true });\n }\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = this.getGraphicTheme();\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n suffixPosition = textTheme.suffixPosition,\n lineClamp\n } = this.attribute;\n const lineHeight =\n calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize) ??\n (this.attribute.fontSize || textTheme.fontSize);\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n protected needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return WrapText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createWrapText(attributes: ITextGraphicAttribute): IText {\n return new WrapText(attributes);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/graphic/wrap-text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAE5E,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,wBAAwB,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;AAO9D,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGhC,YAAY,MAA6B;QACvC,KAAK,iCAAM,MAAM,KAAE,IAAI,EAAE,IAAI,IAAG,CAAC;IACnC,CAAC;IAES,QAAQ;QAChB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,OAAO,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C,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;QAExG,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;SACxC;QAED,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAES,cAAc,CAAC,IAAc;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE;gBAChC,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IACpC,CAAC;IAES,aAAa,CAAC,GAAW;QACjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,wBAAwB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACxD,MAAM,OAAO,GAAG,wBAAwB,CAAC,CAAC,CAAC,CAAC;YAC5C,IAAI,GAAG,KAAK,OAAO,EAAE;gBACnB,OAAO,IAAI,CAAC;aACb;SACF;QACD,OAAO,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,CAAC;IAED,oBAAoB;QAClB,OAAO,QAAQ,CAAC,mBAAmB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,UAAU,cAAc,CAAC,UAAiC;IAC9D,OAAO,IAAI,QAAQ,CAAC,UAAU,CAAC,CAAC;AAClC,CAAC","file":"wrap-text.js","sourcesContent":["import { isArray } from '@visactor/vutils';\nimport { CanvasTextLayout } from '../core/contributions/textMeasure/layout';\nimport type { IText, ITextGraphicAttribute, IWrapTextGraphicAttribute, LayoutItemType } from '../interface';\nimport { application } from '../application';\nimport { Text } from './text';\nimport { getTheme } from './theme';\nimport { calculateLineHeight } from '../common/utils';\n\nconst WRAP_TEXT_UPDATE_TAG_KEY = ['heightLimit', 'lineClamp'];\n\n/* WrapText功能\n * 1. 按照宽度限制自动折行或显示省略号(maxLineWidth)\n * 2. 高度限制控制显示内容及省略号(heightLimit)\n * 3. 按照行数限制显示内容及省略号(lineClamp)\n */\nexport class WrapText extends Text {\n declare attribute: IWrapTextGraphicAttribute;\n\n constructor(params: ITextGraphicAttribute) {\n super({ ...params, wrap: true });\n }\n\n protected _isValid(): boolean {\n const { text } = this.attribute;\n if (isArray(text)) {\n return !(text as any[]).every((t: any) => t == null || t === '');\n }\n return text != null && text !== '';\n }\n\n /**\n * 计算多行文字的bounds,缓存每行文字的布局位置\n * 自动折行params.text是数组,因此只重新updateMultilineAABBBounds\n * @param text\n */\n updateMultilineAABBBounds(text: (number | string)[]) {\n const textTheme = this.getGraphicTheme();\n const {\n fontFamily = textTheme.fontFamily,\n textAlign = textTheme.textAlign,\n textBaseline = textTheme.textBaseline,\n fontSize = textTheme.fontSize,\n ellipsis = textTheme.ellipsis,\n maxLineWidth,\n stroke = textTheme.stroke,\n lineWidth = textTheme.lineWidth,\n wordBreak = textTheme.wordBreak,\n fontWeight = textTheme.fontWeight,\n // widthLimit,\n ignoreBuf = textTheme.ignoreBuf,\n heightLimit = 0,\n suffixPosition = textTheme.suffixPosition,\n lineClamp\n } = this.attribute;\n const lineHeight =\n calculateLineHeight(this.attribute.lineHeight, this.attribute.fontSize || textTheme.fontSize) ??\n (this.attribute.fontSize || textTheme.fontSize);\n const buf = ignoreBuf ? 0 : 2;\n if (!this.shouldUpdateShape() && this.cache?.layoutData) {\n const bbox = this.cache.layoutData.bbox;\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n return this._AABBBounds;\n }\n\n const textMeasure = application.graphicUtil.textMeasure;\n const layoutObj = new CanvasTextLayout(fontFamily, { fontSize, fontWeight, fontFamily }, textMeasure as any) as any;\n\n // layoutObj内逻辑\n const lines = text.map(l => l.toString()) as string[];\n const linesLayout: LayoutItemType[] = [];\n const bboxWH: [number, number] = [0, 0];\n\n let lineCountLimit = Infinity;\n if (heightLimit > 0) {\n lineCountLimit = Math.max(Math.floor(heightLimit / lineHeight), 1);\n }\n if (lineClamp) {\n // 处理行数限制\n lineCountLimit = Math.min(lineCountLimit, lineClamp);\n }\n\n if (typeof maxLineWidth === 'number' && maxLineWidth !== Infinity) {\n // widthLimit > 0\n if (maxLineWidth > 0) {\n for (let i = 0; i < lines.length; i++) {\n const str = lines[i] as string;\n let needCut = true;\n // // 测量当前行宽度\n // width = Math.min(\n // layoutObj.textMeasure.measureTextWidth(str, layoutObj.textOptions),\n // maxLineWidth\n // );\n\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: 0,\n descent: 0\n });\n break; // 不处理后续行\n }\n\n // 测量截断位置\n const clip = layoutObj.textMeasure.clipText(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n wordBreak === 'break-word'\n );\n if (str !== '' && clip.str === '') {\n if (ellipsis) {\n const clipEllipsis = layoutObj.textMeasure.clipTextWithSuffix(\n str,\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n clip.str = clipEllipsis.str ?? '';\n clip.width = clipEllipsis.width ?? 0;\n } else {\n // 宽度限制不足一个字符,不显示\n clip.str = '';\n clip.width = 0;\n }\n needCut = false;\n }\n\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: 0,\n descent: 0\n });\n if (clip.str.length === str.length) {\n // 不需要截断\n } else if (needCut) {\n const newStr = str.substring(clip.str.length);\n lines.splice(i + 1, 0, newStr);\n }\n }\n }\n // bboxWH[0] = maxLineWidth;\n let maxWidth = 0;\n linesLayout.forEach(layout => {\n maxWidth = Math.max(maxWidth, layout.width);\n });\n bboxWH[0] = maxWidth;\n } else {\n // 使用所有行中最长的作为lineWidth\n let lineWidth = 0;\n let width: number;\n let text: string;\n for (let i = 0, len = lines.length; i < len; i++) {\n // 判断是否超过高度限制\n if (i === lineCountLimit - 1) {\n // 当前行为最后一行\n const clip = layoutObj.textMeasure.clipTextWithSuffix(\n lines[i],\n layoutObj.textOptions,\n maxLineWidth,\n ellipsis,\n false,\n suffixPosition\n );\n linesLayout.push({\n str: clip.str,\n width: clip.width,\n ascent: 0,\n descent: 0\n });\n lineWidth = Math.max(lineWidth, clip.width);\n break; // 不处理后续行\n }\n\n text = lines[i] as string;\n width = layoutObj.textMeasure.measureTextWidth(text, layoutObj.textOptions, wordBreak === 'break-word');\n lineWidth = Math.max(lineWidth, width);\n linesLayout.push({ str: text, width, ascent: 0, descent: 0 });\n }\n bboxWH[0] = lineWidth;\n }\n bboxWH[1] = linesLayout.length * (lineHeight + buf);\n\n const bbox = {\n xOffset: 0,\n yOffset: 0,\n width: bboxWH[0],\n height: bboxWH[1]\n };\n\n layoutObj.LayoutBBox(bbox, textAlign, textBaseline as any);\n\n const layoutData = layoutObj.layoutWithBBox(bbox, linesLayout, textAlign, textBaseline as any, lineHeight);\n\n // const layoutData = layoutObj.GetLayoutByLines(\n // text,\n // textAlign,\n // textBaseline as any,\n // lineHeight,\n // ellipsis === true ? (DefaultTextAttribute.ellipsis as string) : ellipsis || undefined,\n // maxLineWidth\n // );\n // const { bbox } = layoutData;\n this.cache.layoutData = layoutData;\n this.clearUpdateShapeTag();\n this._AABBBounds.set(bbox.xOffset, bbox.yOffset, bbox.xOffset + bbox.width, bbox.yOffset + bbox.height);\n\n if (stroke) {\n this._AABBBounds.expand(lineWidth / 2);\n }\n\n return this._AABBBounds;\n }\n\n protected needUpdateTags(keys: string[]): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (keys.indexOf(attrKey) !== -1) {\n return true;\n }\n }\n return super.needUpdateTags(keys);\n }\n\n protected needUpdateTag(key: string): boolean {\n for (let i = 0; i < WRAP_TEXT_UPDATE_TAG_KEY.length; i++) {\n const attrKey = WRAP_TEXT_UPDATE_TAG_KEY[i];\n if (key === attrKey) {\n return true;\n }\n }\n return super.needUpdateTag(key);\n }\n\n getNoWorkAnimateAttr(): Record<string, number> {\n return WrapText.NOWORK_ANIMATE_ATTR;\n }\n}\n\nexport function createWrapText(attributes: ITextGraphicAttribute): IText {\n return new WrapText(attributes);\n}\n"]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IAABBBounds } from '@visactor/vutils';
|
|
2
1
|
import type { IGraphicAttribute, IGraphic } from '../graphic';
|
|
3
2
|
export interface TextLayoutBBox {
|
|
4
3
|
width: number;
|
|
@@ -11,6 +10,8 @@ export interface LayoutItemType {
|
|
|
11
10
|
leftOffset?: number;
|
|
12
11
|
topOffset?: number;
|
|
13
12
|
width: number;
|
|
13
|
+
ascent: number;
|
|
14
|
+
descent: number;
|
|
14
15
|
}
|
|
15
16
|
export interface SimplifyLayoutType {
|
|
16
17
|
lines: LayoutItemType[];
|
|
@@ -28,6 +29,7 @@ export interface LayoutType {
|
|
|
28
29
|
export type ITextAttribute = {
|
|
29
30
|
text: string | number | string[] | number[];
|
|
30
31
|
maxLineWidth: number;
|
|
32
|
+
maxWidth: number;
|
|
31
33
|
textAlign: TextAlignType;
|
|
32
34
|
textBaseline: TextBaselineType;
|
|
33
35
|
fontSize: number;
|
|
@@ -78,8 +80,6 @@ export interface IText extends IGraphic<ITextGraphicAttribute> {
|
|
|
78
80
|
cache?: ITextCache;
|
|
79
81
|
getBaselineMapAlign: () => Record<string, string>;
|
|
80
82
|
getAlignMapBaseline: () => Record<string, string>;
|
|
81
|
-
updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;
|
|
82
|
-
updateSingallineAABBBounds: (text: number | string) => IAABBBounds;
|
|
83
83
|
}
|
|
84
84
|
export type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';
|
|
85
85
|
export type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number | string;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all' | 'keep-all';\n ignoreBuf: boolean;\n heightLimit: number;\n lineClamp: number;\n wrap: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n suffixPosition: 'start' | 'end' | 'middle';\n underlineDash: number[];\n underlineOffset: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n disableAutoClipedPoptip?: boolean;\n};\nexport type ITextCache = {\n //
|
|
1
|
+
{"version":3,"sources":["../src/interface/graphic/text.ts"],"names":[],"mappings":"","file":"text.js","sourcesContent":["import type { IAABBBounds } from '@visactor/vutils';\nimport type { IGraphicAttribute, IGraphic } from '../graphic';\n\nexport interface TextLayoutBBox {\n width: number; // 包围盒的宽度\n height: number; // 包围盒的高度\n xOffset: number;\n yOffset: number;\n}\n\nexport interface LayoutItemType {\n str: string; // 这行的字符串\n leftOffset?: number; // 该行距离左侧的偏移\n topOffset?: number; // 该行距离右侧的偏移\n width: number;\n ascent: number;\n descent: number;\n}\n\nexport interface SimplifyLayoutType {\n lines: LayoutItemType[];\n}\n\nexport interface LayoutType {\n bbox: TextLayoutBBox;\n lines: LayoutItemType[];\n fontFamily: string;\n fontSize: number;\n fontWeight?: string | number;\n lineHeight: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n}\n\nexport type ITextAttribute = {\n text: string | number | string[] | number[];\n maxLineWidth: number;\n maxWidth: number;\n textAlign: TextAlignType;\n textBaseline: TextBaselineType;\n fontSize: number;\n fontFamily: string;\n fontWeight: string | number;\n ellipsis: boolean | string;\n fontVariant: string;\n fontStyle: string;\n lineHeight: number | string;\n underline: number;\n lineThrough: number;\n scaleIn3d: boolean;\n direction: 'horizontal' | 'vertical';\n verticalMode: number; // 垂直布局的模式,0代表默认(横向textAlign,纵向textBaseline),1代表特殊(横向textBaseline,纵向textAlign)\n wordBreak: 'break-word' | 'break-all' | 'keep-all';\n ignoreBuf: boolean;\n heightLimit: number;\n lineClamp: number;\n wrap: boolean;\n whiteSpace: 'normal' | 'no-wrap';\n suffixPosition: 'start' | 'end' | 'middle';\n underlineDash: number[];\n underlineOffset: number;\n // textDecoration: number;\n // textDecorationWidth: number;\n // padding?: number | number[];\n disableAutoClipedPoptip?: boolean;\n};\nexport type ITextCache = {\n // 单行文本的时候缓存(多行文本没有)\n clipedText?: string;\n clipedWidth?: number;\n // 文本的布局缓存(单行文本也有)\n layoutData?: LayoutType;\n // 垂直布局的列表\n verticalList?: { text: string; width?: number; direction: number }[][];\n};\n\nexport type ITextGraphicAttribute = Partial<IGraphicAttribute> & Partial<ITextAttribute>;\n\nexport type IWrapTextGraphicAttribute = ITextGraphicAttribute & {\n heightLimit?: number;\n lineClamp?: number;\n};\n\nexport interface IText extends IGraphic<ITextGraphicAttribute> {\n // 判断是否被ellipisised\n clipedText?: string;\n clipedWidth?: number;\n cliped?: boolean;\n multilineLayout?: LayoutType;\n font?: string;\n isMultiLine: boolean;\n cache?: ITextCache;\n\n getBaselineMapAlign: () => Record<string, string>;\n getAlignMapBaseline: () => Record<string, string>;\n\n // updateMultilineAABBBounds: (text: (number | string)[]) => IAABBBounds;\n // updateSingallineAABBBounds: (text: number | string) => IAABBBounds;\n}\n\nexport type TextAlignType = 'left' | 'right' | 'center' | 'start' | 'end';\nexport type TextBaselineType = 'top' | 'middle' | 'bottom' | 'alphabetic';\n"]}
|