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,29 +2,27 @@ 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,
...options, ...options,
} }
} }
editor!: Editor
options: { [key: string]: any } = {}
defaultOptions: { [key: string]: any } = {}
public abstract name: string
public type = 'extension'
init(): any { protected init() {}
return null
}
bindEditor(editor: Editor): void { protected bindEditor(editor: Editor): void {
this.editor = editor this.editor = editor
} }
public type = 'extension'
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()