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

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