oasis-editor 0.0.145 → 0.0.147

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.
Files changed (59) hide show
  1. package/dist/{OasisEditorApp-CskQWKEC.js → OasisEditorApp-DM9mi2EU.js} +4258 -4167
  2. package/dist/__tests__/ooxml/markupCompatibilityEngine.test.d.ts +1 -0
  3. package/dist/__tests__/ooxml/milestone2Integration.test.d.ts +1 -0
  4. package/dist/__tests__/ooxml/namespaceRegistry.test.d.ts +1 -0
  5. package/dist/__tests__/ooxml/preservationBag.test.d.ts +1 -0
  6. package/dist/__tests__/ooxml/universalContainerPatcher.test.d.ts +1 -0
  7. package/dist/app/controllers/tableOpsMutationCommands.d.ts +14 -3
  8. package/dist/app/controllers/tableOpsSelectionRanges.d.ts +4 -1
  9. package/dist/app/controllers/useEditorTableOperations.d.ts +2 -2
  10. package/dist/assets/importDocxWorker-BLm3QMHu.js +12 -0
  11. package/dist/core/commands/table/tableCommandUtils.d.ts +7 -1
  12. package/dist/core/editorState/nodeFactories.d.ts +1 -1
  13. package/dist/core/model/documentIndex.d.ts +35 -2
  14. package/dist/core/model/index.d.ts +2 -2
  15. package/dist/core/model/types/docxSourcePackage.d.ts +7 -0
  16. package/dist/core/model/types/nodes.d.ts +2 -1
  17. package/dist/export/docx/docxNumbering.d.ts +4 -1
  18. package/dist/export/docx/endnotesXml.d.ts +2 -5
  19. package/dist/export/docx/footnotesXml.d.ts +3 -21
  20. package/dist/export/docx/noteDocxIds.d.ts +9 -0
  21. package/dist/export/docx/opc/commentEntrySourcePatcher.d.ts +5 -0
  22. package/dist/export/docx/opc/commentsExtendedSourcePatcher.d.ts +5 -0
  23. package/dist/export/docx/opc/documentRootSourcePatcher.d.ts +5 -0
  24. package/dist/export/docx/opc/extensionMarkupMerge.d.ts +9 -0
  25. package/dist/export/docx/opc/headerFooterRootSourcePatcher.d.ts +11 -0
  26. package/dist/export/docx/opc/headerFooterSourcePatcher.d.ts +9 -0
  27. package/dist/export/docx/opc/headerFooterStoryReferences.d.ts +14 -0
  28. package/dist/export/docx/opc/noteEntrySourcePatcher.d.ts +4 -0
  29. package/dist/export/docx/opc/numberingSourcePatcher.d.ts +5 -0
  30. package/dist/export/docx/opc/rebuiltPartHashes.d.ts +5 -0
  31. package/dist/export/docx/opc/relatedStoryRootSourcePatcher.d.ts +11 -0
  32. package/dist/export/docx/opc/sectionPropertiesSourcePatcher.d.ts +10 -0
  33. package/dist/export/docx/opc/sourceBackedDocxPatcher.d.ts +4 -0
  34. package/dist/export/docx/opc/sourceOnlySingletonFilter.d.ts +19 -0
  35. package/dist/export/docx/opc/sourcePackagePatcher.d.ts +7 -3
  36. package/dist/export/docx/opc/styleParagraphPropertiesSourcePatcher.d.ts +5 -0
  37. package/dist/export/docx/opc/styleRunPropertiesSourcePatcher.d.ts +5 -0
  38. package/dist/export/docx/opc/styleTablePropertiesSourcePatcher.d.ts +5 -0
  39. package/dist/export/docx/opc/universalContainerPatcher.d.ts +1 -0
  40. package/dist/export/docx/opc/wordPartRootSourcePatcher.d.ts +21 -0
  41. package/dist/export/docx/opc/wordSingletonSourcePatcher.d.ts +14 -0
  42. package/dist/export/docx/tableSourcePropertiesXml.d.ts +13 -0
  43. package/dist/export/docx/tableSourceXml.d.ts +10 -0
  44. package/dist/export/docx/tableXml.d.ts +5 -3
  45. package/dist/export/docx/text/sourceParagraphPropertiesXml.d.ts +8 -0
  46. package/dist/export/docx/text/sourceRunPropertiesXml.d.ts +7 -0
  47. package/dist/import/docx/opc/sourcePackage.d.ts +1 -0
  48. package/dist/{index-DOtfE4EA.js → index-CXKg4TC3.js} +5960 -875
  49. package/dist/oasis-editor.js +79 -79
  50. package/dist/oasis-editor.umd.cjs +4 -4
  51. package/dist/ooxml/markupCompatibilityEngine.d.ts +16 -0
  52. package/dist/ooxml/namespaceRegistry.d.ts +17 -0
  53. package/dist/ooxml/preservationBag.d.ts +21 -0
  54. package/dist/ooxml/schemaOrder.d.ts +7 -0
  55. package/dist/ooxml/word/numberingMetadata.d.ts +4 -0
  56. package/dist/ooxml/word/sourceFragments.d.ts +39 -3
  57. package/dist/ui/tableGeometry.d.ts +2 -3
  58. package/package.json +1 -1
  59. package/dist/assets/importDocxWorker-5S8lX4CZ.js +0 -12
