1e41f4b71Sopenharmony_ci# Text Component Common APIs 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci>**NOTE** 4e41f4b71Sopenharmony_ci> 5e41f4b71Sopenharmony_ci>This topic covers the common APIs of text components. 6e41f4b71Sopenharmony_ci>The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version. 7e41f4b71Sopenharmony_ci 8e41f4b71Sopenharmony_ci## CaretStyle<sup>10+</sup> 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description| 13e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | -------- | 14e41f4b71Sopenharmony_ci| width | [Length](ts-types.md#length) | No | Caret size. It cannot be set in percentage.| 15e41f4b71Sopenharmony_ci| color | [ResourceColor](ts-types.md#resourcecolor) | No | Caret color.| 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ci## LayoutManager<sup>12+</sup> 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciImplements a **LayoutManager** object. 20e41f4b71Sopenharmony_ci> **NOTE** 21e41f4b71Sopenharmony_ci> 22e41f4b71Sopenharmony_ci> After the text content is changed, you must wait for the layout to be completed before you can obtain the most up-to-date layout information. 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ci### Objects to Import 25e41f4b71Sopenharmony_ciThe following uses the **Text** component as an example. 26e41f4b71Sopenharmony_ci``` 27e41f4b71Sopenharmony_cicontroller: TextController = new TextController() 28e41f4b71Sopenharmony_cilet layoutManager: LayoutManager = this.controller.getLayoutManager(); 29e41f4b71Sopenharmony_ci``` 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci### getLineCount 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_cigetLineCount(): number 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ciObtains the total number of lines in the component. 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Return value** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci| Type | Description | 42e41f4b71Sopenharmony_ci| ------ | --------- | 43e41f4b71Sopenharmony_ci| number | Total number of lines in the component.| 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci### getGlyphPositionAtCoordinate 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_cigetGlyphPositionAtCoordinate(x: number, y: number): PositionWithAffinity 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ciObtains the position of a glyph close to a given coordinate. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci**Parameters** 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 56e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- | 57e41f4b71Sopenharmony_ci| x | number | Yes | X coordinate relative to the component, in px.| 58e41f4b71Sopenharmony_ci| y | number | Yes | Y coordinate relative to the component, in px.| 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**Return value** 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci| Type | Description | 63e41f4b71Sopenharmony_ci| --------------------------------------------- | ----------- | 64e41f4b71Sopenharmony_ci| [PositionWithAffinity](#positionwithaffinity) | Position of the glyph.| 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci### getLineMetrics 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_cigetLineMetrics(lineNumber: number): LineMetrics 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ciObtains the metrics information of a specified line. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci**Parameters** 75e41f4b71Sopenharmony_ci 76e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 77e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- | 78e41f4b71Sopenharmony_ci| lineNumber | number | Yes | Line number, starting at 0.| 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ci**Return value** 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ci| Type | Description | 83e41f4b71Sopenharmony_ci| ---------------------------------------- | -------- | 84e41f4b71Sopenharmony_ci| [LineMetrics](../../apis-arkgraphics2d/js-apis-graphics-text.md#linemetrics) | Button("Line Metrics")| 85e41f4b71Sopenharmony_ci 86e41f4b71Sopenharmony_ci## PositionWithAffinity 87e41f4b71Sopenharmony_ci 88e41f4b71Sopenharmony_ciDescribes the position and affinity of a glyph. 89e41f4b71Sopenharmony_ci 90e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci| Name | Type | Read Only| Mandatory| Description | 93e41f4b71Sopenharmony_ci| --------- | --------------------- | ---- | ---- | ------------------------ | 94e41f4b71Sopenharmony_ci| position | number | Yes | Yes | Index of the glyph relative to the paragraph. The value is an integer. | 95e41f4b71Sopenharmony_ci| affinity | [Affinity](../../apis-arkgraphics2d/js-apis-graphics-text.md#affinity) | Yes | Yes | Affinity of the position. | 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci## TextMenuItemId<sup>12+</sup> 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ciProvides the menu ID. 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci### Attributes 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ci| Name | Type | Read Only | Mandatory | Description | 112e41f4b71Sopenharmony_ci| ------------ |---------------------| ---- | ---- | ------ | 113e41f4b71Sopenharmony_ci| CUT | [TextMenuItemId](#textmenuitemid12) | Yes | No | Cut operation by default.| 114e41f4b71Sopenharmony_ci| COPY | [TextMenuItemId](#textmenuitemid12) | Yes | No | Copy operation by default.| 115e41f4b71Sopenharmony_ci| PASTE | [TextMenuItemId](#textmenuitemid12) | Yes | No | Paste operation by default.| 116e41f4b71Sopenharmony_ci| SELECT_ALL | [TextMenuItemId](#textmenuitemid12) | Yes | No | Select-all operation by default.| 117e41f4b71Sopenharmony_ci| COLLABORATION_SERVICE | [TextMenuItemId](#textmenuitemid12) | Yes | No | Collaboration service.| 118e41f4b71Sopenharmony_ci| CAMERA_INPUT | [TextMenuItemId](#textmenuitemid12) | Yes | No | Camera input| 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci### of 121e41f4b71Sopenharmony_ci 122e41f4b71Sopenharmony_cistatic of(id: ResourceStr): TextMenuItemId 123e41f4b71Sopenharmony_ci 124e41f4b71Sopenharmony_ciCreates a **TextMenuItemId** object based on **id**. 125e41f4b71Sopenharmony_ci 126e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 129e41f4b71Sopenharmony_ci 130e41f4b71Sopenharmony_ci**Parameters** 131e41f4b71Sopenharmony_ci 132e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 133e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | ------------------------------------------------------------ | 134e41f4b71Sopenharmony_ci| id | [ResourceStr](ts-types.md#resourcestr) | Yes | Menu ID.| 135e41f4b71Sopenharmony_ci 136e41f4b71Sopenharmony_ci**Return value** 137e41f4b71Sopenharmony_ci 138e41f4b71Sopenharmony_ci| Type | Description | 139e41f4b71Sopenharmony_ci| ------- | --------------------------------- | 140e41f4b71Sopenharmony_ci| [TextMenuItemId](#textmenuitemid12) | **TextMenuItemId** object.| 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci### equals 143e41f4b71Sopenharmony_ci 144e41f4b71Sopenharmony_ciequals(id: TextMenuItemId): boolean 145e41f4b71Sopenharmony_ci 146e41f4b71Sopenharmony_ciChecks whether this **TextMenuItemId** object is the same as another **TextMenuItemId** object. 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci**Parameters** 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 153e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | ------------------------------------------------------------ | 154e41f4b71Sopenharmony_ci| id | [TextMenuItemId](#textmenuitemid12) | Yes | ID of the **TextMenuItemId** object to compare.| 155e41f4b71Sopenharmony_ci 156e41f4b71Sopenharmony_ci**Return value** 157e41f4b71Sopenharmony_ci 158e41f4b71Sopenharmony_ci| Type | Description | 159e41f4b71Sopenharmony_ci| ------- | --------------------------------- | 160e41f4b71Sopenharmony_ci| boolean | Whether the two **TextMenuItemId** objects are the same.| 161e41f4b71Sopenharmony_ci 162e41f4b71Sopenharmony_ci## TextMenuItem 163e41f4b71Sopenharmony_ci 164e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 165e41f4b71Sopenharmony_ci 166e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 167e41f4b71Sopenharmony_ci 168e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 169e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | --------------------------------- | 170e41f4b71Sopenharmony_ci| content | [ResourceStr](ts-types.md#resourcestr) | Yes | Menu name.| 171e41f4b71Sopenharmony_ci| icon | [ResourceStr](ts-types.md#resourcestr) | No | Menu icon.<br>Online images are not supported.| 172e41f4b71Sopenharmony_ci| id | [TextMenuItemId](#textmenuitemid12) | Yes | Menu ID.| 173e41f4b71Sopenharmony_ci 174e41f4b71Sopenharmony_ci## EditMenuOptions 175e41f4b71Sopenharmony_ci 176e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 177e41f4b71Sopenharmony_ci 178e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 179e41f4b71Sopenharmony_ci 180e41f4b71Sopenharmony_ci### onCreateMenu 181e41f4b71Sopenharmony_ci 182e41f4b71Sopenharmony_cionCreateMenu(menuItems: Array\<TextMenuItem>): Array\<TextMenuItem> 183e41f4b71Sopenharmony_ci 184e41f4b71Sopenharmony_ciCreates a menu with the specified menu items. 185e41f4b71Sopenharmony_ci 186e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 189e41f4b71Sopenharmony_ci 190e41f4b71Sopenharmony_ci**Parameters** 191e41f4b71Sopenharmony_ci 192e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 193e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | --------------------------------- | 194e41f4b71Sopenharmony_ci| menuItems | Array\<[TextMenuItem](#textmenuitem)> | Yes | Menu items.<br>**NOTE**<br>Changes to the name of the default menu item do not take effect.| 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci**Return value** 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ci| Type | Description | 199e41f4b71Sopenharmony_ci| ------- | --------------------------------- | 200e41f4b71Sopenharmony_ci| Array\<[TextMenuItem](#textmenuitem)> | Menu items set.<br>**NOTE**<br>The icon of the default menu item is not returned.| 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci### onMenuItemClick 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_cionMenuItemClick(menuItem: TextMenuItem, range: TextRange): boolean 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ciCalled when the specified menu item is clicked. 207e41f4b71Sopenharmony_ci 208e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci**Parameters** 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 215e41f4b71Sopenharmony_ci| ------- | --------------------------------- | ---- | --------------------------------- | 216e41f4b71Sopenharmony_ci| menuItem | [TextMenuItem](#textmenuitem) | Yes | Menu item.| 217e41f4b71Sopenharmony_ci| range | [TextRange](#textrange12) | Yes | Selected text.| 218e41f4b71Sopenharmony_ci 219e41f4b71Sopenharmony_ci**Return value** 220e41f4b71Sopenharmony_ci 221e41f4b71Sopenharmony_ci| Type | Description | 222e41f4b71Sopenharmony_ci| ------- | --------------------------------- | 223e41f4b71Sopenharmony_ci| boolean | Execution logic of the menu item.<br>Returns **true** if the default system logic is intercepted and only the custom logic is executed.<br>Returns **false** if the custom logic is executed before the default system logic.| 224e41f4b71Sopenharmony_ci 225e41f4b71Sopenharmony_ci## TextRange<sup>12+</sup> 226e41f4b71Sopenharmony_ci 227e41f4b71Sopenharmony_ciDefines the text range. 228e41f4b71Sopenharmony_ci 229e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 232e41f4b71Sopenharmony_ci| -- | -- | -- | -- | 233e41f4b71Sopenharmony_ci| start | number | No| Start index.| 234e41f4b71Sopenharmony_ci| end | number | No| End index.| 235e41f4b71Sopenharmony_ci 236e41f4b71Sopenharmony_ci## EditableTextOnChangeCallback<sup>12+</sup> 237e41f4b71Sopenharmony_ci 238e41f4b71Sopenharmony_citype EditableTextOnChangeCallback = (value: string, previewText?: PreviewText) => void 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ciInvoked when the input in the text box changes. 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci**Parameters** 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 245e41f4b71Sopenharmony_ci| -- | -- | -- | -- | 246e41f4b71Sopenharmony_ci| value | string | Yes| Text displayed in the text box.| 247e41f4b71Sopenharmony_ci| previewText | [PreviewText](#previewtext12) | No| Information about the preview text, including its start position and text content.| 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ci## TextDataDetectorType<sup>11+</sup> 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci| Name | Description | 256e41f4b71Sopenharmony_ci| ----- | -------------------------------------- | 257e41f4b71Sopenharmony_ci| PHONE_NUMBER | Phone number.| 258e41f4b71Sopenharmony_ci| URL | URL.| 259e41f4b71Sopenharmony_ci| EMAIL | Email address.| 260e41f4b71Sopenharmony_ci| ADDRESS | Address.| 261e41f4b71Sopenharmony_ci| DATE_TIME | Time.| 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci## TextDeleteDirection<sup>12+</sup> 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ciDefines the direction for deleting text. 266e41f4b71Sopenharmony_ci 267e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 268e41f4b71Sopenharmony_ci 269e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 270e41f4b71Sopenharmony_ci 271e41f4b71Sopenharmony_ci| Name | Value | Description | 272e41f4b71Sopenharmony_ci| ------- | ---- | ---------------------------------- | 273e41f4b71Sopenharmony_ci| BACKWARD | 0 | Backward delete.| 274e41f4b71Sopenharmony_ci| FORWARD | 1 | Forward delete.| 275e41f4b71Sopenharmony_ci 276e41f4b71Sopenharmony_ci## InsertValue<sup>12+</sup> 277e41f4b71Sopenharmony_ci 278e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 279e41f4b71Sopenharmony_ci 280e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 281e41f4b71Sopenharmony_ci 282e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 283e41f4b71Sopenharmony_ci| ------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | 284e41f4b71Sopenharmony_ci| insertOffset | number | Yes | Position of the inserted text.| 285e41f4b71Sopenharmony_ci| insertValue | string | Yes | Content of the inserted text.| 286e41f4b71Sopenharmony_ci 287e41f4b71Sopenharmony_ci## DeleteValue<sup>12+</sup> 288e41f4b71Sopenharmony_ci 289e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 290e41f4b71Sopenharmony_ci 291e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 292e41f4b71Sopenharmony_ci 293e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 294e41f4b71Sopenharmony_ci| ------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ | 295e41f4b71Sopenharmony_ci| deleteOffset | number | Yes | Position of the deleted text.| 296e41f4b71Sopenharmony_ci| direction | [TextDeleteDirection](#textdeletedirection12) | Yes | Direction for deleting the text.| 297e41f4b71Sopenharmony_ci| deleteValue | string | Yes | Content of the deleted text.| 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ci## TextDataDetectorConfig<sup>11+</sup> 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 306e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ------------------------------------------- | 307e41f4b71Sopenharmony_ci| types | [TextDataDetectorType](ts-text-common.md#textdatadetectortype11)[] | Yes | Entity types for text recognition. Values **null** and **[]** indicate that all types of entities can be recognized.| 308e41f4b71Sopenharmony_ci| onDetectResultUpdate | (result: string) => void | No | Callback invoked when text recognition succeeds.<br>- **result**: text recognition result, in JSON format.| 309e41f4b71Sopenharmony_ci| color<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No | Entity color when text recognition succeeds.<br>Default value: **'#ff007dff'**| 310e41f4b71Sopenharmony_ci| decoration<sup>12+</sup> | [DecorationStyleInterface](ts-universal-styled-string.md#decorationstyleinterface)| No | Style of the entity decorative line when text recognition succeeds.<br>Default value:<br>{<br> type: TextDecorationType.Underline,<br> color: consistent with the entity color,<br> style: TextDecorationStyle.SOLID <br>} | 311e41f4b71Sopenharmony_ci## PreviewText<sup>12+</sup> 312e41f4b71Sopenharmony_ci 313e41f4b71Sopenharmony_ciPreview text. 314e41f4b71Sopenharmony_ci 315e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 316e41f4b71Sopenharmony_ci 317e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 320e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------ | ---- | -------------------------------------------------------- | 321e41f4b71Sopenharmony_ci| offset | number | Yes | Start position of the preview text.| 322e41f4b71Sopenharmony_ci| value | string | Yes | Content of the preview text. | 323e41f4b71Sopenharmony_ci 324e41f4b71Sopenharmony_ci## FontSettingOptions<sup>12+</sup> 325e41f4b71Sopenharmony_ci 326e41f4b71Sopenharmony_ciDefines the font settings. 327e41f4b71Sopenharmony_ci 328e41f4b71Sopenharmony_ci**Widget capability**: This API can be used in ArkTS widgets since API version 12. 329e41f4b71Sopenharmony_ci 330e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 331e41f4b71Sopenharmony_ci 332e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 333e41f4b71Sopenharmony_ci 334e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 335e41f4b71Sopenharmony_ci| -------- | ------------------------------------------------ | ---- | -------------------------------------------------------- | 336e41f4b71Sopenharmony_ci| enableVariableFontWeight | boolean | No | Whether to support variable font weight adjustment.| 337e41f4b71Sopenharmony_ci 338e41f4b71Sopenharmony_ci## OnDidChangeCallback<sup>12+</sup> 339e41f4b71Sopenharmony_ci 340e41f4b71Sopenharmony_citype OnDidChangeCallback = (rangeBefore: TextRange, rangeAfter: TextRange) => void 341e41f4b71Sopenharmony_ci 342e41f4b71Sopenharmony_ciRepresents the callback invoked after text changes. 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci**Parameters** 345e41f4b71Sopenharmony_ci 346e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 347e41f4b71Sopenharmony_ci| -- | -- | -- | -- | 348e41f4b71Sopenharmony_ci| rangeBefore | [TextRange](#textrange12) | Yes| Range of the text to be changed.| 349e41f4b71Sopenharmony_ci| rangeAfter | [TextRange](#textrange12) | Yes| Range of the text added.| 350e41f4b71Sopenharmony_ci 351e41f4b71Sopenharmony_ci## StyledStringChangedListener<sup>12+</sup> 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ciDefines the listener for changes of the styled string text content. 354e41f4b71Sopenharmony_ci 355e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 356e41f4b71Sopenharmony_ci 357e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 358e41f4b71Sopenharmony_ci 359e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 360e41f4b71Sopenharmony_ci| -- | -- | -- | -- | 361e41f4b71Sopenharmony_ci| onWillChange | Callback<[StyledStringChangeValue](ts-basic-components-richeditor.md#styledstringchangevalue12), boolean> | No| Callback invoked when text is about to change.| 362e41f4b71Sopenharmony_ci| onDidChange | [OnDidChangeCallback](#ondidchangecallback12) | No| Callback invoked when text is changed.| 363e41f4b71Sopenharmony_ci 364e41f4b71Sopenharmony_ci## StyledStringChangeValue<sup>12+</sup> 365e41f4b71Sopenharmony_ci 366e41f4b71Sopenharmony_ciDescribes the text changes of the styled string. 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 369e41f4b71Sopenharmony_ci 370e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 371e41f4b71Sopenharmony_ci 372e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 373e41f4b71Sopenharmony_ci| -- | -- | -- | -- | 374e41f4b71Sopenharmony_ci| range | TextRange | Yes| Range of the styled string to be replaced in the original string.| 375e41f4b71Sopenharmony_ci| replacementString | [StyledString](ts-universal-styled-string.md#styledstring) | Yes| Styled string used for replacement.| 376