Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions docs/api/methods/get-value.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ getValue(encoder?: any): string;

### Parameters

- `encoder` - (optional) a parser used to encode the RichText's content into a custom format. The following formats are available: `html` (default) and `text`
- `encoder` - (optional) a parser used to encode the RichText's content into a custom format. The following formats are available: `html` (default), `text`, and `markdown`

You can get the required encoder in the following way:

```jsx
const toTextEncoder = richtext.text.toText; // text encoder
const toHTMLEncoder = richtext.html.toHTML; // html encoder
const toTextEncoder = richtext.text.toText; // text encoder
const toHTMLEncoder = richtext.html.toHTML; // html encoder
const toMarkdownEncoder = richtext.markdown.toMarkdown; // markdown encoder
```

### Example
Expand Down
7 changes: 4 additions & 3 deletions docs/api/methods/set-value.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ setValue: (value: string, encoder?: any): void;
### Parameters

- `value` - (required) a value to be inserted into the RichText
- `encoder` - (optional) a custom parser used to encode the RichText's content into a custom format. The following formats are available: `html` (default) and `text`
- `encoder` - (optional) a custom parser used to encode the RichText's content into a custom format. The following formats are available: `html` (default), `text`, and `markdown`

You can get the required encoder in the following way:

```jsx
const fromTextEncoder = richtext.text.fromText; // text encoder
const fromHTMLEncoder = richtext.html.fromHTML; // html encoder
const fromTextEncoder = richtext.text.fromText; // text encoder
const fromHTMLEncoder = richtext.html.fromHTML; // html encoder
const fromMarkdownEncoder = richtext.markdown.fromMarkdown; // markdown encoder
```

### Example
Expand Down
27 changes: 25 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ description: You can have an overview of DHTMLX JavaScript RichText library in t

- Two [**layout modes**](api/config/layout-mode.md)

- Content serialization to both plain text and HTML
- Content serialization to HTML, plain text, and Markdown

- Configurable [**toolbar**](api/config/toolbar.md) with built-in and custom buttons

Expand Down Expand Up @@ -71,7 +71,7 @@ DHTMLX RichText can work with content in "classic" and "document" modes. You can

## Supported formats

The RichText editor supports [parsing](api/methods/set-value.md) and [serialization](api/methods/get-value.md) of content in the **HTML** and plain text formats.
The RichText editor supports [parsing](api/methods/set-value.md) and [serialization](api/methods/get-value.md) of content in the **HTML**, **plain text**, and **Markdown** formats.

#### HTML format

Expand All @@ -85,6 +85,29 @@ The RichText editor supports [parsing](api/methods/set-value.md) and [serializat
![Text format](./assets/richtext/text_format.png)
</div>

#### Markdown format

Pass the built-in `markdown` encoders to [`setValue()`](api/methods/set-value.md) / [`getValue()`](api/methods/get-value.md) to load or serialize content as Markdown:

~~~jsx
const editor = new richtext.Richtext("#root", {
value: "Hello world"
// other configuration properties
});

// load Markdown into the editor
editor.setValue("# Title\n\nParagraph", richtext.markdown.fromMarkdown);

// read editor content as Markdown
const md = editor.getValue(richtext.markdown.toMarkdown);
~~~

:::note
Markdown support covers a limited subset of the syntax — common block and inline elements such as headings, paragraphs, line breaks, emphasis, blockquotes, lists, and links. Formatting that has no Markdown equivalent (font family, font size, colors, alignment, line height) is dropped on serialization.
Comment thread
serhiipylypchuk1991 marked this conversation as resolved.

Nested inline structures are not supported, with the only exception of **bold inside italic**. Combinations such as bold inside a link, italic inside a list item, or multi-level (nested) lists will not render correctly.
:::

## Copy and paste

The RichText editor supports clipboard operations through standard system shortcuts (`Ctrl+C` / `Ctrl+X` / `Ctrl+V` on Windows/Linux, `⌘+C` / `⌘+X` / `⌘+V` on macOS), the corresponding [toolbar](api/config/toolbar.md) buttons, and the [menubar](api/config/menubar.md) entries.
Expand Down