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 (22 loc) 543 B
import { $$ } from '../dom' import FontAwesomeIcon from './FontAwesomeIcon' export default class DefaultIconProvider { constructor (config) { this.config = config } renderIcon (name) { const spec = this._getIconDef(name) if (!spec) { return $$('span') } else { if (spec.fontawesome) { return $$(FontAwesomeIcon, { icon: spec.fontawesome }) } else { throw new Error('Unsupported icon spec') } } } _getIconDef (name) { return this.config._iconRegistry.get(name) } }