throw error for missing mark/node type
This commit is contained in:
@@ -2,6 +2,10 @@ import { MarkType, Schema } from 'prosemirror-model'
|
||||
|
||||
export default function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType {
|
||||
if (typeof nameOrType === 'string') {
|
||||
if (!schema.marks[nameOrType]) {
|
||||
throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`)
|
||||
}
|
||||
|
||||
return schema.marks[nameOrType]
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,10 @@ import { NodeType, Schema } from 'prosemirror-model'
|
||||
|
||||
export default function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType {
|
||||
if (typeof nameOrType === 'string') {
|
||||
if (!schema.nodes[nameOrType]) {
|
||||
throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`)
|
||||
}
|
||||
|
||||
return schema.nodes[nameOrType]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user