( container?: HTMLElement, options?: IPublicTypeEngineOptions, pluginPreference?: PluginPreference, )
| 216 | const pluginPromise = registryInnerPlugin(designer, editor, plugins); |
| 217 | |
| 218 | export async function init( |
| 219 | container?: HTMLElement, |
| 220 | options?: IPublicTypeEngineOptions, |
| 221 | pluginPreference?: PluginPreference, |
| 222 | ) { |
| 223 | await destroy(); |
| 224 | let engineOptions = null; |
| 225 | if (isPlainObject(container)) { |
| 226 | engineOptions = container; |
| 227 | engineContainer = document.createElement('div'); |
| 228 | engineContainer.id = 'engine'; |
| 229 | document.body.appendChild(engineContainer); |
| 230 | } else { |
| 231 | engineOptions = options; |
| 232 | engineContainer = container; |
| 233 | if (!container) { |
| 234 | engineContainer = document.createElement('div'); |
| 235 | engineContainer.id = 'engine'; |
| 236 | document.body.appendChild(engineContainer); |
| 237 | } |
| 238 | } |
| 239 | engineConfig.setEngineOptions(engineOptions as any); |
| 240 | |
| 241 | const { Workbench } = common.skeletonCabin; |
| 242 | if (options && options.enableWorkspaceMode) { |
| 243 | const disposeFun = await pluginPromise; |
| 244 | disposeFun && disposeFun(); |
| 245 | render( |
| 246 | createElement(WorkSpaceWorkbench, { |
| 247 | workspace: innerWorkspace, |
| 248 | // skeleton: workspace.skeleton, |
| 249 | className: 'engine-main', |
| 250 | topAreaItemClassName: 'engine-actionitem', |
| 251 | }), |
| 252 | engineContainer, |
| 253 | ); |
| 254 | innerWorkspace.enableAutoOpenFirstWindow = engineConfig.get('enableAutoOpenFirstWindow', true); |
| 255 | innerWorkspace.setActive(true); |
| 256 | innerWorkspace.initWindow(); |
| 257 | innerHotkey.activate(false); |
| 258 | await innerWorkspace.plugins.init(pluginPreference); |
| 259 | return; |
| 260 | } |
| 261 | |
| 262 | await plugins.init(pluginPreference as any); |
| 263 | |
| 264 | render( |
| 265 | createElement(Workbench, { |
| 266 | skeleton: innerSkeleton, |
| 267 | className: 'engine-main', |
| 268 | topAreaItemClassName: 'engine-actionitem', |
| 269 | }), |
| 270 | engineContainer, |
| 271 | ); |
| 272 | } |
| 273 | |
| 274 | export async function destroy() { |
| 275 | // remove all documents |
nothing calls this directly
no test coverage detected
searching dependent graphs…