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 {
public abstract name: string
editor: any
options: { [key: string]: any } = {}
defaultOptions: { [key: string]: any } = {}
constructor(options = {}) {
this.options = {
...this.defaultOptions,
@@ -15,16 +9,20 @@ export default abstract class Extension {
}
}
init(): any {
return null
}
editor!: Editor
options: { [key: string]: any } = {}
defaultOptions: { [key: string]: any } = {}
bindEditor(editor: Editor): void {
this.editor = editor
}
public abstract name: string
public type = 'extension'
protected init() {}
protected bindEditor(editor: Editor): void {
this.editor = editor
}
get update(): any {
return () => {}
}

View File

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