@contrail/documents 1.0.110 → 1.0.112
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.
|
@@ -10,7 +10,7 @@ export declare class DocumentElementFactory {
|
|
|
10
10
|
static createFrameElement(options: DocumentElement): DocumentElement;
|
|
11
11
|
static createComponent(componentType: string, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
|
|
12
12
|
static createComponentFromComponentDefinition(componentDefinition: ComponentDefinition, model: any, modelBindings: any, options?: DocumentElement): DocumentElement;
|
|
13
|
-
static copyElements(elements: DocumentElement[],
|
|
13
|
+
static copyElements(elements: DocumentElement[], documentId?: string, commonOptions?: DocumentElement, positionOffset?: PositionDefinition, lastFrameNumber?: number): {
|
|
14
14
|
oldIdToNewId: Map<string, string>;
|
|
15
15
|
newElements: DocumentElement[];
|
|
16
16
|
};
|
|
@@ -35,7 +35,7 @@ class DocumentElementFactory {
|
|
|
35
35
|
let element = this.initNewElement(type);
|
|
36
36
|
element = Object.assign(element, options);
|
|
37
37
|
if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
38
|
-
element.elements = element.elements.map(e => {
|
|
38
|
+
element.elements = element.elements.map((e) => {
|
|
39
39
|
e.id = (0, nanoid_1.nanoid)(16);
|
|
40
40
|
return e;
|
|
41
41
|
});
|
|
@@ -68,14 +68,14 @@ class DocumentElementFactory {
|
|
|
68
68
|
element.elements = elements;
|
|
69
69
|
element.modelBindings = modelBindings;
|
|
70
70
|
if (((_a = element === null || element === void 0 ? void 0 : element.elements) === null || _a === void 0 ? void 0 : _a.length) > 0) {
|
|
71
|
-
element.elements = element.elements.map(e => {
|
|
71
|
+
element.elements = element.elements.map((e) => {
|
|
72
72
|
e.id = (0, nanoid_1.nanoid)(16);
|
|
73
73
|
return e;
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
return element;
|
|
77
77
|
}
|
|
78
|
-
static copyElements(elements, commonOptions = {},
|
|
78
|
+
static copyElements(elements, documentId, commonOptions = {}, positionOffset, lastFrameNumber) {
|
|
79
79
|
var _a;
|
|
80
80
|
const oldIdToNewId = new Map();
|
|
81
81
|
const newElements = [];
|
|
@@ -98,17 +98,20 @@ class DocumentElementFactory {
|
|
|
98
98
|
delete e.specifiedId;
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
const newInnerElements = [];
|
|
102
102
|
if (newElement.type === 'table') {
|
|
103
|
-
const oldChildElements = elements.filter(e => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const oldChildElements = elements.filter((e) => e.tableId === element.id && ['cell', 'column', 'row'].indexOf(e.type) !== -1);
|
|
104
|
+
let newTableElement, newChildElements = [];
|
|
105
|
+
try {
|
|
106
|
+
[newTableElement, ...newChildElements] = document_table_1.TableCopyService.copy(newElement, oldChildElements);
|
|
107
|
+
}
|
|
108
|
+
catch (e) { }
|
|
109
|
+
if (oldChildElements.length !== newChildElements.length || oldChildElements.length === 0) {
|
|
106
110
|
console.log(`Invalid table element to copy`, newElement, oldChildElements, newChildElements);
|
|
107
111
|
continue;
|
|
108
112
|
}
|
|
109
113
|
newElement = newTableElement;
|
|
110
|
-
|
|
111
|
-
newChildElements.forEach(newChildElement => {
|
|
114
|
+
newChildElements.forEach((newChildElement) => {
|
|
112
115
|
var _a;
|
|
113
116
|
let oldChildId;
|
|
114
117
|
if (newChildElement.type === 'row') {
|
|
@@ -120,13 +123,13 @@ class DocumentElementFactory {
|
|
|
120
123
|
else if (newChildElement.type === 'cell') {
|
|
121
124
|
const oldRowId = element.rowIds[newTableElement.rowIds.indexOf(newChildElement.rowId)];
|
|
122
125
|
const oldColumnId = element.columnIds[newTableElement.columnIds.indexOf(newChildElement.columnId)];
|
|
123
|
-
oldChildId = (_a = elements.find(e => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
|
|
126
|
+
oldChildId = (_a = elements.find((e) => e.type === 'cell' && e.rowId === oldRowId && e.columnId === oldColumnId)) === null || _a === void 0 ? void 0 : _a.id;
|
|
124
127
|
}
|
|
125
128
|
if (oldChildId) {
|
|
126
129
|
newChildElement.documentId = documentId;
|
|
127
130
|
newChildElement.specifiedId = newChildElement.id;
|
|
128
|
-
oldIdToNewId
|
|
129
|
-
|
|
131
|
+
oldIdToNewId.set(oldChildId, newChildElement.id);
|
|
132
|
+
newInnerElements.push(newChildElement);
|
|
130
133
|
}
|
|
131
134
|
});
|
|
132
135
|
}
|
|
@@ -142,25 +145,26 @@ class DocumentElementFactory {
|
|
|
142
145
|
newElement.position.y = newElement.position.y + positionOffset.y;
|
|
143
146
|
}
|
|
144
147
|
}
|
|
145
|
-
newElement.documentId = documentId;
|
|
146
|
-
newElement.specifiedId = newId;
|
|
147
|
-
oldIdToNewId[element.id] = newId;
|
|
148
148
|
newElement = DocumentElementFactory.createElement(element.type, newElement);
|
|
149
|
+
newElement.documentId = documentId;
|
|
150
|
+
newElement.specifiedId = newElement.id;
|
|
151
|
+
oldIdToNewId.set(element.id, newElement.id);
|
|
149
152
|
newElements.push(newElement);
|
|
153
|
+
newElements.push(...newInnerElements);
|
|
150
154
|
if (newElement.type === 'group')
|
|
151
155
|
groupElements.push(newElement);
|
|
152
156
|
if (DocumentElementFactory.isMask(newElement))
|
|
153
157
|
maskElements.push(newElement);
|
|
154
158
|
}
|
|
155
|
-
groupElements.forEach(groupElement => {
|
|
159
|
+
groupElements.forEach((groupElement) => {
|
|
156
160
|
groupElement.elementIds = groupElement.elementIds
|
|
157
|
-
.map(oldElementId => oldIdToNewId.get(oldElementId))
|
|
158
|
-
.filter(id => !!id);
|
|
161
|
+
.map((oldElementId) => oldIdToNewId.get(oldElementId))
|
|
162
|
+
.filter((id) => !!id);
|
|
159
163
|
});
|
|
160
|
-
maskElements.forEach(maskElement => {
|
|
164
|
+
maskElements.forEach((maskElement) => {
|
|
161
165
|
const newElementIds = maskElement.elementIds
|
|
162
|
-
.map(oldElementId => oldIdToNewId.get(oldElementId))
|
|
163
|
-
.filter(id => !!id);
|
|
166
|
+
.map((oldElementId) => oldIdToNewId.get(oldElementId))
|
|
167
|
+
.filter((id) => !!id);
|
|
164
168
|
maskElement.elementIds = (newElementIds === null || newElementIds === void 0 ? void 0 : newElementIds.length) > 0 ? newElementIds : null;
|
|
165
169
|
});
|
|
166
170
|
return { oldIdToNewId, newElements };
|
|
@@ -6,6 +6,11 @@ export interface AlternateUrls {
|
|
|
6
6
|
lowResolution?: string;
|
|
7
7
|
originalFile?: string;
|
|
8
8
|
}
|
|
9
|
+
export interface LinkedEdgeDefinition {
|
|
10
|
+
id?: string;
|
|
11
|
+
position?: PositionDefinition;
|
|
12
|
+
location?: 'auto' | 'top' | 'bottom' | 'left' | 'right';
|
|
13
|
+
}
|
|
9
14
|
export interface DocumentElement extends Document {
|
|
10
15
|
id?: string;
|
|
11
16
|
specifiedId?: string;
|
|
@@ -37,6 +42,8 @@ export interface DocumentElement extends Document {
|
|
|
37
42
|
tableId?: string;
|
|
38
43
|
colspan?: number;
|
|
39
44
|
rowspan?: number;
|
|
45
|
+
start?: LinkedEdgeDefinition;
|
|
46
|
+
end?: LinkedEdgeDefinition;
|
|
40
47
|
propertyBindingsMetaData?: {
|
|
41
48
|
displayFunction: string;
|
|
42
49
|
propertyType: string;
|