check for protected command names
This commit is contained in:
@@ -11,6 +11,7 @@ import { gapCursor } from 'prosemirror-gapcursor'
|
||||
import magicMethods from './utils/magicMethods'
|
||||
import elementFromString from './utils/elementFromString'
|
||||
import injectCSS from './utils/injectCSS'
|
||||
import getAllMethodNames from './utils/getAllMethodNames'
|
||||
import ExtensionManager from './ExtensionManager'
|
||||
import Extension from './Extension'
|
||||
import Node from './Node'
|
||||
@@ -76,6 +77,10 @@ export class Editor extends EventEmitter {
|
||||
if (this.commands[name]) {
|
||||
throw new Error(`tiptap: command '${name}' is already defined.`)
|
||||
}
|
||||
|
||||
if (getAllMethodNames(this).includes(name)) {
|
||||
throw new Error(`tiptap: '${name}' is a protected name.`)
|
||||
}
|
||||
|
||||
this.commands[name] = this.chainCommand((...args: any) => {
|
||||
return new Promise(resolve => callback(resolve, this, ...args))
|
||||
|
||||
Reference in New Issue
Block a user