@@ -1,4 +1,4 @@
1
- import { EditorBlockNode, EditorDocument, EditorEditingZone, EditorState, EditorTableNode, TableLocation, EditorRevisionMetadata } from '../../model.js';
1
+ import { EditorBlockNode, EditorDocument, EditorEditingZone, EditorState, EditorTableNode, TableLocation, TablePathSegment, EditorRevisionMetadata } from '../../model.js';
2
2
 
3
3
  export type StylePatchValue<T, K extends keyof T> = T[K] | null;
4
4
  export interface ActiveTableLocation {
@@ -14,4 +14,10 @@ export declare function updateTablesInBlocks(blocks: EditorBlockNode[], updateTa
14
14
  export declare function updateNestedTablesInBlocks(blocks: EditorBlockNode[], updateTable: (table: EditorTableNode) => EditorTableNode): EditorBlockNode[];
15
15
  export declare function getBlocksForZone(document: EditorDocument, sectionIndex: number, zone: EditorEditingZone): EditorBlockNode[] | undefined;
16
16
  export declare function resolveActiveTableLocation(state: EditorState): ActiveTableLocation | null;
17
+ /**
18
+ * Applies `updateTable` to exactly the table identified by `tablePath`.
19
+ * Ancestor tables/cells are copied only along the target path, preserving
20
+ * structural sharing for every unrelated block and cell.
21
+ */
22
+ export declare function updateTableAtPath(blocks: EditorBlockNode[], tablePath: readonly TablePathSegment[], updateTable: (table: EditorTableNode) => EditorTableNode): EditorBlockNode[];
17
23
  export declare function updateActiveTableBlocks(state: EditorState, updateTable: (table: EditorTableNode) => EditorTableNode): EditorState;
@@ -18,7 +18,7 @@ export declare function createEditorParagraphFromRuns(runs: Array<{
18
18
  image?: EditorImageRunData;
19
19
  textBox?: EditorTextBoxData;
20
20
  }>): EditorParagraphNode;
21
- export declare function createEditorTableCell(paragraphs: EditorParagraphNode[], colSpan?: number, options?: {
21
+ export declare function createEditorTableCell(blocks: EditorBlockNode[], colSpan?: number, options?: {
22
22
  rowSpan?: number;
23
23
  vMerge?: "restart" | "continue";
24
24
  }): EditorTableCellNode;
@@ -1,4 +1,4 @@
1
- import { EditorParagraphNode } from './types/nodes.js';
1
+ import { EditorBlockNode, EditorParagraphNode, EditorTableCellNode, EditorTableNode } from './types/nodes.js';
2
2
  import { EditorDocument } from './types/document.js';
3
3
  import { EditorEditingZone } from './types/selection.js';
4
4
 
@@ -9,11 +9,33 @@ export interface EditorParagraphLocation {
9
9
  /** When `zone === "footnote"`, identifies which footnote owns the paragraph. */
10
10
  footnoteId?: string;
11
11
  }
12
+ /**
13
+ * One table hop from a block story into a cell. `tableBlockIndex` is relative
14
+ * to the story that contains that table: a section/header/footer story for the
15
+ * first hop, then the parent cell's `blocks` array for every nested hop.
16
+ */
17
+ export interface TablePathSegment {
18
+ tableBlockIndex: number;
19
+ rowIndex: number;
20
+ cellIndex: number;
21
+ }
12
22
  export interface TableLocation {
23
+ /** Top-level table block index. Retained for legacy one-level consumers. */
13
24
  blockIndex: number;
25
+ /** Top-level row index. Retained for legacy one-level consumers. */
14
26
  rowIndex: number;
27
+ /** Top-level cell index. Retained for legacy one-level consumers. */
15
28
  cellIndex: number;
29
+ /** Paragraph block index inside the innermost cell story. */
16
30
  paragraphIndex: number;
31
+ /** Complete outer-to-inner path. One entry means a legacy direct table. */
32
+ tablePath: TablePathSegment[];
33
+ }
34
+ export interface ResolvedTablePath {
35
+ table: EditorTableNode;
36
+ cell: EditorTableCellNode;
37
+ segment: TablePathSegment;
38
+ depth: number;
17
39
  }
18
40
  export interface DocumentParagraphIndexEntry {
19
41
  paragraph: EditorParagraphNode;
@@ -26,7 +48,8 @@ export declare class DocumentIndexBuilder {
26
48
  constructor(document: EditorDocument);
27
49
  build(): Map<string, DocumentParagraphIndexEntry>;
28
50
  private indexZone;
29
- private indexBlock;
51
+ private indexTable;
52
+ private indexTopLevelBlock;
30
53
  private recordParagraph;
31
54
  private indexFootnotes;
32
55
  }
@@ -53,6 +76,16 @@ export declare function getDocumentParagraphsCanonical(document: EditorDocument)
53
76
  export declare function getDocumentParagraphs(document: EditorDocument): EditorParagraphNode[];
54
77
  export declare function getParagraphById(document: EditorDocument, paragraphId: string): EditorParagraphNode | undefined;
55
78
  export declare function findParagraphLocation(document: EditorDocument, paragraphId: string): EditorParagraphLocation | null;
79
+ /** Returns the complete path, including nested tables. */
80
+ export declare function findParagraphTablePathLocation(document: EditorDocument, paragraphId: string, activeSectionIndex?: number): (TableLocation & {
81
+ zone: EditorEditingZone;
82
+ }) | null;
83
+ /**
84
+ * Legacy one-level lookup. Nested table paragraphs intentionally return null so
85
+ * older merge/split callers cannot accidentally mutate the outer table.
86
+ */
56
87
  export declare function findParagraphTableLocation(document: EditorDocument, paragraphId: string, activeSectionIndex?: number): (TableLocation & {
57
88
  zone: EditorEditingZone;
58
89
  }) | null;
90
+ /** Resolve every table/cell hop from a zone block story. */
91
+ export declare function resolveTablePath(blocks: EditorBlockNode[], tablePath: readonly TablePathSegment[]): ResolvedTablePath[] | null;
@@ -29,8 +29,8 @@ export type { StyleMerger, Mergeable } from './styleResolution.js';
29
29
  export { resolveImageSrc } from './assets.js';
30
30
  export { normalizePageSettings, getDocumentPageSettings, getPageContentWidth, getPageColumnRects, getPageHeaderZoneTop, getPageBodyTop, getPageFooterReferenceTop, getPageBodyBottom, getPageHeaderZoneHeight, getPageFooterZoneTop, getPageFooterZoneHeight, getPageContentHeight, } from './pageGeometry.js';
31
31
  export { getDocumentSections, getDocumentSectionsCanonical, } from './documentSections.js';
32
- export { DocumentIndexBuilder, getDocumentParagraphIndex, getDocumentParagraphs, getDocumentParagraphsCanonical, getParagraphById, findParagraphLocation, findParagraphTableLocation, WeakMapDocumentIndexCache, } from './documentIndex.js';
33
- export type { EditorParagraphLocation, TableLocation, DocumentParagraphIndexEntry, DocumentIndexCache, } from './documentIndex.js';
32
+ export { DocumentIndexBuilder, getDocumentParagraphIndex, getDocumentParagraphs, getDocumentParagraphsCanonical, getParagraphById, findParagraphLocation, findParagraphTableLocation, findParagraphTablePathLocation, resolveTablePath, WeakMapDocumentIndexCache, } from './documentIndex.js';
33
+ export type { EditorParagraphLocation, TableLocation, TablePathSegment, DocumentParagraphIndexEntry, DocumentIndexCache, } from './documentIndex.js';
34
34
  export { getBlockParagraphs, collectSectionParagraphs, } from './paragraphWalker.js';
35
35
  export { buildListLabels, resolveListLabel } from './listNumbering.js';
36
36
  export { getActiveSectionIndex, getActiveZone, getEditableBlocksForZone, tryGetEditableBlocksForZone, getActiveSectionBlocks, getParagraphs, } from './editingZones.js';
@@ -43,4 +43,11 @@ export interface EditorDocxSourcePackage {
43
43
  rootRelationships: EditorOpcRelationship[];
44
44
  parts: Record<string, EditorOpcPart>;
45
45
  diagnostics?: EditorDocxDiagnostic[];
46
+ /**
47
+ * Hashes of the canonical Oasis rebuild immediately after import, keyed by
48
+ * conventional rebuilt part path. During source-backed export an equal hash
49
+ * proves that the modeled semantic domain did not change, allowing the exact
50
+ * source part bytes to remain untouched instead of being reserialized.
51
+ */
52
+ rebuiltPartHashes?: Record<string, string>;
46
53
  }
@@ -290,7 +290,8 @@ export interface EditorParagraphNode {
290
290
  }
291
291
  export interface EditorTableCellNode {
292
292
  id: string;
293
- blocks: EditorParagraphNode[];
293
+ /** Ordered block story inside the cell; Word permits paragraphs and tables. */
294
+ blocks: EditorBlockNode[];
294
295
  colSpan?: number;
295
296
  rowSpan?: number;
296
297
  vMerge?: "restart" | "continue";
@@ -4,7 +4,10 @@ import { NumberingContext, NumberingDefinition } from './docxTypes.js';
4
4
  /**
5
5
  * Walks the document (including headers/footers and nested content) collecting
6
6
  * list paragraphs into abstract numbering definitions and a per-paragraph
7
- * numId/level map. Extracted from exportEditorDocumentToDocx (S2).
7
+ * numId/level map. Imported list identities are retained whenever possible so
8
+ * source-backed export can key granular numbering preservation by stable OOXML
9
+ * ids. New ids are allocated above the source package's maximum to avoid
10
+ * colliding with source-only definitions that still need preservation.
8
11
  */
9
12
  export declare function buildNumberingContext(document: EditorDocument): NumberingContext;
10
13
  export declare function buildNumberingXml(definitions: NumberingDefinition[]): string;
@@ -2,17 +2,14 @@ import { EditorBlockNode, EditorDocument, EditorEndnote, EditorNamedStyle } from
2
2
  import { DocContext, ExportBuildState, NumberingContext } from './docxTypes.js';
3
3
 
4
4
  export interface ReferencedEndnote {
5
- /** Local editor id. */
6
5
  endnoteId: string;
7
- /** DOCX numeric id used in `w:endnoteReference w:id="N"` and `w:endnote w:id="N"`. */
8
6
  docxId: number;
9
- /** Endnote body. */
10
7
  endnote: EditorEndnote;
11
8
  }
12
9
  /**
13
10
  * Walks the document in reading order and returns one entry per distinct
14
- * endnote id that is actually referenced by an inline run. Unreferenced
15
- * endnotes in the registry are skipped.
11
+ * referenced endnote. Imported positive `w:id` values are retained when
12
+ * unique; new/conflicting notes are allocated above every imported id.
16
13
  */
17
14
  export declare function collectReferencedEndnotesForExport(document: EditorDocument): ReferencedEndnote[];
18
15
  export declare function buildEndnoteIdMap(referenced: ReferencedEndnote[]): Map<string, number>;
@@ -2,39 +2,21 @@ import { EditorBlockNode, EditorDocument, EditorFootnote, EditorNamedStyle } fro
2
2
  import { DocContext, ExportBuildState, NumberingContext } from './docxTypes.js';
3
3
 
4
4
  export interface ReferencedFootnote {
5
- /** Local editor id. */
6
5
  footnoteId: string;
7
- /** DOCX numeric id used in `w:footnoteReference w:id="N"` and `w:footnote w:id="N"`. */
8
6
  docxId: number;
9
- /** Footnote body. */
10
7
  footnote: EditorFootnote;
11
8
  }
12
9
  /**
13
10
  * Walks the document in reading order and returns one entry per distinct
14
- * footnote id that is actually referenced by an inline run. Unreferenced
15
- * footnotes in the registry are skipped.
16
- *
17
- * Returns an empty list when the document has no footnotes.
11
+ * referenced footnote. Imported positive `w:id` values are retained when
12
+ * unique; new/conflicting notes are allocated above every imported id.
18
13
  */
19
14
  export declare function collectReferencedFootnotesForExport(document: EditorDocument): ReferencedFootnote[];
20
15
  export declare function buildFootnoteIdMap(referenced: ReferencedFootnote[]): Map<string, number>;
21
- /**
22
- * Serialize the footnote bodies into the `<w:footnotes>` part XML, including
23
- * the conventional special entries (`separator` and `continuationSeparator`).
24
- *
25
- * `bodyContext` is the parent `DocContext`. We need it only to share the
26
- * footnoteIdMap; image/hyperlink relationships specific to the footnotes
27
- * part are returned via `partContext` (separate rels file).
28
- */
29
16
  export interface FootnotesPartResult {
30
17
  xml: string;
31
18
  partContext: DocContext;
32
19
  }
33
- export declare function buildFootnotesXml(document: EditorDocument, referenced: ReferencedFootnote[], numberingContext: NumberingContext, state: ExportBuildState, buildContext: (blocks: EditorBlockNode[]) => DocContext, styles: Record<string, EditorNamedStyle> | undefined, footnoteIdMap: Map<string, number>): FootnotesPartResult;
34
- /**
35
- * Convenience: figure out if the document has at least one referenced
36
- * footnote — used by callers to decide whether to emit the part at all.
37
- */
20
+ export declare function buildFootnotesXml(_document: EditorDocument, referenced: ReferencedFootnote[], _numberingContext: NumberingContext, _state: ExportBuildState, buildContext: (blocks: EditorBlockNode[]) => DocContext, styles: Record<string, EditorNamedStyle> | undefined, footnoteIdMap: Map<string, number>): FootnotesPartResult;
38
21
  export declare function hasReferencedFootnotes(document: EditorDocument): boolean;
39
- /** Re-export to keep the public surface small. */
40
22
  export type { DocContext, NumberingContext, ExportBuildState };
@@ -0,0 +1,9 @@
1
+ export interface NoteWithDocxIdHint {
2
+ docxId?: number;
3
+ }
4
+ /**
5
+ * Allocates real footnote/endnote ids while keeping imported identities stable.
6
+ * New or conflicting ids are placed above every imported id in the registry so
7
+ * source-backed entry preservation cannot collide with a source-only note.
8
+ */
9
+ export declare function createSourceAwareNoteDocxIdAllocator<T extends NoteWithDocxIdHint>(items: Record<string, T>): (note: T) => number;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeCommentEntriesOoxmlSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltCommentEntriesFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeCommentsExtendedOoxmlSource(sourceCommentsXml: string, sourceExtendedXml: string, rebuiltCommentsXml: string, rebuiltExtendedXml: string): string;
5
+ export declare function patchRebuiltCommentsExtendedFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeDocumentRootAndBodyExtensionsFromSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltDocumentRootFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,9 @@
1
+ import { Element as XmlElement } from '@xmldom/xmldom';
2
+
3
+ /**
4
+ * Recursively carries extension-namespace markup through a generated Word
5
+ * subtree. WordprocessingML attributes/children that disappeared from the
6
+ * generated form are never restored, so preservation cannot undo an editor
7
+ * deletion or overwrite canonical modeled semantics.
8
+ */
9
+ export declare function mergeNestedExtensionMarkup(source: XmlElement, generated: XmlElement): void;
@@ -0,0 +1,11 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ /**
5
+ * Preserves root namespace/compatibility attributes and opaque extension
6
+ * children in changed header/footer parts before the existing source-path
7
+ * patcher relocates those parts back to their original relationship targets.
8
+ * Pairing uses the same stable section/kind/type/occurrence identity as the
9
+ * path-preservation layer and is disabled when section topology diverges.
10
+ */
11
+ export declare function patchRebuiltHeaderFooterRootsFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,9 @@
1
+ import { EditorDocument } from '../../../core/model.js';
2
+
3
+ /**
4
+ * Prepares collection-valued header/footer relationships before the general
5
+ * source-package merge. Pairing uses section index and reference type, source
6
+ * paths and r:ids are restored, unchanged parts are omitted so their original
7
+ * bytes survive, and explicit removals are filtered from the source snapshot.
8
+ */
9
+ export declare function patchRebuiltDocxWithHeaderFooterSourcePaths(document: EditorDocument, rebuiltBuffer: ArrayBuffer): Promise<ArrayBuffer>;
@@ -0,0 +1,14 @@
1
+ export type HeaderFooterStoryKind = "header" | "footer";
2
+ export interface HeaderFooterStoryReference {
3
+ kind: HeaderFooterStoryKind;
4
+ type: string;
5
+ occurrence: number;
6
+ relationshipId: string;
7
+ }
8
+ /**
9
+ * Reads active section header/footer references without assuming `w` or `r`
10
+ * prefix spellings. The semantic identity is namespace URI + local name; the
11
+ * relationship id is intentionally read by local name so Transitional, Strict
12
+ * and producer-chosen relationship prefixes all remain discoverable.
13
+ */
14
+ export declare function collectHeaderFooterStoryReferences(xml: string): HeaderFooterStoryReference[];
@@ -0,0 +1,4 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocument, EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function patchRebuiltNoteEntriesFromSource(document: EditorDocument, sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeNumberingOoxmlSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltNumberingFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { EditorDocument } from '../../../core/model.js';
2
+
3
+ export declare function hashDocxPartBytes(bytes: Uint8Array): string;
4
+ export declare function hashRebuiltDocxParts(buffer: ArrayBuffer): Promise<Record<string, string>>;
5
+ export declare function captureRebuiltDocxPartHashes(document: EditorDocument): Promise<Record<string, string>>;
@@ -0,0 +1,11 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ /**
5
+ * Preserves compatibility attributes, namespaces and non-Word extension
6
+ * children at the roots of secondary WordprocessingML stories. Note/comment
7
+ * entries themselves remain owned by their semantic serializers; this layer
8
+ * intentionally does not resurrect a deleted `w:footnote`, `w:endnote` or
9
+ * `w:comment`.
10
+ */
11
+ export declare function patchRebuiltRelatedStoryRootsFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Overlays source-only document/section markup onto a rebuilt document.xml.
3
+ *
4
+ * The rebuilt document remains authoritative for the OOXML surface Oasis
5
+ * models. Unknown root attributes, unknown sectPr attributes/children, and
6
+ * producer-specific extensions are retained as long as section topology is
7
+ * unchanged. Relationship/content-type preservation is handled by the outer
8
+ * source-package patcher.
9
+ */
10
+ export declare function mergeRebuiltDocumentSectionPropertiesFromSource(sourceXml: string, rebuiltXml: string): string;
@@ -0,0 +1,4 @@
1
+ import { EditorDocument } from '../../../core/model.js';
2
+
3
+ /** Applies all source-aware prepatches before the generic OPC overlay. */
4
+ export declare function patchRebuiltDocxPreservingSource(document: EditorDocument, rebuiltBuffer: ArrayBuffer): Promise<ArrayBuffer>;
@@ -0,0 +1,19 @@
1
+ import { default as JSZip } from 'jszip';
2
+
3
+ export interface RebuiltSingletonPresence {
4
+ settings: boolean;
5
+ styles: boolean;
6
+ fontTable: boolean;
7
+ }
8
+ /**
9
+ * When the ordinary exporter omitted a modeled singleton but the source-aware
10
+ * prepatch restored it for preservation, strip modeled semantics before the
11
+ * OPC merge. This prevents an explicit "delete the last setting/style/font"
12
+ * edit from being undone while still retaining unsupported source markup.
13
+ *
14
+ * Numbering is intentionally not filtered here: unused numbering definitions
15
+ * have no document-visible effect once all numPr references are gone, and
16
+ * preserving them avoids needless loss until source ID stabilization lets us
17
+ * merge active numbering graphs safely.
18
+ */
19
+ export declare function filterSourceOnlyWordSingletons(rebuilt: JSZip, originallyPresent: RebuiltSingletonPresence): Promise<boolean>;
@@ -1,8 +1,12 @@
1
1
  import { EditorDocument } from '../../../core/model.js';
2
2
 
3
3
  /**
4
- * Clones the imported package and overlays the freshly rebuilt Oasis parts.
5
- * Unknown source parts remain untouched. Content types and relationship parts
6
- * are merged instead of blindly replaced so unrelated package features survive.
4
+ * Clones the imported package and overlays only changed freshly rebuilt Oasis
5
+ * parts. Unknown source parts remain untouched. Content types and relationship
6
+ * parts are merged instead of blindly replaced so unrelated package features
7
+ * survive. Relationship-discovered source paths remain authoritative: rebuilt
8
+ * parts are relocated to those paths and their internal targets are rebased.
9
+ * Modeled singleton parts present in the import baseline but absent from the
10
+ * current rebuild are treated as explicit deletions rather than resurrected.
7
11
  */
8
12
  export declare function patchRebuiltDocxWithSourcePackage(document: EditorDocument, rebuiltBuffer: ArrayBuffer): Promise<ArrayBuffer>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeStyleParagraphPropertiesOoxmlSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltStyleParagraphPropertiesFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeStyleRunPropertiesOoxmlSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltStyleRunPropertiesFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,5 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ export declare function mergeTableStylePropertiesOoxmlSource(sourceXml: string, rebuiltXml: string): string;
5
+ export declare function patchRebuiltTableStylePropertiesFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1 @@
1
+ export declare function preserveNamespacesAndMc(sourceXml: string, rebuiltXml: string): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Preserves root-level producer/extension markup for a rewritten Word part.
3
+ *
4
+ * Word-namespace children are deliberately left to the semantic story model:
5
+ * copying them here could resurrect a paragraph/table/content control that the
6
+ * user intentionally removed. Non-Word children are opaque extension markup;
7
+ * preserving them is safe because Oasis does not currently expose semantic
8
+ * deletion/editing for those nodes. Namespace declarations and compatibility
9
+ * attributes on the root are preserved as well.
10
+ */
11
+ export declare function mergeWordPartRootExtensionsFromSource(sourceXml: string, rebuiltXml: string, expectedRootLocalName: string): string;
12
+ /**
13
+ * Extends root preservation to unsupported WordprocessingML flow wrappers in a
14
+ * story (`customXml`, revision wrappers, `altChunk`, future Word children).
15
+ *
16
+ * The wrapper is restored only when its source gap is unambiguous: preferably
17
+ * through the next original paragraph's `w14:paraId` or SDT id, otherwise via
18
+ * an unchanged p/tbl/sdt topology. This keeps non-structural edits lossless
19
+ * without using raw child indexes after structural changes.
20
+ */
21
+ export declare function mergeWordStoryRootAndFlowFromSource(sourceXml: string, rebuiltXml: string, expectedRootLocalName: string, modeledChildNames?: ReadonlySet<string>): string;
@@ -0,0 +1,14 @@
1
+ import { default as JSZip } from 'jszip';
2
+ import { EditorDocxSourcePackage } from '../../../core/model.js';
3
+
4
+ /**
5
+ * Prepares rewritten Word singleton parts before the generic OPC overlay.
6
+ *
7
+ * - If Oasis did not rebuild a source singleton, keep the source part instead
8
+ * of interpreting omission as deletion.
9
+ * - If Oasis rebuilt a safely keyable singleton, merge source-only markup while
10
+ * leaving generated modeled values authoritative.
11
+ *
12
+ * Relationship and content-type paths are remapped later by sourcePackagePatcher.
13
+ */
14
+ export declare function patchRebuiltWordSingletonsFromSource(sourcePackage: EditorDocxSourcePackage, rebuilt: JSZip): Promise<boolean>;
@@ -0,0 +1,13 @@
1
+ import { EditorTableCellNode, EditorTableNode, EditorTableRowNode } from '../../core/model.js';
2
+
3
+ /** Source-aware merge for a standalone `w:tblPr` such as a table style. */
4
+ export declare function mergeTablePropertiesXmlSource(sourceXml: string, generatedXml: string): string;
5
+ /** Source-aware merge for a standalone `w:trPr` such as `w:tblStylePr`. */
6
+ export declare function mergeTableRowPropertiesXmlSource(sourceXml: string, generatedXml: string): string;
7
+ /** Source-aware merge for a standalone `w:tcPr` such as `w:tblStylePr`. */
8
+ export declare function mergeTableCellPropertiesXmlSource(sourceXml: string, generatedXml: string): string;
9
+ export declare function mergeTablePropertiesOoxmlSource(table: EditorTableNode, generatedXml: string): string;
10
+ export declare function mergeTableGridOoxmlSource(table: EditorTableNode, generatedXml: string): string;
11
+ export declare function mergeTableRowPropertyExceptionsOoxmlSource(row: EditorTableRowNode, generatedXml: string): string;
12
+ export declare function mergeTableRowPropertiesOoxmlSource(row: EditorTableRowNode, generatedXml: string): string;
13
+ export declare function mergeTableCellPropertiesOoxmlSource(cell: EditorTableCellNode, generatedXml: string): string;
@@ -0,0 +1,10 @@
1
+ import { EditorTableNode } from '../../core/model.js';
2
+ import { SerializeTableParagraphXml } from './tableXml.js';
3
+
4
+ /**
5
+ * Serializes a table canonically and then overlays source-backed table, row and
6
+ * cell property containers. Text/content stays authoritative from the editor;
7
+ * source attributes, extension children and unknown property children survive
8
+ * while relationship-bearing fragments continue to use the conservative path.
9
+ */
10
+ export declare function serializeTableXmlPreservingSource(table: EditorTableNode, serializeParagraphXml: SerializeTableParagraphXml): string;
@@ -1,6 +1,8 @@
1
- import { EditorParagraphNode, EditorTableCellNode, EditorTableNode, EditorTableRowStyle } from '../../core/model.js';
1
+ import { EditorBlockNode, EditorTableCellNode, EditorTableNode, EditorTableRowStyle } from '../../core/model.js';
2
2
 
3
- export type SerializeTableParagraphXml = (paragraph: EditorParagraphNode, cell: EditorTableCellNode) => string;
3
+ export type SerializeTableBlockXml = (block: EditorBlockNode, cell: EditorTableCellNode) => string;
4
+ /** @deprecated Use {@link SerializeTableBlockXml}; retained for source compatibility. */
5
+ export type SerializeTableParagraphXml = SerializeTableBlockXml;
4
6
  export declare function serializeTableCellStyleXml(style: EditorTableCellNode["style"]): string;
5
7
  /**
6
8
  * Serializes the core row style properties into `<w:trPr>` inner XML.
@@ -8,4 +10,4 @@ export declare function serializeTableCellStyleXml(style: EditorTableCellNode["s
8
10
  * Returns the full `<w:trPr>...</w:trPr>` element, or `""` when empty.
9
11
  */
10
12
  export declare function serializeTableRowStyleXml(style: EditorTableRowStyle | undefined): string;
11
- export declare function serializeTableXml(table: EditorTableNode, serializeParagraphXml: SerializeTableParagraphXml): string;
13
+ export declare function serializeTableXml(table: EditorTableNode, serializeBlockXml: SerializeTableBlockXml): string;
@@ -1,5 +1,13 @@
1
1
  import { EditorParagraphNode } from '../../../core/model.js';
2
2
 
3
+ /**
4
+ * Generic source-aware merge for a standalone `w:pPr` container. Generated
5
+ * modeled properties remain authoritative while source-only attributes and
6
+ * children are retained in source-relative order. This is shared by paragraph
7
+ * nodes and style property containers so both paths use the same modeled
8
+ * vocabulary and deletion semantics.
9
+ */
10
+ export declare function mergeParagraphPropertiesXmlSource(sourceXml: string, generatedXml: string): string;
3
11
  /**
4
12
  * Preserves source-only `w:pPr` children while keeping the freshly generated
5
13
  * paragraph properties authoritative. Unknown children are inserted before the
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Reuses the run serializer's canonical modeled-property vocabulary for a
3
+ * standalone style `w:rPr`. Unknown Word children are handled by the existing
4
+ * run merge; extension attributes/children nested inside modeled descendants
5
+ * are then layered back without restoring missing Word semantics.
6
+ */
7
+ export declare function mergeRunPropertiesXmlSource(sourceXml: string, generatedXml: string): string;
@@ -1,4 +1,5 @@
1
1
  import { EditorDocument, EditorDocxSourcePackage } from '../../../core/model.js';
2
2
 
3
3
  export declare function captureDocxSourcePackage(buffer: ArrayBuffer): Promise<EditorDocxSourcePackage>;
4
+ export declare function attachDocxRebuiltPartBaseline(document: EditorDocument, sourcePackage: EditorDocxSourcePackage): Promise<void>;
4
5
  export declare function attachDocxSourcePackage(document: EditorDocument, buffer: ArrayBuffer): Promise<EditorDocument>;