docs: improve typescript docs, fix #2407
This commit is contained in:
@@ -45,6 +45,8 @@ export interface CustomExtensionStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CustomExtension = Extension.create<{}, CustomExtensionStorage>({
|
const CustomExtension = Extension.create<{}, CustomExtensionStorage>({
|
||||||
|
name: 'customExtension',
|
||||||
|
|
||||||
addStorage() {
|
addStorage() {
|
||||||
return {
|
return {
|
||||||
awesomeness: 100,
|
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
|
### 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:
|
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:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user