docs: improve typescript docs, fix #2407

This commit is contained in:
Philipp Kühn
2022-01-20 11:53:45 +01:00
parent 21c8a71f73
commit 3215d8d6f8

View File

@@ -45,6 +45,8 @@ export interface CustomExtensionStorage {
}
const CustomExtension = Extension.create<{}, CustomExtensionStorage>({
name: 'customExtension',
addStorage() {
return {
awesomeness: 100,
@@ -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: