11import { BehaviorController } from './behaviors/behavior-controller' ;
2- import { ControlBar } from './control-bar/control-bar' ;
3- import { Dom } from './core/dom' ;
42import { ObjectCloner } from './core/object-cloner' ;
53import { SimpleEvent } from './core/simple-event' ;
64import { Definition } from './definition' ;
75import { DesignerConfiguration } from './designer-configuration' ;
86import { DesignerContext } from './designer-context' ;
9- import { SmartEditor } from './smart-editor/smart-editor' ;
10- import { Toolbox } from './toolbox/toolbox' ;
11- import { Workspace } from './workspace/workspace' ;
7+ import { DesignerView } from './designer-view' ;
128
139export default class Designer {
1410 public static create ( parent : HTMLElement , startDefinition : Definition , configuration : DesignerConfiguration ) : Designer {
15- const theme = configuration . theme || 'light' ;
1611 const definition = ObjectCloner . deepClone ( startDefinition ) ;
1712
18- const root = Dom . element ( 'div' , {
19- class : `sqd-designer sqd-theme-${ theme } `
20- } ) ;
21-
22- parent . appendChild ( root ) ;
23-
2413 const behaviorController = new BehaviorController ( ) ;
2514 const context = new DesignerContext ( definition , behaviorController , configuration ) ;
2615
27- const workspace = Workspace . create ( root , context ) ;
28- if ( ! configuration . toolbox . isHidden ) {
29- Toolbox . create ( root , context ) ;
30- }
31- ControlBar . create ( root , context ) ;
32- if ( ! configuration . editors . isHidden ) {
33- SmartEditor . create ( root , context ) ;
34- }
35-
36- const designer = new Designer ( root , context , workspace ) ;
16+ const view = DesignerView . create ( parent , context , configuration ) ;
17+ const designer = new Designer ( view , context ) ;
3718 context . onDefinitionChanged . subscribe ( ( ) => designer . onDefinitionChanged . forward ( context . definition ) ) ;
3819 return designer ;
3920 }
4021
41- private constructor (
42- private readonly root : HTMLElement ,
43- private readonly context : DesignerContext ,
44- private readonly workspace : Workspace
45- ) { }
22+ private constructor ( private readonly view : DesignerView , private readonly context : DesignerContext ) { }
4623
4724 public readonly onDefinitionChanged = new SimpleEvent < Definition > ( ) ;
4825
@@ -51,11 +28,11 @@ export default class Designer {
5128 }
5229
5330 public revalidate ( ) {
54- this . workspace . revalidate ( ) ;
31+ this . view . workspace . revalidate ( ) ;
5532 }
5633
5734 public isValid ( ) : boolean {
58- return this . workspace . isValid ;
35+ return this . view . workspace . isValid ;
5936 }
6037
6138 public isReadonly ( ) : boolean {
@@ -87,6 +64,6 @@ export default class Designer {
8764 }
8865
8966 public destroy ( ) {
90- this . root . parentElement ?. removeChild ( this . root ) ;
67+ this . view . destroy ( ) ;
9168 }
9269}
0 commit comments