Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions docs/tools-inline.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Also, you can provide optional methods
- `renderActions()` — create additional element below the buttons
- `clear()` — clear Tool's stuff on opening/closing of Inline Toolbar
- `sanitize()` — sanitizer configuration
- `prepare()` — prepare Tool's data on Editor's initialization (static)
- `reset()` — clean up Tool's data on Editor's destroy (static)

At the constructor of Tool's class exemplar you will accept an object with the [API](api.md) as a parameter.

Expand Down Expand Up @@ -104,6 +106,62 @@ Method does not accept any parameters

Method should not return a value.

### static prepare()

If you need to prepare some data for the Tool (eg. load external script, create HTML nodes in the document, etc) you can use the static `prepare()` method.

It accepts the Tool's config passed on Editor's initialization as an argument:

```javascript
class MyInlineTool {
static isInline = true;

static prepare(config) {
loadScript();
insertNodes();
...
}
}
```

#### Parameters

type | description |
-- | -- |
`object` | your Tool configuration |

#### Return value

No return value

---

### static reset()

On Editor destroy you can use an opposite method `reset` to clean up all prepared data:

```javascript
class MyInlineTool {
static isInline = true;

static reset() {
cleanUpScripts();
deleteNodes();
...
}
}
```

#### Parameters

No parameters

#### Return value

No return value

---

### static get sanitize()

We recommend to specify the Sanitizer config that corresponds with inline tags that is used by your Tool.
Expand Down