all files / model/ DocumentNodeFactory.js

80% Statements 4/5
50% Branches 1/2
100% Functions 2/2
80% Lines 4/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17      725×       5206× 5206×     5206×          
class DocumentNodeFactory {
 
  constructor(doc) {
    this.doc = doc
  }
 
  create(nodeType, nodeData) {
    var NodeClass = this.doc.schema.getNodeClass(nodeType)
    Iif (!NodeClass) {
      throw new Error('No node registered by that name: ' + nodeType)
    }
    return new NodeClass(this.doc, nodeData)
  }
}
 
export default DocumentNodeFactory