* Creates instances via passed or default configuration * * @returns {Promise }
()
| 106 | * @returns {Promise<void>} |
| 107 | */ |
| 108 | public async prepare(): Promise<void> { |
| 109 | this.validateTools(); |
| 110 | |
| 111 | /** |
| 112 | * Assign internal tools |
| 113 | */ |
| 114 | this.config.tools = _.deepMerge({}, this.internalTools, this.config.tools); |
| 115 | |
| 116 | if (!Object.prototype.hasOwnProperty.call(this.config, 'tools') || Object.keys(this.config.tools).length === 0) { |
| 117 | throw Error('Can\'t start without tools'); |
| 118 | } |
| 119 | |
| 120 | const config = this.prepareConfig(); |
| 121 | |
| 122 | this.factory = new ToolsFactory(config, this.config, this.Editor.API); |
| 123 | |
| 124 | /** |
| 125 | * getting classes that has prepare method |
| 126 | */ |
| 127 | const sequenceData = this.getListOfPrepareFunctions(config); |
| 128 | |
| 129 | /** |
| 130 | * if sequence data contains nothing then resolve current chain and run other module prepare |
| 131 | */ |
| 132 | if (sequenceData.length === 0) { |
| 133 | return Promise.resolve(); |
| 134 | } |
| 135 | |
| 136 | /** |
| 137 | * to see how it works {@link '../utils.ts#sequence'} |
| 138 | */ |
| 139 | await _.sequence(sequenceData, (data: { toolName: string }) => { |
| 140 | this.toolPrepareMethodSuccess(data); |
| 141 | }, (data: { toolName: string }) => { |
| 142 | this.toolPrepareMethodFallback(data); |
| 143 | }); |
| 144 | |
| 145 | this.prepareBlockTools(); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Return general Sanitizer config for all inline tools |
nothing calls this directly
no test coverage detected