Skip to content

Commit 3d957c8

Browse files
Merge pull request #36 from DHTMLX/next
Rewrite guides using ai skills
2 parents d9ce404 + 23065aa commit 3d957c8

10 files changed

Lines changed: 455 additions & 332 deletions

docs/api/config/layout-mode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ description: You can learn about the layoutMode config in the documentation of t
1616
layoutMode: "classic" | "document";
1717
~~~
1818

19-
The `"classic"` mode represents the edit area that fits the entire page. The `"document"` mode closely represent the real document sizes (sizes used: A4, A5, A6, A7).
19+
The `"classic"` mode fills the entire edit area. The `"document"` mode displays the edit area as a document page.
2020

2121
### Default config
2222

docs/guides/configuration.md

Lines changed: 103 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,34 @@ description: You can learn about the configuration in the documentation of the D
66

77
# Configuration
88

9-
You can configure RichText appearance and functionality via the corresponding API. The available parameters will allow you to:
9+
You can configure the RichText appearance and behavior with the following properties:
1010

11-
- Show/hide **menubar** using the [`menubar`](api/config/menubar.md) property
12-
- Configure **toolbar** using the [`toolbar`](api/config/toolbar.md) property
13-
- Enable the **fullscreen mode** using the [`fullscreenMode`](api/config/fullscreen-mode.md) property
14-
- Toggle the **layout** between "classic" and "document" modes using the [`layoutMode`](api/config/layout-mode.md) property
15-
- Specify **initial value** using the [`value`](api/config/value.md) property
16-
- Specify **initial locale** using the [`locale`](api/config/locale.md) property
17-
- Apply **initial styles** using the [`defaultStyles`](api/config/default-styles.md) property
11+
- [`menubar`](api/config/menubar.md) — show or hide the top menubar
12+
- [`toolbar`](api/config/toolbar.md) — configure toolbar visibility and buttons
13+
- [`fullscreenMode`](api/config/fullscreen-mode.md) — start the editor in fullscreen
14+
- [`layoutMode`](api/config/layout-mode.md) — switch between the `"classic"` and `"document"` layouts
15+
- [`value`](api/config/value.md) — set the initial HTML content
16+
- [`locale`](api/config/locale.md) — apply a localization object on initialization
17+
- [`defaultStyles`](api/config/default-styles.md) — set default styles for specific block types
18+
- [`imageUploadUrl`](api/config/image-upload-url.md) — set the endpoint for image uploads
1819

1920
## Layout modes
2021

21-
There are two layout modes of RichText editor between which you can select to get the best working place for creating your perfect content:
22+
RichText supports two layout modes for the editing area:
2223

23-
- **"classic"**
24+
- **"classic"** — the edit area fills the entire page
2425

2526
<div className="img_border">
2627
![Classic mode](./../assets/richtext/classic_mode.png)
2728
</div>
2829

29-
- **"document"**
30+
- **"document"** — the edit area mimics a document page
3031

3132
<div className="img_border">
3233
![Document mode](./../assets/richtext/document_mode.png)
3334
</div>
3435

35-
To specify the desired mode, you need to define it in the [`layoutMode`](api/config/layout-mode.md) property of the RichText configuration object during initialization of the component:
36+
Set the [`layoutMode`](api/config/layout-mode.md) property during initialization to choose the mode:
3637

