diff --git a/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md b/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md new file mode 100644 index 0000000000000000000000000000000000000000..c807e1ad646371b1a3573cf690db734e7c2fa00f --- /dev/null +++ b/en/application-dev/reference/arkui-ts/ts-basic-components-richtext.md @@ -0,0 +1,81 @@ +# RichText + +> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** +> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. + +The **\** component parses and displays HTML text. + +## Required Permissions + +None + +## Child Components + +None + +## APIs + +RichText\(content:string\) + +- Parameters + + | Name| Type| Mandatory| Default Value| Description| + | -------- | -------- | -------- | -------- | -------- | + | content | string | Yes| - | String in HTML format.| + + +## Events + + +| Name| Description| +| -------- | -------- | +| onStart() => void | Triggered when web page loading starts.| +| onComplete() => void | Triggered when web page loading is completed.| + +## Supported Tags + +| Name| Description| Example| +| -------- | -------- | -------- | +| \

--\

| Defines six levels of headings in the HTML document. \

defines the most important heading, and \

defines the least important heading.| \

This is an H1 heading\

\

This is an H2 heading\

| +| \

\

| Defines a paragraph.| \

This is a paragraph\

| +| \
| Inserts a newline character.| \

This is a paragraph\
This is a new paragraph\

| +| \
| Defines a thematic break (such as a shift of topic) on an HTML page and creates a horizontal line.| \

This is a paragraph\

\
\

This is a paragraph\

| +| \
\
| Defines a generic container that is generally used to group block-level elements. It allows you to apply CSS styles to multiple elements at the same time.| \
\

This is the heading in a div element\

\
| +| \\ | Displays text in italic style.| \

\This is in italic style\\

| +| \\ | Defines text that should be styled differently or have a non-textual annotation, such as misspelt words or a proper name in Chinese text. It is recommended that you avoid using the \ tag where it could be confused with a hyperlink.| \

This is an underlined paragraph\

| +| \ | Used to embed CSS within an HTML document.| \ | +| style | Defines the inline style of an element and is placed inside the tag. Use quotation marks (') to separate the styling text and use semicolons (;) to separate styles, for example, **style='width: 500px;height: 500px;border: 1px solid;margin: 0 auto;'**.| \

This is a heading\

\

This is a paragraph\

| +| \ | Used to embed or reference a client-side script, such as JavaScript.| \ | + +## Example + +``` +@Entry +@Component +struct RichTextExample { + @State data: string ='

h1 heading

+

h1 italic

+

h1 underlined

+

h2 heading

+

h3 heading

+

Regular paragraph


+
+

Font size: 35px; line height: 45px

+

+ This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. + This is a paragraph.

' + + build() { + Flex({direction: FlexDirection.Column,alignItems: ItemAlign.Center, + justifyContent: FlexAlign.Center }){ + RichText(this.data) + .onStart(()=>{ + console.info("RichText onStart") + }) + .onComplete(()=>{ + console.info("RichText onComplete") + }) + } + } +} +```