@stll/folio-core 0.27.1 → 0.28.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.
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { escapeTableCell } from "../../markdown/escape.js";
|
|
2
2
|
import { RELATIONSHIP_TYPES, parseRelationships } from "../relsParser.js";
|
|
3
3
|
import { findAllDeep, findDeep, getAttribute, getAttributeByNamespaceUri, getLocalName, getNamespaceUri, getTextContent, parseXml } from "../xmlParser.js";
|
|
4
|
-
import { loadDocxArchive } from "./boundedArchive.js";
|
|
4
|
+
import { DocxArchiveError, loadDocxArchive } from "./boundedArchive.js";
|
|
5
5
|
//#region src/docx/server/extractDocxText.ts
|
|
6
6
|
const DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels";
|
|
7
|
+
const ARCHIVE_LIMIT_REASON = "total-too-large";
|
|
7
8
|
const WORDPROCESSINGML_NAMESPACES = /* @__PURE__ */ new Set(["http://schemas.openxmlformats.org/wordprocessingml/2006/main", "http://purl.oclc.org/ooxml/wordprocessingml/main"]);
|
|
8
9
|
const childElements = (element) => element.elements?.filter((child) => child.type === "element") ?? [];
|
|
9
10
|
const wordElementName = (element) => WORDPROCESSINGML_NAMESPACES.has(getNamespaceUri(element) ?? "") ? getLocalName(element.name) : null;
|
|
@@ -105,6 +106,23 @@ const MAX_TABLE_COLUMNS = 256;
|
|
|
105
106
|
const MAX_NESTED_TABLE_DEPTH = 8;
|
|
106
107
|
/** Rows collected from one `w:tbl`. The column cap alone leaves row count unbounded. */
|
|
107
108
|
const MAX_TABLE_ROWS = 8192;
|
|
109
|
+
/** Source and rendered characters retained across every table in one extraction. */
|
|
110
|
+
const MAX_TABLE_CHARACTERS = 8 * 1024 * 1024;
|
|
111
|
+
const createTableExtractionBudget = () => ({
|
|
112
|
+
remainingSourceCharacters: MAX_TABLE_CHARACTERS,
|
|
113
|
+
remainingRenderedCharacters: MAX_TABLE_CHARACTERS
|
|
114
|
+
});
|
|
115
|
+
const chargeTableCharacters = ({ budget, characters, kind }) => {
|
|
116
|
+
if (characters > (kind === "source" ? budget.remainingSourceCharacters : budget.remainingRenderedCharacters)) throw new DocxArchiveError({
|
|
117
|
+
message: `Extracted DOCX table ${kind} text exceeded the ${MAX_TABLE_CHARACTERS}-character limit`,
|
|
118
|
+
reason: ARCHIVE_LIMIT_REASON
|
|
119
|
+
});
|
|
120
|
+
if (kind === "source") {
|
|
121
|
+
budget.remainingSourceCharacters -= characters;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
budget.remainingRenderedCharacters -= characters;
|
|
125
|
+
};
|
|
108
126
|
/**
|
|
109
127
|
* Characters one extraction emits, shared by the body and every header/footer
|
|
110
128
|
* part. Element count is bounded at unzip, but a bounded element count still
|
|
@@ -112,19 +130,16 @@ const MAX_TABLE_ROWS = 8192;
|
|
|
112
130
|
* GFM scaffolding are counted, so the emitted side carries its own ceiling.
|
|
113
131
|
*/
|
|
114
132
|
const MAX_EXTRACTED_CHARS = 8e6;
|
|
115
|
-
|
|
116
|
-
* Collect a table's `w:tr`, or a row's `w:tc`, seeing through the wrappers Word
|
|
117
|
-
* puts around them (`w:sdt` / `w:sdtContent` content controls, `w:customXml`).
|
|
118
|
-
* The walk stops at `w:tbl` and `w:p` so a nested table's rows and cells never
|
|
119
|
-
* leak into the grid of the table that contains them.
|
|
120
|
-
*/
|
|
121
|
-
const collectTableParts = (parent, localName, limit) => {
|
|
133
|
+
const collectTableParts = ({ parent, localName, limit }) => {
|
|
122
134
|
const parts = [];
|
|
123
135
|
const walk = (node) => {
|
|
124
136
|
for (const child of childElements(node)) {
|
|
125
|
-
if (parts.length >= limit) return;
|
|
126
137
|
const childName = wordElementName(child);
|
|
127
138
|
if (childName === localName) {
|
|
139
|
+
if (parts.length >= limit) throw new DocxArchiveError({
|
|
140
|
+
message: `Extracted DOCX table exceeded the ${limit}-${localName} limit`,
|
|
141
|
+
reason: ARCHIVE_LIMIT_REASON
|
|
142
|
+
});
|
|
128
143
|
parts.push(child);
|
|
129
144
|
continue;
|
|
130
145
|
}
|
|
@@ -152,7 +167,15 @@ const readCellSourceParagraphs = (cell, depth) => {
|
|
|
152
167
|
}
|
|
153
168
|
if (childName === "tbl") {
|
|
154
169
|
if (depth >= MAX_NESTED_TABLE_DEPTH) continue;
|
|
155
|
-
for (const row of collectTableParts(
|
|
170
|
+
for (const row of collectTableParts({
|
|
171
|
+
parent: child,
|
|
172
|
+
localName: "tr",
|
|
173
|
+
limit: MAX_TABLE_ROWS
|
|
174
|
+
})) for (const nestedCell of collectTableParts({
|
|
175
|
+
parent: row,
|
|
176
|
+
localName: "tc",
|
|
177
|
+
limit: MAX_TABLE_COLUMNS
|
|
178
|
+
})) for (const paragraph of readCellSourceParagraphs(nestedCell, depth + 1)) paragraphs.push(paragraph);
|
|
156
179
|
continue;
|
|
157
180
|
}
|
|
158
181
|
walk(child);
|
|
@@ -161,18 +184,26 @@ const readCellSourceParagraphs = (cell, depth) => {
|
|
|
161
184
|
walk(cell);
|
|
162
185
|
return paragraphs;
|
|
163
186
|
};
|
|
164
|
-
const readCellRenderedLines = (cell, depth) => {
|
|
187
|
+
const readCellRenderedLines = (cell, { depth, budget }) => {
|
|
165
188
|
const lines = [];
|
|
166
189
|
const walk = (node) => {
|
|
167
190
|
for (const child of childElements(node)) {
|
|
168
191
|
const childName = wordElementName(child);
|
|
169
192
|
if (childName === "p") {
|
|
170
193
|
const text = collectText(child);
|
|
194
|
+
chargeTableCharacters({
|
|
195
|
+
budget,
|
|
196
|
+
characters: text.length,
|
|
197
|
+
kind: "source"
|
|
198
|
+
});
|
|
171
199
|
if (text.length > 0) lines.push(text);
|
|
172
200
|
continue;
|
|
173
201
|
}
|
|
174
202
|
if (childName === "tbl") {
|
|
175
|
-
if (depth < MAX_NESTED_TABLE_DEPTH) for (const line of flattenNestedTable(child,
|
|
203
|
+
if (depth < MAX_NESTED_TABLE_DEPTH) for (const line of flattenNestedTable(child, {
|
|
204
|
+
depth: depth + 1,
|
|
205
|
+
budget
|
|
206
|
+
})) lines.push(line);
|
|
176
207
|
continue;
|
|
177
208
|
}
|
|
178
209
|
walk(child);
|
|
@@ -181,10 +212,21 @@ const readCellRenderedLines = (cell, depth) => {
|
|
|
181
212
|
walk(cell);
|
|
182
213
|
return lines;
|
|
183
214
|
};
|
|
184
|
-
const flattenNestedTable = (table, depth) => {
|
|
215
|
+
const flattenNestedTable = (table, { depth, budget }) => {
|
|
185
216
|
const lines = [];
|
|
186
|
-
for (const row of collectTableParts(
|
|
187
|
-
|
|
217
|
+
for (const row of collectTableParts({
|
|
218
|
+
parent: table,
|
|
219
|
+
localName: "tr",
|
|
220
|
+
limit: MAX_TABLE_ROWS
|
|
221
|
+
})) {
|
|
222
|
+
const cells = collectTableParts({
|
|
223
|
+
parent: row,
|
|
224
|
+
localName: "tc",
|
|
225
|
+
limit: MAX_TABLE_COLUMNS
|
|
226
|
+
}).map((cell) => readCellRenderedLines(cell, {
|
|
227
|
+
depth,
|
|
228
|
+
budget
|
|
229
|
+
}).join("\n"));
|
|
188
230
|
if (cells.some((text) => text.length > 0)) lines.push(cells.join(NESTED_TABLE_CELL_SEPARATOR));
|
|
189
231
|
}
|
|
190
232
|
return lines;
|
|
@@ -194,7 +236,7 @@ const emptyTableCell = () => ({
|
|
|
194
236
|
paragraphs: [],
|
|
195
237
|
gridSpan: 1
|
|
196
238
|
});
|
|
197
|
-
const readTableCell = (cell, depth) => {
|
|
239
|
+
const readTableCell = (cell, { depth, budget }) => {
|
|
198
240
|
const properties = findWordChild(cell, "tcPr");
|
|
199
241
|
const gridSpanValue = getWordAttribute(findWordChild(properties, "gridSpan"), "val");
|
|
200
242
|
const parsedGridSpan = gridSpanValue === null ? 1 : Number.parseInt(gridSpanValue, 10);
|
|
@@ -205,10 +247,12 @@ const readTableCell = (cell, depth) => {
|
|
|
205
247
|
paragraphs: [],
|
|
206
248
|
gridSpan
|
|
207
249
|
};
|
|
208
|
-
const paragraphs = readCellSourceParagraphs(cell, depth);
|
|
209
250
|
return {
|
|
210
|
-
text: readCellRenderedLines(cell,
|
|
211
|
-
|
|
251
|
+
text: readCellRenderedLines(cell, {
|
|
252
|
+
depth,
|
|
253
|
+
budget
|
|
254
|
+
}).join("\n"),
|
|
255
|
+
paragraphs: readCellSourceParagraphs(cell, depth),
|
|
212
256
|
gridSpan
|
|
213
257
|
};
|
|
214
258
|
};
|
|
@@ -235,18 +279,29 @@ const readRowGridOffset = (row, localName) => {
|
|
|
235
279
|
const parsed = value === null ? 0 : Number.parseInt(value, 10);
|
|
236
280
|
return Number.isFinite(parsed) && parsed > 0 ? Math.min(parsed, MAX_TABLE_COLUMNS) : 0;
|
|
237
281
|
};
|
|
238
|
-
const readTableGrid = (table) => {
|
|
282
|
+
const readTableGrid = (table, budget) => {
|
|
239
283
|
const rows = [];
|
|
240
284
|
let columnCount = 0;
|
|
241
285
|
let firstRowIsHeader = false;
|
|
242
|
-
for (const [rowIndex, row] of collectTableParts(
|
|
286
|
+
for (const [rowIndex, row] of collectTableParts({
|
|
287
|
+
parent: table,
|
|
288
|
+
localName: "tr",
|
|
289
|
+
limit: MAX_TABLE_ROWS
|
|
290
|
+
}).entries()) {
|
|
243
291
|
if (rowIndex === 0) firstRowIsHeader = declaresHeaderRow(row);
|
|
244
292
|
const columns = [];
|
|
245
293
|
const gridBefore = readRowGridOffset(row, "gridBefore");
|
|
246
294
|
for (let index = 0; index < gridBefore; index += 1) columns.push(emptyTableCell());
|
|
247
|
-
for (const cell of collectTableParts(
|
|
295
|
+
for (const cell of collectTableParts({
|
|
296
|
+
parent: row,
|
|
297
|
+
localName: "tc",
|
|
298
|
+
limit: MAX_TABLE_COLUMNS
|
|
299
|
+
})) {
|
|
248
300
|
if (columns.length >= MAX_TABLE_COLUMNS) break;
|
|
249
|
-
const extractedCell = readTableCell(cell,
|
|
301
|
+
const extractedCell = readTableCell(cell, {
|
|
302
|
+
depth: 0,
|
|
303
|
+
budget
|
|
304
|
+
});
|
|
250
305
|
columns.push(extractedCell);
|
|
251
306
|
const padding = Math.min(extractedCell.gridSpan - 1, MAX_TABLE_COLUMNS - columns.length);
|
|
252
307
|
for (let index = 0; index < padding; index++) columns.push(emptyTableCell());
|
|
@@ -269,12 +324,17 @@ const toRowLine = (columns, columnCount) => {
|
|
|
269
324
|
return `| ${cells.join(" | ")} |`;
|
|
270
325
|
};
|
|
271
326
|
/** Render a `w:tbl` as GFM rows. A table with no cell at all renders nothing. */
|
|
272
|
-
const renderTableRows = (table, tableIndex) => {
|
|
273
|
-
const { rows, columnCount, firstRowIsHeader } = readTableGrid(table);
|
|
327
|
+
const renderTableRows = ({ table, tableIndex, budget }) => {
|
|
328
|
+
const { rows, columnCount, firstRowIsHeader } = readTableGrid(table, budget);
|
|
274
329
|
const [firstRow, ...remainingRows] = rows;
|
|
275
330
|
if (columnCount === 0 || firstRow === void 0) return [];
|
|
276
331
|
const rendered = [];
|
|
277
332
|
const pushScaffolding = (text, kind) => {
|
|
333
|
+
chargeTableCharacters({
|
|
334
|
+
budget,
|
|
335
|
+
characters: text.length,
|
|
336
|
+
kind: "rendered"
|
|
337
|
+
});
|
|
278
338
|
rendered.push({
|
|
279
339
|
text,
|
|
280
340
|
position: {
|
|
@@ -284,8 +344,14 @@ const renderTableRows = (table, tableIndex) => {
|
|
|
284
344
|
});
|
|
285
345
|
};
|
|
286
346
|
const pushCells = (cells) => {
|
|
347
|
+
const text = toRowLine(cells, columnCount);
|
|
348
|
+
chargeTableCharacters({
|
|
349
|
+
budget,
|
|
350
|
+
characters: text.length,
|
|
351
|
+
kind: "rendered"
|
|
352
|
+
});
|
|
287
353
|
rendered.push({
|
|
288
|
-
text
|
|
354
|
+
text,
|
|
289
355
|
position: {
|
|
290
356
|
table: tableIndex,
|
|
291
357
|
kind: "cells",
|
|
@@ -304,7 +370,7 @@ const renderTableRows = (table, tableIndex) => {
|
|
|
304
370
|
return rendered;
|
|
305
371
|
};
|
|
306
372
|
const createCharBudget = () => ({ remaining: MAX_EXTRACTED_CHARS });
|
|
307
|
-
const extractContainer = ({ container, source, startIndex, startTableIndex, budget }) => {
|
|
373
|
+
const extractContainer = ({ container, source, startIndex, startTableIndex, budget, tableBudget }) => {
|
|
308
374
|
const paragraphs = [];
|
|
309
375
|
let charCount = 0;
|
|
310
376
|
let tableCount = 0;
|
|
@@ -341,7 +407,11 @@ const extractContainer = ({ container, source, startIndex, startTableIndex, budg
|
|
|
341
407
|
if (budget.remaining <= 0) return;
|
|
342
408
|
const childName = wordElementName(child);
|
|
343
409
|
if (childName === "tbl") {
|
|
344
|
-
for (const row of renderTableRows(
|
|
410
|
+
for (const row of renderTableRows({
|
|
411
|
+
table: child,
|
|
412
|
+
tableIndex: startTableIndex + tableCount,
|
|
413
|
+
budget: tableBudget
|
|
414
|
+
})) pushTableRow(row);
|
|
345
415
|
tableCount += 1;
|
|
346
416
|
continue;
|
|
347
417
|
}
|
|
@@ -356,7 +426,7 @@ const extractContainer = ({ container, source, startIndex, startTableIndex, budg
|
|
|
356
426
|
tableCount
|
|
357
427
|
};
|
|
358
428
|
};
|
|
359
|
-
const extractParts = async ({ archive, source, rootName, startIndex, startTableIndex, paths, budget }) => {
|
|
429
|
+
const extractParts = async ({ archive, source, rootName, startIndex, startTableIndex, paths, budget, tableBudget }) => {
|
|
360
430
|
const paragraphs = [];
|
|
361
431
|
let charCount = 0;
|
|
362
432
|
let tableCount = 0;
|
|
@@ -371,7 +441,8 @@ const extractParts = async ({ archive, source, rootName, startIndex, startTableI
|
|
|
371
441
|
source,
|
|
372
442
|
startIndex: nextIndex,
|
|
373
443
|
startTableIndex: startTableIndex + tableCount,
|
|
374
|
-
budget
|
|
444
|
+
budget,
|
|
445
|
+
tableBudget
|
|
375
446
|
});
|
|
376
447
|
for (const paragraph of result.paragraphs) paragraphs.push(paragraph);
|
|
377
448
|
charCount += result.charCount;
|
|
@@ -443,6 +514,7 @@ const extractDocxText = async (bytes) => {
|
|
|
443
514
|
if (!body) return createEmptyResult();
|
|
444
515
|
const referencedParts = await resolveReferencedHeaderFooterParts(archive, root);
|
|
445
516
|
const budget = createCharBudget();
|
|
517
|
+
const tableBudget = createTableExtractionBudget();
|
|
446
518
|
const headers = await extractParts({
|
|
447
519
|
archive,
|
|
448
520
|
source: "header",
|
|
@@ -450,14 +522,16 @@ const extractDocxText = async (bytes) => {
|
|
|
450
522
|
startIndex: 0,
|
|
451
523
|
startTableIndex: 0,
|
|
452
524
|
paths: referencedParts.headers,
|
|
453
|
-
budget
|
|
525
|
+
budget,
|
|
526
|
+
tableBudget
|
|
454
527
|
});
|
|
455
528
|
const bodyResult = extractContainer({
|
|
456
529
|
container: body,
|
|
457
530
|
source: "body",
|
|
458
531
|
startIndex: headers.paragraphs.length,
|
|
459
532
|
startTableIndex: headers.tableCount,
|
|
460
|
-
budget
|
|
533
|
+
budget,
|
|
534
|
+
tableBudget
|
|
461
535
|
});
|
|
462
536
|
const footers = await extractParts({
|
|
463
537
|
archive,
|
|
@@ -466,7 +540,8 @@ const extractDocxText = async (bytes) => {
|
|
|
466
540
|
startIndex: headers.paragraphs.length + bodyResult.paragraphs.length,
|
|
467
541
|
startTableIndex: headers.tableCount + bodyResult.tableCount,
|
|
468
542
|
paths: referencedParts.footers,
|
|
469
|
-
budget
|
|
543
|
+
budget,
|
|
544
|
+
tableBudget
|
|
470
545
|
});
|
|
471
546
|
return {
|
|
472
547
|
paragraphs: [
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/docx/server/materializeYjsDocx.d.ts
|
|
2
|
+
/** Yjs fragment that stores Folio's canonical ProseMirror document. */
|
|
3
|
+
declare const FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME = "prosemirror";
|
|
4
|
+
/** Maximum accepted size of a complete Yjs collaboration state update. */
|
|
5
|
+
declare const FOLIO_YJS_UPDATE_MAX_BYTES: number;
|
|
6
|
+
/** Stable failure codes returned by server-side Yjs-to-DOCX materialization. */
|
|
7
|
+
declare const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES: readonly ["empty_update", "invalid_update", "missing_document", "update_too_large"];
|
|
8
|
+
/** Failure code for a rejected Yjs-to-DOCX materialization request. */
|
|
9
|
+
type FolioYjsDocxMaterializationErrorCode = (typeof FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES)[number];
|
|
10
|
+
declare const FolioYjsDocxMaterializationError_base: import("better-result").TaggedErrorClass<"FolioYjsDocxMaterializationError">;
|
|
11
|
+
/** Typed failure raised when a collaboration snapshot cannot be materialized. */
|
|
12
|
+
declare class FolioYjsDocxMaterializationError extends FolioYjsDocxMaterializationError_base<{
|
|
13
|
+
code: FolioYjsDocxMaterializationErrorCode;
|
|
14
|
+
message: string;
|
|
15
|
+
cause?: unknown;
|
|
16
|
+
}> {}
|
|
17
|
+
/** Inputs for materializing a complete Yjs state update into a DOCX package. */
|
|
18
|
+
type MaterializeYjsDocxOptions = {
|
|
19
|
+
/** Original DOCX whose package parts and non-body stories must be preserved. */
|
|
20
|
+
sourceDocx: ArrayBuffer | Uint8Array;
|
|
21
|
+
/** Complete Yjs state update containing Folio's ProseMirror fragment. */
|
|
22
|
+
yjsUpdate: Uint8Array;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Materialize a complete Folio Yjs state update into a DOCX while preserving
|
|
26
|
+
* package parts from the source document. This is the server-side equivalent
|
|
27
|
+
* of the browser editor's full save path for the main document story.
|
|
28
|
+
*/
|
|
29
|
+
declare const materializeYjsDocx: ({ sourceDocx, yjsUpdate }: MaterializeYjsDocxOptions) => Promise<ArrayBuffer>;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioYjsDocxMaterializationError, FolioYjsDocxMaterializationErrorCode, MaterializeYjsDocxOptions, materializeYjsDocx };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { fromProseDoc } from "../../prosemirror/conversion/fromProseDoc.js";
|
|
2
|
+
import { schema } from "../../prosemirror/schema/index.js";
|
|
3
|
+
import { parseDocx } from "../parser.js";
|
|
4
|
+
import { repackDocx } from "../rezip.js";
|
|
5
|
+
import { Result, TaggedError } from "better-result";
|
|
6
|
+
import { initProseMirrorDoc } from "y-prosemirror";
|
|
7
|
+
import * as Y from "yjs";
|
|
8
|
+
//#region src/docx/server/materializeYjsDocx.ts
|
|
9
|
+
/** Yjs fragment that stores Folio's canonical ProseMirror document. */
|
|
10
|
+
const FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME = "prosemirror";
|
|
11
|
+
/** Maximum accepted size of a complete Yjs collaboration state update. */
|
|
12
|
+
const FOLIO_YJS_UPDATE_MAX_BYTES = 10 * 1024 * 1024;
|
|
13
|
+
/** Stable failure codes returned by server-side Yjs-to-DOCX materialization. */
|
|
14
|
+
const FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES = [
|
|
15
|
+
"empty_update",
|
|
16
|
+
"invalid_update",
|
|
17
|
+
"missing_document",
|
|
18
|
+
"update_too_large"
|
|
19
|
+
];
|
|
20
|
+
/** Typed failure raised when a collaboration snapshot cannot be materialized. */
|
|
21
|
+
var FolioYjsDocxMaterializationError = class extends TaggedError("FolioYjsDocxMaterializationError") {};
|
|
22
|
+
const readProseMirrorDocument = (yjsUpdate) => {
|
|
23
|
+
if (yjsUpdate.byteLength === 0) throw new FolioYjsDocxMaterializationError({
|
|
24
|
+
code: "empty_update",
|
|
25
|
+
message: "Cannot materialize DOCX from an empty Yjs update."
|
|
26
|
+
});
|
|
27
|
+
if (yjsUpdate.byteLength > 10485760) throw new FolioYjsDocxMaterializationError({
|
|
28
|
+
code: "update_too_large",
|
|
29
|
+
message: "Yjs update exceeds the DOCX materialization limit."
|
|
30
|
+
});
|
|
31
|
+
const ydoc = new Y.Doc();
|
|
32
|
+
const parsed = Result.try({
|
|
33
|
+
try: () => {
|
|
34
|
+
Y.applyUpdate(ydoc, yjsUpdate);
|
|
35
|
+
const fragment = ydoc.getXmlFragment(FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME);
|
|
36
|
+
if (fragment.length === 0) throw new FolioYjsDocxMaterializationError({
|
|
37
|
+
code: "missing_document",
|
|
38
|
+
message: "Yjs update does not contain a Folio document."
|
|
39
|
+
});
|
|
40
|
+
return initProseMirrorDoc(fragment, schema).doc;
|
|
41
|
+
},
|
|
42
|
+
catch: (cause) => cause instanceof FolioYjsDocxMaterializationError ? cause : new FolioYjsDocxMaterializationError({
|
|
43
|
+
code: "invalid_update",
|
|
44
|
+
message: "Yjs update is not a valid Folio collaboration snapshot.",
|
|
45
|
+
cause
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
ydoc.destroy();
|
|
49
|
+
if (parsed.isOk()) return parsed.value;
|
|
50
|
+
throw parsed.error;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Materialize a complete Folio Yjs state update into a DOCX while preserving
|
|
54
|
+
* package parts from the source document. This is the server-side equivalent
|
|
55
|
+
* of the browser editor's full save path for the main document story.
|
|
56
|
+
*/
|
|
57
|
+
const materializeYjsDocx = async ({ sourceDocx, yjsUpdate }) => {
|
|
58
|
+
return await repackDocx(fromProseDoc(readProseMirrorDocument(yjsUpdate), await parseDocx(sourceDocx, { preloadFonts: false })));
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
export { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioYjsDocxMaterializationError, materializeYjsDocx };
|
package/dist/server.d.ts
CHANGED
|
@@ -24,6 +24,7 @@ import { CreateBilingualDocxOptions, CreateBilingualDocxResult, createBilingualD
|
|
|
24
24
|
import { docxToMarkdown } from "./docx/server/docxToMarkdown.js";
|
|
25
25
|
import { DocxParagraphSource, DocxTableRowKind, DocxTableRowPosition, ExtractedDocxParagraph, ExtractedDocxTableCell, ExtractedDocxTableCellParagraph, ExtractedDocxText, extractDocxText } from "./docx/server/extractDocxText.js";
|
|
26
26
|
import { FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FolioDocxInspectedXmlPart, FolioDocxPackageInspection, FolioDocxPackageInspectionError, FolioDocxPackageInspectionErrorCode, FolioDocxPackageInspectionLimits, FolioDocxPackagePart, FolioDocxPackagePartKind, InspectDocxPackageOptions, inspectDocxPackage } from "./docx/server/inspectDocxPackage.js";
|
|
27
|
+
import { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioYjsDocxMaterializationError, FolioYjsDocxMaterializationErrorCode, MaterializeYjsDocxOptions, materializeYjsDocx } from "./docx/server/materializeYjsDocx.js";
|
|
27
28
|
import { GenerateRedlineDocxOptions, GenerateRedlineDocxResult, GenerateRedlineUnprocessedStory, InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
|
|
28
29
|
import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioBlockDiff, FolioCompareDocxVersionsOptions, FolioDocumentMetadataValue, FolioFormatProperty, FolioMetadataDiff, FolioStoryDiff, FolioVersionBlockHandle, FolioVersionComparisonPrivacyTransform, FolioVersionComparisonScope, FolioVersionDiff, FolioVersionDiffPrivacyOptions, FolioVersionDiffPrivacyReport, FolioVersionDiffSegment, FolioVersionDiffSummaryCounts, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
|
|
29
|
-
export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioCompareDocxVersionsOptions, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
|
|
30
|
+
export { type ApplyDocxXmlPatchProposalArgs, type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type BilingualBorders, type BilingualParagraphRef, type BilingualRow, type BilingualRowKind, type BilingualTableParagraphRef, type CreateBilingualDocumentOptions, type CreateBilingualDocumentResult, type CreateBilingualDocxOptions, type CreateBilingualDocxResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, type DeriveBlockIdInput, type DocumentPreset, type DocumentStyleCatalog, type DocumentStyleCatalogEntry, type DocumentStyleSet, DocxArchiveError, type DocxArchiveOptions, type DocxParagraphSource, type DocxTableRowKind, type DocxTableRowPosition, EnsureParaIdsError, type EnsureParaIdsOptions, type EnsureParaIdsResult, type EvaluateDocxXmlPatchProposalArgs, type ExtractDocumentStyleSetOptions, type ExtractedDocxParagraph, type ExtractedDocxTableCell, type ExtractedDocxTableCellParagraph, type ExtractedDocxText, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditPrecondition, type FolioAIEditSnapshot, type FolioAIInlineFormatting, type FolioAITextRangeHandle, type FolioApplyDocumentOperationsOptions, type FolioApplyDocumentOperationsToStoryOptions, type FolioApplyOperationsOptions, type FolioBlockDiff, type FolioBlockId, type FolioCompareDocxVersionsOptions, type FolioDocumentMetadataProperty, type FolioDocumentMetadataValue, type FolioDocumentNavigationTarget, type FolioDocumentOperation, type FolioDocumentOperationAffectedTarget, type FolioDocumentOperationBatch, type FolioDocumentOperationCapabilities, type FolioDocumentOperationIssue, type FolioDocumentOperationMode, type FolioDocumentOperationPrecondition, type FolioDocumentOperationReceipt, type FolioDocumentOperationRecovery, type FolioDocumentOperationResult, type FolioDocumentOperationStatus, type FolioDocumentOperationStory, type FolioDocumentOperationType, type FolioDocumentOperationUndoFailureReason, type FolioDocumentOperationUndoHandle, type FolioDocumentOperationUndoResult, type FolioDocumentOutline, type FolioDocumentOutlineEntry, FolioDocumentPrivacyArchiveError, type FolioDocumentPrivacyOptions, type FolioDocumentPrivacyReport, type FolioDocumentPrivacyTransform, type FolioDocumentSection, type FolioDocumentSectionHandle, type FolioDocumentSectionReadResult, type FolioDocumentStory, type FolioDocumentStoryHandle, FolioDocumentStoryNotFoundError, type FolioDocxConformanceCheck, type FolioDocxConformanceCheckId, type FolioDocxConformanceCheckStatus, type FolioDocxConformanceIssue, type FolioDocxConformanceIssueCode, type FolioDocxConformanceReport, type FolioDocxConformanceStatus, type FolioDocxInspectedXmlPart, type FolioDocxPackageInspection, FolioDocxPackageInspectionError, type FolioDocxPackageInspectionErrorCode, type FolioDocxPackageInspectionLimits, type FolioDocxPackagePart, type FolioDocxPackagePartKind, type FolioDocxPreparedXmlReplacement, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioDocxXmlPatchApplication, FolioDocxXmlPatchApplicationError, type FolioDocxXmlPatchApplicationReceipt, type FolioDocxXmlPatchProposal, type FolioDocxXmlPatchProposalEvaluation, type FolioDocxXmlPatchProposalIssue, type FolioDocxXmlPatchProposalIssueCode, type FolioDocxXmlPatchProposalLimits, type FolioDocxXmlReplacement, type FolioEditableDocumentStoryHandle, type FolioFormatProperty, type FolioMetadataDiff, type FolioReadReviewedStoryOptions, type FolioResolveReviewedStoryOptions, type FolioResolvedReviewedView, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, type FolioReviewedStory, type FolioReviewedView, type FolioStoryDiff, type FolioVersionBlockHandle, type FolioVersionComparisonPrivacyTransform, type FolioVersionComparisonScope, type FolioVersionDiff, type FolioVersionDiffPrivacyOptions, type FolioVersionDiffPrivacyReport, type FolioVersionDiffSegment, type FolioVersionDiffSummaryCounts, FolioYjsDocxMaterializationError, type FolioYjsDocxMaterializationErrorCode, type GenerateRedlineDocxOptions, type GenerateRedlineDocxResult, type GenerateRedlineUnprocessedStory, HEADING_LEVELS, type HeadingLevel, type InspectDocxPackageOptions, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, type MaterializeYjsDocxOptions, type ParseOptions, type RewriteDocxMetadataPrivacyResult, STELLA_STYLE_SET_NAME, type TableCellSpec, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, type ValidateDocxConformanceOptions, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
|
package/dist/server.js
CHANGED
|
@@ -16,6 +16,7 @@ import { docxToMarkdown } from "./docx/server/docxToMarkdown.js";
|
|
|
16
16
|
import { FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, evaluateDocxXmlPatchProposal, parseFolioDocxXmlPatchProposal } from "./docx/server/evaluateDocxXmlPatchProposal.js";
|
|
17
17
|
import { extractDocxText } from "./docx/server/extractDocxText.js";
|
|
18
18
|
import { FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FolioDocxPackageInspectionError, inspectDocxPackage } from "./docx/server/inspectDocxPackage.js";
|
|
19
|
+
import { FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioYjsDocxMaterializationError, materializeYjsDocx } from "./docx/server/materializeYjsDocx.js";
|
|
19
20
|
import { FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, validateDocxConformance } from "./docx/server/validateDocxConformance.js";
|
|
20
21
|
import { InvalidGenerateRedlineDocxOptionsError, generateRedlineDocx } from "./redline.js";
|
|
21
22
|
import { extractDocumentStyleSet, extractDocumentStyleSetFromDocx, inspectDocumentStyles, inspectDocumentStylesFromDocx } from "./style-sets/extract.js";
|
|
@@ -24,4 +25,4 @@ import { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION } from "./style-set
|
|
|
24
25
|
import { deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
25
26
|
import { createEmptyDocument } from "./utils/createDocument.js";
|
|
26
27
|
import { FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, InvalidFolioVersionComparisonOptionsError, applyFolioVersionDiffPrivacy, compareDocxVersions, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope } from "./version-comparison.js";
|
|
27
|
-
export { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocxArchiveError, EnsureParaIdsError, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FolioDocumentPrivacyArchiveError, FolioDocumentStoryNotFoundError, FolioDocxPackageInspectionError, FolioDocxReviewer, FolioDocxXmlPatchApplicationError, HEADING_LEVELS, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
|
|
28
|
+
export { DOCUMENT_PRESET_VERSION, DOCUMENT_STYLE_SET_VERSION, DocxArchiveError, EnsureParaIdsError, FOLIO_DOCUMENT_METADATA_PROPERTIES, FOLIO_DOCUMENT_OPERATION_BATCH_MODES, FOLIO_DOCUMENT_OPERATION_CONTRACT_VERSION, FOLIO_DOCUMENT_OPERATION_MODES, FOLIO_DOCUMENT_OPERATION_MODES_BY_TYPE, FOLIO_DOCUMENT_OPERATION_PRECONDITIONS, FOLIO_DOCUMENT_OPERATION_STORIES, FOLIO_DOCUMENT_OPERATION_TYPES, FOLIO_DOCUMENT_PRIVACY_TRANSFORMS, FOLIO_DOCX_CONFORMANCE_CHECKS, FOLIO_DOCX_CONFORMANCE_ISSUE_CODES, FOLIO_DOCX_CONFORMANCE_PROFILE, FOLIO_DOCX_CONFORMANCE_REPORT_VERSION, FOLIO_DOCX_PACKAGE_INSPECTION_DEFAULTS, FOLIO_DOCX_PACKAGE_INSPECTION_ERROR_CODES, FOLIO_DOCX_PACKAGE_INSPECTION_VERSION, FOLIO_DOCX_XML_PATCH_APPLICATION_PROFILE, FOLIO_DOCX_XML_PATCH_APPLICATION_VERSION, FOLIO_DOCX_XML_PATCH_PROPOSAL_DEFAULTS, FOLIO_DOCX_XML_PATCH_PROPOSAL_ISSUE_CODES, FOLIO_DOCX_XML_PATCH_PROPOSAL_PROFILE, FOLIO_DOCX_XML_PATCH_PROPOSAL_VERSION, FOLIO_RESOLVED_REVIEWED_VIEWS, FOLIO_REVIEWED_VIEWS, FOLIO_VERSION_COMPARISON_PRIVACY_TRANSFORMS, FOLIO_VERSION_COMPARISON_SCOPES, FOLIO_YJS_DOCX_MATERIALIZATION_ERROR_CODES, FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME, FOLIO_YJS_UPDATE_MAX_BYTES, FolioDocumentPrivacyArchiveError, FolioDocumentStoryNotFoundError, FolioDocxPackageInspectionError, FolioDocxReviewer, FolioDocxXmlPatchApplicationError, FolioYjsDocxMaterializationError, HEADING_LEVELS, InvalidBilingualDocumentOptionsError, InvalidFolioDocumentOperationBatchError, InvalidFolioDocumentPrivacyOptionsError, InvalidFolioDocxXmlPatchProposalError, InvalidFolioDocxXmlPatchProposalOptionsError, InvalidFolioReportBuilderOptionsError, InvalidFolioVersionComparisonOptionsError, InvalidGenerateRedlineDocxOptionsError, STELLA_STYLE_SET_NAME, UnsupportedFolioDocumentOperationVersionError, UnsupportedFolioDocxXmlPatchApplicationProfileError, UnsupportedFolioReviewedViewError, applyDocxXmlPatchProposal, applyFolioAIEditsToBuffer, applyFolioVersionDiffPrivacy, assertSupportedFolioDocumentOperationVersion, bookmark, compareDocxVersions, createBilingualDocument, createBilingualDocx, createDocx, createEmptyDocument, createFolioAITextRangeHandle, createStellaStyleDocumentPreset, createStellaStyleSet, createTableOfContentsField, deriveBlockId, docxToMarkdown, endnote, ensureParaIds, evaluateDocxXmlPatchProposal, extractDocumentStyleSet, extractDocumentStyleSetFromDocx, extractDocxText, generateRedlineDocx, getFolioDocumentOperationCapabilities, getFolioDocumentOperationIssues, getFolioDocumentOperationReceipts, getFolioDocumentOutline, getFolioParaIdFromBlockId, hashFolioAIBlockText, heading, hyperlink, inspectDocumentStyles, inspectDocumentStylesFromDocx, inspectDocxPackage, isFolioBlockId, isFolioDocumentOperationModeSupported, isFolioDocumentPrivacyTransform, isFolioResolvedReviewedView, isFolioReviewedView, isFolioVersionComparisonPrivacyTransform, isFolioVersionComparisonScope, isSequentialFolioBlockId, isSupportedFolioDocumentOperationVersion, materializeYjsDocx, normalizeFolioAIBlockText, pageBreak, paragraph, parseDocx, parseFolioDocumentOperationBatch, parseFolioDocxXmlPatchProposal, readBilingualDocument, readBilingualDocx, readFolioDocumentSection, replyToComment, rewriteDocxMetadataPrivacy, run, table, validateDocxConformance };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|
|
@@ -113,7 +113,7 @@
|
|
|
113
113
|
"perf": "bun scripts/profile-editor.ts"
|
|
114
114
|
},
|
|
115
115
|
"dependencies": {
|
|
116
|
-
"@stll/docx-core": "^0.17.
|
|
116
|
+
"@stll/docx-core": "^0.17.2",
|
|
117
117
|
"@stll/docx-utils": "^0.1.0",
|
|
118
118
|
"@stll/template-conditions": "^0.1.0",
|
|
119
119
|
"better-result": "3.0.1",
|