enable extensions init
This commit is contained in:
@@ -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 () => {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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()
|
||||||
|
|||||||
Reference in New Issue
Block a user