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

26 lines (21 loc) 711 B
import DefaultDOMElement from '../dom/DefaultDOMElement' import DOMImporter from './DOMImporter' export default class XMLImporter extends DOMImporter { constructor (params, doc, options = {}) { super(_defaultParams(params, options), doc, options) } importDocument (xml) { this.reset() const dom = DefaultDOMElement.parseXML(xml) this.convertDocument(dom) return this.state.doc } convertDocument (xmlDocument) { const rootNode = xmlDocument.children[0] if (!rootNode) throw new Error('XML Root node could not be found.') this.convertElement(rootNode) } } function _defaultParams (params, options) { return Object.assign({ idAttribute: 'id' }, params, options) }