ts-d2 0.0.21 → 0.0.23
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 +212 -29
- package/dist/index.cjs +947 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +397 -17
- package/dist/index.d.ts +397 -17
- package/dist/index.js +947 -209
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.js
CHANGED
|
@@ -4,15 +4,49 @@ var __export = (target, all) => {
|
|
|
4
4
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
// src/
|
|
7
|
+
// src/Alignment/index.ts
|
|
8
8
|
import Proto from "docframe-types";
|
|
9
|
+
var HorizontalAlignment = class {
|
|
10
|
+
constructor(value) {
|
|
11
|
+
this.value = value;
|
|
12
|
+
}
|
|
13
|
+
toDocFrame() {
|
|
14
|
+
return this.value;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var VerticalAlignment = class {
|
|
18
|
+
constructor(value) {
|
|
19
|
+
this.value = value;
|
|
20
|
+
}
|
|
21
|
+
toDocFrame() {
|
|
22
|
+
return this.value;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
var Alignment;
|
|
26
|
+
((Alignment2) => {
|
|
27
|
+
Alignment2.Horizontal = {
|
|
28
|
+
Left: new HorizontalAlignment(Proto.ProtoHorizontalAlignment.ALIGN_LEFT),
|
|
29
|
+
Center: new HorizontalAlignment(Proto.ProtoHorizontalAlignment.ALIGN_CENTER),
|
|
30
|
+
Right: new HorizontalAlignment(Proto.ProtoHorizontalAlignment.ALIGN_RIGHT),
|
|
31
|
+
Justify: new HorizontalAlignment(Proto.ProtoHorizontalAlignment.ALIGN_JUSTIFY),
|
|
32
|
+
FullJustify: new HorizontalAlignment(Proto.ProtoHorizontalAlignment.ALIGN_FULL_JUSTIFY)
|
|
33
|
+
};
|
|
34
|
+
Alignment2.Vertical = {
|
|
35
|
+
Top: new VerticalAlignment(Proto.ProtoVerticalAlignment.TOP),
|
|
36
|
+
Middle: new VerticalAlignment(Proto.ProtoVerticalAlignment.MIDDLE),
|
|
37
|
+
Bottom: new VerticalAlignment(Proto.ProtoVerticalAlignment.BOTTOM)
|
|
38
|
+
};
|
|
39
|
+
})(Alignment || (Alignment = {}));
|
|
40
|
+
|
|
41
|
+
// src/Border/index.ts
|
|
42
|
+
import Proto2 from "docframe-types";
|
|
9
43
|
var Border = class {
|
|
10
44
|
constructor(width, color) {
|
|
11
45
|
this.width = width;
|
|
12
46
|
this.color = color;
|
|
13
47
|
}
|
|
14
48
|
toDocFrame() {
|
|
15
|
-
return new
|
|
49
|
+
return new Proto2.ProtoBorder({
|
|
16
50
|
weight: this.width.toDocFrame(),
|
|
17
51
|
color: this.color.toDocFrame()
|
|
18
52
|
});
|
|
@@ -24,7 +58,7 @@ var SideBorders = class {
|
|
|
24
58
|
}
|
|
25
59
|
toDocFrame() {
|
|
26
60
|
var _a, _b, _c, _d;
|
|
27
|
-
return new
|
|
61
|
+
return new Proto2.ProtoSideBorders({
|
|
28
62
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
29
63
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
30
64
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -34,7 +68,7 @@ var SideBorders = class {
|
|
|
34
68
|
};
|
|
35
69
|
|
|
36
70
|
// src/Color/index.ts
|
|
37
|
-
import
|
|
71
|
+
import Proto3 from "docframe-types";
|
|
38
72
|
var Color = class _Color {
|
|
39
73
|
static rgb(r, g, b) {
|
|
40
74
|
if (r < 0 || r > 255) {
|
|
@@ -46,8 +80,8 @@ var Color = class _Color {
|
|
|
46
80
|
if (b < 0 || b > 255) {
|
|
47
81
|
throw new Error(`Invalid blue value: ${b}`);
|
|
48
82
|
}
|
|
49
|
-
return new _Color(
|
|
50
|
-
type:
|
|
83
|
+
return new _Color(Proto3.ProtoColor.create({
|
|
84
|
+
type: Proto3.ProtoColorType.RGB,
|
|
51
85
|
r,
|
|
52
86
|
g,
|
|
53
87
|
b
|
|
@@ -66,8 +100,8 @@ var Color = class _Color {
|
|
|
66
100
|
if (k < 0 || k > 100) {
|
|
67
101
|
throw new Error(`Invalid black value: ${k}`);
|
|
68
102
|
}
|
|
69
|
-
return new _Color(
|
|
70
|
-
type:
|
|
103
|
+
return new _Color(Proto3.ProtoColor.create({
|
|
104
|
+
type: Proto3.ProtoColorType.CMYK,
|
|
71
105
|
c,
|
|
72
106
|
m,
|
|
73
107
|
y,
|
|
@@ -84,8 +118,8 @@ var Color = class _Color {
|
|
|
84
118
|
const r = parseInt(hex.slice(0, 2), 16);
|
|
85
119
|
const g = parseInt(hex.slice(2, 4), 16);
|
|
86
120
|
const b = parseInt(hex.slice(4, 6), 16);
|
|
87
|
-
return new _Color(
|
|
88
|
-
type:
|
|
121
|
+
return new _Color(Proto3.ProtoColor.create({
|
|
122
|
+
type: Proto3.ProtoColorType.RGB,
|
|
89
123
|
r,
|
|
90
124
|
g,
|
|
91
125
|
b
|
|
@@ -108,7 +142,7 @@ var Colors;
|
|
|
108
142
|
import axios from "axios";
|
|
109
143
|
import FormData from "form-data";
|
|
110
144
|
import dotenv from "dotenv";
|
|
111
|
-
import
|
|
145
|
+
import Proto4 from "docframe-types";
|
|
112
146
|
dotenv.config();
|
|
113
147
|
var Connection = class {
|
|
114
148
|
constructor(url, token) {
|
|
@@ -120,7 +154,7 @@ var Connection = class {
|
|
|
120
154
|
}
|
|
121
155
|
convertTo(format, doc, outputParams, jobParams) {
|
|
122
156
|
const node = doc.toDocFrame();
|
|
123
|
-
const protoData =
|
|
157
|
+
const protoData = Proto4.Node.encode(node).finish();
|
|
124
158
|
const form = new FormData();
|
|
125
159
|
let meta = {
|
|
126
160
|
format
|
|
@@ -166,13 +200,131 @@ var Connection = class {
|
|
|
166
200
|
};
|
|
167
201
|
var defaultConnection = new Connection();
|
|
168
202
|
|
|
169
|
-
// src/Content/
|
|
203
|
+
// src/Content/AdjustHorizontally/index.ts
|
|
170
204
|
import Proto6 from "docframe-types";
|
|
171
205
|
|
|
172
206
|
// src/Content/DocumentElement/index.ts
|
|
173
207
|
var DocumentElement = class {
|
|
174
208
|
};
|
|
175
209
|
|
|
210
|
+
// src/Content/Text/index.ts
|
|
211
|
+
import Proto5 from "docframe-types";
|
|
212
|
+
var Text = class extends DocumentElement {
|
|
213
|
+
constructor(content) {
|
|
214
|
+
super();
|
|
215
|
+
this.content = content;
|
|
216
|
+
}
|
|
217
|
+
toDocFrame() {
|
|
218
|
+
return Proto5.Node.create({
|
|
219
|
+
text: Proto5.ProtoText.create({
|
|
220
|
+
content: this.content
|
|
221
|
+
})
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// src/Content/BranchDocumentElement/index.ts
|
|
227
|
+
var BranchDocumentElement = class extends DocumentElement {
|
|
228
|
+
constructor(children, props) {
|
|
229
|
+
super();
|
|
230
|
+
this.children = [];
|
|
231
|
+
this._props = props;
|
|
232
|
+
if (children === void 0) {
|
|
233
|
+
this.children = [];
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
this.children = documentElementsFromContent(children);
|
|
237
|
+
}
|
|
238
|
+
appendChildren(children) {
|
|
239
|
+
this.children = this.children.concat(children);
|
|
240
|
+
}
|
|
241
|
+
appendChild(child) {
|
|
242
|
+
this.children.push(child);
|
|
243
|
+
}
|
|
244
|
+
prependChildren(children) {
|
|
245
|
+
this.children = children.concat(this.children);
|
|
246
|
+
}
|
|
247
|
+
prependChild(child) {
|
|
248
|
+
this.children.unshift(child);
|
|
249
|
+
}
|
|
250
|
+
childrenToDocFrame() {
|
|
251
|
+
return this.children.map((child) => child.toDocFrame());
|
|
252
|
+
}
|
|
253
|
+
set props(props) {
|
|
254
|
+
this._props = props;
|
|
255
|
+
}
|
|
256
|
+
get props() {
|
|
257
|
+
return this._props;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
function documentElementsFromContent(content) {
|
|
261
|
+
if (typeof content === "string") {
|
|
262
|
+
return [new Text(content)];
|
|
263
|
+
} else if (Array.isArray(content)) {
|
|
264
|
+
return content.map(documentElementsFromContent).flat();
|
|
265
|
+
} else {
|
|
266
|
+
return [content];
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// src/Content/AdjustHorizontally/index.ts
|
|
271
|
+
var AdjustHorizontally = class extends BranchDocumentElement {
|
|
272
|
+
constructor(content, props) {
|
|
273
|
+
super(content, props);
|
|
274
|
+
}
|
|
275
|
+
toDocFrame() {
|
|
276
|
+
var _a, _b, _c, _d;
|
|
277
|
+
return Proto6.Node.create({
|
|
278
|
+
adjustHorizontally: Proto6.ProtoAdjustHorizontally.create({
|
|
279
|
+
minFontSize: (_b = (_a = this.props) == null ? void 0 : _a.minFontSize) == null ? void 0 : _b.toDocFrame(),
|
|
280
|
+
maxFontSize: (_d = (_c = this.props) == null ? void 0 : _c.maxFontSize) == null ? void 0 : _d.toDocFrame()
|
|
281
|
+
}),
|
|
282
|
+
children: this.childrenToDocFrame()
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
// src/Content/AdvancedIllustrationArea/index.ts
|
|
288
|
+
import Proto7 from "docframe-types";
|
|
289
|
+
function textFlowTypeToDocFrame(type) {
|
|
290
|
+
switch (type) {
|
|
291
|
+
case "around":
|
|
292
|
+
return Proto7.ProtoAdvancedIllustrationAreaTextFlowType.AROUND;
|
|
293
|
+
case "no-flow":
|
|
294
|
+
return Proto7.ProtoAdvancedIllustrationAreaTextFlowType.NO_FLOW;
|
|
295
|
+
case "foreground":
|
|
296
|
+
return Proto7.ProtoAdvancedIllustrationAreaTextFlowType.FOREGROUND;
|
|
297
|
+
case "background":
|
|
298
|
+
return Proto7.ProtoAdvancedIllustrationAreaTextFlowType.BACKGROUND;
|
|
299
|
+
default:
|
|
300
|
+
throw new Error(`Unknown text flow type: ${type}`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
var AdvancedIllustrationArea = class extends BranchDocumentElement {
|
|
304
|
+
constructor(content, props) {
|
|
305
|
+
super(content, props);
|
|
306
|
+
}
|
|
307
|
+
toDocFrame() {
|
|
308
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
309
|
+
return Proto7.Node.create({
|
|
310
|
+
advancedIllustrationArea: Proto7.ProtoAdvancedIllustrationArea.create({
|
|
311
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
312
|
+
absolute: (_b = this.props) == null ? void 0 : _b.absolute,
|
|
313
|
+
width: (_d = (_c = this.props) == null ? void 0 : _c.width) == null ? void 0 : _d.toDocFrame(),
|
|
314
|
+
height: (_f = (_e = this.props) == null ? void 0 : _e.height) == null ? void 0 : _f.toDocFrame(),
|
|
315
|
+
x: (_h = (_g = this.props) == null ? void 0 : _g.x) == null ? void 0 : _h.toDocFrame(),
|
|
316
|
+
y: (_j = (_i = this.props) == null ? void 0 : _i.y) == null ? void 0 : _j.toDocFrame(),
|
|
317
|
+
textFlow: ((_k = this.props) == null ? void 0 : _k.textFlow) ? textFlowTypeToDocFrame(this.props.textFlow) : void 0,
|
|
318
|
+
rotation: (_l = this.props) == null ? void 0 : _l.rotation
|
|
319
|
+
}),
|
|
320
|
+
children: this.childrenToDocFrame()
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
// src/Content/Barcode/index.ts
|
|
326
|
+
import Proto10 from "docframe-types";
|
|
327
|
+
|
|
176
328
|
// src/Measure/index.ts
|
|
177
329
|
var Measure_exports = {};
|
|
178
330
|
__export(Measure_exports, {
|
|
@@ -183,7 +335,7 @@ __export(Measure_exports, {
|
|
|
183
335
|
});
|
|
184
336
|
|
|
185
337
|
// src/Measure/Measure.ts
|
|
186
|
-
import
|
|
338
|
+
import Proto8 from "docframe-types";
|
|
187
339
|
var _Measure = class _Measure {
|
|
188
340
|
constructor(value, unit) {
|
|
189
341
|
this.value = value;
|
|
@@ -192,34 +344,34 @@ var _Measure = class _Measure {
|
|
|
192
344
|
toDocFrame() {
|
|
193
345
|
switch (this.unit) {
|
|
194
346
|
case "pt":
|
|
195
|
-
return new
|
|
347
|
+
return new Proto8.ProtoMeasure({
|
|
196
348
|
value: this.value,
|
|
197
|
-
mtype:
|
|
349
|
+
mtype: Proto8.ProtoMeasureType.PT
|
|
198
350
|
});
|
|
199
351
|
case "cm":
|
|
200
|
-
return new
|
|
352
|
+
return new Proto8.ProtoMeasure({
|
|
201
353
|
value: this.value,
|
|
202
|
-
mtype:
|
|
354
|
+
mtype: Proto8.ProtoMeasureType.CM
|
|
203
355
|
});
|
|
204
356
|
case "mm":
|
|
205
|
-
return new
|
|
357
|
+
return new Proto8.ProtoMeasure({
|
|
206
358
|
value: this.value,
|
|
207
|
-
mtype:
|
|
359
|
+
mtype: Proto8.ProtoMeasureType.MM
|
|
208
360
|
});
|
|
209
361
|
case "in":
|
|
210
|
-
return new
|
|
362
|
+
return new Proto8.ProtoMeasure({
|
|
211
363
|
value: this.value,
|
|
212
|
-
mtype:
|
|
364
|
+
mtype: Proto8.ProtoMeasureType.IN
|
|
213
365
|
});
|
|
214
366
|
case "px":
|
|
215
|
-
return new
|
|
367
|
+
return new Proto8.ProtoMeasure({
|
|
216
368
|
value: this.value,
|
|
217
|
-
mtype:
|
|
369
|
+
mtype: Proto8.ProtoMeasureType.PX
|
|
218
370
|
});
|
|
219
371
|
case "%":
|
|
220
|
-
return new
|
|
372
|
+
return new Proto8.ProtoMeasure({
|
|
221
373
|
value: this.value,
|
|
222
|
-
mtype:
|
|
374
|
+
mtype: Proto8.ProtoMeasureType.PERCENT
|
|
223
375
|
});
|
|
224
376
|
default:
|
|
225
377
|
throw new Error(`Unknown measure unit: ${this.unit}`);
|
|
@@ -236,7 +388,7 @@ var SideMeasures = class {
|
|
|
236
388
|
}
|
|
237
389
|
toDocFrame() {
|
|
238
390
|
var _a, _b, _c, _d;
|
|
239
|
-
return new
|
|
391
|
+
return new Proto8.ProtoSideMeasures({
|
|
240
392
|
top: (_a = this.value.top) == null ? void 0 : _a.toDocFrame(),
|
|
241
393
|
right: (_b = this.value.right) == null ? void 0 : _b.toDocFrame(),
|
|
242
394
|
bottom: (_c = this.value.bottom) == null ? void 0 : _c.toDocFrame(),
|
|
@@ -248,19 +400,19 @@ var Sides = class {
|
|
|
248
400
|
};
|
|
249
401
|
|
|
250
402
|
// src/Content/ReferencePoint/index.ts
|
|
251
|
-
import
|
|
403
|
+
import Proto9 from "docframe-types";
|
|
252
404
|
function referencePointToDocFrame(point) {
|
|
253
405
|
switch (point) {
|
|
254
406
|
case "top-left":
|
|
255
|
-
return
|
|
407
|
+
return Proto9.ProtoImageReferencePoint.REF_POINT_TOP_LEFT;
|
|
256
408
|
case "top-right":
|
|
257
|
-
return
|
|
409
|
+
return Proto9.ProtoImageReferencePoint.REF_POINT_TOP_RIGHT;
|
|
258
410
|
case "center":
|
|
259
|
-
return
|
|
411
|
+
return Proto9.ProtoImageReferencePoint.REF_POINT_CENTER;
|
|
260
412
|
case "bottom-left":
|
|
261
|
-
return
|
|
413
|
+
return Proto9.ProtoImageReferencePoint.REF_POINT_BOTTOM_LEFT;
|
|
262
414
|
case "bottom-right":
|
|
263
|
-
return
|
|
415
|
+
return Proto9.ProtoImageReferencePoint.REF_POINT_BOTTOM_RIGHT;
|
|
264
416
|
default:
|
|
265
417
|
throw new Error(`Unknown reference point: ${point}`);
|
|
266
418
|
}
|
|
@@ -273,8 +425,8 @@ var Barcode = class extends DocumentElement {
|
|
|
273
425
|
this.props = props;
|
|
274
426
|
}
|
|
275
427
|
toDocFrame() {
|
|
276
|
-
return
|
|
277
|
-
barcode:
|
|
428
|
+
return Proto10.Node.create({
|
|
429
|
+
barcode: Proto10.ProtoBarcode.create({
|
|
278
430
|
type: this.props.type,
|
|
279
431
|
positionAbsolute: this.props.positionAbsolute,
|
|
280
432
|
referencePoint: referencePointToDocFrame(this.props.referencePoint),
|
|
@@ -283,15 +435,32 @@ var Barcode = class extends DocumentElement {
|
|
|
283
435
|
rotation: this.props.rotation,
|
|
284
436
|
width: this.props.width.toDocFrame(),
|
|
285
437
|
height: this.props.height.toDocFrame(),
|
|
286
|
-
padding: Measure.zero.toDocFrame(),
|
|
287
|
-
data: this.props.data
|
|
438
|
+
padding: (this.props.padding ?? Measure.zero).toDocFrame(),
|
|
439
|
+
data: this.props.data,
|
|
440
|
+
code: this.props.code,
|
|
441
|
+
altText: this.props.altText,
|
|
442
|
+
uuid: this.props.uuid
|
|
288
443
|
})
|
|
289
444
|
});
|
|
290
445
|
}
|
|
291
446
|
};
|
|
292
447
|
|
|
448
|
+
// src/Content/CarryOver/index.ts
|
|
449
|
+
import Proto11 from "docframe-types";
|
|
450
|
+
var CarryOver = class extends BranchDocumentElement {
|
|
451
|
+
constructor(content) {
|
|
452
|
+
super(content);
|
|
453
|
+
}
|
|
454
|
+
toDocFrame() {
|
|
455
|
+
return Proto11.Node.create({
|
|
456
|
+
carryOver: Proto11.ProtoCarryOver.create({}),
|
|
457
|
+
children: this.childrenToDocFrame()
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
};
|
|
461
|
+
|
|
293
462
|
// src/Content/ColumnDefinition/index.ts
|
|
294
|
-
import
|
|
463
|
+
import Proto12 from "docframe-types";
|
|
295
464
|
import { v4 as uuidv4 } from "uuid";
|
|
296
465
|
var ColumnPositionMode = class {
|
|
297
466
|
constructor(value) {
|
|
@@ -303,12 +472,12 @@ var ColumnPositionMode = class {
|
|
|
303
472
|
};
|
|
304
473
|
var ColumnPosition;
|
|
305
474
|
((ColumnPosition2) => {
|
|
306
|
-
ColumnPosition2.Center = new ColumnPositionMode(
|
|
307
|
-
ColumnPosition2.Left = new ColumnPositionMode(
|
|
308
|
-
ColumnPosition2.Folio = new ColumnPositionMode(
|
|
309
|
-
ColumnPosition2.Right = new ColumnPositionMode(
|
|
475
|
+
ColumnPosition2.Center = new ColumnPositionMode(Proto12.ProtoPositionMode.CENTER);
|
|
476
|
+
ColumnPosition2.Left = new ColumnPositionMode(Proto12.ProtoPositionMode.LEFT);
|
|
477
|
+
ColumnPosition2.Folio = new ColumnPositionMode(Proto12.ProtoPositionMode.FOLIO);
|
|
478
|
+
ColumnPosition2.Right = new ColumnPositionMode(Proto12.ProtoPositionMode.RIGHT);
|
|
310
479
|
ColumnPosition2.ReverseFolio = new ColumnPositionMode(
|
|
311
|
-
|
|
480
|
+
Proto12.ProtoPositionMode.REVERSE_FOLIO
|
|
312
481
|
);
|
|
313
482
|
})(ColumnPosition || (ColumnPosition = {}));
|
|
314
483
|
var ColumnDefinition = class {
|
|
@@ -318,20 +487,20 @@ var ColumnDefinition = class {
|
|
|
318
487
|
}
|
|
319
488
|
toDocFrame(applyImmediate) {
|
|
320
489
|
const result = [
|
|
321
|
-
|
|
322
|
-
cDef:
|
|
490
|
+
Proto12.Node.create({
|
|
491
|
+
cDef: Proto12.ProtoCDef.create({
|
|
323
492
|
Uuid: this.uuid,
|
|
324
|
-
columSettings:
|
|
325
|
-
width:
|
|
493
|
+
columSettings: Proto12.ProtoColumnSettings.create({
|
|
494
|
+
width: Proto12.ProtoBoxedMeasure.create({
|
|
326
495
|
isNull: false,
|
|
327
496
|
value: this.props.width.toDocFrame()
|
|
328
497
|
}),
|
|
329
|
-
positionOffset:
|
|
498
|
+
positionOffset: Proto12.ProtoBoxedMeasure.create({
|
|
330
499
|
isNull: false,
|
|
331
500
|
value: this.props.positionOffset.toDocFrame()
|
|
332
501
|
}),
|
|
333
502
|
positionMode: this.props.position.toDocFrame(),
|
|
334
|
-
interColumnSpace:
|
|
503
|
+
interColumnSpace: Proto12.ProtoBoxedMeasure.create({
|
|
335
504
|
isNull: false,
|
|
336
505
|
value: this.props.interColumnSpace.toDocFrame()
|
|
337
506
|
})
|
|
@@ -341,8 +510,8 @@ var ColumnDefinition = class {
|
|
|
341
510
|
];
|
|
342
511
|
if (applyImmediate) {
|
|
343
512
|
result.push(
|
|
344
|
-
|
|
345
|
-
applyCDef:
|
|
513
|
+
Proto12.Node.create({
|
|
514
|
+
applyCDef: Proto12.ProtoApplyProtoCDef.create({
|
|
346
515
|
cDefUuid: this.uuid
|
|
347
516
|
})
|
|
348
517
|
})
|
|
@@ -368,81 +537,63 @@ var ColumnDefinitions = {
|
|
|
368
537
|
}
|
|
369
538
|
};
|
|
370
539
|
|
|
371
|
-
// src/Content/
|
|
372
|
-
import
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
var Text = class extends DocumentElement {
|
|
377
|
-
constructor(content) {
|
|
378
|
-
super();
|
|
379
|
-
this.content = content;
|
|
540
|
+
// src/Content/Condition/index.ts
|
|
541
|
+
import Proto13 from "docframe-types";
|
|
542
|
+
var Condition = class extends BranchDocumentElement {
|
|
543
|
+
constructor(content, props) {
|
|
544
|
+
super(content, props);
|
|
380
545
|
}
|
|
381
546
|
toDocFrame() {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
547
|
+
var _a, _b, _c, _d;
|
|
548
|
+
return Proto13.Node.create({
|
|
549
|
+
condition: Proto13.ProtoCondition.create({
|
|
550
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
551
|
+
code: (_b = this.props) == null ? void 0 : _b.code,
|
|
552
|
+
result: (_c = this.props) == null ? void 0 : _c.result,
|
|
553
|
+
regenerate: (_d = this.props) == null ? void 0 : _d.regenerate
|
|
554
|
+
}),
|
|
555
|
+
children: this.childrenToDocFrame()
|
|
386
556
|
});
|
|
387
557
|
}
|
|
388
558
|
};
|
|
389
559
|
|
|
390
|
-
// src/Content/
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
this.children.push(child);
|
|
407
|
-
}
|
|
408
|
-
prependChildren(children) {
|
|
409
|
-
this.children = children.concat(this.children);
|
|
410
|
-
}
|
|
411
|
-
prependChild(child) {
|
|
412
|
-
this.children.unshift(child);
|
|
413
|
-
}
|
|
414
|
-
childrenToDocFrame() {
|
|
415
|
-
return this.children.map((child) => child.toDocFrame());
|
|
416
|
-
}
|
|
417
|
-
set props(props) {
|
|
418
|
-
this._props = props;
|
|
419
|
-
}
|
|
420
|
-
get props() {
|
|
421
|
-
return this._props;
|
|
422
|
-
}
|
|
423
|
-
};
|
|
424
|
-
function documentElementsFromContent(content) {
|
|
425
|
-
if (typeof content === "string") {
|
|
426
|
-
return [new Text(content)];
|
|
427
|
-
} else if (Array.isArray(content)) {
|
|
428
|
-
return content.map(documentElementsFromContent).flat();
|
|
429
|
-
} else {
|
|
430
|
-
return [content];
|
|
560
|
+
// src/Content/Directory/index.ts
|
|
561
|
+
import Proto14 from "docframe-types";
|
|
562
|
+
function semanticTypeToDocFrame(type) {
|
|
563
|
+
switch (type) {
|
|
564
|
+
case "none":
|
|
565
|
+
return Proto14.ProtoSemanticType.SEMANTIC_TYPE_NONE;
|
|
566
|
+
case "part":
|
|
567
|
+
return Proto14.ProtoSemanticType.SEMANTIC_TYPE_PART;
|
|
568
|
+
case "art":
|
|
569
|
+
return Proto14.ProtoSemanticType.SEMANTIC_TYPE_ART;
|
|
570
|
+
case "sect":
|
|
571
|
+
return Proto14.ProtoSemanticType.SEMANTIC_TYPE_SECT;
|
|
572
|
+
case "div":
|
|
573
|
+
return Proto14.ProtoSemanticType.SEMANTIC_TYPE_DIV;
|
|
574
|
+
default:
|
|
575
|
+
throw new Error(`Unknown semantic type: ${type}`);
|
|
431
576
|
}
|
|
432
577
|
}
|
|
433
|
-
|
|
434
|
-
// src/Content/Directory/index.ts
|
|
435
578
|
var Directory = class extends BranchDocumentElement {
|
|
579
|
+
constructor(content, props) {
|
|
580
|
+
super(content, props);
|
|
581
|
+
}
|
|
436
582
|
toDocFrame() {
|
|
437
|
-
|
|
438
|
-
|
|
583
|
+
var _a, _b, _c;
|
|
584
|
+
return Proto14.Node.create({
|
|
585
|
+
directory: Proto14.ProtoDirectory.create({
|
|
586
|
+
name: (_a = this.props) == null ? void 0 : _a.name,
|
|
587
|
+
editable: (_b = this.props) == null ? void 0 : _b.editable,
|
|
588
|
+
semanticType: ((_c = this.props) == null ? void 0 : _c.semanticType) ? semanticTypeToDocFrame(this.props.semanticType) : void 0
|
|
589
|
+
}),
|
|
439
590
|
children: this.childrenToDocFrame()
|
|
440
591
|
});
|
|
441
592
|
}
|
|
442
593
|
};
|
|
443
594
|
|
|
444
595
|
// src/Content/Document/index.ts
|
|
445
|
-
import
|
|
596
|
+
import Proto21 from "docframe-types";
|
|
446
597
|
|
|
447
598
|
// src/OutputFormat/index.ts
|
|
448
599
|
var OutputFormat_exports = {};
|
|
@@ -460,29 +611,69 @@ var OutputFormat = /* @__PURE__ */ ((OutputFormat2) => {
|
|
|
460
611
|
})(OutputFormat || {});
|
|
461
612
|
|
|
462
613
|
// src/Content/Footer/index.ts
|
|
463
|
-
import
|
|
614
|
+
import Proto15 from "docframe-types";
|
|
615
|
+
function footerModeToDocFrame(mode) {
|
|
616
|
+
switch (mode) {
|
|
617
|
+
case "append-initial":
|
|
618
|
+
return Proto15.ProtoFooterMode.FOOTER_MODE_APPEND_INITIAL;
|
|
619
|
+
case "append":
|
|
620
|
+
return Proto15.ProtoFooterMode.FOOTER_MODE_APPEND;
|
|
621
|
+
case "extend":
|
|
622
|
+
return Proto15.ProtoFooterMode.FOOTER_MODE_EXTEND;
|
|
623
|
+
case "replace":
|
|
624
|
+
return Proto15.ProtoFooterMode.FOOTER_MODE_REPLACE;
|
|
625
|
+
default:
|
|
626
|
+
throw new Error(`Unknown footer mode: ${mode}`);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
464
629
|
var Footer = class extends BranchDocumentElement {
|
|
630
|
+
constructor(content, props) {
|
|
631
|
+
super(content, props);
|
|
632
|
+
}
|
|
465
633
|
toDocFrame() {
|
|
466
|
-
|
|
467
|
-
|
|
634
|
+
var _a;
|
|
635
|
+
return Proto15.Node.create({
|
|
636
|
+
footer: Proto15.ProtoFooter.create({
|
|
637
|
+
mode: ((_a = this.props) == null ? void 0 : _a.mode) ? footerModeToDocFrame(this.props.mode) : void 0
|
|
638
|
+
}),
|
|
468
639
|
children: this.childrenToDocFrame()
|
|
469
640
|
});
|
|
470
641
|
}
|
|
471
642
|
};
|
|
472
643
|
|
|
473
644
|
// src/Content/Header/index.ts
|
|
474
|
-
import
|
|
645
|
+
import Proto16 from "docframe-types";
|
|
646
|
+
function headerModeToDocFrame(mode) {
|
|
647
|
+
switch (mode) {
|
|
648
|
+
case "append-initial":
|
|
649
|
+
return Proto16.ProtoHeaderMode.HEADER_MODE_APPEND_INITIAL;
|
|
650
|
+
case "append":
|
|
651
|
+
return Proto16.ProtoHeaderMode.HEADER_MODE_APPEND;
|
|
652
|
+
case "extend":
|
|
653
|
+
return Proto16.ProtoHeaderMode.HEADER_MODE_EXTEND;
|
|
654
|
+
case "replace":
|
|
655
|
+
return Proto16.ProtoHeaderMode.HEADER_MODE_REPLACE;
|
|
656
|
+
default:
|
|
657
|
+
throw new Error(`Unknown header mode: ${mode}`);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
475
660
|
var Header = class extends BranchDocumentElement {
|
|
661
|
+
constructor(content, props) {
|
|
662
|
+
super(content, props);
|
|
663
|
+
}
|
|
476
664
|
toDocFrame() {
|
|
477
|
-
|
|
478
|
-
|
|
665
|
+
var _a;
|
|
666
|
+
return Proto16.Node.create({
|
|
667
|
+
header: Proto16.ProtoHeader.create({
|
|
668
|
+
mode: ((_a = this.props) == null ? void 0 : _a.mode) ? headerModeToDocFrame(this.props.mode) : void 0
|
|
669
|
+
}),
|
|
479
670
|
children: this.childrenToDocFrame()
|
|
480
671
|
});
|
|
481
672
|
}
|
|
482
673
|
};
|
|
483
674
|
|
|
484
675
|
// src/Content/PageDefinition/index.ts
|
|
485
|
-
import
|
|
676
|
+
import Proto17 from "docframe-types";
|
|
486
677
|
import { v4 } from "uuid";
|
|
487
678
|
var PageDefinition = class {
|
|
488
679
|
constructor(width, height) {
|
|
@@ -492,12 +683,12 @@ var PageDefinition = class {
|
|
|
492
683
|
}
|
|
493
684
|
toDocFrame() {
|
|
494
685
|
var _a, _b;
|
|
495
|
-
return new
|
|
496
|
-
pageDepth: new
|
|
686
|
+
return new Proto17.ProtoPDef({
|
|
687
|
+
pageDepth: new Proto17.ProtoBoxedMeasure({
|
|
497
688
|
isNull: this.height === void 0,
|
|
498
689
|
value: (_a = this.height) == null ? void 0 : _a.toDocFrame()
|
|
499
690
|
}),
|
|
500
|
-
pageWidth: new
|
|
691
|
+
pageWidth: new Proto17.ProtoBoxedMeasure({
|
|
501
692
|
isNull: this.width === void 0,
|
|
502
693
|
value: (_b = this.width) == null ? void 0 : _b.toDocFrame()
|
|
503
694
|
}),
|
|
@@ -522,7 +713,7 @@ var PageDefinitions;
|
|
|
522
713
|
})(PageDefinitions || (PageDefinitions = {}));
|
|
523
714
|
|
|
524
715
|
// src/ParagraphFormat/index.ts
|
|
525
|
-
import
|
|
716
|
+
import Proto18 from "docframe-types";
|
|
526
717
|
import { v4 as uuidv42 } from "uuid";
|
|
527
718
|
var ParagraphFormat = class {
|
|
528
719
|
constructor(props) {
|
|
@@ -531,101 +722,101 @@ var ParagraphFormat = class {
|
|
|
531
722
|
}
|
|
532
723
|
toDocFrame() {
|
|
533
724
|
let format = {
|
|
534
|
-
default:
|
|
725
|
+
default: Proto18.ProtoBoxedBool.create({
|
|
535
726
|
isNull: false,
|
|
536
727
|
value: this.props.default || false
|
|
537
728
|
}),
|
|
538
|
-
name:
|
|
729
|
+
name: Proto18.ProtoBoxedString.create({
|
|
539
730
|
isNull: false,
|
|
540
731
|
value: this.props.name
|
|
541
732
|
})
|
|
542
733
|
};
|
|
543
734
|
if (this.props.alignment) {
|
|
544
|
-
format.alignment =
|
|
735
|
+
format.alignment = Proto18.ProtoBoxedHorizontalAlignment.create({
|
|
545
736
|
isNull: false,
|
|
546
737
|
value: this.props.alignment.toDocFrame()
|
|
547
738
|
});
|
|
548
739
|
}
|
|
549
740
|
if (this.props.font) {
|
|
550
|
-
format.font =
|
|
741
|
+
format.font = Proto18.ProtoBoxedFont.create({
|
|
551
742
|
isNull: false,
|
|
552
743
|
value: this.props.font.toDocFrame()
|
|
553
744
|
});
|
|
554
745
|
}
|
|
555
746
|
if (this.props.fontSize) {
|
|
556
|
-
format.fontSize =
|
|
747
|
+
format.fontSize = Proto18.ProtoBoxedMeasure.create({
|
|
557
748
|
isNull: false,
|
|
558
749
|
value: this.props.fontSize.toDocFrame()
|
|
559
750
|
});
|
|
560
751
|
}
|
|
561
752
|
if (this.props.characterWidth) {
|
|
562
|
-
format.characterWidth =
|
|
753
|
+
format.characterWidth = Proto18.ProtoBoxedMeasure.create({
|
|
563
754
|
isNull: false,
|
|
564
755
|
value: this.props.characterWidth.toDocFrame()
|
|
565
756
|
});
|
|
566
757
|
}
|
|
567
758
|
if (this.props.characterSpacing) {
|
|
568
|
-
format.characterSpacing =
|
|
759
|
+
format.characterSpacing = Proto18.ProtoBoxedMeasure.create({
|
|
569
760
|
isNull: false,
|
|
570
761
|
value: this.props.characterSpacing.toDocFrame()
|
|
571
762
|
});
|
|
572
763
|
}
|
|
573
764
|
if (this.props.lineFeed) {
|
|
574
|
-
format.lineFeed =
|
|
765
|
+
format.lineFeed = Proto18.ProtoBoxedMeasure.create({
|
|
575
766
|
isNull: false,
|
|
576
767
|
value: this.props.lineFeed.toDocFrame()
|
|
577
768
|
});
|
|
578
769
|
}
|
|
579
770
|
if (this.props.indentionLevel !== void 0) {
|
|
580
|
-
format.indentionLevel =
|
|
771
|
+
format.indentionLevel = Proto18.ProtoBoxedInt32.create({
|
|
581
772
|
isNull: false,
|
|
582
773
|
value: this.props.indentionLevel
|
|
583
774
|
});
|
|
584
775
|
}
|
|
585
776
|
if (this.props.indentionWidth) {
|
|
586
|
-
format.indentionWidth =
|
|
777
|
+
format.indentionWidth = Proto18.ProtoBoxedMeasure.create({
|
|
587
778
|
isNull: false,
|
|
588
779
|
value: this.props.indentionWidth.toDocFrame()
|
|
589
780
|
});
|
|
590
781
|
}
|
|
591
782
|
if (this.props.bold !== void 0) {
|
|
592
|
-
format.bold =
|
|
783
|
+
format.bold = Proto18.ProtoBoxedBool.create({
|
|
593
784
|
isNull: false,
|
|
594
785
|
value: !!this.props.bold
|
|
595
786
|
});
|
|
596
787
|
}
|
|
597
788
|
if (this.props.italic !== void 0) {
|
|
598
|
-
format.italic =
|
|
789
|
+
format.italic = Proto18.ProtoBoxedBool.create({
|
|
599
790
|
isNull: false,
|
|
600
791
|
value: !!this.props.italic
|
|
601
792
|
});
|
|
602
793
|
}
|
|
603
794
|
if (this.props.spaceAbove) {
|
|
604
|
-
format.spaceAbove =
|
|
795
|
+
format.spaceAbove = Proto18.ProtoBoxedMeasure.create({
|
|
605
796
|
isNull: false,
|
|
606
797
|
value: this.props.spaceAbove.toDocFrame()
|
|
607
798
|
});
|
|
608
799
|
}
|
|
609
800
|
if (this.props.spaceBelow) {
|
|
610
|
-
format.spaceBelow =
|
|
801
|
+
format.spaceBelow = Proto18.ProtoBoxedMeasure.create({
|
|
611
802
|
isNull: false,
|
|
612
803
|
value: this.props.spaceBelow.toDocFrame()
|
|
613
804
|
});
|
|
614
805
|
}
|
|
615
|
-
return
|
|
806
|
+
return Proto18.ProtoParagraphFormat.create(format);
|
|
616
807
|
}
|
|
617
808
|
};
|
|
618
809
|
|
|
619
810
|
// src/Content/SpaceVertically/index.ts
|
|
620
|
-
import
|
|
811
|
+
import Proto19 from "docframe-types";
|
|
621
812
|
var SpaceVertically = class extends DocumentElement {
|
|
622
813
|
constructor(space) {
|
|
623
814
|
super();
|
|
624
815
|
this.space = space;
|
|
625
816
|
}
|
|
626
817
|
toDocFrame() {
|
|
627
|
-
return
|
|
628
|
-
spaceVertically:
|
|
818
|
+
return Proto19.Node.create({
|
|
819
|
+
spaceVertically: Proto19.ProtoSpaceVertically.create({
|
|
629
820
|
space: this.space.toDocFrame()
|
|
630
821
|
})
|
|
631
822
|
});
|
|
@@ -633,13 +824,13 @@ var SpaceVertically = class extends DocumentElement {
|
|
|
633
824
|
};
|
|
634
825
|
|
|
635
826
|
// src/Font/index.ts
|
|
636
|
-
import
|
|
827
|
+
import Proto20 from "docframe-types";
|
|
637
828
|
var Font = class {
|
|
638
829
|
constructor(name) {
|
|
639
830
|
this.name = name;
|
|
640
831
|
}
|
|
641
832
|
toDocFrame() {
|
|
642
|
-
return
|
|
833
|
+
return Proto20.ProtoFont.create({
|
|
643
834
|
name: this.name,
|
|
644
835
|
// TODO: suppot font mapping for docframe step
|
|
645
836
|
id: 5
|
|
@@ -686,11 +877,21 @@ var Document = class extends BranchDocumentElement {
|
|
|
686
877
|
registerParagraphFormat(name, pf) {
|
|
687
878
|
this.paragraphFormats[name] = pf;
|
|
688
879
|
}
|
|
689
|
-
convertTo(outputFormat, outputParams) {
|
|
690
|
-
return defaultConnection.convertTo(
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
880
|
+
convertTo(outputFormat, outputParams, jobParams) {
|
|
881
|
+
return defaultConnection.convertTo(
|
|
882
|
+
outputFormat,
|
|
883
|
+
this,
|
|
884
|
+
outputParams,
|
|
885
|
+
jobParams
|
|
886
|
+
);
|
|
887
|
+
}
|
|
888
|
+
convertToPDF(outputParams, jobParams) {
|
|
889
|
+
return defaultConnection.convertTo(
|
|
890
|
+
"pdf" /* PDF */,
|
|
891
|
+
this,
|
|
892
|
+
outputParams,
|
|
893
|
+
jobParams
|
|
894
|
+
);
|
|
694
895
|
}
|
|
695
896
|
/*
|
|
696
897
|
public getProtoParagraphFormat(format?: ParagraphFormat): Proto.IProtoParagraphFormat {
|
|
@@ -712,15 +913,15 @@ var Document = class extends BranchDocumentElement {
|
|
|
712
913
|
toDocFrame() {
|
|
713
914
|
const props = this.props;
|
|
714
915
|
const docSettings = Object.values(this.paragraphFormats).map(
|
|
715
|
-
(pf) =>
|
|
916
|
+
(pf) => Proto21.Node.create({
|
|
716
917
|
paragraphFormat: pf.toDocFrame()
|
|
717
918
|
})
|
|
718
919
|
).concat([
|
|
719
|
-
|
|
920
|
+
Proto21.Node.create({
|
|
720
921
|
pDef: props.pageDefinition.toDocFrame()
|
|
721
922
|
}),
|
|
722
|
-
|
|
723
|
-
applyPDef:
|
|
923
|
+
Proto21.Node.create({
|
|
924
|
+
applyPDef: Proto21.ProtoApplyProtoPDef.create({
|
|
724
925
|
pDefUuid: props.pageDefinition.uuid
|
|
725
926
|
})
|
|
726
927
|
}),
|
|
@@ -735,19 +936,19 @@ var Document = class extends BranchDocumentElement {
|
|
|
735
936
|
const content = this.childrenToDocFrame();
|
|
736
937
|
for (const format of Object.values(this.paragraphFormats)) {
|
|
737
938
|
docSettings.push(
|
|
738
|
-
|
|
939
|
+
Proto21.Node.create({
|
|
739
940
|
paragraphFormat: format.toDocFrame()
|
|
740
941
|
})
|
|
741
942
|
);
|
|
742
943
|
}
|
|
743
|
-
return
|
|
944
|
+
return Proto21.Node.create({
|
|
744
945
|
children: docSettings.concat(...content)
|
|
745
946
|
});
|
|
746
947
|
}
|
|
747
948
|
};
|
|
748
949
|
|
|
749
950
|
// src/Content/Formatted/index.ts
|
|
750
|
-
import
|
|
951
|
+
import Proto22 from "docframe-types";
|
|
751
952
|
var Formatted = class extends DocumentElement {
|
|
752
953
|
constructor(doctypeContent, htmlContent) {
|
|
753
954
|
super();
|
|
@@ -757,8 +958,8 @@ var Formatted = class extends DocumentElement {
|
|
|
757
958
|
};
|
|
758
959
|
}
|
|
759
960
|
toDocFrame() {
|
|
760
|
-
return
|
|
761
|
-
formatted:
|
|
961
|
+
return Proto22.Node.create({
|
|
962
|
+
formatted: Proto22.ProtoFormatted.create({
|
|
762
963
|
doctypeContent: this.content.doctype,
|
|
763
964
|
htmlContent: this.content.html
|
|
764
965
|
})
|
|
@@ -766,28 +967,249 @@ var Formatted = class extends DocumentElement {
|
|
|
766
967
|
}
|
|
767
968
|
};
|
|
768
969
|
|
|
970
|
+
// src/Content/Image/index.ts
|
|
971
|
+
import Proto23 from "docframe-types";
|
|
972
|
+
function imageScaleTypeToDocFrame(type) {
|
|
973
|
+
switch (type) {
|
|
974
|
+
case "relative":
|
|
975
|
+
return Proto23.ProtoImageScaleType.IMAGE_SCALE_TYPE_RELATIVE;
|
|
976
|
+
case "absolute":
|
|
977
|
+
return Proto23.ProtoImageScaleType.IMAGE_SCALE_TYPE_ABSOLUTE;
|
|
978
|
+
case "relative-to-column":
|
|
979
|
+
return Proto23.ProtoImageScaleType.IMAGE_SCALE_TYPE_RELATIVE_TO_COLUMN;
|
|
980
|
+
default:
|
|
981
|
+
throw new Error(`Unknown image scale type: ${type}`);
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
var Image = class extends DocumentElement {
|
|
985
|
+
constructor(props) {
|
|
986
|
+
super();
|
|
987
|
+
this.props = props;
|
|
988
|
+
}
|
|
989
|
+
toDocFrame() {
|
|
990
|
+
const p = this.props;
|
|
991
|
+
const image = {
|
|
992
|
+
alt: p.alt,
|
|
993
|
+
name: p.name,
|
|
994
|
+
src: p.src,
|
|
995
|
+
filename: p.filename,
|
|
996
|
+
rotation: p.rotation,
|
|
997
|
+
hyperlink: p.hyperlink,
|
|
998
|
+
uuid: p.uuid,
|
|
999
|
+
imageContent: p.imageContent
|
|
1000
|
+
};
|
|
1001
|
+
if (p.scale !== void 0) {
|
|
1002
|
+
image.scale = Proto23.ProtoBoxedDouble.create({
|
|
1003
|
+
isNull: false,
|
|
1004
|
+
value: p.scale
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
if (p.columnScale !== void 0) {
|
|
1008
|
+
image.columnScale = Proto23.ProtoBoxedDouble.create({
|
|
1009
|
+
isNull: false,
|
|
1010
|
+
value: p.columnScale
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
1013
|
+
if (p.width) {
|
|
1014
|
+
image.width = Proto23.ProtoBoxedMeasure.create({
|
|
1015
|
+
isNull: false,
|
|
1016
|
+
value: p.width.toDocFrame()
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
if (p.height) {
|
|
1020
|
+
image.height = Proto23.ProtoBoxedMeasure.create({
|
|
1021
|
+
isNull: false,
|
|
1022
|
+
value: p.height.toDocFrame()
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
if (p.x) {
|
|
1026
|
+
image.x = Proto23.ProtoBoxedMeasure.create({
|
|
1027
|
+
isNull: false,
|
|
1028
|
+
value: p.x.toDocFrame()
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
if (p.y) {
|
|
1032
|
+
image.y = Proto23.ProtoBoxedMeasure.create({
|
|
1033
|
+
isNull: false,
|
|
1034
|
+
value: p.y.toDocFrame()
|
|
1035
|
+
});
|
|
1036
|
+
}
|
|
1037
|
+
if (p.positionAbsolute !== void 0) {
|
|
1038
|
+
image.positionAbsolute = Proto23.ProtoBoxedBool.create({
|
|
1039
|
+
isNull: false,
|
|
1040
|
+
value: p.positionAbsolute
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
if (p.flip) {
|
|
1044
|
+
image.flipSettings = Proto23.ProtoFlipSettings.create({
|
|
1045
|
+
x: p.flip.x,
|
|
1046
|
+
y: p.flip.y
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
if (p.crop) {
|
|
1050
|
+
const cropSettings = {};
|
|
1051
|
+
if (p.crop.x) {
|
|
1052
|
+
cropSettings.x = Proto23.ProtoBoxedMeasure.create({
|
|
1053
|
+
isNull: false,
|
|
1054
|
+
value: p.crop.x.toDocFrame()
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
if (p.crop.y) {
|
|
1058
|
+
cropSettings.y = Proto23.ProtoBoxedMeasure.create({
|
|
1059
|
+
isNull: false,
|
|
1060
|
+
value: p.crop.y.toDocFrame()
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
if (p.crop.width) {
|
|
1064
|
+
cropSettings.width = Proto23.ProtoBoxedMeasure.create({
|
|
1065
|
+
isNull: false,
|
|
1066
|
+
value: p.crop.width.toDocFrame()
|
|
1067
|
+
});
|
|
1068
|
+
}
|
|
1069
|
+
if (p.crop.height) {
|
|
1070
|
+
cropSettings.height = Proto23.ProtoBoxedMeasure.create({
|
|
1071
|
+
isNull: false,
|
|
1072
|
+
value: p.crop.height.toDocFrame()
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
image.cropSettings = Proto23.ProtoCropSettings.create(cropSettings);
|
|
1076
|
+
}
|
|
1077
|
+
if (p.referencePoint) {
|
|
1078
|
+
image.referencePoint = referencePointToDocFrame(p.referencePoint);
|
|
1079
|
+
}
|
|
1080
|
+
if (p.scaleType) {
|
|
1081
|
+
image.scaleType = imageScaleTypeToDocFrame(p.scaleType);
|
|
1082
|
+
}
|
|
1083
|
+
return Proto23.Node.create({
|
|
1084
|
+
image: Proto23.ProtoImage.create(image)
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
// src/Content/Indentation/index.ts
|
|
1090
|
+
import Proto24 from "docframe-types";
|
|
1091
|
+
var Indentation = class extends BranchDocumentElement {
|
|
1092
|
+
constructor(content, props) {
|
|
1093
|
+
super(content, props);
|
|
1094
|
+
}
|
|
1095
|
+
toDocFrame() {
|
|
1096
|
+
var _a, _b, _c;
|
|
1097
|
+
const indent = {
|
|
1098
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid
|
|
1099
|
+
};
|
|
1100
|
+
if ((_b = this.props) == null ? void 0 : _b.left) {
|
|
1101
|
+
indent.left = Proto24.ProtoBoxedMeasure.create({
|
|
1102
|
+
isNull: false,
|
|
1103
|
+
value: this.props.left.toDocFrame()
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
if ((_c = this.props) == null ? void 0 : _c.right) {
|
|
1107
|
+
indent.right = Proto24.ProtoBoxedMeasure.create({
|
|
1108
|
+
isNull: false,
|
|
1109
|
+
value: this.props.right.toDocFrame()
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
return Proto24.Node.create({
|
|
1113
|
+
indentation: Proto24.ProtoIndentation.create(indent),
|
|
1114
|
+
children: this.childrenToDocFrame()
|
|
1115
|
+
});
|
|
1116
|
+
}
|
|
1117
|
+
};
|
|
1118
|
+
|
|
769
1119
|
// src/Content/Linebreak/index.ts
|
|
770
|
-
import
|
|
1120
|
+
import Proto25 from "docframe-types";
|
|
771
1121
|
var Linebreak = class extends DocumentElement {
|
|
772
1122
|
toDocFrame() {
|
|
773
|
-
return
|
|
774
|
-
linebreak:
|
|
1123
|
+
return Proto25.Node.create({
|
|
1124
|
+
linebreak: Proto25.ProtoLinebreak.create({})
|
|
1125
|
+
});
|
|
1126
|
+
}
|
|
1127
|
+
};
|
|
1128
|
+
|
|
1129
|
+
// src/Content/Link/index.ts
|
|
1130
|
+
import Proto26 from "docframe-types";
|
|
1131
|
+
var Link = class extends BranchDocumentElement {
|
|
1132
|
+
constructor(content, url) {
|
|
1133
|
+
super(content, url ? { url } : void 0);
|
|
1134
|
+
}
|
|
1135
|
+
toDocFrame() {
|
|
1136
|
+
var _a;
|
|
1137
|
+
return Proto26.Node.create({
|
|
1138
|
+
link: Proto26.ProtoLink.create({
|
|
1139
|
+
url: (_a = this.props) == null ? void 0 : _a.url
|
|
1140
|
+
}),
|
|
1141
|
+
children: this.childrenToDocFrame()
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
// src/Content/Loop/index.ts
|
|
1147
|
+
import Proto27 from "docframe-types";
|
|
1148
|
+
var Loop = class extends BranchDocumentElement {
|
|
1149
|
+
constructor(content, props) {
|
|
1150
|
+
super(content, props);
|
|
1151
|
+
}
|
|
1152
|
+
toDocFrame() {
|
|
1153
|
+
var _a, _b;
|
|
1154
|
+
return Proto27.Node.create({
|
|
1155
|
+
loop: Proto27.ProtoLoop.create({
|
|
1156
|
+
path: (_a = this.props) == null ? void 0 : _a.path,
|
|
1157
|
+
uuid: (_b = this.props) == null ? void 0 : _b.uuid
|
|
1158
|
+
}),
|
|
1159
|
+
children: this.childrenToDocFrame()
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1164
|
+
// src/Content/LoopEntry/index.ts
|
|
1165
|
+
import Proto28 from "docframe-types";
|
|
1166
|
+
var LoopEntry = class extends BranchDocumentElement {
|
|
1167
|
+
constructor(content, props) {
|
|
1168
|
+
super(content, props);
|
|
1169
|
+
}
|
|
1170
|
+
toDocFrame() {
|
|
1171
|
+
var _a, _b, _c;
|
|
1172
|
+
return Proto28.Node.create({
|
|
1173
|
+
loopEntry: Proto28.ProtoLoopEntry.create({
|
|
1174
|
+
path: (_a = this.props) == null ? void 0 : _a.path,
|
|
1175
|
+
index: (_b = this.props) == null ? void 0 : _b.index,
|
|
1176
|
+
uuid: (_c = this.props) == null ? void 0 : _c.uuid
|
|
1177
|
+
}),
|
|
1178
|
+
children: this.childrenToDocFrame()
|
|
775
1179
|
});
|
|
776
1180
|
}
|
|
777
1181
|
};
|
|
778
1182
|
|
|
779
1183
|
// src/Content/Pagebreak/index.ts
|
|
780
|
-
import
|
|
1184
|
+
import Proto29 from "docframe-types";
|
|
781
1185
|
var Pagebreak = class extends DocumentElement {
|
|
782
1186
|
toDocFrame() {
|
|
783
|
-
return
|
|
784
|
-
newPage:
|
|
1187
|
+
return Proto29.Node.create({
|
|
1188
|
+
newPage: Proto29.ProtoNewPage.create({})
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
|
|
1193
|
+
// src/Content/PageCondition/index.ts
|
|
1194
|
+
import Proto30 from "docframe-types";
|
|
1195
|
+
var PageCondition = class extends BranchDocumentElement {
|
|
1196
|
+
constructor(content, props) {
|
|
1197
|
+
super(content, props);
|
|
1198
|
+
}
|
|
1199
|
+
toDocFrame() {
|
|
1200
|
+
var _a, _b;
|
|
1201
|
+
return Proto30.Node.create({
|
|
1202
|
+
pageCondition: Proto30.ProtoPageCondition.create({
|
|
1203
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
1204
|
+
code: (_b = this.props) == null ? void 0 : _b.code
|
|
1205
|
+
}),
|
|
1206
|
+
children: this.childrenToDocFrame()
|
|
785
1207
|
});
|
|
786
1208
|
}
|
|
787
1209
|
};
|
|
788
1210
|
|
|
789
1211
|
// src/Content/Paragraph/index.ts
|
|
790
|
-
import
|
|
1212
|
+
import Proto31 from "docframe-types";
|
|
791
1213
|
var Paragraph = class extends BranchDocumentElement {
|
|
792
1214
|
constructor(content, paragraphFormatName, overwrite) {
|
|
793
1215
|
var _a;
|
|
@@ -802,62 +1224,243 @@ var Paragraph = class extends BranchDocumentElement {
|
|
|
802
1224
|
par.overwrite = this.props.overwrite.toDocFrame();
|
|
803
1225
|
}
|
|
804
1226
|
if (this.props.paragraphFormatName) {
|
|
805
|
-
par.format =
|
|
806
|
-
name:
|
|
1227
|
+
par.format = Proto31.ProtoParagraphFormat.create({
|
|
1228
|
+
name: Proto31.ProtoBoxedString.create({
|
|
807
1229
|
isNull: false,
|
|
808
1230
|
value: this.props.paragraphFormatName
|
|
809
1231
|
})
|
|
810
1232
|
});
|
|
811
1233
|
}
|
|
812
|
-
return
|
|
813
|
-
paragraph:
|
|
1234
|
+
return Proto31.Node.create({
|
|
1235
|
+
paragraph: Proto31.ProtoParagraph.create(par),
|
|
1236
|
+
children: this.childrenToDocFrame()
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
};
|
|
1240
|
+
|
|
1241
|
+
// src/Content/Rule/index.ts
|
|
1242
|
+
import Proto32 from "docframe-types";
|
|
1243
|
+
function ruleStyleToDocFrame(style) {
|
|
1244
|
+
switch (style) {
|
|
1245
|
+
case "solid":
|
|
1246
|
+
return Proto32.ProtoRuleStyle.SOLID;
|
|
1247
|
+
case "sparse-shading":
|
|
1248
|
+
return Proto32.ProtoRuleStyle.SPARSE_SHADING;
|
|
1249
|
+
case "medium-shading":
|
|
1250
|
+
return Proto32.ProtoRuleStyle.MEDIUM_SHADING;
|
|
1251
|
+
case "dense-shading":
|
|
1252
|
+
return Proto32.ProtoRuleStyle.DENSE_SHADING;
|
|
1253
|
+
case "light-dotted":
|
|
1254
|
+
return Proto32.ProtoRuleStyle.LIGHT_DOTTED;
|
|
1255
|
+
case "medium-dotted":
|
|
1256
|
+
return Proto32.ProtoRuleStyle.MEDIUM_DOTTED;
|
|
1257
|
+
case "heavy-dotted":
|
|
1258
|
+
return Proto32.ProtoRuleStyle.HEAVY_DOTTED;
|
|
1259
|
+
case "light-dashed":
|
|
1260
|
+
return Proto32.ProtoRuleStyle.LIGHT_DASHED;
|
|
1261
|
+
case "medium-dashed":
|
|
1262
|
+
return Proto32.ProtoRuleStyle.MEDIUM_DASHED;
|
|
1263
|
+
case "heavy-dashed":
|
|
1264
|
+
return Proto32.ProtoRuleStyle.HEAVY_DASHED;
|
|
1265
|
+
case "dash-pattern":
|
|
1266
|
+
return Proto32.ProtoRuleStyle.DASH_PATTERN;
|
|
1267
|
+
case "double":
|
|
1268
|
+
return Proto32.ProtoRuleStyle.DOUBLE;
|
|
1269
|
+
default:
|
|
1270
|
+
throw new Error(`Unknown rule style: ${style}`);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
function ruleModeToDocFrame(mode) {
|
|
1274
|
+
switch (mode) {
|
|
1275
|
+
case "normal":
|
|
1276
|
+
return Proto32.ProtoRuleMode.NORMAL;
|
|
1277
|
+
case "boundary":
|
|
1278
|
+
return Proto32.ProtoRuleMode.BOUNDARY;
|
|
1279
|
+
default:
|
|
1280
|
+
throw new Error(`Unknown rule mode: ${mode}`);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
var Rule = class extends DocumentElement {
|
|
1284
|
+
constructor(props) {
|
|
1285
|
+
super();
|
|
1286
|
+
this.props = props;
|
|
1287
|
+
}
|
|
1288
|
+
toDocFrame() {
|
|
1289
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1290
|
+
const rule = {
|
|
1291
|
+
xOffset: (_a = this.props.xOffset) == null ? void 0 : _a.toDocFrame(),
|
|
1292
|
+
yOffset: (_b = this.props.yOffset) == null ? void 0 : _b.toDocFrame(),
|
|
1293
|
+
width: (_c = this.props.width) == null ? void 0 : _c.toDocFrame(),
|
|
1294
|
+
thickness: (_d = this.props.thickness) == null ? void 0 : _d.toDocFrame(),
|
|
1295
|
+
rotation: this.props.rotation,
|
|
1296
|
+
color: (_e = this.props.color) == null ? void 0 : _e.toDocFrame()
|
|
1297
|
+
};
|
|
1298
|
+
if (this.props.style) {
|
|
1299
|
+
rule.style = ruleStyleToDocFrame(this.props.style);
|
|
1300
|
+
}
|
|
1301
|
+
if (this.props.mode) {
|
|
1302
|
+
rule.mode = ruleModeToDocFrame(this.props.mode);
|
|
1303
|
+
}
|
|
1304
|
+
if (this.props.boundaries) {
|
|
1305
|
+
rule.boundaries = Proto32.ProtoRuleBoundaries.create({
|
|
1306
|
+
start: (_f = this.props.boundaries.start) == null ? void 0 : _f.toDocFrame(),
|
|
1307
|
+
end: (_g = this.props.boundaries.end) == null ? void 0 : _g.toDocFrame()
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
return Proto32.Node.create({
|
|
1311
|
+
rule: Proto32.ProtoRule.create(rule)
|
|
1312
|
+
});
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
|
|
1316
|
+
// src/Content/Section/index.ts
|
|
1317
|
+
import Proto33 from "docframe-types";
|
|
1318
|
+
var Section = class extends BranchDocumentElement {
|
|
1319
|
+
constructor(content, props) {
|
|
1320
|
+
super(content, props);
|
|
1321
|
+
}
|
|
1322
|
+
toDocFrame() {
|
|
1323
|
+
var _a, _b;
|
|
1324
|
+
return Proto33.Node.create({
|
|
1325
|
+
section: Proto33.ProtoSection.create({
|
|
1326
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
1327
|
+
cDefUuid: (_b = this.props) == null ? void 0 : _b.cDefUuid
|
|
1328
|
+
}),
|
|
1329
|
+
children: this.childrenToDocFrame()
|
|
1330
|
+
});
|
|
1331
|
+
}
|
|
1332
|
+
};
|
|
1333
|
+
|
|
1334
|
+
// src/Content/Selection/index.ts
|
|
1335
|
+
import Proto34 from "docframe-types";
|
|
1336
|
+
var Selection = class extends BranchDocumentElement {
|
|
1337
|
+
constructor(content, props) {
|
|
1338
|
+
super(content, props);
|
|
1339
|
+
}
|
|
1340
|
+
toDocFrame() {
|
|
1341
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1342
|
+
return Proto34.Node.create({
|
|
1343
|
+
selection: Proto34.ProtoSelection.create({
|
|
1344
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
1345
|
+
internalName: (_b = this.props) == null ? void 0 : _b.internalName,
|
|
1346
|
+
name: (_c = this.props) == null ? void 0 : _c.name,
|
|
1347
|
+
multi: (_d = this.props) == null ? void 0 : _d.multi,
|
|
1348
|
+
min: (_e = this.props) == null ? void 0 : _e.min,
|
|
1349
|
+
max: (_f = this.props) == null ? void 0 : _f.max
|
|
1350
|
+
}),
|
|
1351
|
+
children: this.childrenToDocFrame()
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
};
|
|
1355
|
+
|
|
1356
|
+
// src/Content/SelectionEntry/index.ts
|
|
1357
|
+
import Proto35 from "docframe-types";
|
|
1358
|
+
var SelectionEntry = class extends BranchDocumentElement {
|
|
1359
|
+
constructor(content, props) {
|
|
1360
|
+
super(content, props);
|
|
1361
|
+
}
|
|
1362
|
+
toDocFrame() {
|
|
1363
|
+
var _a, _b, _c, _d;
|
|
1364
|
+
return Proto35.Node.create({
|
|
1365
|
+
selectionEntry: Proto35.ProtoSelectionEntry.create({
|
|
1366
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid,
|
|
1367
|
+
internalName: (_b = this.props) == null ? void 0 : _b.internalName,
|
|
1368
|
+
name: (_c = this.props) == null ? void 0 : _c.name,
|
|
1369
|
+
selected: (_d = this.props) == null ? void 0 : _d.selected
|
|
1370
|
+
}),
|
|
814
1371
|
children: this.childrenToDocFrame()
|
|
815
1372
|
});
|
|
816
1373
|
}
|
|
817
1374
|
};
|
|
818
1375
|
|
|
819
1376
|
// src/Content/Span/index.ts
|
|
820
|
-
import
|
|
1377
|
+
import Proto36 from "docframe-types";
|
|
821
1378
|
var Span = class extends BranchDocumentElement {
|
|
822
1379
|
constructor(content, props) {
|
|
823
1380
|
super(content, props || {});
|
|
824
1381
|
}
|
|
825
1382
|
toDocFrame() {
|
|
826
|
-
var _a, _b, _c, _d;
|
|
1383
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
827
1384
|
let bold = void 0;
|
|
828
1385
|
if (((_a = this.props) == null ? void 0 : _a.bold) !== void 0) {
|
|
829
|
-
bold =
|
|
1386
|
+
bold = Proto36.ProtoBoxedBool.create({
|
|
830
1387
|
isNull: false,
|
|
831
1388
|
value: this.props.bold
|
|
832
1389
|
});
|
|
833
1390
|
}
|
|
834
1391
|
let italic = void 0;
|
|
835
1392
|
if (((_b = this.props) == null ? void 0 : _b.italic) !== void 0) {
|
|
836
|
-
italic =
|
|
1393
|
+
italic = Proto36.ProtoBoxedBool.create({
|
|
837
1394
|
isNull: false,
|
|
838
1395
|
value: this.props.italic
|
|
839
1396
|
});
|
|
840
1397
|
}
|
|
841
1398
|
let underline = void 0;
|
|
842
1399
|
if (((_c = this.props) == null ? void 0 : _c.underline) !== void 0) {
|
|
843
|
-
underline =
|
|
1400
|
+
underline = Proto36.ProtoBoxedBool.create({
|
|
844
1401
|
isNull: false,
|
|
845
1402
|
value: this.props.underline
|
|
846
1403
|
});
|
|
847
1404
|
}
|
|
848
1405
|
let strikethrough = void 0;
|
|
849
1406
|
if (((_d = this.props) == null ? void 0 : _d.strikethrough) !== void 0) {
|
|
850
|
-
strikethrough =
|
|
1407
|
+
strikethrough = Proto36.ProtoBoxedBool.create({
|
|
851
1408
|
isNull: false,
|
|
852
1409
|
value: this.props.strikethrough
|
|
853
1410
|
});
|
|
854
1411
|
}
|
|
855
|
-
|
|
856
|
-
|
|
1412
|
+
let subscript = void 0;
|
|
1413
|
+
if (((_e = this.props) == null ? void 0 : _e.subscript) !== void 0) {
|
|
1414
|
+
subscript = Proto36.ProtoBoxedBool.create({
|
|
1415
|
+
isNull: false,
|
|
1416
|
+
value: this.props.subscript
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
let superscript = void 0;
|
|
1420
|
+
if (((_f = this.props) == null ? void 0 : _f.superscript) !== void 0) {
|
|
1421
|
+
superscript = Proto36.ProtoBoxedBool.create({
|
|
1422
|
+
isNull: false,
|
|
1423
|
+
value: this.props.superscript
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
return Proto36.Node.create({
|
|
1427
|
+
span: Proto36.ProtoSpan.create({
|
|
857
1428
|
bold,
|
|
858
1429
|
italic,
|
|
859
1430
|
underline,
|
|
860
|
-
strikethrough
|
|
1431
|
+
strikethrough,
|
|
1432
|
+
color: (_h = (_g = this.props) == null ? void 0 : _g.color) == null ? void 0 : _h.toDocFrame(),
|
|
1433
|
+
subscript,
|
|
1434
|
+
superscript
|
|
1435
|
+
}),
|
|
1436
|
+
children: this.childrenToDocFrame()
|
|
1437
|
+
});
|
|
1438
|
+
}
|
|
1439
|
+
};
|
|
1440
|
+
|
|
1441
|
+
// src/Content/SubTotal/index.ts
|
|
1442
|
+
import Proto37 from "docframe-types";
|
|
1443
|
+
function subTotalPositionToDocFrame(pos) {
|
|
1444
|
+
switch (pos) {
|
|
1445
|
+
case "above-footer":
|
|
1446
|
+
return Proto37.ProtoSubTotalPosition.POSITION_ABOVE_FOOTER;
|
|
1447
|
+
case "below-content":
|
|
1448
|
+
return Proto37.ProtoSubTotalPosition.POSITION_BELOW_CONTENT;
|
|
1449
|
+
default:
|
|
1450
|
+
throw new Error(`Unknown sub total position: ${pos}`);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
var SubTotal = class extends BranchDocumentElement {
|
|
1454
|
+
constructor(content, props) {
|
|
1455
|
+
super(content, props);
|
|
1456
|
+
}
|
|
1457
|
+
toDocFrame() {
|
|
1458
|
+
var _a, _b, _c, _d;
|
|
1459
|
+
return Proto37.Node.create({
|
|
1460
|
+
subTotal: Proto37.ProtoSubTotal.create({
|
|
1461
|
+
applyImmediate: (_a = this.props) == null ? void 0 : _a.applyImmediate,
|
|
1462
|
+
position: ((_b = this.props) == null ? void 0 : _b.position) ? subTotalPositionToDocFrame(this.props.position) : void 0,
|
|
1463
|
+
height: (_d = (_c = this.props) == null ? void 0 : _c.height) == null ? void 0 : _d.toDocFrame()
|
|
861
1464
|
}),
|
|
862
1465
|
children: this.childrenToDocFrame()
|
|
863
1466
|
});
|
|
@@ -865,7 +1468,7 @@ var Span = class extends BranchDocumentElement {
|
|
|
865
1468
|
};
|
|
866
1469
|
|
|
867
1470
|
// src/Content/Table/index.ts
|
|
868
|
-
import
|
|
1471
|
+
import Proto38 from "docframe-types";
|
|
869
1472
|
var Table = class extends BranchDocumentElement {
|
|
870
1473
|
constructor(content, props) {
|
|
871
1474
|
super(content, props || {});
|
|
@@ -876,16 +1479,23 @@ var Table = class extends BranchDocumentElement {
|
|
|
876
1479
|
toDocFrame() {
|
|
877
1480
|
var _a, _b;
|
|
878
1481
|
const props = this.props;
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
1482
|
+
const settings = {
|
|
1483
|
+
width: (_a = props.width) == null ? void 0 : _a.toDocFrame(),
|
|
1484
|
+
xOffset: (_b = props.xOffset) == null ? void 0 : _b.toDocFrame(),
|
|
1485
|
+
leftMeasure: Proto38.ProtoBoxedBool.create({
|
|
1486
|
+
isNull: false,
|
|
1487
|
+
value: props.leftMeasure ?? false
|
|
1488
|
+
})
|
|
1489
|
+
};
|
|
1490
|
+
if (props.repeatHeader !== void 0) {
|
|
1491
|
+
settings.repeatHeader = Proto38.ProtoBoxedUint32.create({
|
|
1492
|
+
isNull: false,
|
|
1493
|
+
value: props.repeatHeader
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1496
|
+
return Proto38.Node.create({
|
|
1497
|
+
table: Proto38.ProtoTable.create({
|
|
1498
|
+
settings: Proto38.ProtoTableSettings.create(settings)
|
|
889
1499
|
}),
|
|
890
1500
|
children: this.childrenToDocFrame()
|
|
891
1501
|
});
|
|
@@ -893,7 +1503,7 @@ var Table = class extends BranchDocumentElement {
|
|
|
893
1503
|
};
|
|
894
1504
|
|
|
895
1505
|
// src/Content/TableCell/index.ts
|
|
896
|
-
import
|
|
1506
|
+
import Proto39 from "docframe-types";
|
|
897
1507
|
var TableCell = class extends BranchDocumentElement {
|
|
898
1508
|
constructor(content, props) {
|
|
899
1509
|
super(content, props || {});
|
|
@@ -901,23 +1511,53 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
901
1511
|
toDocFrame() {
|
|
902
1512
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
903
1513
|
const props = this.props;
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1514
|
+
const settings = {
|
|
1515
|
+
align: Proto39.ProtoBoxedHorizontalAlignment.create({
|
|
1516
|
+
isNull: false,
|
|
1517
|
+
value: ((_a = props.alignment) == null ? void 0 : _a.toDocFrame()) || Proto39.ProtoHorizontalAlignment.ALIGN_LEFT
|
|
1518
|
+
}),
|
|
1519
|
+
backgroundColor: (_b = props.backgroundColor) == null ? void 0 : _b.toDocFrame(),
|
|
1520
|
+
border: (_c = props.border) == null ? void 0 : _c.toDocFrame(),
|
|
1521
|
+
margin: (_d = props.margin) == null ? void 0 : _d.toDocFrame(),
|
|
1522
|
+
padding: (_e = props.padding) == null ? void 0 : _e.toDocFrame(),
|
|
1523
|
+
valign: Proto39.ProtoBoxedVerticalAlignment.create({
|
|
1524
|
+
isNull: false,
|
|
1525
|
+
value: ((_f = props.verticalAlignment) == null ? void 0 : _f.toDocFrame()) || Proto39.ProtoVerticalAlignment.TOP
|
|
1526
|
+
}),
|
|
1527
|
+
width: (_g = props.width) == null ? void 0 : _g.toDocFrame()
|
|
1528
|
+
};
|
|
1529
|
+
if (props.rotation !== void 0) {
|
|
1530
|
+
settings.rotation = Proto39.ProtoBoxedDouble.create({
|
|
1531
|
+
isNull: false,
|
|
1532
|
+
value: props.rotation
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
if (props.defaultParagraphFormat !== void 0) {
|
|
1536
|
+
settings.defaultParagraphFormat = Proto39.ProtoBoxedString.create({
|
|
1537
|
+
isNull: false,
|
|
1538
|
+
value: props.defaultParagraphFormat
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
return Proto39.Node.create({
|
|
1542
|
+
tableCell: Proto39.ProtoTableCell.create({
|
|
1543
|
+
settings: Proto39.ProtoTableCellSettings.create(settings)
|
|
1544
|
+
}),
|
|
1545
|
+
children: this.childrenToDocFrame()
|
|
1546
|
+
});
|
|
1547
|
+
}
|
|
1548
|
+
};
|
|
1549
|
+
|
|
1550
|
+
// src/Content/TableContentGroup/index.ts
|
|
1551
|
+
import Proto40 from "docframe-types";
|
|
1552
|
+
var TableContentGroup = class extends BranchDocumentElement {
|
|
1553
|
+
constructor(content, props) {
|
|
1554
|
+
super(content, props);
|
|
1555
|
+
}
|
|
1556
|
+
toDocFrame() {
|
|
1557
|
+
var _a;
|
|
1558
|
+
return Proto40.Node.create({
|
|
1559
|
+
tableContentGroup: Proto40.ProtoTableContentGroup.create({
|
|
1560
|
+
uuid: (_a = this.props) == null ? void 0 : _a.uuid
|
|
921
1561
|
}),
|
|
922
1562
|
children: this.childrenToDocFrame()
|
|
923
1563
|
});
|
|
@@ -925,16 +1565,16 @@ var TableCell = class extends BranchDocumentElement {
|
|
|
925
1565
|
};
|
|
926
1566
|
|
|
927
1567
|
// src/Content/TableRow/index.ts
|
|
928
|
-
import
|
|
1568
|
+
import Proto41 from "docframe-types";
|
|
929
1569
|
var TableRow = class extends BranchDocumentElement {
|
|
930
1570
|
constructor(content, props) {
|
|
931
1571
|
super(content, props || {});
|
|
932
1572
|
}
|
|
933
1573
|
toDocFrame() {
|
|
934
1574
|
var _a;
|
|
935
|
-
return
|
|
936
|
-
tableRow:
|
|
937
|
-
settings:
|
|
1575
|
+
return Proto41.Node.create({
|
|
1576
|
+
tableRow: Proto41.ProtoTableRow.create({
|
|
1577
|
+
settings: Proto41.ProtoTableRowSettings.create({
|
|
938
1578
|
minHeight: (_a = this.props.minHeight) == null ? void 0 : _a.toDocFrame()
|
|
939
1579
|
})
|
|
940
1580
|
}),
|
|
@@ -943,30 +1583,128 @@ var TableRow = class extends BranchDocumentElement {
|
|
|
943
1583
|
}
|
|
944
1584
|
};
|
|
945
1585
|
|
|
1586
|
+
// src/Content/Tag/index.ts
|
|
1587
|
+
import Proto42 from "docframe-types";
|
|
1588
|
+
var Tag = class extends DocumentElement {
|
|
1589
|
+
constructor(props) {
|
|
1590
|
+
super();
|
|
1591
|
+
this.props = props;
|
|
1592
|
+
}
|
|
1593
|
+
toDocFrame() {
|
|
1594
|
+
return Proto42.Node.create({
|
|
1595
|
+
tag: Proto42.ProtoTag.create({
|
|
1596
|
+
name: this.props.name,
|
|
1597
|
+
uuid: this.props.uuid,
|
|
1598
|
+
params: this.props.params,
|
|
1599
|
+
nameCode: this.props.nameCode,
|
|
1600
|
+
codeMode: this.props.codeMode
|
|
1601
|
+
})
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
};
|
|
1605
|
+
|
|
1606
|
+
// src/Content/Variable/index.ts
|
|
1607
|
+
import Proto43 from "docframe-types";
|
|
1608
|
+
function specialTypeToDocFrame(type) {
|
|
1609
|
+
switch (type) {
|
|
1610
|
+
case "table-number":
|
|
1611
|
+
return Proto43.ProtoVariableSpecialType.TABLE_NUMBER;
|
|
1612
|
+
case "doc-page-count":
|
|
1613
|
+
return Proto43.ProtoVariableSpecialType.DOC_PAGE_COUNT;
|
|
1614
|
+
case "doc-cur-page":
|
|
1615
|
+
return Proto43.ProtoVariableSpecialType.DOC_CUR_PAGE;
|
|
1616
|
+
case "cur-page":
|
|
1617
|
+
return Proto43.ProtoVariableSpecialType.CUR_PAGE;
|
|
1618
|
+
case "page-count":
|
|
1619
|
+
return Proto43.ProtoVariableSpecialType.PAGE_COUNT;
|
|
1620
|
+
case "prev-page":
|
|
1621
|
+
return Proto43.ProtoVariableSpecialType.PREV_PAGE;
|
|
1622
|
+
case "section-page":
|
|
1623
|
+
return Proto43.ProtoVariableSpecialType.SECTION_PAGE;
|
|
1624
|
+
case "updated-at":
|
|
1625
|
+
return Proto43.ProtoVariableSpecialType.UPDATED_AT;
|
|
1626
|
+
case "generated-at":
|
|
1627
|
+
return Proto43.ProtoVariableSpecialType.GENERATED_AT;
|
|
1628
|
+
default:
|
|
1629
|
+
throw new Error(`Unknown variable special type: ${type}`);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
var Variable = class extends DocumentElement {
|
|
1633
|
+
constructor(props) {
|
|
1634
|
+
super();
|
|
1635
|
+
this.props = props;
|
|
1636
|
+
}
|
|
1637
|
+
toDocFrame() {
|
|
1638
|
+
return Proto43.Node.create({
|
|
1639
|
+
variable: Proto43.ProtoVariable.create({
|
|
1640
|
+
path: this.props.path,
|
|
1641
|
+
content: this.props.content,
|
|
1642
|
+
formatUuid: this.props.formatUuid,
|
|
1643
|
+
specialType: this.props.specialType ? specialTypeToDocFrame(this.props.specialType) : void 0,
|
|
1644
|
+
uuid: this.props.uuid
|
|
1645
|
+
})
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
|
|
1650
|
+
// src/Content/WsArea/index.ts
|
|
1651
|
+
import Proto44 from "docframe-types";
|
|
1652
|
+
var WsArea = class extends BranchDocumentElement {
|
|
1653
|
+
constructor(content) {
|
|
1654
|
+
super(content);
|
|
1655
|
+
}
|
|
1656
|
+
toDocFrame() {
|
|
1657
|
+
return Proto44.Node.create({
|
|
1658
|
+
wsArea: Proto44.ProtoWsArea.create({}),
|
|
1659
|
+
children: this.childrenToDocFrame()
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
|
|
946
1664
|
// src/Content/index.ts
|
|
947
1665
|
var Content_default = {
|
|
1666
|
+
AdjustHorizontally,
|
|
1667
|
+
AdvancedIllustrationArea,
|
|
948
1668
|
Barcode,
|
|
1669
|
+
CarryOver,
|
|
949
1670
|
ColumnDefinition,
|
|
950
1671
|
ColumnPosition,
|
|
1672
|
+
Condition,
|
|
951
1673
|
Directory,
|
|
952
1674
|
Document,
|
|
953
1675
|
Footer,
|
|
954
1676
|
Formatted,
|
|
955
1677
|
Header,
|
|
1678
|
+
Image,
|
|
1679
|
+
Indentation,
|
|
956
1680
|
Linebreak,
|
|
1681
|
+
Link,
|
|
1682
|
+
Loop,
|
|
1683
|
+
LoopEntry,
|
|
957
1684
|
Pagebreak,
|
|
1685
|
+
PageCondition,
|
|
958
1686
|
PageDefinition,
|
|
959
1687
|
Paragraph,
|
|
1688
|
+
Rule,
|
|
1689
|
+
Section,
|
|
1690
|
+
Selection,
|
|
1691
|
+
SelectionEntry,
|
|
960
1692
|
SpaceVertically,
|
|
961
1693
|
Span,
|
|
1694
|
+
SubTotal,
|
|
962
1695
|
Table,
|
|
963
1696
|
TableCell,
|
|
1697
|
+
TableContentGroup,
|
|
964
1698
|
TableRow,
|
|
965
|
-
|
|
1699
|
+
Tag,
|
|
1700
|
+
Text,
|
|
1701
|
+
Variable,
|
|
1702
|
+
WsArea
|
|
966
1703
|
};
|
|
967
1704
|
|
|
968
1705
|
// src/index.ts
|
|
969
1706
|
var index_default = {
|
|
1707
|
+
Alignment,
|
|
970
1708
|
Border: {
|
|
971
1709
|
Border,
|
|
972
1710
|
SideBorders
|