3738
~~~jsx
3839
const editor = new richtext.Richtext("#root", {
@@ -42,17 +43,17 @@ const editor = new richtext.Richtext("#root", {
4243

4344
## Toolbar
4445

45-
The RichText toolbar consists of several blocks of controls that can be changed according to your needs.
46+
The RichText toolbar groups controls into several blocks that you can customize.
4647

4748
### Default toolbar controls
4849

49-
You can specify the following buttons and controls in the RichText toolbar:
50+
You can include the following buttons and controls in the RichText toolbar:
5051

5152
| Button | Description |
5253
|---------------------|-----------------------------------------------------------------------------|
5354
| `undo` | Reverts the most recent user action |
5455
| `redo` | Reapplies the previously undone action |
55-
| `style` | Allows selection of text styles (e.g., headings, paragraph, etc.) |
56+
| `style` | Selects a text style (e.g., heading, paragraph, blockquote) |
5657
| `font-family` | Changes the font of the selected text |
5758
| `font-size` | Adjusts the size of the selected text |
5859
| `bold` | Applies bold formatting to the selected text |
@@ -76,11 +77,11 @@ You can specify the following buttons and controls in the RichText toolbar:
7677
| `clear` | Removes all formatting from the selected text |
7778
| `print` | Opens the print dialog |
7879
| `fullscreen` | Toggles fullscreen mode |
79-
| `mode` | Switches between 2 view modes: Classic/ Document |
80+
| `mode` | Switches between two layout modes: `classic` and `document` |
8081
| `shortcuts` | Displays a list of available keyboard shortcuts |
8182
| `separator` | Adds a visual separator between controls |
8283

83-
The toolbar structure is defined using the [`toolbar`](api/config/toolbar.md) property, which is an array with strings presenting the names of controls.
84+
Use the [`toolbar`](api/config/toolbar.md) property to define the toolbar as an array of control name strings:
8485

8586
~~~jsx {2-36}
8687
new richtext.Richtext("#root", {
@@ -125,36 +126,38 @@ new richtext.Richtext("#root", {
125126

126127
**Related sample:** [RichText. Custom control and simplified toolbar](https://snippet.dhtmlx.com/wda202ih?tag=richtext)
127128

128-
### Custom toolbar controls
129+
### Add custom toolbar controls
129130

130-
You can also specify custom controls as objects in the [`toolbar`](api/config/toolbar.md) property with the following parameters:
131+
Pass an object to the [`toolbar`](api/config/toolbar.md) array with one of these fields:
131132

132-
- `type` - (required) specifies a custom control type. The following types are available: `"button"`, `"richselect"`, `"colorpicker"`
133-
- `id` - (optional) a custom control ID (cannot overlap with existing control ID)
134-
- `label` - (optional) a button label (combines with icon)
135-
- `tooltip` - (optional) a tooltip displayed on hover (if not specified, uses the value from "label")
136-
- `css` - (optional) a css class name assigned to the control (default supported classes: wx-primary, wx-secondary)
137-
- `handler` - (optional) a callback function that executes when the button is clicked
133+
- `type: string` — required. Control type: `"button"`, `"richselect"`, or `"colorpicker"`
134+
- `id: string` — optional. Custom control ID; cannot overlap with existing control IDs
135+
- `icon: string` — optional. Icon class name; combines with the label
136+
- `label: string` — optional. Button label; combines with the icon
137+
- `tooltip: string` — optional. Tooltip that appears on hover; defaults to `label` if not set
138+
- `css: string` — optional. CSS class for the control. Built-in classes: `wx-primary`, `wx-secondary`
139+
- `handler: () => void` — optional. Callback that runs on click
140+
141+
The example below combines built-in buttons, a predefined control with the `richselect` type, and two custom buttons:
138142

139143
~~~jsx {6-32}
140144
new richtext.Richtext("#root", {
141145
toolbar: [
142-
// buttons (strings represent buttons only)
146+
// string entries represent built-in buttons
143147
"bold",
144148
"italic",
145-
// predefined buttons (user cannot define any other options for these (no labels, tooltips, options, etc.), so only ({ type: "button", id: string })
149+
// predefined buttons accept only { type: "button", id: string }
146150
{
147151
type: "button",
148152
id: "fullscreen",
149153
},
150-
// user must specify the correct type if they want to use a predefined control (e.g. richselect/colorpicker)
151-
// non-matching types will be ignored (not added to the toolbar)
154+
// for predefined richselect/colorpicker controls, set the matching type
155+
// entries with a non-matching type are ignored
152156
{
153-
type: "richselect", // type: "button" - incorrect, will be ignored
157+
type: "richselect", // type: "button" would be ignored here
154158
id: "mode",
155159
},
156-
// custom buttons (supported options are below)
157-
// user can only define custom buttons (no richselect/colorpicker support atm)
160+
// custom buttons (richselect/colorpicker are not supported for custom controls)
158161
{
159162
type: "button",
160163
id: "some",
@@ -176,9 +179,9 @@ new richtext.Richtext("#root", {
176179

177180
**Related sample:** [RichText. Custom control and simplified toolbar](https://snippet.dhtmlx.com/wda202ih?tag=richtext)
178181

179-
### Hide Toolbar
182+
### Hide the toolbar
180183

181-
If you need to hide toolbar, set the [`toolbar`](api/config/toolbar.md) property to `false` as follows:
184+
Set the [`toolbar`](api/config/toolbar.md) property to `false` to hide the toolbar:
182185

183186
~~~jsx {2}
184187
new richtext.Richtext("#root", {
@@ -187,13 +190,74 @@ new richtext.Richtext("#root", {
187190
});
188191
~~~
189192

190-
## Default styles
193+
## Show the menubar
194+
195+
Enable the [`menubar`](api/config/menubar.md) property to render the top menubar above the toolbar. The default value is `false`.
196+
197+
~~~jsx {2}
198+
new richtext.Richtext("#root", {
199+
menubar: true
200+
// other configuration properties
201+
});
202+
~~~
203+
204+
## Set the initial content
205+
206+
Use the [`value`](api/config/value.md) property to pass initial HTML content into the editor on initialization:
207+
208+
~~~jsx {2}
209+
new richtext.Richtext("#root", {
210+
value: "<h1>some value</h1>"
211+
// other configuration properties
212+
});
213+
~~~
214+
215+
To replace the content after initialization, or to load it in a non-HTML format with a custom encoder, call the [`setValue()`](api/methods/set-value.md) method.
216+
217+
## Set the initial locale
218+
219+
Use the [`locale`](api/config/locale.md) property to apply a localization object on initialization:
220+
221+
~~~jsx {2}
222+
new richtext.Richtext("#root", {
223+
locale: richtext.locales.cn
224+
// other configuration properties
225+
});
226+
~~~
227+
228+
For details and dynamic locale switching with [`setLocale()`](api/methods/set-locale.md), see the [Localization](guides/localization.md) guide.
229+
230+
## Start in fullscreen mode
231+
232+
Set the [`fullscreenMode`](api/config/fullscreen-mode.md) property to `true` to open the editor in fullscreen on initialization. The default value is `false`.
233+
234+
~~~jsx {2}
235+
new richtext.Richtext("#root", {
236+
fullscreenMode: true
237+
// other configuration properties
238+
});
239+
~~~
240+
241+
## Configure the image upload URL
242+
243+
Pass a URL to the [`imageUploadUrl`](api/config/image-upload-url.md) property to set the server endpoint for toolbar image uploads:
244+
245+
~~~jsx {2}
246+
new richtext.Richtext("#root", {
247+
imageUploadUrl: "https://example.com/upload"
248+
// other configuration properties
249+
});
250+
~~~
251+
252+
## Configure default styles
253+
254+
Use the [`defaultStyles`](api/config/default-styles.md) property to set default styles per block type.
191255

192-
You can apply default style values for specific block types in the editor using the [`defaultStyles`](api/config/default-styles.md) property.
256+
The [`defaultStyles`](api/config/default-styles.md) property has the following type signature:
193257

194258
~~~jsx {}
195259
defaultStyles?: boolean | {
196-
"*"?: { // affects all blocks, allowing you to set common properties for all of these blocks
260+
"*"?: { // applies to all blocks; sets common properties for every block
197261
"font-family"?: string; // "Roboto"| "Arial" | "Georgia" | "Tahoma" | "Times New Roman" | "Verdana"
198262
"font-size"?: string; // "12px" | "14px" | "16px" | "18px" | "20px" | "24px" | "28px" | "32px" | "36px"
199263
color?: string;
@@ -250,7 +314,7 @@ defaultStyles?: boolean | {
250314
};
251315
~~~
252316

253-
The `defaultStyles` property DOES NOT set the actual CSS to the affected blocks. CSS styles have to be applied separately:
317+
The [`defaultStyles`](api/config/default-styles.md) property does not apply CSS to the affected blocks. Apply matching CSS styles separately:
254318

255319
```html title="index.html"
256320
<div id="root"></div>
@@ -278,6 +342,6 @@ const editor = new richtext.Richtext("#root", {
278342
}
279343
```
280344

281-
In this example, all `h2` blocks are assigned to the `"Roboto"` font-family with a font-size of 28px with both the foreground and the background colors changed as well. Css styles are assigned to `h2` blocks as well.
345+
In this example, all `h2` blocks use the `"Roboto"` font family at 28px with purple text on a pink background. The matching CSS rule applies the same values to the rendered `h2` elements.
282346

283347
**Related sample:** [RichText. Changing the default value for typography (font, font size, etc.)](https://snippet.dhtmlx.com/6u3ti01s?tag=richtext)

docs/guides/initialization.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,58 +6,73 @@ description: You can learn about the initialization in the documentation of the
66

77
# Initialization
88

9-
This guide will give you detailed instructions on how to create RichText on a page to enrich your application with features of the RichText editor. Take the following steps to get a ready-to-use component:
9+
This guide explains how to add RichText to a page. Follow these steps to get a ready-to-use editor:
1010

11-
1. [Include the RichText source files on a page](#including-source-files).
12-
2. [Create a container for RichText](#creating-container).
13-
3. [Initialize RichText with the object constructor](#initializing-richtext).
11+
1. [Include the source files on a page](#include-the-source-files).
12+
2. [Create a container for RichText](#create-a-container).
13+
3. [Initialize RichText](#initialize-richtext).
1414

15-
## Including source files
15+
## Include the source files
1616

17-
[Download the package](https://dhtmlx.com/docs/products/dhtmlxRichText/download.shtml) and unpack it into a folder of your project.
17+
Add the RichText JavaScript and CSS files to your project. [Download the package](https://dhtmlx.com/docs/products/dhtmlxRichText/download.shtml) and unpack the contents into your project folder.
1818

19-
To create RichText, you need to include 2 source files on your page:
19+
To create RichText, include two source files on your page:
2020

2121
- *richtext.js*
2222
- *richtext.css*
2323

24-
Make sure that you set correct relative paths to the source files:
24+
Reference the files in your HTML. Adjust the relative paths to match your folder layout:
2525

2626
~~~html title="index.html"
2727
<script type="text/javascript" src="./codebase/richtext.js"></script>
2828
<link rel="stylesheet" href="./codebase/richtext.css">
2929
~~~
3030

31-
## Creating container
31+
## Create a container
3232

33-
Add a container for RichText and give it an ID, for example *"root"*:
33+
Add a container for RichText with an ID such as *"root"*:
3434

3535
~~~jsx title="index.html"
3636
<div id="root"></div>
3737
~~~
3838

39-
## Initializing RichText
39+
## Initialize RichText
4040

4141
Initialize RichText with the `richtext.Richtext` constructor. The constructor takes two parameters:
4242

43-
- an HTML container (the ID of the HTML container)
44-
- an object with configuration properties. [See the full list here](#configuration-properties)
43+
- a container — a CSS selector or a DOM element
44+
- a configuration object with the editor properties. See the [full list of properties](#configuration-properties) below
45+
46+
The example below initializes RichText in the `#root` container:
4547

4648
~~~jsx title="index.html"
47-
// create RichText
4849
const editor = new richtext.Richtext("#root", {
4950
// configuration properties
5051
});
5152
~~~
5253

5354
### Configuration properties
5455

56+
Add configuration options as keys of the configuration object.
57+
5558
:::note
56-
The full list of properties to configure **RichText** can be found [**here**](api/overview/properties_overview.md).
59+
For the full list of configuration properties, see the [Properties overview](api/overview/properties_overview.md).
5760
:::
5861

62+
## Destroy the RichText instance
63+
64+
Call the [`destructor()`](api/methods/destructor.md) method to remove the RichText HTML and detach all related events:
65+
66+
~~~jsx
67+
const editor = new richtext.Richtext("#root", {
68+
// configuration properties
69+
});
70+
71+
editor.destructor();
72+
~~~
73+
5974
## Example
6075

61-
In this snippet you can see how to initialize **RichText** with the initial data:
76+
The example below initializes RichText with the menubar enabled:
6277

6378
<iframe src="https://snippet.dhtmlx.com/tjryzka7?mode=js" frameborder="0" class="snippet_iframe" width="100%" height="500"></iframe>

0 commit comments

Comments
 (0)