MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / add

Method add

packages/editor-skeleton/src/skeleton.ts:473–524  ·  view source on GitHub ↗
(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>)

Source from the content-addressed store, hash-verified

471 }
472
473 add(config: IPublicTypeSkeletonConfig, extraConfig?: Record<string, any>): IWidget | Widget | Panel | Stage | Dock | PanelDock | undefined {
474 const registeredTransducers = this.getRegisteredConfigTransducers();
475
476 const parsedConfig = registeredTransducers.reduce((prevConfig, current) => {
477 return current(prevConfig);
478 }, {
479 ...this.parseConfig(config),
480 ...extraConfig,
481 });
482
483 let { area } = parsedConfig;
484 if (!area) {
485 if (parsedConfig.type === 'Panel') {
486 area = 'leftFloatArea';
487 } else if (parsedConfig.type === 'Widget') {
488 area = 'mainArea';
489 } else {
490 area = 'leftArea';
491 }
492 }
493 switch (area) {
494 case 'leftArea':
495 case 'left':
496 return this.leftArea.add(parsedConfig as PanelDockConfig);
497 case 'rightArea':
498 case 'right':
499 return this.rightArea.add(parsedConfig as IPublicTypePanelConfig);
500 case 'topArea':
501 case 'top':
502 return this.topArea.add(parsedConfig as PanelDockConfig);
503 case 'subTopArea':
504 return this.subTopArea.add(parsedConfig as PanelDockConfig);
505 case 'toolbar':
506 return this.toolbar.add(parsedConfig as PanelDockConfig);
507 case 'mainArea':
508 case 'main':
509 case 'center':
510 case 'centerArea':
511 return this.mainArea.add(parsedConfig as IPublicTypePanelConfig);
512 case 'bottomArea':
513 case 'bottom':
514 return this.bottomArea.add(parsedConfig as IPublicTypePanelConfig);
515 case 'leftFixedArea':
516 return this.leftFixedArea.add(parsedConfig as IPublicTypePanelConfig);
517 case 'leftFloatArea':
518 return this.leftFloatArea.add(parsedConfig as IPublicTypePanelConfig);
519 case 'stages':
520 return this.stages.add(parsedConfig as StageConfig);
521 default:
522 // do nothing
523 }
524 }
525}

Callers 2

setupPluginsMethod · 0.95
createStageMethod · 0.95

Calls 4

parseConfigMethod · 0.95
reduceMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected