Skip to content

Commit

Permalink
docs: improve typescript docs, fix #2407
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Kühn authored and Philipp Kühn committed Jan 20, 2022
1 parent 21c8a71 commit 3215d8d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docs/guide/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface CustomExtensionStorage {
}

const CustomExtension = Extension.create<{}, CustomExtensionStorage>({
name: 'customExtension',

addStorage() {
return {
awesomeness: 100,
Expand All @@ -53,6 +55,14 @@ const CustomExtension = Extension.create<{}, CustomExtensionStorage>({
})
```

When using storage outside of the extension you have to manually set the type.

```
import { CustomExtensionStorage } from './custom-extension
const customStorage = editor.storage.customExtension as CustomExtensionStorage
```

### Command type
The core package also exports a `Command` type, which needs to be added to all commands that you specify in your code. Here is an example:

Expand Down

0 comments on commit 3215d8d

Please sign in to comment.