Skip to content
Open
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
24 changes: 22 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,26 @@ 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\n\nSome **bold** text",
});

// 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.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add that markdown parser of Rich Text Editor doesn't provide support for nested structures (except bold inside italic). This means that combinations such as bold inside a link, italic inside a list, or multi-level lists will not render correctly

:::

## Keyboard shortcuts

The RichText editor supports a set of common keyboard shortcuts for faster formatting and editing. The shortcuts follow platform conventions and are available on both **Windows/Linux** (`Ctrl`) and **macOS** (`⌘`).
Expand Down