tiptap/packages/tiptap-core/src/ExtensionManager.ts

35 lines
759 B
TypeScript
Raw Normal View History

2020-03-06 04:05:01 +08:00
import { keymap } from 'prosemirror-keymap'
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
}
get nodes() {
return this.extensions
.filter(extension => extension.type === 'node')
.reduce((nodes, { name, schema }) => ({
...nodes,
[name]: schema,
}), {})
}
get marks() {
return this.extensions
.filter(extension => extension.type === 'mark')
.reduce((marks, { name, schema }) => ({
...marks,
[name]: schema,
}), {})
}
}