-
Notifications
You must be signed in to change notification settings - Fork 1
[add] document insertValue() method #40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sp-next-v-2-1
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| --- | ||
| sidebar_label: insertValue() | ||
| title: insertValue Method | ||
| description: You can learn about the insertValue method in the documentation of the DHTMLX JavaScript RichText library. Browse developer guides and API reference, try out code examples and live demos, and download a free 30-day evaluation version of DHTMLX RichText. | ||
| --- | ||
|
|
||
| # insertValue() | ||
|
|
||
| ### Description | ||
|
|
||
| @short: Inserts a value at the current cursor position or replaces the selected text | ||
|
|
||
| ### Usage | ||
|
|
||
| ~~~jsx {} | ||
| insertValue: (value: string, encoder?: any): void; | ||
| ~~~ | ||
|
|
||
| ### Parameters | ||
|
|
||
| - `value` - (required) a value to be inserted into the RichText at the current cursor position. If a selection is active, the selection is replaced with the new value | ||
| - `encoder` - (optional) a parser used to decode the inserted value from a custom format. The following formats are available: `html` (default), `text`, and `markdown` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "custom format" is somewhat misleading. only 3 formats are supported, which is said later. so just drop "from a custom format"
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Убрал «from a custom format» — оставил только перечень поддерживаемых форматов ниже. |
||
|
|
||
| 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 fromMarkdownEncoder = richtext.markdown.fromMarkdown; // markdown encoder | ||
| ``` | ||
|
|
||
| ### Example | ||
|
|
||
| ~~~jsx {6} | ||
| const editor = new richtext.Richtext("#root", { | ||
| // configuration properties | ||
| }); | ||
|
|
||
| // inserts an HTML link with custom attributes at the cursor position | ||
| editor.insertValue("<a href=\"https://example.com\" title=\"Example\">link</a>"); | ||
| ~~~ | ||
|
|
||
| The inserted content is added as a single history entry and can be reverted with one **Undo** step. | ||
|
|
||
| **Change log:** The method was added in v2.1 | ||
Uh oh!
There was an error while loading. Please reload this page.