Skip to content

Commit 1bf2916

Browse files
Add basic methods description
1 parent 88b3de8 commit 1bf2916

5 files changed

Lines changed: 62 additions & 103 deletions

File tree

docs/api/methods/get-uploader.md

Lines changed: 0 additions & 41 deletions
This file was deleted.

docs/api/methods/get-value.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,43 @@
11
---
22
sidebar_label: getValue()
3-
title: setNext Method
4-
description: You can learn about the setNext 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.
3+
title: getValue Method
4+
description: You can learn about the getValue 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.
55
---
66

77
# getValue()
88

99
### Description
1010

11-
@short: ...
11+
@short: Gets the editor value
1212

1313
### Usage
1414

1515
~~~jsx {}
16-
getValue(next: any): void;
16+
getValue(encoder?: any): string;
1717
~~~
1818

1919
### Parameters
2020

21-
- `next` - (required) the action to be included into the **Event Bus** order
21+
- `encoder` - (optional) a parser used to encode the editor's content into a custom format. The following formats are available: `html` (default) and `text`
22+
23+
You can get the required encoder in the following way:
24+
25+
```jsx
26+
const TextEncoder = richtext.text.toText; // text encoder
27+
const HTMLEncoder = richtext.text.toHTML; // html encoder
28+
```
2229

2330
### Example
2431

25-
~~~jsx {15}
26-
const url = "https://some_backend_url";
27-
const restProvider = new richtext.RestDataProvider(url);
28-
29-
Promise.all([
30-
...
31-
]).then(([cards, columns, rows]) => {
32-
const editor = new richtext.Richtext("#root", {
33-
...
34-
});
35-
editor.getValue(restProvider);
32+
~~~jsx {6-7}
33+
const editor = new richtext.Richtext("#root", {
34+
value: "Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos." // sets the default value (HTML format)
35+
// other parameters
3636
});
37+
38+
const TextEncoder = richtext.text.toText;
39+
const editor_value = editor.getValue();
40+
console.log(editor_value);
3741
~~~
3842

39-
:::info
40-
You need to include **RestDataProvider** into the **Event Bus** order to perform operations with data (**adding**, **deleting** etc) and send the corresponding requests to the server
41-
:::
43+
**Change log:** The method was updated in v2.0. The `mode` parameter was deprecated. The `encoder` parameter was added

docs/api/methods/set-config.md

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,38 @@
11
---
22
sidebar_label: setConfig()
3-
title: setNext Method
4-
description: You can learn about the setNext 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.
3+
title: setConfig Method
4+
description: You can learn about the setConfig 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.
55
---
66

77
# setConfig()
88

99
### Description
1010

11-
@short: ...
11+
@short: Sets new configuration parameters
1212

1313
### Usage
1414

1515
~~~jsx {}
16-
setConfig(next: any): void;
16+
setConfig(config: { [key:any]: any }): void;
1717
~~~
1818

1919
### Parameters
2020

21-
- `next` - (required) the action to be included into the **Event Bus** order
21+
- `config` - (required) the object of Richtext configuration parameters. See the full list of properties [here](/category/richtext-properties/)
22+
23+
:::note
24+
The `setConfig()` method preserves all the previously set parameters that are not explicitly provided in the `setConfig()` method call.
25+
:::
2226

2327
### Example
2428

25-
~~~jsx {15}
26-
const url = "https://some_backend_url";
27-
const restProvider = new richtext.RestDataProvider(url);
28-
29-
Promise.all([
30-
...
31-
]).then(([cards, columns, rows]) => {
32-
const editor = new richtext.Richtext("#root", {
33-
...
34-
});
35-
editor.setConfig(restProvider);
29+
~~~jsx {6-8}
30+
const editor = new richtext.Richtext("#root", {
31+
value: "<h1>Some text</h1>",
32+
// other configuration parameters
3633
});
37-
~~~
3834

39-
:::info
40-
You need to include **RestDataProvider** into the **Event Bus** order to perform operations with data (**adding**, **deleting** etc) and send the corresponding requests to the server
41-
:::
35+
editor.setConfig({
36+
layoutMode: "document"
37+
});
38+
~~~

docs/api/methods/set-value.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,44 @@
11
---
22
sidebar_label: setValue()
3-
title: setNext Method
4-
description: You can learn about the setNext 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.
3+
title: setValue Method
4+
description: You can learn about the setValue 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.
55
---
66

77
# setValue()
88

99
### Description
1010

11-
@short: ...
11+
@short: Sets the editor value
1212

1313
### Usage
1414

1515
~~~jsx {}
16-
setValue(next: any): void;
16+
setValue: (value: string, encoder?: any): void;
1717
~~~
1818

1919
### Parameters
2020

21-
- `next` - (required) the action to be included into the **Event Bus** order
21+
- `value` - (required) a value to be inserted into the editor
22+
- `encoder` - (optional) a custom parser used to encode the editor's content into a custom format. The following formats are available: `html` (default) and `text`
23+
24+
You can get the required encoder in the following way:
25+
26+
```jsx
27+
const TextEncoder = richtext.text.fromText; // text encoder
28+
const HTMLEncoder = richtext.text.fromHTML; // html encoder
29+
```
2230

2331
### Example
2432

25-
~~~jsx {15}
26-
const url = "https://some_backend_url";
27-
const restProvider = new richtext.RestDataProvider(url);
28-
29-
Promise.all([
30-
...
31-
]).then(([cards, columns, rows]) => {
32-
const editor = new richtext.Richtext("#root", {
33-
...
34-
});
35-
editor.setValue(restProvider);
33+
~~~jsx {7-8}
34+
const editor = new richtext.Richtext("#root", {
35+
// configuration parameters
3636
});
37+
38+
const editor_value = "Lorem ipsum dolor sit amet consectetur adipiscing elit. Quisque faucibus ex sapien vitae pellentesque sem placerat. In id cursus mi pretium tellus duis convallis. Tempus leo eu aenean sed diam urna tempor. Pulvinar vivamus fringilla lacus nec metus bibendum egestas. Iaculis massa nisl malesuada lacinia integer nunc posuere. Ut hendrerit semper vel class aptent taciti sociosqu. Ad litora torquent per conubia nostra inceptos himenaeos."
39+
40+
const TextEncoder = richtext.text.fromText;
41+
editor.setValue(editor_value, TextEncoder);
3742
~~~
3843

39-
:::info
40-
You need to include **RestDataProvider** into the **Event Bus** order to perform operations with data (**adding**, **deleting** etc) and send the corresponding requests to the server
41-
:::
44+
**Change log:** The method was updated in v2.0. The `mode` parameter was deprecated. The `encoder` parameter was added

sidebars.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ module.exports = {
3737
image: "/img/docusaurus.png"
3838
},
3939
items: [
40-
// A
41-
"api/methods/get-uploader",
4240
"api/methods/get-value",
43-
"api/methods/set-config",
44-
"api/methods/set-value"
41+
"api/methods/set-value",
42+
"api/methods/set-config"
4543
]
4644
},
4745
// JS RichText internal methods

0 commit comments

Comments
 (0)