2020-08-22 06:12:34 +08:00
|
|
|
import { Plugin } from 'prosemirror-state'
|
2020-04-13 06:16:12 +08:00
|
|
|
import { Editor, Command } from './Editor'
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-03-06 03:30:58 +08:00
|
|
|
export default abstract class Extension {
|
|
|
|
|
2019-12-17 06:20:05 +08:00
|
|
|
constructor(options = {}) {
|
|
|
|
this.options = {
|
2020-04-13 20:03:39 +08:00
|
|
|
...this.defaultOptions(),
|
2019-12-17 06:20:05 +08:00
|
|
|
...options,
|
|
|
|
}
|
|
|
|
}
|
2020-03-06 05:40:02 +08:00
|
|
|
|
|
|
|
editor!: Editor
|
|
|
|
options: { [key: string]: any } = {}
|
|
|
|
|
|
|
|
public abstract name: string
|
|
|
|
|
2020-04-11 04:07:27 +08:00
|
|
|
public extensionType = 'extension'
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-03-08 06:37:58 +08:00
|
|
|
public created() {}
|
2019-12-17 06:20:05 +08:00
|
|
|
|
2020-03-08 06:37:58 +08:00
|
|
|
public bindEditor(editor: Editor): void {
|
2019-12-17 06:20:05 +08:00
|
|
|
this.editor = editor
|
|
|
|
}
|
|
|
|
|
2020-04-13 20:03:39 +08:00
|
|
|
defaultOptions(): { [key: string]: any } {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
|
2020-03-29 06:58:48 +08:00
|
|
|
update(): any {
|
2019-12-17 06:20:05 +08:00
|
|
|
return () => {}
|
|
|
|
}
|
|
|
|
|
2020-08-22 06:12:34 +08:00
|
|
|
plugins(): Plugin[] {
|
2019-12-17 06:20:05 +08:00
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
inputRules(): any {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
|
|
|
pasteRules(): any {
|
|
|
|
return []
|
|
|
|
}
|
|
|
|
|
2020-04-13 18:27:29 +08:00
|
|
|
keys(): { [key: string]: Function } {
|
2019-12-17 06:20:05 +08:00
|
|
|
return {}
|
2020-04-02 20:34:07 +08:00
|
|
|
}
|
|
|
|
|
2020-04-13 06:16:12 +08:00
|
|
|
commands(): { [key: string]: Command } {
|
2020-04-02 20:34:07 +08:00
|
|
|
return {}
|
2020-04-01 04:17:54 +08:00
|
|
|
}
|
2019-12-17 06:20:05 +08:00
|
|
|
|
|
|
|
}
|