add useBuiltInExtensions option
This commit is contained in:
@@ -63,11 +63,14 @@ export default {
|
|||||||
|
|
||||||
## Editor Properties
|
## Editor Properties
|
||||||
|
|
||||||
|
useBuiltInExtensions
|
||||||
|
|
||||||
| **Property** | **Type** | **Default** | **Description** |
|
| **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. |
|
| `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. |
|
| `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`. |
|
| `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. |
|
| `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. |
|
| `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. |
|
| `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 { inputRules, undoInputRule } from 'prosemirror-inputrules'
|
||||||
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
|
import { markIsActive, nodeIsActive, getMarkAttrs } from 'tiptap-utils'
|
||||||
import { ExtensionManager, ComponentView } from './Utils'
|
import { ExtensionManager, ComponentView } from './Utils'
|
||||||
import builtInNodes from './Nodes'
|
import { Doc, Paragraph, Text } from './Nodes'
|
||||||
|
|
||||||
export default class Editor {
|
export default class Editor {
|
||||||
|
|
||||||
@@ -46,6 +46,7 @@ export default class Editor {
|
|||||||
type: 'paragraph',
|
type: 'paragraph',
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
|
useBuiltInExtensions: true,
|
||||||
onInit: () => {},
|
onInit: () => {},
|
||||||
onUpdate: () => {},
|
onUpdate: () => {},
|
||||||
onFocus: () => {},
|
onFocus: () => {},
|
||||||
@@ -58,9 +59,21 @@ export default class Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get builtInExtensions() {
|
||||||
|
if (!this.options.useBuiltInExtensions) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
new Doc(),
|
||||||
|
new Text(),
|
||||||
|
new Paragraph(),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
createExtensions() {
|
createExtensions() {
|
||||||
return new ExtensionManager([
|
return new ExtensionManager([
|
||||||
...builtInNodes,
|
...this.builtInExtensions,
|
||||||
...this.options.extensions,
|
...this.options.extensions,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
@@ -179,7 +192,7 @@ export default class Editor {
|
|||||||
nodeViews: this.initNodeViews({
|
nodeViews: this.initNodeViews({
|
||||||
parent: component,
|
parent: component,
|
||||||
extensions: [
|
extensions: [
|
||||||
...builtInNodes,
|
...this.builtInExtensions,
|
||||||
...this.options.extensions,
|
...this.options.extensions,
|
||||||
],
|
],
|
||||||
editable: this.options.editable,
|
editable: this.options.editable,
|
||||||
|
|||||||
@@ -1,9 +1,3 @@
|
|||||||
import Doc from './Doc'
|
export { default as Doc } from './Doc'
|
||||||
import Paragraph from './Paragraph'
|
export { default as Paragraph } from './Paragraph'
|
||||||
import Text from './Text'
|
export { default as Text } from './Text'
|
||||||
|
|
||||||
export default [
|
|
||||||
new Doc(),
|
|
||||||
new Text(),
|
|
||||||
new Paragraph(),
|
|
||||||
]
|
|
||||||
|
|||||||
Reference in New Issue
Block a user