documents.js 1.58.0 → 1.60.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/README.md +65 -26
- package/dist/convert/capability.cjs +239 -0
- package/dist/convert/capability.d.cts +42 -0
- package/dist/convert/capability.d.ts +42 -0
- package/dist/convert/capability.js +236 -0
- package/dist/convert/codec.cjs +20 -0
- package/dist/convert/codec.d.cts +5 -1
- package/dist/convert/codec.d.ts +5 -1
- package/dist/convert/codec.js +19 -3
- package/dist/convert/convert.cjs +114 -0
- package/dist/convert/convert.d.cts +9 -1
- package/dist/convert/convert.d.ts +9 -1
- package/dist/convert/convert.js +107 -1
- package/dist/convert/local.cjs +26 -335
- package/dist/convert/local.js +26 -335
- package/dist/convert/port.d.cts +1 -1
- package/dist/convert/port.d.ts +1 -1
- package/dist/edit/ods/column-row.cjs +31 -0
- package/dist/edit/ods/column-row.d.cts +6 -0
- package/dist/edit/ods/column-row.d.ts +6 -0
- package/dist/edit/ods/column-row.js +29 -0
- package/dist/edit/ods/content.cjs +2 -0
- package/dist/edit/ods/content.js +2 -0
- package/dist/edit/ods/sheet.cjs +7 -0
- package/dist/edit/ods/sheet.d.cts +2 -0
- package/dist/edit/ods/sheet.d.ts +2 -0
- package/dist/edit/ods/sheet.js +7 -0
- package/dist/index.cjs +20 -0
- package/dist/index.d.cts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +7 -4
- package/dist/markdown/read.cjs +16 -0
- package/dist/markdown/read.d.cts +6 -0
- package/dist/markdown/read.d.ts +6 -0
- package/dist/markdown/read.js +15 -0
- package/dist/markdown/text.cjs +16 -0
- package/dist/markdown/text.d.cts +5 -0
- package/dist/markdown/text.d.ts +5 -0
- package/dist/markdown/text.js +14 -0
- package/dist/markdown/write.cjs +8 -0
- package/dist/markdown/write.d.cts +6 -0
- package/dist/markdown/write.d.ts +6 -0
- package/dist/markdown/write.js +7 -0
- package/dist/model/bytes.cjs +10 -0
- package/dist/model/bytes.d.cts +2 -1
- package/dist/model/bytes.d.ts +2 -1
- package/dist/model/bytes.js +10 -1
- package/package.json +2 -1
package/dist/convert/local.js
CHANGED
|
@@ -1,83 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DIRECT_EDGES, resolveConversionPath } from "./capability.js";
|
|
2
2
|
//#region src/convert/local.ts
|
|
3
|
-
const SUPPORTED_CONVERSIONS =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
{
|
|
9
|
-
source: "pptx",
|
|
10
|
-
target: "pdf"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
source: "odt",
|
|
14
|
-
target: "pdf"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
source: "odp",
|
|
18
|
-
target: "pdf"
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
source: "ods",
|
|
22
|
-
target: "pdf"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
source: "odg",
|
|
26
|
-
target: "pdf"
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
source: "odf",
|
|
30
|
-
target: "pdf"
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
source: "pdf",
|
|
34
|
-
target: "docx"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
source: "pdf",
|
|
38
|
-
target: "pptx"
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
source: "pdf",
|
|
42
|
-
target: "odt"
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
source: "pdf",
|
|
46
|
-
target: "odp"
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
source: "pdf",
|
|
50
|
-
target: "ods"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
source: "pdf",
|
|
54
|
-
target: "odg"
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
source: "odt",
|
|
58
|
-
target: "docx"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
source: "docx",
|
|
62
|
-
target: "odt"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
source: "odp",
|
|
66
|
-
target: "pptx"
|
|
67
|
-
},
|
|
68
|
-
{
|
|
69
|
-
source: "pptx",
|
|
70
|
-
target: "odp"
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
source: "ods",
|
|
74
|
-
target: "xlsx"
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
source: "xlsx",
|
|
78
|
-
target: "ods"
|
|
79
|
-
}
|
|
80
|
-
];
|
|
3
|
+
const SUPPORTED_CONVERSIONS = DIRECT_EDGES.map((edge) => ({
|
|
4
|
+
source: edge.source,
|
|
5
|
+
target: edge.target
|
|
6
|
+
}));
|
|
81
7
|
function substitutionDiagnostic(substitution, context) {
|
|
82
8
|
return {
|
|
83
9
|
severity: "info",
|
|
@@ -105,286 +31,51 @@ function createLocalDocumentConverter() {
|
|
|
105
31
|
const onDocument = (pkg) => {
|
|
106
32
|
documentPackage = pkg;
|
|
107
33
|
};
|
|
108
|
-
|
|
109
|
-
|
|
34
|
+
const strategy = resolveConversionPath(source.format, targetFormat);
|
|
35
|
+
if (strategy?.kind !== "direct") return Promise.reject(/* @__PURE__ */ new Error(`unsupported conversion: ${source.format} -> ${targetFormat}`));
|
|
36
|
+
const edge = strategy.edge;
|
|
37
|
+
if (edge.kind === "toPdf") {
|
|
38
|
+
const bytes = edge.convert(source.bytes, {
|
|
110
39
|
signal: options.signal,
|
|
111
40
|
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
112
41
|
onDocument
|
|
113
42
|
});
|
|
114
43
|
return Promise.resolve({
|
|
115
44
|
document: {
|
|
116
|
-
format:
|
|
45
|
+
format: edge.target,
|
|
117
46
|
bytes
|
|
118
47
|
},
|
|
119
48
|
diagnostics,
|
|
120
49
|
package: documentPackage
|
|
121
50
|
});
|
|
122
51
|
}
|
|
123
|
-
if (
|
|
124
|
-
const bytes =
|
|
125
|
-
signal: options.signal,
|
|
126
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
127
|
-
onDocument
|
|
128
|
-
});
|
|
129
|
-
return Promise.resolve({
|
|
130
|
-
document: {
|
|
131
|
-
format: "pdf",
|
|
132
|
-
bytes
|
|
133
|
-
},
|
|
134
|
-
diagnostics,
|
|
135
|
-
package: documentPackage
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
if (source.format === "odt" && targetFormat === "pdf") {
|
|
139
|
-
const bytes = odtToPdf(source.bytes, {
|
|
140
|
-
signal: options.signal,
|
|
141
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
142
|
-
onDocument
|
|
143
|
-
});
|
|
144
|
-
return Promise.resolve({
|
|
145
|
-
document: {
|
|
146
|
-
format: "pdf",
|
|
147
|
-
bytes
|
|
148
|
-
},
|
|
149
|
-
diagnostics,
|
|
150
|
-
package: documentPackage
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
if (source.format === "odp" && targetFormat === "pdf") {
|
|
154
|
-
const bytes = odpToPdf(source.bytes, {
|
|
155
|
-
signal: options.signal,
|
|
156
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
157
|
-
onDocument
|
|
158
|
-
});
|
|
159
|
-
return Promise.resolve({
|
|
160
|
-
document: {
|
|
161
|
-
format: "pdf",
|
|
162
|
-
bytes
|
|
163
|
-
},
|
|
164
|
-
diagnostics,
|
|
165
|
-
package: documentPackage
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
if (source.format === "ods" && targetFormat === "pdf") {
|
|
169
|
-
const bytes = odsToPdf(source.bytes, {
|
|
170
|
-
signal: options.signal,
|
|
171
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
172
|
-
onDocument
|
|
173
|
-
});
|
|
174
|
-
return Promise.resolve({
|
|
175
|
-
document: {
|
|
176
|
-
format: "pdf",
|
|
177
|
-
bytes
|
|
178
|
-
},
|
|
179
|
-
diagnostics,
|
|
180
|
-
package: documentPackage
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (source.format === "odg" && targetFormat === "pdf") {
|
|
184
|
-
const bytes = odgToPdf(source.bytes, {
|
|
185
|
-
signal: options.signal,
|
|
186
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
187
|
-
onDocument
|
|
188
|
-
});
|
|
189
|
-
return Promise.resolve({
|
|
190
|
-
document: {
|
|
191
|
-
format: "pdf",
|
|
192
|
-
bytes
|
|
193
|
-
},
|
|
194
|
-
diagnostics,
|
|
195
|
-
package: documentPackage
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
if (source.format === "odf" && targetFormat === "pdf") {
|
|
199
|
-
const bytes = odfToPdf(source.bytes, {
|
|
200
|
-
signal: options.signal,
|
|
201
|
-
onSubstitution: (s, c) => diagnostics.push(substitutionDiagnostic(s, c)),
|
|
202
|
-
onDocument
|
|
203
|
-
});
|
|
204
|
-
return Promise.resolve({
|
|
205
|
-
document: {
|
|
206
|
-
format: "pdf",
|
|
207
|
-
bytes
|
|
208
|
-
},
|
|
209
|
-
diagnostics,
|
|
210
|
-
package: documentPackage
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
if (source.format === "pdf" && targetFormat === "docx") {
|
|
214
|
-
const bytes = pdfToDocx(source.bytes, {
|
|
215
|
-
signal: options.signal,
|
|
216
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
217
|
-
onDocument
|
|
218
|
-
});
|
|
219
|
-
return Promise.resolve({
|
|
220
|
-
document: {
|
|
221
|
-
format: "docx",
|
|
222
|
-
bytes
|
|
223
|
-
},
|
|
224
|
-
diagnostics,
|
|
225
|
-
package: documentPackage
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
if (source.format === "pdf" && targetFormat === "pptx") {
|
|
229
|
-
const bytes = pdfToPptx(source.bytes, {
|
|
230
|
-
signal: options.signal,
|
|
231
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
232
|
-
onDocument
|
|
233
|
-
});
|
|
234
|
-
return Promise.resolve({
|
|
235
|
-
document: {
|
|
236
|
-
format: "pptx",
|
|
237
|
-
bytes
|
|
238
|
-
},
|
|
239
|
-
diagnostics,
|
|
240
|
-
package: documentPackage
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
if (source.format === "pdf" && targetFormat === "odt") {
|
|
244
|
-
const bytes = pdfToOdt(source.bytes, {
|
|
245
|
-
signal: options.signal,
|
|
246
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
247
|
-
onDocument
|
|
248
|
-
});
|
|
249
|
-
return Promise.resolve({
|
|
250
|
-
document: {
|
|
251
|
-
format: "odt",
|
|
252
|
-
bytes
|
|
253
|
-
},
|
|
254
|
-
diagnostics,
|
|
255
|
-
package: documentPackage
|
|
256
|
-
});
|
|
257
|
-
}
|
|
258
|
-
if (source.format === "pdf" && targetFormat === "odp") {
|
|
259
|
-
const bytes = pdfToOdp(source.bytes, {
|
|
260
|
-
signal: options.signal,
|
|
261
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
262
|
-
onDocument
|
|
263
|
-
});
|
|
264
|
-
return Promise.resolve({
|
|
265
|
-
document: {
|
|
266
|
-
format: "odp",
|
|
267
|
-
bytes
|
|
268
|
-
},
|
|
269
|
-
diagnostics,
|
|
270
|
-
package: documentPackage
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
if (source.format === "pdf" && targetFormat === "ods") {
|
|
274
|
-
const bytes = pdfToOds(source.bytes, {
|
|
275
|
-
signal: options.signal,
|
|
276
|
-
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
277
|
-
onDocument
|
|
278
|
-
});
|
|
279
|
-
return Promise.resolve({
|
|
280
|
-
document: {
|
|
281
|
-
format: "ods",
|
|
282
|
-
bytes
|
|
283
|
-
},
|
|
284
|
-
diagnostics,
|
|
285
|
-
package: documentPackage
|
|
286
|
-
});
|
|
287
|
-
}
|
|
288
|
-
if (source.format === "pdf" && targetFormat === "odg") {
|
|
289
|
-
const bytes = pdfToOdg(source.bytes, {
|
|
52
|
+
if (edge.kind === "fromPdf") {
|
|
53
|
+
const bytes = edge.convert(source.bytes, {
|
|
290
54
|
signal: options.signal,
|
|
291
55
|
sink: (d) => diagnostics.push(fromPdfDiagnostic(d)),
|
|
292
56
|
onDocument
|
|
293
57
|
});
|
|
294
58
|
return Promise.resolve({
|
|
295
59
|
document: {
|
|
296
|
-
format:
|
|
297
|
-
bytes
|
|
298
|
-
},
|
|
299
|
-
diagnostics,
|
|
300
|
-
package: documentPackage
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
if (source.format === "odt" && targetFormat === "docx") {
|
|
304
|
-
const bytes = odtToDocx(source.bytes, {
|
|
305
|
-
signal: options.signal,
|
|
306
|
-
onDocument
|
|
307
|
-
});
|
|
308
|
-
return Promise.resolve({
|
|
309
|
-
document: {
|
|
310
|
-
format: "docx",
|
|
311
|
-
bytes
|
|
312
|
-
},
|
|
313
|
-
diagnostics,
|
|
314
|
-
package: documentPackage
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
if (source.format === "docx" && targetFormat === "odt") {
|
|
318
|
-
const bytes = docxToOdt(source.bytes, {
|
|
319
|
-
signal: options.signal,
|
|
320
|
-
onDocument
|
|
321
|
-
});
|
|
322
|
-
return Promise.resolve({
|
|
323
|
-
document: {
|
|
324
|
-
format: "odt",
|
|
325
|
-
bytes
|
|
326
|
-
},
|
|
327
|
-
diagnostics,
|
|
328
|
-
package: documentPackage
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
if (source.format === "odp" && targetFormat === "pptx") {
|
|
332
|
-
const bytes = odpToPptx(source.bytes, {
|
|
333
|
-
signal: options.signal,
|
|
334
|
-
onDocument
|
|
335
|
-
});
|
|
336
|
-
return Promise.resolve({
|
|
337
|
-
document: {
|
|
338
|
-
format: "pptx",
|
|
339
|
-
bytes
|
|
340
|
-
},
|
|
341
|
-
diagnostics,
|
|
342
|
-
package: documentPackage
|
|
343
|
-
});
|
|
344
|
-
}
|
|
345
|
-
if (source.format === "pptx" && targetFormat === "odp") {
|
|
346
|
-
const bytes = pptxToOdp(source.bytes, {
|
|
347
|
-
signal: options.signal,
|
|
348
|
-
onDocument
|
|
349
|
-
});
|
|
350
|
-
return Promise.resolve({
|
|
351
|
-
document: {
|
|
352
|
-
format: "odp",
|
|
353
|
-
bytes
|
|
354
|
-
},
|
|
355
|
-
diagnostics,
|
|
356
|
-
package: documentPackage
|
|
357
|
-
});
|
|
358
|
-
}
|
|
359
|
-
if (source.format === "ods" && targetFormat === "xlsx") {
|
|
360
|
-
const bytes = odsToXlsx(source.bytes, {
|
|
361
|
-
signal: options.signal,
|
|
362
|
-
onDocument
|
|
363
|
-
});
|
|
364
|
-
return Promise.resolve({
|
|
365
|
-
document: {
|
|
366
|
-
format: "xlsx",
|
|
367
|
-
bytes
|
|
368
|
-
},
|
|
369
|
-
diagnostics,
|
|
370
|
-
package: documentPackage
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
if (source.format === "xlsx" && targetFormat === "ods") {
|
|
374
|
-
const bytes = xlsxToOds(source.bytes, {
|
|
375
|
-
signal: options.signal,
|
|
376
|
-
onDocument
|
|
377
|
-
});
|
|
378
|
-
return Promise.resolve({
|
|
379
|
-
document: {
|
|
380
|
-
format: "ods",
|
|
60
|
+
format: edge.target,
|
|
381
61
|
bytes
|
|
382
62
|
},
|
|
383
63
|
diagnostics,
|
|
384
64
|
package: documentPackage
|
|
385
65
|
});
|
|
386
66
|
}
|
|
387
|
-
|
|
67
|
+
const bytes = edge.convert(source.bytes, {
|
|
68
|
+
signal: options.signal,
|
|
69
|
+
onDocument
|
|
70
|
+
});
|
|
71
|
+
return Promise.resolve({
|
|
72
|
+
document: {
|
|
73
|
+
format: edge.target,
|
|
74
|
+
bytes
|
|
75
|
+
},
|
|
76
|
+
diagnostics,
|
|
77
|
+
package: documentPackage
|
|
78
|
+
});
|
|
388
79
|
}
|
|
389
80
|
};
|
|
390
81
|
}
|
package/dist/convert/port.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentPackage } from "document-schema.js";
|
|
2
2
|
//#region src/convert/port.d.ts
|
|
3
|
-
type DocumentFormat = 'docx' | 'pptx' | 'xlsx' | 'odt' | 'odp' | 'ods' | 'odg' | 'odf' | 'pdf';
|
|
3
|
+
type DocumentFormat = 'docx' | 'pptx' | 'xlsx' | 'odt' | 'odp' | 'ods' | 'odg' | 'odf' | 'markdown' | 'pdf';
|
|
4
4
|
interface DocumentPayload {
|
|
5
5
|
readonly format: DocumentFormat;
|
|
6
6
|
readonly bytes: Uint8Array<ArrayBuffer>;
|
package/dist/convert/port.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DocumentPackage } from "document-schema.js";
|
|
2
2
|
//#region src/convert/port.d.ts
|
|
3
|
-
type DocumentFormat = 'docx' | 'pptx' | 'xlsx' | 'odt' | 'odp' | 'ods' | 'odg' | 'odf' | 'pdf';
|
|
3
|
+
type DocumentFormat = 'docx' | 'pptx' | 'xlsx' | 'odt' | 'odp' | 'ods' | 'odg' | 'odf' | 'markdown' | 'pdf';
|
|
4
4
|
interface DocumentPayload {
|
|
5
5
|
readonly format: DocumentFormat;
|
|
6
6
|
readonly bytes: Uint8Array<ArrayBuffer>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_xml_fragment = require("../../xml/fragment.cjs");
|
|
3
|
+
const require_xml_edit = require("../../xml/edit.cjs");
|
|
4
|
+
const require_edit_odt_automatic_styles = require("../odt/automatic-styles.cjs");
|
|
5
|
+
const require_edit_ods_address = require("./address.cjs");
|
|
6
|
+
let odf_js = require("odf.js");
|
|
7
|
+
//#region src/edit/ods/column-row.ts
|
|
8
|
+
function writeColumnWidth(pkg, tableElement, index, widthPt) {
|
|
9
|
+
require_edit_ods_address.ensureColumnCoverage(tableElement, index + 1);
|
|
10
|
+
const columnElement = require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(require_edit_ods_address.COLUMN_TAG), index, require_edit_ods_address.COLUMN_REPEAT_ATTR, () => require_xml_fragment.el(require_edit_ods_address.COLUMN_TAG));
|
|
11
|
+
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
12
|
+
const styleName = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", "OdsColumn");
|
|
13
|
+
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
14
|
+
"style:name": styleName,
|
|
15
|
+
"style:family": "table-column"
|
|
16
|
+
}, [require_xml_fragment.el("style:table-column-properties", { "style:column-width": (0, odf_js.formatOdfLength)(widthPt) })]));
|
|
17
|
+
require_xml_edit.setAttr(columnElement, "table:style-name", styleName);
|
|
18
|
+
}
|
|
19
|
+
function writeRowHeight(pkg, tableElement, index, heightPt) {
|
|
20
|
+
const rowElement = require_edit_ods_address.replaceRun(tableElement.children, require_edit_ods_address.isElementWithTag(require_edit_ods_address.ROW_TAG), index, require_edit_ods_address.ROW_REPEAT_ATTR, () => require_xml_fragment.el(require_edit_ods_address.ROW_TAG));
|
|
21
|
+
const automaticStyles = require_edit_odt_automatic_styles.ensureAutomaticStyles(pkg);
|
|
22
|
+
const styleName = require_edit_odt_automatic_styles.nextStyleName(automaticStyles, "style:style", "OdsRow");
|
|
23
|
+
automaticStyles.children.push(require_xml_fragment.el("style:style", {
|
|
24
|
+
"style:name": styleName,
|
|
25
|
+
"style:family": "table-row"
|
|
26
|
+
}, [require_xml_fragment.el("style:table-row-properties", { "style:row-height": (0, odf_js.formatOdfLength)(heightPt) })]));
|
|
27
|
+
require_xml_edit.setAttr(rowElement, "table:style-name", styleName);
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.writeColumnWidth = writeColumnWidth;
|
|
31
|
+
exports.writeRowHeight = writeRowHeight;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Package, XmlElement } from "odf.js";
|
|
2
|
+
//#region src/edit/ods/column-row.d.ts
|
|
3
|
+
declare function writeColumnWidth(pkg: Package, tableElement: XmlElement, index: number, widthPt: number): void;
|
|
4
|
+
declare function writeRowHeight(pkg: Package, tableElement: XmlElement, index: number, heightPt: number): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { writeColumnWidth, writeRowHeight };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Package, XmlElement } from "odf.js";
|
|
2
|
+
//#region src/edit/ods/column-row.d.ts
|
|
3
|
+
declare function writeColumnWidth(pkg: Package, tableElement: XmlElement, index: number, widthPt: number): void;
|
|
4
|
+
declare function writeRowHeight(pkg: Package, tableElement: XmlElement, index: number, heightPt: number): void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { writeColumnWidth, writeRowHeight };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { el } from "../../xml/fragment.js";
|
|
2
|
+
import { setAttr } from "../../xml/edit.js";
|
|
3
|
+
import { ensureAutomaticStyles, nextStyleName } from "../odt/automatic-styles.js";
|
|
4
|
+
import { COLUMN_REPEAT_ATTR, COLUMN_TAG, ROW_REPEAT_ATTR, ROW_TAG, ensureColumnCoverage, isElementWithTag, replaceRun } from "./address.js";
|
|
5
|
+
import { formatOdfLength } from "odf.js";
|
|
6
|
+
//#region src/edit/ods/column-row.ts
|
|
7
|
+
function writeColumnWidth(pkg, tableElement, index, widthPt) {
|
|
8
|
+
ensureColumnCoverage(tableElement, index + 1);
|
|
9
|
+
const columnElement = replaceRun(tableElement.children, isElementWithTag(COLUMN_TAG), index, COLUMN_REPEAT_ATTR, () => el(COLUMN_TAG));
|
|
10
|
+
const automaticStyles = ensureAutomaticStyles(pkg);
|
|
11
|
+
const styleName = nextStyleName(automaticStyles, "style:style", "OdsColumn");
|
|
12
|
+
automaticStyles.children.push(el("style:style", {
|
|
13
|
+
"style:name": styleName,
|
|
14
|
+
"style:family": "table-column"
|
|
15
|
+
}, [el("style:table-column-properties", { "style:column-width": formatOdfLength(widthPt) })]));
|
|
16
|
+
setAttr(columnElement, "table:style-name", styleName);
|
|
17
|
+
}
|
|
18
|
+
function writeRowHeight(pkg, tableElement, index, heightPt) {
|
|
19
|
+
const rowElement = replaceRun(tableElement.children, isElementWithTag(ROW_TAG), index, ROW_REPEAT_ATTR, () => el(ROW_TAG));
|
|
20
|
+
const automaticStyles = ensureAutomaticStyles(pkg);
|
|
21
|
+
const styleName = nextStyleName(automaticStyles, "style:style", "OdsRow");
|
|
22
|
+
automaticStyles.children.push(el("style:style", {
|
|
23
|
+
"style:name": styleName,
|
|
24
|
+
"style:family": "table-row"
|
|
25
|
+
}, [el("style:table-row-properties", { "style:row-height": formatOdfLength(heightPt) })]));
|
|
26
|
+
setAttr(rowElement, "table:style-name", styleName);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { writeColumnWidth, writeRowHeight };
|
|
@@ -9,6 +9,8 @@ function buildOdsPackage(content) {
|
|
|
9
9
|
const odsSheet = editor.addSheet(sheet.name);
|
|
10
10
|
odsSheet.printSettings = sheet.printSettings;
|
|
11
11
|
for (const cell of sheet.cells) appendCell(odsSheet, cell);
|
|
12
|
+
for (const column of sheet.columns) odsSheet.setColumnWidth(column.index, column.widthPt);
|
|
13
|
+
for (const row of sheet.rows) odsSheet.setRowHeight(row.index, row.heightPt);
|
|
12
14
|
}
|
|
13
15
|
return editor.toPackage();
|
|
14
16
|
}
|
package/dist/edit/ods/content.js
CHANGED
|
@@ -8,6 +8,8 @@ function buildOdsPackage(content) {
|
|
|
8
8
|
const odsSheet = editor.addSheet(sheet.name);
|
|
9
9
|
odsSheet.printSettings = sheet.printSettings;
|
|
10
10
|
for (const cell of sheet.cells) appendCell(odsSheet, cell);
|
|
11
|
+
for (const column of sheet.columns) odsSheet.setColumnWidth(column.index, column.widthPt);
|
|
12
|
+
for (const row of sheet.rows) odsSheet.setRowHeight(row.index, row.heightPt);
|
|
11
13
|
}
|
|
12
14
|
return editor.toPackage();
|
|
13
15
|
}
|
package/dist/edit/ods/sheet.cjs
CHANGED
|
@@ -2,6 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_xml_edit = require("../../xml/edit.cjs");
|
|
3
3
|
const require_edit_ods_address = require("./address.cjs");
|
|
4
4
|
const require_edit_ods_cell = require("./cell.cjs");
|
|
5
|
+
const require_edit_ods_column_row = require("./column-row.cjs");
|
|
5
6
|
const require_edit_ods_print_settings = require("./print-settings.cjs");
|
|
6
7
|
let ooxml_js = require("ooxml.js");
|
|
7
8
|
let odf_js = require("odf.js");
|
|
@@ -35,6 +36,12 @@ var OdsSheet = class {
|
|
|
35
36
|
set printSettings(value) {
|
|
36
37
|
require_edit_ods_print_settings.writeSheetPrintSettings(this.pkg, this.live(), value);
|
|
37
38
|
}
|
|
39
|
+
setColumnWidth(index, widthPt) {
|
|
40
|
+
require_edit_ods_column_row.writeColumnWidth(this.pkg, this.live(), index, widthPt);
|
|
41
|
+
}
|
|
42
|
+
setRowHeight(index, heightPt) {
|
|
43
|
+
require_edit_ods_column_row.writeRowHeight(this.pkg, this.live(), index, heightPt);
|
|
44
|
+
}
|
|
38
45
|
cell(row, column) {
|
|
39
46
|
const node = require_edit_ods_address.resolveCellNode(this.live(), row, column);
|
|
40
47
|
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range -- address the merge's own anchor cell instead`);
|
|
@@ -13,6 +13,8 @@ declare class OdsSheet {
|
|
|
13
13
|
set name(value: string);
|
|
14
14
|
get printSettings(): ContentSheetPrintSettings;
|
|
15
15
|
set printSettings(value: ContentSheetPrintSettings);
|
|
16
|
+
setColumnWidth(index: number, widthPt: number): void;
|
|
17
|
+
setRowHeight(index: number, heightPt: number): void;
|
|
16
18
|
cell(row: number, column: number): OdsCell;
|
|
17
19
|
cellAt(reference: string): OdsCell;
|
|
18
20
|
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): OdsCell;
|
package/dist/edit/ods/sheet.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ declare class OdsSheet {
|
|
|
13
13
|
set name(value: string);
|
|
14
14
|
get printSettings(): ContentSheetPrintSettings;
|
|
15
15
|
set printSettings(value: ContentSheetPrintSettings);
|
|
16
|
+
setColumnWidth(index: number, widthPt: number): void;
|
|
17
|
+
setRowHeight(index: number, heightPt: number): void;
|
|
16
18
|
cell(row: number, column: number): OdsCell;
|
|
17
19
|
cellAt(reference: string): OdsCell;
|
|
18
20
|
mergeCells(startRow: number, startColumn: number, rowSpan: number, colSpan: number): OdsCell;
|
package/dist/edit/ods/sheet.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { removeChild, setAttr } from "../../xml/edit.js";
|
|
2
2
|
import { COVERED_CELL_TAG, resolveCellNode } from "./address.js";
|
|
3
3
|
import { OdsCell } from "./cell.js";
|
|
4
|
+
import { writeColumnWidth, writeRowHeight } from "./column-row.js";
|
|
4
5
|
import { readSheetPrintSettings, writeSheetPrintSettings } from "./print-settings.js";
|
|
5
6
|
import { attr } from "ooxml.js";
|
|
6
7
|
import { parseCellReference } from "odf.js";
|
|
@@ -34,6 +35,12 @@ var OdsSheet = class {
|
|
|
34
35
|
set printSettings(value) {
|
|
35
36
|
writeSheetPrintSettings(this.pkg, this.live(), value);
|
|
36
37
|
}
|
|
38
|
+
setColumnWidth(index, widthPt) {
|
|
39
|
+
writeColumnWidth(this.pkg, this.live(), index, widthPt);
|
|
40
|
+
}
|
|
41
|
+
setRowHeight(index, heightPt) {
|
|
42
|
+
writeRowHeight(this.pkg, this.live(), index, heightPt);
|
|
43
|
+
}
|
|
37
44
|
cell(row, column) {
|
|
38
45
|
const node = resolveCellNode(this.live(), row, column);
|
|
39
46
|
if (node.tag === "table:covered-table-cell") throw new Error(`cell (${row}, ${column}) is covered by a merged range -- address the merge's own anchor cell instead`);
|
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,9 @@ const require_odf_odt_read = require("./odf/odt/read.cjs");
|
|
|
40
40
|
const require_odf_odp_read = require("./odf/odp/read.cjs");
|
|
41
41
|
const require_odf_ods_read = require("./odf/ods/read.cjs");
|
|
42
42
|
const require_odf_odg_read = require("./odf/odg/read.cjs");
|
|
43
|
+
const require_markdown_text = require("./markdown/text.cjs");
|
|
44
|
+
const require_markdown_read = require("./markdown/read.cjs");
|
|
45
|
+
const require_markdown_write = require("./markdown/write.cjs");
|
|
43
46
|
const require_layout_engine = require("./layout/engine.cjs");
|
|
44
47
|
const require_layout_slides = require("./layout/slides.cjs");
|
|
45
48
|
const require_ports_abort = require("./ports/abort.cjs");
|
|
@@ -304,6 +307,7 @@ Object.defineProperty(exports, "LayoutDocumentSchema", {
|
|
|
304
307
|
return document_schema_js.LayoutDocumentSchema;
|
|
305
308
|
}
|
|
306
309
|
});
|
|
310
|
+
exports.MarkdownBytesSchema = require_model_bytes.MarkdownBytesSchema;
|
|
307
311
|
Object.defineProperty(exports, "NOOP_DIAGNOSTIC_SINK", {
|
|
308
312
|
enumerable: true,
|
|
309
313
|
get: function() {
|
|
@@ -460,6 +464,7 @@ Object.defineProperty(exports, "base64ToBytes", {
|
|
|
460
464
|
}
|
|
461
465
|
});
|
|
462
466
|
exports.buildDocxPackage = require_edit_docx_content.buildDocxPackage;
|
|
467
|
+
exports.buildMarkdownText = require_markdown_write.buildMarkdownText;
|
|
463
468
|
exports.buildOdgPackage = require_edit_odg_content.buildOdgPackage;
|
|
464
469
|
exports.buildOdpPackage = require_edit_odp_content.buildOdpPackage;
|
|
465
470
|
exports.buildOdsPackage = require_edit_ods_content.buildOdsPackage;
|
|
@@ -525,6 +530,7 @@ Object.defineProperty(exports, "decodeEntities", {
|
|
|
525
530
|
}
|
|
526
531
|
});
|
|
527
532
|
exports.decodeHsqldbCachedTables = require_hsqldb_cache.decodeHsqldbCachedTables;
|
|
533
|
+
exports.decodeMarkdownText = require_markdown_text.decodeMarkdownText;
|
|
528
534
|
Object.defineProperty(exports, "decodePackage", {
|
|
529
535
|
enumerable: true,
|
|
530
536
|
get: function() {
|
|
@@ -550,6 +556,7 @@ Object.defineProperty(exports, "documentSchemaKindOf", {
|
|
|
550
556
|
}
|
|
551
557
|
});
|
|
552
558
|
exports.docxPdfCodec = require_convert_codec.docxPdfCodec;
|
|
559
|
+
exports.docxToMarkdown = require_convert_convert.docxToMarkdown;
|
|
553
560
|
exports.docxToOdt = require_convert_convert.docxToOdt;
|
|
554
561
|
exports.docxToPdf = require_convert_convert.docxToPdf;
|
|
555
562
|
exports.elementChildren = require_mathml_nodes.elementChildren;
|
|
@@ -566,6 +573,7 @@ Object.defineProperty(exports, "encodeCompactPackage", {
|
|
|
566
573
|
return ooxml_js.encodeCompactPackage;
|
|
567
574
|
}
|
|
568
575
|
});
|
|
576
|
+
exports.encodeMarkdownText = require_markdown_text.encodeMarkdownText;
|
|
569
577
|
Object.defineProperty(exports, "encodePackage", {
|
|
570
578
|
enumerable: true,
|
|
571
579
|
get: function() {
|
|
@@ -617,6 +625,12 @@ Object.defineProperty(exports, "loadMathFont", {
|
|
|
617
625
|
});
|
|
618
626
|
exports.localName = require_mathml_nodes.localName;
|
|
619
627
|
exports.mapMathVariant = require_mathml_variant.mapMathVariant;
|
|
628
|
+
exports.markdownDocxCodec = require_convert_codec.markdownDocxCodec;
|
|
629
|
+
exports.markdownOdtCodec = require_convert_codec.markdownOdtCodec;
|
|
630
|
+
exports.markdownPdfCodec = require_convert_codec.markdownPdfCodec;
|
|
631
|
+
exports.markdownToDocx = require_convert_convert.markdownToDocx;
|
|
632
|
+
exports.markdownToOdt = require_convert_convert.markdownToOdt;
|
|
633
|
+
exports.markdownToPdf = require_convert_convert.markdownToPdf;
|
|
620
634
|
exports.mathMlTextContent = require_mathml_nodes.textContent;
|
|
621
635
|
exports.odbTablesToSpreadsheetDocument = require_odb_spreadsheet.odbTablesToSpreadsheetDocument;
|
|
622
636
|
exports.odbToCsv = require_convert_convert.odbToCsv;
|
|
@@ -636,6 +650,7 @@ exports.odsXlsxCodec = require_convert_codec.odsXlsxCodec;
|
|
|
636
650
|
exports.odtDocxCodec = require_convert_codec.odtDocxCodec;
|
|
637
651
|
exports.odtPdfCodec = require_convert_codec.odtPdfCodec;
|
|
638
652
|
exports.odtToDocx = require_convert_convert.odtToDocx;
|
|
653
|
+
exports.odtToMarkdown = require_convert_convert.odtToMarkdown;
|
|
639
654
|
exports.odtToPdf = require_convert_convert.odtToPdf;
|
|
640
655
|
exports.openDocx = require_edit_docx_editor.openDocx;
|
|
641
656
|
exports.openOdg = require_edit_odg_editor.openOdg;
|
|
@@ -670,16 +685,19 @@ Object.defineProperty(exports, "pdfCodec", {
|
|
|
670
685
|
}
|
|
671
686
|
});
|
|
672
687
|
exports.pdfToDocx = require_convert_convert.pdfToDocx;
|
|
688
|
+
exports.pdfToMarkdown = require_convert_convert.pdfToMarkdown;
|
|
673
689
|
exports.pdfToOdg = require_convert_convert.pdfToOdg;
|
|
674
690
|
exports.pdfToOdp = require_convert_convert.pdfToOdp;
|
|
675
691
|
exports.pdfToOds = require_convert_convert.pdfToOds;
|
|
676
692
|
exports.pdfToOdt = require_convert_convert.pdfToOdt;
|
|
677
693
|
exports.pdfToPptx = require_convert_convert.pdfToPptx;
|
|
694
|
+
exports.pdfToXlsx = require_convert_convert.pdfToXlsx;
|
|
678
695
|
exports.pptxPdfCodec = require_convert_codec.pptxPdfCodec;
|
|
679
696
|
exports.pptxToOdp = require_convert_convert.pptxToOdp;
|
|
680
697
|
exports.pptxToPdf = require_convert_convert.pptxToPdf;
|
|
681
698
|
exports.readDocxContent = require_ooxml_docx_read.readDocxContent;
|
|
682
699
|
exports.readFirebirdBackup = require_firebird_backup.readFirebirdBackup;
|
|
700
|
+
exports.readMarkdownContent = require_markdown_read.readMarkdownContent;
|
|
683
701
|
exports.readOdbTables = require_odb_read.readOdbTables;
|
|
684
702
|
exports.readOdfEmbeddedFormula = require_odf_formula_read.readOdfEmbeddedFormula;
|
|
685
703
|
exports.readOdfFormulaContent = require_odf_formula_read.readOdfFormulaContent;
|
|
@@ -760,7 +778,9 @@ Object.defineProperty(exports, "writePdf", {
|
|
|
760
778
|
return pdf_codec.writePdf;
|
|
761
779
|
}
|
|
762
780
|
});
|
|
781
|
+
exports.xlsxPdfCodec = require_convert_codec.xlsxPdfCodec;
|
|
763
782
|
exports.xlsxToOds = require_convert_convert.xlsxToOds;
|
|
783
|
+
exports.xlsxToPdf = require_convert_convert.xlsxToPdf;
|
|
764
784
|
Object.defineProperty(exports, "xmlCodec", {
|
|
765
785
|
enumerable: true,
|
|
766
786
|
get: function() {
|