add enableInputRules and enablePasteRules option
This commit is contained in:
@@ -100,6 +100,33 @@ new Editor({
|
|||||||
| `false` | Disables autofocus. |
|
| `false` | Disables autofocus. |
|
||||||
| `null` | Disables autofocus. |
|
| `null` | Disables autofocus. |
|
||||||
|
|
||||||
|
### Enable input rules
|
||||||
|
By default, tiptap enables all [input rules](/guide/build-custom-extensions/#input-rules). With `enableInputRules` you can disable that.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Editor } from '@tiptap/core'
|
||||||
|
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||||
|
|
||||||
|
new Editor({
|
||||||
|
content: `<p>Example Text</p>`,
|
||||||
|
extensions: defaultExtensions(),
|
||||||
|
enableInputRules: false,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### Enable paste rules
|
||||||
|
By default, tiptap enables all [paste rules](/guide/build-custom-extensions/#paste-rules). With `enablePasteRules` you can disable that.
|
||||||
|
|
||||||
|
```js
|
||||||
|
import { Editor } from '@tiptap/core'
|
||||||
|
import { defaultExtensions } from '@tiptap/starter-kit'
|
||||||
|
|
||||||
|
new Editor({
|
||||||
|
content: `<p>Example Text</p>`,
|
||||||
|
extensions: defaultExtensions(),
|
||||||
|
enablePasteRules: false,
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
### Inject CSS
|
### Inject CSS
|
||||||
By default, tiptap injects [a little bit of CSS](https://github.com/ueberdosis/tiptap-next/tree/main/packages/core/src/style.ts). With `injectCSS` you can disable that.
|
By default, tiptap injects [a little bit of CSS](https://github.com/ueberdosis/tiptap-next/tree/main/packages/core/src/style.ts). With `injectCSS` you can disable that.
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ export class Editor extends EventEmitter {
|
|||||||
editable: true,
|
editable: true,
|
||||||
editorProps: {},
|
editorProps: {},
|
||||||
parseOptions: {},
|
parseOptions: {},
|
||||||
|
enableInputRules: true,
|
||||||
|
enablePasteRules: true,
|
||||||
onInit: () => null,
|
onInit: () => null,
|
||||||
onUpdate: () => null,
|
onUpdate: () => null,
|
||||||
onTransaction: () => null,
|
onTransaction: () => null,
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { Plugin } from 'prosemirror-state'
|
|
||||||
import { keymap } from 'prosemirror-keymap'
|
import { keymap } from 'prosemirror-keymap'
|
||||||
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
|
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
|
||||||
import { inputRules } from 'prosemirror-inputrules'
|
import { inputRules } from 'prosemirror-inputrules'
|
||||||
@@ -37,7 +36,7 @@ export default class ExtensionManager {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
get plugins(): Plugin[] {
|
get plugins() {
|
||||||
const plugins = this.extensions
|
const plugins = this.extensions
|
||||||
.map(extension => {
|
.map(extension => {
|
||||||
const context = {
|
const context = {
|
||||||
@@ -58,7 +57,11 @@ export default class ExtensionManager {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
get inputRules(): any {
|
get inputRules() {
|
||||||
|
if (!this.editor.options.enableInputRules) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
return this.extensions
|
return this.extensions
|
||||||
.map(extension => {
|
.map(extension => {
|
||||||
const context = {
|
const context = {
|
||||||
@@ -72,7 +75,11 @@ export default class ExtensionManager {
|
|||||||
.flat()
|
.flat()
|
||||||
}
|
}
|
||||||
|
|
||||||
get pasteRules(): any {
|
get pasteRules() {
|
||||||
|
if (!this.editor.options.enablePasteRules) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
return this.extensions
|
return this.extensions
|
||||||
.map(extension => {
|
.map(extension => {
|
||||||
const context = {
|
const context = {
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ export interface EditorOptions {
|
|||||||
editable: boolean,
|
editable: boolean,
|
||||||
editorProps: EditorProps,
|
editorProps: EditorProps,
|
||||||
parseOptions: ParseOptions,
|
parseOptions: ParseOptions,
|
||||||
|
enableInputRules: boolean,
|
||||||
|
enablePasteRules: boolean,
|
||||||
onInit: () => void,
|
onInit: () => void,
|
||||||
onUpdate: () => void,
|
onUpdate: () => void,
|
||||||
onTransaction: (props: { transaction: Transaction }) => void,
|
onTransaction: (props: { transaction: Transaction }) => void,
|
||||||
|
|||||||
Reference in New Issue
Block a user