-
-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from MohamedRejeb/1.x
Improve documentation
- Loading branch information
Showing
13 changed files
with
602 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,75 @@ | ||
# HTML import and export | ||
# HTML Import and Export | ||
|
||
To convert HTML to `RichTextState`, use `RichTextState.setHtml` method: | ||
The Rich Text Editor supports converting between HTML and rich text content. This allows you to: | ||
- Save editor content as HTML | ||
- Load content from HTML sources | ||
- Integrate with HTML-based systems | ||
|
||
## Importing HTML | ||
|
||
To convert HTML to `RichTextState`, use the `setHtml` method: | ||
|
||
```kotlin | ||
val html = "<p><b>Compose Rich Editor</b></p>" | ||
richTextState.setHtml(html) | ||
// Basic formatting | ||
val simpleHtml = """ | ||
<p><b>Bold</b> and <i>italic</i> text with <u>underline</u></p> | ||
""" | ||
richTextState.setHtml(simpleHtml) | ||
|
||
// Complex structure | ||
val complexHtml = """ | ||
<div> | ||
<h1>Title</h1> | ||
<p>Paragraph with <strong>bold</strong> and <em>italic</em> text.</p> | ||
<ul> | ||
<li>Unordered list item 1</li> | ||
<li>Unordered list item 2</li> | ||
</ul> | ||
<ol> | ||
<li>Ordered list item 1</li> | ||
<li>Ordered list item 2</li> | ||
</ol> | ||
<p>Link to <a href="https://example.com">Example</a></p> | ||
<pre><code>Code block example</code></pre> | ||
</div> | ||
""" | ||
richTextState.setHtml(complexHtml) | ||
``` | ||
|
||
To convert `RichTextState` to HTML, use `RichTextState.toHtml` method: | ||
## Exporting to HTML | ||
|
||
To convert `RichTextState` to HTML, use the `toHtml` method: | ||
|
||
```kotlin | ||
val html = richTextState.toHtml() | ||
``` | ||
println(html) // Outputs formatted HTML string | ||
``` | ||
|
||
## Supported HTML Tags | ||
|
||
The following HTML tags are supported: | ||
|
||
### Text Formatting | ||
- `<b>`, `<strong>` - Bold text | ||
- `<i>`, `<em>` - Italic text | ||
- `<u>` - Underlined text | ||
- `<s>`, `<del>` - Strikethrough text | ||
- `<code>` - Code spans | ||
|
||
### Structure | ||
- `<p>` - Paragraphs | ||
- `<div>` - Divisions | ||
- `<br>` - Line breaks | ||
- `<ul>` - Unordered lists | ||
- `<ol>` - Ordered lists | ||
- `<li>` - List items | ||
|
||
### Links | ||
- `<a href="...">` - Hyperlinks | ||
|
||
## Notes | ||
|
||
- Unsupported HTML tags will be ignored during import | ||
- Nested lists are supported | ||
- Custom styles (using style attribute) are not currently supported | ||
- The HTML output is clean and properly formatted |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.