superdoc 2.6.1-next.3 → 2.7.0-next.10

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 (50) hide show
  1. package/dist/chunks/{create-super-doc-ui-DCjm-_Xo.es.js → create-super-doc-ui-BTNVc3UD.es.js} +7 -3
  2. package/dist/chunks/{create-super-doc-ui-CwCvqMOa.cjs → create-super-doc-ui-C44xPZxz.cjs} +7 -3
  3. package/dist/collaboration-upgrade-engine.cjs +1 -1
  4. package/dist/collaboration-upgrade-engine.es.js +1 -1
  5. package/dist/document-api/src/content-projection/validation.d.ts +3 -0
  6. package/dist/document-api/src/contract/command-catalog.d.ts +1 -1
  7. package/dist/document-api/src/contract/operation-definitions.d.ts +31 -0
  8. package/dist/document-api/src/contract/operation-registry.d.ts +18 -1
  9. package/dist/document-api/src/contract/sd-fragment-schema.d.ts +4 -0
  10. package/dist/document-api/src/get-html/get-html.d.ts +6 -6
  11. package/dist/document-api/src/get-markdown/get-markdown.d.ts +2 -4
  12. package/dist/document-api/src/html-to-fragment/html-to-fragment.d.ts +8 -0
  13. package/dist/document-api/src/index.d.ts +24 -5
  14. package/dist/document-api/src/insert/insert.d.ts +1 -2
  15. package/dist/document-api/src/project-html/project-html.d.ts +5 -0
  16. package/dist/document-api/src/project-markdown/project-markdown.d.ts +5 -0
  17. package/dist/document-api/src/ranges/ranges.types.d.ts +5 -2
  18. package/dist/document-api/src/receipt-bridge.d.ts +24 -3
  19. package/dist/document-api/src/replace/replace.d.ts +29 -5
  20. package/dist/document-api/src/types/address.d.ts +2 -0
  21. package/dist/document-api/src/types/clipboard.d.ts +69 -6
  22. package/dist/document-api/src/types/content-projection.d.ts +126 -0
  23. package/dist/document-api/src/types/fragment.d.ts +1 -1
  24. package/dist/document-api/src/types/index.d.ts +2 -0
  25. package/dist/document-api/src/types/mutation-plan.types.d.ts +3 -0
  26. package/dist/document-api/src/types/receipt.d.ts +4 -0
  27. package/dist/document-api/src/types/sd-contract.d.ts +61 -5
  28. package/dist/document-api/src/types/sd-nodes.d.ts +9 -1
  29. package/dist/document-api/src/types/structural-input.d.ts +18 -3
  30. package/dist/document-api/src/write/write.d.ts +1 -1
  31. package/dist/layout-engine/painters/dom/src/index.d.ts +2 -0
  32. package/dist/layout-engine/painters/dom/src/web-flow/index.d.ts +3 -0
  33. package/dist/layout-engine/painters/dom/src/web-flow/painter.d.ts +2 -0
  34. package/dist/layout-engine/painters/dom/src/web-flow/render.d.ts +8 -0
  35. package/dist/layout-engine/painters/dom/src/web-flow/styles.d.ts +10 -0
  36. package/dist/layout-engine/painters/dom/src/web-flow/types.d.ts +77 -0
  37. package/dist/public/ui-react.cjs +1 -1
  38. package/dist/public/ui-react.es.js +1 -1
  39. package/dist/public/ui.cjs +1 -1
  40. package/dist/public/ui.es.js +1 -1
  41. package/dist/superdoc/src/composables/use-link-popover.d.ts +3 -14
  42. package/dist/superdoc/src/core/types/index.d.ts +12 -5
  43. package/dist/superdoc/src/helpers/v2-review-mutation-impact.d.ts +2 -3
  44. package/dist/superdoc.cjs +36 -128
  45. package/dist/superdoc.es.js +36 -128
  46. package/dist/word-layout/src/index.d.ts +2 -0
  47. package/dist/word-layout/src/list-marker.d.ts +8 -0
  48. package/dist/word-layout/src/review-aware-numbering.d.ts +41 -0
  49. package/dist-cdn/superdoc.min.js +37 -37
  50. package/package.json +2 -2
@@ -1,6 +1,7 @@
1
1
  import { AdapterMutationFailure } from './adapter-result.js';
2
2
  import { SelectionTarget } from './address.js';
3
3
  import { ReceiptFailure, ReceiptSuccess, ReviewWarning } from './receipt.js';
4
+ import { SDConversionDiagnostic, SDDiagnostic } from './sd-contract.js';
4
5
  import { StoryLocator } from './story.types.js';
5
6
  export declare const SUPERDOC_V2_CLIPBOARD_MIME = "application/x-superdoc-v2-fragment";
6
7
  export declare const SUPERDOC_V22_CLIPBOARD_MIME = "application/x-superdoc-v2-fragment-v2.2";
