2020-03-06 04:05:01 +08:00
|
|
|
import { keymap } from 'prosemirror-keymap'
|
2020-03-06 04:35:30 +08:00
|
|
|
import collect from 'collect.js'
|
2020-03-06 04:05:01 +08:00
|
|
|
import { Editor } from './Editor'
|
|
|
|
|
|
|
|
export default class ExtensionManager {
|
|
|
|
|
|
|
|
extensions: [any?]
|
|
|
|
|
|
|
|
constructor(extensions: any = [], editor: Editor) {
|
|
|
|
// extensions.forEach(extension => {
|
|
|
|
// extension.bindEditor(editor)
|
|
|
|
// extension.init()
|
|
|
|
// })
|
|
|
|
this.extensions = extensions
|
|
|
|
}
|
|
|
|
|
2020-03-06 04:35:30 +08:00
|
|
|
get nodes(): any {
|
|
|
|
return collect(this.extensions)
|
|
|
|
.where('type', 'node')
|
|
|
|
.mapWithKeys((extension: any) => [extension.name, extension.schema])
|
|
|
|
.all()
|
2020-03-06 04:05:01 +08:00
|
|
|
}
|
|
|
|
|
2020-03-06 04:35:30 +08:00
|
|
|
get marks(): any {
|
|
|
|
return collect(this.extensions)
|
|
|
|
.where('type', 'mark')
|
|
|
|
.mapWithKeys((extension: any) => [extension.name, extension.schema])
|
|
|
|
.all()
|
2020-03-06 04:05:01 +08:00
|
|
|
}
|
|
|
|
|
2020-03-06 05:15:17 +08:00
|
|
|
get plugins(): any {
|
|
|
|
return collect(this.extensions)
|
|
|
|
.flatMap(extension => extension.plugins)
|
|
|
|
.toArray()
|
|
|
|
}
|
|
|
|
|
2020-03-06 04:05:01 +08:00
|
|
|
}
|