UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).

16 lines (15 loc) 532 B
export default function getComponentForNode (comp, node) { const componentRegistry = comp.context.componentRegistry let ComponentClass = componentRegistry.get(node.type) if (!ComponentClass) { const superTypes = node.getSchema().getSuperTypes() for (const superType of superTypes) { ComponentClass = componentRegistry.get(superType) if (ComponentClass) break } } if (!ComponentClass) { throw new Error(`No Component class registered for model type ${node.type}.`) } return ComponentClass }