add useBuiltInExtensions option

This commit is contained in:
Philipp Kühn
2018-11-22 21:56:19 +01:00
parent a743149bba
commit e478c1aeb1
3 changed files with 22 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ import { baseKeymap, selectParentNode } from 'prosemirror-commands'
import { inputRules, undoInputRule } from 'prosemirror-inputrules'
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
import { ExtensionManager, ComponentView } from './Utils'
import builtInNodes from './Nodes'
import { Doc, Paragraph, Text } from './Nodes'
export default class Editor {
@@ -46,6 +46,7 @@ export default class Editor {
type: 'paragraph',
}],
},
useBuiltInExtensions: true,
onInit: () => {},
onUpdate: () => {},
onFocus: () => {},
@@ -58,9 +59,21 @@ export default class Editor {
}
}
get builtInExtensions() {
if (!this.options.useBuiltInExtensions) {
return []
}
return [
new Doc(),
new Text(),
new Paragraph(),
]
}
createExtensions() {
return new ExtensionManager([
...builtInNodes,
...this.builtInExtensions,
...this.options.extensions,
])
}
@@ -179,7 +192,7 @@ export default class Editor {
nodeViews: this.initNodeViews({
parent: component,
extensions: [
...builtInNodes,
...this.builtInExtensions,
...this.options.extensions,
],
editable: this.options.editable,

View File

@@ -1,9 +1,3 @@
import Doc from './Doc'
import Paragraph from './Paragraph'
import Text from './Text'
export default [
new Doc(),
new Text(),
new Paragraph(),
]
export { default as Doc } from './Doc'
export { default as Paragraph } from './Paragraph'
export { default as Text } from './Text'