@@ -46,11 +47,34 @@ export interface SDPasteRunMarks {
46
47
  export interface SDPasteRun {
47
48
  text: string;
48
49
  marks?: SDPasteRunMarks;
50
+ /** Transient conversion identity used to map mutation effects back to source nodes. */
51
+ sourcePath?: readonly (string | number)[];
49
52
  }
50
- export type SDPasteInline = {
53
+ export interface SDPasteParagraphProperties {
54
+ alignment?: 'left' | 'center' | 'right' | 'justify';
55
+ indent?: {
56
+ start?: number;
57
+ end?: number;
58
+ left?: number;
59
+ right?: number;
60
+ firstLine?: number;
61
+ hanging?: number;
62
+ };
63
+ spacing?: {
64
+ before?: number;
65
+ after?: number;
66
+ line?: number;
67
+ lineRule?: 'auto' | 'exact' | 'atLeast';
68
+ };
69
+ }
70
+ export type SDPasteLeafInline = {
51
71
  kind: 'text';
52
72
  text: string;
53
73
  marks?: SDPasteRunMarks;
74
+ sourcePath?: readonly (string | number)[];
75
+ } | {
76
+ kind: 'lineBreak';
77
+ sourcePath?: readonly (string | number)[];
54
78
  } | {
55
79
  kind: 'image';
56
80
  assetId: string;
@@ -59,11 +83,26 @@ export type SDPasteInline = {
59
83
  name?: string;
60
84
  alt?: string;
61
85
  title?: string;
86
+ sourcePath?: readonly (string | number)[];
87
+ };
88
+ export type SDPasteInline = SDPasteLeafInline | {
89
+ kind: 'hyperlink';
90
+ target: {
91
+ kind: 'external';
92
+ url: string;
93
+ } | {
94
+ kind: 'anchor';
95
+ anchor: string;
96
+ };
97
+ inlines: readonly SDPasteLeafInline[];
98
+ tooltip?: string;
99
+ sourcePath?: readonly (string | number)[];
62
100
  };
63
101
  export interface SDPasteParagraphBlock {
64
102
  kind: 'paragraph';
65
103
  runs: readonly SDPasteRun[];
66
104
  inlines?: readonly SDPasteInline[];
105
+ paragraphProps?: SDPasteParagraphProperties;
67
106
  styleRef?: string;
68
107
  /** Portable built-in style intent; destination style identity remains local. */
69
108
  semanticStyleRole?: 'default-paragraph' | 'title' | 'subtitle' | `heading-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`;
@@ -83,7 +122,12 @@ export interface SDPasteParagraphBlock {
83
122
  level?: number;
84
123
  /** True on the first block of a distinct adjacent portable list. */
85
124
  startsNewList?: boolean;
125
+ /** Positive ordinal for an ordered-list restart at `level`. */
126
+ start?: number;
127
+ format?: 'decimal' | 'lowerLetter' | 'upperLetter' | 'lowerRoman' | 'upperRoman';
128
+ text?: string;
86
129
  };
130
+ listItemContinuationLevel?: number;
87
131
  /**
88
132
  * Pre-validated direct `<w:pPr>` properties. Same-document copy carries the
89
133
  * source paragraph's materialized properties for fidelity; external HTML
@@ -99,6 +143,16 @@ export interface SDPasteParagraphBlock {
99
143
  * paste anchor's paragraph, independent of whether they carry formatting.
100
144
  */
101
145
  complete?: boolean;
146
+ /** Transient conversion identity used to map mutation effects back to source nodes. */
147
+ sourcePath?: readonly (string | number)[];
148
+ }
149
+ export interface SDPasteHeadingBlock extends Omit<SDPasteParagraphBlock, 'kind' | 'semanticStyleRole'> {
150
+ kind: 'heading';
151
+ level: 1 | 2 | 3 | 4 | 5 | 6;
152
+ }
153
+ export interface SDPasteHorizontalRuleBlock {
154
+ kind: 'horizontalRule';
155
+ sourcePath?: readonly (string | number)[];
102
156
  }
103
157
  export interface SDPasteTableCell {
104
158
  /** Cell content: paragraph blocks rendered through the shared paste renderer. */
@@ -114,9 +168,12 @@ export interface SDPasteTableCell {
114
168
  bottomPt?: number;
115
169
  leftPt?: number;
116
170
  };
171
+ sourcePath?: readonly (string | number)[];
117
172
  }
118
173
  export interface SDPasteTableRow {
119
174
  cells: readonly SDPasteTableCell[];
175
+ header?: boolean;
176
+ sourcePath?: readonly (string | number)[];
120
177
  }
121
178
  /**
122
179
  * Table paste block: rendered as `w:tbl` with V1-parity defaults. Cell
@@ -126,8 +183,9 @@ export interface SDPasteTableRow {
126
183
  export interface SDPasteTableBlock {
127
184
  kind: 'table';
128
185
  rows: readonly SDPasteTableRow[];
186
+ sourcePath?: readonly (string | number)[];
129
187
  }
130
- export type SDPasteBlock = SDPasteParagraphBlock | SDPasteTableBlock;
188
+ export type SDPasteBlock = SDPasteParagraphBlock | SDPasteHeadingBlock | SDPasteHorizontalRuleBlock | SDPasteTableBlock;
131
189
  export interface SDPasteAsset {
132
190
  id: string;
133
191
  mimeType: 'image/png' | 'image/jpeg';
@@ -146,12 +204,17 @@ export interface SDPasteFragment {
146
204
  assets?: readonly SDPasteAsset[];
147
205
  diagnostics?: readonly ClipboardInsertDiagnostic[];
148
206
  }
149
- export interface ClipboardInsertDiagnostic {
150
- severity: 'error' | 'warning' | 'info';
207
+ export interface ClipboardInsertDiagnostic extends SDDiagnostic {
151
208
  reason: SDPasteUnsupportedReason;
152
- message: string;
153
209
  sourceKind?: ClipboardSourceKind;
154
- path?: Array<string | number>;
210
+ /** Fatal rich-conversion attempt retained when a plain-text fallback is selected. */
211
+ cause?: SDConversionDiagnostic;
212
+ }
213
+ /** HTML conversion diagnostic with the clipboard negotiation envelope retained. */
214
+ export interface ClipboardHtmlConversionDiagnostic extends SDConversionDiagnostic {
215
+ reason: SDPasteUnsupportedReason;
216
+ sourceKind: 'html';
217
+ cause?: SDConversionDiagnostic;
155
218
  }
156
219
  export interface ClipboardInsertPlanSummary {
157
220
  sourceKind: ClipboardSourceKind;
@@ -0,0 +1,126 @@
1
+ import { BlockNodeAddress, BlockNodeType } from './base.js';
2
+ import { Range, SelectionTarget, TextTarget } from './address.js';
3
+ import { StoryLocator } from './story.types.js';
4
+ import { SDDiagnostic } from './sd-contract.js';
5
+ export declare const SD_PROJECTION_FORMATS: readonly ["html", "markdown"];
6
+ export type SDProjectionFormat = (typeof SD_PROJECTION_FORMATS)[number];
7
+ export declare const SD_PROJECTION_REVIEW_MODES: readonly ["final", "original", "redline"];
8
+ export type SDProjectionReviewMode = (typeof SD_PROJECTION_REVIEW_MODES)[number];
9
+ export declare const SD_PROJECTION_STATUSES: readonly ["success", "warning", "failed"];
10
+ export type SDProjectionStatus = (typeof SD_PROJECTION_STATUSES)[number];
11
+ export declare const SD_PROJECTION_DIAGNOSTIC_CODES: readonly ["projection-normalized-construct", "projection-downgraded-construct", "projection-unsupported-construct", "projection-placeholder-emitted", "projection-annotation-omitted", "projection-numbering-unresolved", "projection-source-coverage-incomplete", "projection-scope-unsupported", "projection-limit-exceeded", "projection-revision-changed", "projection-malformed-source"];
12
+ export type SDProjectionDiagnosticCode = (typeof SD_PROJECTION_DIAGNOSTIC_CODES)[number];
13
+ export declare const SD_PROJECTION_CONSTRUCTS: readonly ["document", "source", "text", "paragraph", "emptyParagraph", "softBreak", "lineBreak", "heading", "bold", "italic", "underline", "strike", "hyperlink", "list", "listLabel", "table", "tableHeader", "tableRow", "tableCell", "colSpan", "rowSpan", "horizontalRule", "inlineCode", "codeBlock", "image", "field", "contentControl", "math", "drawing", "embeddedObject", "sectionBreak", "pageBreak", "columnBreak", "trackedChange", "comment", "scope", "placeholder"];
14
+ export type SDProjectionConstruct = (typeof SD_PROJECTION_CONSTRUCTS)[number];
15
+ export declare const SD_PROJECTION_DISPOSITIONS: readonly ["preserved", "normalized", "downgraded", "placeholder", "omitted", "rejected"];
16
+ export type SDProjectionDisposition = (typeof SD_PROJECTION_DISPOSITIONS)[number];
17
+ export type SDProjectionScope = BlockNodeAddress | SelectionTarget;
18
+ export interface SDProjectionReadInput {
19
+ in?: StoryLocator;
20
+ reviewMode?: SDProjectionReviewMode;
21
+ scope?: SDProjectionScope;
22
+ }
23
+ export interface ProjectHtmlInput extends SDProjectionReadInput {
24
+ includeSourceMap?: boolean;
25
+ }
26
+ export interface ProjectMarkdownInput extends SDProjectionReadInput {
27
+ includeSourceMap?: boolean;
28
+ }
29
+ export type SDResolvedProjectionScope = {
30
+ kind: 'story';
31
+ } | {
32
+ kind: 'block';
33
+ target: BlockNodeAddress;
34
+ } | {
35
+ kind: 'range';
36
+ target: SelectionTarget & {
37
+ coordinateSpace: 'tracked';
38
+ };
39
+ };
40
+ export type SDProjectionBlockMapEntry = {
41
+ nodeType: BlockNodeType;
42
+ output: Range;
43
+ parentBlockId?: string;
44
+ changeIds?: string[];
45
+ commentIds?: string[];
46
+ } & ({
47
+ identity: 'public';
48
+ blockId: string;
49
+ } | {
50
+ identity: 'unavailable';
51
+ identityUnavailableReason: 'positionDerivedFallback';
52
+ blockId?: never;
53
+ });
54
+ export type SDProjectionDiagnostic = Omit<SDDiagnostic, 'code' | 'construct' | 'disposition' | 'lossy' | 'source'> & {
55
+ code: SDProjectionDiagnosticCode;
56
+ construct: SDProjectionConstruct;
57
+ disposition: SDProjectionDisposition;
58
+ lossy: boolean;
59
+ source: {
60
+ story: StoryLocator;
61
+ blockId?: string;
62
+ range?: Range;
63
+ coordinateSpace?: 'tracked';
64
+ changeIds?: string[];
65
+ commentIds?: string[];
66
+ };
67
+ output?: {
68
+ format: SDProjectionFormat;
69
+ range?: Range;
70
+ };
71
+ };
72
+ export interface SDProjectionSourceMap {
73
+ version: 'sd-projection-source-map/1';
74
+ outputCoordinateSpace: 'utf16';
75
+ sourceCoordinateSpace: 'tracked';
76
+ entries: SDProjectionSourceMapEntry[];
77
+ }
78
+ export type SDProjectionSourceMapEntry = {
79
+ kind: 'text';
80
+ output: Range;
81
+ source: TextTarget & {
82
+ coordinateSpace: 'tracked';
83
+ };
84
+ blockId: string;
85
+ changeIds?: string[];
86
+ commentIds?: string[];
87
+ } | ({
88
+ kind: 'synthetic';
89
+ output: Range;
90
+ role: 'listLabel' | 'placeholder';
91
+ changeIds?: string[];
92
+ commentIds?: string[];
93
+ } & ({
94
+ identity: 'public';
95
+ blockId: string;
96
+ } | {
97
+ identity: 'unavailable';
98
+ identityUnavailableReason: 'positionDerivedFallback';
99
+ blockId?: never;
100
+ }));
101
+ export interface SDProjectionAnnotation {
102
+ kind: 'trackedChange' | 'comment';
103
+ id: string;
104
+ blockIds: string[];
105
+ sourceTarget?: TextTarget;
106
+ outputRanges: Range[];
107
+ status: 'emitted' | 'partiallyEmitted' | 'omitted';
108
+ omittedReason?: 'reviewMode' | 'unsupported';
109
+ side?: 'inserted' | 'deleted' | 'source' | 'destination' | 'formatting';
110
+ }
111
+ export interface SDContentProjectionResult<TFormat extends SDProjectionFormat = SDProjectionFormat> {
112
+ format: TFormat;
113
+ content: string;
114
+ status: SDProjectionStatus;
115
+ reviewMode: SDProjectionReviewMode;
116
+ evaluatedRevision: string;
117
+ story: StoryLocator;
118
+ scope: SDResolvedProjectionScope;
119
+ lossy: boolean;
120
+ diagnostics: SDProjectionDiagnostic[];
121
+ blocks: SDProjectionBlockMapEntry[];
122
+ annotations: SDProjectionAnnotation[];
123
+ sourceMap?: SDProjectionSourceMap;
124
+ }
125
+ export declare function deriveSDProjectionStatus(diagnostics: readonly Pick<SDProjectionDiagnostic, 'severity' | 'lossy'>[]): SDProjectionStatus;
126
+ export declare function validateSDProjectionSourceMap(sourceMap: SDProjectionSourceMap, contentLength: number): boolean;
@@ -16,7 +16,7 @@ export interface SDDocument {
16
16
  annotations?: SDAnnotations;
17
17
  metadata?: SDDocumentMeta;
18
18
  }
19
- export declare const SD_CONTENT_NODE_KINDS: readonly ["paragraph", "heading", "list", "table", "toc", "index", "bibliography", "tableOfAuthorities", "break", "sectionBreak", "sectPr", "image", "drawing", "sdt", "customXml", "altChunk", "math", "field"];
19
+ export declare const SD_CONTENT_NODE_KINDS: readonly ["paragraph", "heading", "list", "table", "toc", "index", "bibliography", "tableOfAuthorities", "break", "horizontalRule", "sectionBreak", "sectPr", "image", "drawing", "sdt", "customXml", "altChunk", "math", "field"];
20
20
  export type SDContentNodeKind = (typeof SD_CONTENT_NODE_KINDS)[number];
21
21
  export declare const SD_INLINE_NODE_KINDS: readonly ["run", "hyperlink", "crossRef", "indexEntry", "sequenceField", "citation", "authorityEntry", "tocEntry", "image", "drawing", "sdt", "customXml", "math", "field", "tab", "lineBreak", "footnoteRef", "endnoteRef"];
22
22
  export type SDInlineNodeKind = (typeof SD_INLINE_NODE_KINDS)[number];
@@ -23,8 +23,10 @@ export * from './discovery.js';
23
23
  export * from './blocks.types.js';
24
24
  export * from './toc.types.js';
25
25
  export * from './fragment.js';
26
+ export * from './sd-contract.js';
26
27
  export * from './placement.js';
27
28
  export * from './adapter-result.js';
28
29
  export * from './structural-input.js';
29
30
  export * from './story.types.js';
30
31
  export * from './clipboard.js';
32
+ export * from './content-projection.js';
@@ -5,6 +5,7 @@ import { InsertStylePolicy, StylePolicy } from './style-policy.types.js';
5
5
  import { InlineRunPatch } from '../format/inline-run-patch.js';
6
6
  import { SDFragment } from './fragment.js';
7
7
  import { Placement, NestingPolicy } from './placement.js';
8
+ import { AffectedRef } from './receipt.js';
8
9
  import { ChangeMode } from '../write/write.js';
9
10
  import { StoryLocator } from './story.types.js';
10
11
  export type SelectWhere = {
@@ -229,6 +230,8 @@ export type PlanReceipt = {
229
230
  };
230
231
  steps: StepOutcome[];
231
232
  trackedChanges?: TrackedChangeAddress[];
233
+ /** Caller-held refs that no longer resolve after the plan. */
234
+ invalidatedRefs?: AffectedRef[];
232
235
  timing: {
233
236
  totalMs: number;
234
237
  };
@@ -68,6 +68,8 @@ export interface TextRangeShift {
68
68
  /** A visible text span created by a mutation (e.g. `doc.insert`). */
69
69
  export interface TextMutationEffect {
70
70
  kind: 'insertedText';
71
+ /** Transient source fragment path that produced this created span. */
72
+ sourcePath?: readonly (string | number)[];
71
73
  /**
72
74
  * Block-absolute address of the created span. `range.start` is the base
73
75
  * offset within the target block (nonzero when text was appended into a
@@ -82,6 +84,8 @@ export interface TextMutationEffect {
82
84
  /** A block created by a structural mutation (e.g. paragraph/heading insert). */
83
85
  export interface BlockMutationEffect {
84
86
  kind: 'insertedBlock';
87
+ /** Transient source fragment path that produced this created block. */
88
+ sourcePath?: readonly (string | number)[];
85
89
  /** Address of the created block. */
86
90
  target: BlockNodeAddress;
87
91
  /**
@@ -1,13 +1,14 @@
1
1
  import { BlockNodeAddress } from './base.js';
2
2
  import { SelectionTarget, TextAddress } from './address.js';
3
- import { ReceiptEffects, TextMutationRange } from './receipt.js';
3
+ import { ReceiptEffects, ReceiptSuccess, TextMutationRange } from './receipt.js';
4
+ import { BodyStoryLocator } from './story.types.js';
4
5
  export type SDErrorCode = 'INVALID_PAYLOAD' | 'INVALID_TARGET' | 'TARGET_NOT_FOUND' | 'ADDRESS_STALE' | 'PRECONDITION_FAILED' | 'REVISION_MISMATCH' | 'INVALID_CONTEXT' | 'INVALID_NESTING' | 'INVALID_PLACEMENT' | 'DUPLICATE_ID' | 'CAPABILITY_UNSUPPORTED' | 'RAW_MODE_REQUIRED' | 'PRESERVE_ONLY_VIOLATION' | 'NO_OP' | 'UNSUPPORTED_ENVIRONMENT' | 'INTERNAL_ERROR';
5
6
  export interface SDError {
6
7
  code: SDErrorCode;
7
8
  message: string;
8
9
  path?: Array<string | number>;
9
10
  /** The target that caused the error, when available. */
10
- target?: BlockNodeAddress | TextAddress | SelectionTarget;
11
+ target?: BlockNodeAddress | TextAddress | SelectionTarget | BodyStoryLocator;
11
12
  details?: Record<string, unknown>;
12
13
  }
13
14
  /**
@@ -15,8 +16,9 @@ export interface SDError {
15
16
  *
16
17
  * - `TextAddress` (`kind: 'text'`): text-level insert/replace with block-relative offsets.
17
18
  * - `BlockNodeAddress` (`kind: 'block'`): structural insert/replace targeting a whole block.
19
+ * - `BodyStoryLocator` (`kind: 'story'`): explicit complete-main-body replacement.
18
20
  */
19
- export type MutationResolutionTarget = TextAddress | BlockNodeAddress;
21
+ export type MutationResolutionTarget = TextAddress | BlockNodeAddress | BodyStoryLocator;
20
22
  export interface SDMutationReceipt {
21
23
  success: boolean;
22
24
  failure?: SDError;
@@ -24,6 +26,16 @@ export interface SDMutationReceipt {
24
26
  before: string;
25
27
  after: string;
26
28
  };
29
+ id?: ReceiptSuccess['id'];
30
+ inserted?: ReceiptSuccess['inserted'];
31
+ updated?: ReceiptSuccess['updated'];
32
+ removed?: ReceiptSuccess['removed'];
33
+ invalidatedRefs?: ReceiptSuccess['invalidatedRefs'];
34
+ remappedRefs?: ReceiptSuccess['remappedRefs'];
35
+ affectedStories?: ReceiptSuccess['affectedStories'];
36
+ textRangeShifts?: ReceiptSuccess['textRangeShifts'];
37
+ txId?: ReceiptSuccess['txId'];
38
+ warnings?: ReceiptSuccess['warnings'];
27
39
  resolution?: {
28
40
  target: MutationResolutionTarget;
29
41
  /** Engine-resolved absolute document range for the effective target. */
@@ -40,15 +52,59 @@ export interface SDMutationReceipt {
40
52
  * read it here instead. See {@link ReceiptEffects}.
41
53
  */
42
54
  effects?: ReceiptEffects;
55
+ conversion?: SDMutationConversionReport;
56
+ }
57
+ export declare const SD_CONVERSION_FORMATS: readonly ["html", "markdown"];
58
+ export type SDConversionFormat = (typeof SD_CONVERSION_FORMATS)[number];
59
+ export declare const SD_CONVERSION_DIAGNOSTIC_CODES: readonly ["conversion-normalized-construct", "conversion-unsupported-construct", "conversion-dropped-style", "conversion-unsafe-content", "conversion-unsafe-url", "conversion-source-limit-exceeded", "conversion-depth-limit-exceeded", "conversion-malformed-input", "conversion-empty-result"];
60
+ export type SDConversionDiagnosticCode = (typeof SD_CONVERSION_DIAGNOSTIC_CODES)[number];
61
+ /** Stable feature identifiers used to classify conversion diagnostics. */
62
+ export declare const SD_CONVERSION_CONSTRUCTS: readonly ["document", "source", "text", "paragraph", "emptyParagraph", "softBreak", "lineBreak", "heading", "bold", "italic", "underline", "strike", "hyperlink", "list", "table", "tableHeader", "colSpan", "rowSpan", "horizontalRule", "inlineCode", "codeBlock", "blockquote", "taskList", "image", "footnote", "rawHtml", "unknownWrapper", "script", "style", "eventHandler"];
63
+ export type SDConversionConstruct = (typeof SD_CONVERSION_CONSTRUCTS)[number];
64
+ export declare const SD_CONVERSION_DISPOSITIONS: readonly ["preserved", "normalized", "downgraded", "dropped", "rejected"];
65
+ export type SDConversionDisposition = (typeof SD_CONVERSION_DISPOSITIONS)[number];
66
+ /** UTF-16 offsets are start-inclusive and end-exclusive. */
67
+ export interface SDConversionSourceRange {
68
+ startOffset: number;
69
+ endOffset: number;
70
+ startLine?: number;
71
+ startColumn?: number;
72
+ endLine?: number;
73
+ endColumn?: number;
74
+ }
75
+ export interface SDConversionSource {
76
+ format: SDConversionFormat;
77
+ range?: SDConversionSourceRange;
43
78
  }
44
79
  export interface SDDiagnostic {
45
80
  code: string;
46
81
  severity: 'error' | 'warning' | 'info';
47
82
  message: string;
48
83
  path?: Array<string | number>;
84
+ construct?: SDConversionConstruct;
85
+ disposition?: SDConversionDisposition;
86
+ lossy?: boolean;
87
+ source?: SDConversionSource;
88
+ }
89
+ /** Diagnostic shape guaranteed by the canonical HTML/Markdown converters. */
90
+ export interface SDConversionDiagnostic extends SDDiagnostic {
91
+ code: SDConversionDiagnosticCode;
92
+ construct: SDConversionConstruct;
93
+ disposition: SDConversionDisposition;
94
+ lossy: boolean;
95
+ source: SDConversionSource;
49
96
  }
50
- export interface SDMarkdownToFragmentResult {
97
+ export interface SDMutationConversionReport {
98
+ format: SDConversionFormat;
99
+ lossy: boolean;
100
+ diagnostics: SDConversionDiagnostic[];
101
+ }
102
+ export interface SDContentToFragmentResult<TDiagnostic extends SDDiagnostic = SDDiagnostic> {
51
103
  fragment: import('./fragment.js').SDFragment;
52
104
  lossy: boolean;
53
- diagnostics: SDDiagnostic[];
105
+ diagnostics: TDiagnostic[];
106
+ }
107
+ export type SDHtmlToFragmentResult = SDContentToFragmentResult<SDConversionDiagnostic>;
108
+ /** Existing Markdown adapters may continue returning base diagnostics. */
109
+ export interface SDMarkdownToFragmentResult extends SDContentToFragmentResult<SDDiagnostic> {
54
110
  }
@@ -74,6 +74,8 @@ export interface SDTableCell {
74
74
  props?: SDCellProps;
75
75
  colSpan?: number;
76
76
  rowSpan?: number;
77
+ /** Marks a semantic table header cell. */
78
+ header?: boolean;
77
79
  content: SDContentNode[];
78
80
  }
79
81
  export interface SDTable extends SDNodeBase {
@@ -164,6 +166,12 @@ export interface SDBreak extends SDNodeBase {
164
166
  type: 'page' | 'column';
165
167
  };
166
168
  }
169
+ /** A semantic horizontal rule; the destination chooses its durable representation. */
170
+ export interface SDHorizontalRule {
171
+ id?: string;
172
+ kind: 'horizontalRule';
173
+ horizontalRule: Record<string, never>;
174
+ }
167
175
  export interface SDSectionBreak extends SDNodeBase {
168
176
  kind: 'sectionBreak';
169
177
  sectionBreak: {
@@ -371,5 +379,5 @@ export interface SDExtInlineNode extends SDNodeBase {
371
379
  kind: `ext.${string}`;
372
380
  [key: string]: unknown;
373
381
  }
374
- export type SDContentNode = SDParagraph | SDHeading | SDList | SDTable | SDToc | SDDocumentIndex | SDBibliography | SDTableOfAuthorities | SDBreak | SDSectionBreak | SDSectPr | SDImage | SDDrawing | SDSdt | SDCustomXml | SDAltChunk | SDMath | SDField | SDExtContentNode;
382
+ export type SDContentNode = SDParagraph | SDHeading | SDList | SDTable | SDToc | SDDocumentIndex | SDBibliography | SDTableOfAuthorities | SDBreak | SDHorizontalRule | SDSectionBreak | SDSectPr | SDImage | SDDrawing | SDSdt | SDCustomXml | SDAltChunk | SDMath | SDField | SDExtContentNode;
375
383
  export type SDInlineNode = SDRun | SDHyperlink | SDCrossRef | SDIndexEntry | SDSequenceField | SDCitation | SDAuthorityEntry | SDTocEntry | SDImage | SDDrawing | SDSdt | SDCustomXml | SDMath | SDField | SDTab | SDLineBreak | SDFootnoteRef | SDEndnoteRef | SDExtInlineNode;
@@ -2,7 +2,7 @@ import { BlockNodeAddress } from './base.js';
2
2
  import { SelectionTarget } from './address.js';
3
3
  import { SDFragment } from './fragment.js';
4
4
  import { Placement, NestingPolicy } from './placement.js';
5
- import { StoryLocator } from './story.types.js';
5
+ import { BodyStoryLocator, StoryLocator } from './story.types.js';
6
6
  /** Structural shape for the insert operation. */
7
7
  export interface SDInsertInput {
8
8
  /** Optional insertion target. When omitted, inserts at the end of the document. */
@@ -27,14 +27,29 @@ type StructuralReplaceLocator = {
27
27
  ref: string;
28
28
  /** Target to replace. BlockNodeAddress replaces the entire block; SelectionTarget replaces a contiguous selection. */
29
29
  target?: undefined;
30
+ } | {
31
+ /** Replace the complete main body while preserving the destination DOCX package. */
32
+ target: BodyStoryLocator;
33
+ ref?: undefined;
30
34
  };
31
- /** Structural shape for the replace operation. */
32
- export type SDReplaceInput = StructuralReplaceLocator & {
35
+ type StructuralReplaceContent = {
33
36
  /** Structural content to replace with. */
34
37
  content: SDFragment;
38
+ };
39
+ /** Structural shape for the replace operation. */
40
+ export type SDReplaceInput = (Exclude<StructuralReplaceLocator, {
41
+ target: BodyStoryLocator;
42
+ }> & StructuralReplaceContent & {
35
43
  /** Target a specific document story (body, header, footer, footnote, endnote). */
36
44
  in?: StoryLocator;
37
45
  /** Nesting policy. Defaults to { tables: 'forbid' }. */
38
46
  nestingPolicy?: NestingPolicy;
47
+ }) | {
48
+ /** Replace the complete main body while preserving the destination DOCX package. */
49
+ target: BodyStoryLocator;
50
+ content: SDFragment;
51
+ ref?: never;
52
+ in?: never;
53
+ nestingPolicy?: never;
39
54
  };
40
55
  export {};
@@ -66,7 +66,7 @@ export interface WriteAdapter {
66
66
  write(request: InsertWriteRequest, options?: MutationOptions): TextMutationReceipt;
67
67
  /** Structured insert for SDFragment or markdown/html content. Returns SDMutationReceipt. */
68
68
  insertStructured(input: InsertInput, options?: MutationOptions): SDMutationReceipt;
69
- /** Structured replace for SDFragment content. Returns SDMutationReceipt. */
69
+ /** Structured replace for SDFragment or markdown/html content. Returns SDMutationReceipt. */
70
70
  replaceStructured(input: ReplaceInput, options?: MutationOptions): SDMutationReceipt;
71
71
  }
72
72
  export declare function normalizeMutationOptions(options?: MutationOptions): MutationOptions;
@@ -3,6 +3,8 @@ import { PageStyles } from './styles.js';
3
3
  import { PositionValidationOptions, PositionValidationSummary } from './pm-position-validation.js';
4
4
  import { DomPainterInput, PageDecorationProvider, PaintSnapshot, PositionMapping, FlowMode } from './renderer.js';
5
5
  import { DomPainterPersistentPageInput } from './persistent-page-surface.js';
6
+ export { createWebFlowPainter, ensureWebFlowStyles, WEB_FLOW_CLASS_NAMES } from './web-flow/index.js';
7
+ export type { WebFlowAppliedPaint, WebFlowDomBinding, WebFlowPaintCommand, WebFlowPaintItem, WebFlowPaintSnapshot, WebFlowPaintTransaction, WebFlowPainterHandle, WebFlowPainterOptions, WebFlowPaintWorkSummary, WebFlowStableDomKey, } from './web-flow/index.js';
6
8
  export { DOM_CLASS_NAMES } from './constants.js';
7
9
  export type { DomClassName } from './constants.js';
8
10
  export { ensureDocumentSurfaceStyles } from './styles.js';
@@ -0,0 +1,3 @@
1
+ export { createWebFlowPainter } from './painter.js';
2
+ export { ensureWebFlowStyles, WEB_FLOW_CLASS_NAMES } from './styles.js';
3
+ export type { WebFlowAppliedPaint, WebFlowDomBinding, WebFlowPaintCommand, WebFlowPaintItem, WebFlowPaintSnapshot, WebFlowPaintTransaction, WebFlowPainterHandle, WebFlowPainterOptions, WebFlowPaintWorkSummary, WebFlowStableDomKey, } from './types.js';
@@ -0,0 +1,2 @@
1
+ import { WebFlowPainterHandle, WebFlowPainterOptions } from './types.js';
2
+ export declare function createWebFlowPainter(mount: HTMLElement, options?: WebFlowPainterOptions): WebFlowPainterHandle;
@@ -0,0 +1,8 @@
1
+ import { FlowBlock } from '../../../../contracts/src/index.js';
2
+ import { WebFlowPaintItem, WebFlowPainterOptions } from './types.js';
3
+ export declare function doesWebFlowBlockProduceDom(block: FlowBlock): boolean;
4
+ export declare function renderWebFlowItem(item: WebFlowPaintItem, doc: Document, options: WebFlowPainterOptions): HTMLElement | null;
5
+ /** Identity-only signature for deciding whether a retained node needs dataset rebasing. */
6
+ export declare function webFlowItemIdentityFingerprint(item: WebFlowPaintItem): string;
7
+ /** Rebase canonical identity datasets without replacing an unchanged retained node. */
8
+ export declare function rebaseWebFlowItemNode(node: HTMLElement, previous: WebFlowPaintItem, next: WebFlowPaintItem): () => void;
@@ -0,0 +1,10 @@
1
+ export declare const WEB_FLOW_CLASS_NAMES: {
2
+ readonly root: "superdoc-web-flow";
3
+ readonly block: "superdoc-web-flow-block";
4
+ readonly paragraph: "superdoc-web-flow-paragraph";
5
+ readonly run: "superdoc-web-flow-run";
6
+ readonly listMarker: "superdoc-web-flow-list-marker";
7
+ readonly table: "superdoc-web-flow-table";
8
+ readonly diagnostic: "superdoc-web-flow-diagnostic";
9
+ };
10
+ export declare function ensureWebFlowStyles(doc: Document): void;
@@ -0,0 +1,77 @@
1
+ import { FlowBlock, LayoutSourceIdentity } from '../../../../contracts/src/index.js';
2
+ /** Opaque adapter-issued identity. The painter never derives this value from DOM or block ids. */
3
+ export type WebFlowStableDomKey = string;
4
+ export interface WebFlowPaintItem {
5
+ readonly stableDomKey: WebFlowStableDomKey;
6
+ readonly renderFingerprint: string;
7
+ readonly block: FlowBlock;
8
+ readonly layoutEpoch?: number;
9
+ readonly layoutIdentities?: readonly LayoutSourceIdentity[];
10
+ readonly editable?: boolean;
11
+ }
12
+ export type WebFlowPaintCommand = {
13
+ readonly kind: 'replace-all';
14
+ readonly epoch: number;
15
+ readonly items: readonly WebFlowPaintItem[];
16
+ } | {
17
+ readonly kind: 'splice';
18
+ readonly expectedBaseEpoch: number;
19
+ readonly epoch: number;
20
+ readonly storyKey: string;
21
+ readonly expectedRemovedKeys: readonly WebFlowStableDomKey[];
22
+ readonly expectedLeftKey: WebFlowStableDomKey | null;
23
+ readonly expectedRightKey: WebFlowStableDomKey | null;
24
+ readonly items: readonly WebFlowPaintItem[];
25
+ /** Identity-only updates for retained nodes downstream of a structural splice. */
26
+ readonly retainedRebases?: readonly WebFlowPaintItem[];
27
+ };
28
+ export interface WebFlowPaintWorkSummary {
29
+ readonly kind: WebFlowPaintCommand['kind'];
30
+ readonly retainedNodes: number;
31
+ readonly createdNodes: number;
32
+ readonly removedNodes: number;
33
+ readonly rebasedNodes: number;
34
+ readonly touchedItems: number;
35
+ }
36
+ export interface WebFlowDomBinding {
37
+ readonly key: WebFlowStableDomKey;
38
+ readonly renderFingerprint: string;
39
+ readonly blockId: string;
40
+ readonly node: HTMLElement;
41
+ }
42
+ export interface WebFlowPaintSnapshot {
43
+ readonly epoch: number | null;
44
+ readonly version: number;
45
+ readonly bindings: readonly WebFlowDomBinding[];
46
+ }
47
+ export interface WebFlowAppliedPaint {
48
+ readonly work: WebFlowPaintWorkSummary;
49
+ /** Bindings directly owned by this command; localized splices never scan the retained root. */
50
+ readonly touchedBindings: readonly WebFlowDomBinding[];
51
+ /** Bindings whose DOM node or retained identity changed in this command. */
52
+ readonly changedBindings: readonly WebFlowDomBinding[];
53
+ }
54
+ export interface WebFlowPaintTransaction {
55
+ readonly command: WebFlowPaintCommand;
56
+ /** Installs the candidate synchronously. The caller must then finalize or roll it back. */
57
+ apply(): WebFlowAppliedPaint;
58
+ /** Publishes the applied state and releases the rollback journal. */
59
+ finalize(): WebFlowAppliedPaint;
60
+ /** Restores the exact pre-apply DOM and retained state. */
61
+ rollback(): void;
62
+ }
63
+ export interface WebFlowPainterHandle {
64
+ prepare(command: WebFlowPaintCommand): WebFlowPaintTransaction;
65
+ snapshot(): WebFlowPaintSnapshot;
66
+ /** Rebuilds the last committed derived DOM after an externally owned mutation. */
67
+ restoreCommittedDomAfterUnownedMutation(): WebFlowPaintSnapshot;
68
+ dispose(): void;
69
+ }
70
+ export interface WebFlowPainterOptions {
71
+ readonly resolvePhysical?: (cssFontFamily: string, face: {
72
+ weight: '400' | '700';
73
+ style: 'normal' | 'italic';
74
+ }) => string;
75
+ /** Fires synchronously when the mutation observer first detects unowned DOM. */
76
+ readonly onUnownedMutation?: (kind: 'text' | 'dom') => void;
77
+ }
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-CwCvqMOa.cjs");
2
+ const require_create_super_doc_ui = require("../chunks/create-super-doc-ui-C44xPZxz.cjs");
3
3
  let react = require("react");
4
4
  //#region src/public/ui/react.ts
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-DCjm-_Xo.es.js";
1
+ import { t as createSuperDocUI } from "../chunks/create-super-doc-ui-BTNVc3UD.es.js";
2
2
  import { createContext, createElement, useCallback, useContext, useEffect, useRef, useState } from "react";
3
3
  //#region src/public/ui/react.ts
4
4
  /**