add useBuiltInExtensions option
This commit is contained in:
@@ -63,11 +63,14 @@ export default {
|
||||
|
||||
## Editor Properties
|
||||
|
||||
useBuiltInExtensions
|
||||
|
||||
| **Property** | **Type** | **Default** | **Description** |
|
||||
| --- | :---: | :---: | --- |
|
||||
| `content` | `Object\|String` | `null` | The editor state object used by Prosemirror. You can also pass HTML to the `content` slot. When used both, the `content` slot will be ignored. |
|
||||
| `editable` | `Boolean` | `true` | When set to `false` the editor is read-only. |
|
||||
| `extensions` | `Array` | `[]` | A list of extensions used, by the editor. This can be `Nodes`, `Marks` or `Plugins`. |
|
||||
| `useBuiltInExtensions` | `Boolean` | `true` | By default tiptap adds a `Doc`, `Paragraph` and `Text` node to the Prosemirror schema. |
|
||||
| `onInit` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on init. |
|
||||
| `onFocus` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on focus. |
|
||||
| `onBlur` | `Function` | `undefined` | This will return an Object with the current `state` and `view` of Prosemirror on blur. |
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user