RichText.d.ts 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { PatternObject } from '../graphic/Pattern';
  2. import { LinearGradientObject } from '../graphic/LinearGradient';
  3. import { RadialGradientObject } from '../graphic/RadialGradient';
  4. import { TextAlign, TextVerticalAlign, ImageLike, Dictionary, AllPropTypes } from '../core/types';
  5. import Element, { ElementOption } from '../Element';
  6. interface RichTextStyleOptionPart {
  7. text?: string;
  8. textFill?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  9. textStroke?: string | PatternObject | LinearGradientObject | RadialGradientObject;
  10. opacity?: number;
  11. fillOpacity?: number;
  12. strokeOpacity?: number;
  13. textStrokeWidth?: number;
  14. font?: string;
  15. textFont?: string;
  16. fontStyle?: string;
  17. fontWeight?: string;
  18. fontFamily?: string;
  19. fontSize?: number;
  20. textAlign?: TextAlign;
  21. textVerticalAlign?: TextVerticalAlign;
  22. textLineHeight?: number;
  23. textWidth?: number | string;
  24. textHeight?: number;
  25. textTag?: string;
  26. textShadowColor?: string;
  27. textShadowBlur?: number;
  28. textShadowOffsetX?: number;
  29. textShadowOffsetY?: number;
  30. textBackgroundColor?: string | {
  31. image: ImageLike | string;
  32. };
  33. textPadding?: number | number[];
  34. textBorderColor?: string;
  35. textBorderWidth?: number;
  36. textBorderRadius?: number | number[];
  37. textBoxShadowColor?: string;
  38. textBoxShadowBlur?: number;
  39. textBoxShadowOffsetX?: number;
  40. textBoxShadowOffsetY?: number;
  41. }
  42. export interface RichTextStyleOption extends RichTextStyleOptionPart {
  43. text?: string;
  44. x?: number;
  45. y?: number;
  46. wrap?: false;
  47. rich?: Dictionary<RichTextStyleOptionPart>;
  48. truncate?: {
  49. outerWidth?: number;
  50. outerHeight?: number;
  51. ellipsis?: string;
  52. placeholder?: string;
  53. minChar?: number;
  54. };
  55. }
  56. interface RichTextOption extends ElementOption {
  57. style?: RichTextStyleOption;
  58. }
  59. interface RichText {
  60. attr(key: RichTextOption): RichText;
  61. attr(key: keyof RichTextOption, value: AllPropTypes<RichTextOption>): RichText;
  62. }
  63. declare class RichText extends Element {
  64. readonly isGroup = true;
  65. style?: RichTextStyleOption;
  66. private _children;
  67. private _styleChanged;
  68. constructor(opts?: RichTextOption);
  69. update(): void;
  70. attrKV(key: keyof RichTextOption, value: AllPropTypes<RichTextStyleOption>): void;
  71. setStyle(obj: RichTextStyleOption): void;
  72. setStyle(obj: keyof RichTextStyleOption, value: any): void;
  73. dirtyStyle(): void;
  74. children(): Element[];
  75. private _addChild;
  76. private _updatePlainTexts;
  77. private _updateRichTexts;
  78. private _placeToken;
  79. private _renderBackground;
  80. }
  81. export declare function normalizeTextStyle(style: RichTextStyleOption): RichTextStyleOption;
  82. export default RichText;