ducjs 2.2.3 → 2.3.0
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/dist/flatbuffers/duc/document-grid-align-items.d.ts +5 -0
- package/dist/flatbuffers/duc/document-grid-align-items.js +8 -0
- package/dist/flatbuffers/duc/document-grid-config.d.ts +22 -0
- package/dist/flatbuffers/duc/document-grid-config.js +73 -0
- package/dist/flatbuffers/duc/duc-doc-element.d.ts +6 -0
- package/dist/flatbuffers/duc/duc-doc-element.js +16 -1
- package/dist/flatbuffers/duc/duc-model-element.d.ts +26 -0
- package/dist/flatbuffers/duc/duc-model-element.js +79 -0
- package/dist/flatbuffers/duc/duc-pdf-element.d.ts +3 -1
- package/dist/flatbuffers/duc/duc-pdf-element.js +9 -7
- package/dist/flatbuffers/duc/element.d.ts +5 -3
- package/dist/flatbuffers/duc/element.js +4 -0
- package/dist/flatbuffers/duc.d.ts +3 -0
- package/dist/flatbuffers/duc.js +3 -0
- package/dist/parse.d.ts +3 -2
- package/dist/parse.js +41 -14
- package/dist/restore/restoreDataState.d.ts +1 -6
- package/dist/restore/restoreDataState.js +4 -11
- package/dist/restore/restoreElements.js +39 -25
- package/dist/serialize.js +55 -27
- package/dist/types/elements/index.d.ts +28 -27
- package/dist/types/elements/typeChecks.js +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.js +1 -1
- package/dist/utils/elements/newElement.d.ts +2 -2
- package/dist/utils/elements/newElement.js +4 -4
- package/package.json +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
3
|
+
export var DOCUMENT_GRID_ALIGN_ITEMS;
|
|
4
|
+
(function (DOCUMENT_GRID_ALIGN_ITEMS) {
|
|
5
|
+
DOCUMENT_GRID_ALIGN_ITEMS[DOCUMENT_GRID_ALIGN_ITEMS["START"] = 10] = "START";
|
|
6
|
+
DOCUMENT_GRID_ALIGN_ITEMS[DOCUMENT_GRID_ALIGN_ITEMS["CENTER"] = 11] = "CENTER";
|
|
7
|
+
DOCUMENT_GRID_ALIGN_ITEMS[DOCUMENT_GRID_ALIGN_ITEMS["END"] = 12] = "END";
|
|
8
|
+
})(DOCUMENT_GRID_ALIGN_ITEMS || (DOCUMENT_GRID_ALIGN_ITEMS = {}));
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as flatbuffers from 'flatbuffers';
|
|
2
|
+
import { DOCUMENT_GRID_ALIGN_ITEMS } from '../duc/document-grid-align-items';
|
|
3
|
+
export declare class DocumentGridConfig {
|
|
4
|
+
bb: flatbuffers.ByteBuffer | null;
|
|
5
|
+
bb_pos: number;
|
|
6
|
+
__init(i: number, bb: flatbuffers.ByteBuffer): DocumentGridConfig;
|
|
7
|
+
static getRootAsDocumentGridConfig(bb: flatbuffers.ByteBuffer, obj?: DocumentGridConfig): DocumentGridConfig;
|
|
8
|
+
static getSizePrefixedRootAsDocumentGridConfig(bb: flatbuffers.ByteBuffer, obj?: DocumentGridConfig): DocumentGridConfig;
|
|
9
|
+
columns(): number;
|
|
10
|
+
gapX(): number;
|
|
11
|
+
gapY(): number;
|
|
12
|
+
alignItems(): DOCUMENT_GRID_ALIGN_ITEMS | null;
|
|
13
|
+
firstPageAlone(): boolean;
|
|
14
|
+
static startDocumentGridConfig(builder: flatbuffers.Builder): void;
|
|
15
|
+
static addColumns(builder: flatbuffers.Builder, columns: number): void;
|
|
16
|
+
static addGapX(builder: flatbuffers.Builder, gapX: number): void;
|
|
17
|
+
static addGapY(builder: flatbuffers.Builder, gapY: number): void;
|
|
18
|
+
static addAlignItems(builder: flatbuffers.Builder, alignItems: DOCUMENT_GRID_ALIGN_ITEMS): void;
|
|
19
|
+
static addFirstPageAlone(builder: flatbuffers.Builder, firstPageAlone: boolean): void;
|
|
20
|
+
static endDocumentGridConfig(builder: flatbuffers.Builder): flatbuffers.Offset;
|
|
21
|
+
static createDocumentGridConfig(builder: flatbuffers.Builder, columns: number, gapX: number, gapY: number, alignItems: DOCUMENT_GRID_ALIGN_ITEMS | null, firstPageAlone: boolean): flatbuffers.Offset;
|
|
22
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
3
|
+
import * as flatbuffers from 'flatbuffers';
|
|
4
|
+
export class DocumentGridConfig {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.bb = null;
|
|
7
|
+
this.bb_pos = 0;
|
|
8
|
+
}
|
|
9
|
+
__init(i, bb) {
|
|
10
|
+
this.bb_pos = i;
|
|
11
|
+
this.bb = bb;
|
|
12
|
+
return this;
|
|
13
|
+
}
|
|
14
|
+
static getRootAsDocumentGridConfig(bb, obj) {
|
|
15
|
+
return (obj || new DocumentGridConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
16
|
+
}
|
|
17
|
+
static getSizePrefixedRootAsDocumentGridConfig(bb, obj) {
|
|
18
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
|
19
|
+
return (obj || new DocumentGridConfig()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
20
|
+
}
|
|
21
|
+
columns() {
|
|
22
|
+
const offset = this.bb.__offset(this.bb_pos, 4);
|
|
23
|
+
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
|
|
24
|
+
}
|
|
25
|
+
gapX() {
|
|
26
|
+
const offset = this.bb.__offset(this.bb_pos, 6);
|
|
27
|
+
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
|
|
28
|
+
}
|
|
29
|
+
gapY() {
|
|
30
|
+
const offset = this.bb.__offset(this.bb_pos, 8);
|
|
31
|
+
return offset ? this.bb.readFloat64(this.bb_pos + offset) : 0.0;
|
|
32
|
+
}
|
|
33
|
+
alignItems() {
|
|
34
|
+
const offset = this.bb.__offset(this.bb_pos, 10);
|
|
35
|
+
return offset ? this.bb.readUint8(this.bb_pos + offset) : null;
|
|
36
|
+
}
|
|
37
|
+
firstPageAlone() {
|
|
38
|
+
const offset = this.bb.__offset(this.bb_pos, 12);
|
|
39
|
+
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
|
40
|
+
}
|
|
41
|
+
static startDocumentGridConfig(builder) {
|
|
42
|
+
builder.startObject(5);
|
|
43
|
+
}
|
|
44
|
+
static addColumns(builder, columns) {
|
|
45
|
+
builder.addFieldInt32(0, columns, 0);
|
|
46
|
+
}
|
|
47
|
+
static addGapX(builder, gapX) {
|
|
48
|
+
builder.addFieldFloat64(1, gapX, 0.0);
|
|
49
|
+
}
|
|
50
|
+
static addGapY(builder, gapY) {
|
|
51
|
+
builder.addFieldFloat64(2, gapY, 0.0);
|
|
52
|
+
}
|
|
53
|
+
static addAlignItems(builder, alignItems) {
|
|
54
|
+
builder.addFieldInt8(3, alignItems, null);
|
|
55
|
+
}
|
|
56
|
+
static addFirstPageAlone(builder, firstPageAlone) {
|
|
57
|
+
builder.addFieldInt8(4, +firstPageAlone, +false);
|
|
58
|
+
}
|
|
59
|
+
static endDocumentGridConfig(builder) {
|
|
60
|
+
const offset = builder.endObject();
|
|
61
|
+
return offset;
|
|
62
|
+
}
|
|
63
|
+
static createDocumentGridConfig(builder, columns, gapX, gapY, alignItems, firstPageAlone) {
|
|
64
|
+
DocumentGridConfig.startDocumentGridConfig(builder);
|
|
65
|
+
DocumentGridConfig.addColumns(builder, columns);
|
|
66
|
+
DocumentGridConfig.addGapX(builder, gapX);
|
|
67
|
+
DocumentGridConfig.addGapY(builder, gapY);
|
|
68
|
+
if (alignItems !== null)
|
|
69
|
+
DocumentGridConfig.addAlignItems(builder, alignItems);
|
|
70
|
+
DocumentGridConfig.addFirstPageAlone(builder, firstPageAlone);
|
|
71
|
+
return DocumentGridConfig.endDocumentGridConfig(builder);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as flatbuffers from 'flatbuffers';
|
|
2
2
|
import { ColumnLayout } from '../duc/column-layout';
|
|
3
|
+
import { DocumentGridConfig } from '../duc/document-grid-config';
|
|
3
4
|
import { DucDocStyle } from '../duc/duc-doc-style';
|
|
4
5
|
import { DucTextDynamicPart } from '../duc/duc-text-dynamic-part';
|
|
5
6
|
import { TEXT_FLOW_DIRECTION } from '../duc/text-flow-direction';
|
|
@@ -19,6 +20,9 @@ export declare class DucDocElement {
|
|
|
19
20
|
flowDirection(): TEXT_FLOW_DIRECTION | null;
|
|
20
21
|
columns(obj?: ColumnLayout): ColumnLayout | null;
|
|
21
22
|
autoResize(): boolean;
|
|
23
|
+
gridConfig(obj?: DocumentGridConfig): DocumentGridConfig | null;
|
|
24
|
+
fileId(): string | null;
|
|
25
|
+
fileId(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
|
22
26
|
static startDucDocElement(builder: flatbuffers.Builder): void;
|
|
23
27
|
static addBase(builder: flatbuffers.Builder, baseOffset: flatbuffers.Offset): void;
|
|
24
28
|
static addStyle(builder: flatbuffers.Builder, styleOffset: flatbuffers.Offset): void;
|
|
@@ -29,5 +33,7 @@ export declare class DucDocElement {
|
|
|
29
33
|
static addFlowDirection(builder: flatbuffers.Builder, flowDirection: TEXT_FLOW_DIRECTION): void;
|
|
30
34
|
static addColumns(builder: flatbuffers.Builder, columnsOffset: flatbuffers.Offset): void;
|
|
31
35
|
static addAutoResize(builder: flatbuffers.Builder, autoResize: boolean): void;
|
|
36
|
+
static addGridConfig(builder: flatbuffers.Builder, gridConfigOffset: flatbuffers.Offset): void;
|
|
37
|
+
static addFileId(builder: flatbuffers.Builder, fileIdOffset: flatbuffers.Offset): void;
|
|
32
38
|
static endDucDocElement(builder: flatbuffers.Builder): flatbuffers.Offset;
|
|
33
39
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
3
3
|
import * as flatbuffers from 'flatbuffers';
|
|
4
4
|
import { ColumnLayout } from '../duc/column-layout';
|
|
5
|
+
import { DocumentGridConfig } from '../duc/document-grid-config';
|
|
5
6
|
import { DucDocStyle } from '../duc/duc-doc-style';
|
|
6
7
|
import { DucTextDynamicPart } from '../duc/duc-text-dynamic-part';
|
|
7
8
|
import { _DucElementBase } from '../duc/duc-element-base';
|
|
@@ -54,8 +55,16 @@ export class DucDocElement {
|
|
|
54
55
|
const offset = this.bb.__offset(this.bb_pos, 16);
|
|
55
56
|
return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false;
|
|
56
57
|
}
|
|
58
|
+
gridConfig(obj) {
|
|
59
|
+
const offset = this.bb.__offset(this.bb_pos, 18);
|
|
60
|
+
return offset ? (obj || new DocumentGridConfig()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
|
61
|
+
}
|
|
62
|
+
fileId(optionalEncoding) {
|
|
63
|
+
const offset = this.bb.__offset(this.bb_pos, 20);
|
|
64
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
|
65
|
+
}
|
|
57
66
|
static startDucDocElement(builder) {
|
|
58
|
-
builder.startObject(
|
|
67
|
+
builder.startObject(9);
|
|
59
68
|
}
|
|
60
69
|
static addBase(builder, baseOffset) {
|
|
61
70
|
builder.addFieldOffset(0, baseOffset, 0);
|
|
@@ -88,6 +97,12 @@ export class DucDocElement {
|
|
|
88
97
|
static addAutoResize(builder, autoResize) {
|
|
89
98
|
builder.addFieldInt8(6, +autoResize, +false);
|
|
90
99
|
}
|
|
100
|
+
static addGridConfig(builder, gridConfigOffset) {
|
|
101
|
+
builder.addFieldOffset(7, gridConfigOffset, 0);
|
|
102
|
+
}
|
|
103
|
+
static addFileId(builder, fileIdOffset) {
|
|
104
|
+
builder.addFieldOffset(8, fileIdOffset, 0);
|
|
105
|
+
}
|
|
91
106
|
static endDucDocElement(builder) {
|
|
92
107
|
const offset = builder.endObject();
|
|
93
108
|
return offset;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as flatbuffers from 'flatbuffers';
|
|
2
|
+
import { _DucElementBase } from '../duc/duc-element-base';
|
|
3
|
+
export declare class DucModelElement {
|
|
4
|
+
bb: flatbuffers.ByteBuffer | null;
|
|
5
|
+
bb_pos: number;
|
|
6
|
+
__init(i: number, bb: flatbuffers.ByteBuffer): DucModelElement;
|
|
7
|
+
static getRootAsDucModelElement(bb: flatbuffers.ByteBuffer, obj?: DucModelElement): DucModelElement;
|
|
8
|
+
static getSizePrefixedRootAsDucModelElement(bb: flatbuffers.ByteBuffer, obj?: DucModelElement): DucModelElement;
|
|
9
|
+
base(obj?: _DucElementBase): _DucElementBase | null;
|
|
10
|
+
source(): string | null;
|
|
11
|
+
source(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
|
12
|
+
svgPath(): string | null;
|
|
13
|
+
svgPath(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
|
14
|
+
fileIds(index: number): string;
|
|
15
|
+
fileIds(index: number, optionalEncoding: flatbuffers.Encoding): string | Uint8Array;
|
|
16
|
+
fileIdsLength(): number;
|
|
17
|
+
static startDucModelElement(builder: flatbuffers.Builder): void;
|
|
18
|
+
static addBase(builder: flatbuffers.Builder, baseOffset: flatbuffers.Offset): void;
|
|
19
|
+
static addSource(builder: flatbuffers.Builder, sourceOffset: flatbuffers.Offset): void;
|
|
20
|
+
static addSvgPath(builder: flatbuffers.Builder, svgPathOffset: flatbuffers.Offset): void;
|
|
21
|
+
static addFileIds(builder: flatbuffers.Builder, fileIdsOffset: flatbuffers.Offset): void;
|
|
22
|
+
static createFileIdsVector(builder: flatbuffers.Builder, data: flatbuffers.Offset[]): flatbuffers.Offset;
|
|
23
|
+
static startFileIdsVector(builder: flatbuffers.Builder, numElems: number): void;
|
|
24
|
+
static endDucModelElement(builder: flatbuffers.Builder): flatbuffers.Offset;
|
|
25
|
+
static createDucModelElement(builder: flatbuffers.Builder, baseOffset: flatbuffers.Offset, sourceOffset: flatbuffers.Offset, svgPathOffset: flatbuffers.Offset, fileIdsOffset: flatbuffers.Offset): flatbuffers.Offset;
|
|
26
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
3
|
+
import * as flatbuffers from 'flatbuffers';
|
|
4
|
+
import { _DucElementBase } from '../duc/duc-element-base';
|
|
5
|
+
export class DucModelElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
this.bb = null;
|
|
8
|
+
this.bb_pos = 0;
|
|
9
|
+
}
|
|
10
|
+
__init(i, bb) {
|
|
11
|
+
this.bb_pos = i;
|
|
12
|
+
this.bb = bb;
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
static getRootAsDucModelElement(bb, obj) {
|
|
16
|
+
return (obj || new DucModelElement()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
17
|
+
}
|
|
18
|
+
static getSizePrefixedRootAsDucModelElement(bb, obj) {
|
|
19
|
+
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
|
|
20
|
+
return (obj || new DucModelElement()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
|
|
21
|
+
}
|
|
22
|
+
base(obj) {
|
|
23
|
+
const offset = this.bb.__offset(this.bb_pos, 4);
|
|
24
|
+
return offset ? (obj || new _DucElementBase()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
|
25
|
+
}
|
|
26
|
+
source(optionalEncoding) {
|
|
27
|
+
const offset = this.bb.__offset(this.bb_pos, 6);
|
|
28
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
|
29
|
+
}
|
|
30
|
+
svgPath(optionalEncoding) {
|
|
31
|
+
const offset = this.bb.__offset(this.bb_pos, 8);
|
|
32
|
+
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
|
33
|
+
}
|
|
34
|
+
fileIds(index, optionalEncoding) {
|
|
35
|
+
const offset = this.bb.__offset(this.bb_pos, 10);
|
|
36
|
+
return offset ? this.bb.__string(this.bb.__vector(this.bb_pos + offset) + index * 4, optionalEncoding) : null;
|
|
37
|
+
}
|
|
38
|
+
fileIdsLength() {
|
|
39
|
+
const offset = this.bb.__offset(this.bb_pos, 10);
|
|
40
|
+
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
|
|
41
|
+
}
|
|
42
|
+
static startDucModelElement(builder) {
|
|
43
|
+
builder.startObject(4);
|
|
44
|
+
}
|
|
45
|
+
static addBase(builder, baseOffset) {
|
|
46
|
+
builder.addFieldOffset(0, baseOffset, 0);
|
|
47
|
+
}
|
|
48
|
+
static addSource(builder, sourceOffset) {
|
|
49
|
+
builder.addFieldOffset(1, sourceOffset, 0);
|
|
50
|
+
}
|
|
51
|
+
static addSvgPath(builder, svgPathOffset) {
|
|
52
|
+
builder.addFieldOffset(2, svgPathOffset, 0);
|
|
53
|
+
}
|
|
54
|
+
static addFileIds(builder, fileIdsOffset) {
|
|
55
|
+
builder.addFieldOffset(3, fileIdsOffset, 0);
|
|
56
|
+
}
|
|
57
|
+
static createFileIdsVector(builder, data) {
|
|
58
|
+
builder.startVector(4, data.length, 4);
|
|
59
|
+
for (let i = data.length - 1; i >= 0; i--) {
|
|
60
|
+
builder.addOffset(data[i]);
|
|
61
|
+
}
|
|
62
|
+
return builder.endVector();
|
|
63
|
+
}
|
|
64
|
+
static startFileIdsVector(builder, numElems) {
|
|
65
|
+
builder.startVector(4, numElems, 4);
|
|
66
|
+
}
|
|
67
|
+
static endDucModelElement(builder) {
|
|
68
|
+
const offset = builder.endObject();
|
|
69
|
+
return offset;
|
|
70
|
+
}
|
|
71
|
+
static createDucModelElement(builder, baseOffset, sourceOffset, svgPathOffset, fileIdsOffset) {
|
|
72
|
+
DucModelElement.startDucModelElement(builder);
|
|
73
|
+
DucModelElement.addBase(builder, baseOffset);
|
|
74
|
+
DucModelElement.addSource(builder, sourceOffset);
|
|
75
|
+
DucModelElement.addSvgPath(builder, svgPathOffset);
|
|
76
|
+
DucModelElement.addFileIds(builder, fileIdsOffset);
|
|
77
|
+
return DucModelElement.endDucModelElement(builder);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as flatbuffers from 'flatbuffers';
|
|
2
|
+
import { DocumentGridConfig } from '../duc/document-grid-config';
|
|
2
3
|
import { _DucElementBase } from '../duc/duc-element-base';
|
|
3
4
|
export declare class DucPdfElement {
|
|
4
5
|
bb: flatbuffers.ByteBuffer | null;
|
|
@@ -9,9 +10,10 @@ export declare class DucPdfElement {
|
|
|
9
10
|
base(obj?: _DucElementBase): _DucElementBase | null;
|
|
10
11
|
fileId(): string | null;
|
|
11
12
|
fileId(optionalEncoding: flatbuffers.Encoding): string | Uint8Array | null;
|
|
13
|
+
gridConfig(obj?: DocumentGridConfig): DocumentGridConfig | null;
|
|
12
14
|
static startDucPdfElement(builder: flatbuffers.Builder): void;
|
|
13
15
|
static addBase(builder: flatbuffers.Builder, baseOffset: flatbuffers.Offset): void;
|
|
14
16
|
static addFileId(builder: flatbuffers.Builder, fileIdOffset: flatbuffers.Offset): void;
|
|
17
|
+
static addGridConfig(builder: flatbuffers.Builder, gridConfigOffset: flatbuffers.Offset): void;
|
|
15
18
|
static endDucPdfElement(builder: flatbuffers.Builder): flatbuffers.Offset;
|
|
16
|
-
static createDucPdfElement(builder: flatbuffers.Builder, baseOffset: flatbuffers.Offset, fileIdOffset: flatbuffers.Offset): flatbuffers.Offset;
|
|
17
19
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// automatically generated by the FlatBuffers compiler, do not modify
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any, @typescript-eslint/no-non-null-assertion */
|
|
3
3
|
import * as flatbuffers from 'flatbuffers';
|
|
4
|
+
import { DocumentGridConfig } from '../duc/document-grid-config';
|
|
4
5
|
import { _DucElementBase } from '../duc/duc-element-base';
|
|
5
6
|
export class DucPdfElement {
|
|
6
7
|
constructor() {
|
|
@@ -27,8 +28,12 @@ export class DucPdfElement {
|
|
|
27
28
|
const offset = this.bb.__offset(this.bb_pos, 6);
|
|
28
29
|
return offset ? this.bb.__string(this.bb_pos + offset, optionalEncoding) : null;
|
|
29
30
|
}
|
|
31
|
+
gridConfig(obj) {
|
|
32
|
+
const offset = this.bb.__offset(this.bb_pos, 8);
|
|
33
|
+
return offset ? (obj || new DocumentGridConfig()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
|
|
34
|
+
}
|
|
30
35
|
static startDucPdfElement(builder) {
|
|
31
|
-
builder.startObject(
|
|
36
|
+
builder.startObject(3);
|
|
32
37
|
}
|
|
33
38
|
static addBase(builder, baseOffset) {
|
|
34
39
|
builder.addFieldOffset(0, baseOffset, 0);
|
|
@@ -36,14 +41,11 @@ export class DucPdfElement {
|
|
|
36
41
|
static addFileId(builder, fileIdOffset) {
|
|
37
42
|
builder.addFieldOffset(1, fileIdOffset, 0);
|
|
38
43
|
}
|
|
44
|
+
static addGridConfig(builder, gridConfigOffset) {
|
|
45
|
+
builder.addFieldOffset(2, gridConfigOffset, 0);
|
|
46
|
+
}
|
|
39
47
|
static endDucPdfElement(builder) {
|
|
40
48
|
const offset = builder.endObject();
|
|
41
49
|
return offset;
|
|
42
50
|
}
|
|
43
|
-
static createDucPdfElement(builder, baseOffset, fileIdOffset) {
|
|
44
|
-
DucPdfElement.startDucPdfElement(builder);
|
|
45
|
-
DucPdfElement.addBase(builder, baseOffset);
|
|
46
|
-
DucPdfElement.addFileId(builder, fileIdOffset);
|
|
47
|
-
return DucPdfElement.endDucPdfElement(builder);
|
|
48
|
-
}
|
|
49
51
|
}
|
|
@@ -11,6 +11,7 @@ import { DucImageElement } from '../duc/duc-image-element';
|
|
|
11
11
|
import { DucLeaderElement } from '../duc/duc-leader-element';
|
|
12
12
|
import { DucLinearElement } from '../duc/duc-linear-element';
|
|
13
13
|
import { DucMermaidElement } from '../duc/duc-mermaid-element';
|
|
14
|
+
import { DucModelElement } from '../duc/duc-model-element';
|
|
14
15
|
import { DucParametricElement } from '../duc/duc-parametric-element';
|
|
15
16
|
import { DucPdfElement } from '../duc/duc-pdf-element';
|
|
16
17
|
import { DucPlotElement } from '../duc/duc-plot-element';
|
|
@@ -43,7 +44,8 @@ export declare enum Element {
|
|
|
43
44
|
DucDimensionElement = 19,
|
|
44
45
|
DucFeatureControlFrameElement = 20,
|
|
45
46
|
DucDocElement = 21,
|
|
46
|
-
DucParametricElement = 22
|
|
47
|
+
DucParametricElement = 22,
|
|
48
|
+
DucModelElement = 23
|
|
47
49
|
}
|
|
48
|
-
export declare function unionToElement(type: Element, accessor: (obj: DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement) => DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null): DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null;
|
|
49
|
-
export declare function unionListToElement(type: Element, accessor: (index: number, obj: DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement) => DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null, index: number): DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null;
|
|
50
|
+
export declare function unionToElement(type: Element, accessor: (obj: DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement) => DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null): DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null;
|
|
51
|
+
export declare function unionListToElement(type: Element, accessor: (index: number, obj: DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement) => DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null, index: number): DucArrowElement | DucBlockInstanceElement | DucDimensionElement | DucDocElement | DucEllipseElement | DucEmbeddableElement | DucFeatureControlFrameElement | DucFrameElement | DucFreeDrawElement | DucImageElement | DucLeaderElement | DucLinearElement | DucMermaidElement | DucModelElement | DucParametricElement | DucPdfElement | DucPlotElement | DucPolygonElement | DucRectangleElement | DucTableElement | DucTextElement | DucViewportElement | DucXRayElement | null;
|
|
@@ -13,6 +13,7 @@ import { DucImageElement } from '../duc/duc-image-element';
|
|
|
13
13
|
import { DucLeaderElement } from '../duc/duc-leader-element';
|
|
14
14
|
import { DucLinearElement } from '../duc/duc-linear-element';
|
|
15
15
|
import { DucMermaidElement } from '../duc/duc-mermaid-element';
|
|
16
|
+
import { DucModelElement } from '../duc/duc-model-element';
|
|
16
17
|
import { DucParametricElement } from '../duc/duc-parametric-element';
|
|
17
18
|
import { DucPdfElement } from '../duc/duc-pdf-element';
|
|
18
19
|
import { DucPlotElement } from '../duc/duc-plot-element';
|
|
@@ -47,6 +48,7 @@ export var Element;
|
|
|
47
48
|
Element[Element["DucFeatureControlFrameElement"] = 20] = "DucFeatureControlFrameElement";
|
|
48
49
|
Element[Element["DucDocElement"] = 21] = "DucDocElement";
|
|
49
50
|
Element[Element["DucParametricElement"] = 22] = "DucParametricElement";
|
|
51
|
+
Element[Element["DucModelElement"] = 23] = "DucModelElement";
|
|
50
52
|
})(Element || (Element = {}));
|
|
51
53
|
export function unionToElement(type, accessor) {
|
|
52
54
|
switch (Element[type]) {
|
|
@@ -73,6 +75,7 @@ export function unionToElement(type, accessor) {
|
|
|
73
75
|
case 'DucFeatureControlFrameElement': return accessor(new DucFeatureControlFrameElement());
|
|
74
76
|
case 'DucDocElement': return accessor(new DucDocElement());
|
|
75
77
|
case 'DucParametricElement': return accessor(new DucParametricElement());
|
|
78
|
+
case 'DucModelElement': return accessor(new DucModelElement());
|
|
76
79
|
default: return null;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
@@ -101,6 +104,7 @@ export function unionListToElement(type, accessor, index) {
|
|
|
101
104
|
case 'DucFeatureControlFrameElement': return accessor(index, new DucFeatureControlFrameElement());
|
|
102
105
|
case 'DucDocElement': return accessor(index, new DucDocElement());
|
|
103
106
|
case 'DucParametricElement': return accessor(index, new DucParametricElement());
|
|
107
|
+
case 'DucModelElement': return accessor(index, new DucModelElement());
|
|
104
108
|
default: return null;
|
|
105
109
|
}
|
|
106
110
|
}
|
|
@@ -18,6 +18,7 @@ export { DIMENSION_FIT_RULE } from './duc/dimension-fit-rule';
|
|
|
18
18
|
export { DIMENSION_TEXT_PLACEMENT } from './duc/dimension-text-placement';
|
|
19
19
|
export { DIMENSION_TYPE } from './duc/dimension-type';
|
|
20
20
|
export { DIMENSION_UNITS_FORMAT } from './duc/dimension-units-format';
|
|
21
|
+
export { DOCUMENT_GRID_ALIGN_ITEMS } from './duc/document-grid-align-items';
|
|
21
22
|
export { DatumReference } from './duc/datum-reference';
|
|
22
23
|
export { Delta } from './duc/delta';
|
|
23
24
|
export { DictionaryEntry } from './duc/dictionary-entry';
|
|
@@ -31,6 +32,7 @@ export { DimensionLineStyle } from './duc/dimension-line-style';
|
|
|
31
32
|
export { DimensionSymbolStyle } from './duc/dimension-symbol-style';
|
|
32
33
|
export { DimensionToleranceStyle } from './duc/dimension-tolerance-style';
|
|
33
34
|
export { DimensionValidationRules } from './duc/dimension-validation-rules';
|
|
35
|
+
export { DocumentGridConfig } from './duc/document-grid-config';
|
|
34
36
|
export { DucArrowElement } from './duc/duc-arrow-element';
|
|
35
37
|
export { DucBlock } from './duc/duc-block';
|
|
36
38
|
export { DucBlockAttributeDefinition } from './duc/duc-block-attribute-definition';
|
|
@@ -70,6 +72,7 @@ export { DucLineReference } from './duc/duc-line-reference';
|
|
|
70
72
|
export { DucLinearElement } from './duc/duc-linear-element';
|
|
71
73
|
export { DucLocalState } from './duc/duc-local-state';
|
|
72
74
|
export { DucMermaidElement } from './duc/duc-mermaid-element';
|
|
75
|
+
export { DucModelElement } from './duc/duc-model-element';
|
|
73
76
|
export { DucParametricElement } from './duc/duc-parametric-element';
|
|
74
77
|
export { DucPath } from './duc/duc-path';
|
|
75
78
|
export { DucPdfElement } from './duc/duc-pdf-element';
|
package/dist/flatbuffers/duc.js
CHANGED
|
@@ -20,6 +20,7 @@ export { DIMENSION_FIT_RULE } from './duc/dimension-fit-rule';
|
|
|
20
20
|
export { DIMENSION_TEXT_PLACEMENT } from './duc/dimension-text-placement';
|
|
21
21
|
export { DIMENSION_TYPE } from './duc/dimension-type';
|
|
22
22
|
export { DIMENSION_UNITS_FORMAT } from './duc/dimension-units-format';
|
|
23
|
+
export { DOCUMENT_GRID_ALIGN_ITEMS } from './duc/document-grid-align-items';
|
|
23
24
|
export { DatumReference } from './duc/datum-reference';
|
|
24
25
|
export { Delta } from './duc/delta';
|
|
25
26
|
export { DictionaryEntry } from './duc/dictionary-entry';
|
|
@@ -33,6 +34,7 @@ export { DimensionLineStyle } from './duc/dimension-line-style';
|
|
|
33
34
|
export { DimensionSymbolStyle } from './duc/dimension-symbol-style';
|
|
34
35
|
export { DimensionToleranceStyle } from './duc/dimension-tolerance-style';
|
|
35
36
|
export { DimensionValidationRules } from './duc/dimension-validation-rules';
|
|
37
|
+
export { DocumentGridConfig } from './duc/document-grid-config';
|
|
36
38
|
export { DucArrowElement } from './duc/duc-arrow-element';
|
|
37
39
|
export { DucBlock } from './duc/duc-block';
|
|
38
40
|
export { DucBlockAttributeDefinition } from './duc/duc-block-attribute-definition';
|
|
@@ -72,6 +74,7 @@ export { DucLineReference } from './duc/duc-line-reference';
|
|
|
72
74
|
export { DucLinearElement } from './duc/duc-linear-element';
|
|
73
75
|
export { DucLocalState } from './duc/duc-local-state';
|
|
74
76
|
export { DucMermaidElement } from './duc/duc-mermaid-element';
|
|
77
|
+
export { DucModelElement } from './duc/duc-model-element';
|
|
75
78
|
export { DucParametricElement } from './duc/duc-parametric-element';
|
|
76
79
|
export { DucPath } from './duc/duc-path';
|
|
77
80
|
export { DucPdfElement } from './duc/duc-pdf-element';
|
package/dist/parse.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { FileSystemHandle } from 'browser-fs-access';
|
|
2
|
-
import { CustomHatchPattern as CustomHatchPatternFb, DimensionToleranceStyle as DimensionToleranceStyleFb, DucBlock as DucBlockFb, DucDimensionStyle as DucDimensionStyleFb, DucDocStyle as DucDocStyleFb, DucExternalFileEntry, DucFeatureControlFrameStyle as DucFeatureControlFrameStyleFb, DucGlobalState as DucGlobalStateFb, DucGroup as DucGroupFb, DucHatchStyle as DucHatchStyleFb, DucHead as DucHeadFb, DucImageFilter as DucImageFilterFb, DucLayer as DucLayerFb, DucLeaderStyle as DucLeaderStyleFb, DucLine as DucLineFb, DucLineReference as DucLineReferenceFb, DucLocalState as DucLocalStateFb, DucPath as DucPathFb, DucPlotStyle as DucPlotStyleFb, DucPointBinding as DucPointBindingFb, DucPoint as DucPointFb, DucRegion as DucRegionFb, DucStackLikeStyles as DucStackLikeStylesFb, DucTableCellStyle as DucTableCellStyleFb, DucTableStyle as DucTableStyleFb, DucTextStyle as DucTextStyleFb, DucViewportStyle as DucViewportStyleFb, DucXRayStyle as DucXRayStyleFb, ElementBackground as ElementBackgroundFb, ElementContentBase as ElementContentBaseFb, ElementStroke as ElementStrokeFb, ElementWrapper, ExportedDataState as ExportedDataStateFb, GeometricPoint as GeometricPointFb, HatchPatternLine as HatchPatternLineFb, Margins as MarginsFb, PrimaryUnits as PrimaryUnitsFb, Standard as StandardFb, StrokeSides as StrokeSidesFb, StrokeStyle as StrokeStyleFb, TilingProperties as TilingPropertiesFb, VersionGraph as VersionGraphFb, _DucElementBase as _DucElementBaseFb, _DucElementStylesBase as _DucElementStylesBaseFb, _DucLinearElementBase as _DucLinearElementBaseFb, _DucStackBase as _DucStackBaseFb, _DucStackElementBase as _DucStackElementBaseFb } from "./flatbuffers/duc";
|
|
2
|
+
import { CustomHatchPattern as CustomHatchPatternFb, DimensionToleranceStyle as DimensionToleranceStyleFb, DucBlock as DucBlockFb, DucDimensionStyle as DucDimensionStyleFb, DucDocStyle as DucDocStyleFb, DucExternalFileEntry, DucFeatureControlFrameStyle as DucFeatureControlFrameStyleFb, DucGlobalState as DucGlobalStateFb, DucGroup as DucGroupFb, DucHatchStyle as DucHatchStyleFb, DucHead as DucHeadFb, DucImageFilter as DucImageFilterFb, DucLayer as DucLayerFb, DucLeaderStyle as DucLeaderStyleFb, DucLine as DucLineFb, DucLineReference as DucLineReferenceFb, DucLocalState as DucLocalStateFb, DucPath as DucPathFb, DucPlotStyle as DucPlotStyleFb, DucPointBinding as DucPointBindingFb, DucPoint as DucPointFb, DucRegion as DucRegionFb, DucStackLikeStyles as DucStackLikeStylesFb, DucTableCellStyle as DucTableCellStyleFb, DucTableStyle as DucTableStyleFb, DucTextStyle as DucTextStyleFb, DucViewportStyle as DucViewportStyleFb, DucXRayStyle as DucXRayStyleFb, DocumentGridConfig as DocumentGridConfigFb, ElementBackground as ElementBackgroundFb, ElementContentBase as ElementContentBaseFb, ElementStroke as ElementStrokeFb, ElementWrapper, ExportedDataState as ExportedDataStateFb, GeometricPoint as GeometricPointFb, HatchPatternLine as HatchPatternLineFb, Margins as MarginsFb, PrimaryUnits as PrimaryUnitsFb, Standard as StandardFb, StrokeSides as StrokeSidesFb, StrokeStyle as StrokeStyleFb, TilingProperties as TilingPropertiesFb, VersionGraph as VersionGraphFb, _DucElementBase as _DucElementBaseFb, _DucElementStylesBase as _DucElementStylesBaseFb, _DucLinearElementBase as _DucLinearElementBaseFb, _DucStackBase as _DucStackBaseFb, _DucStackElementBase as _DucStackElementBaseFb } from "./flatbuffers/duc";
|
|
3
3
|
import { RestoreConfig, RestoredDataState } from "./restore";
|
|
4
4
|
import { Standard, StandardUnits } from "./technical";
|
|
5
|
-
import { CustomHatchPattern, Dictionary, DucBlock, DucDimensionStyle, DucDocStyle, DucElement, DucExternalFiles, DucFeatureControlFrameStyle, DucGlobalState, DucGroup, DucHatchStyle, DucHead, DucImageFilter, DucLayer, DucLeaderStyle, DucLine, DucLineReference, DucLocalState, DucPath, DucPlotStyle, DucPoint, DucPointBinding, DucRegion, DucStackLikeStyles, DucTableCellStyle, DucTableStyle, DucTextStyle, DucViewportStyle, DucXRayStyle, ElementBackground, ElementContentBase, ElementStroke, GeometricPoint, HatchPatternLine, PlotLayout, StrokeSides, StrokeStyle, TilingProperties, VersionGraph, _DucElementBase, _DucElementStylesBase, _DucLinearElementBase, _DucStackBase, _DucStackElementBase } from "./types";
|
|
5
|
+
import { CustomHatchPattern, Dictionary, DocumentGridConfig, DucBlock, DucDimensionStyle, DucDocStyle, DucElement, DucExternalFiles, DucFeatureControlFrameStyle, DucGlobalState, DucGroup, DucHatchStyle, DucHead, DucImageFilter, DucLayer, DucLeaderStyle, DucLine, DucLineReference, DucLocalState, DucPath, DucPlotStyle, DucPoint, DucPointBinding, DucRegion, DucStackLikeStyles, DucTableCellStyle, DucTableStyle, DucTextStyle, DucViewportStyle, DucXRayStyle, ElementBackground, ElementContentBase, ElementStroke, GeometricPoint, HatchPatternLine, PlotLayout, StrokeSides, StrokeStyle, TilingProperties, VersionGraph, _DucElementBase, _DucElementStylesBase, _DucLinearElementBase, _DucStackBase, _DucStackElementBase } from "./types";
|
|
6
6
|
export declare function parseGeometricPoint(point: GeometricPointFb): GeometricPoint;
|
|
7
7
|
export declare function parsePoint(point: DucPointFb): DucPoint;
|
|
8
8
|
export declare function parseMargins(margins: MarginsFb): PlotLayout["margins"];
|
|
9
|
+
export declare function parseDocumentGridConfig(gridConfig: DocumentGridConfigFb): DocumentGridConfig;
|
|
9
10
|
export declare function parseHead(head: DucHeadFb): DucHead;
|
|
10
11
|
export declare function parseHatchPatternLine(line: HatchPatternLineFb): HatchPatternLine;
|
|
11
12
|
export declare function parseCustomHatchPattern(pattern: CustomHatchPatternFb): CustomHatchPattern;
|
package/dist/parse.js
CHANGED
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { decompressSync, strFromU8 } from 'fflate';
|
|
11
11
|
import * as flatbuffers from "flatbuffers";
|
|
12
12
|
import { nanoid } from 'nanoid';
|
|
13
|
-
import { DucArrowElement as DucArrowElementFb, DucDimensionElement as DucDimensionElementFb, DucDocElement as DucDocElementFb, DucEllipseElement as DucEllipseElementFb, DucEmbeddableElement as DucEmbeddableElementFb, DucFeatureControlFrameElement as DucFeatureControlFrameElementFb, DucFrameElement as DucFrameElementFb, DucFreeDrawElement as DucFreeDrawElementFb, DucImageElement as DucImageElementFb, DucLeaderElement as DucLeaderElementFb, DucLinearElement as DucLinearElementFb, DucMermaidElement as DucMermaidElementFb,
|
|
13
|
+
import { DOCUMENT_GRID_ALIGN_ITEMS, DucArrowElement as DucArrowElementFb, DucDimensionElement as DucDimensionElementFb, DucDocElement as DucDocElementFb, DucEllipseElement as DucEllipseElementFb, DucEmbeddableElement as DucEmbeddableElementFb, DucFeatureControlFrameElement as DucFeatureControlFrameElementFb, DucFrameElement as DucFrameElementFb, DucFreeDrawElement as DucFreeDrawElementFb, DucImageElement as DucImageElementFb, DucLeaderElement as DucLeaderElementFb, DucLinearElement as DucLinearElementFb, DucMermaidElement as DucMermaidElementFb, DucModelElement as DucModelElementFb, DucPdfElement as DucPdfElementFb, DucPlotElement as DucPlotElementFb, DucPolygonElement as DucPolygonElementFb, DucRectangleElement as DucRectangleElementFb, DucTableElement as DucTableElementFb, DucTextDynamicDictionarySource as DucTextDynamicDictionarySourceFb, DucTextDynamicElementSource as DucTextDynamicElementSourceFb, DucTextElement as DucTextElementFb, DucViewportElement as DucViewportElementFb, DucXRayElement as DucXRayElementFb, Element as ElementUnion, ExportedDataState, LEADER_CONTENT_TYPE as LEADER_CONTENT_TYPE_ENUM, LeaderBlockContent as LeaderBlockContentFb, LeaderTextBlockContent as LeaderTextBlockContentFb, TEXT_FIELD_SOURCE_TYPE } from "./flatbuffers/duc";
|
|
14
14
|
import { restore } from "./restore";
|
|
15
15
|
// #region HELPERS & LOW-LEVEL CASTS
|
|
16
16
|
// Helper functions for type casting
|
|
@@ -70,6 +70,24 @@ export function parseMargins(margins) {
|
|
|
70
70
|
left: toPrecisionValue(margins.left()),
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
|
+
export function parseDocumentGridConfig(gridConfig) {
|
|
74
|
+
return {
|
|
75
|
+
columns: gridConfig.columns(),
|
|
76
|
+
gapX: gridConfig.gapX(),
|
|
77
|
+
gapY: gridConfig.gapY(),
|
|
78
|
+
alignItems: (() => {
|
|
79
|
+
const align = gridConfig.alignItems();
|
|
80
|
+
if (align === DOCUMENT_GRID_ALIGN_ITEMS.START)
|
|
81
|
+
return 'start';
|
|
82
|
+
if (align === DOCUMENT_GRID_ALIGN_ITEMS.CENTER)
|
|
83
|
+
return 'center';
|
|
84
|
+
if (align === DOCUMENT_GRID_ALIGN_ITEMS.END)
|
|
85
|
+
return 'end';
|
|
86
|
+
return 'start';
|
|
87
|
+
})(),
|
|
88
|
+
firstPageAlone: gridConfig.firstPageAlone(),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
73
91
|
export function parseHead(head) {
|
|
74
92
|
return {
|
|
75
93
|
type: head.type(),
|
|
@@ -257,7 +275,14 @@ function parseEmbeddableElement(element) {
|
|
|
257
275
|
return Object.assign({ type: "embeddable" }, parseElementBase(element.base()));
|
|
258
276
|
}
|
|
259
277
|
function parsePdfElement(element) {
|
|
260
|
-
|
|
278
|
+
const gridConfig = element.gridConfig();
|
|
279
|
+
return Object.assign(Object.assign({ type: "pdf" }, parseElementBase(element.base())), { fileId: element.fileId(), gridConfig: gridConfig ? parseDocumentGridConfig(gridConfig) : {
|
|
280
|
+
columns: 1,
|
|
281
|
+
gapX: 0,
|
|
282
|
+
gapY: 0,
|
|
283
|
+
alignItems: 'start',
|
|
284
|
+
firstPageAlone: false,
|
|
285
|
+
} });
|
|
261
286
|
}
|
|
262
287
|
function parseMermaidElement(element) {
|
|
263
288
|
return Object.assign(Object.assign({ type: "mermaid" }, parseElementBase(element.base())), { source: element.source(), theme: element.theme() || undefined, svgPath: element.svgPath() });
|
|
@@ -545,6 +570,7 @@ function parseDocElement(element) {
|
|
|
545
570
|
});
|
|
546
571
|
}
|
|
547
572
|
const columns = element.columns();
|
|
573
|
+
const gridConfig = element.gridConfig();
|
|
548
574
|
return Object.assign(Object.assign(Object.assign({ type: "doc" }, parseElementBase(element.base())), parseDocStyle(element.style())), { text: element.text(), dynamic: dynamicParts, flowDirection: element.flowDirection(), columns: {
|
|
549
575
|
type: columns.type(),
|
|
550
576
|
definitions: Array.from({ length: columns.definitionsLength() }, (_, i) => {
|
|
@@ -555,16 +581,17 @@ function parseDocElement(element) {
|
|
|
555
581
|
};
|
|
556
582
|
}),
|
|
557
583
|
autoHeight: columns.autoHeight(),
|
|
558
|
-
}, autoResize: element.autoResize()
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
code: source.code(),
|
|
565
|
-
fileId: source.fileId(),
|
|
584
|
+
}, autoResize: element.autoResize(), fileId: element.fileId(), gridConfig: gridConfig ? parseDocumentGridConfig(gridConfig) : {
|
|
585
|
+
columns: 1,
|
|
586
|
+
gapX: 0,
|
|
587
|
+
gapY: 0,
|
|
588
|
+
alignItems: 'start',
|
|
589
|
+
firstPageAlone: false,
|
|
566
590
|
} });
|
|
567
591
|
}
|
|
592
|
+
function parseModelElement(element) {
|
|
593
|
+
return Object.assign(Object.assign({ type: "model" }, parseElementBase(element.base())), { source: element.source(), svgPath: element.svgPath(), fileIds: Array.from({ length: element.fileIdsLength() }, (_, i) => element.fileIds(i)) });
|
|
594
|
+
}
|
|
568
595
|
// #endregion
|
|
569
596
|
// #region STYLE PARSERS (ELEMENT-LEVEL)
|
|
570
597
|
export function parseTextStyle(style) {
|
|
@@ -772,8 +799,8 @@ export function parseElementFromBinary(wrapper) {
|
|
|
772
799
|
case ElementUnion.DucDocElement:
|
|
773
800
|
element = wrapper.element(new DucDocElementFb());
|
|
774
801
|
break;
|
|
775
|
-
case ElementUnion.
|
|
776
|
-
element = wrapper.element(new
|
|
802
|
+
case ElementUnion.DucModelElement:
|
|
803
|
+
element = wrapper.element(new DucModelElementFb());
|
|
777
804
|
break;
|
|
778
805
|
default:
|
|
779
806
|
return null;
|
|
@@ -823,8 +850,8 @@ export function parseElementFromBinary(wrapper) {
|
|
|
823
850
|
return parseFeatureControlFrameElement(element);
|
|
824
851
|
case ElementUnion.DucDocElement:
|
|
825
852
|
return parseDocElement(element);
|
|
826
|
-
case ElementUnion.
|
|
827
|
-
return
|
|
853
|
+
case ElementUnion.DucModelElement:
|
|
854
|
+
return parseModelElement(element);
|
|
828
855
|
default:
|
|
829
856
|
return null;
|
|
830
857
|
}
|
|
@@ -97,12 +97,7 @@ export declare const restoreBlockCollections: (collections: unknown) => Restored
|
|
|
97
97
|
* Restores the blockInstances array from imported data, ensuring each item
|
|
98
98
|
* conforms to the DucBlockInstance type.
|
|
99
99
|
*/
|
|
100
|
-
export declare const restoreBlockInstances: (blockInstances: unknown) => RestoredDataState["blockInstances"];
|
|
101
|
-
/**
|
|
102
|
-
* Restores instances from block instances data (alias for restoreBlockInstances)
|
|
103
|
-
* This method provides a consistent naming convention for instance restoration.
|
|
104
|
-
*/
|
|
105
|
-
export declare const restoreInstances: (instances: unknown) => RestoredDataState["blockInstances"];
|
|
100
|
+
export declare const restoreBlockInstances: (blockInstances: unknown, currentScope: Scope) => RestoredDataState["blockInstances"];
|
|
106
101
|
/**
|
|
107
102
|
* Restores the global state of the document from imported data.
|
|
108
103
|
* It validates and provides defaults for missing or invalid properties.
|
|
@@ -20,7 +20,7 @@ export const restore = (data, elementsConfig, restoreConfig = {}) => {
|
|
|
20
20
|
const restoredRegions = restoreRegions(data === null || data === void 0 ? void 0 : data.regions);
|
|
21
21
|
const restoredGroups = restoreGroups(data === null || data === void 0 ? void 0 : data.groups);
|
|
22
22
|
const restoredLayers = restoreLayers(data === null || data === void 0 ? void 0 : data.layers, restoredLocalState.scope);
|
|
23
|
-
const restoredBlockInstances = restoreBlockInstances(data === null || data === void 0 ? void 0 : data.blockInstances);
|
|
23
|
+
const restoredBlockInstances = restoreBlockInstances(data === null || data === void 0 ? void 0 : data.blockInstances, restoredLocalState.scope);
|
|
24
24
|
const restoredElements = restoreElements(data === null || data === void 0 ? void 0 : data.elements, restoredLocalState.scope, restoredBlocks, restoredElementsConfig);
|
|
25
25
|
const restoredVersionGraph = restoreVersionGraph(data === null || data === void 0 ? void 0 : data.versionGraph);
|
|
26
26
|
// Generate a new ID if none exists or if it's empty
|
|
@@ -247,7 +247,7 @@ export const restoreBlockCollections = (collections) => {
|
|
|
247
247
|
* Restores the blockInstances array from imported data, ensuring each item
|
|
248
248
|
* conforms to the DucBlockInstance type.
|
|
249
249
|
*/
|
|
250
|
-
export const restoreBlockInstances = (blockInstances) => {
|
|
250
|
+
export const restoreBlockInstances = (blockInstances, currentScope) => {
|
|
251
251
|
if (!Array.isArray(blockInstances)) {
|
|
252
252
|
return [];
|
|
253
253
|
}
|
|
@@ -301,8 +301,8 @@ export const restoreBlockInstances = (blockInstances) => {
|
|
|
301
301
|
? {
|
|
302
302
|
rows: typeof dupArray.rows === "number" ? dupArray.rows : 1,
|
|
303
303
|
cols: typeof dupArray.cols === "number" ? dupArray.cols : 1,
|
|
304
|
-
rowSpacing:
|
|
305
|
-
colSpacing:
|
|
304
|
+
rowSpacing: restorePrecisionValue(dupArray.rowSpacing, NEUTRAL_SCOPE, currentScope),
|
|
305
|
+
colSpacing: restorePrecisionValue(dupArray.colSpacing, NEUTRAL_SCOPE, currentScope),
|
|
306
306
|
}
|
|
307
307
|
: null,
|
|
308
308
|
};
|
|
@@ -337,13 +337,6 @@ const restoreBlockMetadata = (metadata) => {
|
|
|
337
337
|
: undefined;
|
|
338
338
|
return Object.assign(Object.assign({}, (source ? { source } : {})), { usageCount: typeof metadataObj.usageCount === "number" ? metadataObj.usageCount : 0, createdAt: typeof metadataObj.createdAt === "number" ? metadataObj.createdAt : Date.now(), updatedAt: typeof metadataObj.updatedAt === "number" ? metadataObj.updatedAt : Date.now(), localization });
|
|
339
339
|
};
|
|
340
|
-
/**
|
|
341
|
-
* Restores instances from block instances data (alias for restoreBlockInstances)
|
|
342
|
-
* This method provides a consistent naming convention for instance restoration.
|
|
343
|
-
*/
|
|
344
|
-
export const restoreInstances = (instances) => {
|
|
345
|
-
return restoreBlockInstances(instances);
|
|
346
|
-
};
|
|
347
340
|
/**
|
|
348
341
|
* Restores the global state of the document from imported data.
|
|
349
342
|
* It validates and provides defaults for missing or invalid properties.
|
|
@@ -3,7 +3,7 @@ isValidColor, isValidDucHead, isValidEnumValue, isValidFunction, isValidImageSca
|
|
|
3
3
|
import { getPrecisionValueFromRaw, getPrecisionValueFromScoped, getScaledZoomValueForScope, getScopedBezierPointFromDucPoint, getScopedZoomValue, NEUTRAL_SCOPE, ScaleFactors, } from "../technical/scopes";
|
|
4
4
|
import { isElbowArrow, isLinearElement, isTextElement, } from "../types";
|
|
5
5
|
import { arrayToMap, bumpVersion, DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, detectLineHeight, FONT_FAMILY, getContainerElement, getDefaultLocalState, getDefaultTableData, getNormalizedDimensions, getNormalizedPoints, getNormalizedZoom, getSizeFromPoints, getUpdatedTimestamp, isFiniteNumber, isInvisiblySmallElement, LINE_CONFIRM_THRESHOLD, mergeOverlappingPoints, migratePoints, normalizeFixedPoint, normalizeLink, randomId, refreshTextDimensions, validateClosedPath, } from "../utils";
|
|
6
|
-
import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION,
|
|
6
|
+
import { AXIS, BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, GDT_SYMBOL, LEADER_CONTENT_TYPE, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, STACKED_TEXT_ALIGN, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT, } from "../flatbuffers/duc";
|
|
7
7
|
import tinycolor from "tinycolor2";
|
|
8
8
|
const restoreElementWithProperties = (element, extra, localState, globalState) => {
|
|
9
9
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
@@ -80,7 +80,7 @@ const restoreElementWithProperties = (element, extra, localState, globalState) =
|
|
|
80
80
|
return Object.assign(Object.assign(Object.assign(Object.assign({}, _element), base), normalized), { type: _element.type });
|
|
81
81
|
};
|
|
82
82
|
const restoreElement = (element, currentScope, restoredBlocks, localState, globalState) => {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x
|
|
83
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
84
84
|
// Migration: convert deprecated 'diamond' to 'polygon' with 4 sides
|
|
85
85
|
if (element.type === "diamond") {
|
|
86
86
|
const migrated = Object.assign(Object.assign({}, element), { type: "polygon", sides: 4 });
|
|
@@ -343,7 +343,10 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
343
343
|
}
|
|
344
344
|
// Other elements
|
|
345
345
|
case "pdf":
|
|
346
|
-
return restoreElementWithProperties(element, {
|
|
346
|
+
return restoreElementWithProperties(element, {
|
|
347
|
+
fileId: isValidString(element.fileId) || null,
|
|
348
|
+
gridConfig: restoreDocumentGridConfig(element.gridConfig),
|
|
349
|
+
}, localState);
|
|
347
350
|
case "mermaid":
|
|
348
351
|
return restoreElementWithProperties(element, {
|
|
349
352
|
source: isValidString(element.source),
|
|
@@ -381,7 +384,7 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
381
384
|
const docElement = element;
|
|
382
385
|
return restoreElementWithProperties(element, Object.assign(Object.assign({}, restoreDocStyleProperties(docElement, currentScope)), { text: isValidString(docElement.text), dynamic: restoreTextDynamicParts(docElement.dynamic), flowDirection: (Object.values(TEXT_FLOW_DIRECTION)).includes(docElement.flowDirection)
|
|
383
386
|
? docElement.flowDirection
|
|
384
|
-
: TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: restoreTextColumns(docElement.columns, currentScope), autoResize: isValidBooleanValue(docElement.autoResize, true) }), localState);
|
|
387
|
+
: TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: restoreTextColumns(docElement.columns, currentScope), autoResize: isValidBooleanValue(docElement.autoResize, true), fileId: isValidString(docElement.fileId) || null, gridConfig: restoreDocumentGridConfig(docElement.gridConfig) }), localState);
|
|
385
388
|
}
|
|
386
389
|
case "xray": {
|
|
387
390
|
const xrayElement = element;
|
|
@@ -393,22 +396,13 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
393
396
|
color: isValidColor(xrayElement.color, "#FF00FF"),
|
|
394
397
|
}, localState, globalState);
|
|
395
398
|
}
|
|
396
|
-
case "
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
};
|
|
404
|
-
}
|
|
405
|
-
else {
|
|
406
|
-
source = {
|
|
407
|
-
type: PARAMETRIC_SOURCE_TYPE.CODE,
|
|
408
|
-
code: isValidString((_u = parametricElement.source) === null || _u === void 0 ? void 0 : _u.code),
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
return restoreElementWithProperties(parametricElement, { source }, localState, globalState);
|
|
399
|
+
case "model": {
|
|
400
|
+
const modelElement = element;
|
|
401
|
+
return restoreElementWithProperties(modelElement, {
|
|
402
|
+
source: isValidString(modelElement.source),
|
|
403
|
+
fileIds: modelElement.fileIds || [],
|
|
404
|
+
svgPath: modelElement.svgPath || null,
|
|
405
|
+
}, localState, globalState);
|
|
412
406
|
}
|
|
413
407
|
case "featurecontrolframe": {
|
|
414
408
|
const fcfElement = element;
|
|
@@ -417,15 +411,15 @@ const restoreElement = (element, currentScope, restoredBlocks, localState, globa
|
|
|
417
411
|
// Restore style properties
|
|
418
412
|
textStyle: restoreTextStyle(fcfElement.textStyle, currentScope),
|
|
419
413
|
layout: {
|
|
420
|
-
padding: restorePrecisionValue((
|
|
421
|
-
segmentSpacing: restorePrecisionValue((
|
|
422
|
-
rowSpacing: restorePrecisionValue((
|
|
414
|
+
padding: restorePrecisionValue((_s = fcfElement.layout) === null || _s === void 0 ? void 0 : _s.padding, elementScope, currentScope, 2),
|
|
415
|
+
segmentSpacing: restorePrecisionValue((_t = fcfElement.layout) === null || _t === void 0 ? void 0 : _t.segmentSpacing, elementScope, currentScope, 2),
|
|
416
|
+
rowSpacing: restorePrecisionValue((_u = fcfElement.layout) === null || _u === void 0 ? void 0 : _u.rowSpacing, elementScope, currentScope, 2),
|
|
423
417
|
},
|
|
424
418
|
symbols: {
|
|
425
|
-
scale: (
|
|
419
|
+
scale: (_w = (_v = fcfElement.symbols) === null || _v === void 0 ? void 0 : _v.scale) !== null && _w !== void 0 ? _w : 1,
|
|
426
420
|
},
|
|
427
421
|
datumStyle: {
|
|
428
|
-
bracketStyle: isValidEnumValue((
|
|
422
|
+
bracketStyle: isValidEnumValue((_x = fcfElement.datumStyle) === null || _x === void 0 ? void 0 : _x.bracketStyle, DATUM_BRACKET_STYLE, DATUM_BRACKET_STYLE.SQUARE),
|
|
429
423
|
},
|
|
430
424
|
// Restore data properties
|
|
431
425
|
rows: restoreFcfRows(fcfElement.rows),
|
|
@@ -973,6 +967,26 @@ const restoreTextColumns = (columns, currentScope) => {
|
|
|
973
967
|
autoHeight: isValidBooleanValue(columns.autoHeight, true),
|
|
974
968
|
};
|
|
975
969
|
};
|
|
970
|
+
const restoreDocumentGridConfig = (gridConfig) => {
|
|
971
|
+
if (!gridConfig || typeof gridConfig !== "object") {
|
|
972
|
+
return {
|
|
973
|
+
columns: 1,
|
|
974
|
+
gapX: 0,
|
|
975
|
+
gapY: 0,
|
|
976
|
+
alignItems: "start",
|
|
977
|
+
firstPageAlone: false,
|
|
978
|
+
};
|
|
979
|
+
}
|
|
980
|
+
return {
|
|
981
|
+
columns: typeof gridConfig.columns === "number" ? gridConfig.columns : 1,
|
|
982
|
+
gapX: typeof gridConfig.gapX === "number" ? gridConfig.gapX : 0,
|
|
983
|
+
gapY: typeof gridConfig.gapY === "number" ? gridConfig.gapY : 0,
|
|
984
|
+
alignItems: (typeof gridConfig.alignItems === "string" && ["start", "center", "end"].includes(gridConfig.alignItems))
|
|
985
|
+
? gridConfig.alignItems
|
|
986
|
+
: "start",
|
|
987
|
+
firstPageAlone: typeof gridConfig.firstPageAlone === "boolean" ? gridConfig.firstPageAlone : false,
|
|
988
|
+
};
|
|
989
|
+
};
|
|
976
990
|
const getFontFamilyByName = (fontFamilyName) => {
|
|
977
991
|
if (Object.keys(FONT_FAMILY).includes(fontFamilyName)) {
|
|
978
992
|
return FONT_FAMILY[fontFamilyName];
|
package/dist/serialize.js
CHANGED
|
@@ -740,6 +740,24 @@ function writeColumnLayout(b, c, usv) {
|
|
|
740
740
|
Duc.ColumnLayout.addAutoHeight(b, c.autoHeight);
|
|
741
741
|
return Duc.ColumnLayout.endColumnLayout(b);
|
|
742
742
|
}
|
|
743
|
+
function writeDocumentGridConfig(b, config, usv) {
|
|
744
|
+
Duc.DocumentGridConfig.startDocumentGridConfig(b);
|
|
745
|
+
Duc.DocumentGridConfig.addColumns(b, config.columns);
|
|
746
|
+
Duc.DocumentGridConfig.addGapX(b, config.gapX);
|
|
747
|
+
Duc.DocumentGridConfig.addGapY(b, config.gapY);
|
|
748
|
+
const alignItems = (() => {
|
|
749
|
+
if (config.alignItems === 'start')
|
|
750
|
+
return Duc.DOCUMENT_GRID_ALIGN_ITEMS.START;
|
|
751
|
+
if (config.alignItems === 'center')
|
|
752
|
+
return Duc.DOCUMENT_GRID_ALIGN_ITEMS.CENTER;
|
|
753
|
+
if (config.alignItems === 'end')
|
|
754
|
+
return Duc.DOCUMENT_GRID_ALIGN_ITEMS.END;
|
|
755
|
+
return Duc.DOCUMENT_GRID_ALIGN_ITEMS.START;
|
|
756
|
+
})();
|
|
757
|
+
Duc.DocumentGridConfig.addAlignItems(b, alignItems);
|
|
758
|
+
Duc.DocumentGridConfig.addFirstPageAlone(b, config.firstPageAlone);
|
|
759
|
+
return Duc.DocumentGridConfig.endDocumentGridConfig(b);
|
|
760
|
+
}
|
|
743
761
|
function writeText(b, e, usv) {
|
|
744
762
|
var _a;
|
|
745
763
|
const base = writeElementBase(b, e, usv);
|
|
@@ -836,8 +854,14 @@ function writeBlockInstance(b, i, usv) {
|
|
|
836
854
|
Duc.DucBlockDuplicationArray.startDucBlockDuplicationArray(b);
|
|
837
855
|
Duc.DucBlockDuplicationArray.addRows(b, i.duplicationArray.rows);
|
|
838
856
|
Duc.DucBlockDuplicationArray.addCols(b, i.duplicationArray.cols);
|
|
839
|
-
|
|
840
|
-
|
|
857
|
+
const rSpacing = typeof i.duplicationArray.rowSpacing === 'number'
|
|
858
|
+
? i.duplicationArray.rowSpacing
|
|
859
|
+
: getPrecisionValue(i.duplicationArray.rowSpacing, usv);
|
|
860
|
+
const cSpacing = typeof i.duplicationArray.colSpacing === 'number'
|
|
861
|
+
? i.duplicationArray.colSpacing
|
|
862
|
+
: getPrecisionValue(i.duplicationArray.colSpacing, usv);
|
|
863
|
+
Duc.DucBlockDuplicationArray.addRowSpacing(b, rSpacing);
|
|
864
|
+
Duc.DucBlockDuplicationArray.addColSpacing(b, cSpacing);
|
|
841
865
|
return Duc.DucBlockDuplicationArray.endDucBlockDuplicationArray(b);
|
|
842
866
|
})()
|
|
843
867
|
: undefined;
|
|
@@ -1378,6 +1402,8 @@ function writeDoc(b, e, usv) {
|
|
|
1378
1402
|
Duc.ColumnLayout.addAutoHeight(b, col.autoHeight);
|
|
1379
1403
|
return Duc.ColumnLayout.endColumnLayout(b);
|
|
1380
1404
|
})();
|
|
1405
|
+
const fileId = e.fileId ? b.createString(e.fileId) : undefined;
|
|
1406
|
+
const gridConfig = writeDocumentGridConfig(b, e.gridConfig, usv);
|
|
1381
1407
|
Duc.DucDocElement.startDucDocElement(b);
|
|
1382
1408
|
Duc.DucDocElement.addBase(b, base);
|
|
1383
1409
|
Duc.DucDocElement.addStyle(b, style);
|
|
@@ -1386,36 +1412,23 @@ function writeDoc(b, e, usv) {
|
|
|
1386
1412
|
Duc.DucDocElement.addFlowDirection(b, e.flowDirection);
|
|
1387
1413
|
Duc.DucDocElement.addColumns(b, columns);
|
|
1388
1414
|
Duc.DucDocElement.addAutoResize(b, e.autoResize);
|
|
1415
|
+
if (fileId)
|
|
1416
|
+
Duc.DucDocElement.addFileId(b, fileId);
|
|
1417
|
+
Duc.DucDocElement.addGridConfig(b, gridConfig);
|
|
1389
1418
|
return Duc.DucDocElement.endDucDocElement(b);
|
|
1390
1419
|
}
|
|
1391
1420
|
/**
|
|
1392
|
-
*
|
|
1421
|
+
* PDF, Mermaid, Embeddable
|
|
1393
1422
|
*/
|
|
1394
|
-
function writeParametricSource(b, s, usv) {
|
|
1395
|
-
Duc.ParametricSource.startParametricSource(b);
|
|
1396
|
-
Duc.ParametricSource.addType(b, s.type);
|
|
1397
|
-
if (s.type === Duc.PARAMETRIC_SOURCE_TYPE.CODE) {
|
|
1398
|
-
Duc.ParametricSource.addCode(b, b.createString(s.code));
|
|
1399
|
-
}
|
|
1400
|
-
else {
|
|
1401
|
-
Duc.ParametricSource.addFileId(b, b.createString(s.fileId));
|
|
1402
|
-
}
|
|
1403
|
-
return Duc.ParametricSource.endParametricSource(b);
|
|
1404
|
-
}
|
|
1405
|
-
function writeParametric(b, e, usv) {
|
|
1406
|
-
const base = writeElementBase(b, e, usv);
|
|
1407
|
-
const src = writeParametricSource(b, e.source, usv);
|
|
1408
|
-
Duc.DucParametricElement.startDucParametricElement(b);
|
|
1409
|
-
Duc.DucParametricElement.addBase(b, base);
|
|
1410
|
-
Duc.DucParametricElement.addSource(b, src);
|
|
1411
|
-
return Duc.DucParametricElement.endDucParametricElement(b);
|
|
1412
|
-
}
|
|
1413
1423
|
function writePdf(b, e, usv) {
|
|
1414
1424
|
const base = writeElementBase(b, e, usv);
|
|
1415
|
-
const fileId = b.createString(e.fileId);
|
|
1425
|
+
const fileId = e.fileId ? b.createString(e.fileId) : undefined;
|
|
1426
|
+
const gridConfig = writeDocumentGridConfig(b, e.gridConfig, usv);
|
|
1416
1427
|
Duc.DucPdfElement.startDucPdfElement(b);
|
|
1417
1428
|
Duc.DucPdfElement.addBase(b, base);
|
|
1418
|
-
|
|
1429
|
+
if (fileId)
|
|
1430
|
+
Duc.DucPdfElement.addFileId(b, fileId);
|
|
1431
|
+
Duc.DucPdfElement.addGridConfig(b, gridConfig);
|
|
1419
1432
|
return Duc.DucPdfElement.endDucPdfElement(b);
|
|
1420
1433
|
}
|
|
1421
1434
|
function writeMermaid(b, e, usv) {
|
|
@@ -1432,6 +1445,21 @@ function writeMermaid(b, e, usv) {
|
|
|
1432
1445
|
Duc.DucMermaidElement.addSvgPath(b, svg);
|
|
1433
1446
|
return Duc.DucMermaidElement.endDucMermaidElement(b);
|
|
1434
1447
|
}
|
|
1448
|
+
function writeModel(b, e, usv) {
|
|
1449
|
+
var _a;
|
|
1450
|
+
const base = writeElementBase(b, e, usv);
|
|
1451
|
+
const src = b.createString(e.source);
|
|
1452
|
+
const svg = e.svgPath ? b.createString(e.svgPath) : undefined;
|
|
1453
|
+
const fileIds = ((_a = e.fileIds) === null || _a === void 0 ? void 0 : _a.length) ? Duc.DucModelElement.createFileIdsVector(b, e.fileIds.map((id) => b.createString(id))) : undefined;
|
|
1454
|
+
Duc.DucModelElement.startDucModelElement(b);
|
|
1455
|
+
Duc.DucModelElement.addBase(b, base);
|
|
1456
|
+
Duc.DucModelElement.addSource(b, src);
|
|
1457
|
+
if (svg)
|
|
1458
|
+
Duc.DucModelElement.addSvgPath(b, svg);
|
|
1459
|
+
if (fileIds)
|
|
1460
|
+
Duc.DucModelElement.addFileIds(b, fileIds);
|
|
1461
|
+
return Duc.DucModelElement.endDucModelElement(b);
|
|
1462
|
+
}
|
|
1435
1463
|
function writeEmbeddable(b, e, usv) {
|
|
1436
1464
|
const base = writeElementBase(b, e, usv);
|
|
1437
1465
|
Duc.DucEmbeddableElement.startDucEmbeddableElement(b);
|
|
@@ -1633,9 +1661,9 @@ function writeElementWrapper(b, e, usv) {
|
|
|
1633
1661
|
type = Duc.Element.DucDocElement;
|
|
1634
1662
|
elem = writeDoc(b, e, usv);
|
|
1635
1663
|
break;
|
|
1636
|
-
case "
|
|
1637
|
-
type = Duc.Element.
|
|
1638
|
-
elem =
|
|
1664
|
+
case "model":
|
|
1665
|
+
type = Duc.Element.DucModelElement;
|
|
1666
|
+
elem = writeModel(b, e, usv);
|
|
1639
1667
|
break;
|
|
1640
1668
|
case "embeddable":
|
|
1641
1669
|
type = Duc.Element.DucEmbeddableElement;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from "./typeChecks";
|
|
2
2
|
import { DucView, PrecisionValue, Scope } from "..";
|
|
3
|
-
import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION,
|
|
3
|
+
import { BEZIER_MIRRORING, BLENDING, BLOCK_ATTACHMENT, BOOLEAN_OPERATION, COLUMN_TYPE, DATUM_BRACKET_STYLE, DATUM_TARGET_TYPE, DIMENSION_FIT_RULE, DIMENSION_TEXT_PLACEMENT, DIMENSION_TYPE, ELEMENT_CONTENT_PREFERENCE, FEATURE_MODIFIER, GDT_SYMBOL, HATCH_STYLE, IMAGE_STATUS, LINE_HEAD, LINE_SPACING_TYPE, MARK_ELLIPSE_CENTER, MATERIAL_CONDITION, STACKED_TEXT_ALIGN, STROKE_CAP, STROKE_JOIN, STROKE_PLACEMENT, STROKE_PREFERENCE, STROKE_SIDE_PREFERENCE, TABLE_CELL_ALIGNMENT, TABLE_FLOW_DIRECTION, TEXT_ALIGN, TEXT_FIELD_SOURCE_PROPERTY, TEXT_FIELD_SOURCE_TYPE, TEXT_FLOW_DIRECTION, TOLERANCE_DISPLAY, TOLERANCE_TYPE, TOLERANCE_ZONE_TYPE, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
|
|
4
4
|
import { Standard, StandardUnits } from "../../technical/standards";
|
|
5
5
|
import { FONT_FAMILY, FREEDRAW_EASINGS } from "../../utils/constants";
|
|
6
6
|
import { Axis, GeometricPoint, Percentage, Radian, ScaleFactor } from "../geometryTypes";
|
|
@@ -134,7 +134,7 @@ export type DucGenericElement = DucSelectionElement | DucRectangleElement;
|
|
|
134
134
|
* no computed data. The list of all DucElements should be shareable
|
|
135
135
|
* between peers and contain no state local to the peer.
|
|
136
136
|
*/
|
|
137
|
-
export type DucElement = DucGenericElement | DucTextElement | DucLinearElement | DucFreeDrawElement | DucArrowElement | DucImageElement | DucFrameElement | DucEmbeddableElement | DucTableElement | DucDocElement | DucEllipseElement | DucPolygonElement |
|
|
137
|
+
export type DucElement = DucGenericElement | DucTextElement | DucLinearElement | DucFreeDrawElement | DucArrowElement | DucImageElement | DucFrameElement | DucEmbeddableElement | DucTableElement | DucDocElement | DucEllipseElement | DucPolygonElement | DucModelElement | DucFeatureControlFrameElement | DucLeaderElement | DucDimensionElement | DucViewportElement | DucPlotElement | DucXRayElement | DucPdfElement | DucMermaidElement;
|
|
138
138
|
export type DucElementTypes = DucElement["type"];
|
|
139
139
|
export type NonDeleted<TElement extends DucElement> = TElement & {
|
|
140
140
|
isDeleted: boolean;
|
|
@@ -316,9 +316,21 @@ export type DucEllipseElement = _DucElementBase & {
|
|
|
316
316
|
export type DucEmbeddableElement = _DucElementBase & {
|
|
317
317
|
type: "embeddable";
|
|
318
318
|
};
|
|
319
|
+
/**
|
|
320
|
+
* Configuration for PDF grid layout
|
|
321
|
+
*/
|
|
322
|
+
export type DocumentGridConfig = {
|
|
323
|
+
columns: number;
|
|
324
|
+
gapX: number;
|
|
325
|
+
gapY: number;
|
|
326
|
+
alignItems: 'start' | 'center' | 'end';
|
|
327
|
+
firstPageAlone: boolean;
|
|
328
|
+
};
|
|
319
329
|
export type DucPdfElement = _DucElementBase & {
|
|
320
330
|
type: "pdf";
|
|
321
331
|
fileId: ExternalFileId | null;
|
|
332
|
+
/** Configuration for rendering the document in a grid layout */
|
|
333
|
+
gridConfig: DocumentGridConfig;
|
|
322
334
|
};
|
|
323
335
|
export type DucMermaidElement = _DucElementBase & {
|
|
324
336
|
type: "mermaid";
|
|
@@ -1357,10 +1369,8 @@ export type TextColumn = {
|
|
|
1357
1369
|
export type DucDocElement = _DucElementBase & DucDocStyle & {
|
|
1358
1370
|
type: "doc";
|
|
1359
1371
|
/**
|
|
1360
|
-
* The content of the document, stored as a
|
|
1361
|
-
* This approach allows a rich text editor
|
|
1362
|
-
* inline formatting (bold, italic, colors, hyperlinks, etc.) while keeping the
|
|
1363
|
-
* core data structure simple and clean.
|
|
1372
|
+
* The content of the document, stored as a code string.
|
|
1373
|
+
* This approach allows to use a rich text editor that can compile to PDF using Typst code
|
|
1364
1374
|
*
|
|
1365
1375
|
* It can also contain wildcards like `{@fieldname}` for dynamic data insertion.
|
|
1366
1376
|
* Example: "This is **bold text** and this is a {color:red}red word{/color}."
|
|
@@ -1369,6 +1379,9 @@ export type DucDocElement = _DucElementBase & DucDocStyle & {
|
|
|
1369
1379
|
* Example: "This document was last saved on {{SaveDate}} by {{Author}}."
|
|
1370
1380
|
*/
|
|
1371
1381
|
text: string;
|
|
1382
|
+
fileId: ExternalFileId | null;
|
|
1383
|
+
/** Configuration for rendering the document in a grid layout */
|
|
1384
|
+
gridConfig: DocumentGridConfig;
|
|
1372
1385
|
/**
|
|
1373
1386
|
* An array of metadata objects that define the behavior of the placeholders
|
|
1374
1387
|
* found in the `text` property. If this is empty, the text is treated
|
|
@@ -1401,27 +1414,15 @@ export type DucDocElement = _DucElementBase & DucDocStyle & {
|
|
|
1401
1414
|
autoResize: boolean;
|
|
1402
1415
|
};
|
|
1403
1416
|
/**
|
|
1404
|
-
*
|
|
1405
|
-
* The geometry is either generated from live code or loaded from an external file.
|
|
1406
|
-
*/
|
|
1407
|
-
export type ParametricElementSource = {
|
|
1408
|
-
/** The geometry is defined by executable Replicad code. */
|
|
1409
|
-
type: PARAMETRIC_SOURCE_TYPE.CODE;
|
|
1410
|
-
/** The JavaScript code that generates the Replicad model. */
|
|
1411
|
-
code: string;
|
|
1412
|
-
} | {
|
|
1413
|
-
/** The geometry is loaded from a static 3D file. */
|
|
1414
|
-
type: PARAMETRIC_SOURCE_TYPE.FILE;
|
|
1415
|
-
/** A reference to the imported file in the DucExternalFiles collection. */
|
|
1416
|
-
fileId: ExternalFileId;
|
|
1417
|
-
};
|
|
1418
|
-
/**
|
|
1419
|
-
* An element that embeds a 3D model on the 2D canvas, defined either by
|
|
1420
|
-
* parametric Replicad code or by an imported 3D file (e.g., STEP, STL).
|
|
1417
|
+
* An element that embeds a 3D model on the 2D canvas, defined by build123d python code.
|
|
1421
1418
|
* It includes its own 3D view and display controls.
|
|
1422
1419
|
*/
|
|
1423
|
-
export type
|
|
1424
|
-
type: "
|
|
1425
|
-
/** Defines the source of the
|
|
1426
|
-
source:
|
|
1420
|
+
export type DucModelElement = _DucElementBase & {
|
|
1421
|
+
type: "model";
|
|
1422
|
+
/** Defines the source of the model using build123d python code */
|
|
1423
|
+
source: string;
|
|
1424
|
+
/** The last known SVG path representation of the 3D model for quick rendering on the canvas */
|
|
1425
|
+
svgPath: string | null;
|
|
1426
|
+
/** Possibly connected external files, such as STEP, STL or other reference models */
|
|
1427
|
+
fileIds: ExternalFileId[];
|
|
1427
1428
|
};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
export * from "./elements";
|
|
2
2
|
export * from "./geometryTypes";
|
|
3
|
-
export * from "./utility-types";
|
|
4
3
|
export * from "./typeChecks";
|
|
4
|
+
export * from "./utility-types";
|
|
5
5
|
import { OBJECT_SNAP_MODE, PRUNING_LEVEL } from "../flatbuffers/duc";
|
|
6
6
|
import { SupportedMeasures } from "../technical/scopes";
|
|
7
7
|
import { Standard } from "../technical/standards";
|
|
8
|
+
import type { GRID_DISPLAY_TYPE, GRID_TYPE, SNAP_MARKER_SHAPE, SNAP_MODE, SNAP_OVERRIDE_BEHAVIOR } from "../utils/constants";
|
|
8
9
|
import { DucBindableElement, DucBlock, DucBlockCollection, DucBlockInstance, DucElement, DucElementType, DucGroup, DucIframeLikeElement, DucLayer, DucLinearElement, DucPoint, DucRegion, DucTextElement, ElementBackground, ElementStroke, ExternalFileId, FontFamilyValues, LineHead, NonDeleted, TextAlign } from "./elements";
|
|
9
10
|
import { GeometricPoint, Percentage, Radian, ScaleFactor } from "./geometryTypes";
|
|
10
11
|
import { MakeBrand, MarkOptional, MaybePromise, ValueOf } from "./utility-types";
|
|
11
|
-
import type { GRID_DISPLAY_TYPE, GRID_TYPE, SNAP_MARKER_SHAPE, SNAP_MODE, SNAP_OVERRIDE_BEHAVIOR } from "../utils/constants";
|
|
12
12
|
/**
|
|
13
13
|
* Root data structure for the stored data state
|
|
14
14
|
*/
|
|
@@ -112,7 +112,7 @@ export type SuggestedPointBinding = [
|
|
|
112
112
|
"start" | "end" | "both",
|
|
113
113
|
NonDeleted<DucBindableElement>
|
|
114
114
|
];
|
|
115
|
-
export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "plot" | "embeddable" | "ruler" | "lasso" | "laser" | "table";
|
|
115
|
+
export type ToolType = "selection" | "rectangle" | "polygon" | "ellipse" | "line" | "freedraw" | "text" | "image" | "eraser" | "hand" | "frame" | "plot" | "embeddable" | "ruler" | "lasso" | "laser" | "table" | "doc" | "pdf";
|
|
116
116
|
export type ElementOrToolType = DucElementType | ToolType | "custom";
|
|
117
117
|
/**
|
|
118
118
|
* Defines the global, persistent settings for the drawing. These are fundamental
|
package/dist/types/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Scope } from "../../types";
|
|
2
|
-
import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement,
|
|
2
|
+
import { DucArrowElement, DucDimensionElement, DucDocElement, DucElement, DucEllipseElement, DucEmbeddableElement, DucFeatureControlFrameElement, DucFrameElement, DucFreeDrawElement, DucGenericElement, DucImageElement, DucLeaderElement, DucLinearElement, DucMermaidElement, DucModelElement, DucPdfElement, DucPlotElement, DucPolygonElement, DucTableElement, DucTextElement, DucViewportElement, DucXRayElement, ElementConstructorOpts, ElementUpdate, NonDeleted } from "../../types/elements";
|
|
3
3
|
import { Mutable } from "../../types/utility-types";
|
|
4
4
|
export declare const newElementWith: <TElement extends DucElement>(element: TElement, updates: ElementUpdate<TElement>,
|
|
5
5
|
/** pass `true` to always regenerate */
|
|
@@ -46,7 +46,7 @@ export declare const newXRayElement: (currentScope: Scope, opts: ElementConstruc
|
|
|
46
46
|
export declare const newLeaderElement: (currentScope: Scope, opts: Partial<DucLeaderElement> & ElementConstructorOpts) => NonDeleted<DucLeaderElement>;
|
|
47
47
|
export declare const newDimensionElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucDimensionElement>;
|
|
48
48
|
export declare const newFeatureControlFrameElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucFeatureControlFrameElement>;
|
|
49
|
-
export declare const newParametricElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<
|
|
49
|
+
export declare const newParametricElement: (currentScope: Scope, opts: ElementConstructorOpts) => NonDeleted<DucModelElement>;
|
|
50
50
|
/**
|
|
51
51
|
* Clones DucElement data structure. Does not regenerate id, nonce, or
|
|
52
52
|
* any value. The purpose is to to break object references for immutability
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { getUpdatedTimestamp, getZoom } from "..";
|
|
13
|
-
import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE,
|
|
13
|
+
import { BLOCK_ATTACHMENT, COLUMN_TYPE, DATUM_BRACKET_STYLE, IMAGE_STATUS, LINE_SPACING_TYPE, STACKED_TEXT_ALIGN, TEXT_FLOW_DIRECTION, VERTICAL_ALIGN, VIEWPORT_SHADE_PLOT } from "../../flatbuffers/duc";
|
|
14
14
|
import { getPrecisionValueFromRaw } from "../../technical/scopes";
|
|
15
15
|
import { DEFAULT_ELEMENT_PROPS, DEFAULT_ELLIPSE_ELEMENT, DEFAULT_FONT_FAMILY, DEFAULT_FONT_SIZE, DEFAULT_FREEDRAW_ELEMENT, DEFAULT_POLYGON_SIDES, DEFAULT_TEXT_ALIGN, DEFAULT_VERTICAL_ALIGN } from "../constants";
|
|
16
16
|
import { randomId, randomInteger } from "../math/random";
|
|
@@ -153,11 +153,11 @@ export const newImageElement = (currentScope, opts) => {
|
|
|
153
153
|
export const newTableElement = (currentScope, opts) => (Object.assign(Object.assign(Object.assign({}, _newElementBase("table", currentScope, opts)), getDefaultTableData(currentScope)), { type: "table" }));
|
|
154
154
|
export const newDocElement = (currentScope, opts) => {
|
|
155
155
|
var _a, _b, _c, _d;
|
|
156
|
-
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", dynamic: opts.dynamic || [], flowDirection: opts.flowDirection || TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: opts.columns || { type: COLUMN_TYPE.NO_COLUMNS, definitions: [], autoHeight: true }, autoResize: (_a = opts.autoResize) !== null && _a !== void 0 ? _a : true,
|
|
156
|
+
return (Object.assign(Object.assign({}, _newElementBase("doc", currentScope, opts)), { type: "doc", text: opts.text || "", dynamic: opts.dynamic || [], flowDirection: opts.flowDirection || TEXT_FLOW_DIRECTION.TOP_TO_BOTTOM, columns: opts.columns || { type: COLUMN_TYPE.NO_COLUMNS, definitions: [], autoHeight: true }, autoResize: (_a = opts.autoResize) !== null && _a !== void 0 ? _a : true, fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false },
|
|
157
157
|
// DucDocStyle properties
|
|
158
158
|
isLtr: (_b = opts.isLtr) !== null && _b !== void 0 ? _b : true, fontFamily: opts.fontFamily || DEFAULT_FONT_FAMILY, bigFontFamily: opts.bigFontFamily || "sans-serif", textAlign: opts.textAlign || DEFAULT_TEXT_ALIGN, verticalAlign: opts.verticalAlign || DEFAULT_VERTICAL_ALIGN, lineHeight: opts.lineHeight || 1.2, lineSpacing: opts.lineSpacing || { type: LINE_SPACING_TYPE.MULTIPLE, value: 1.2 }, obliqueAngle: opts.obliqueAngle || 0, fontSize: opts.fontSize || getPrecisionValueFromRaw(DEFAULT_FONT_SIZE, currentScope, currentScope), paperTextHeight: opts.paperTextHeight, widthFactor: opts.widthFactor || 1, isUpsideDown: (_c = opts.isUpsideDown) !== null && _c !== void 0 ? _c : false, isBackwards: (_d = opts.isBackwards) !== null && _d !== void 0 ? _d : false, paragraph: opts.paragraph || { firstLineIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), hangingIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), leftIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), rightIndent: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceBefore: getPrecisionValueFromRaw(0, currentScope, currentScope), spaceAfter: getPrecisionValueFromRaw(0, currentScope, currentScope), tabStops: [] }, stackFormat: opts.stackFormat || { autoStack: false, stackChars: [], properties: { upperScale: 0.7, lowerScale: 0.7, alignment: STACKED_TEXT_ALIGN.CENTER } } }));
|
|
159
159
|
};
|
|
160
|
-
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
160
|
+
export const newPdfElement = (currentScope, opts) => (Object.assign(Object.assign({ fileId: null, gridConfig: { columns: 1, gapX: 0, gapY: 0, alignItems: 'start', firstPageAlone: false } }, _newElementBase("pdf", currentScope, opts)), { type: "pdf" }));
|
|
161
161
|
export const newMermaidElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", theme: undefined, svgPath: null }, _newElementBase("mermaid", currentScope, opts)), { type: "mermaid" }));
|
|
162
162
|
export const newXRayElement = (currentScope, opts) => (Object.assign(Object.assign({ origin: { x: getPrecisionValueFromRaw(0, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, direction: { x: getPrecisionValueFromRaw(1, currentScope, currentScope), y: getPrecisionValueFromRaw(0, currentScope, currentScope) }, startFromOrigin: false, color: '#FF00FF' }, _newElementBase("xray", currentScope, opts)), { type: "xray" }));
|
|
163
163
|
export const newLeaderElement = (currentScope, opts) => {
|
|
@@ -179,7 +179,7 @@ export const newFeatureControlFrameElement = (currentScope, opts) => {
|
|
|
179
179
|
bracketStyle: DATUM_BRACKET_STYLE.SQUARE
|
|
180
180
|
} }, _newElementBase("featurecontrolframe", currentScope, opts)), { type: "featurecontrolframe" });
|
|
181
181
|
};
|
|
182
|
-
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source:
|
|
182
|
+
export const newParametricElement = (currentScope, opts) => (Object.assign(Object.assign({ source: "", svgPath: null, fileIds: [] }, _newElementBase("model", currentScope, opts)), { type: 'model' }));
|
|
183
183
|
// Simplified deep clone for the purpose of cloning DucElement.
|
|
184
184
|
//
|
|
185
185
|
// Only clones plain objects and arrays. Doesn't clone Date, RegExp, Map, Set,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ducjs",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "The duc 2D CAD file format is a cornerstone of our advanced design system, conceived to cater to professionals seeking precision and efficiency in their design work.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|