add enableInputRules and enablePasteRules option

This commit is contained in:
Philipp Kühn
2020-11-20 21:30:12 +01:00
parent d7441deec9
commit feda283fcb
4 changed files with 42 additions and 4 deletions

View File

@@ -52,6 +52,8 @@ export class Editor extends EventEmitter {
editable: true,
editorProps: {},
parseOptions: {},
enableInputRules: true,
enablePasteRules: true,
onInit: () => null,
onUpdate: () => null,
onTransaction: () => null,

View File

@@ -1,4 +1,3 @@
import { Plugin } from 'prosemirror-state'
import { keymap } from 'prosemirror-keymap'
import { Schema, Node as ProsemirrorNode } from 'prosemirror-model'
import { inputRules } from 'prosemirror-inputrules'
@@ -37,7 +36,7 @@ export default class ExtensionManager {
})
}
get plugins(): Plugin[] {
get plugins() {
const plugins = this.extensions
.map(extension => {
const context = {
@@ -58,7 +57,11 @@ export default class ExtensionManager {
]
}
get inputRules(): any {
get inputRules() {
if (!this.editor.options.enableInputRules) {
return []
}
return this.extensions
.map(extension => {
const context = {
@@ -72,7 +75,11 @@ export default class ExtensionManager {
.flat()
}
get pasteRules(): any {
get pasteRules() {
if (!this.editor.options.enablePasteRules) {
return []
}
return this.extensions
.map(extension => {
const context = {

View File

@@ -23,6 +23,8 @@ export interface EditorOptions {
editable: boolean,
editorProps: EditorProps,
parseOptions: ParseOptions,
enableInputRules: boolean,
enablePasteRules: boolean,
onInit: () => void,
onUpdate: () => void,
onTransaction: (props: { transaction: Transaction }) => void,