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: dev/docs/wysiwyg-js-api.md
+33-9Lines changed: 33 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,10 @@
3
3
TODO - Link to this from JS code doc.
4
4
TODO - Create JS events and add to the js public events doc.
5
5
6
-
TODO - Document the JS API.
7
-
8
-
TODO - Add testing coverage
9
-
10
6
**Warning: This API is currently in development and may change without notice.**
11
7
12
8
This document covers the JavaScript API for the (newer Lexical-based) WYSIWYG editor.
13
-
This API is custom-built, and designed to abstract the internals of the editor away
9
+
This API is built and designed to abstract the internals of the editor away
14
10
to provide a stable interface for performing common customizations.
15
11
16
12
Only the methods and properties documented here are guaranteed to be stable **once this API
@@ -25,8 +21,9 @@ The API is provided as an object, which itself provides a number of modules
25
21
via its properties:
26
22
27
23
-`ui` - Provides all actions related to the UI of the editor, like buttons and toolbars.
24
+
-`content` - Provides all actions related to the live user content being edited upon.
28
25
29
-
Each of these modules, and the relevant types used within, can be found detailed below.
26
+
Each of these modules, and the relevant types used within, are documented in detail below.
30
27
31
28
---
32
29
@@ -36,7 +33,7 @@ This module provides all actions related to the UI of the editor, like buttons a
36
33
37
34
### Methods
38
35
39
-
#### createButton(options)
36
+
#### createButton(options: object)
40
37
41
38
Creates a new button which can be used by other methods.
42
39
This takes an option object with the following properties:
@@ -92,6 +89,33 @@ This has the following methods:
92
89
Represents a section of the main editor toolbar, which contains a set of buttons.
93
90
This has the following methods:
94
91
95
-
-`getLabel(): string` - Gets the label of the section.
92
+
-`getLabel(): string` - Provides the string label of the section.
96
93
-`addButton(button: EditorApiButton, targetIndex: number = -1): void` - Adds a button to the section.
97
-
- By default, this will append the button, although a target index can be provided to insert the button at a specific position.
94
+
- By default, this will append the button, although a target index can be provided to insert the button at a specific position.
95
+
96
+
---
97
+
98
+
## Content Module
99
+
100
+
This module provides all actions related to the live user content being edited within the editor.
101
+
102
+
### Methods
103
+
104
+
#### insertHtml(html, position)
105
+
106
+
Inserts the given HTML string at the given position string.
107
+
The position, if not provided, will default to `'selection'`, replacing any existing selected content (or inserting at the selection if there's no active selection range).
108
+
Valid position string values are: `selection`, `start` and `end`. `start` & `end` are relative to the whole editor document.
109
+
The HTML is not assured to be added to the editor exactly as provided, since it will be parsed and serialised to fit the editor's internal known model format. Different parts of the HTML content may be handled differently depending on if it's block or inline content.
0 commit comments