constructor(el, config) { if (!(el instanceof HTMLElement)) throw new TypeError( 'The first argument to the SketchInput constructor must be an HTMLElement' ); this.el = el; if (config.initialstate) { this.initialState = deepCopy(config.initialstate); delete config.initialstate; } // Check if we are in debug mode this.debug = typeof config.debug === 'boolean' ? config.debug : false; // Load default config this.config = DEFAULT_CONFIG; // If in debug mode, validate config except plugins array entries that will be validated by each plugin // If we are not in debug mode or have a valid config, overwrite default keys/values if (!this.debug || validate(config, 'main')) { deepExtend(this.config, config); } // Otherwise use default values and add plugins array to the config else { this.config.plugins = deepExtend(config.plugins); console.log('The main config has errors, using default values instead'); } this.params = createInheritingObjectTree(this.config); this.messageBus = new EventEmitter(); this.oldTime = Date.now(); this.oldPt = { x: 0, y: 0 } Promise.all( this.params.plugins.map(pluginParams => System.import(`plugins/${pluginParams.name}`).then(module => module.default) ) ).then(plugins => this.init(plugins)); }
let tag = { type: 'object', properties: { value: {type: 'string'}, latex: {type: 'boolean'}, xoffset: {type: 'integer'}, yoffset: {type: 'integer'}, align: { type: 'string', enum: ['start', 'middle', 'end'] } }, additionalProperties: false }; let arrowTag = deepCopy(tag); arrowTag.properties.position = { type: 'string', enum: ['start', 'middle', 'end'] }; let dashStyle = { type: 'string', enum: ['dashed', 'longdashed', 'dotted', 'dashdotted', 'solid'] } let coords = { type: 'array', minItems: 2, maxItems: 2, items: [