mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-30 21:25:27 +08:00
35 lines
759 B
TypeScript
35 lines
759 B
TypeScript
|
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,
|
||
|
}), {})
|
||
|
}
|
||
|
|
||
|
}
|