1 | import { TextAlign, TextVerticalAlign, ImageLike, Dictionary, MapToType, FontWeight, FontStyle } from '../core/types';
|
2 | import TSpan from './TSpan';
|
3 | import ZRImage from './Image';
|
4 | import Rect from './shape/Rect';
|
5 | import BoundingRect from '../core/BoundingRect';
|
6 | import { MatrixArray } from '../core/matrix';
|
7 | import Displayable, { DisplayableStatePropNames, DisplayableProps } from './Displayable';
|
8 | import { ZRenderType } from '../zrender';
|
9 | import Animator from '../animation/Animator';
|
10 | import Transformable from '../core/Transformable';
|
11 | import { ElementCommonState } from '../Element';
|
12 | import { GroupLike } from './Group';
|
13 | export interface TextStylePropsPart {
|
14 | text?: string;
|
15 | fill?: string;
|
16 | stroke?: string;
|
17 | strokeNoScale?: boolean;
|
18 | opacity?: number;
|
19 | fillOpacity?: number;
|
20 | strokeOpacity?: number;
|
21 | lineWidth?: number;
|
22 | lineDash?: false | number[];
|
23 | lineDashOffset?: number;
|
24 | borderDash?: false | number[];
|
25 | borderDashOffset?: number;
|
26 | font?: string;
|
27 | textFont?: string;
|
28 | fontStyle?: FontStyle;
|
29 | fontWeight?: FontWeight;
|
30 | fontFamily?: string;
|
31 | fontSize?: number | string;
|
32 | align?: TextAlign;
|
33 | verticalAlign?: TextVerticalAlign;
|
34 | lineHeight?: number;
|
35 | width?: number | string;
|
36 | height?: number;
|
37 | tag?: string;
|
38 | textShadowColor?: string;
|
39 | textShadowBlur?: number;
|
40 | textShadowOffsetX?: number;
|
41 | textShadowOffsetY?: number;
|
42 | backgroundColor?: string | {
|
43 | image: ImageLike | string;
|
44 | };
|
45 | padding?: number | number[];
|
46 | margin?: number;
|
47 | borderColor?: string;
|
48 | borderWidth?: number;
|
49 | borderRadius?: number | number[];
|
50 | shadowColor?: string;
|
51 | shadowBlur?: number;
|
52 | shadowOffsetX?: number;
|
53 | shadowOffsetY?: number;
|
54 | }
|
55 | export interface TextStyleProps extends TextStylePropsPart {
|
56 | text?: string;
|
57 | x?: number;
|
58 | y?: number;
|
59 | width?: number;
|
60 | rich?: Dictionary<TextStylePropsPart>;
|
61 | overflow?: 'break' | 'breakAll' | 'truncate' | 'none';
|
62 | lineOverflow?: 'truncate';
|
63 | ellipsis?: string;
|
64 | placeholder?: string;
|
65 | truncateMinChar?: number;
|
66 | }
|
67 | export interface TextProps extends DisplayableProps {
|
68 | style?: TextStyleProps;
|
69 | zlevel?: number;
|
70 | z?: number;
|
71 | z2?: number;
|
72 | culling?: boolean;
|
73 | cursor?: string;
|
74 | }
|
75 | export declare type TextState = Pick<TextProps, DisplayableStatePropNames> & ElementCommonState;
|
76 | export declare type DefaultTextStyle = Pick<TextStyleProps, 'fill' | 'stroke' | 'align' | 'verticalAlign'> & {
|
77 | autoStroke?: boolean;
|
78 | };
|
79 | export declare const DEFAULT_TEXT_ANIMATION_PROPS: MapToType<TextProps, boolean>;
|
80 | interface ZRText {
|
81 | animate(key?: '', loop?: boolean): Animator<this>;
|
82 | animate(key: 'style', loop?: boolean): Animator<this['style']>;
|
83 | getState(stateName: string): TextState;
|
84 | ensureState(stateName: string): TextState;
|
85 | states: Dictionary<TextState>;
|
86 | stateProxy: (stateName: string) => TextState;
|
87 | }
|
88 | declare class ZRText extends Displayable<TextProps> implements GroupLike {
|
89 | type: string;
|
90 | style: TextStyleProps;
|
91 | overlap: 'hidden' | 'show' | 'blur';
|
92 | innerTransformable: Transformable;
|
93 | isTruncated: boolean;
|
94 | private _children;
|
95 | private _childCursor;
|
96 | private _defaultStyle;
|
97 | constructor(opts?: TextProps);
|
98 | childrenRef(): (ZRImage | Rect | TSpan)[];
|
99 | update(): void;
|
100 | updateTransform(): void;
|
101 | getLocalTransform(m?: MatrixArray): MatrixArray;
|
102 | getComputedTransform(): MatrixArray;
|
103 | private _updateSubTexts;
|
104 | addSelfToZr(zr: ZRenderType): void;
|
105 | removeSelfFromZr(zr: ZRenderType): void;
|
106 | getBoundingRect(): BoundingRect;
|
107 | setDefaultTextStyle(defaultTextStyle: DefaultTextStyle): void;
|
108 | setTextContent(textContent: never): void;
|
109 | protected _mergeStyle(targetStyle: TextStyleProps, sourceStyle: TextStyleProps): TextStyleProps;
|
110 | private _mergeRich;
|
111 | getAnimationStyleProps(): MapToType<TextProps, boolean>;
|
112 | private _getOrCreateChild;
|
113 | private _updatePlainTexts;
|
114 | private _updateRichTexts;
|
115 | private _placeToken;
|
116 | private _renderBackground;
|
117 | static makeFont(style: TextStylePropsPart): string;
|
118 | }
|
119 | export declare function parseFontSize(fontSize: number | string): string;
|
120 | export declare function hasSeparateFont(style: Pick<TextStylePropsPart, 'fontSize' | 'fontFamily' | 'fontWeight'>): string | number | true;
|
121 | export declare function normalizeTextStyle(style: TextStyleProps): TextStyleProps;
|
122 | export default ZRText;
|