@contrail/documents 1.0.107 → 1.0.109
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.
- package/README.md +1 -1
- package/lib/components/components.d.ts +448 -448
- package/lib/components/components.js +143 -143
- package/lib/components/index.d.ts +1 -1
- package/lib/components/index.js +17 -17
- package/lib/document-action.d.ts +25 -7
- package/lib/document-action.js +14 -10
- package/lib/document-element-component-size-handler.d.ts +4 -4
- package/lib/document-element-component-size-handler.js +55 -55
- package/lib/document-element-factory.d.ts +18 -12
- package/lib/document-element-factory.js +171 -77
- package/lib/document-element-property-binding-handler.d.ts +6 -6
- package/lib/document-element-property-binding-handler.js +71 -71
- package/lib/index.d.ts +8 -8
- package/lib/index.js +24 -24
- package/lib/types/common.d.ts +84 -84
- package/lib/types/common.js +8 -8
- package/lib/types/data-object.d.ts +6 -6
- package/lib/types/data-object.js +2 -2
- package/lib/types/document-change.d.ts +17 -17
- package/lib/types/document-change.js +12 -12
- package/lib/types/document-element-event.d.ts +24 -24
- package/lib/types/document-element-event.js +2 -2
- package/lib/types/document-element-holder.d.ts +8 -8
- package/lib/types/document-element-holder.js +2 -2
- package/lib/types/document-element.d.ts +48 -46
- package/lib/types/document-element.js +2 -2
- package/lib/types/document-navigation-event.d.ts +5 -5
- package/lib/types/document-navigation-event.js +2 -2
- package/lib/types/document.d.ts +24 -24
- package/lib/types/document.js +2 -2
- package/lib/types/element-transformation.d.ts +18 -18
- package/lib/types/element-transformation.js +2 -2
- package/lib/types/index.d.ts +9 -9
- package/lib/types/index.js +25 -25
- package/lib/util/dynamic-text/dynamic-text-util.d.ts +14 -14
- package/lib/util/dynamic-text/dynamic-text-util.js +58 -58
- package/lib/util/measure-text/measure-text.d.ts +5 -5
- package/lib/util/measure-text/measure-text.js +53 -53
- package/lib/util/measure-text/widths-map.d.ts +1651 -1651
- package/lib/util/measure-text/widths-map.js +1654 -1654
- package/package.json +47 -46
|
@@ -1,143 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ComponentRegistry = exports.ITEM_VIEW_V3 = exports.ITEM_VIEW_V2 = exports.ITEM_VIEW = exports.ITEM_VIEW_TEMPLATE_V3 = exports.ITEM_VIEW_TEMPLATE_V2 = exports.ITEM_VIEW_TEMPLATE = void 0;
|
|
4
|
-
const types_1 = require("../types");
|
|
5
|
-
exports.ITEM_VIEW_TEMPLATE = {
|
|
6
|
-
elements: [
|
|
7
|
-
{
|
|
8
|
-
type: 'image',
|
|
9
|
-
size: { width: 125, height: 125 },
|
|
10
|
-
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
11
|
-
propertyBindings: { url: 'thumbnail.downloadUrl' },
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
type: 'text',
|
|
15
|
-
position: { x: 0, y: 126 },
|
|
16
|
-
size: { height: 25, width: 125 },
|
|
17
|
-
style: {
|
|
18
|
-
font: {
|
|
19
|
-
size: 8,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
propertyBindings: { text: 'item.name' },
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
type: 'text',
|
|
26
|
-
position: { x: 0, y: 151 },
|
|
27
|
-
size: { height: 25, width: 125 },
|
|
28
|
-
style: {
|
|
29
|
-
font: {
|
|
30
|
-
size: 8,
|
|
31
|
-
},
|
|
32
|
-
color: 'rgba(0,0,0,.5)',
|
|
33
|
-
},
|
|
34
|
-
propertyBindings: { text: 'item.optionName' },
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
};
|
|
38
|
-
exports.ITEM_VIEW_TEMPLATE_V2 = {
|
|
39
|
-
elements: [
|
|
40
|
-
{
|
|
41
|
-
type: 'image',
|
|
42
|
-
size: { width: 125, height: 125 },
|
|
43
|
-
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
44
|
-
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
type: 'text',
|
|
48
|
-
position: { x: 0, y: 126 },
|
|
49
|
-
size: { height: 25, width: 125 },
|
|
50
|
-
style: {
|
|
51
|
-
font: {
|
|
52
|
-
size: 8,
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
propertyBindings: { text: 'item.name' },
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
type: 'text',
|
|
59
|
-
position: { x: 0, y: 151 },
|
|
60
|
-
size: { height: 25, width: 125 },
|
|
61
|
-
style: {
|
|
62
|
-
font: {
|
|
63
|
-
size: 8,
|
|
64
|
-
},
|
|
65
|
-
color: 'rgba(0,0,0,.5)',
|
|
66
|
-
},
|
|
67
|
-
propertyBindings: { text: 'item.optionName' },
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
};
|
|
71
|
-
exports.ITEM_VIEW_TEMPLATE_V3 = {
|
|
72
|
-
elements: [
|
|
73
|
-
{
|
|
74
|
-
type: 'image',
|
|
75
|
-
size: { width: 125, height: 125 },
|
|
76
|
-
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
77
|
-
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: 'text',
|
|
81
|
-
position: { x: 0, y: 126 },
|
|
82
|
-
size: { height: 25, width: 125 },
|
|
83
|
-
style: {
|
|
84
|
-
font: {
|
|
85
|
-
size: 8,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
propertyBindings: { text: 'item.name' },
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
type: 'text',
|
|
92
|
-
position: { x: 0, y: 151 },
|
|
93
|
-
size: { height: 25, width: 125 },
|
|
94
|
-
style: {
|
|
95
|
-
font: {
|
|
96
|
-
size: 8,
|
|
97
|
-
},
|
|
98
|
-
color: 'rgba(0,0,0,.5)',
|
|
99
|
-
},
|
|
100
|
-
propertyBindings: { text: 'item.optionName' },
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
type: 'text',
|
|
104
|
-
position: { x: 0, y: 176 },
|
|
105
|
-
size: { height: 25, width: 125 },
|
|
106
|
-
style: {
|
|
107
|
-
font: {
|
|
108
|
-
size: 8,
|
|
109
|
-
},
|
|
110
|
-
color: 'rgba(0,0,0,.5)',
|
|
111
|
-
},
|
|
112
|
-
label: 'Item Type',
|
|
113
|
-
propertyBindings: { text: 'item.type.label' },
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
};
|
|
117
|
-
exports.ITEM_VIEW = {
|
|
118
|
-
slug: 'item-view',
|
|
119
|
-
defaultTemplate: exports.ITEM_VIEW_TEMPLATE,
|
|
120
|
-
};
|
|
121
|
-
exports.ITEM_VIEW_V2 = {
|
|
122
|
-
slug: 'item-view-v2',
|
|
123
|
-
defaultTemplate: exports.ITEM_VIEW_TEMPLATE_V2,
|
|
124
|
-
};
|
|
125
|
-
exports.ITEM_VIEW_V3 = {
|
|
126
|
-
slug: 'item-view-v3',
|
|
127
|
-
defaultTemplate: exports.ITEM_VIEW_TEMPLATE_V3,
|
|
128
|
-
};
|
|
129
|
-
class ComponentRegistry {
|
|
130
|
-
static getComponentDefinition(slug) {
|
|
131
|
-
if (!this.componentDefinitionMap) {
|
|
132
|
-
this.initMap();
|
|
133
|
-
}
|
|
134
|
-
return this.componentDefinitionMap.get(slug);
|
|
135
|
-
}
|
|
136
|
-
static initMap() {
|
|
137
|
-
this.componentDefinitionMap = new Map();
|
|
138
|
-
this.componentDefinitionMap.set('item-view', exports.ITEM_VIEW);
|
|
139
|
-
this.componentDefinitionMap.set('item-view-v2', exports.ITEM_VIEW_V2);
|
|
140
|
-
this.componentDefinitionMap.set('item-view-v3', exports.ITEM_VIEW_V3);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
exports.ComponentRegistry = ComponentRegistry;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ComponentRegistry = exports.ITEM_VIEW_V3 = exports.ITEM_VIEW_V2 = exports.ITEM_VIEW = exports.ITEM_VIEW_TEMPLATE_V3 = exports.ITEM_VIEW_TEMPLATE_V2 = exports.ITEM_VIEW_TEMPLATE = void 0;
|
|
4
|
+
const types_1 = require("../types");
|
|
5
|
+
exports.ITEM_VIEW_TEMPLATE = {
|
|
6
|
+
elements: [
|
|
7
|
+
{
|
|
8
|
+
type: 'image',
|
|
9
|
+
size: { width: 125, height: 125 },
|
|
10
|
+
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
11
|
+
propertyBindings: { url: 'thumbnail.downloadUrl' },
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'text',
|
|
15
|
+
position: { x: 0, y: 126 },
|
|
16
|
+
size: { height: 25, width: 125 },
|
|
17
|
+
style: {
|
|
18
|
+
font: {
|
|
19
|
+
size: 8,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
propertyBindings: { text: 'item.name' },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'text',
|
|
26
|
+
position: { x: 0, y: 151 },
|
|
27
|
+
size: { height: 25, width: 125 },
|
|
28
|
+
style: {
|
|
29
|
+
font: {
|
|
30
|
+
size: 8,
|
|
31
|
+
},
|
|
32
|
+
color: 'rgba(0,0,0,.5)',
|
|
33
|
+
},
|
|
34
|
+
propertyBindings: { text: 'item.optionName' },
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
};
|
|
38
|
+
exports.ITEM_VIEW_TEMPLATE_V2 = {
|
|
39
|
+
elements: [
|
|
40
|
+
{
|
|
41
|
+
type: 'image',
|
|
42
|
+
size: { width: 125, height: 125 },
|
|
43
|
+
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
44
|
+
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'text',
|
|
48
|
+
position: { x: 0, y: 126 },
|
|
49
|
+
size: { height: 25, width: 125 },
|
|
50
|
+
style: {
|
|
51
|
+
font: {
|
|
52
|
+
size: 8,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
propertyBindings: { text: 'item.name' },
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'text',
|
|
59
|
+
position: { x: 0, y: 151 },
|
|
60
|
+
size: { height: 25, width: 125 },
|
|
61
|
+
style: {
|
|
62
|
+
font: {
|
|
63
|
+
size: 8,
|
|
64
|
+
},
|
|
65
|
+
color: 'rgba(0,0,0,.5)',
|
|
66
|
+
},
|
|
67
|
+
propertyBindings: { text: 'item.optionName' },
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
};
|
|
71
|
+
exports.ITEM_VIEW_TEMPLATE_V3 = {
|
|
72
|
+
elements: [
|
|
73
|
+
{
|
|
74
|
+
type: 'image',
|
|
75
|
+
size: { width: 125, height: 125 },
|
|
76
|
+
style: { background: { size: types_1.BackgroundSizeType.CONTAIN } },
|
|
77
|
+
propertyBindings: { url: 'viewable.mediumViewableDownloadUrl' },
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: 'text',
|
|
81
|
+
position: { x: 0, y: 126 },
|
|
82
|
+
size: { height: 25, width: 125 },
|
|
83
|
+
style: {
|
|
84
|
+
font: {
|
|
85
|
+
size: 8,
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
propertyBindings: { text: 'item.name' },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: 'text',
|
|
92
|
+
position: { x: 0, y: 151 },
|
|
93
|
+
size: { height: 25, width: 125 },
|
|
94
|
+
style: {
|
|
95
|
+
font: {
|
|
96
|
+
size: 8,
|
|
97
|
+
},
|
|
98
|
+
color: 'rgba(0,0,0,.5)',
|
|
99
|
+
},
|
|
100
|
+
propertyBindings: { text: 'item.optionName' },
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'text',
|
|
104
|
+
position: { x: 0, y: 176 },
|
|
105
|
+
size: { height: 25, width: 125 },
|
|
106
|
+
style: {
|
|
107
|
+
font: {
|
|
108
|
+
size: 8,
|
|
109
|
+
},
|
|
110
|
+
color: 'rgba(0,0,0,.5)',
|
|
111
|
+
},
|
|
112
|
+
label: 'Item Type',
|
|
113
|
+
propertyBindings: { text: 'item.type.label' },
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
};
|
|
117
|
+
exports.ITEM_VIEW = {
|
|
118
|
+
slug: 'item-view',
|
|
119
|
+
defaultTemplate: exports.ITEM_VIEW_TEMPLATE,
|
|
120
|
+
};
|
|
121
|
+
exports.ITEM_VIEW_V2 = {
|
|
122
|
+
slug: 'item-view-v2',
|
|
123
|
+
defaultTemplate: exports.ITEM_VIEW_TEMPLATE_V2,
|
|
124
|
+
};
|
|
125
|
+
exports.ITEM_VIEW_V3 = {
|
|
126
|
+
slug: 'item-view-v3',
|
|
127
|
+
defaultTemplate: exports.ITEM_VIEW_TEMPLATE_V3,
|
|
128
|
+
};
|
|
129
|
+
class ComponentRegistry {
|
|
130
|
+
static getComponentDefinition(slug) {
|
|
131
|
+
if (!this.componentDefinitionMap) {
|
|
132
|
+
this.initMap();
|
|
133
|
+
}
|
|
134
|
+
return this.componentDefinitionMap.get(slug);
|
|
135
|
+
}
|
|
136
|
+
static initMap() {
|
|
137
|
+
this.componentDefinitionMap = new Map();
|
|
138
|
+
this.componentDefinitionMap.set('item-view', exports.ITEM_VIEW);
|
|
139
|
+
this.componentDefinitionMap.set('item-view-v2', exports.ITEM_VIEW_V2);
|
|
140
|
+
this.componentDefinitionMap.set('item-view-v3', exports.ITEM_VIEW_V3);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.ComponentRegistry = ComponentRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './components';
|
|
1
|
+
export * from './components';
|
package/lib/components/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./components"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./components"), exports);
|
package/lib/document-action.d.ts
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
-
import { Action } from '@contrail/actions';
|
|
2
|
-
import { DocumentChange } from './types';
|
|
3
|
-
export declare class DocumentAction extends Action {
|
|
4
|
-
changeDefinition: DocumentChange;
|
|
5
|
-
undoChangeDefinition: DocumentChange;
|
|
6
|
-
constructor(change: any, undoChange?: any);
|
|
7
|
-
}
|
|
1
|
+
import { Action } from '@contrail/actions';
|
|
2
|
+
import { DocumentChange, DocumentElement } from './types';
|
|
3
|
+
export declare class DocumentAction extends Action {
|
|
4
|
+
changeDefinition: DocumentChange;
|
|
5
|
+
undoChangeDefinition: DocumentChange;
|
|
6
|
+
constructor(change: any, undoChange?: any);
|
|
7
|
+
}
|
|
8
|
+
export interface DocumentElementChanges {
|
|
9
|
+
elementsToUpdate?: Array<{
|
|
10
|
+
change: DocumentElement;
|
|
11
|
+
undo: DocumentElement;
|
|
12
|
+
}>;
|
|
13
|
+
elementsToCreate?: DocumentElement[];
|
|
14
|
+
elementsToDelete?: DocumentElement[];
|
|
15
|
+
}
|
|
16
|
+
export declare function uniqueElementsToUpdate(elementsToUpdate: Array<{
|
|
17
|
+
change: DocumentElement;
|
|
18
|
+
undo: DocumentElement;
|
|
19
|
+
}>, mainElementsToUpdate: Array<{
|
|
20
|
+
change: DocumentElement;
|
|
21
|
+
undo: DocumentElement;
|
|
22
|
+
}>): {
|
|
23
|
+
change: DocumentElement;
|
|
24
|
+
undo: DocumentElement;
|
|
25
|
+
}[];
|
package/lib/document-action.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentAction = void 0;
|
|
4
|
-
const actions_1 = require("@contrail/actions");
|
|
5
|
-
class DocumentAction extends actions_1.Action {
|
|
6
|
-
constructor(change, undoChange = null) {
|
|
7
|
-
super('document', change, undoChange);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.DocumentAction = DocumentAction;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.uniqueElementsToUpdate = exports.DocumentAction = void 0;
|
|
4
|
+
const actions_1 = require("@contrail/actions");
|
|
5
|
+
class DocumentAction extends actions_1.Action {
|
|
6
|
+
constructor(change, undoChange = null) {
|
|
7
|
+
super('document', change, undoChange);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.DocumentAction = DocumentAction;
|
|
11
|
+
function uniqueElementsToUpdate(elementsToUpdate, mainElementsToUpdate) {
|
|
12
|
+
return elementsToUpdate.filter(({ change }) => mainElementsToUpdate.findIndex((elementToUpdate) => elementToUpdate.change.id === change.id) === -1);
|
|
13
|
+
}
|
|
14
|
+
exports.uniqueElementsToUpdate = uniqueElementsToUpdate;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare class DocumentElementComponentSizeHandler {
|
|
2
|
-
static updateSizeAndPositionForPropertyElements(propertyElements: any[]): any;
|
|
3
|
-
private static getYMargin;
|
|
4
|
-
}
|
|
1
|
+
export declare class DocumentElementComponentSizeHandler {
|
|
2
|
+
static updateSizeAndPositionForPropertyElements(propertyElements: any[]): any;
|
|
3
|
+
private static getYMargin;
|
|
4
|
+
}
|
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DocumentElementComponentSizeHandler = void 0;
|
|
4
|
-
class DocumentElementComponentSizeHandler {
|
|
5
|
-
static updateSizeAndPositionForPropertyElements(propertyElements) {
|
|
6
|
-
const newElements = [];
|
|
7
|
-
let lastYPosition = 0;
|
|
8
|
-
let width = 200;
|
|
9
|
-
const imageElements = propertyElements.filter((element) => {
|
|
10
|
-
return element.type === 'image';
|
|
11
|
-
});
|
|
12
|
-
if (imageElements.length > 0) {
|
|
13
|
-
width = imageElements[0].size.width;
|
|
14
|
-
}
|
|
15
|
-
propertyElements.forEach((element) => {
|
|
16
|
-
var _a;
|
|
17
|
-
if (element.enabled === false) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
element.position = {
|
|
21
|
-
x: 0,
|
|
22
|
-
y: lastYPosition,
|
|
23
|
-
};
|
|
24
|
-
lastYPosition = lastYPosition + this.getYMargin(element);
|
|
25
|
-
if (element.type === 'text') {
|
|
26
|
-
if (!((_a = element.style) === null || _a === void 0 ? void 0 : _a.font)) {
|
|
27
|
-
element.style = Object.assign(Object.assign({}, element.style), { font: { size: 8 } });
|
|
28
|
-
}
|
|
29
|
-
if (!(element === null || element === void 0 ? void 0 : element.size)) {
|
|
30
|
-
element.size = {};
|
|
31
|
-
}
|
|
32
|
-
element.size.height = element.style.font.size + 6;
|
|
33
|
-
}
|
|
34
|
-
element.size.width = width;
|
|
35
|
-
newElements.push(element);
|
|
36
|
-
});
|
|
37
|
-
return newElements;
|
|
38
|
-
}
|
|
39
|
-
static getYMargin(element) {
|
|
40
|
-
let marginY = 11;
|
|
41
|
-
if (element.type === 'image') {
|
|
42
|
-
marginY = element.size.height;
|
|
43
|
-
}
|
|
44
|
-
else if (element.type === 'text') {
|
|
45
|
-
if (element.size && element.size.height) {
|
|
46
|
-
marginY = element.size.height;
|
|
47
|
-
}
|
|
48
|
-
else if (element.style && element.style.font) {
|
|
49
|
-
marginY = element.style.font.size + 6;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return marginY;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
exports.DocumentElementComponentSizeHandler = DocumentElementComponentSizeHandler;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentElementComponentSizeHandler = void 0;
|
|
4
|
+
class DocumentElementComponentSizeHandler {
|
|
5
|
+
static updateSizeAndPositionForPropertyElements(propertyElements) {
|
|
6
|
+
const newElements = [];
|
|
7
|
+
let lastYPosition = 0;
|
|
8
|
+
let width = 200;
|
|
9
|
+
const imageElements = propertyElements.filter((element) => {
|
|
10
|
+
return element.type === 'image';
|
|
11
|
+
});
|
|
12
|
+
if (imageElements.length > 0) {
|
|
13
|
+
width = imageElements[0].size.width;
|
|
14
|
+
}
|
|
15
|
+
propertyElements.forEach((element) => {
|
|
16
|
+
var _a;
|
|
17
|
+
if (element.enabled === false) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
element.position = {
|
|
21
|
+
x: 0,
|
|
22
|
+
y: lastYPosition,
|
|
23
|
+
};
|
|
24
|
+
lastYPosition = lastYPosition + this.getYMargin(element);
|
|
25
|
+
if (element.type === 'text') {
|
|
26
|
+
if (!((_a = element.style) === null || _a === void 0 ? void 0 : _a.font)) {
|
|
27
|
+
element.style = Object.assign(Object.assign({}, element.style), { font: { size: 8 } });
|
|
28
|
+
}
|
|
29
|
+
if (!(element === null || element === void 0 ? void 0 : element.size)) {
|
|
30
|
+
element.size = {};
|
|
31
|
+
}
|
|
32
|
+
element.size.height = element.style.font.size + 6;
|
|
33
|
+
}
|
|
34
|
+
element.size.width = width;
|
|
35
|
+
newElements.push(element);
|
|
36
|
+
});
|
|
37
|
+
return newElements;
|
|
38
|
+
}
|
|
39
|
+
static getYMargin(element) {
|
|
40
|
+
let marginY = 11;
|
|
41
|
+
if (element.type === 'image') {
|
|
42
|
+
marginY = element.size.height;
|
|
43
|
+
}
|
|
44
|
+
else if (element.type === 'text') {
|
|
45
|
+
if (element.size && element.size.height) {
|
|
46
|
+
marginY = element.size.height;
|
|
47
|
+
}
|
|
48
|
+
else if (element.style && element.style.font) {
|
|
49
|
+
marginY = element.style.font.size + 6;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return marginY;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.DocumentElementComponentSizeHandler = DocumentElementComponentSizeHandler;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import { ComponentDefinition } from './components/components';
|
|
2
|
-
import { DocumentElement } from './types/document-element';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
static
|
|
6
|
-
static
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static
|
|
11
|
-
static
|
|
12
|
-
|
|
1
|
+
import { ComponentDefinition } from './components/components';
|
|
2
|
+
import { DocumentElement } from './types/document-element';
|
|
3
|
+
import { PositionDefinition } from './types';
|
|
4
|
+
export declare class DocumentElementFactory {
|
|
5
|
+
static initNewElement(type: string): DocumentElement;
|
|
6
|
+
static createTextElement(text: string, options?: DocumentElement): DocumentElement;
|
|
7
|
+
static createShapeElement(type: string, options?: DocumentElement): DocumentElement;
|
|
8
|
+
static createElement(type: string, options?: DocumentElement): DocumentElement;
|
|
9
|
+
static createImageElement(options: DocumentElement): DocumentElement;
|
|
10
|
+
static createFrameElement(options: DocumentElement): DocumentElement;
|
|
11
|
+
static createComponent(componentType: string, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
|
|
12
|
+
static createComponentFromComponentDefinition(componentDefinition: ComponentDefinition, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
|
|
13
|
+
static copyElements(elements: DocumentElement[], commonOptions?: DocumentElement, documentId?: string, positionOffset?: PositionDefinition, lastFrameNumber?: number): {
|
|
14
|
+
oldIdToNewId: Map<string, string>;
|
|
15
|
+
newElements: DocumentElement[];
|
|
16
|
+
};
|
|
17
|
+
static isMask(element: DocumentElement): boolean;
|
|
18
|
+
}
|