You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api/config/layout-mode.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ description: You can learn about the layoutMode config in the documentation of t
16
16
layoutMode:"classic"|"document";
17
17
~~~
18
18
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.
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:
36
37
37
38
~~~jsx
38
39
consteditor=newrichtext.Richtext("#root", {
@@ -42,17 +43,17 @@ const editor = new richtext.Richtext("#root", {
42
43
43
44
## Toolbar
44
45
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.
46
47
47
48
### Default toolbar controls
48
49
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:
|`style`|Allows selection of text styles (e.g., headings, paragraph, etc.)|
56
+
|`style`|Selects a text style (e.g., heading, paragraph, blockquote) |
56
57
|`font-family`| Changes the font of the selected text |
57
58
|`font-size`| Adjusts the size of the selected text |
58
59
|`bold`| Applies bold formatting to the selected text |
@@ -76,11 +77,11 @@ You can specify the following buttons and controls in the RichText toolbar:
76
77
|`clear`| Removes all formatting from the selected text |
77
78
|`print`| Opens the print dialog |
78
79
|`fullscreen`| Toggles fullscreen mode |
79
-
|`mode`| Switches between 2 view modes: Classic/ Document |
80
+
|`mode`| Switches between two layout modes: `classic` and `document`|
80
81
|`shortcuts`| Displays a list of available keyboard shortcuts |
81
82
|`separator`| Adds a visual separator between controls |
82
83
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:
84
85
85
86
~~~jsx {2-36}
86
87
newrichtext.Richtext("#root", {
@@ -125,36 +126,38 @@ new richtext.Richtext("#root", {
125
126
126
127
**Related sample:**[RichText. Custom control and simplified toolbar](https://snippet.dhtmlx.com/wda202ih?tag=richtext)
127
128
128
-
### Custom toolbar controls
129
+
### Add custom toolbar controls
129
130
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:
131
132
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:
138
142
139
143
~~~jsx {6-32}
140
144
newrichtext.Richtext("#root", {
141
145
toolbar: [
142
-
//buttons (strings represent buttons only)
146
+
//string entries represent built-in buttons
143
147
"bold",
144
148
"italic",
145
-
// predefined buttons (user cannot define any other options for these (no labels, tooltips, options, etc.), so only ({ type: "button", id: string })
//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
152
156
{
153
-
type:"richselect", // type: "button" - incorrect, will be ignored
157
+
type:"richselect", // type: "button" would be ignored here
154
158
id:"mode",
155
159
},
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)
158
161
{
159
162
type:"button",
160
163
id:"some",
@@ -176,9 +179,9 @@ new richtext.Richtext("#root", {
176
179
177
180
**Related sample:**[RichText. Custom control and simplified toolbar](https://snippet.dhtmlx.com/wda202ih?tag=richtext)
178
181
179
-
### Hide Toolbar
182
+
### Hide the toolbar
180
183
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:
182
185
183
186
~~~jsx {2}
184
187
newrichtext.Richtext("#root", {
@@ -187,13 +190,74 @@ new richtext.Richtext("#root", {
187
190
});
188
191
~~~
189
192
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
+
newrichtext.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
+
newrichtext.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
+
newrichtext.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
+
newrichtext.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
+
newrichtext.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.
191
255
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:
193
257
194
258
~~~jsx {}
195
259
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
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:
254
318
255
319
```html title="index.html"
256
320
<divid="root"></div>
@@ -278,6 +342,6 @@ const editor = new richtext.Richtext("#root", {
278
342
}
279
343
```
280
344
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"` fontfamily at 28px with purple text on a pink background. The matching CSS rule applies the same values to the rendered `h2`elements.
282
346
283
347
**Related sample:**[RichText. Changing the default value for typography (font, font size, etc.)](https://snippet.dhtmlx.com/6u3ti01s?tag=richtext)
Copy file name to clipboardExpand all lines: docs/guides/initialization.md
+31-16Lines changed: 31 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,58 +6,73 @@ description: You can learn about the initialization in the documentation of the
6
6
7
7
# Initialization
8
8
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:
10
10
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).
14
14
15
-
## Including source files
15
+
## Include the source files
16
16
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.
18
18
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:
20
20
21
21
-*richtext.js*
22
22
-*richtext.css*
23
23
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:
0 commit comments