1/* 2 * Copyright (c) 2021-2023 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 * Defines the text data detector type. 23 * 24 * @enum { number } 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @since 11 27 */ 28/** 29 * Defines the text data detector type. 30 * 31 * @enum { number } 32 * @syscap SystemCapability.ArkUI.ArkUI.Full 33 * @atomicservice 34 * @since 12 35 */ 36declare enum TextDataDetectorType { 37 /** 38 * Detector type phone number. 39 * 40 * @syscap SystemCapability.ArkUI.ArkUI.Full 41 * @since 11 42 */ 43 /** 44 * Detector type phone number. 45 * 46 * @syscap SystemCapability.ArkUI.ArkUI.Full 47 * @atomicservice 48 * @since 12 49 */ 50 PHONE_NUMBER = 0, 51 52 /** 53 * Detector type URL. 54 * 55 * @syscap SystemCapability.ArkUI.ArkUI.Full 56 * @since 11 57 */ 58 /** 59 * Detector type URL. 60 * 61 * @syscap SystemCapability.ArkUI.ArkUI.Full 62 * @atomicservice 63 * @since 12 64 */ 65 URL = 1, 66 67 /** 68 * Detector type email. 69 * 70 * @syscap SystemCapability.ArkUI.ArkUI.Full 71 * @since 11 72 */ 73 /** 74 * Detector type email. 75 * 76 * @syscap SystemCapability.ArkUI.ArkUI.Full 77 * @atomicservice 78 * @since 12 79 */ 80 EMAIL = 2, 81 82 /** 83 * Detector type address. 84 * 85 * @syscap SystemCapability.ArkUI.ArkUI.Full 86 * @since 11 87 */ 88 /** 89 * Detector type address. 90 * 91 * @syscap SystemCapability.ArkUI.ArkUI.Full 92 * @atomicservice 93 * @since 12 94 */ 95 ADDRESS = 3, 96 97 /** 98 * Detector type datetime. 99 * 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @atomicservice 102 * @since 12 103 */ 104 DATE_TIME = 4, 105} 106 107/** 108 * Text data detector config. 109 * 110 * @interface TextDataDetectorConfig 111 * @syscap SystemCapability.ArkUI.ArkUI.Full 112 * @since 11 113 */ 114/** 115 * Text data detector config. 116 * 117 * @interface TextDataDetectorConfig 118 * @syscap SystemCapability.ArkUI.ArkUI.Full 119 * @atomicservice 120 * @since 12 121 */ 122declare interface TextDataDetectorConfig { 123 /** 124 * Text data detector types. 125 * 126 * @type { TextDataDetectorType[] } 127 * @syscap SystemCapability.ArkUI.ArkUI.Full 128 * @since 11 129 */ 130 /** 131 * Text data detector types. 132 * 133 * @type { TextDataDetectorType[] } 134 * @syscap SystemCapability.ArkUI.ArkUI.Full 135 * @atomicservice 136 * @since 12 137 */ 138 types: TextDataDetectorType[] 139 140 /** 141 * Text data detect result callback. 142 * 143 * @type { ?function } 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @since 11 146 */ 147 /** 148 * Text data detect result callback. 149 * 150 * @type { ?function } 151 * @syscap SystemCapability.ArkUI.ArkUI.Full 152 * @atomicservice 153 * @since 12 154 */ 155 onDetectResultUpdate?: (result: string) => void 156 157 /** 158 * The color of AI entity. 159 * 160 * @type { ?ResourceColor } 161 * @syscap SystemCapability.ArkUI.ArkUI.Full 162 * @atomicservice 163 * @since 12 164 */ 165 color?: ResourceColor, 166 167 /** 168 * The decoration of AI entity. 169 * 170 * @type { ?DecorationStyleInterface } 171 * @syscap SystemCapability.ArkUI.ArkUI.Full 172 * @atomicservice 173 * @since 12 174 */ 175 decoration?: DecorationStyleInterface 176} 177 178/** 179 * Defines range of text type component. 180 * 181 * @interface TextRange 182 * @syscap SystemCapability.ArkUI.ArkUI.Full 183 * @crossplatform 184 * @atomicservice 185 * @since 12 186 */ 187declare interface TextRange { 188 /** 189 * Start offset. 190 * 191 * @type { ?number } 192 * @default 0 193 * @syscap SystemCapability.ArkUI.ArkUI.Full 194 * @crossplatform 195 * @atomicservice 196 * @since 12 197 */ 198 start?: number; 199 200 /** 201 * End offset. 202 * 203 * @type { ?number } 204 * @default text length 205 * @syscap SystemCapability.ArkUI.ArkUI.Full 206 * @crossplatform 207 * @atomicservice 208 * @since 12 209 */ 210 end?: number; 211} 212 213/** 214 * Defines the inserted text value info. 215 * 216 * @interface InsertValue 217 * @syscap SystemCapability.ArkUI.ArkUI.Full 218 * @crossplatform 219 * @atomicservice 220 * @since 12 221 */ 222declare interface InsertValue { 223 /** 224 * The location info where the value will be inserted. 225 * 226 * @type { number } 227 * @syscap SystemCapability.ArkUI.ArkUI.Full 228 * @crossplatform 229 * @atomicservice 230 * @since 12 231 */ 232 insertOffset: number; 233 234 /** 235 * The inserted value. 236 * 237 * @type { string } 238 * @syscap SystemCapability.ArkUI.ArkUI.Full 239 * @crossplatform 240 * @atomicservice 241 * @since 12 242 */ 243 insertValue: string; 244} 245 246/** 247 * Defines delete text direction. 248 * 249 * @enum { number } 250 * @syscap SystemCapability.ArkUI.ArkUI.Full 251 * @crossplatform 252 * @atomicservice 253 * @since 12 254 */ 255declare enum TextDeleteDirection { 256 /** 257 * Delete backward. 258 * 259 * @syscap SystemCapability.ArkUI.ArkUI.Full 260 * @crossplatform 261 * @atomicservice 262 * @since 12 263 */ 264 BACKWARD = 0, 265 266 /** 267 * Delete forward. 268 * 269 * @syscap SystemCapability.ArkUI.ArkUI.Full 270 * @crossplatform 271 * @atomicservice 272 * @since 12 273 */ 274 FORWARD = 1, 275} 276 277/** 278 * Defines menu type. 279 * 280 * @enum { number } 281 * @syscap SystemCapability.ArkUI.ArkUI.Full 282 * @crossplatform 283 * @atomicservice 284 * @since 13 285 */ 286declare enum MenuType { 287 /** 288 * Selection menu. 289 * 290 * @syscap SystemCapability.ArkUI.ArkUI.Full 291 * @crossplatform 292 * @atomicservice 293 * @since 13 294 */ 295 SELECTION_MENU = 0, 296 297 /** 298 * Preview menu, only for image. 299 * 300 * @syscap SystemCapability.ArkUI.ArkUI.Full 301 * @crossplatform 302 * @atomicservice 303 * @since 13 304 */ 305 PREVIEW_MENU = 1, 306} 307 308/** 309 * Provides an interface for deleting value from text. 310 * 311 * @interface DeleteValue 312 * @syscap SystemCapability.ArkUI.ArkUI.Full 313 * @crossplatform 314 * @atomicservice 315 * @since 12 316 */ 317declare interface DeleteValue { 318 /** 319 * The location info where the value will be deleted. 320 * 321 * @type { number } 322 * @syscap SystemCapability.ArkUI.ArkUI.Full 323 * @crossplatform 324 * @atomicservice 325 * @since 12 326 */ 327 deleteOffset: number; 328 329 /** 330 * The deleted direction. 331 * 332 * @type { TextDeleteDirection } 333 * @syscap SystemCapability.ArkUI.ArkUI.Full 334 * @crossplatform 335 * @atomicservice 336 * @since 12 337 */ 338 direction: TextDeleteDirection; 339 340 /** 341 * The deleted value. 342 * 343 * @type { string } 344 * @syscap SystemCapability.ArkUI.ArkUI.Full 345 * @crossplatform 346 * @atomicservice 347 * @since 12 348 */ 349 deleteValue: string; 350} 351 352/** 353 * Callback after content changed. 354 * 355 * @typedef { function } OnDidChangeCallback 356 * @param { TextRange } rangeBefore - Range of content that had been replaced. 357 * @param { TextRange } rangeAfter - Range of content that newly added. 358 * @syscap SystemCapability.ArkUI.ArkUI.Full 359 * @crossplatform 360 * @atomicservice 361 * @since 12 362 */ 363declare type OnDidChangeCallback = (rangeBefore: TextRange, rangeAfter: TextRange) => void; 364 365/** 366 * Callback when input sometimes has info of previewText. 367 * 368 * @typedef { function } EditableTextOnChangeCallback 369 * @param { string } value - Value of body text, without previewText value. 370 * @param { PreviewText } [previewText] - info of previewText, contains previewText value and start index. 371 * @syscap SystemCapability.ArkUI.ArkUI.Full 372 * @crossplatform 373 * @atomicservice 374 * @since 12 375 */ 376/** 377 * Callback when input sometimes has info of previewText. 378 * 379 * @typedef { function } EditableTextOnChangeCallback 380 * @param { string } value - Value of body text, without previewText value. 381 * @param { PreviewText } [previewText] - info of previewText, contains previewText value and start index. 382 * @param { TextChangeOptions } [options] - contains the selection range before and after the change, as well as the old content. 383 * @syscap SystemCapability.ArkUI.ArkUI.Full 384 * @crossplatform 385 * @atomicservice 386 * @since 15 387 */ 388declare type EditableTextOnChangeCallback = (value: string, previewText?: PreviewText, options?: TextChangeOptions) => void; 389 390/** 391 * Define the text selection controller. 392 * 393 * @interface TextBaseController 394 * @syscap SystemCapability.ArkUI.ArkUI.Full 395 * @crossplatform 396 * @atomicservice 397 * @since 12 398 */ 399declare interface TextBaseController { 400 /** 401 * Set selection to select a range of content. 402 * 403 * @param { number } selectionStart - The start position of the selected text. 404 * @param { number } selectionEnd - The end position of the selected text. 405 * @param { SelectionOptions } [options] - Indicates the options of selection. 406 * @syscap SystemCapability.ArkUI.ArkUI.Full 407 * @crossplatform 408 * @atomicservice 409 * @since 12 410 */ 411 setSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void; 412 413 /** 414 * Close the select menu when menu is on. 415 * 416 * @syscap SystemCapability.ArkUI.ArkUI.Full 417 * @crossplatform 418 * @atomicservice 419 * @since 12 420 */ 421 closeSelectionMenu(): void; 422 423 /** 424 * Get LayoutManager. 425 * 426 * @returns { LayoutManager } - Return the LayoutManager. 427 * @syscap SystemCapability.ArkUI.ArkUI.Full 428 * @crossplatform 429 * @atomicservice 430 * @since 12 431 */ 432 getLayoutManager(): LayoutManager; 433} 434 435/** 436 * Define the text extended editing controller. 437 * 438 * @extends TextBaseController 439 * @interface TextEditControllerEx 440 * @syscap SystemCapability.ArkUI.ArkUI.Full 441 * @crossplatform 442 * @atomicservice 443 * @since 12 444 */ 445declare interface TextEditControllerEx extends TextBaseController { 446 /** 447 * Judge whether is in editing state 448 * 449 * @returns { boolean } - true means that the component is in editing state, false means is non in editing status 450 * @syscap SystemCapability.ArkUI.ArkUI.Full 451 * @crossplatform 452 * @atomicservice 453 * @since 12 454 */ 455 isEditing(): boolean; 456 457 /** 458 * Stop editing state. 459 * 460 * @syscap SystemCapability.ArkUI.ArkUI.Full 461 * @crossplatform 462 * @atomicservice 463 * @since 12 464 */ 465 stopEditing(): void; 466 467 /** 468 * Set caret offset. 469 * 470 * @param { number } offset - caret offset. 471 * @returns { boolean } - Return true if the caret offset was successfully set, false otherwise. 472 * @syscap SystemCapability.ArkUI.ArkUI.Full 473 * @crossplatform 474 * @atomicservice 475 * @since 12 476 */ 477 setCaretOffset(offset: number): boolean; 478 479 /** 480 * Get caret offset from controller. 481 * 482 * @returns { number } 483 * @syscap SystemCapability.ArkUI.ArkUI.Full 484 * @crossplatform 485 * @atomicservice 486 * @since 12 487 */ 488 getCaretOffset(): number; 489 490 /** 491 * Get PreviewText. 492 * 493 * @returns { PreviewText } - Return the PreviewText. 494 * @syscap SystemCapability.ArkUI.ArkUI.Full 495 * @crossplatform 496 * @atomicservice 497 * @since 12 498 */ 499 getPreviewText?(): PreviewText; 500} 501 502/** 503 * The previewText. 504 * @interface PreviewText 505 * @syscap SystemCapability.ArkUI.ArkUI.Full 506 * @crossplatform 507 * @atomicservice 508 * @since 12 509 */ 510declare interface PreviewText { 511 /** 512 * Start offset of the previewText 513 * 514 * @type { number } 515 * @syscap SystemCapability.ArkUI.ArkUI.Full 516 * @crossplatform 517 * @atomicservice 518 * @since 12 519 */ 520 offset: number; 521 522 /** 523 * Value of the previewText. 524 * 525 * @type { string } 526 * @syscap SystemCapability.ArkUI.ArkUI.Full 527 * @crossplatform 528 * @atomicservice 529 * @since 12 530 */ 531 value: string; 532} 533 534/** 535 * Define the StyledString controller. 536 * 537 * @interface StyledStringController 538 * @syscap SystemCapability.ArkUI.ArkUI.Full 539 * @crossplatform 540 * @atomicservice 541 * @since 12 542 */ 543declare interface StyledStringController { 544 /** 545 * Set the StyledString of the component. 546 * 547 * @param { StyledString } styledString - StyledString. 548 * @syscap SystemCapability.ArkUI.ArkUI.Full 549 * @crossplatform 550 * @atomicservice 551 * @since 12 552 */ 553 setStyledString(styledString: StyledString): void; 554 555 /** 556 * Get the StyledString of the component. 557 * 558 * @returns { MutableStyledString } 559 * @syscap SystemCapability.ArkUI.ArkUI.Full 560 * @crossplatform 561 * @atomicservice 562 * @since 12 563 */ 564 getStyledString(): MutableStyledString; 565} 566 567/** 568 * Define the StyledString changed listener. 569 * 570 * @interface StyledStringChangedListener 571 * @syscap SystemCapability.ArkUI.ArkUI.Full 572 * @crossplatform 573 * @atomicservice 574 * @since 12 575 */ 576declare interface StyledStringChangedListener { 577 /** 578 * Called before text changed. 579 * 580 * @type { ?Callback<StyledStringChangeValue, boolean> } 581 * @syscap SystemCapability.ArkUI.ArkUI.Full 582 * @crossplatform 583 * @atomicservice 584 * @since 12 585 */ 586 onWillChange?: Callback<StyledStringChangeValue, boolean>; 587 588 /** 589 * Called after text changed. 590 * 591 * @type { ?OnDidChangeCallback } 592 * @syscap SystemCapability.ArkUI.ArkUI.Full 593 * @crossplatform 594 * @atomicservice 595 * @since 12 596 */ 597 onDidChange?: OnDidChangeCallback; 598} 599 600/** 601 * Define the StyledString changed value. 602 * 603 * @interface StyledStringChangeValue 604 * @syscap SystemCapability.ArkUI.ArkUI.Full 605 * @crossplatform 606 * @atomicservice 607 * @since 12 608 */ 609interface StyledStringChangeValue { 610 /** 611 * Range of the content to be replaced. 612 * 613 * @type { TextRange } 614 * @syscap SystemCapability.ArkUI.ArkUI.Full 615 * @crossplatform 616 * @atomicservice 617 * @since 12 618 */ 619 range: TextRange; 620 621 /** 622 * StyledString to replace. 623 * 624 * @type { StyledString } 625 * @syscap SystemCapability.ArkUI.ArkUI.Full 626 * @crossplatform 627 * @atomicservice 628 * @since 12 629 */ 630 replacementString: StyledString; 631 632 /** 633 * Preview StyledString 634 * 635 * @type { ?StyledString } 636 * @syscap SystemCapability.ArkUI.ArkUI.Full 637 * @crossplatform 638 * @atomicservice 639 * @since 12 640 */ 641 previewText?: StyledString; 642} 643 644/** 645 * Define the LayoutManager for querying layout information. 646 * 647 * @interface LayoutManager 648 * @syscap SystemCapability.ArkUI.ArkUI.Full 649 * @crossplatform 650 * @atomicservice 651 * @since 12 652 */ 653declare interface LayoutManager { 654 /** 655 * Get the line count. 656 * 657 * @returns { number } The line count value returned to the caller. 658 * @syscap SystemCapability.ArkUI.ArkUI.Full 659 * @crossplatform 660 * @atomicservice 661 * @since 12 662 */ 663 getLineCount(): number; 664 665 /** 666 * Get the glyph position at coordinate. 667 * 668 * @param { number } x - the positionX of typography. 669 * @param { number } y - the positionY of typography. 670 * @returns { PositionWithAffinity } TextBlob object. 671 * @syscap SystemCapability.ArkUI.ArkUI.Full 672 * @crossplatform 673 * @atomicservice 674 * @since 12 675 */ 676 getGlyphPositionAtCoordinate(x: number, y: number): PositionWithAffinity; 677 678 /** 679 * Get LineMetrics. 680 * 681 * @param { number } lineNumber - the number of line. 682 * @returns { LineMetrics } The line Metrics. 683 * @syscap SystemCapability.ArkUI.ArkUI.Full 684 * @crossplatform 685 * @atomicservice 686 * @since 12 687 */ 688 getLineMetrics(lineNumber: number): LineMetrics; 689 690 /** 691 * Get the rects for range. 692 * @param { TextRange } range - The range to set. 693 * @param { RectWidthStyle } widthStyle - Width style to set. 694 * @param { RectHeightStyle } heightStyle - Height style to set. 695 * @returns { Array<TextBox> } The rects for range. 696 * @syscap SystemCapability.ArkUI.ArkUI.Full 697 * @crossplatform 698 * @atomicservice 699 * @since 14 700 */ 701 getRectsForRange(range: TextRange, widthStyle: RectWidthStyle, heightStyle: RectHeightStyle): Array<TextBox>; 702} 703 704/** 705 * Position and affinity. 706 * 707 * @typedef PositionWithAffinity 708 * @syscap SystemCapability.ArkUI.ArkUI.Full 709 * @crossplatform 710 * @atomicservice 711 * @since 12 712 */ 713interface PositionWithAffinity { 714 /** 715 * Position of text. 716 * 717 * @type { number } 718 * @syscap SystemCapability.ArkUI.ArkUI.Full 719 * @crossplatform 720 * @atomicservice 721 * @since 12 722 */ 723 position: number; 724 725 /** 726 * Affinity of text. 727 * 728 * @type { Affinity } 729 * @syscap SystemCapability.ArkUI.ArkUI.Full 730 * @crossplatform 731 * @atomicservice 732 * @since 12 733 */ 734 affinity: Affinity; 735} 736 737/** 738 * Define the Affinity type. 739 * 740 * @typedef { import('../api/@ohos.graphics.text').default.Affinity } Affinity 741 * @syscap SystemCapability.ArkUI.ArkUI.Full 742 * @crossplatform 743 * @atomicservice 744 * @since 12 745 */ 746declare type Affinity = import('../api/@ohos.graphics.text').default.Affinity; 747 748/** 749 * Define the LineMetrics type. 750 * 751 * @typedef { import('../api/@ohos.graphics.text').default.LineMetrics } LineMetrics 752 * @syscap SystemCapability.ArkUI.ArkUI.Full 753 * @crossplatform 754 * @atomicservice 755 * @since 12 756 */ 757declare type LineMetrics = import('../api/@ohos.graphics.text').default.LineMetrics; 758 759/** 760 * Define the RectWidthStyle type. 761 * 762 * @typedef { import('../api/@ohos.graphics.text').default.RectWidthStyle } RectWidthStyle 763 * @syscap SystemCapability.ArkUI.ArkUI.Full 764 * @crossplatform 765 * @atomicservice 766 * @since 14 767 */ 768declare type RectWidthStyle = import('../api/@ohos.graphics.text').default.RectWidthStyle; 769 770/** 771 * Define the RectHeightStyle type. 772 * 773 * @typedef { import('../api/@ohos.graphics.text').default.RectHeightStyle } RectHeightStyle 774 * @syscap SystemCapability.ArkUI.ArkUI.Full 775 * @crossplatform 776 * @atomicservice 777 * @since 14 778 */ 779declare type RectHeightStyle = import('../api/@ohos.graphics.text').default.RectHeightStyle; 780 781/** 782 * Define the TextBox type. 783 * 784 * @typedef { import('../api/@ohos.graphics.text').default.TextBox } TextBox 785 * @syscap SystemCapability.ArkUI.ArkUI.Full 786 * @crossplatform 787 * @atomicservice 788 * @since 14 789 */ 790declare type TextBox = import('../api/@ohos.graphics.text').default.TextBox; 791 792/** 793 * Defines the cursor style 794 * 795 * @interface CaretStyle 796 * @syscap SystemCapability.ArkUI.ArkUI.Full 797 * @crossplatform 798 * @since 10 799 */ 800/** 801 * Defines the cursor style 802 * 803 * @interface CaretStyle 804 * @syscap SystemCapability.ArkUI.ArkUI.Full 805 * @crossplatform 806 * @atomicservice 807 * @since 11 808 */ 809interface CaretStyle { 810 /** 811 * Set the cursor width 812 * 813 * @type { ?Length } 814 * @syscap SystemCapability.ArkUI.ArkUI.Full 815 * @crossplatform 816 * @since 10 817 */ 818 /** 819 * Set the cursor width 820 * 821 * @type { ?Length } 822 * @syscap SystemCapability.ArkUI.ArkUI.Full 823 * @crossplatform 824 * @atomicservice 825 * @since 11 826 */ 827 width?: Length, 828 829 /** 830 * Set the cursor color 831 * 832 * @type { ?ResourceColor } 833 * @syscap SystemCapability.ArkUI.ArkUI.Full 834 * @crossplatform 835 * @since 10 836 */ 837 /** 838 * Set the cursor color 839 * 840 * @type { ?ResourceColor } 841 * @syscap SystemCapability.ArkUI.ArkUI.Full 842 * @crossplatform 843 * @atomicservice 844 * @since 11 845 */ 846 color?: ResourceColor, 847} 848 849/** 850 * Defines the TextMenuItemId. 851 * 852 * @syscap SystemCapability.ArkUI.ArkUI.Full 853 * @crossplatform 854 * @atomicservice 855 * @since 12 856 */ 857declare class TextMenuItemId { 858 /** 859 * Init a TextMenuItemId with id. 860 * 861 * @param { ResourceStr } id - The id of the TextMenuItemId. 862 * @returns { TextMenuItemId } - Returns the TextMenuItemId object. 863 * @static 864 * @syscap SystemCapability.ArkUI.ArkUI.Full 865 * @crossplatform 866 * @atomicservice 867 * @since 12 868 */ 869 static of(id: ResourceStr): TextMenuItemId; 870 871 /** 872 * Judge if two TextMenuItemId are equal. 873 * 874 * @param { TextMenuItemId } id - id TextMenuItemId. 875 * @returns { boolean } 876 * @syscap SystemCapability.ArkUI.ArkUI.Full 877 * @crossplatform 878 * @atomicservice 879 * @since 12 880 */ 881 equals(id: TextMenuItemId): boolean; 882 883 /** 884 * Indicates the TextMenuItemId to copy and delete the currently selected text. 885 * 886 * @type { TextMenuItemId } 887 * @readonly 888 * @static 889 * @syscap SystemCapability.ArkUI.ArkUI.Full 890 * @atomicservice 891 * @since 12 892 */ 893 static readonly CUT: TextMenuItemId; 894 895 /** 896 * Indicates the TextMenuItemId to copy the currently selected text to the clipboard. 897 * 898 * @type { TextMenuItemId } 899 * @readonly 900 * @static 901 * @syscap SystemCapability.ArkUI.ArkUI.Full 902 * @atomicservice 903 * @since 12 904 */ 905 static readonly COPY: TextMenuItemId; 906 907 /** 908 * Indicates the TextMenuItemId to copy the current contents of the clipboard into the text view. 909 * 910 * @type { TextMenuItemId } 911 * @readonly 912 * @static 913 * @syscap SystemCapability.ArkUI.ArkUI.Full 914 * @atomicservice 915 * @since 12 916 */ 917 static readonly PASTE: TextMenuItemId; 918 919 /** 920 * Indicates the TextMenuItemId to select all text in a text view. 921 * 922 * @type { TextMenuItemId } 923 * @readonly 924 * @static 925 * @syscap SystemCapability.ArkUI.ArkUI.Full 926 * @atomicservice 927 * @since 12 928 */ 929 static readonly SELECT_ALL: TextMenuItemId; 930 931 /** 932 * Indicates the TextMenuItemId for collaboration service menu items. 933 * 934 * @type { TextMenuItemId } 935 * @readonly 936 * @static 937 * @syscap SystemCapability.ArkUI.ArkUI.Full 938 * @atomicservice 939 * @since 12 940 */ 941 static readonly COLLABORATION_SERVICE: TextMenuItemId; 942 943 /** 944 * Indicates the TextMenuItemId to recognize the text in the picture and input it into the text view. 945 * 946 * @type { TextMenuItemId } 947 * @readonly 948 * @static 949 * @syscap SystemCapability.ArkUI.ArkUI.Full 950 * @atomicservice 951 * @since 12 952 */ 953 static readonly CAMERA_INPUT: TextMenuItemId; 954 955 /** 956 * Indicates the TextMenuItemId to help with text creation by invoking large models. 957 * 958 * @type { TextMenuItemId } 959 * @readonly 960 * @static 961 * @syscap SystemCapability.ArkUI.ArkUI.Full 962 * @atomicservice 963 * @since 13 964 */ 965 static readonly AI_WRITER: TextMenuItemId; 966 967 /** 968 * Indicates the TextMenuItemId to translate the selected content. 969 * 970 * @type { TextMenuItemId } 971 * @readonly 972 * @static 973 * @syscap SystemCapability.ArkUI.ArkUI.Full 974 * @atomicservice 975 * @since 15 976 */ 977 static readonly TRANSLATE: TextMenuItemId; 978 979 /** 980 * Indicates the TextMenuItemId to search the selected content. 981 * 982 * @type { TextMenuItemId } 983 * @readonly 984 * @static 985 * @syscap SystemCapability.ArkUI.ArkUI.Full 986 * @atomicservice 987 * @since 18 988 */ 989 static readonly SEARCH: TextMenuItemId; 990 991 /** 992 * Indicates the TextMenuItemId to share the selected content. 993 * 994 * @type { TextMenuItemId } 995 * @readonly 996 * @static 997 * @syscap SystemCapability.ArkUI.ArkUI.Full 998 * @atomicservice 999 * @since 18 1000 */ 1001 static readonly SHARE: TextMenuItemId; 1002} 1003 1004/** 1005 * TextMenuItem 1006 * 1007 * @interface TextMenuItem 1008 * @syscap SystemCapability.ArkUI.ArkUI.Full 1009 * @crossplatform 1010 * @atomicservice 1011 * @since 12 1012 */ 1013declare interface TextMenuItem { 1014 /** 1015 * Customize what the menu displays. 1016 * 1017 * @type { ResourceStr } 1018 * @syscap SystemCapability.ArkUI.ArkUI.Full 1019 * @crossplatform 1020 * @atomicservice 1021 * @since 12 1022 */ 1023 content: ResourceStr; 1024 /** 1025 * Customize the icon before the menu displays content. 1026 * 1027 * @type { ?ResourceStr } 1028 * @syscap SystemCapability.ArkUI.ArkUI.Full 1029 * @crossplatform 1030 * @atomicservice 1031 * @since 12 1032 */ 1033 icon?: ResourceStr; 1034 /** 1035 * Distinguish clicked menu content by Id. 1036 * 1037 * @type { TextMenuItemId } 1038 * @syscap SystemCapability.ArkUI.ArkUI.Full 1039 * @crossplatform 1040 * @atomicservice 1041 * @since 12 1042 */ 1043 id: TextMenuItemId; 1044 /** 1045 * Customize what the menu item shortcut displays. 1046 * 1047 * @type { ?ResourceStr } 1048 * @syscap SystemCapability.ArkUI.ArkUI.Full 1049 * @crossplatform 1050 * @atomicservice 1051 * @since 15 1052 */ 1053 labelInfo?: ResourceStr; 1054} 1055 1056/** 1057 * EditMenuOptions 1058 * 1059 * @interface EditMenuOptions 1060 * @syscap SystemCapability.ArkUI.ArkUI.Full 1061 * @crossplatform 1062 * @atomicservice 1063 * @since 12 1064 */ 1065declare interface EditMenuOptions { 1066 /** 1067 * Passes the default menu, invokes before every display to generate a menu for triggering click events. 1068 * 1069 * @param { Array<TextMenuItem> } menuItems - current default menu array. 1070 * @returns { Array<TextMenuItem> } - Return the menu after operations. 1071 * @syscap SystemCapability.ArkUI.ArkUI.Full 1072 * @crossplatform 1073 * @atomicservice 1074 * @since 12 1075 */ 1076 onCreateMenu(menuItems: Array<TextMenuItem>): Array<TextMenuItem>; 1077 /** 1078 * Invoke upon clicking an item, capable of intercepting the default system menu execution behavior. 1079 * 1080 * @param { TextMenuItem } menuItem - current default menu. 1081 * @param { TextRange } range - current selected range. 1082 * @returns { boolean } - Return True, the event is consumed, false otherwise. 1083 * @syscap SystemCapability.ArkUI.ArkUI.Full 1084 * @crossplatform 1085 * @atomicservice 1086 * @since 12 1087 */ 1088 onMenuItemClick(menuItem: TextMenuItem, range: TextRange): boolean; 1089} 1090 1091/** 1092 * Defines the font decoration result. 1093 * 1094 * @interface DecorationStyleResult 1095 * @syscap SystemCapability.ArkUI.ArkUI.Full 1096 * @crossplatform 1097 * @atomicservice 1098 * @since 12 1099 */ 1100interface DecorationStyleResult { 1101 /** 1102 * Font decoration type. 1103 * 1104 * @type { TextDecorationType } 1105 * @syscap SystemCapability.ArkUI.ArkUI.Full 1106 * @crossplatform 1107 * @atomicservice 1108 * @since 12 1109 */ 1110 type: TextDecorationType; 1111 1112 /** 1113 * Font decoration color. 1114 * 1115 * @type { ResourceColor } 1116 * @syscap SystemCapability.ArkUI.ArkUI.Full 1117 * @crossplatform 1118 * @atomicservice 1119 * @since 12 1120 */ 1121 color: ResourceColor; 1122 1123 /** 1124 * The style value of the decoration property object. 1125 * 1126 * @type { ?TextDecorationStyle } 1127 * @syscap SystemCapability.ArkUI.ArkUI.Full 1128 * @crossplatform 1129 * @atomicservice 1130 * @since 12 1131 */ 1132 style?: TextDecorationStyle; 1133} 1134 1135/** 1136 * Defines the options of font. 1137 * 1138 * @interface FontSettingOptions 1139 * @syscap SystemCapability.ArkUI.ArkUI.Full 1140 * @crossplatform 1141 * @form 1142 * @atomicservice 1143 * @since 12 1144 */ 1145declare interface FontSettingOptions { 1146 /** 1147 * Define whether VariableFontWeight is supported. 1148 * 1149 * @type { ?boolean } 1150 * @syscap SystemCapability.ArkUI.ArkUI.Full 1151 * @crossplatform 1152 * @form 1153 * @atomicservice 1154 * @since 12 1155 */ 1156 enableVariableFontWeight?: boolean; 1157 } 1158 1159 /** 1160 * The TextChangeOptions. 1161 * @interface TextChangeOptions 1162 * @syscap SystemCapability.ArkUI.ArkUI.Full 1163 * @crossplatform 1164 * @atomicservice 1165 * @since 15 1166 */ 1167declare interface TextChangeOptions { 1168 /** 1169 * The selected area before the change. 1170 * 1171 * @type { TextRange } 1172 * @syscap SystemCapability.ArkUI.ArkUI.Full 1173 * @crossplatform 1174 * @atomicservice 1175 * @since 15 1176 */ 1177 rangeBefore: TextRange; 1178 1179 /** 1180 * The selected area after the change. 1181 * 1182 * @type { TextRange } 1183 * @syscap SystemCapability.ArkUI.ArkUI.Full 1184 * @crossplatform 1185 * @atomicservice 1186 * @since 15 1187 */ 1188 rangeAfter: TextRange; 1189 1190 /** 1191 * The content before the change. 1192 * 1193 * @type { string } 1194 * @syscap SystemCapability.ArkUI.ArkUI.Full 1195 * @crossplatform 1196 * @atomicservice 1197 * @since 15 1198 */ 1199 oldContent: string; 1200 1201 /** 1202 * The info of PreviewText before the change. 1203 * 1204 * @type { PreviewText } 1205 * @syscap SystemCapability.ArkUI.ArkUI.Full 1206 * @crossplatform 1207 * @atomicservice 1208 * @since 15 1209 */ 1210 oldPreviewText: PreviewText; 1211} 1212 1213/** 1214 * Define the editableText Component changed value. 1215 * 1216 * @interface EditableTextChangeValue 1217 * @syscap SystemCapability.ArkUI.ArkUI.Full 1218 * @crossplatform 1219 * @atomicservice 1220 * @since 15 1221 */ 1222interface EditableTextChangeValue { 1223 /** 1224 * Value of body text, without previewText value. 1225 * 1226 * @type { string } 1227 * @syscap SystemCapability.ArkUI.ArkUI.Full 1228 * @crossplatform 1229 * @atomicservice 1230 * @since 15 1231 */ 1232 content: string; 1233 1234 /** 1235 * Info of previewText, contains previewText value and start index. 1236 * 1237 * @type { ?PreviewText } 1238 * @syscap SystemCapability.ArkUI.ArkUI.Full 1239 * @crossplatform 1240 * @atomicservice 1241 * @since 15 1242 */ 1243 previewText?: PreviewText; 1244 1245 /** 1246 * The TextChangeOptions. 1247 * 1248 * @type { TextChangeOptions } 1249 * @syscap SystemCapability.ArkUI.ArkUI.Full 1250 * @crossplatform 1251 * @atomicservice 1252 * @since 15 1253 */ 1254 options?: TextChangeOptions; 1255} 1256 1257 /** 1258 * Defines text menu show mode. 1259 * 1260 * @enum { number } 1261 * @syscap SystemCapability.ArkUI.ArkUI.Full 1262 * @crossplatform 1263 * @atomicservice 1264 * @since 16 1265 */ 1266declare enum TextMenuShowMode { 1267 /** 1268 * Display the text selection menu in the current window. 1269 * 1270 * @syscap SystemCapability.ArkUI.ArkUI.Full 1271 * @crossplatform 1272 * @atomicservice 1273 * @since 16 1274 */ 1275 DEFAULT = 0, 1276 1277 /** 1278 * Prefer to display the text selection menu in a separate window 1279 * and continue to display it within the current window if a separate window is not supported 1280 * 1281 * @syscap SystemCapability.ArkUI.ArkUI.Full 1282 * @crossplatform 1283 * @atomicservice 1284 * @since 16 1285 */ 1286 PREFER_WINDOW = 1, 1287} 1288 1289 /** 1290 * Defines text menu options. 1291 * 1292 * @interface TextMenuOptions 1293 * @syscap SystemCapability.ArkUI.ArkUI.Full 1294 * @crossplatform 1295 * @atomicservice 1296 * @since 16 1297 */ 1298declare interface TextMenuOptions { 1299 /** 1300 * Text menu show mode. 1301 * 1302 * @type { ?TextMenuShowMode } 1303 * @syscap SystemCapability.ArkUI.ArkUI.Full 1304 * @crossplatform 1305 * @atomicservice 1306 * @since 16 1307 */ 1308 showMode?: TextMenuShowMode; 1309} 1310/** 1311 * Defines keyboard appearance. 1312 * 1313 * @enum { number } 1314 * @syscap SystemCapability.ArkUI.ArkUI.Full 1315 * @atomicservice 1316 * @since 15 1317 */ 1318declare enum KeyboardAppearance { 1319 /** 1320 * Default appearance mode, don't adopt immersive styles 1321 * 1322 * @syscap SystemCapability.ArkUI.ArkUI.Full 1323 * @atomicservice 1324 * @since 15 1325 */ 1326 NONE_IMMERSIVE = 0, 1327 1328 /** 1329 * Immersive mode 1330 * 1331 * @syscap SystemCapability.ArkUI.ArkUI.Full 1332 * @atomicservice 1333 * @since 15 1334 */ 1335 IMMERSIVE = 1, 1336 1337 /** 1338 * Light immersive style 1339 * 1340 * @syscap SystemCapability.ArkUI.ArkUI.Full 1341 * @atomicservice 1342 * @since 15 1343 */ 1344 LIGHT_IMMERSIVE = 2, 1345 1346 /** 1347 * Dark immersive style 1348 * 1349 * @syscap SystemCapability.ArkUI.ArkUI.Full 1350 * @atomicservice 1351 * @since 15 1352 */ 1353 DARK_IMMERSIVE = 3, 1354}