@beyondwork/docx-react-component 1.0.57 → 1.0.59
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 +1 -1
- package/package.json +2 -1
- package/src/api/awareness-identity-types.ts +4 -2
- package/src/api/comment-negotiation-types.ts +4 -1
- package/src/api/external-custody-types.ts +16 -0
- package/src/api/internal/build-ref-projections.ts +108 -0
- package/src/api/package-version.ts +1 -1
- package/src/api/participants-types.ts +11 -1
- package/src/api/public-types.ts +1149 -8
- package/src/api/scope-metadata-resolver-types.ts +6 -0
- package/src/compare/diff-engine.ts +3 -0
- package/src/core/commands/formatting-commands.ts +1 -0
- package/src/core/commands/index.ts +225 -16
- package/src/core/commands/legacy-form-field-commands.ts +181 -0
- package/src/core/commands/table-structure-commands.ts +149 -31
- package/src/core/selection/mapping.ts +20 -0
- package/src/core/state/editor-state.ts +2 -1
- package/src/index.ts +28 -0
- package/src/io/docx-session.ts +22 -3
- package/src/io/export/export-session.ts +11 -7
- package/src/io/export/ooxml-namespaces.ts +47 -0
- package/src/io/export/reattach-preserved-parts.ts +4 -16
- package/src/io/export/serialize-comments.ts +3 -131
- package/src/io/export/serialize-ffdata.ts +89 -0
- package/src/io/export/serialize-headers-footers.ts +5 -0
- package/src/io/export/serialize-main-document.ts +224 -34
- package/src/io/export/serialize-numbering.ts +22 -2
- package/src/io/export/serialize-revisions.ts +99 -0
- package/src/io/export/serialize-tables.ts +9 -0
- package/src/io/export/split-review-boundaries.ts +1 -0
- package/src/io/export/table-properties-xml.ts +14 -0
- package/src/io/load-scheduler.ts +70 -28
- package/src/io/normalize/normalize-text.ts +13 -0
- package/src/io/ooxml/_mini-xml.ts +198 -0
- package/src/io/ooxml/canonicalize-payload.ts +1 -4
- package/src/io/ooxml/chart/chart-style-table.ts +4 -3
- package/src/io/ooxml/chart/parse-chart-space.ts +2 -4
- package/src/io/ooxml/chart/parse-series.ts +2 -1
- package/src/io/ooxml/chart/resolve-color.ts +2 -2
- package/src/io/ooxml/chart/types.ts +6 -434
- package/src/io/ooxml/comment-presentation-payload.ts +6 -5
- package/src/io/ooxml/highlight-colors.ts +8 -5
- package/src/io/ooxml/parse-anchor.ts +68 -53
- package/src/io/ooxml/parse-comments.ts +14 -142
- package/src/io/ooxml/parse-complex-content.ts +3 -106
- package/src/io/ooxml/parse-drawing.ts +100 -195
- package/src/io/ooxml/parse-ffdata.ts +93 -0
- package/src/io/ooxml/parse-fields.ts +7 -146
- package/src/io/ooxml/parse-fill.ts +88 -8
- package/src/io/ooxml/parse-font-table.ts +5 -105
- package/src/io/ooxml/parse-footnotes.ts +28 -152
- package/src/io/ooxml/parse-headers-footers.ts +106 -212
- package/src/io/ooxml/parse-inline-media.ts +3 -200
- package/src/io/ooxml/parse-main-document.ts +180 -217
- package/src/io/ooxml/parse-numbering.ts +154 -335
- package/src/io/ooxml/parse-object.ts +147 -0
- package/src/io/ooxml/parse-ole-relationship.ts +82 -0
- package/src/io/ooxml/parse-paragraph-formatting.ts +7 -10
- package/src/io/ooxml/parse-picture-sdt.ts +85 -0
- package/src/io/ooxml/parse-picture.ts +120 -39
- package/src/io/ooxml/parse-revisions.ts +285 -51
- package/src/io/ooxml/parse-settings.ts +6 -99
- package/src/io/ooxml/parse-shapes.ts +25 -140
- package/src/io/ooxml/parse-styles.ts +3 -218
- package/src/io/ooxml/parse-tables.ts +76 -256
- package/src/io/ooxml/parse-theme.ts +1 -4
- package/src/io/ooxml/property-grab-bag.ts +5 -47
- package/src/io/ooxml/xml-element-serialize.ts +32 -0
- package/src/io/ooxml/xml-parser.ts +183 -0
- package/src/legal/bookmarks.ts +1 -1
- package/src/legal/cross-references.ts +1 -1
- package/src/legal/defined-terms.ts +1 -1
- package/src/legal/{_document-root.ts → document-root.ts} +8 -0
- package/src/legal/signature-blocks.ts +1 -1
- package/src/model/canonical-document.ts +165 -6
- package/src/model/chart-types.ts +439 -0
- package/src/model/snapshot.ts +3 -1
- package/src/review/store/comment-remapping.ts +24 -11
- package/src/review/store/revision-actions.ts +482 -2
- package/src/review/store/revision-store.ts +15 -0
- package/src/review/store/revision-types.ts +76 -0
- package/src/runtime/collab/remote-cursor-awareness.ts +24 -0
- package/src/runtime/collab/runtime-collab-sync.ts +33 -0
- package/src/runtime/diagnostics/build-diagnostic.ts +151 -0
- package/src/runtime/diagnostics/code-metadata-table.ts +221 -0
- package/src/runtime/document-runtime.ts +544 -35
- package/src/runtime/document-search.ts +176 -0
- package/src/runtime/edit-ops/index.ts +18 -2
- package/src/runtime/footnote-resolver.ts +130 -0
- package/src/runtime/layout/layout-engine-instance.ts +31 -4
- package/src/runtime/layout/layout-engine-version.ts +37 -1
- package/src/runtime/layout/page-graph.ts +14 -1
- package/src/runtime/layout/resolved-formatting-state.ts +21 -0
- package/src/runtime/numbering-prefix.ts +17 -0
- package/src/runtime/query-scopes.ts +183 -0
- package/src/runtime/resolved-numbering-geometry.ts +37 -6
- package/src/runtime/revision-runtime.ts +27 -1
- package/src/runtime/scope-resolver.ts +60 -0
- package/src/runtime/selection/post-edit-validator.ts +60 -6
- package/src/runtime/structure-ops/index.ts +20 -4
- package/src/runtime/surface-projection.ts +293 -18
- package/src/runtime/table-schema.ts +6 -0
- package/src/runtime/theme-color-resolver.ts +2 -2
- package/src/runtime/units.ts +9 -0
- package/src/runtime/workflow-rail-segments.ts +4 -0
- package/src/ui/WordReviewEditor.tsx +258 -44
- package/src/ui/editor-runtime-boundary.ts +13 -0
- package/src/ui/editor-shell-view.tsx +4 -1
- package/src/ui/headless/chrome-registry.ts +53 -0
- package/src/ui/headless/selection-tool-resolver.ts +11 -1
- package/src/ui-tailwind/chrome/chrome-preset-model.ts +13 -0
- package/src/ui-tailwind/chrome/tw-command-palette-mount.tsx +96 -0
- package/src/ui-tailwind/chrome/tw-context-menu.tsx +2 -1
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +5 -4
- package/src/ui-tailwind/chrome/tw-mode-dock.tsx +6 -2
- package/src/ui-tailwind/chrome/use-container-breakpoint.ts +111 -0
- package/src/ui-tailwind/chrome-overlay/tw-chrome-overlay.tsx +23 -9
- package/src/ui-tailwind/chrome-overlay/tw-object-selection-overlay.tsx +158 -0
- package/src/ui-tailwind/chrome-overlay/tw-page-stack-overlay-layer.tsx +6 -7
- package/src/ui-tailwind/editor-surface/pm-schema.ts +105 -17
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +13 -0
- package/src/ui-tailwind/editor-surface/shape-renderer.ts +76 -14
- package/src/ui-tailwind/editor-surface/tw-page-block-view.helpers.ts +18 -1
- package/src/ui-tailwind/editor-surface/tw-page-block-view.tsx +2 -0
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +18 -2
- package/src/ui-tailwind/index.ts +9 -0
- package/src/ui-tailwind/page-chrome-model.ts +77 -5
- package/src/ui-tailwind/page-stack/tw-page-stack-chrome-layer.tsx +56 -1
- package/src/ui-tailwind/page-stack/tw-region-block-renderer.tsx +2 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +116 -113
- package/src/ui-tailwind/review/tw-review-rail-footer.tsx +2 -2
- package/src/ui-tailwind/theme/tokens.ts +14 -0
- package/src/ui-tailwind/toolbar/tw-shell-header.tsx +5 -0
- package/src/ui-tailwind/tw-review-workspace.tsx +52 -87
- package/src/validation/diagnostics.ts +1 -0
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { OpcRelationship } from "./part-manifest.ts";
|
|
2
2
|
import { normalizePartPath, resolveRelationshipTarget } from "./part-manifest.ts";
|
|
3
|
+
import { parseXml } from "./xml-parser.ts";
|
|
4
|
+
import { localName } from "./xml-attr-helpers.ts";
|
|
3
5
|
|
|
4
6
|
export interface InlineMediaPart {
|
|
5
7
|
path: string;
|
|
@@ -35,19 +37,7 @@ export interface ParsedInlineMedia {
|
|
|
35
37
|
};
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
type: "element";
|
|
40
|
-
name: string;
|
|
41
|
-
attributes: Record<string, string>;
|
|
42
|
-
children: XmlNode[];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface XmlTextNode {
|
|
46
|
-
type: "text";
|
|
47
|
-
text: string;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
type XmlNode = XmlElementNode | XmlTextNode;
|
|
40
|
+
import type { XmlElementNode } from "./xml-element.ts";
|
|
51
41
|
|
|
52
42
|
export function parseInlineMediaXml(
|
|
53
43
|
xml: string,
|
|
@@ -246,10 +236,6 @@ function findDescendants(node: XmlElementNode, local: string): XmlElementNode[]
|
|
|
246
236
|
return results;
|
|
247
237
|
}
|
|
248
238
|
|
|
249
|
-
function localName(name: string): string {
|
|
250
|
-
const separatorIndex = name.indexOf(":");
|
|
251
|
-
return separatorIndex >= 0 ? name.slice(separatorIndex + 1) : name;
|
|
252
|
-
}
|
|
253
239
|
|
|
254
240
|
function extractText(node: XmlElementNode): string {
|
|
255
241
|
return node.children.map((child) => child.type === "text" ? child.text : extractText(child)).join("");
|
|
@@ -276,186 +262,3 @@ function readBooleanAttribute(node: XmlElementNode, name: string): boolean | und
|
|
|
276
262
|
return value !== "0" && value !== "false" && value !== "off";
|
|
277
263
|
}
|
|
278
264
|
|
|
279
|
-
function parseXml(xml: string): XmlElementNode {
|
|
280
|
-
const root: XmlElementNode = {
|
|
281
|
-
type: "element",
|
|
282
|
-
name: "__root__",
|
|
283
|
-
attributes: {},
|
|
284
|
-
children: [],
|
|
285
|
-
};
|
|
286
|
-
const stack: XmlElementNode[] = [root];
|
|
287
|
-
let cursor = 0;
|
|
288
|
-
|
|
289
|
-
while (cursor < xml.length) {
|
|
290
|
-
if (xml.startsWith("<!--", cursor)) {
|
|
291
|
-
const end = xml.indexOf("-->", cursor);
|
|
292
|
-
cursor = end >= 0 ? end + 3 : xml.length;
|
|
293
|
-
continue;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
if (xml.startsWith("<?", cursor)) {
|
|
297
|
-
const end = xml.indexOf("?>", cursor);
|
|
298
|
-
cursor = end >= 0 ? end + 2 : xml.length;
|
|
299
|
-
continue;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (xml[cursor] !== "<") {
|
|
303
|
-
const nextTag = xml.indexOf("<", cursor);
|
|
304
|
-
const end = nextTag >= 0 ? nextTag : xml.length;
|
|
305
|
-
const text = decodeXmlEntities(xml.slice(cursor, end));
|
|
306
|
-
if (text.length > 0) {
|
|
307
|
-
stack[stack.length - 1]?.children.push({ type: "text", text });
|
|
308
|
-
}
|
|
309
|
-
cursor = end;
|
|
310
|
-
continue;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (xml[cursor + 1] === "/") {
|
|
314
|
-
const end = xml.indexOf(">", cursor);
|
|
315
|
-
const current = stack.pop();
|
|
316
|
-
const name = xml.slice(cursor + 2, end).trim();
|
|
317
|
-
if (!current || localName(current.name) !== localName(name)) {
|
|
318
|
-
throw new Error(`Malformed XML: unexpected closing tag </${name}>.`);
|
|
319
|
-
}
|
|
320
|
-
cursor = end + 1;
|
|
321
|
-
continue;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
const tagEnd = findTagEnd(xml, cursor);
|
|
325
|
-
const tagBody = xml.slice(cursor + 1, tagEnd);
|
|
326
|
-
const selfClosing = /\/\s*$/.test(tagBody);
|
|
327
|
-
const { name, attributes } = parseTag(tagBody.replace(/\/\s*$/, "").trim());
|
|
328
|
-
const element: XmlElementNode = {
|
|
329
|
-
type: "element",
|
|
330
|
-
name,
|
|
331
|
-
attributes,
|
|
332
|
-
children: [],
|
|
333
|
-
};
|
|
334
|
-
stack[stack.length - 1]?.children.push(element);
|
|
335
|
-
|
|
336
|
-
if (!selfClosing) {
|
|
337
|
-
stack.push(element);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
cursor = tagEnd + 1;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if (stack.length !== 1) {
|
|
344
|
-
throw new Error("Malformed XML: unclosed element.");
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
return root;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
function parseTag(tagBody: string): { name: string; attributes: Record<string, string> } {
|
|
351
|
-
let cursor = 0;
|
|
352
|
-
while (cursor < tagBody.length && /\s/.test(tagBody[cursor] ?? "")) {
|
|
353
|
-
cursor += 1;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
const nameStart = cursor;
|
|
357
|
-
while (cursor < tagBody.length && !/\s/.test(tagBody[cursor] ?? "")) {
|
|
358
|
-
cursor += 1;
|
|
359
|
-
}
|
|
360
|
-
const name = tagBody.slice(nameStart, cursor);
|
|
361
|
-
const attributes: Record<string, string> = {};
|
|
362
|
-
|
|
363
|
-
while (cursor < tagBody.length) {
|
|
364
|
-
while (cursor < tagBody.length && /\s/.test(tagBody[cursor] ?? "")) {
|
|
365
|
-
cursor += 1;
|
|
366
|
-
}
|
|
367
|
-
if (cursor >= tagBody.length) {
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
const keyStart = cursor;
|
|
372
|
-
while (cursor < tagBody.length && !/[\s=]/.test(tagBody[cursor] ?? "")) {
|
|
373
|
-
cursor += 1;
|
|
374
|
-
}
|
|
375
|
-
const key = tagBody.slice(keyStart, cursor);
|
|
376
|
-
|
|
377
|
-
while (cursor < tagBody.length && /\s/.test(tagBody[cursor] ?? "")) {
|
|
378
|
-
cursor += 1;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
if (tagBody[cursor] !== "=") {
|
|
382
|
-
attributes[key] = "";
|
|
383
|
-
continue;
|
|
384
|
-
}
|
|
385
|
-
cursor += 1;
|
|
386
|
-
|
|
387
|
-
while (cursor < tagBody.length && /\s/.test(tagBody[cursor] ?? "")) {
|
|
388
|
-
cursor += 1;
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
const quote = tagBody[cursor];
|
|
392
|
-
if (quote !== `"` && quote !== `'`) {
|
|
393
|
-
throw new Error(`Malformed XML attribute ${key}.`);
|
|
394
|
-
}
|
|
395
|
-
cursor += 1;
|
|
396
|
-
|
|
397
|
-
const valueStart = cursor;
|
|
398
|
-
while (cursor < tagBody.length && tagBody[cursor] !== quote) {
|
|
399
|
-
cursor += 1;
|
|
400
|
-
}
|
|
401
|
-
attributes[key] = decodeXmlEntities(tagBody.slice(valueStart, cursor));
|
|
402
|
-
cursor += 1;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return { name, attributes };
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
function findTagEnd(xml: string, start: number): number {
|
|
409
|
-
let cursor = start + 1;
|
|
410
|
-
let quote: string | null = null;
|
|
411
|
-
|
|
412
|
-
while (cursor < xml.length) {
|
|
413
|
-
const current = xml[cursor];
|
|
414
|
-
if (quote) {
|
|
415
|
-
if (current === quote) {
|
|
416
|
-
quote = null;
|
|
417
|
-
}
|
|
418
|
-
cursor += 1;
|
|
419
|
-
continue;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (current === `"` || current === `'`) {
|
|
423
|
-
quote = current;
|
|
424
|
-
cursor += 1;
|
|
425
|
-
continue;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
if (current === ">") {
|
|
429
|
-
return cursor;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
cursor += 1;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
throw new Error("Malformed XML: missing >.");
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
function decodeXmlEntities(value: string): string {
|
|
439
|
-
return value.replace(/&(#x[0-9a-fA-F]+|#\d+|amp|lt|gt|quot|apos);/g, (match, entity) => {
|
|
440
|
-
switch (entity) {
|
|
441
|
-
case "amp":
|
|
442
|
-
return "&";
|
|
443
|
-
case "lt":
|
|
444
|
-
return "<";
|
|
445
|
-
case "gt":
|
|
446
|
-
return ">";
|
|
447
|
-
case "quot":
|
|
448
|
-
return `"`;
|
|
449
|
-
case "apos":
|
|
450
|
-
return "'";
|
|
451
|
-
default:
|
|
452
|
-
if (entity.startsWith("#x")) {
|
|
453
|
-
return String.fromCodePoint(Number.parseInt(entity.slice(2), 16));
|
|
454
|
-
}
|
|
455
|
-
if (entity.startsWith("#")) {
|
|
456
|
-
return String.fromCodePoint(Number.parseInt(entity.slice(1), 10));
|
|
457
|
-
}
|
|
458
|
-
return match;
|
|
459
|
-
}
|
|
460
|
-
});
|
|
461
|
-
}
|