diff --git a/README.md b/README.md index c2fbd9af..0c0ff427 100644 --- a/README.md +++ b/README.md @@ -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. | diff --git a/packages/tiptap/src/Editor.js b/packages/tiptap/src/Editor.js index ba4fcdbc..7a92a24e 100644 --- a/packages/tiptap/src/Editor.js +++ b/packages/tiptap/src/Editor.js @@ -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, diff --git a/packages/tiptap/src/Nodes/index.js b/packages/tiptap/src/Nodes/index.js index a921a807..13f1a452 100644 --- a/packages/tiptap/src/Nodes/index.js +++ b/packages/tiptap/src/Nodes/index.js @@ -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'