@beyondwork/docx-react-component 1.0.28 → 1.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canonical-document-BLEbzL2J.d.cts +844 -0
- package/dist/canonical-document-BLEbzL2J.d.ts +844 -0
- package/dist/chunk-2FJS5GZM.js +763 -0
- package/dist/chunk-2FJS5GZM.js.map +1 -0
- package/{src/core/commands/section-layout-commands.ts → dist/chunk-2OQBZS3F.js} +106 -340
- package/dist/chunk-2OQBZS3F.js.map +1 -0
- package/dist/chunk-2S7W4KFO.js +127 -0
- package/dist/chunk-2S7W4KFO.js.map +1 -0
- package/dist/chunk-2TG72QSW.js +3874 -0
- package/dist/chunk-2TG72QSW.js.map +1 -0
- package/{src/core/commands/table-structure-commands.ts → dist/chunk-36QNIZBO.js} +126 -315
- package/dist/chunk-36QNIZBO.js.map +1 -0
- package/dist/chunk-4AQOYAW4.js +3069 -0
- package/dist/chunk-4AQOYAW4.js.map +1 -0
- package/dist/chunk-4D5EWJ3P.js +77 -0
- package/dist/chunk-4D5EWJ3P.js.map +1 -0
- package/dist/chunk-5FN54NDH.js +2257 -0
- package/dist/chunk-5FN54NDH.js.map +1 -0
- package/dist/chunk-BOYGQYRQ.js +7306 -0
- package/dist/chunk-BOYGQYRQ.js.map +1 -0
- package/dist/chunk-CN3XMECL.js +212 -0
- package/dist/chunk-CN3XMECL.js.map +1 -0
- package/dist/chunk-EBI3BX6U.js +164 -0
- package/dist/chunk-EBI3BX6U.js.map +1 -0
- package/dist/chunk-EILUG3VB.js +1275 -0
- package/dist/chunk-EILUG3VB.js.map +1 -0
- package/dist/chunk-FUDY333O.js +70 -0
- package/dist/chunk-FUDY333O.js.map +1 -0
- package/dist/chunk-GBVOWFIK.js +1237 -0
- package/dist/chunk-GBVOWFIK.js.map +1 -0
- package/dist/chunk-H4TQ3H3Y.js +262 -0
- package/dist/chunk-H4TQ3H3Y.js.map +1 -0
- package/{src/core/commands/style-commands.ts → dist/chunk-JGB3IXZO.js} +40 -113
- package/dist/chunk-JGB3IXZO.js.map +1 -0
- package/dist/chunk-KD2QRQPY.js +4342 -0
- package/dist/chunk-KD2QRQPY.js.map +1 -0
- package/dist/chunk-KLMXQVYK.js +369 -0
- package/dist/chunk-KLMXQVYK.js.map +1 -0
- package/dist/chunk-KZUG5KFQ.js +214 -0
- package/dist/chunk-KZUG5KFQ.js.map +1 -0
- package/{src/core/state/text-transaction.ts → dist/chunk-QDAQ4CJU.js} +79 -236
- package/dist/chunk-QDAQ4CJU.js.map +1 -0
- package/{src/legal/bookmarks.ts → dist/chunk-RMH72RZI.js} +44 -130
- package/dist/chunk-RMH72RZI.js.map +1 -0
- package/dist/chunk-SWKWQZXM.js +117 -0
- package/dist/chunk-SWKWQZXM.js.map +1 -0
- package/{src/core/commands/formatting-commands.ts → dist/chunk-TJBP2K4T.js} +196 -536
- package/dist/chunk-TJBP2K4T.js.map +1 -0
- package/dist/chunk-TLCEAQDQ.js +542 -0
- package/dist/chunk-TLCEAQDQ.js.map +1 -0
- package/{src/core/commands/text-commands.ts → dist/chunk-UZXBISGO.js} +86 -142
- package/dist/chunk-UZXBISGO.js.map +1 -0
- package/dist/chunk-WGBAKP3Q.js +3220 -0
- package/dist/chunk-WGBAKP3Q.js.map +1 -0
- package/dist/compare/index.cjs +5475 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +114 -0
- package/dist/compare/index.d.ts +114 -0
- package/dist/compare/index.js +731 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/core/commands/formatting-commands.cjs +828 -0
- package/dist/core/commands/formatting-commands.cjs.map +1 -0
- package/dist/core/commands/formatting-commands.d.cts +63 -0
- package/dist/core/commands/formatting-commands.d.ts +63 -0
- package/dist/core/commands/formatting-commands.js +37 -0
- package/dist/core/commands/formatting-commands.js.map +1 -0
- package/dist/core/commands/image-commands.cjs +2023 -0
- package/dist/core/commands/image-commands.cjs.map +1 -0
- package/dist/core/commands/image-commands.d.cts +58 -0
- package/dist/core/commands/image-commands.d.ts +58 -0
- package/dist/core/commands/image-commands.js +18 -0
- package/dist/core/commands/image-commands.js.map +1 -0
- package/dist/core/commands/section-layout-commands.cjs +477 -0
- package/dist/core/commands/section-layout-commands.cjs.map +1 -0
- package/dist/core/commands/section-layout-commands.d.cts +62 -0
- package/dist/core/commands/section-layout-commands.d.ts +62 -0
- package/dist/core/commands/section-layout-commands.js +21 -0
- package/dist/core/commands/section-layout-commands.js.map +1 -0
- package/dist/core/commands/style-commands.cjs +214 -0
- package/dist/core/commands/style-commands.cjs.map +1 -0
- package/dist/core/commands/style-commands.d.cts +13 -0
- package/dist/core/commands/style-commands.d.ts +13 -0
- package/dist/core/commands/style-commands.js +9 -0
- package/dist/core/commands/style-commands.js.map +1 -0
- package/dist/core/commands/table-structure-commands.cjs +1883 -0
- package/dist/core/commands/table-structure-commands.cjs.map +1 -0
- package/dist/core/commands/table-structure-commands.d.cts +59 -0
- package/dist/core/commands/table-structure-commands.d.ts +59 -0
- package/dist/core/commands/table-structure-commands.js +12 -0
- package/dist/core/commands/table-structure-commands.js.map +1 -0
- package/dist/core/commands/text-commands.cjs +2391 -0
- package/dist/core/commands/text-commands.cjs.map +1 -0
- package/dist/core/commands/text-commands.d.cts +24 -0
- package/dist/core/commands/text-commands.d.ts +24 -0
- package/dist/core/commands/text-commands.js +28 -0
- package/dist/core/commands/text-commands.js.map +1 -0
- package/dist/core/selection/mapping.cjs +200 -0
- package/dist/core/selection/mapping.cjs.map +1 -0
- package/dist/core/selection/mapping.d.cts +2 -0
- package/dist/core/selection/mapping.d.ts +2 -0
- package/dist/core/selection/mapping.js +31 -0
- package/dist/core/selection/mapping.js.map +1 -0
- package/dist/core/state/editor-state.cjs +2278 -0
- package/dist/core/state/editor-state.cjs.map +1 -0
- package/dist/core/state/editor-state.d.cts +2 -0
- package/dist/core/state/editor-state.d.ts +2 -0
- package/dist/core/state/editor-state.js +26 -0
- package/dist/core/state/editor-state.js.map +1 -0
- package/dist/index.cjs +38553 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7856 -0
- package/dist/index.js.map +1 -0
- package/dist/io/docx-session.cjs +16236 -0
- package/dist/io/docx-session.cjs.map +1 -0
- package/dist/io/docx-session.d.cts +21 -0
- package/dist/io/docx-session.d.ts +21 -0
- package/dist/io/docx-session.js +18 -0
- package/dist/io/docx-session.js.map +1 -0
- package/dist/legal/index.cjs +3900 -0
- package/dist/legal/index.cjs.map +1 -0
- package/dist/legal/index.d.cts +86 -0
- package/dist/legal/index.d.ts +86 -0
- package/dist/legal/index.js +616 -0
- package/dist/legal/index.js.map +1 -0
- package/dist/public-types-7ZL_94cz.d.ts +1573 -0
- package/dist/public-types-CeMaDueh.d.cts +1573 -0
- package/dist/public-types.cjs +19 -0
- package/dist/public-types.cjs.map +1 -0
- package/dist/public-types.d.cts +2 -0
- package/dist/public-types.d.ts +2 -0
- package/dist/public-types.js +1 -0
- package/dist/public-types.js.map +1 -0
- package/dist/runtime/document-runtime.cjs +11140 -0
- package/dist/runtime/document-runtime.cjs.map +1 -0
- package/dist/runtime/document-runtime.d.cts +231 -0
- package/dist/runtime/document-runtime.d.ts +231 -0
- package/dist/runtime/document-runtime.js +21 -0
- package/dist/runtime/document-runtime.js.map +1 -0
- package/dist/structural-helpers-CilgOVhh.d.cts +10 -0
- package/dist/structural-helpers-q0Gd-eBN.d.ts +10 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs +313 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +1 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js +23 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js.map +1 -0
- package/dist/ui-tailwind/index.cjs +4833 -0
- package/dist/ui-tailwind/index.cjs.map +1 -0
- package/dist/ui-tailwind/index.d.cts +617 -0
- package/dist/ui-tailwind/index.d.ts +617 -0
- package/dist/ui-tailwind/index.js +575 -0
- package/dist/ui-tailwind/index.js.map +1 -0
- package/package.json +61 -41
- package/src/README.md +0 -85
- package/src/api/README.md +0 -26
- package/src/api/public-types.ts +0 -1421
- package/src/api/session-state.ts +0 -60
- package/src/compare/diff-engine.ts +0 -623
- package/src/compare/export-redlines.ts +0 -280
- package/src/compare/index.ts +0 -25
- package/src/compare/snapshot.ts +0 -97
- package/src/component-inventory.md +0 -99
- package/src/core/README.md +0 -10
- package/src/core/commands/README.md +0 -3
- package/src/core/commands/image-commands.ts +0 -373
- package/src/core/commands/index.ts +0 -1757
- package/src/core/commands/list-commands.ts +0 -565
- package/src/core/commands/paragraph-layout-commands.ts +0 -339
- package/src/core/commands/review-commands.ts +0 -108
- package/src/core/commands/structural-helpers.ts +0 -309
- package/src/core/schema/README.md +0 -3
- package/src/core/schema/text-schema.ts +0 -516
- package/src/core/search/search-text.ts +0 -357
- package/src/core/selection/README.md +0 -3
- package/src/core/selection/mapping.ts +0 -289
- package/src/core/selection/review-anchors.ts +0 -183
- package/src/core/state/README.md +0 -3
- package/src/core/state/editor-state.ts +0 -892
- package/src/formats/xlsx/io/parse-shared-strings.ts +0 -41
- package/src/formats/xlsx/io/parse-sheet.ts +0 -459
- package/src/formats/xlsx/io/parse-styles.ts +0 -59
- package/src/formats/xlsx/io/parse-workbook.ts +0 -75
- package/src/formats/xlsx/io/serialize-shared-strings.ts +0 -72
- package/src/formats/xlsx/io/serialize-sheet.ts +0 -333
- package/src/formats/xlsx/io/serialize-styles.ts +0 -98
- package/src/formats/xlsx/io/serialize-workbook.ts +0 -429
- package/src/formats/xlsx/io/xlsx-session.ts +0 -314
- package/src/formats/xlsx/model/cell.ts +0 -189
- package/src/formats/xlsx/model/sheet.ts +0 -326
- package/src/formats/xlsx/model/styles.ts +0 -118
- package/src/formats/xlsx/model/workbook.ts +0 -453
- package/src/formats/xlsx/runtime/cell-commands.ts +0 -567
- package/src/formats/xlsx/runtime/sheet-commands.ts +0 -206
- package/src/formats/xlsx/runtime/workbook-runtime.ts +0 -177
- package/src/formats/xlsx/runtime/workbook-transaction.ts +0 -822
- package/src/index.ts +0 -101
- package/src/io/README.md +0 -10
- package/src/io/docx-session.ts +0 -2882
- package/src/io/export/README.md +0 -3
- package/src/io/export/export-session.ts +0 -220
- package/src/io/export/minimal-docx.ts +0 -115
- package/src/io/export/reattach-preserved-parts.ts +0 -54
- package/src/io/export/serialize-comments.ts +0 -947
- package/src/io/export/serialize-footnotes.ts +0 -399
- package/src/io/export/serialize-headers-footers.ts +0 -372
- package/src/io/export/serialize-main-document.ts +0 -1376
- package/src/io/export/serialize-numbering.ts +0 -118
- package/src/io/export/serialize-revisions.ts +0 -389
- package/src/io/export/serialize-runtime-revisions.ts +0 -269
- package/src/io/export/serialize-tables.ts +0 -174
- package/src/io/export/split-review-boundaries.ts +0 -356
- package/src/io/normalize/README.md +0 -3
- package/src/io/normalize/normalize-text.ts +0 -639
- package/src/io/ooxml/README.md +0 -3
- package/src/io/ooxml/highlight-colors.ts +0 -39
- package/src/io/ooxml/numbering-sentinels.ts +0 -44
- package/src/io/ooxml/parse-comments.ts +0 -846
- package/src/io/ooxml/parse-complex-content.ts +0 -287
- package/src/io/ooxml/parse-fields.ts +0 -834
- package/src/io/ooxml/parse-footnotes.ts +0 -896
- package/src/io/ooxml/parse-headers-footers.ts +0 -1169
- package/src/io/ooxml/parse-inline-media.ts +0 -461
- package/src/io/ooxml/parse-main-document.ts +0 -2877
- package/src/io/ooxml/parse-numbering.ts +0 -432
- package/src/io/ooxml/parse-revisions.ts +0 -931
- package/src/io/ooxml/parse-settings.ts +0 -184
- package/src/io/ooxml/parse-shapes.ts +0 -296
- package/src/io/ooxml/parse-styles.ts +0 -463
- package/src/io/ooxml/parse-tables.ts +0 -618
- package/src/io/ooxml/parse-theme.ts +0 -346
- package/src/io/ooxml/part-manifest.ts +0 -136
- package/src/io/ooxml/revision-boundaries.ts +0 -351
- package/src/io/opc/README.md +0 -3
- package/src/io/opc/corrupt-package.ts +0 -166
- package/src/io/opc/docx-package.ts +0 -74
- package/src/io/opc/package-reader.ts +0 -325
- package/src/io/opc/package-writer.ts +0 -273
- package/src/io/source-package-provenance.ts +0 -241
- package/src/legal/cross-references.ts +0 -414
- package/src/legal/defined-terms.ts +0 -203
- package/src/legal/index.ts +0 -32
- package/src/legal/signature-blocks.ts +0 -259
- package/src/model/README.md +0 -3
- package/src/model/canonical-document.ts +0 -2632
- package/src/model/cds-1.0.0.ts +0 -212
- package/src/model/snapshot.ts +0 -649
- package/src/preservation/README.md +0 -3
- package/src/preservation/markup-compatibility.ts +0 -48
- package/src/preservation/opaque-fragment-store.ts +0 -89
- package/src/preservation/opaque-region.ts +0 -233
- package/src/preservation/package-preservation.ts +0 -113
- package/src/preservation/preserved-part-manifest.ts +0 -56
- package/src/preservation/relationship-retention.ts +0 -57
- package/src/preservation/store.ts +0 -185
- package/src/review/README.md +0 -16
- package/src/review/store/README.md +0 -3
- package/src/review/store/comment-anchors.ts +0 -70
- package/src/review/store/comment-remapping.ts +0 -154
- package/src/review/store/comment-store.ts +0 -331
- package/src/review/store/comment-thread.ts +0 -109
- package/src/review/store/revision-actions.ts +0 -394
- package/src/review/store/revision-store.ts +0 -312
- package/src/review/store/revision-types.ts +0 -171
- package/src/review/store/runtime-comment-store.ts +0 -43
- package/src/runtime/README.md +0 -3
- package/src/runtime/ai-action-policy.ts +0 -764
- package/src/runtime/document-layout.ts +0 -332
- package/src/runtime/document-navigation.ts +0 -603
- package/src/runtime/document-runtime.ts +0 -3159
- package/src/runtime/document-search.ts +0 -145
- package/src/runtime/numbering-prefix.ts +0 -216
- package/src/runtime/page-layout-estimation.ts +0 -212
- package/src/runtime/read-only-diagnostics-runtime.ts +0 -241
- package/src/runtime/review-runtime.ts +0 -44
- package/src/runtime/revision-runtime.ts +0 -107
- package/src/runtime/session-capabilities.ts +0 -192
- package/src/runtime/story-context.ts +0 -164
- package/src/runtime/story-targeting.ts +0 -162
- package/src/runtime/surface-projection.ts +0 -1357
- package/src/runtime/table-commands.ts +0 -173
- package/src/runtime/table-schema.ts +0 -309
- package/src/runtime/view-state.ts +0 -477
- package/src/runtime/virtualized-rendering.ts +0 -258
- package/src/runtime/workflow-markup.ts +0 -353
- package/src/ui/README.md +0 -30
- package/src/ui/WordReviewEditor.tsx +0 -4086
- package/src/ui/browser-export.ts +0 -52
- package/src/ui/comments/README.md +0 -3
- package/src/ui/compatibility/README.md +0 -3
- package/src/ui/editor-command-bag.ts +0 -120
- package/src/ui/editor-runtime-boundary.ts +0 -1457
- package/src/ui/editor-shell-view.tsx +0 -142
- package/src/ui/editor-surface/README.md +0 -3
- package/src/ui/editor-surface-controller.tsx +0 -61
- package/src/ui/headless/comment-decoration-model.ts +0 -124
- package/src/ui/headless/preserve-editor-selection.ts +0 -5
- package/src/ui/headless/revision-decoration-model.ts +0 -128
- package/src/ui/headless/selection-helpers.ts +0 -54
- package/src/ui/headless/selection-toolbar-model.ts +0 -34
- package/src/ui/headless/use-editor-keyboard.ts +0 -103
- package/src/ui/review/README.md +0 -3
- package/src/ui/runtime-snapshot-selectors.ts +0 -197
- package/src/ui/shared/revision-filters.ts +0 -31
- package/src/ui/status/README.md +0 -3
- package/src/ui/theme/README.md +0 -3
- package/src/ui/toolbar/README.md +0 -3
- package/src/ui/workflow-surface-blocked-rails.ts +0 -94
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +0 -64
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +0 -129
- package/src/ui-tailwind/chrome/tw-layout-panel.tsx +0 -114
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +0 -34
- package/src/ui-tailwind/chrome/tw-page-ruler.tsx +0 -386
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +0 -186
- package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +0 -139
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +0 -128
- package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +0 -58
- package/src/ui-tailwind/chrome/use-before-unload.ts +0 -20
- package/src/ui-tailwind/editor-surface/perf-probe.ts +0 -179
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -184
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +0 -31
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +0 -427
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +0 -123
- package/src/ui-tailwind/editor-surface/pm-schema.ts +0 -876
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +0 -504
- package/src/ui-tailwind/editor-surface/search-plugin.ts +0 -168
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +0 -61
- package/src/ui-tailwind/editor-surface/tw-caret.tsx +0 -12
- package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +0 -150
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +0 -129
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +0 -58
- package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +0 -151
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +0 -944
- package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +0 -111
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -436
- package/src/ui-tailwind/index.ts +0 -62
- package/src/ui-tailwind/page-chrome-model.ts +0 -27
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +0 -406
- package/src/ui-tailwind/review/tw-health-panel.tsx +0 -149
- package/src/ui-tailwind/review/tw-review-rail.tsx +0 -120
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +0 -164
- package/src/ui-tailwind/status/tw-status-bar.tsx +0 -61
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +0 -52
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +0 -1064
- package/src/ui-tailwind/tw-review-workspace.tsx +0 -1417
- package/src/validation/README.md +0 -3
- package/src/validation/compatibility-engine.ts +0 -634
- package/src/validation/compatibility-report.ts +0 -161
- package/src/validation/diagnostics.ts +0 -204
- package/src/validation/docx-comment-proof.ts +0 -707
- package/src/validation/import-diagnostics.ts +0 -128
- package/src/validation/low-priority-word-surfaces.ts +0 -373
- /package/{src → dist}/ui-tailwind/theme/editor-theme.css +0 -0
|
@@ -1,931 +0,0 @@
|
|
|
1
|
-
import { createDetachedAnchor } from "../../core/selection/mapping.ts";
|
|
2
|
-
import {
|
|
3
|
-
createRevisionRecord,
|
|
4
|
-
type RevisionRecord,
|
|
5
|
-
} from "../../review/store/revision-store.ts";
|
|
6
|
-
import {
|
|
7
|
-
createRevisionRangeAnchor,
|
|
8
|
-
type MoveData,
|
|
9
|
-
type PropertyChangeData,
|
|
10
|
-
type RevisionKind,
|
|
11
|
-
} from "../../review/store/revision-types.ts";
|
|
12
|
-
import {
|
|
13
|
-
findChildElement,
|
|
14
|
-
findRequiredChildElement,
|
|
15
|
-
localName,
|
|
16
|
-
mapRevisionBoundaries,
|
|
17
|
-
parseXmlWithPositions,
|
|
18
|
-
type RevisionParagraphBoundary,
|
|
19
|
-
type XmlElementNode,
|
|
20
|
-
type XmlNode,
|
|
21
|
-
} from "./revision-boundaries.ts";
|
|
22
|
-
|
|
23
|
-
export interface PreservedRevisionMarkup {
|
|
24
|
-
revisionId: string;
|
|
25
|
-
rawXml: string;
|
|
26
|
-
xmlStart: number;
|
|
27
|
-
xmlEnd: number;
|
|
28
|
-
originalRevisionType: string;
|
|
29
|
-
paragraphIndex?: number;
|
|
30
|
-
containerXmlStart?: number;
|
|
31
|
-
containerXmlEnd?: number;
|
|
32
|
-
beforeContainerXml?: string;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface RevisionImportDiagnostic {
|
|
36
|
-
revisionId: string;
|
|
37
|
-
code:
|
|
38
|
-
| "preserve_only_move_revision"
|
|
39
|
-
| "preserve_only_formatting_revision"
|
|
40
|
-
| "nested_revision_preserve_only"
|
|
41
|
-
| "shallow_nested_revision_promoted"
|
|
42
|
-
| "linked_move_pair"
|
|
43
|
-
| "unlinked_move_revision"
|
|
44
|
-
| "ambiguous_revision_anchor"
|
|
45
|
-
| "table_structural_revision_preserve_only"
|
|
46
|
-
| "table_property_revision_parsed";
|
|
47
|
-
message: string;
|
|
48
|
-
featureClass: "preserve-only" | "supported" | "informational";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export interface ParsedRevisionsResult {
|
|
52
|
-
revisions: RevisionRecord[];
|
|
53
|
-
preservedMarkup: PreservedRevisionMarkup[];
|
|
54
|
-
diagnostics: RevisionImportDiagnostic[];
|
|
55
|
-
boundaries: RevisionParagraphBoundary[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
interface ParseState {
|
|
59
|
-
documentXml: string;
|
|
60
|
-
boundaries: RevisionParagraphBoundary[];
|
|
61
|
-
revisions: RevisionRecord[];
|
|
62
|
-
preservedMarkup: PreservedRevisionMarkup[];
|
|
63
|
-
diagnostics: RevisionImportDiagnostic[];
|
|
64
|
-
nextGeneratedIndex: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
interface RevisionMetadata {
|
|
68
|
-
revisionId: string;
|
|
69
|
-
ooxmlRevisionId?: string;
|
|
70
|
-
authorId: string;
|
|
71
|
-
createdAt: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const SUPPORTED_CONTAINER_TYPES = new Set(["ins", "del"]);
|
|
75
|
-
const PRESERVE_ONLY_CONTAINER_TYPES = new Set(["moveFrom", "moveTo"]);
|
|
76
|
-
const PROPERTY_CHANGE_REVISION_TYPES = new Set(["rPrChange", "pPrChange"]);
|
|
77
|
-
const STRUCTURAL_TABLE_REVISION_TYPES = new Set(["cellIns", "cellDel", "cellMerge"]);
|
|
78
|
-
|
|
79
|
-
export function parseRevisionsFromDocumentXml(
|
|
80
|
-
documentXml: string,
|
|
81
|
-
): ParsedRevisionsResult {
|
|
82
|
-
const root = parseXmlWithPositions(documentXml);
|
|
83
|
-
const documentElement = findRequiredChildElement(root, "document");
|
|
84
|
-
const bodyElement = findRequiredChildElement(documentElement, "body");
|
|
85
|
-
const boundaries = mapRevisionBoundaries(documentXml);
|
|
86
|
-
const state: ParseState = {
|
|
87
|
-
documentXml,
|
|
88
|
-
boundaries,
|
|
89
|
-
revisions: [],
|
|
90
|
-
preservedMarkup: [],
|
|
91
|
-
diagnostics: [],
|
|
92
|
-
nextGeneratedIndex: 1,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
let paragraphIndex = -1;
|
|
96
|
-
let cursor = 0;
|
|
97
|
-
let previousWasParagraph = false;
|
|
98
|
-
|
|
99
|
-
for (const child of bodyElement.children) {
|
|
100
|
-
if (child.type !== "element") {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const childType = localName(child.name);
|
|
105
|
-
|
|
106
|
-
if (childType !== "p") {
|
|
107
|
-
if (childType === "tbl") {
|
|
108
|
-
parseTblPropertyRevisions(child, cursor, state);
|
|
109
|
-
} else if (childType === "sectPr") {
|
|
110
|
-
parseSectPrRevisions(child, cursor, state);
|
|
111
|
-
}
|
|
112
|
-
cursor += 1;
|
|
113
|
-
previousWasParagraph = false;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
if (previousWasParagraph) {
|
|
118
|
-
cursor += 1;
|
|
119
|
-
}
|
|
120
|
-
paragraphIndex += 1;
|
|
121
|
-
const paragraphBoundary = boundaries[paragraphIndex];
|
|
122
|
-
if (!paragraphBoundary) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
parseParagraphMarkRevisions(child, paragraphBoundary, state);
|
|
127
|
-
walkParagraphContent(child.children, paragraphIndex, state, () => cursor, (next) => {
|
|
128
|
-
cursor = next;
|
|
129
|
-
});
|
|
130
|
-
previousWasParagraph = true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
linkMoveRevisionPairs(state);
|
|
134
|
-
|
|
135
|
-
return {
|
|
136
|
-
revisions: state.revisions,
|
|
137
|
-
preservedMarkup: state.preservedMarkup.sort((left, right) => left.xmlStart - right.xmlStart),
|
|
138
|
-
diagnostics: state.diagnostics,
|
|
139
|
-
boundaries,
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function parseParagraphMarkRevisions(
|
|
144
|
-
paragraph: XmlElementNode,
|
|
145
|
-
boundary: RevisionParagraphBoundary,
|
|
146
|
-
state: ParseState,
|
|
147
|
-
): void {
|
|
148
|
-
const paragraphProperties = findChildElement(paragraph, "pPr");
|
|
149
|
-
const paragraphRunProperties = paragraphProperties
|
|
150
|
-
? findChildElement(paragraphProperties, "rPr")
|
|
151
|
-
: undefined;
|
|
152
|
-
|
|
153
|
-
if (!paragraphProperties) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const paragraphRange =
|
|
158
|
-
boundary.start === boundary.end
|
|
159
|
-
? createRevisionRangeAnchor(boundary.end, boundary.end)
|
|
160
|
-
: createRevisionRangeAnchor(boundary.start, boundary.end);
|
|
161
|
-
|
|
162
|
-
for (const child of paragraphProperties.children) {
|
|
163
|
-
if (child.type !== "element") {
|
|
164
|
-
continue;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const type = localName(child.name);
|
|
168
|
-
if (type === "pPrChange") {
|
|
169
|
-
const metadata = readRevisionMetadata(child, state, "property-change");
|
|
170
|
-
const innerPPr = findChildElement(child, "pPr");
|
|
171
|
-
const beforeXml = innerPPr ? state.documentXml.slice(innerPPr.start, innerPPr.end) : "";
|
|
172
|
-
const propertyChangeData: PropertyChangeData = {
|
|
173
|
-
xmlTag: "pPrChange",
|
|
174
|
-
beforeXml,
|
|
175
|
-
};
|
|
176
|
-
state.revisions.push(
|
|
177
|
-
createRevisionRecord({
|
|
178
|
-
revisionId: metadata.revisionId,
|
|
179
|
-
kind: "property-change",
|
|
180
|
-
anchor: paragraphRange,
|
|
181
|
-
authorId: metadata.authorId,
|
|
182
|
-
createdAt: metadata.createdAt,
|
|
183
|
-
metadata: {
|
|
184
|
-
source: "import",
|
|
185
|
-
originalRevisionType: "pPrChange",
|
|
186
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
187
|
-
propertyChangeData,
|
|
188
|
-
},
|
|
189
|
-
}),
|
|
190
|
-
);
|
|
191
|
-
state.preservedMarkup.push({
|
|
192
|
-
revisionId: metadata.revisionId,
|
|
193
|
-
rawXml: state.documentXml.slice(child.start, child.end),
|
|
194
|
-
xmlStart: child.start,
|
|
195
|
-
xmlEnd: child.end,
|
|
196
|
-
originalRevisionType: "pPrChange",
|
|
197
|
-
containerXmlStart: paragraphProperties.start,
|
|
198
|
-
containerXmlEnd: paragraphProperties.end,
|
|
199
|
-
beforeContainerXml: beforeXml,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (!paragraphRunProperties) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
for (const child of paragraphRunProperties.children) {
|
|
209
|
-
if (child.type !== "element") {
|
|
210
|
-
continue;
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const type = localName(child.name);
|
|
214
|
-
if (!SUPPORTED_CONTAINER_TYPES.has(type)) {
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
const metadata = readRevisionMetadata(child, state, type);
|
|
219
|
-
state.revisions.push(
|
|
220
|
-
createRevisionRecord({
|
|
221
|
-
revisionId: metadata.revisionId,
|
|
222
|
-
kind: type === "ins" ? "insertion" : "deletion",
|
|
223
|
-
anchor: createRevisionRangeAnchor(boundary.end, boundary.end),
|
|
224
|
-
authorId: metadata.authorId,
|
|
225
|
-
createdAt: metadata.createdAt,
|
|
226
|
-
metadata: {
|
|
227
|
-
source: "import",
|
|
228
|
-
importedRevisionForm:
|
|
229
|
-
type === "ins" ? "paragraph-insertion" : "paragraph-deletion",
|
|
230
|
-
originalRevisionType: `paragraph-${type}`,
|
|
231
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
232
|
-
},
|
|
233
|
-
}),
|
|
234
|
-
);
|
|
235
|
-
state.preservedMarkup.push({
|
|
236
|
-
revisionId: metadata.revisionId,
|
|
237
|
-
rawXml: state.documentXml.slice(child.start, child.end),
|
|
238
|
-
xmlStart: child.start,
|
|
239
|
-
xmlEnd: child.end,
|
|
240
|
-
originalRevisionType: `paragraph-${type}`,
|
|
241
|
-
paragraphIndex: boundary.paragraphIndex,
|
|
242
|
-
});
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
function walkParagraphContent(
|
|
247
|
-
nodes: XmlNode[],
|
|
248
|
-
paragraphIndex: number,
|
|
249
|
-
state: ParseState,
|
|
250
|
-
getCursor: () => number,
|
|
251
|
-
setCursor: (next: number) => void,
|
|
252
|
-
): void {
|
|
253
|
-
for (const node of nodes) {
|
|
254
|
-
walkContentNode(node, paragraphIndex, state, getCursor, setCursor);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function walkContentNode(
|
|
259
|
-
node: XmlNode,
|
|
260
|
-
paragraphIndex: number,
|
|
261
|
-
state: ParseState,
|
|
262
|
-
getCursor: () => number,
|
|
263
|
-
setCursor: (next: number) => void,
|
|
264
|
-
): void {
|
|
265
|
-
if (node.type !== "element") {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const type = localName(node.name);
|
|
270
|
-
if (type === "pPr") {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
if (type === "r") {
|
|
275
|
-
parseRunFormattingRevisions(node, paragraphIndex, state, getCursor());
|
|
276
|
-
for (const child of node.children) {
|
|
277
|
-
walkContentNode(child, paragraphIndex, state, getCursor, setCursor);
|
|
278
|
-
}
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
if (SUPPORTED_CONTAINER_TYPES.has(type) || PRESERVE_ONLY_CONTAINER_TYPES.has(type)) {
|
|
283
|
-
const start = getCursor();
|
|
284
|
-
const length = measureStoryLength(node);
|
|
285
|
-
const end = start + length;
|
|
286
|
-
const hasNestedRevision = containsNestedRevision(node);
|
|
287
|
-
const metadata = readRevisionMetadata(
|
|
288
|
-
node,
|
|
289
|
-
state,
|
|
290
|
-
type === "moveFrom" || type === "moveTo" ? "move" : type,
|
|
291
|
-
);
|
|
292
|
-
|
|
293
|
-
if (hasNestedRevision) {
|
|
294
|
-
const nestedKind = type === "ins" ? "insertion" : type === "del" ? "deletion" : "move";
|
|
295
|
-
const isShallowNesting = isShallowPropertyChangeNesting(node);
|
|
296
|
-
|
|
297
|
-
if (isShallowNesting && SUPPORTED_CONTAINER_TYPES.has(type)) {
|
|
298
|
-
state.revisions.push(
|
|
299
|
-
createRevisionRecord({
|
|
300
|
-
revisionId: metadata.revisionId,
|
|
301
|
-
kind: nestedKind as "insertion" | "deletion",
|
|
302
|
-
anchor:
|
|
303
|
-
length > 0
|
|
304
|
-
? createRevisionRangeAnchor(start, end)
|
|
305
|
-
: createDetachedAnchor({ from: start, to: end }, "importAmbiguity"),
|
|
306
|
-
authorId: metadata.authorId,
|
|
307
|
-
createdAt: metadata.createdAt,
|
|
308
|
-
metadata: {
|
|
309
|
-
source: "import",
|
|
310
|
-
importedRevisionForm:
|
|
311
|
-
type === "ins" ? "run-insertion" : "run-deletion",
|
|
312
|
-
originalRevisionType: type,
|
|
313
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
314
|
-
},
|
|
315
|
-
}),
|
|
316
|
-
);
|
|
317
|
-
state.preservedMarkup.push({
|
|
318
|
-
revisionId: metadata.revisionId,
|
|
319
|
-
rawXml: state.documentXml.slice(node.start, node.end),
|
|
320
|
-
xmlStart: node.start,
|
|
321
|
-
xmlEnd: node.end,
|
|
322
|
-
originalRevisionType: type,
|
|
323
|
-
});
|
|
324
|
-
state.diagnostics.push({
|
|
325
|
-
revisionId: metadata.revisionId,
|
|
326
|
-
code: "shallow_nested_revision_promoted",
|
|
327
|
-
message: "Shallow nested revision (property changes inside ins/del) promoted to supported rendering.",
|
|
328
|
-
featureClass: "supported",
|
|
329
|
-
});
|
|
330
|
-
parseNestedPropertyChangeRevisions(node, paragraphIndex, state, start);
|
|
331
|
-
advanceCursor(node, setCursor, getCursor);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
state.revisions.push(
|
|
336
|
-
createRevisionRecord({
|
|
337
|
-
revisionId: metadata.revisionId,
|
|
338
|
-
kind: nestedKind,
|
|
339
|
-
anchor:
|
|
340
|
-
length > 0
|
|
341
|
-
? createRevisionRangeAnchor(start, end)
|
|
342
|
-
: createDetachedAnchor({ from: start, to: end }, "importAmbiguity"),
|
|
343
|
-
authorId: metadata.authorId,
|
|
344
|
-
createdAt: metadata.createdAt,
|
|
345
|
-
metadata: {
|
|
346
|
-
source: "import",
|
|
347
|
-
originalRevisionType: type,
|
|
348
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
349
|
-
preserveOnlyReason: "Nested revision markup remains preserve-only.",
|
|
350
|
-
},
|
|
351
|
-
}),
|
|
352
|
-
);
|
|
353
|
-
state.preservedMarkup.push({
|
|
354
|
-
revisionId: metadata.revisionId,
|
|
355
|
-
rawXml: state.documentXml.slice(node.start, node.end),
|
|
356
|
-
xmlStart: node.start,
|
|
357
|
-
xmlEnd: node.end,
|
|
358
|
-
originalRevisionType: type,
|
|
359
|
-
});
|
|
360
|
-
state.diagnostics.push({
|
|
361
|
-
revisionId: metadata.revisionId,
|
|
362
|
-
code: "nested_revision_preserve_only",
|
|
363
|
-
message: "Nested revision markup remains preserve-only and is exported unchanged.",
|
|
364
|
-
featureClass: "preserve-only",
|
|
365
|
-
});
|
|
366
|
-
advanceCursor(node, setCursor, getCursor);
|
|
367
|
-
return;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
if (type === "moveFrom" || type === "moveTo") {
|
|
371
|
-
const moveData: MoveData = {
|
|
372
|
-
moveId: metadata.ooxmlRevisionId ?? `generated-${metadata.revisionId}`,
|
|
373
|
-
direction: type === "moveFrom" ? "from" : "to",
|
|
374
|
-
};
|
|
375
|
-
state.revisions.push(
|
|
376
|
-
createRevisionRecord({
|
|
377
|
-
revisionId: metadata.revisionId,
|
|
378
|
-
kind: "move",
|
|
379
|
-
anchor:
|
|
380
|
-
length > 0
|
|
381
|
-
? createRevisionRangeAnchor(start, end)
|
|
382
|
-
: createDetachedAnchor({ from: start, to: end }, "importAmbiguity"),
|
|
383
|
-
authorId: metadata.authorId,
|
|
384
|
-
createdAt: metadata.createdAt,
|
|
385
|
-
metadata: {
|
|
386
|
-
source: "import",
|
|
387
|
-
originalRevisionType: type,
|
|
388
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
389
|
-
preserveOnlyReason: "Imported preserve-only revision.",
|
|
390
|
-
moveData,
|
|
391
|
-
},
|
|
392
|
-
}),
|
|
393
|
-
);
|
|
394
|
-
state.preservedMarkup.push({
|
|
395
|
-
revisionId: metadata.revisionId,
|
|
396
|
-
rawXml: state.documentXml.slice(node.start, node.end),
|
|
397
|
-
xmlStart: node.start,
|
|
398
|
-
xmlEnd: node.end,
|
|
399
|
-
originalRevisionType: type,
|
|
400
|
-
});
|
|
401
|
-
state.diagnostics.push({
|
|
402
|
-
revisionId: metadata.revisionId,
|
|
403
|
-
code: "preserve_only_move_revision",
|
|
404
|
-
message: "Move revision parsed as preserve-only. Content is preserved for round-trip; linking resolved in post-parse step.",
|
|
405
|
-
featureClass: "preserve-only",
|
|
406
|
-
});
|
|
407
|
-
advanceCursor(node, setCursor, getCursor);
|
|
408
|
-
return;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
state.revisions.push(
|
|
412
|
-
createRevisionRecord({
|
|
413
|
-
revisionId: metadata.revisionId,
|
|
414
|
-
kind: type === "ins" ? "insertion" : "deletion",
|
|
415
|
-
anchor: createRevisionRangeAnchor(start, end),
|
|
416
|
-
authorId: metadata.authorId,
|
|
417
|
-
createdAt: metadata.createdAt,
|
|
418
|
-
metadata: {
|
|
419
|
-
source: "import",
|
|
420
|
-
importedRevisionForm:
|
|
421
|
-
type === "ins" ? "run-insertion" : "run-deletion",
|
|
422
|
-
originalRevisionType: type,
|
|
423
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
424
|
-
},
|
|
425
|
-
}),
|
|
426
|
-
);
|
|
427
|
-
state.preservedMarkup.push({
|
|
428
|
-
revisionId: metadata.revisionId,
|
|
429
|
-
rawXml: state.documentXml.slice(node.start, node.end),
|
|
430
|
-
xmlStart: node.start,
|
|
431
|
-
xmlEnd: node.end,
|
|
432
|
-
originalRevisionType: type,
|
|
433
|
-
});
|
|
434
|
-
advanceCursor(node, setCursor, getCursor);
|
|
435
|
-
return;
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
switch (type) {
|
|
439
|
-
case "t":
|
|
440
|
-
case "delText":
|
|
441
|
-
case "instrText":
|
|
442
|
-
case "delInstrText": {
|
|
443
|
-
const text = node.children
|
|
444
|
-
.filter((child): child is XmlElementNode["children"][number] & { type: "text" } => child.type === "text")
|
|
445
|
-
.map((child) => child.text)
|
|
446
|
-
.join("");
|
|
447
|
-
setCursor(getCursor() + text.length);
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
case "tab":
|
|
451
|
-
case "br":
|
|
452
|
-
case "cr":
|
|
453
|
-
setCursor(getCursor() + 1);
|
|
454
|
-
return;
|
|
455
|
-
default:
|
|
456
|
-
for (const child of node.children) {
|
|
457
|
-
walkContentNode(child, paragraphIndex, state, getCursor, setCursor);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
function parseRunFormattingRevisions(
|
|
463
|
-
run: XmlElementNode,
|
|
464
|
-
_paragraphIndex: number,
|
|
465
|
-
state: ParseState,
|
|
466
|
-
runStart: number,
|
|
467
|
-
): void {
|
|
468
|
-
const runProperties = findChildElement(run, "rPr");
|
|
469
|
-
if (!runProperties) {
|
|
470
|
-
return;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
const runLength = measureStoryLength(run);
|
|
474
|
-
const anchor =
|
|
475
|
-
runLength > 0
|
|
476
|
-
? createRevisionRangeAnchor(runStart, runStart + runLength)
|
|
477
|
-
: createDetachedAnchor({ from: runStart, to: runStart }, "importAmbiguity");
|
|
478
|
-
|
|
479
|
-
for (const child of runProperties.children) {
|
|
480
|
-
if (child.type !== "element" || !PROPERTY_CHANGE_REVISION_TYPES.has(localName(child.name))) {
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
const childLocalName = localName(child.name) as "rPrChange" | "pPrChange";
|
|
485
|
-
const metadata = readRevisionMetadata(child, state, "property-change");
|
|
486
|
-
const innerRPr = findChildElement(child, "rPr");
|
|
487
|
-
const beforeXml = innerRPr ? state.documentXml.slice(innerRPr.start, innerRPr.end) : "";
|
|
488
|
-
const propertyChangeData: PropertyChangeData = {
|
|
489
|
-
xmlTag: childLocalName === "rPrChange" ? "rPrChange" : "pPrChange",
|
|
490
|
-
beforeXml,
|
|
491
|
-
};
|
|
492
|
-
state.revisions.push(
|
|
493
|
-
createRevisionRecord({
|
|
494
|
-
revisionId: metadata.revisionId,
|
|
495
|
-
kind: "property-change",
|
|
496
|
-
anchor,
|
|
497
|
-
authorId: metadata.authorId,
|
|
498
|
-
createdAt: metadata.createdAt,
|
|
499
|
-
metadata: {
|
|
500
|
-
source: "import",
|
|
501
|
-
originalRevisionType: childLocalName,
|
|
502
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
503
|
-
propertyChangeData,
|
|
504
|
-
},
|
|
505
|
-
}),
|
|
506
|
-
);
|
|
507
|
-
state.preservedMarkup.push({
|
|
508
|
-
revisionId: metadata.revisionId,
|
|
509
|
-
rawXml: state.documentXml.slice(child.start, child.end),
|
|
510
|
-
xmlStart: child.start,
|
|
511
|
-
xmlEnd: child.end,
|
|
512
|
-
originalRevisionType: childLocalName,
|
|
513
|
-
containerXmlStart: runProperties.start,
|
|
514
|
-
containerXmlEnd: runProperties.end,
|
|
515
|
-
beforeContainerXml: beforeXml,
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
function parseTblPropertyRevisions(
|
|
521
|
-
table: XmlElementNode,
|
|
522
|
-
position: number,
|
|
523
|
-
state: ParseState,
|
|
524
|
-
): void {
|
|
525
|
-
const tblPr = findChildElement(table, "tblPr");
|
|
526
|
-
if (tblPr) {
|
|
527
|
-
const tblPrChange = findChildElement(tblPr, "tblPrChange");
|
|
528
|
-
if (tblPrChange) {
|
|
529
|
-
const metadata = readRevisionMetadata(tblPrChange, state, "property-change");
|
|
530
|
-
const innerTblPr = findChildElement(tblPrChange, "tblPr");
|
|
531
|
-
const beforeXml = innerTblPr ? state.documentXml.slice(innerTblPr.start, innerTblPr.end) : "";
|
|
532
|
-
const propertyChangeData: PropertyChangeData = { xmlTag: "tblPrChange", beforeXml };
|
|
533
|
-
|
|
534
|
-
state.revisions.push(
|
|
535
|
-
createRevisionRecord({
|
|
536
|
-
revisionId: metadata.revisionId,
|
|
537
|
-
kind: "property-change",
|
|
538
|
-
anchor: createRevisionRangeAnchor(position, position),
|
|
539
|
-
authorId: metadata.authorId,
|
|
540
|
-
createdAt: metadata.createdAt,
|
|
541
|
-
metadata: {
|
|
542
|
-
source: "import",
|
|
543
|
-
originalRevisionType: "tblPrChange",
|
|
544
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
545
|
-
propertyChangeData,
|
|
546
|
-
},
|
|
547
|
-
}),
|
|
548
|
-
);
|
|
549
|
-
state.preservedMarkup.push({
|
|
550
|
-
revisionId: metadata.revisionId,
|
|
551
|
-
rawXml: state.documentXml.slice(tblPrChange.start, tblPrChange.end),
|
|
552
|
-
xmlStart: tblPrChange.start,
|
|
553
|
-
xmlEnd: tblPrChange.end,
|
|
554
|
-
originalRevisionType: "tblPrChange",
|
|
555
|
-
containerXmlStart: tblPr.start,
|
|
556
|
-
containerXmlEnd: tblPr.end,
|
|
557
|
-
beforeContainerXml: beforeXml,
|
|
558
|
-
});
|
|
559
|
-
state.diagnostics.push({
|
|
560
|
-
revisionId: metadata.revisionId,
|
|
561
|
-
code: "table_property_revision_parsed",
|
|
562
|
-
message: "Table property change (tblPrChange) parsed as actionable property-change revision.",
|
|
563
|
-
featureClass: "supported",
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
parseTableRowAndCellRevisions(table, position, state);
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
function parseTableRowAndCellRevisions(
|
|
572
|
-
table: XmlElementNode,
|
|
573
|
-
position: number,
|
|
574
|
-
state: ParseState,
|
|
575
|
-
): void {
|
|
576
|
-
for (const child of table.children) {
|
|
577
|
-
if (child.type !== "element" || localName(child.name) !== "tr") {
|
|
578
|
-
continue;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
const trPr = findChildElement(child, "trPr");
|
|
582
|
-
if (trPr) {
|
|
583
|
-
const trPrChange = findChildElement(trPr, "trPrChange");
|
|
584
|
-
if (trPrChange) {
|
|
585
|
-
const metadata = readRevisionMetadata(trPrChange, state, "property-change");
|
|
586
|
-
const innerTrPr = findChildElement(trPrChange, "trPr");
|
|
587
|
-
const beforeXml = innerTrPr ? state.documentXml.slice(innerTrPr.start, innerTrPr.end) : "";
|
|
588
|
-
const propertyChangeData: PropertyChangeData = { xmlTag: "tblPrChange", beforeXml };
|
|
589
|
-
|
|
590
|
-
state.revisions.push(
|
|
591
|
-
createRevisionRecord({
|
|
592
|
-
revisionId: metadata.revisionId,
|
|
593
|
-
kind: "property-change",
|
|
594
|
-
anchor: createRevisionRangeAnchor(position, position),
|
|
595
|
-
authorId: metadata.authorId,
|
|
596
|
-
createdAt: metadata.createdAt,
|
|
597
|
-
metadata: {
|
|
598
|
-
source: "import",
|
|
599
|
-
originalRevisionType: "trPrChange",
|
|
600
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
601
|
-
propertyChangeData,
|
|
602
|
-
preserveOnlyReason: "Row property changes remain preserve-only for export safety.",
|
|
603
|
-
},
|
|
604
|
-
}),
|
|
605
|
-
);
|
|
606
|
-
state.preservedMarkup.push({
|
|
607
|
-
revisionId: metadata.revisionId,
|
|
608
|
-
rawXml: state.documentXml.slice(trPrChange.start, trPrChange.end),
|
|
609
|
-
xmlStart: trPrChange.start,
|
|
610
|
-
xmlEnd: trPrChange.end,
|
|
611
|
-
originalRevisionType: "trPrChange",
|
|
612
|
-
containerXmlStart: trPr.start,
|
|
613
|
-
containerXmlEnd: trPr.end,
|
|
614
|
-
beforeContainerXml: beforeXml,
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
|
|
619
|
-
for (const tcNode of child.children) {
|
|
620
|
-
if (tcNode.type !== "element" || localName(tcNode.name) !== "tc") {
|
|
621
|
-
continue;
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
const tcPr = findChildElement(tcNode, "tcPr");
|
|
625
|
-
if (!tcPr) {
|
|
626
|
-
continue;
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
const tcPrChange = findChildElement(tcPr, "tcPrChange");
|
|
630
|
-
if (tcPrChange) {
|
|
631
|
-
const metadata = readRevisionMetadata(tcPrChange, state, "property-change");
|
|
632
|
-
const innerTcPr = findChildElement(tcPrChange, "tcPr");
|
|
633
|
-
const beforeXml = innerTcPr ? state.documentXml.slice(innerTcPr.start, innerTcPr.end) : "";
|
|
634
|
-
const propertyChangeData: PropertyChangeData = { xmlTag: "tblPrChange", beforeXml };
|
|
635
|
-
|
|
636
|
-
state.revisions.push(
|
|
637
|
-
createRevisionRecord({
|
|
638
|
-
revisionId: metadata.revisionId,
|
|
639
|
-
kind: "property-change",
|
|
640
|
-
anchor: createRevisionRangeAnchor(position, position),
|
|
641
|
-
authorId: metadata.authorId,
|
|
642
|
-
createdAt: metadata.createdAt,
|
|
643
|
-
metadata: {
|
|
644
|
-
source: "import",
|
|
645
|
-
originalRevisionType: "tcPrChange",
|
|
646
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
647
|
-
propertyChangeData,
|
|
648
|
-
preserveOnlyReason: "Cell property changes remain preserve-only for export safety.",
|
|
649
|
-
},
|
|
650
|
-
}),
|
|
651
|
-
);
|
|
652
|
-
state.preservedMarkup.push({
|
|
653
|
-
revisionId: metadata.revisionId,
|
|
654
|
-
rawXml: state.documentXml.slice(tcPrChange.start, tcPrChange.end),
|
|
655
|
-
xmlStart: tcPrChange.start,
|
|
656
|
-
xmlEnd: tcPrChange.end,
|
|
657
|
-
originalRevisionType: "tcPrChange",
|
|
658
|
-
containerXmlStart: tcPr.start,
|
|
659
|
-
containerXmlEnd: tcPr.end,
|
|
660
|
-
beforeContainerXml: beforeXml,
|
|
661
|
-
});
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
for (const tcChild of tcPr.children) {
|
|
665
|
-
if (tcChild.type !== "element") {
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
const tcChildName = localName(tcChild.name);
|
|
670
|
-
if (STRUCTURAL_TABLE_REVISION_TYPES.has(tcChildName)) {
|
|
671
|
-
const metadata = readRevisionMetadata(tcChild, state, tcChildName);
|
|
672
|
-
state.preservedMarkup.push({
|
|
673
|
-
revisionId: metadata.revisionId,
|
|
674
|
-
rawXml: state.documentXml.slice(tcChild.start, tcChild.end),
|
|
675
|
-
xmlStart: tcChild.start,
|
|
676
|
-
xmlEnd: tcChild.end,
|
|
677
|
-
originalRevisionType: tcChildName,
|
|
678
|
-
});
|
|
679
|
-
state.diagnostics.push({
|
|
680
|
-
revisionId: metadata.revisionId,
|
|
681
|
-
code: "table_structural_revision_preserve_only",
|
|
682
|
-
message: `Structural table revision (${tcChildName}) remains preserve-only; topology-altering changes cannot be safely applied.`,
|
|
683
|
-
featureClass: "preserve-only",
|
|
684
|
-
});
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
function parseSectPrRevisions(
|
|
692
|
-
sectPr: XmlElementNode,
|
|
693
|
-
position: number,
|
|
694
|
-
state: ParseState,
|
|
695
|
-
): void {
|
|
696
|
-
const sectPrChange = findChildElement(sectPr, "sectPrChange");
|
|
697
|
-
if (!sectPrChange) {
|
|
698
|
-
return;
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
const metadata = readRevisionMetadata(sectPrChange, state, "property-change");
|
|
702
|
-
const innerSectPr = findChildElement(sectPrChange, "sectPr");
|
|
703
|
-
const beforeXml = innerSectPr ? state.documentXml.slice(innerSectPr.start, innerSectPr.end) : "";
|
|
704
|
-
const propertyChangeData: PropertyChangeData = { xmlTag: "sectPrChange", beforeXml };
|
|
705
|
-
|
|
706
|
-
state.revisions.push(
|
|
707
|
-
createRevisionRecord({
|
|
708
|
-
revisionId: metadata.revisionId,
|
|
709
|
-
kind: "property-change",
|
|
710
|
-
anchor: createRevisionRangeAnchor(position, position),
|
|
711
|
-
authorId: metadata.authorId,
|
|
712
|
-
createdAt: metadata.createdAt,
|
|
713
|
-
metadata: {
|
|
714
|
-
source: "import",
|
|
715
|
-
originalRevisionType: "sectPrChange",
|
|
716
|
-
ooxmlRevisionId: metadata.ooxmlRevisionId,
|
|
717
|
-
propertyChangeData,
|
|
718
|
-
},
|
|
719
|
-
}),
|
|
720
|
-
);
|
|
721
|
-
state.preservedMarkup.push({
|
|
722
|
-
revisionId: metadata.revisionId,
|
|
723
|
-
rawXml: state.documentXml.slice(sectPrChange.start, sectPrChange.end),
|
|
724
|
-
xmlStart: sectPrChange.start,
|
|
725
|
-
xmlEnd: sectPrChange.end,
|
|
726
|
-
originalRevisionType: "sectPrChange",
|
|
727
|
-
containerXmlStart: sectPr.start,
|
|
728
|
-
containerXmlEnd: sectPr.end,
|
|
729
|
-
beforeContainerXml: beforeXml,
|
|
730
|
-
});
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
function readRevisionMetadata(
|
|
734
|
-
node: XmlElementNode,
|
|
735
|
-
state: ParseState,
|
|
736
|
-
prefix: string,
|
|
737
|
-
): RevisionMetadata {
|
|
738
|
-
const rawId = node.attributes["w:id"] ?? node.attributes.id;
|
|
739
|
-
const ooxmlRevisionId = rawId ? rawId : undefined;
|
|
740
|
-
const revisionId = rawId
|
|
741
|
-
? `revision:${sanitizeRevisionToken(prefix)}-${sanitizeRevisionToken(rawId)}`
|
|
742
|
-
: `revision:${sanitizeRevisionToken(prefix)}-generated-${state.nextGeneratedIndex++}`;
|
|
743
|
-
const authorId =
|
|
744
|
-
node.attributes["w:author"] ??
|
|
745
|
-
node.attributes.author ??
|
|
746
|
-
"word:unknown-author";
|
|
747
|
-
const createdAt =
|
|
748
|
-
normalizeImportedTimestamp(
|
|
749
|
-
node.attributes["w:date"] ?? node.attributes.date,
|
|
750
|
-
) ??
|
|
751
|
-
"1970-01-01T00:00:00.000Z";
|
|
752
|
-
|
|
753
|
-
return {
|
|
754
|
-
revisionId,
|
|
755
|
-
ooxmlRevisionId,
|
|
756
|
-
authorId,
|
|
757
|
-
createdAt,
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
function normalizeImportedTimestamp(value: string | undefined): string | undefined {
|
|
762
|
-
if (!value) {
|
|
763
|
-
return undefined;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
const parsed = new Date(value);
|
|
767
|
-
if (Number.isNaN(parsed.valueOf())) {
|
|
768
|
-
return undefined;
|
|
769
|
-
}
|
|
770
|
-
|
|
771
|
-
return parsed.toISOString();
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
function sanitizeRevisionToken(value: string): string {
|
|
775
|
-
const sanitized = value.replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
776
|
-
return sanitized.length > 0 ? sanitized : "unknown";
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
function linkMoveRevisionPairs(state: ParseState): void {
|
|
780
|
-
const moveRevisions = state.revisions.filter(
|
|
781
|
-
(r) => r.kind === "move" && r.metadata.moveData,
|
|
782
|
-
);
|
|
783
|
-
|
|
784
|
-
const byMoveId = new Map<string, typeof moveRevisions>();
|
|
785
|
-
for (const revision of moveRevisions) {
|
|
786
|
-
const moveId = revision.metadata.moveData!.moveId;
|
|
787
|
-
const group = byMoveId.get(moveId) ?? [];
|
|
788
|
-
group.push(revision);
|
|
789
|
-
byMoveId.set(moveId, group);
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
for (const [moveId, group] of byMoveId) {
|
|
793
|
-
const fromRevision = group.find(
|
|
794
|
-
(r) => r.metadata.moveData!.direction === "from",
|
|
795
|
-
);
|
|
796
|
-
const toRevision = group.find(
|
|
797
|
-
(r) => r.metadata.moveData!.direction === "to",
|
|
798
|
-
);
|
|
799
|
-
|
|
800
|
-
if (fromRevision && toRevision) {
|
|
801
|
-
fromRevision.metadata.moveData!.linkedRevisionId = toRevision.revisionId;
|
|
802
|
-
toRevision.metadata.moveData!.linkedRevisionId = fromRevision.revisionId;
|
|
803
|
-
|
|
804
|
-
state.diagnostics.push({
|
|
805
|
-
revisionId: fromRevision.revisionId,
|
|
806
|
-
code: "linked_move_pair",
|
|
807
|
-
message: `Move-from revision linked to move-to revision ${toRevision.revisionId} via moveId ${moveId}.`,
|
|
808
|
-
featureClass: "informational",
|
|
809
|
-
});
|
|
810
|
-
state.diagnostics.push({
|
|
811
|
-
revisionId: toRevision.revisionId,
|
|
812
|
-
code: "linked_move_pair",
|
|
813
|
-
message: `Move-to revision linked to move-from revision ${fromRevision.revisionId} via moveId ${moveId}.`,
|
|
814
|
-
featureClass: "informational",
|
|
815
|
-
});
|
|
816
|
-
} else {
|
|
817
|
-
for (const revision of group) {
|
|
818
|
-
state.diagnostics.push({
|
|
819
|
-
revisionId: revision.revisionId,
|
|
820
|
-
code: "unlinked_move_revision",
|
|
821
|
-
message: `Move revision has no matching counterpart for moveId ${moveId}. Remains preserve-only.`,
|
|
822
|
-
featureClass: "preserve-only",
|
|
823
|
-
});
|
|
824
|
-
}
|
|
825
|
-
}
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
function isShallowPropertyChangeNesting(node: XmlElementNode): boolean {
|
|
830
|
-
for (const child of node.children) {
|
|
831
|
-
if (child.type !== "element") {
|
|
832
|
-
continue;
|
|
833
|
-
}
|
|
834
|
-
|
|
835
|
-
const name = localName(child.name);
|
|
836
|
-
|
|
837
|
-
if (SUPPORTED_CONTAINER_TYPES.has(name) || PRESERVE_ONLY_CONTAINER_TYPES.has(name)) {
|
|
838
|
-
return false;
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
if (name === "r") {
|
|
842
|
-
const runProperties = findChildElement(child, "rPr");
|
|
843
|
-
if (runProperties) {
|
|
844
|
-
for (const rpChild of runProperties.children) {
|
|
845
|
-
if (rpChild.type !== "element") {
|
|
846
|
-
continue;
|
|
847
|
-
}
|
|
848
|
-
|
|
849
|
-
const rpChildName = localName(rpChild.name);
|
|
850
|
-
if (
|
|
851
|
-
SUPPORTED_CONTAINER_TYPES.has(rpChildName) ||
|
|
852
|
-
PRESERVE_ONLY_CONTAINER_TYPES.has(rpChildName)
|
|
853
|
-
) {
|
|
854
|
-
return false;
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
continue;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
if (!isShallowPropertyChangeNesting(child)) {
|
|
862
|
-
return false;
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
return true;
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
function parseNestedPropertyChangeRevisions(
|
|
870
|
-
container: XmlElementNode,
|
|
871
|
-
paragraphIndex: number,
|
|
872
|
-
state: ParseState,
|
|
873
|
-
containerStart: number,
|
|
874
|
-
): void {
|
|
875
|
-
for (const child of container.children) {
|
|
876
|
-
if (child.type !== "element") {
|
|
877
|
-
continue;
|
|
878
|
-
}
|
|
879
|
-
|
|
880
|
-
if (localName(child.name) === "r") {
|
|
881
|
-
parseRunFormattingRevisions(child, paragraphIndex, state, containerStart);
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
|
|
886
|
-
function containsNestedRevision(node: XmlElementNode): boolean {
|
|
887
|
-
return node.children.some(
|
|
888
|
-
(child) =>
|
|
889
|
-
child.type === "element" &&
|
|
890
|
-
(SUPPORTED_CONTAINER_TYPES.has(localName(child.name)) ||
|
|
891
|
-
PRESERVE_ONLY_CONTAINER_TYPES.has(localName(child.name)) ||
|
|
892
|
-
PROPERTY_CHANGE_REVISION_TYPES.has(localName(child.name)) ||
|
|
893
|
-
containsNestedRevision(child)),
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
function advanceCursor(
|
|
898
|
-
node: XmlElementNode,
|
|
899
|
-
setCursor: (next: number) => void,
|
|
900
|
-
getCursor: () => number,
|
|
901
|
-
): void {
|
|
902
|
-
setCursor(getCursor() + measureStoryLength(node));
|
|
903
|
-
}
|
|
904
|
-
|
|
905
|
-
function measureStoryLength(node: XmlNode): number {
|
|
906
|
-
if (node.type !== "element") {
|
|
907
|
-
return 0;
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
switch (localName(node.name)) {
|
|
911
|
-
case "t":
|
|
912
|
-
case "delText":
|
|
913
|
-
case "instrText":
|
|
914
|
-
case "delInstrText":
|
|
915
|
-
return node.children
|
|
916
|
-
.filter((child): child is XmlElementNode["children"][number] & { type: "text" } => child.type === "text")
|
|
917
|
-
.map((child) => child.text.length)
|
|
918
|
-
.reduce((total, length) => total + length, 0);
|
|
919
|
-
case "tab":
|
|
920
|
-
case "br":
|
|
921
|
-
case "cr":
|
|
922
|
-
return 1;
|
|
923
|
-
case "pPr":
|
|
924
|
-
case "rPr":
|
|
925
|
-
case "rPrChange":
|
|
926
|
-
case "pPrChange":
|
|
927
|
-
return 0;
|
|
928
|
-
default:
|
|
929
|
-
return node.children.reduce((total, child) => total + measureStoryLength(child), 0);
|
|
930
|
-
}
|
|
931
|
-
}
|