1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * StyledString 23 * 24 * @syscap SystemCapability.ArkUI.ArkUI.Full 25 * @crossplatform 26 * @atomicservice 27 * @since 12 28 */ 29declare class StyledString { 30 /** 31 * constructor. 32 * 33 * @param { string | ImageAttachment | CustomSpan } value - indicates the current object value of the StyledString. 34 * @param { Array<StyleOptions> } [styles] - indicates the SpanStyle objects. 35 * @syscap SystemCapability.ArkUI.ArkUI.Full 36 * @crossplatform 37 * @atomicservice 38 * @since 12 39 */ 40 constructor(value: string | ImageAttachment | CustomSpan, styles?: Array<StyleOptions>); 41 42 /** 43 * Get the length of the StyledString's characters. 44 * 45 * @type { number } - the length of the StyledString's characters. 46 * @readonly 47 * @syscap SystemCapability.ArkUI.ArkUI.Full 48 * @crossplatform 49 * @atomicservice 50 * @since 12 51 */ 52 readonly length: number; 53 54 /** 55 * Get the literal content of the StyledString. 56 * 57 * @returns { string } - the literal content of the StyledString 58 * @syscap SystemCapability.ArkUI.ArkUI.Full 59 * @crossplatform 60 * @atomicservice 61 * @since 12 62 */ 63 getString(): string; 64 65 /** 66 * Get the attribute objects of the subStyledString. 67 * 68 * @param { number } start - the start position of the subStyledString. 69 * @param { number } length - the length of the subStyledString's characters. 70 * @param { StyledStringKey } [styledKey] - the specified type. 71 * @returns { Array<SpanStyle> } 72 * @throws { BusinessError } 401 - Parameter error. Possible causes: 73 * <br> 1. Mandatory parameters are left unspecified. 74 * <br> 2. Incorrect parameters types. 75 * <br> 3. Parameter verification failed. 76 * @syscap SystemCapability.ArkUI.ArkUI.Full 77 * @crossplatform 78 * @atomicservice 79 * @since 12 80 */ 81 getStyles(start: number, length: number, styledKey?: StyledStringKey): Array<SpanStyle>; 82 83 /** 84 * Judge if two attribute strings are equal. 85 * 86 * @param { StyledString } other - another StyledString. 87 * @returns { boolean } 88 * @syscap SystemCapability.ArkUI.ArkUI.Full 89 * @crossplatform 90 * @atomicservice 91 * @since 12 92 */ 93 equals(other: StyledString): boolean; 94 95 /** 96 * Get the substring of the StyledString. 97 * 98 * @param { number } start - the start position of the subStyledString. 99 * @param { number } [length] - the length of the subStyledString's characters. 100 * @returns { StyledString } 101 * @throws { BusinessError } 401 - Parameter error. Possible causes: 102 * <br> 1. Mandatory parameters are left unspecified. 103 * <br> 2. Incorrect parameters types. 104 * <br> 3. Parameter verification failed. 105 * @syscap SystemCapability.ArkUI.ArkUI.Full 106 * @crossplatform 107 * @atomicservice 108 * @since 12 109 */ 110 subStyledString(start: number, length?: number): StyledString; 111 112 /** 113 * Returns StyledString from the provided HTML string. 114 * 115 * @param { string } html - the html text will be converted to a StyledString. 116 * @returns { Promise<StyledString> } 117 * @throws { BusinessError } 401 - Parameter error. Possible causes: 118 * <br> 1. Mandatory parameters are left unspecified. 119 * <br> 2. Incorrect parameters types. 120 * <br> 3. Parameter verification failed. 121 * @syscap SystemCapability.ArkUI.ArkUI.Full 122 * @atomicservice 123 * @since 12 124 */ 125 static fromHtml(html: string): Promise<StyledString>; 126 127 /** 128 * Returns ArrayBuffer from the serialized styled string. 129 * 130 * @param { StyledString } styledString - StyledString parameter. 131 * @returns { ArrayBuffer } 132 * @syscap SystemCapability.ArkUI.ArkUI.Full 133 * @systemapi 134 * @since 13 135 */ 136 static marshalling(styledString: StyledString): ArrayBuffer; 137 138 /** 139 * Returns StyledString from the deserialized ArrayBuffer. 140 * 141 * @param { ArrayBuffer } buffer - The buffer will be deserialized to a StyledString. 142 * @returns { Promise<StyledString> } 143 * @throws { BusinessError } 401 - Parameter error. Possible causes: 144 * <br> 1. Mandatory parameters are left unspecified. 145 * <br> 2. Incorrect parameters types. 146 * <br> 3. Parameter verification failed. 147 * @syscap SystemCapability.ArkUI.ArkUI.Full 148 * @systemapi 149 * @since 13 150 */ 151 static unmarshalling(buffer: ArrayBuffer): Promise<StyledString>; 152} 153 154/** 155 * StyleOptions 156 * 157 * @interface StyleOptions 158 * @syscap SystemCapability.ArkUI.ArkUI.Full 159 * @crossplatform 160 * @atomicservice 161 * @since 12 162 */ 163declare interface StyleOptions { 164 /** 165 * The start position of the StyleOptions. 166 * 167 * @type { ?number } 168 * @syscap SystemCapability.ArkUI.ArkUI.Full 169 * @crossplatform 170 * @atomicservice 171 * @since 12 172 */ 173 start?: number; 174 175 /** 176 * The length of the modifiedStyledString's characters. 177 * 178 * @type { ?number } 179 * @syscap SystemCapability.ArkUI.ArkUI.Full 180 * @crossplatform 181 * @atomicservice 182 * @since 12 183 */ 184 length?: number; 185 186 /** 187 * The attribute key of the StyleOptions. 188 * 189 * @type { StyledStringKey } 190 * @syscap SystemCapability.ArkUI.ArkUI.Full 191 * @crossplatform 192 * @atomicservice 193 * @since 12 194 */ 195 styledKey: StyledStringKey; 196 197 /** 198 * The attribute value of the StyleOptions. 199 * 200 * @type { StyledStringValue } 201 * @syscap SystemCapability.ArkUI.ArkUI.Full 202 * @crossplatform 203 * @atomicservice 204 * @since 12 205 */ 206 styledValue: StyledStringValue; 207} 208 209/** 210 * SpanStyle 211 * 212 * @interface SpanStyle 213 * @syscap SystemCapability.ArkUI.ArkUI.Full 214 * @crossplatform 215 * @atomicservice 216 * @since 12 217 */ 218declare interface SpanStyle { 219 /** 220 * The start position of the SpanStyle. 221 * 222 * @type { number } 223 * @syscap SystemCapability.ArkUI.ArkUI.Full 224 * @crossplatform 225 * @atomicservice 226 * @since 12 227 */ 228 start: number; 229 230 /** 231 * The length of the modifiedStyledString's characters. 232 * 233 * @type { number } 234 * @syscap SystemCapability.ArkUI.ArkUI.Full 235 * @crossplatform 236 * @atomicservice 237 * @since 12 238 */ 239 length: number; 240 241 /** 242 * The attribute key of the SpanStyle. 243 * 244 * @type { StyledStringKey } 245 * @syscap SystemCapability.ArkUI.ArkUI.Full 246 * @crossplatform 247 * @atomicservice 248 * @since 12 249 */ 250 styledKey: StyledStringKey; 251 252 /** 253 * The attribute value of the SpanStyle. 254 * 255 * @type { StyledStringValue } 256 * @syscap SystemCapability.ArkUI.ArkUI.Full 257 * @crossplatform 258 * @atomicservice 259 * @since 12 260 */ 261 styledValue: StyledStringValue; 262} 263 264/** 265 * Defines TextStyle. 266 * 267 * @syscap SystemCapability.ArkUI.ArkUI.Full 268 * @crossplatform 269 * @atomicservice 270 * @since 12 271 */ 272declare class TextStyle { 273 274 /** 275 * constructor. 276 * 277 * @param { TextStyleInterface } [value] - font property object. 278 * @syscap SystemCapability.ArkUI.ArkUI.Full 279 * @crossplatform 280 * @atomicservice 281 * @since 12 282 */ 283 constructor(value?: TextStyleInterface); 284 285 /** 286 * Get the fontColor of the StyledString. 287 * 288 * @type { ?ResourceColor } - the set fontColor of the StyledString or undefined 289 * @readonly 290 * @syscap SystemCapability.ArkUI.ArkUI.Full 291 * @crossplatform 292 * @atomicservice 293 * @since 12 294 */ 295 readonly fontColor?: ResourceColor; 296 297 /** 298 * Get the fontFamily of the StyledString. 299 * 300 * @type { ?string } - the fontFamily of the StyledString or undefined 301 * @readonly 302 * @syscap SystemCapability.ArkUI.ArkUI.Full 303 * @crossplatform 304 * @atomicservice 305 * @since 12 306 */ 307 readonly fontFamily?: string; 308 309 /** 310 * Get the fontSize of the StyledString. 311 * If not undefined, the unit is vp. 312 * 313 * @type { ?number } - the fontSize of the StyledString or undefined 314 * @readonly 315 * @syscap SystemCapability.ArkUI.ArkUI.Full 316 * @crossplatform 317 * @atomicservice 318 * @since 12 319 */ 320 readonly fontSize?: number; 321 322 /** 323 * Get the fontWeight of the StyledString. 324 * 325 * @type { ?number } - the fontWeight of the StyledString or undefined 326 * @readonly 327 * @syscap SystemCapability.ArkUI.ArkUI.Full 328 * @crossplatform 329 * @atomicservice 330 * @since 12 331 */ 332 readonly fontWeight?: number; 333 334 /** 335 * Get the fontStyle of the StyledString. 336 * 337 * @type { ?FontStyle } - the fontStyle of the StyledString or undefined 338 * @readonly 339 * @syscap SystemCapability.ArkUI.ArkUI.Full 340 * @crossplatform 341 * @atomicservice 342 * @since 12 343 */ 344 readonly fontStyle?: FontStyle; 345} 346 347/** 348 * TextStyleInterface 349 * 350 * @interface TextStyleInterface 351 * @syscap SystemCapability.ArkUI.ArkUI.Full 352 * @crossplatform 353 * @atomicservice 354 * @since 12 355 */ 356declare interface TextStyleInterface { 357 /** 358 * The fontColor value of the font property object. 359 * 360 * @type { ?ResourceColor } 361 * @syscap SystemCapability.ArkUI.ArkUI.Full 362 * @crossplatform 363 * @atomicservice 364 * @since 12 365 */ 366 fontColor?: ResourceColor; 367 368 /** 369 * The fontFamily value of the font property object. 370 * 371 * @type { ?ResourceStr } 372 * @syscap SystemCapability.ArkUI.ArkUI.Full 373 * @crossplatform 374 * @atomicservice 375 * @since 12 376 */ 377 fontFamily?: ResourceStr; 378 379 /** 380 * The fontSize value of the font property object. 381 * 382 * @type { ?LengthMetrics } 383 * @syscap SystemCapability.ArkUI.ArkUI.Full 384 * @crossplatform 385 * @atomicservice 386 * @since 12 387 */ 388 fontSize?: LengthMetrics; 389 390 /** 391 * The fontWeight value of the font property object. 392 * 393 * @type { ?(number | FontWeight | string) } 394 * @syscap SystemCapability.ArkUI.ArkUI.Full 395 * @crossplatform 396 * @atomicservice 397 * @since 12 398 */ 399 fontWeight?: number | FontWeight | string; 400 401 /** 402 * The fontStyle value of the font property object. 403 * 404 * @type { ?FontStyle } 405 * @syscap SystemCapability.ArkUI.ArkUI.Full 406 * @crossplatform 407 * @atomicservice 408 * @since 12 409 */ 410 fontStyle?: FontStyle; 411} 412 413/** 414 * Defines DecorationStyle. 415 * 416 * @syscap SystemCapability.ArkUI.ArkUI.Full 417 * @crossplatform 418 * @atomicservice 419 * @since 12 420 */ 421declare class DecorationStyle { 422 423 /** 424 * constructor. 425 * 426 * @param { DecorationStyleInterface } value - text decoration value. 427 * @syscap SystemCapability.ArkUI.ArkUI.Full 428 * @crossplatform 429 * @atomicservice 430 * @since 12 431 */ 432 constructor(value: DecorationStyleInterface); 433 434 /** 435 * Get the text decoration type of the StyledString. 436 * 437 * @type { TextDecorationType } - the decoration type of the StyledString 438 * @readonly 439 * @syscap SystemCapability.ArkUI.ArkUI.Full 440 * @crossplatform 441 * @atomicservice 442 * @since 12 443 */ 444 readonly type: TextDecorationType; 445 446 /** 447 * Get the decorationColor of the StyledString. 448 * 449 * @type { ?ResourceColor } - the decorationColor of the StyledString or undefined 450 * @readonly 451 * @syscap SystemCapability.ArkUI.ArkUI.Full 452 * @crossplatform 453 * @atomicservice 454 * @since 12 455 */ 456 readonly color?: ResourceColor; 457 458 /** 459 * Get the decorationStyle of the StyledString. 460 * 461 * @type { ?TextDecorationStyle } - the decorationStyle of the StyledString or undefined 462 * @readonly 463 * @syscap SystemCapability.ArkUI.ArkUI.Full 464 * @crossplatform 465 * @atomicservice 466 * @since 12 467 */ 468 readonly style?: TextDecorationStyle; 469} 470 471/** 472 * DecorationStyleInterface 473 * 474 * @interface DecorationStyleInterface 475 * @syscap SystemCapability.ArkUI.ArkUI.Full 476 * @crossplatform 477 * @atomicservice 478 * @since 12 479 */ 480declare interface DecorationStyleInterface { 481 /** 482 * The type value of the decoration property object. 483 * 484 * @type { TextDecorationType } 485 * @syscap SystemCapability.ArkUI.ArkUI.Full 486 * @crossplatform 487 * @atomicservice 488 * @since 12 489 */ 490 type: TextDecorationType; 491 492 /** 493 * The color value of the decoration property object. 494 * 495 * @type { ?ResourceColor } 496 * @syscap SystemCapability.ArkUI.ArkUI.Full 497 * @crossplatform 498 * @atomicservice 499 * @since 12 500 */ 501 color?: ResourceColor; 502 503 /** 504 * The style value of the decoration property object. 505 * 506 * @type { ?TextDecorationStyle } 507 * @syscap SystemCapability.ArkUI.ArkUI.Full 508 * @crossplatform 509 * @atomicservice 510 * @since 12 511 */ 512 style?: TextDecorationStyle; 513} 514 515/** 516 * Defines BaselineOffsetStyle. 517 * 518 * @syscap SystemCapability.ArkUI.ArkUI.Full 519 * @crossplatform 520 * @atomicservice 521 * @since 12 522 */ 523declare class BaselineOffsetStyle { 524 525 /** 526 * constructor. 527 * 528 * @param { LengthMetrics } value - baseline offset value. 529 * @syscap SystemCapability.ArkUI.ArkUI.Full 530 * @crossplatform 531 * @atomicservice 532 * @since 12 533 */ 534 constructor(value: LengthMetrics); 535 536 /** 537 * Get the baselineOffset value of the StyledString. 538 * The unit is vp. 539 * 540 * @type { number } - the baselineOffset value of the StyledString 541 * @readonly 542 * @syscap SystemCapability.ArkUI.ArkUI.Full 543 * @crossplatform 544 * @atomicservice 545 * @since 12 546 */ 547 readonly baselineOffset: number; 548} 549 550/** 551 * Defines LetterSpacingStyle. 552 * 553 * @syscap SystemCapability.ArkUI.ArkUI.Full 554 * @crossplatform 555 * @atomicservice 556 * @since 12 557 */ 558declare class LetterSpacingStyle { 559 560 /** 561 * constructor. 562 * 563 * @param { LengthMetrics } value - letter space value. 564 * @syscap SystemCapability.ArkUI.ArkUI.Full 565 * @crossplatform 566 * @atomicservice 567 * @since 12 568 */ 569 constructor(value: LengthMetrics); 570 571 /** 572 * Get the letterSpacing value of the StyledString. 573 * The unit is vp. 574 * 575 * @type { number } - the letterSpacing value of the StyledString 576 * @readonly 577 * @syscap SystemCapability.ArkUI.ArkUI.Full 578 * @crossplatform 579 * @atomicservice 580 * @since 12 581 */ 582 readonly letterSpacing: number; 583} 584 585/** 586 * Defines TextShadowStyle. 587 * 588 * @syscap SystemCapability.ArkUI.ArkUI.Full 589 * @crossplatform 590 * @atomicservice 591 * @since 12 592 */ 593declare class TextShadowStyle { 594 595 /** 596 * constructor. 597 * 598 * @param { ShadowOptions | Array<ShadowOptions> } value - text shadow value. 599 * @syscap SystemCapability.ArkUI.ArkUI.Full 600 * @crossplatform 601 * @atomicservice 602 * @since 12 603 */ 604 constructor(value: ShadowOptions | Array<ShadowOptions>); 605 606 /** 607 * Get the textShadow value of the StyledString. 608 * 609 * @type { Array<ShadowOptions> } - the textShadow value of the StyledString 610 * @readonly 611 * @syscap SystemCapability.ArkUI.ArkUI.Full 612 * @crossplatform 613 * @atomicservice 614 * @since 12 615 */ 616 readonly textShadow: Array<ShadowOptions>; 617} 618 619/** 620 * Defines GestureStyle. 621 * 622 * @syscap SystemCapability.ArkUI.ArkUI.Full 623 * @crossplatform 624 * @atomicservice 625 * @since 12 626 */ 627declare class GestureStyle { 628 629 /** 630 * constructor. 631 * 632 * @param { GestureStyleInterface } [value] - gesture event object. 633 * @syscap SystemCapability.ArkUI.ArkUI.Full 634 * @crossplatform 635 * @atomicservice 636 * @since 12 637 */ 638 constructor(value?: GestureStyleInterface); 639} 640 641/** 642 * Defines the Gesture Events. 643 * 644 * @interface GestureStyleInterface 645 * @syscap SystemCapability.ArkUI.ArkUI.Full 646 * @crossplatform 647 * @atomicservice 648 * @since 12 649 */ 650declare interface GestureStyleInterface { 651 /** 652 * Trigger a click event when a click is clicked. 653 * 654 * @type { ?Callback<ClickEvent> } 655 * @syscap SystemCapability.ArkUI.ArkUI.Full 656 * @crossplatform 657 * @atomicservice 658 * @since 12 659 */ 660 onClick?: Callback<ClickEvent>; 661 662 /** 663 * Trigger a gesture event when long press event is complete. 664 * 665 * @type { ?Callback<GestureEvent> } 666 * @syscap SystemCapability.ArkUI.ArkUI.Full 667 * @crossplatform 668 * @atomicservice 669 * @since 12 670 */ 671 onLongPress?: Callback<GestureEvent>; 672} 673 674/** 675 * Defines ParagraphStyle. 676 * 677 * @syscap SystemCapability.ArkUI.ArkUI.Full 678 * @crossplatform 679 * @atomicservice 680 * @since 12 681 */ 682declare class ParagraphStyle { 683 684 /** 685 * constructor. 686 * 687 * @param { ParagraphStyleInterface } [value] - paragraph property object. 688 * @syscap SystemCapability.ArkUI.ArkUI.Full 689 * @crossplatform 690 * @atomicservice 691 * @since 12 692 */ 693 constructor(value?: ParagraphStyleInterface); 694 695 /** 696 * Get the text alignment of the StyledString. 697 * 698 * @type { ?TextAlign } - the text alignment of the StyledString or undefined 699 * @readonly 700 * @syscap SystemCapability.ArkUI.ArkUI.Full 701 * @crossplatform 702 * @atomicservice 703 * @since 12 704 */ 705 readonly textAlign?: TextAlign; 706 707 /** 708 * Get the first line indentation of the StyledString. 709 * The unit is vp. 710 * 711 * @type { ?number } - the first line indentation of the StyledString or undefined 712 * @readonly 713 * @syscap SystemCapability.ArkUI.ArkUI.Full 714 * @crossplatform 715 * @atomicservice 716 * @since 12 717 */ 718 readonly textIndent?: number; 719 720 /** 721 * Get the maximum number of lines of the StyledString. 722 * 723 * @type { ?number } - the maximum number of the StyledString or undefined 724 * @readonly 725 * @syscap SystemCapability.ArkUI.ArkUI.Full 726 * @crossplatform 727 * @atomicservice 728 * @since 12 729 */ 730 readonly maxLines?: number; 731 732 /** 733 * Get the overflow mode of the StyledString. 734 * 735 * @type { ?TextOverflow } - the overflow mode of the StyledString or undefined 736 * @readonly 737 * @syscap SystemCapability.ArkUI.ArkUI.Full 738 * @crossplatform 739 * @atomicservice 740 * @since 12 741 */ 742 readonly overflow?: TextOverflow; 743 744 /** 745 * Get the wordBreak mode of the StyledString. 746 * 747 * @type { ?WordBreak } - the wordBreak mode of the StyledString or undefined 748 * @readonly 749 * @syscap SystemCapability.ArkUI.ArkUI.Full 750 * @crossplatform 751 * @atomicservice 752 * @since 12 753 */ 754 readonly wordBreak?: WordBreak; 755 756 /** 757 * Get the leading margin of the StyledString. 758 * 759 * @type { ?(number | LeadingMarginPlaceholder) } - the leading margin of the StyledString or undefined 760 * @readonly 761 * @syscap SystemCapability.ArkUI.ArkUI.Full 762 * @crossplatform 763 * @atomicservice 764 * @since 12 765 */ 766 readonly leadingMargin?: number | LeadingMarginPlaceholder; 767} 768 769/** 770 * ParagraphStyleInterface 771 * 772 * @interface ParagraphStyleInterface 773 * @syscap SystemCapability.ArkUI.ArkUI.Full 774 * @crossplatform 775 * @atomicservice 776 * @since 12 777 */ 778declare interface ParagraphStyleInterface { 779 /** 780 * Alignment of text. 781 * 782 * @type { ?TextAlign } 783 * @syscap SystemCapability.ArkUI.ArkUI.Full 784 * @crossplatform 785 * @atomicservice 786 * @since 12 787 */ 788 textAlign?: TextAlign; 789 790 /** 791 * Set the first line indentation. 792 * 793 * @type { ?LengthMetrics } 794 * @syscap SystemCapability.ArkUI.ArkUI.Full 795 * @crossplatform 796 * @atomicservice 797 * @since 12 798 */ 799 textIndent?: LengthMetrics; 800 801 /** 802 * The maximum number of lines of content. 803 * 804 * @type { ?number } 805 * @syscap SystemCapability.ArkUI.ArkUI.Full 806 * @crossplatform 807 * @atomicservice 808 * @since 12 809 */ 810 maxLines?: number; 811 812 /** 813 * The overflow mode of the content. 814 * 815 * @type { ?TextOverflow } 816 * @syscap SystemCapability.ArkUI.ArkUI.Full 817 * @crossplatform 818 * @atomicservice 819 * @since 12 820 */ 821 overflow?: TextOverflow; 822 823 /** 824 * Set word break type. 825 * 826 * @type { ?WordBreak } 827 * @syscap SystemCapability.ArkUI.ArkUI.Full 828 * @crossplatform 829 * @atomicservice 830 * @since 12 831 */ 832 wordBreak?: WordBreak; 833 834 /** 835 * Leading margin. 836 * 837 * @type { ?(LengthMetrics | LeadingMarginPlaceholder) } 838 * @syscap SystemCapability.ArkUI.ArkUI.Full 839 * @crossplatform 840 * @atomicservice 841 * @since 12 842 */ 843 leadingMargin?: LengthMetrics | LeadingMarginPlaceholder; 844} 845 846/** 847 * Defines LineHeightStyle. 848 * 849 * @syscap SystemCapability.ArkUI.ArkUI.Full 850 * @crossplatform 851 * @atomicservice 852 * @since 12 853 */ 854declare class LineHeightStyle { 855 856 /** 857 * constructor. 858 * 859 * @param { LengthMetrics } lineHeight - line height value. 860 * @syscap SystemCapability.ArkUI.ArkUI.Full 861 * @crossplatform 862 * @atomicservice 863 * @since 12 864 */ 865 constructor(lineHeight: LengthMetrics); 866 867 /** 868 * Get the lineHeight value of the StyledString. 869 * The unit is vp. 870 * 871 * @type { number } - the lineHeight value of the StyledString 872 * @readonly 873 * @syscap SystemCapability.ArkUI.ArkUI.Full 874 * @crossplatform 875 * @atomicservice 876 * @since 12 877 */ 878 readonly lineHeight: number; 879} 880 881/** 882 * Defines the Span Type. 883 * 884 * @typedef { TextStyle | DecorationStyle | BaselineOffsetStyle | LetterSpacingStyle | TextShadowStyle | 885 * GestureStyle | ImageAttachment | ParagraphStyle | LineHeightStyle | CustomSpan | UserDataSpan} StyledStringValue 886 * @syscap SystemCapability.ArkUI.ArkUI.Full 887 * @crossplatform 888 * @atomicservice 889 * @since 12 890 */ 891declare type StyledStringValue = TextStyle | DecorationStyle | BaselineOffsetStyle | LetterSpacingStyle | TextShadowStyle | 892GestureStyle | ImageAttachment | ParagraphStyle | LineHeightStyle | CustomSpan | UserDataSpan; 893 894/** 895 * MutableStyledString 896 * 897 * @extends StyledString 898 * @syscap SystemCapability.ArkUI.ArkUI.Full 899 * @crossplatform 900 * @atomicservice 901 * @since 12 902 */ 903declare class MutableStyledString extends StyledString { 904 /** 905 * Replace the string of the specified range. 906 * 907 * @param { number } start - the start position of the replacedString. 908 * @param { number } length - the length of the replacedString's characters. 909 * @param { string } other - must be unicode string. 910 * @throws { BusinessError } 401 - Parameter error. Possible causes: 911 * <br> 1. Mandatory parameters are left unspecified. 912 * <br> 2. Incorrect parameters types. 913 * <br> 3. Parameter verification failed. 914 * @syscap SystemCapability.ArkUI.ArkUI.Full 915 * @crossplatform 916 * @atomicservice 917 * @since 12 918 */ 919 replaceString(start: number, length: number, other: string): void; 920 921 /** 922 * Insert the string at the specified location. 923 * 924 * @param { number } start - the start position of the insertedString. 925 * @param { string } other - must be unicode string. 926 * @throws { BusinessError } 401 - Parameter error. Possible causes: 927 * <br> 1. Mandatory parameters are left unspecified. 928 * <br> 2. Incorrect parameters types. 929 * <br> 3. Parameter verification failed. 930 * @syscap SystemCapability.ArkUI.ArkUI.Full 931 * @crossplatform 932 * @atomicservice 933 * @since 12 934 */ 935 insertString(start: number, other: string): void; 936 937 /** 938 * Remove the string of the specified range. 939 * 940 * @param { number } start - the start position of the removedString. 941 * @param { number } length - the length of the removedString's characters. 942 * @throws { BusinessError } 401 - Parameter error. Possible causes: 943 * <br> 1. Mandatory parameters are left unspecified. 944 * <br> 2. Incorrect parameters types. 945 * <br> 3. Parameter verification failed. 946 * @syscap SystemCapability.ArkUI.ArkUI.Full 947 * @crossplatform 948 * @atomicservice 949 * @since 12 950 */ 951 removeString(start: number, length: number): void; 952 953 /** 954 * Replace the specified range string attribute. 955 * 956 * @param { SpanStyle } spanStyle - the SpanStyle Object. 957 * @throws { BusinessError } 401 - Parameter error. Possible causes: 958 * <br> 1. Mandatory parameters are left unspecified. 959 * <br> 2. Incorrect parameters types. 960 * <br> 3. Parameter verification failed. 961 * @syscap SystemCapability.ArkUI.ArkUI.Full 962 * @crossplatform 963 * @atomicservice 964 * @since 12 965 */ 966 replaceStyle(spanStyle: SpanStyle): void; 967 968 /** 969 * Add attributes to the specified range string. 970 * 971 * @param { SpanStyle } spanStyle - the SpanStyle Object. 972 * @throws { BusinessError } 401 - The parameter check failed. 973 * @syscap SystemCapability.ArkUI.ArkUI.Full 974 * @crossplatform 975 * @atomicservice 976 * @since 12 977 */ 978 setStyle(spanStyle: SpanStyle): void; 979 980 /** 981 * Delete the specified type attributes for the specified range string. 982 * 983 * @param { number } start - the start position of the removedAttributeStyledString. 984 * @param { number } length - the length of the removedAttributeStyledString's characters. 985 * @param { StyledStringKey } styledKey - the specified attribute type's key. 986 * @throws { BusinessError } 401 - Parameter error. Possible causes: 987 * <br> 1. Mandatory parameters are left unspecified. 988 * <br> 2. Incorrect parameters types. 989 * <br> 3. Parameter verification failed. 990 * @syscap SystemCapability.ArkUI.ArkUI.Full 991 * @crossplatform 992 * @atomicservice 993 * @since 12 994 */ 995 removeStyle(start: number, length: number, styledKey: StyledStringKey): void; 996 997 /** 998 * Delete all attributes for the specified range styledString. 999 * 1000 * @param { number } start - the start position of the attributeRemovedStyledString's characters. 1001 * @param { number } length - the length of the attributeRemovedStyledString's characters. 1002 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1003 * <br> 1. Mandatory parameters are left unspecified. 1004 * <br> 2. Incorrect parameters types. 1005 * <br> 3. Parameter verification failed. 1006 * @syscap SystemCapability.ArkUI.ArkUI.Full 1007 * @crossplatform 1008 * @atomicservice 1009 * @since 12 1010 */ 1011 removeStyles(start: number, length: number): void; 1012 1013 /** 1014 * Delete all attributes. 1015 * 1016 * @syscap SystemCapability.ArkUI.ArkUI.Full 1017 * @crossplatform 1018 * @atomicservice 1019 * @since 12 1020 */ 1021 clearStyles(): void; 1022 1023 /** 1024 * Replace the StyledString of the specified range. 1025 * 1026 * @param { number } start - the start position of the replacedStyledString. 1027 * @param { number } length - the length of the replacedStyledString's characters. 1028 * @param { StyledString } other - new StyledString. 1029 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1030 * <br> 1. Mandatory parameters are left unspecified. 1031 * <br> 2. Incorrect parameters types. 1032 * <br> 3. Parameter verification failed. 1033 * @syscap SystemCapability.ArkUI.ArkUI.Full 1034 * @crossplatform 1035 * @atomicservice 1036 * @since 12 1037 */ 1038 replaceStyledString(start: number, length: number, other: StyledString): void; 1039 1040 /** 1041 * Insert new StyledString at the specified location. 1042 * 1043 * @param { number } start - the start position of the insertedStyledString. 1044 * @param { StyledString } other - new StyledString. 1045 * @throws { BusinessError } 401 - Parameter error. Possible causes: 1046 * <br> 1. Mandatory parameters are left unspecified. 1047 * <br> 2. Incorrect parameters types. 1048 * <br> 3. Parameter verification failed. 1049 * @syscap SystemCapability.ArkUI.ArkUI.Full 1050 * @crossplatform 1051 * @atomicservice 1052 * @since 12 1053 */ 1054 insertStyledString(start: number, other: StyledString): void; 1055 1056 /** 1057 * Append new StyledString at the end. 1058 * 1059 * @param { StyledString } other - new StyledString. 1060 * @syscap SystemCapability.ArkUI.ArkUI.Full 1061 * @crossplatform 1062 * @atomicservice 1063 * @since 12 1064 */ 1065 appendStyledString(other: StyledString): void; 1066} 1067 1068 1069/** 1070 * the attribute type of the StyledString 1071 * 1072 * @enum { number } 1073 * @syscap SystemCapability.ArkUI.ArkUI.Full 1074 * @crossplatform 1075 * @atomicservice 1076 * @since 12 1077 */ 1078declare enum StyledStringKey { 1079 /** 1080 * The key of TextStyle. 1081 * 1082 * @syscap SystemCapability.ArkUI.ArkUI.Full 1083 * @crossplatform 1084 * @atomicservice 1085 * @since 12 1086 */ 1087 FONT = 0, 1088 1089 /** 1090 * The key of DecorationStyle. 1091 * 1092 * @syscap SystemCapability.ArkUI.ArkUI.Full 1093 * @crossplatform 1094 * @atomicservice 1095 * @since 12 1096 */ 1097 DECORATION = 1, 1098 1099 /** 1100 * The key of BaselineOffsetStyle. 1101 * 1102 * @syscap SystemCapability.ArkUI.ArkUI.Full 1103 * @crossplatform 1104 * @atomicservice 1105 * @since 12 1106 */ 1107 BASELINE_OFFSET = 2, 1108 1109 /** 1110 * The key of LetterSpacingStyle. 1111 * 1112 * @syscap SystemCapability.ArkUI.ArkUI.Full 1113 * @crossplatform 1114 * @atomicservice 1115 * @since 12 1116 */ 1117 LETTER_SPACING = 3, 1118 1119 /** 1120 * The key of TextShadowStyle. 1121 * 1122 * @syscap SystemCapability.ArkUI.ArkUI.Full 1123 * @crossplatform 1124 * @atomicservice 1125 * @since 12 1126 */ 1127 TEXT_SHADOW = 4, 1128 1129 /** 1130 * The key of LineHeightStyle. 1131 * 1132 * @syscap SystemCapability.ArkUI.ArkUI.Full 1133 * @crossplatform 1134 * @atomicservice 1135 * @since 12 1136 */ 1137 LINE_HEIGHT = 5, 1138 1139 /** 1140 * The key of GestureStyle. 1141 * 1142 * @syscap SystemCapability.ArkUI.ArkUI.Full 1143 * @crossplatform 1144 * @atomicservice 1145 * @since 12 1146 */ 1147 GESTURE = 100, 1148 1149 /** 1150 * The key of ParagraphStyle. 1151 * 1152 * @syscap SystemCapability.ArkUI.ArkUI.Full 1153 * @crossplatform 1154 * @atomicservice 1155 * @since 12 1156 */ 1157 PARAGRAPH_STYLE = 200, 1158 1159 /** 1160 * The key of ImageAttachment. 1161 * 1162 * @syscap SystemCapability.ArkUI.ArkUI.Full 1163 * @crossplatform 1164 * @atomicservice 1165 * @since 12 1166 */ 1167 IMAGE = 300, 1168 1169 /** 1170 * The key of CustomSpan. 1171 * 1172 * @syscap SystemCapability.ArkUI.ArkUI.Full 1173 * @crossplatform 1174 * @atomicservice 1175 * @since 12 1176 */ 1177 CUSTOM_SPAN = 400, 1178 1179 /** 1180 * The key of UserDataSpan. 1181 * 1182 * @syscap SystemCapability.ArkUI.ArkUI.Full 1183 * @crossplatform 1184 * @atomicservice 1185 * @since 12 1186 */ 1187 USER_DATA = 500, 1188} 1189 1190/** 1191 * Defines ImageAttachment. 1192 * 1193 * @syscap SystemCapability.ArkUI.ArkUI.Full 1194 * @crossplatform 1195 * @atomicservice 1196 * @since 12 1197 */ 1198declare class ImageAttachment { 1199 1200 /** 1201 * constructor. 1202 * 1203 * @param { ImageAttachmentInterface } value - image attachment object. 1204 * @syscap SystemCapability.ArkUI.ArkUI.Full 1205 * @crossplatform 1206 * @atomicservice 1207 * @since 12 1208 */ 1209 constructor(value: ImageAttachmentInterface); 1210 1211 /** 1212 * Get the image content of the StyledString. 1213 * 1214 * @type { PixelMap } - the image content of the StyledString or undefined 1215 * @readonly 1216 * @syscap SystemCapability.ArkUI.ArkUI.Full 1217 * @crossplatform 1218 * @atomicservice 1219 * @since 12 1220 */ 1221 readonly value: PixelMap; 1222 1223 /** 1224 * Get the imageSize of the StyledString. 1225 * 1226 * @type { ?SizeOptions } - the imageSize of the StyledString or undefined 1227 * @readonly 1228 * @syscap SystemCapability.ArkUI.ArkUI.Full 1229 * @crossplatform 1230 * @atomicservice 1231 * @since 12 1232 */ 1233 readonly size?: SizeOptions; 1234 1235 /** 1236 * Get the ImageSpanAlignment of the StyledString. 1237 * 1238 * @type { ?ImageSpanAlignment } - the ImageSpanAlignment of the StyledString or undefined 1239 * @readonly 1240 * @syscap SystemCapability.ArkUI.ArkUI.Full 1241 * @crossplatform 1242 * @atomicservice 1243 * @since 12 1244 */ 1245 readonly verticalAlign?: ImageSpanAlignment; 1246 1247 /** 1248 * Get the imageFit of the StyledString. 1249 * 1250 * @type { ?ImageFit } - the imageFit of the StyledString or undefined 1251 * @readonly 1252 * @syscap SystemCapability.ArkUI.ArkUI.Full 1253 * @crossplatform 1254 * @atomicservice 1255 * @since 12 1256 */ 1257 readonly objectFit?: ImageFit; 1258 1259 /** 1260 * Get the imageAttachmentLayoutStyle of the StyledString. 1261 * 1262 * @type { ?ImageAttachmentLayoutStyle } - the imageAttachmentLayoutStyle of the StyledString or undefined 1263 * @readonly 1264 * @syscap SystemCapability.ArkUI.ArkUI.Full 1265 * @crossplatform 1266 * @atomicservice 1267 * @since 12 1268 */ 1269 readonly layoutStyle?: ImageAttachmentLayoutStyle; 1270} 1271 1272/** 1273 * Defines the ImageAttachmentInterface. 1274 * 1275 * @interface ImageAttachmentInterface 1276 * @syscap SystemCapability.ArkUI.ArkUI.Full 1277 * @crossplatform 1278 * @atomicservice 1279 * @since 12 1280 */ 1281declare interface ImageAttachmentInterface { 1282 /** 1283 * The content of the ImageAttachment. 1284 * 1285 * @type { PixelMap } 1286 * @syscap SystemCapability.ArkUI.ArkUI.Full 1287 * @crossplatform 1288 * @atomicservice 1289 * @since 12 1290 */ 1291 value: PixelMap; 1292 1293 /** 1294 * Image size. 1295 * 1296 * @type { ?SizeOptions } 1297 * @syscap SystemCapability.ArkUI.ArkUI.Full 1298 * @crossplatform 1299 * @atomicservice 1300 * @since 12 1301 */ 1302 size?: SizeOptions; 1303 1304 /** 1305 * Image vertical align. 1306 * 1307 * @type { ?ImageSpanAlignment } 1308 * @syscap SystemCapability.ArkUI.ArkUI.Full 1309 * @crossplatform 1310 * @atomicservice 1311 * @since 12 1312 */ 1313 verticalAlign?: ImageSpanAlignment; 1314 1315 /** 1316 * Image fit. 1317 * 1318 * @type { ?ImageFit } 1319 * @syscap SystemCapability.ArkUI.ArkUI.Full 1320 * @crossplatform 1321 * @atomicservice 1322 * @since 12 1323 */ 1324 objectFit?: ImageFit; 1325 1326 /** 1327 * The Image Layout Style. 1328 * 1329 * @type { ?ImageAttachmentLayoutStyle } 1330 * @syscap SystemCapability.ArkUI.ArkUI.Full 1331 * @crossplatform 1332 * @atomicservice 1333 * @since 12 1334 */ 1335 layoutStyle?: ImageAttachmentLayoutStyle; 1336} 1337 1338/** 1339 * Defines the ImageAttachment Layout Style. 1340 * 1341 * @interface ImageAttachmentLayoutStyle 1342 * @syscap SystemCapability.ArkUI.ArkUI.Full 1343 * @crossplatform 1344 * @atomicservice 1345 * @since 12 1346 */ 1347declare interface ImageAttachmentLayoutStyle { 1348 /** 1349 * Outer Margin. 1350 * 1351 * @type { ?(LengthMetrics | Margin) } 1352 * @syscap SystemCapability.ArkUI.ArkUI.Full 1353 * @crossplatform 1354 * @atomicservice 1355 * @since 12 1356 */ 1357 margin?: LengthMetrics | Margin; 1358 1359 /** 1360 * Inner margin. 1361 * 1362 * @type { ?(LengthMetrics | Padding) } 1363 * @syscap SystemCapability.ArkUI.ArkUI.Full 1364 * @crossplatform 1365 * @atomicservice 1366 * @since 12 1367 */ 1368 padding?: LengthMetrics | Padding; 1369 1370 /** 1371 * Border radius. 1372 * 1373 * @type { ?(LengthMetrics | BorderRadiuses) } 1374 * @syscap SystemCapability.ArkUI.ArkUI.Full 1375 * @crossplatform 1376 * @atomicservice 1377 * @since 12 1378 */ 1379 borderRadius?: LengthMetrics | BorderRadiuses; 1380} 1381 1382/** 1383 * Defines the CustomSpanMetrics interface. 1384 * 1385 * @interface CustomSpanMetrics 1386 * @syscap SystemCapability.ArkUI.ArkUI.Full 1387 * @crossplatform 1388 * @atomicservice 1389 * @since 12 1390 */ 1391declare interface CustomSpanMetrics { 1392 /** 1393 * CustomSpan Width. 1394 * The unit is vp. 1395 * 1396 * @type { number } 1397 * @default 0 1398 * @syscap SystemCapability.ArkUI.ArkUI.Full 1399 * @crossplatform 1400 * @atomicservice 1401 * @since 12 1402 */ 1403 width: number; 1404 1405 /** 1406 * CustomSpan Height. 1407 * The unit is vp. 1408 * 1409 * @type { ?number } 1410 * @syscap SystemCapability.ArkUI.ArkUI.Full 1411 * @crossplatform 1412 * @atomicservice 1413 * @since 12 1414 */ 1415 height?: number; 1416} 1417 1418/** 1419 * Defines the CustomSpanDrawInfo interface. 1420 * 1421 * @interface CustomSpanDrawInfo 1422 * @syscap SystemCapability.ArkUI.ArkUI.Full 1423 * @crossplatform 1424 * @atomicservice 1425 * @since 12 1426 */ 1427declare interface CustomSpanDrawInfo { 1428 /** 1429 * CustomSpan's offset relative to the parent component. 1430 * The unit is px. 1431 * 1432 * @type { number } 1433 * @syscap SystemCapability.ArkUI.ArkUI.Full 1434 * @crossplatform 1435 * @atomicservice 1436 * @since 12 1437 */ 1438 x: number; 1439 1440 /** 1441 * The top position of the line where customSpan is located. 1442 * The unit is px. 1443 * 1444 * @type { number } 1445 * @syscap SystemCapability.ArkUI.ArkUI.Full 1446 * @crossplatform 1447 * @atomicservice 1448 * @since 12 1449 */ 1450 lineTop: number; 1451 1452 /** 1453 * The bottom position of the line where customSpan is located. 1454 * The unit is px. 1455 * 1456 * @type { number } 1457 * @syscap SystemCapability.ArkUI.ArkUI.Full 1458 * @crossplatform 1459 * @atomicservice 1460 * @since 12 1461 */ 1462 lineBottom: number; 1463 1464 /** 1465 * The baseline offset of the line where customSpan is located. 1466 * The unit is px. 1467 * 1468 * @type { number } 1469 * @syscap SystemCapability.ArkUI.ArkUI.Full 1470 * @crossplatform 1471 * @atomicservice 1472 * @since 12 1473 */ 1474 baseline: number; 1475} 1476 1477/** 1478 * Defines the CustomSpanMeasureInfo interface. 1479 * 1480 * @interface CustomSpanMeasureInfo 1481 * @syscap SystemCapability.ArkUI.ArkUI.Full 1482 * @crossplatform 1483 * @atomicservice 1484 * @since 12 1485 */ 1486declare interface CustomSpanMeasureInfo { 1487 /** 1488 * Current component's fontSize value. 1489 * The unit is fp. 1490 * 1491 * @type { number } 1492 * @syscap SystemCapability.ArkUI.ArkUI.Full 1493 * @crossplatform 1494 * @atomicservice 1495 * @since 12 1496 */ 1497 fontSize: number; 1498} 1499 1500/** 1501 * Defines CustomSpan. 1502 * 1503 * @syscap SystemCapability.ArkUI.ArkUI.Full 1504 * @crossplatform 1505 * @atomicservice 1506 * @since 12 1507 */ 1508declare abstract class CustomSpan { 1509 /** 1510 * Measure the size of custom span. 1511 * 1512 * @param { CustomSpanMeasureInfo } measureInfo 1513 * @returns { CustomSpanMetrics } - CustomSpan Size 1514 * @syscap SystemCapability.ArkUI.ArkUI.Full 1515 * @crossplatform 1516 * @atomicservice 1517 * @since 12 1518 */ 1519 abstract onMeasure(measureInfo: CustomSpanMeasureInfo) : CustomSpanMetrics; 1520 1521 /** 1522 * Draw the custom span. 1523 * 1524 * @param { DrawContext } context 1525 * @param { CustomSpanDrawInfo } drawInfo 1526 * @syscap SystemCapability.ArkUI.ArkUI.Full 1527 * @crossplatform 1528 * @atomicservice 1529 * @since 12 1530 */ 1531 abstract onDraw(context: DrawContext, drawInfo: CustomSpanDrawInfo): void; 1532 1533 /** 1534 * Invalidate all components that use the object, which will cause a re-render of all components. 1535 * 1536 * @syscap SystemCapability.ArkUI.ArkUI.Full 1537 * @crossplatform 1538 * @atomicservice 1539 * @since 13 1540 */ 1541 invalidate(): void; 1542} 1543 1544/** 1545 * Defines UserDataSpan. Used to store and obtain user data. 1546 * 1547 * @syscap SystemCapability.ArkUI.ArkUI.Full 1548 * @crossplatform 1549 * @atomicservice 1550 * @since 12 1551 */ 1552declare abstract class UserDataSpan {}