@contrail/documents 1.0.43 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { Document } from '../types/document';
2
2
  export interface ComponentDefinition {
3
- slug: string;
3
+ slug?: string;
4
4
  defaultTemplate: Document;
5
5
  }
6
6
  export declare const ITEM_VIEW_TEMPLATE: {
@@ -1,3 +1,4 @@
1
+ import { ComponentDefinition } from './components/components';
1
2
  import { DocumentElement } from './types/document-element';
2
3
  export declare class DocumentElementFactory {
3
4
  static initNewElement(type: string): DocumentElement;
@@ -7,4 +8,5 @@ export declare class DocumentElementFactory {
7
8
  static createImageElement(options: DocumentElement): DocumentElement;
8
9
  static createFrameElement(options: DocumentElement): DocumentElement;
9
10
  static createComponent(componentType: string, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
11
+ static createComponentFromComponentDefinition(componentDefinition: ComponentDefinition, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
10
12
  }
@@ -51,12 +51,15 @@ class DocumentElementFactory {
51
51
  return element;
52
52
  }
53
53
  static createComponent(componentType, model, modelBindings, options) {
54
+ const componentDefinition = components_1.ComponentRegistry.getComponentDefinition(componentType);
55
+ return this.createComponentFromComponentDefinition(componentDefinition, model, modelBindings, options);
56
+ }
57
+ static createComponentFromComponentDefinition(componentDefinition, model, modelBindings, options) {
54
58
  var _a;
55
59
  let element = this.initNewElement('component');
56
60
  if (options) {
57
61
  element = Object.assign(element, options);
58
62
  }
59
- const componentDefinition = components_1.ComponentRegistry.getComponentDefinition(componentType);
60
63
  const elements = JSON.parse(JSON.stringify(componentDefinition.defaultTemplate.elements));
61
64
  document_element_property_binding_handler_1.DocumentElementPropertyBindingHandler.bindPropertiesToElements(elements, model);
62
65
  element.elements = elements;
@@ -58,6 +58,6 @@ export interface CropDefinition {
58
58
  x2?: number;
59
59
  y1?: number;
60
60
  y2?: number;
61
- cWidth?: number;
62
- cHeight?: number;
61
+ width?: number;
62
+ height?: number;
63
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/documents",
3
- "version": "1.0.43",
3
+ "version": "1.0.45",
4
4
  "description": "Documents library for contrail platform",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",