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 systems.

18 lines (13 loc) 350 B
class DocumentNodeFactory { constructor(doc) { this.doc = doc } create(nodeType, nodeData) { var NodeClass = this.doc.schema.getNodeClass(nodeType) if (!NodeClass) { throw new Error('No node registered by that name: ' + nodeType) } return new NodeClass(this.doc, nodeData) } } export default DocumentNodeFactory