enable extensions init

This commit is contained in:
Philipp Kühn
2020-03-05 22:40:02 +01:00
parent bb26465da8
commit 8da66c9cd8
2 changed files with 15 additions and 17 deletions

View File

@@ -2,12 +2,6 @@ import { Editor } from './Editor'
export default abstract class Extension { export default abstract class Extension {
public abstract name: string
editor: any
options: { [key: string]: any } = {}
defaultOptions: { [key: string]: any } = {}
constructor(options = {}) { constructor(options = {}) {
this.options = { this.options = {
...this.defaultOptions, ...this.defaultOptions,
@@ -15,16 +9,20 @@ export default abstract class Extension {
} }
} }
init(): any { editor!: Editor
return null options: { [key: string]: any } = {}
} defaultOptions: { [key: string]: any } = {}
bindEditor(editor: Editor): void { public abstract name: string
this.editor = editor
}
public type = 'extension' public type = 'extension'
protected init() {}
protected bindEditor(editor: Editor): void {
this.editor = editor
}
get update(): any { get update(): any {
return () => {} return () => {}
} }

View File

@@ -7,11 +7,11 @@ export default class ExtensionManager {
extensions: [any?] extensions: [any?]
constructor(extensions: any = [], editor: Editor) { constructor(extensions: any = [], editor: Editor) {
// extensions.forEach(extension => {
// extension.bindEditor(editor)
// extension.init()
// })
this.extensions = extensions this.extensions = extensions
this.extensions.forEach(extension => {
extension.bindEditor(editor)
extension.init()
})
} }
get nodes(): any { get nodes(): any {
@@ -28,7 +28,7 @@ export default class ExtensionManager {
.all() .all()
} }
get plugins(): any { get plugins() {
return collect(this.extensions) return collect(this.extensions)
.flatMap(extension => extension.plugins) .flatMap(extension => extension.plugins)
.toArray() .toArray()