@stll/docx-core 0.43.1 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{document-CaGfolcU.d.ts → document-BKejiFuk.d.ts} +383 -250
- package/dist/{document-CEMwM5On.js → document-BuoCvTcR.js} +44 -50
- package/dist/docx_kernel_bg.wasm +0 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +202 -53
- package/dist/listItems-bPpOKnLB.js +116 -0
- package/dist/model/document.d.ts +16 -3
- package/dist/model/document.js +1 -1
- package/dist/ops/documentOps.d.ts +1183 -111
- package/dist/ops/documentOps.js +34619 -16484
- package/dist/preservedMarkup-BWpGhchw.d.ts +79 -0
- package/dist/projection.js +77 -78
- package/dist/schema/sequenceChildren.d.ts +1 -1
- package/dist/schema/sequenceChildren.js +1 -1
- package/dist/{sequenceChildren-BEcOm3tR.js → sequenceChildren-ESF-Ei5K.js} +1 -1
- package/dist/{streamingXmlParser-GnKxUuw_.js → streamingXmlParser-BqnCIEZd.js} +288 -156
- package/dist/xml/streamingXmlParser.d.ts +74 -12
- package/dist/xml/streamingXmlParser.js +1 -1
- package/dist/xml/xmlNamespaceContext.d.ts +8 -0
- package/dist/xml/xmlNamespaceContext.js +3 -1
- package/dist/zip/archive.d.ts +1 -1
- package/package.json +3 -3
- package/dist/href-ogmJmncc.js +0 -138
- package/dist/preservedMarkup-9L4lbGnE.d.ts +0 -66
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Bt as HeaderFooter, C as Relationship, Ct as DocumentBody, D as StyleDefinitions, Dn as ParagraphContent, En as Paragraph, Er as TrackedChangeInfo, Jr as AbstractNumbering, Lt as Footnote, On as ParagraphMarkChange, S as MediaFile, Si as TableRowFormatting, Ti as TextFormatting, Un as Run, Vt as HeaderFooterType, Wi as HeadingOutlineLevel, Wn as RunContent, Wt as INSERTION_SEAM_POLICIES, Xn as SectionProperties, Yn as Section, Zn as SectionPropertyChange, _i as TableFormatting, a as DocumentSettings, an as KeptCut, at as BlockContent, br as TableRow, ct as BookmarkEnd, dr as Table, dt as BreakContent, g as ExhaustiveFields, gi as TableCellFormatting, i as Document, ii as NumberingInstance, jn as ParagraphPropertyChange, kt as Endnote, pt as Comment, qn as SdtProperties, ri as NumberingDefinitions, s as DocxPackage, st as BlockSdt, ui as ParagraphFormatting, ur as TabContent } from "../document-BKejiFuk.js";
|
|
2
|
+
import { a as DeepReadonly, n as PreservedChild, o as RecordField } from "../preservedMarkup-BWpGhchw.js";
|
|
2
3
|
import { Result, TaggedErrorClass } from "better-result";
|
|
3
4
|
/** JSON-safe map presence, including an explicitly undefined section map. */
|
|
4
5
|
type SectionMapState = {
|
|
@@ -31,6 +32,22 @@ type SectionViewChange = {
|
|
|
31
32
|
/**
|
|
32
33
|
* The operation schema this module reads and writes.
|
|
33
34
|
*
|
|
35
|
+
* Version 18 adds `comments` and `newCommentIds` to `insertContent`: a
|
|
36
|
+
* pasted copy of a standing comment's anchors takes a fresh comment id and a
|
|
37
|
+
* copy of the thread the paste carries, or is left out without one.
|
|
38
|
+
* Version 17 adds the `containerStart` insertion point: paragraphs or a table
|
|
39
|
+
* before the first block of a block list, whatever kind that block is.
|
|
40
|
+
* Version 16 adds `createdSince` to `restoreCommentState`: a restoration
|
|
41
|
+
* rebased over concurrent comment creations keeps them.
|
|
42
|
+
* Version 15 adds paragraph insertion beside tables and exact empty block
|
|
43
|
+
* replacements. Older envelopes receive an unsupportedSchema refusal; old
|
|
44
|
+
* operation payloads retain their meaning, with no automatic schema rewrite.
|
|
45
|
+
* Version 14 restores section-view topology in story lifecycle inverses.
|
|
46
|
+
* Older envelopes receive an unsupportedSchema refusal.
|
|
47
|
+
* Version 12 adds `setContentControl`, which sets a block-level content
|
|
48
|
+
* control's properties by its id.
|
|
49
|
+
* Version 11 records, as a sequenced format's effect, the run a direct
|
|
50
|
+
* format cut (`setRunProps` effect).
|
|
34
51
|
* Version 9 adds exact, JSON-safe package resource replacement for clipboard imports.
|
|
35
52
|
* Version 8 adds semantic table edits and exact whole-table restoration.
|
|
36
53
|
* Version 7 adds lossless own-undefined operation snapshot presence and
|
|
@@ -53,7 +70,7 @@ type SectionViewChange = {
|
|
|
53
70
|
* and paragraph operations, and the review operations `setParagraphReview`,
|
|
54
71
|
* `replaceInline` and `resolveRevision`.
|
|
55
72
|
*/
|
|
56
|
-
export declare const DOCUMENT_OP_SCHEMA_VERSION =
|
|
73
|
+
export declare const DOCUMENT_OP_SCHEMA_VERSION = 18;
|
|
57
74
|
/**
|
|
58
75
|
* The main story has a fixed address; other editable parts use their stable
|
|
59
76
|
* relationship id or note id. Comment bodies are not yet editable stories.
|
|
@@ -221,6 +238,7 @@ export declare const DOCUMENT_OP_TYPES: Readonly<{
|
|
|
221
238
|
readonly DELETE_NUMBERING_INSTANCE: "deleteNumberingInstance";
|
|
222
239
|
readonly SET_SECTION_ENDPOINT: "setSectionEndpoint";
|
|
223
240
|
readonly SET_PACKAGE_RESOURCES: "setPackageResources";
|
|
241
|
+
readonly SET_CONTENT_CONTROL: "setContentControl";
|
|
224
242
|
}>;
|
|
225
243
|
/** One of {@link DOCUMENT_OP_TYPES}. */
|
|
226
244
|
type DocumentOpType = (typeof DOCUMENT_OP_TYPES)[keyof typeof DOCUMENT_OP_TYPES];
|
|
@@ -230,8 +248,11 @@ type DocumentOpType = (typeof DOCUMENT_OP_TYPES)[keyof typeof DOCUMENT_OP_TYPES]
|
|
|
230
248
|
* `runProps` is either {@link INHERIT_RUN_PROPS} or the exact property set the
|
|
231
249
|
* text carries. When the set differs from the run at the position, the text
|
|
232
250
|
* becomes a run of its own and that run is split around it; `newIds` names
|
|
233
|
-
* the ids of the second half when the run carries some. The
|
|
234
|
-
*
|
|
251
|
+
* the ids of the second half when the run carries some. The text goes in
|
|
252
|
+
* exactly at the gap `at` names: after the zero-width leaves
|
|
253
|
+
* `at.zeroWidthBefore` counts (all of them when it is absent) and before the
|
|
254
|
+
* rest. It joins the run holding the leaf before that gap, else the one
|
|
255
|
+
* holding the leaf after it, whatever kind of leaf either is.
|
|
235
256
|
*
|
|
236
257
|
* With `revision`, the text is a tracked insertion: it is wrapped in an
|
|
237
258
|
* `Insertion` carrying the stamp, cutting the records around it down to a
|
|
@@ -261,6 +282,15 @@ type InsertTextOp = {
|
|
|
261
282
|
* {@link InsertTextOp}. It is refused inside tracked-removed content, and
|
|
262
283
|
* when it holds a comment boundary or reference, which no tracked change can
|
|
263
284
|
* hold.
|
|
285
|
+
*
|
|
286
|
+
* A comment owns one range. A comment anchor of the slice whose kind its
|
|
287
|
+
* comment already has standing in the document is a copy: when `comments`
|
|
288
|
+
* carries that comment's thread and the slice holds the comment's range (or
|
|
289
|
+
* point) whole, the thread's anchors take the ids `newCommentIds` lists and
|
|
290
|
+
* the thread is copied under them; otherwise those anchors are left out. An
|
|
291
|
+
* anchor completing a comment's range goes in as it is, a repeated one is
|
|
292
|
+
* left out, and a carried thread none of whose anchors stand joins the
|
|
293
|
+
* records unless they hold it. A thread it adds belongs to its suggestion.
|
|
264
294
|
*/
|
|
265
295
|
type InsertContentOp = {
|
|
266
296
|
type: typeof DOCUMENT_OP_TYPES.INSERT_CONTENT;
|
|
@@ -269,6 +299,17 @@ type InsertContentOp = {
|
|
|
269
299
|
seamPolicy?: typeof INSERTION_SEAM_POLICIES.MERGE_PLAIN_RUNS;
|
|
270
300
|
newIds?: NewIds;
|
|
271
301
|
revision?: RevisionStamp;
|
|
302
|
+
/**
|
|
303
|
+
* The comment threads the slice carries, as a paste copies them: each
|
|
304
|
+
* root names, by its id, anchors of the slice; replies follow their root.
|
|
305
|
+
* Their paragraphs need ids the package does not use.
|
|
306
|
+
*/
|
|
307
|
+
comments?: readonly Comment[];
|
|
308
|
+
/**
|
|
309
|
+
* Fresh comment ids for the carried threads a paste copies, one per
|
|
310
|
+
* comment of each copied thread, in carried order. Unused ones are left.
|
|
311
|
+
*/
|
|
312
|
+
newCommentIds?: readonly number[];
|
|
272
313
|
};
|
|
273
314
|
/**
|
|
274
315
|
* Remove what lies between two positions of one paragraph: its units and the
|
|
@@ -288,10 +329,12 @@ type InsertContentOp = {
|
|
|
288
329
|
* already inside a deletion or moved away is left as it is; content inside an
|
|
289
330
|
* insertion or a move gets a deletion nested inside that record; everything
|
|
290
331
|
* else is wrapped in a `Deletion` carrying the stamp, an inline content
|
|
291
|
-
* control the range covers whole going in with its content. A
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
332
|
+
* control the range covers whole going in with its content. A record the
|
|
333
|
+
* range covers whole goes in with the comment anchors it holds, and accepting
|
|
334
|
+
* the deletion removes them, as the direct deletion does. A range holding a
|
|
335
|
+
* bare comment boundary or reference is refused, since no tracked change
|
|
336
|
+
* takes one in; `planTrackedDeletion` plans the deletions around them. A
|
|
337
|
+
* tracked deletion joins nothing, so `join` must be absent.
|
|
295
338
|
*/
|
|
296
339
|
type DeleteRangeOp = {
|
|
297
340
|
type: typeof DOCUMENT_OP_TYPES.DELETE_RANGE;
|
|
@@ -317,11 +360,19 @@ type SplitInlineOp = {
|
|
|
317
360
|
* already run across it. Merged records must be alike in everything but
|
|
318
361
|
* their content and ids; the first's ids stand for both. Absent
|
|
319
362
|
* `zeroWidthBefore` is `0`.
|
|
363
|
+
*
|
|
364
|
+
* With `ifAlike`, the join is the seam of an edit rather than a record it
|
|
365
|
+
* restores: records that are not alike, that carry ids the merge would
|
|
366
|
+
* retire, or that a run already runs across, and a position where no
|
|
367
|
+
* records meet are left as they are, and the operation changes nothing. Typing joins its run to alike runs this
|
|
368
|
+
* way, so the join still applies, or keeps out, where a concurrent edit has
|
|
369
|
+
* changed the records beside it.
|
|
320
370
|
*/
|
|
321
371
|
type JoinInlineOp = {
|
|
322
372
|
type: typeof DOCUMENT_OP_TYPES.JOIN_INLINE;
|
|
323
373
|
at: TextPosition;
|
|
324
374
|
depth: number;
|
|
375
|
+
ifAlike?: true;
|
|
325
376
|
};
|
|
326
377
|
/** Whether a tracked run patch appends an independently rejectable review. */
|
|
327
378
|
export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
|
|
@@ -339,6 +390,9 @@ export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
|
|
|
339
390
|
* levels once the patch is applied, as {@link JoinInlineOp} does; the inverse
|
|
340
391
|
* of a patch that cut runs uses them.
|
|
341
392
|
*
|
|
393
|
+
* Under `propertyReview: "append"`, a run patched back to the formatting its
|
|
394
|
+
* pending change started from keeps no pending change.
|
|
395
|
+
*
|
|
342
396
|
* With `revision`, every run the patch changes records a tracked property
|
|
343
397
|
* change (`w:rPrChange`) whose previous formatting is the run's own property
|
|
344
398
|
* set before the patch. A run already carrying one keeps it, and with it the
|
|
@@ -346,6 +400,8 @@ export declare const PROPERTY_REVIEW_POLICIES: Readonly<{
|
|
|
346
400
|
* and `joinEnd` must be absent.
|
|
347
401
|
* `propertyReview: "append"` coalesces an editor action into one pending review.
|
|
348
402
|
* It retains the first baseline and records the latest formatter's metadata.
|
|
403
|
+
* A suggestion's patch of a run whose pending change is not that suggestion's
|
|
404
|
+
* is refused: rejecting the suggestion would discard the other change too.
|
|
349
405
|
*/
|
|
350
406
|
type SetRunPropsOp = {
|
|
351
407
|
type: typeof DOCUMENT_OP_TYPES.SET_RUN_PROPS;
|
|
@@ -486,7 +542,11 @@ type BlockInsertionPoint = {
|
|
|
486
542
|
blockId: string;
|
|
487
543
|
};
|
|
488
544
|
/**
|
|
489
|
-
* Insert paragraphs beside an existing paragraph,
|
|
545
|
+
* Insert paragraphs beside an existing paragraph or table, or at the start of
|
|
546
|
+
* a block list, with pre-minted ids. A table is addressed by a paragraph of
|
|
547
|
+
* its own, and a list by a paragraph it holds, as in TableInsertionPoint.
|
|
548
|
+
* Tracked table-side insertion refuses an earlier pending first-paragraph
|
|
549
|
+
* source owner in the same containing block list.
|
|
490
550
|
* Section-bearing paragraphs are refused. With `revision`, each inserted
|
|
491
551
|
* paragraph receives an inserted mark and its content an insertion wrapper.
|
|
492
552
|
* A tracked insertion after a paragraph no paragraph follows marks the
|
|
@@ -499,7 +559,7 @@ type BlockInsertionPoint = {
|
|
|
499
559
|
type InsertBlocksOp = {
|
|
500
560
|
type: typeof DOCUMENT_OP_TYPES.INSERT_BLOCKS;
|
|
501
561
|
story: OpStory;
|
|
502
|
-
at:
|
|
562
|
+
at: TableInsertionPoint;
|
|
503
563
|
blocks: readonly Paragraph[];
|
|
504
564
|
revision?: RevisionStamp;
|
|
505
565
|
/** With `revision`, the insertion is the destination of a move: `w:moveTo`. */
|
|
@@ -529,7 +589,11 @@ type DeleteBlocksOp = {
|
|
|
529
589
|
newIds?: NewIds;
|
|
530
590
|
};
|
|
531
591
|
/**
|
|
532
|
-
* Replace a run of adjacent paragraphs with other paragraphs.
|
|
592
|
+
* Replace a run of adjacent paragraphs with other paragraphs, or remove it.
|
|
593
|
+
* An empty replacement must preserve the containing story/cell invariants;
|
|
594
|
+
* its inverse inserts the exact captured paragraphs at the surviving boundary.
|
|
595
|
+
* Container-final marks and owned empty formatting refuse when that insertion
|
|
596
|
+
* cannot restore the capture exactly.
|
|
533
597
|
*
|
|
534
598
|
* `expected` is the paragraphs as they stand: they are found by `paraId` and
|
|
535
599
|
* compared structurally (without the fields a relayout recomputes), so a
|
|
@@ -738,6 +802,24 @@ type PackageResourceMapChange<Value> = {
|
|
|
738
802
|
next: PackageResourcePresence;
|
|
739
803
|
entries: readonly PackageResourceEntryChange<Value>[];
|
|
740
804
|
};
|
|
805
|
+
/**
|
|
806
|
+
* Set one content control's properties exactly: its value (`w:lastValue`,
|
|
807
|
+
* `w14:checked`, `w:fullDate`), placeholder state and binding. The control is
|
|
808
|
+
* addressed by its `w:sdtPr/w:id`, block-level or inline, in one story.
|
|
809
|
+
* `expected` is what its properties are now and `properties` what they become;
|
|
810
|
+
* the inverse swaps the two. The control's id and type do not change, and its
|
|
811
|
+
* content is edited by the text operations. `blockIds` names the paragraphs
|
|
812
|
+
* the control holds (block-level) or sits in (inline), in document order: the
|
|
813
|
+
* blocks a concurrent change conflicts with.
|
|
814
|
+
*/
|
|
815
|
+
type SetContentControlOp = {
|
|
816
|
+
type: typeof DOCUMENT_OP_TYPES.SET_CONTENT_CONTROL;
|
|
817
|
+
story: OpStory;
|
|
818
|
+
controlId: number;
|
|
819
|
+
blockIds: readonly string[];
|
|
820
|
+
expected: SdtProperties;
|
|
821
|
+
properties: SdtProperties;
|
|
822
|
+
};
|
|
741
823
|
/** Replace merged definitions and change keyed package entries, refusing stale package data. */
|
|
742
824
|
type SetPackageResourcesOp = {
|
|
743
825
|
type: typeof DOCUMENT_OP_TYPES.SET_PACKAGE_RESOURCES;
|
|
@@ -770,15 +852,37 @@ type SetSectionEndpointOp = {
|
|
|
770
852
|
sectionMetadata?: SectionViewState;
|
|
771
853
|
};
|
|
772
854
|
/**
|
|
773
|
-
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
855
|
+
* Where a table goes: beside a paragraph, or beside the innermost table
|
|
856
|
+
* holding the paragraph `blockId` names, in the block list holding that
|
|
857
|
+
* table, touching it, where no paragraph stands on that side to name; or,
|
|
858
|
+
* with `containerStart`, before the first block of the block list (a story,
|
|
859
|
+
* cell, note, text box or block content control) that holds the paragraph
|
|
860
|
+
* `blockId` names directly, whatever kind that first block is: the one place
|
|
861
|
+
* no paragraph or table names when the list starts with a block that holds
|
|
862
|
+
* no paragraph, such as an empty content control. Every container ends with
|
|
863
|
+
* a paragraph, so one is always there to name the list by.
|
|
864
|
+
*/
|
|
865
|
+
type TableInsertionPoint = BlockInsertionPoint | {
|
|
866
|
+
type: "beforeTable";
|
|
867
|
+
blockId: string;
|
|
868
|
+
} | {
|
|
869
|
+
type: "afterTable";
|
|
870
|
+
blockId: string;
|
|
871
|
+
} | {
|
|
872
|
+
type: "containerStart";
|
|
873
|
+
blockId: string;
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* Insert a table before or after a paragraph, or beside a table. Tracking
|
|
877
|
+
* records each row, cell content and cell-ending paragraph mark. At a
|
|
878
|
+
* container's end, `terminal` moves the source content into a new preceding
|
|
879
|
+
* paragraph while retaining the source id and fields on the untracked final
|
|
880
|
+
* paragraph.
|
|
777
881
|
*/
|
|
778
882
|
type InsertTableOp = {
|
|
779
883
|
type: typeof DOCUMENT_OP_TYPES.INSERT_TABLE;
|
|
780
884
|
story: OpStory;
|
|
781
|
-
at:
|
|
885
|
+
at: TableInsertionPoint;
|
|
782
886
|
table: Table;
|
|
783
887
|
revision?: RevisionStamp;
|
|
784
888
|
newIds?: NewIds;
|
|
@@ -846,33 +950,39 @@ type SetSectionPropsOp = {
|
|
|
846
950
|
patch: FormattingPatch<SectionProperties>;
|
|
847
951
|
};
|
|
848
952
|
/** JSON-safe lifecycle deltas: omitted fields are unowned, null restores absence. */
|
|
849
|
-
type
|
|
953
|
+
type StoryPartFields = {
|
|
850
954
|
/** Owned fields whose source explicitly had an undefined own property. */
|
|
851
955
|
undefinedFields?: readonly ({
|
|
852
956
|
target: "body";
|
|
853
957
|
keys: readonly (keyof NonNullable<StoryParts["body"]>)[];
|
|
854
958
|
} | {
|
|
855
959
|
target: "package";
|
|
856
|
-
keys: readonly (keyof Omit<StoryParts, "body" | "sections" | "undefinedFields">)[];
|
|
960
|
+
keys: readonly (keyof Omit<StoryParts, "body" | "sections" | "sectionView" | "undefinedFields">)[];
|
|
857
961
|
} | {
|
|
858
962
|
target: "section";
|
|
859
963
|
index: number;
|
|
860
964
|
keys: readonly (keyof Omit<NonNullable<StoryParts["sections"]>[number], "index">)[];
|
|
861
965
|
})[];
|
|
862
|
-
body?: { [Key in
|
|
863
|
-
/** Section contents remain derived from the body's content and are never duplicated. */
|
|
864
|
-
sections?: readonly {
|
|
865
|
-
index: number;
|
|
866
|
-
properties?: Section["properties"];
|
|
867
|
-
headers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
|
|
868
|
-
footers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
|
|
869
|
-
}[];
|
|
966
|
+
body?: { [Key in Exclude<RecordField<DocumentBody>, "sections">]?: Key extends "content" ? DocumentBody[Key] : Exclude<DocumentBody[Key], undefined> | null; };
|
|
870
967
|
headers?: readonly (readonly [string, HeaderFooter])[] | null;
|
|
871
968
|
footers?: readonly (readonly [string, HeaderFooter])[] | null;
|
|
872
969
|
footnotes?: readonly Footnote[] | null;
|
|
873
970
|
endnotes?: readonly Endnote[] | null;
|
|
874
971
|
settings?: DocumentSettings | null;
|
|
875
972
|
};
|
|
973
|
+
/** Section contents stay derived; a complete view and narrow metadata never overlap. */
|
|
974
|
+
type StoryParts = StoryPartFields & ({
|
|
975
|
+
sectionView?: never;
|
|
976
|
+
sections?: readonly {
|
|
977
|
+
index: number;
|
|
978
|
+
properties?: Section["properties"];
|
|
979
|
+
headers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
|
|
980
|
+
footers?: readonly (readonly [HeaderFooterType, HeaderFooter])[] | null;
|
|
981
|
+
}[];
|
|
982
|
+
} | {
|
|
983
|
+
sectionView: SectionViewState;
|
|
984
|
+
sections?: never;
|
|
985
|
+
});
|
|
876
986
|
/** Exact stale-checked lifecycle inverse; unrelated package parts stay untouched. */
|
|
877
987
|
type RestoreStoryPartsOp = {
|
|
878
988
|
type: typeof DOCUMENT_OP_TYPES.RESTORE_STORY_PARTS;
|
|
@@ -886,11 +996,16 @@ type TableEditTarget = {
|
|
|
886
996
|
revision?: RevisionStamp;
|
|
887
997
|
newIds?: NewIds;
|
|
888
998
|
};
|
|
889
|
-
/**
|
|
999
|
+
/**
|
|
1000
|
+
* Insert `count` adjacent columns (one when absent), each `width` wide,
|
|
1001
|
+
* before column (including the final boundary); fresh ids are in reading
|
|
1002
|
+
* order, row by row. Tracked, the columns share one grid change.
|
|
1003
|
+
*/
|
|
890
1004
|
type InsertColumnOp = TableEditTarget & {
|
|
891
1005
|
type: typeof DOCUMENT_OP_TYPES.INSERT_COLUMN;
|
|
892
1006
|
column: number;
|
|
893
1007
|
width: number;
|
|
1008
|
+
count?: number;
|
|
894
1009
|
newBlockIds: readonly string[];
|
|
895
1010
|
};
|
|
896
1011
|
type DeleteColumnOp = TableEditTarget & {
|
|
@@ -911,7 +1026,10 @@ type SplitCellOp = TableEditTarget & {
|
|
|
911
1026
|
type: typeof DOCUMENT_OP_TYPES.SPLIT_CELL;
|
|
912
1027
|
newBlockIds: readonly string[];
|
|
913
1028
|
};
|
|
914
|
-
/**
|
|
1029
|
+
/**
|
|
1030
|
+
* Resize the existing logical grid without changing its topology. No widths
|
|
1031
|
+
* leaves the grid unmeasured, for a table laid out from its contents.
|
|
1032
|
+
*/
|
|
915
1033
|
type SetTableGridOp = TableEditTarget & {
|
|
916
1034
|
type: typeof DOCUMENT_OP_TYPES.SET_TABLE_GRID;
|
|
917
1035
|
columnWidths: readonly number[];
|
|
@@ -980,6 +1098,27 @@ type DeleteCommentOp = {
|
|
|
980
1098
|
id: number;
|
|
981
1099
|
scope: "thread" | "reply";
|
|
982
1100
|
};
|
|
1101
|
+
/**
|
|
1102
|
+
* A comment range marker standing between blocks rather than in a paragraph,
|
|
1103
|
+
* addressed by the nearest block of its own block list that holds a
|
|
1104
|
+
* paragraph: the nearest such block after it, or before it when none follows.
|
|
1105
|
+
*/
|
|
1106
|
+
type CommentBoundaryAnchor = {
|
|
1107
|
+
story: OpStory;
|
|
1108
|
+
/** That block's first paragraph after the marker, or its last before it. */
|
|
1109
|
+
blockId: string;
|
|
1110
|
+
/** How many block lists that paragraph's own list lies below the marker's. */
|
|
1111
|
+
depth: number;
|
|
1112
|
+
/** Whether the marker stands before or after that block. */
|
|
1113
|
+
side: "before" | "after";
|
|
1114
|
+
/** How many blocks, other markers of the same comments aside, stand between the two. */
|
|
1115
|
+
gap: number;
|
|
1116
|
+
node: Extract<BlockContent, {
|
|
1117
|
+
type: "commentRangeStart";
|
|
1118
|
+
} | {
|
|
1119
|
+
type: "commentRangeEnd";
|
|
1120
|
+
}>;
|
|
1121
|
+
};
|
|
983
1122
|
/** Exact owned comment records and the paragraph fragments containing their anchors. */
|
|
984
1123
|
type CommentState = {
|
|
985
1124
|
relationshipPresence: "absent" | "undefined" | "present";
|
|
@@ -998,6 +1137,12 @@ type CommentState = {
|
|
|
998
1137
|
blockId: string;
|
|
999
1138
|
content: readonly ParagraphContent[];
|
|
1000
1139
|
}[];
|
|
1140
|
+
/**
|
|
1141
|
+
* The owned markers standing between blocks, in document order; absent
|
|
1142
|
+
* when there are none. Each one's addressing paragraph is also one of
|
|
1143
|
+
* `anchors`, so an edit to it conflicts with the restoration.
|
|
1144
|
+
*/
|
|
1145
|
+
boundaries?: readonly CommentBoundaryAnchor[];
|
|
1001
1146
|
};
|
|
1002
1147
|
type RestoreCommentStateOp = {
|
|
1003
1148
|
type: typeof DOCUMENT_OP_TYPES.RESTORE_COMMENT_STATE;
|
|
@@ -1006,10 +1151,17 @@ type RestoreCommentStateOp = {
|
|
|
1006
1151
|
scaffoldIds: NewIds;
|
|
1007
1152
|
expected: CommentState;
|
|
1008
1153
|
state: CommentState;
|
|
1154
|
+
/**
|
|
1155
|
+
* Comments created concurrently since the restoration was captured, in the
|
|
1156
|
+
* order they were created: it applies as if they were absent, then each
|
|
1157
|
+
* takes its place again before the first comment with a greater id, as its
|
|
1158
|
+
* creation does. Absent when there are none.
|
|
1159
|
+
*/
|
|
1160
|
+
createdSince?: readonly number[];
|
|
1009
1161
|
};
|
|
1010
1162
|
type CommentOp = CreateCommentOp | UpdateCommentContentOp | SetCommentResolutionOp | DeleteCommentOp | RestoreCommentStateOp;
|
|
1011
1163
|
/** A schema-version-10 document operation. */
|
|
1012
|
-
type DocumentOp = (CommentOp | CreateHeaderFooterOp | RemoveHeaderFooterOp | AddNoteOp | RemoveNoteOp | SetSectionPropsOp | RestoreStoryPartsOp | DeleteBlocksOp | InsertTableOp | DeleteTableOp | SetContainerBlocksOp | InsertBlocksOp | InsertTextOp | InsertContentOp | DeleteRangeOp | SplitInlineOp | JoinInlineOp | SetRunPropsOp | SetParagraphPropsOp | SplitBlockOp | JoinBlocksOp | ReplaceBlocksOp | SetParagraphReviewOp | ReplaceInlineOp | ResolveRevisionOp | SetRevisionInfoOp | InsertRowOp | DeleteRowOp | SetTableRowsOp | TableEditOp | SetTableOp | CreateNumberingInstanceOp | DeleteNumberingInstanceOp | SetSectionEndpointOp | SetPackageResourcesOp) & {
|
|
1164
|
+
type DocumentOp = (CommentOp | CreateHeaderFooterOp | RemoveHeaderFooterOp | AddNoteOp | RemoveNoteOp | SetSectionPropsOp | RestoreStoryPartsOp | DeleteBlocksOp | InsertTableOp | DeleteTableOp | SetContainerBlocksOp | InsertBlocksOp | InsertTextOp | InsertContentOp | DeleteRangeOp | SplitInlineOp | JoinInlineOp | SetRunPropsOp | SetParagraphPropsOp | SplitBlockOp | JoinBlocksOp | ReplaceBlocksOp | SetParagraphReviewOp | ReplaceInlineOp | ResolveRevisionOp | SetRevisionInfoOp | InsertRowOp | DeleteRowOp | SetTableRowsOp | TableEditOp | SetTableOp | CreateNumberingInstanceOp | DeleteNumberingInstanceOp | SetSectionEndpointOp | SetPackageResourcesOp | SetContentControlOp) & {
|
|
1013
1165
|
/** Own undefined fields recorded by the operation capture boundary. */
|
|
1014
1166
|
undefinedFields?: readonly (readonly string[])[];
|
|
1015
1167
|
};
|
|
@@ -1029,6 +1181,34 @@ type TouchedBlocks = {
|
|
|
1029
1181
|
modified: readonly string[];
|
|
1030
1182
|
inserted: readonly string[];
|
|
1031
1183
|
removed: readonly string[];
|
|
1184
|
+
/**
|
|
1185
|
+
* Removed paragraphs whose content an edit joined into another paragraph,
|
|
1186
|
+
* each with the paragraph that holds it now. A join keeps the second
|
|
1187
|
+
* paragraph's id (a paragraph mark that goes leaves the one after it); a
|
|
1188
|
+
* host holding a removed id re-anchors on its survivor.
|
|
1189
|
+
*/
|
|
1190
|
+
absorbed?: readonly ParagraphAbsorption[];
|
|
1191
|
+
/**
|
|
1192
|
+
* Tracked changes a resolution joined into the alike change they met, the
|
|
1193
|
+
* pieces of one change rejoining where what stood between them went, each
|
|
1194
|
+
* with the change that holds their content now and keeps its id. A host
|
|
1195
|
+
* holding an absorbed revision id decides the survivor instead.
|
|
1196
|
+
*/
|
|
1197
|
+
absorbedRevisions?: readonly RevisionAbsorption[];
|
|
1198
|
+
};
|
|
1199
|
+
/** A tracked change a resolution joined into another, and the one it joined. */
|
|
1200
|
+
type RevisionAbsorption = {
|
|
1201
|
+
/** The id no record carries any more. */
|
|
1202
|
+
absorbed: number;
|
|
1203
|
+
/** The id of the change that holds its content now. */
|
|
1204
|
+
survivor: number;
|
|
1205
|
+
};
|
|
1206
|
+
/** A paragraph an edit joined into another, and the paragraph it joined. */
|
|
1207
|
+
type ParagraphAbsorption = {
|
|
1208
|
+
/** The removed paragraph's id. */
|
|
1209
|
+
absorbed: string;
|
|
1210
|
+
/** The id of the paragraph that holds its content now. */
|
|
1211
|
+
survivor: string;
|
|
1032
1212
|
};
|
|
1033
1213
|
/** What applying operations produced: the document, its inverse, and the blocks it changed. */
|
|
1034
1214
|
type DocumentEdit = {
|
|
@@ -1037,8 +1217,89 @@ type DocumentEdit = {
|
|
|
1037
1217
|
inverse: readonly DocumentOp[];
|
|
1038
1218
|
touched: TouchedBlocks;
|
|
1039
1219
|
};
|
|
1220
|
+
type DocumentEditEffects = Pick<DocumentEdit, "inverse" | "touched">;
|
|
1221
|
+
/** Effects of edits made in turn, with their final document. */
|
|
1222
|
+
export declare const combineEditEffects: (final: Document, edits: readonly DocumentEditEffects[]) => DocumentEdit;
|
|
1040
1223
|
/** Edits made in turn, starting from `document`, as one edit. */
|
|
1041
1224
|
export declare const combineEdits: (document: Document, edits: readonly DocumentEdit[]) => DocumentEdit;
|
|
1225
|
+
/** Every `paraId` of every paragraph in a value, nested ones included, in document order. */
|
|
1226
|
+
export declare const paragraphIdsIn: (value: unknown) => string[];
|
|
1227
|
+
/** Every paragraph id of a package, each story walked once. */
|
|
1228
|
+
export declare const packageParagraphIds: (pkg: DocxPackage) => string[];
|
|
1229
|
+
/**
|
|
1230
|
+
* The key two spellings of one id share. `ST_LongHexNumber` is hex, so
|
|
1231
|
+
* `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
|
|
1232
|
+
* paragraph ids goes through this.
|
|
1233
|
+
*/
|
|
1234
|
+
export declare const idKey: (id: string) => string;
|
|
1235
|
+
/** A paragraph id's spelling for its number. */
|
|
1236
|
+
export declare const formatParaId: (id: number) => string;
|
|
1237
|
+
export declare const ID_LEASE_KINDS: Readonly<{
|
|
1238
|
+
readonly PARAGRAPH: "paragraph";
|
|
1239
|
+
readonly REVISION: "revision";
|
|
1240
|
+
readonly CONTROL: "control";
|
|
1241
|
+
readonly COMMENT: "comment";
|
|
1242
|
+
}>;
|
|
1243
|
+
type IdLeaseKind = (typeof ID_LEASE_KINDS)[keyof typeof ID_LEASE_KINDS];
|
|
1244
|
+
/**
|
|
1245
|
+
* One past the largest id of each kind: a paragraph id stays below
|
|
1246
|
+
* 0x80000000, and `w:id` is a signed 32-bit integer.
|
|
1247
|
+
*/
|
|
1248
|
+
export declare const ID_KIND_LIMITS: Readonly<Record<IdLeaseKind, number>>;
|
|
1249
|
+
/** Ids from `start` up to, not including, `end`. */
|
|
1250
|
+
type IdRange = {
|
|
1251
|
+
readonly start: number;
|
|
1252
|
+
readonly end: number;
|
|
1253
|
+
};
|
|
1254
|
+
/** One leased range of one id kind. */
|
|
1255
|
+
type IdBlock = IdRange & {
|
|
1256
|
+
readonly kind: IdLeaseKind;
|
|
1257
|
+
};
|
|
1258
|
+
/** The ids one author may still mint: disjoint blocks, ascending per kind. */
|
|
1259
|
+
type IdLease = {
|
|
1260
|
+
readonly blocks: readonly IdBlock[];
|
|
1261
|
+
};
|
|
1262
|
+
/** Whether `lease` holds `id` of `kind`. */
|
|
1263
|
+
export declare const idLeaseHolds: (lease: IdLease, kind: IdLeaseKind, id: number) => boolean;
|
|
1264
|
+
/** How many ids of `kind` the lease still holds. */
|
|
1265
|
+
export declare const idLeaseRemaining: (lease: IdLease, kind: IdLeaseKind) => number;
|
|
1266
|
+
/** The ids of each kind a document holds anywhere in its package. */
|
|
1267
|
+
type LeasedIdCensus = Readonly<Record<IdLeaseKind, ReadonlySet<number>>>;
|
|
1268
|
+
/** Every paragraph, revision, content-control and comment id of a document. */
|
|
1269
|
+
export declare const leasedIdCensus: (document: Document) => LeasedIdCensus;
|
|
1270
|
+
/** One id of one kind. */
|
|
1271
|
+
type LeasedId = {
|
|
1272
|
+
readonly kind: IdLeaseKind;
|
|
1273
|
+
readonly id: number;
|
|
1274
|
+
};
|
|
1275
|
+
/** The ids `after` holds that `before` does not, by kind and then by id. */
|
|
1276
|
+
export declare const introducedIds: (before: LeasedIdCensus, after: LeasedIdCensus) => LeasedId[];
|
|
1277
|
+
/** The IDs introduced between package versions, in the same order as the census difference. */
|
|
1278
|
+
export declare const introducedDocumentIds: ({ before, after }: {
|
|
1279
|
+
before: Document;
|
|
1280
|
+
after: Document;
|
|
1281
|
+
}) => LeasedId[];
|
|
1282
|
+
/**
|
|
1283
|
+
* `lease` without any id at or below the highest of `ids` it holds, per kind:
|
|
1284
|
+
* an author mints upward through its lease and never mints an id twice, so an
|
|
1285
|
+
* id it minted and later removed cannot meet another author's restoration of it.
|
|
1286
|
+
*/
|
|
1287
|
+
export declare const trimIdLease: (lease: IdLease, ids: readonly LeasedId[]) => IdLease;
|
|
1288
|
+
type FreshLeasedIdsOptions = {
|
|
1289
|
+
lease: IdLease | undefined;
|
|
1290
|
+
kind: IdLeaseKind;
|
|
1291
|
+
count: number;
|
|
1292
|
+
/** Whether an id is already in use and cannot be minted. */
|
|
1293
|
+
taken: (id: number) => boolean;
|
|
1294
|
+
/** The lowest candidate, 1 by default. */
|
|
1295
|
+
from?: number;
|
|
1296
|
+
};
|
|
1297
|
+
/**
|
|
1298
|
+
* Up to `count` ids of `kind` that `taken` refuses, lowest first, from the
|
|
1299
|
+
* lease, or from the whole space without one. Fewer come back only when the
|
|
1300
|
+
* lease or the space has no more: the caller refuses the edit, never wraps.
|
|
1301
|
+
*/
|
|
1302
|
+
export declare const freshLeasedIds: ({ lease, kind, count, taken, from }: FreshLeasedIdsOptions) => number[];
|
|
1042
1303
|
/** A place between two leaves. */
|
|
1043
1304
|
type Gap = {
|
|
1044
1305
|
offset: number;
|
|
@@ -1094,8 +1355,6 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
|
|
|
1094
1355
|
readonly BLOCK_NOT_FOUND: "blockNotFound";
|
|
1095
1356
|
/** A raw operation is missing required fields or supplies their wrong shape. */
|
|
1096
1357
|
readonly INVALID_OPERATION: "invalidOperation";
|
|
1097
|
-
/** Removing a column would leave a row with no active cells. */
|
|
1098
|
-
readonly TABLE_ROW_EMPTY: "tableRowEmpty";
|
|
1099
1358
|
/** The requested topology edit changes nothing. */
|
|
1100
1359
|
readonly NO_CHANGE: "noChange";
|
|
1101
1360
|
/** Removed content carries anchors or review records that require coordinated resolution. */
|
|
@@ -1123,7 +1382,8 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
|
|
|
1123
1382
|
/**
|
|
1124
1383
|
* The operation would move or remove a section break (joining a paragraph
|
|
1125
1384
|
* that ends a section, replacing paragraphs across or at one); that is a
|
|
1126
|
-
* section operation.
|
|
1385
|
+
* section operation. Or it would put one inside a table cell, where no
|
|
1386
|
+
* section ends.
|
|
1127
1387
|
*/
|
|
1128
1388
|
readonly SECTION_BOUNDARY: "sectionBoundary";
|
|
1129
1389
|
/** Direct text would land inside tracked-deleted or moved-away content. */
|
|
@@ -1157,19 +1417,93 @@ export declare const DOCUMENT_OP_REFUSAL_REASONS: Readonly<{
|
|
|
1157
1417
|
/** A replacement names no paragraph to replace, or none to put in its place. */
|
|
1158
1418
|
readonly EMPTY_BLOCK_LIST: "emptyBlockList";
|
|
1159
1419
|
/**
|
|
1160
|
-
* The operation would
|
|
1161
|
-
*
|
|
1162
|
-
*
|
|
1420
|
+
* The operation would give a tracked split a mark or property change of
|
|
1421
|
+
* its own, or would put a pasted paragraph's review over the review the
|
|
1422
|
+
* destination already carries.
|
|
1163
1423
|
*/
|
|
1164
1424
|
readonly REVISION_CONFLICT: "revisionConflict";
|
|
1425
|
+
/**
|
|
1426
|
+
* The operation cannot preserve an existing table, row, cell or grid
|
|
1427
|
+
* review, or would overwrite one of the same kind. Resolve it before
|
|
1428
|
+
* changing the table.
|
|
1429
|
+
*/
|
|
1430
|
+
readonly PENDING_TABLE_CHANGE: "pendingTableChange";
|
|
1431
|
+
/**
|
|
1432
|
+
* A suggestion would fold into a run's pending property change that is not
|
|
1433
|
+
* its own. A run holds one property change and a suggestion is resolved by
|
|
1434
|
+
* its id: rejecting it would discard the other change with its own.
|
|
1435
|
+
*/
|
|
1436
|
+
readonly PENDING_RUN_PROPERTY_CHANGE: "pendingRunPropertyChange";
|
|
1437
|
+
/**
|
|
1438
|
+
* A suggestion would fold into a paragraph's pending property change that
|
|
1439
|
+
* is not its own, for the same reason as
|
|
1440
|
+
* {@link DOCUMENT_OP_REFUSAL_REASONS.PENDING_RUN_PROPERTY_CHANGE}; or a
|
|
1441
|
+
* tracked insertion after a container's final paragraph would take over
|
|
1442
|
+
* the mark of one whose properties carry a pending change.
|
|
1443
|
+
*/
|
|
1444
|
+
readonly PENDING_PARAGRAPH_PROPERTY_CHANGE: "pendingParagraphPropertyChange";
|
|
1445
|
+
/**
|
|
1446
|
+
* A tracked join would run a paragraph, through one whose own mark is
|
|
1447
|
+
* already going, into the table after it while that table's first row or
|
|
1448
|
+
* cell has a pending insertion and cannot receive what runs in.
|
|
1449
|
+
*/
|
|
1450
|
+
readonly JOIN_INTO_PENDING_TABLE: "joinIntoPendingTable";
|
|
1165
1451
|
/** The operation would put a mark on a paragraph that ends its story body or table cell. */
|
|
1166
1452
|
readonly CONTAINER_FINAL_MARK: "containerFinalMark";
|
|
1453
|
+
/**
|
|
1454
|
+
* A paragraph break inside an inline content control: the control lives in
|
|
1455
|
+
* one paragraph, so the break has no form.
|
|
1456
|
+
*/
|
|
1457
|
+
readonly INSIDE_INLINE_CONTROL: "insideInlineControl";
|
|
1167
1458
|
/**
|
|
1168
1459
|
* No tracked change can record the edit, or no resolution op can carry it
|
|
1169
1460
|
* out yet: comment boundaries in a tracked range, the paragraph mark's run
|
|
1170
1461
|
* properties, a join at a section break, a record inside a field.
|
|
1171
1462
|
*/
|
|
1172
1463
|
readonly UNTRACKABLE: "untrackable";
|
|
1464
|
+
/**
|
|
1465
|
+
* A tracked paragraph would take over the mark of a paragraph whose break
|
|
1466
|
+
* is pending deletion or moving away. No placement of that record keeps
|
|
1467
|
+
* both laws: accepting equals the direct edit, and rejecting the insertion
|
|
1468
|
+
* alone gives the original back.
|
|
1469
|
+
*/
|
|
1470
|
+
readonly PENDING_BREAK_TAKEOVER: "pendingBreakTakeover";
|
|
1471
|
+
/**
|
|
1472
|
+
* A tracked operation would record a change of a paragraph mark whose
|
|
1473
|
+
* break is pending deletion (deleted, moving away, or added and then
|
|
1474
|
+
* deleted), which holds one such record: joining or deleting through it,
|
|
1475
|
+
* putting a table or row against it, or, after a container's final
|
|
1476
|
+
* paragraph, taking it over, since the container's new final paragraph
|
|
1477
|
+
* keeps no record a pending change moves to it.
|
|
1478
|
+
*/
|
|
1479
|
+
readonly PENDING_PARAGRAPH_MARK_DELETION: "pendingParagraphMarkDeletion";
|
|
1480
|
+
/**
|
|
1481
|
+
* As {@link DOCUMENT_OP_REFUSAL_REASONS.PENDING_PARAGRAPH_MARK_DELETION},
|
|
1482
|
+
* for a paragraph mark whose break is pending insertion (inserted or moved
|
|
1483
|
+
* here) and not deleted since.
|
|
1484
|
+
*/
|
|
1485
|
+
readonly PENDING_PARAGRAPH_MARK_INSERTION: "pendingParagraphMarkInsertion";
|
|
1486
|
+
/**
|
|
1487
|
+
* A paragraph the operation would edit separately joins the next one
|
|
1488
|
+
* through a mark pending deletion (deleted or moving away): accepting that
|
|
1489
|
+
* deletion gives the joined paragraph the next paragraph's properties, so
|
|
1490
|
+
* the edit would land on another paragraph or merge two named ones.
|
|
1491
|
+
*/
|
|
1492
|
+
readonly PENDING_PARAGRAPH_JOIN: "pendingParagraphJoin";
|
|
1493
|
+
/**
|
|
1494
|
+
* A tracked column insertion in a table whose columns already carry a
|
|
1495
|
+
* pending change. A table records one previous grid (`w:tblGridChange`), so
|
|
1496
|
+
* a second insertion could not be rejected alone: the columns of one change
|
|
1497
|
+
* go in one operation (`InsertColumnOp.count`).
|
|
1498
|
+
*/
|
|
1499
|
+
readonly PENDING_GRID_CHANGE: "pendingGridChange";
|
|
1500
|
+
/**
|
|
1501
|
+
* A suggested link change would leave a piece of a link holding only
|
|
1502
|
+
* bookmark or comment markers, or would copy content that names a record of
|
|
1503
|
+
* its own (preserved run markup, a marker inside a copied text box, or a
|
|
1504
|
+
* note holding a tracked change, comment or bookmark).
|
|
1505
|
+
*/
|
|
1506
|
+
readonly UNRECORDABLE_LINK_SUGGESTION: "unrecordableLinkSuggestion";
|
|
1173
1507
|
/** Seed contract: a main-story paragraph has no `paraId`. */
|
|
1174
1508
|
readonly MISSING_BLOCK_ID: "missingBlockId";
|
|
1175
1509
|
/** Seed contract: two paragraphs in the package carry one id. */
|
|
@@ -1188,7 +1522,21 @@ export declare class DocumentOpRefusal extends DocumentOpRefusalBase<{
|
|
|
1188
1522
|
message: string;
|
|
1189
1523
|
reason: DocumentOpRefusalReason;
|
|
1190
1524
|
opType: DocumentOpType | undefined;
|
|
1525
|
+
/** Paragraph-mark revision that would move text across a standing range boundary. */
|
|
1526
|
+
blockedParagraphMarkRevisionId?: number;
|
|
1191
1527
|
}> {}
|
|
1528
|
+
/**
|
|
1529
|
+
* What a run of a story's blocks adds to the document's comment anchors, as
|
|
1530
|
+
* {@link commentDocumentIssue} reads them: each anchor's kind and id in
|
|
1531
|
+
* document order, those of the run's own blocks, then those of the text
|
|
1532
|
+
* boxes inside them. A range marker between blocks attaches to a paragraph
|
|
1533
|
+
* beside it, which may lie outside the run, so the sequence also marks which
|
|
1534
|
+
* markers wait for the run's first paragraph and which are held past its
|
|
1535
|
+
* last, or that it has no paragraph. Two runs alike here leave the issue as
|
|
1536
|
+
* it was when one replaces the other in the same story, whatever blocks
|
|
1537
|
+
* surround it.
|
|
1538
|
+
*/
|
|
1539
|
+
export declare const commentAnchorSequence: (blocks: readonly BlockContent[]) => string[];
|
|
1192
1540
|
type CommentExhaustionInput = {
|
|
1193
1541
|
type: "document";
|
|
1194
1542
|
document: Document;
|
|
@@ -1198,22 +1546,38 @@ type CommentExhaustionInput = {
|
|
|
1198
1546
|
anchorKind: Comment["anchorKind"];
|
|
1199
1547
|
survivingNonCarrierContent: boolean;
|
|
1200
1548
|
};
|
|
1201
|
-
/** Whether a
|
|
1549
|
+
/** Whether a known range lost its content or a known point lost its anchor. */
|
|
1202
1550
|
export declare const isCommentExhausted: (input: CommentExhaustionInput) => boolean;
|
|
1203
1551
|
/** Comment definitions whose root remains covered or projected, with replies. */
|
|
1204
1552
|
export declare const survivingComments: (document: Document, projectedRootIds?: ReadonlySet<number>) => Comment[];
|
|
1205
1553
|
/** Remove each supplied root and its recursive replies, preserving input order. */
|
|
1206
1554
|
export declare const withoutCommentThreads: (comments: readonly Comment[], removedRootIds: ReadonlySet<number>) => Comment[];
|
|
1555
|
+
/**
|
|
1556
|
+
* Root comments without any owned source anchor. Loaded packages may carry
|
|
1557
|
+
* them; they stay preserved as read-only entries rather than refusing the
|
|
1558
|
+
* document, and no comment operation may create or target one.
|
|
1559
|
+
*/
|
|
1560
|
+
export declare const orphanRootCommentIds: (document: Document) => Set<number>;
|
|
1207
1561
|
/**
|
|
1208
1562
|
* Shared loaded-comment activation contract; legacy parentId revision associations stay explicit.
|
|
1209
1563
|
* `allowedOrphans` names unanchored root comments the caller accepts ("all" for a loaded package).
|
|
1210
1564
|
*/
|
|
1211
1565
|
export declare const commentDocumentIssue: (document: Document, allowedOrphans?: ReadonlySet<number> | "all") => string | undefined;
|
|
1212
|
-
/**
|
|
1213
|
-
|
|
1566
|
+
/**
|
|
1567
|
+
* Allocate from the package's annotation domains without a hidden mutable
|
|
1568
|
+
* counter: one past every annotation id, the lowest free one once the
|
|
1569
|
+
* highest id is taken, or, for an author holding a lease, the lowest leased
|
|
1570
|
+
* comment id no annotation carries.
|
|
1571
|
+
*/
|
|
1572
|
+
export declare const freshCommentId: (document: Document, lease?: IdLease) => Result<number, DocumentOpRefusal>;
|
|
1214
1573
|
/** Reconcile modeled comment and numbering parts with their document relationships. */
|
|
1215
1574
|
export declare const reconcileDocumentPartRelationships: (document: Document) => Document;
|
|
1216
1575
|
type CopyOriginAncestorList = NonNullable<BookmarkEnd["copyOriginAncestors"]>;
|
|
1576
|
+
/**
|
|
1577
|
+
* Whether a copy of `node` carries copy ancestry: true of bookmark and move
|
|
1578
|
+
* range boundaries, false of comment boundaries and anything else.
|
|
1579
|
+
*/
|
|
1580
|
+
export declare const recordsCopyOrigin: (node: InlineNode) => boolean;
|
|
1217
1581
|
export declare const isCopyOriginAncestors: (value: unknown) => value is CopyOriginAncestorList;
|
|
1218
1582
|
export declare const shiftCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, insertedOrdinal: number) => CopyOriginAncestorList | undefined;
|
|
1219
1583
|
export declare const addCopyOriginAncestor: (origins: CopyOriginAncestorList | undefined, addedOrdinal: number) => CopyOriginAncestorList | undefined;
|
|
@@ -1225,15 +1589,154 @@ type RejectedCopyOriginAncestors = {
|
|
|
1225
1589
|
copyOriginAncestors?: CopyOriginAncestorList;
|
|
1226
1590
|
};
|
|
1227
1591
|
export declare const rejectCopyOriginAncestors: (origins: CopyOriginAncestorList | undefined, removedAddedAncestors: number) => RejectedCopyOriginAncestors;
|
|
1592
|
+
/** Tracked insertions, deletions and moves. */
|
|
1593
|
+
type TrackedWrapper = Extract<InlineNode, {
|
|
1594
|
+
type: "insertion" | "deletion" | "moveFrom" | "moveTo";
|
|
1595
|
+
}>;
|
|
1596
|
+
/** The review fields a paragraph states, each only when present. */
|
|
1597
|
+
export declare const reviewFieldsOf: (paragraph: ParagraphReviewFields) => ParagraphReviewFields;
|
|
1598
|
+
/**
|
|
1599
|
+
* The side of a kept marker whose pending change holds a piece of its cut,
|
|
1600
|
+
* as its holders name it: `both` where changes either side hold one. Derived
|
|
1601
|
+
* from {@link KeptCutHolders}; never stored.
|
|
1602
|
+
*/
|
|
1603
|
+
type KeptCutPiece = "before" | "after" | "both";
|
|
1604
|
+
export declare const isKeptCutPiece: (value: unknown) => value is KeptCutPiece;
|
|
1605
|
+
type SeamJoins = NonNullable<TrackedWrapper["resolutionJoins"]>;
|
|
1606
|
+
/**
|
|
1607
|
+
* Kept markers a change's joins name in review history version 1: the
|
|
1608
|
+
* revision they were kept from and how many boundaries they are, nearest
|
|
1609
|
+
* the seam (all of those standing there when no count is given).
|
|
1610
|
+
*/
|
|
1611
|
+
type VersionOneKeptMarkers = {
|
|
1612
|
+
keptFrom: string;
|
|
1613
|
+
keptCount?: number;
|
|
1614
|
+
};
|
|
1615
|
+
/**
|
|
1616
|
+
* What review history version 1 wrote on a change about kept markers: those
|
|
1617
|
+
* its own joins name (`change`), and those each of its deferred seam groups
|
|
1618
|
+
* names, by the group's place in `deferredRemove`.
|
|
1619
|
+
*/
|
|
1620
|
+
type VersionOneKept = {
|
|
1621
|
+
change?: VersionOneKeptMarkers;
|
|
1622
|
+
groups: readonly (VersionOneKeptMarkers | undefined)[];
|
|
1623
|
+
};
|
|
1624
|
+
/** {@link withKeptCutsFromChanges} over a paragraph's content. */
|
|
1625
|
+
export declare const paragraphKeptCutsFromChanges: (content: readonly ParagraphContent[], writtenOnChange: (joins: SeamJoins) => VersionOneKept | undefined, legacyPiece?: LegacyKeptCutPiece) => ParagraphContent[];
|
|
1626
|
+
/**
|
|
1627
|
+
* Whether `cut` is a well-formed kept cut: exactly its fields, kept from a
|
|
1628
|
+
* dated revision, naming the revisions holding its piece if any. The
|
|
1629
|
+
* contract and the review history reader share it.
|
|
1630
|
+
*/
|
|
1631
|
+
export declare const isKeptCut: (cut: unknown) => cut is KeptCut;
|
|
1632
|
+
type LegacyKeptCutPiece = (cut: KeptCut) => KeptCutPiece | undefined;
|
|
1633
|
+
type NoteDeletionOpsOptions = {
|
|
1634
|
+
/** The document before the tracked edit. */
|
|
1635
|
+
before: Document;
|
|
1636
|
+
/** The document the tracked edit left. */
|
|
1637
|
+
after: Document;
|
|
1638
|
+
/** The edit's stamp: the notes whose last live reference it deleted follow it. */
|
|
1639
|
+
stamp: RevisionStamp;
|
|
1640
|
+
/** Ids the note records may take; those `after` holds are passed over. */
|
|
1641
|
+
revisionIds: readonly number[];
|
|
1642
|
+
};
|
|
1643
|
+
/** The operations deleting notes with their references, and the revision ids their records took. */
|
|
1644
|
+
type NoteDeletion = {
|
|
1645
|
+
ops: readonly DocumentOp[];
|
|
1646
|
+
revisions: readonly number[];
|
|
1647
|
+
};
|
|
1648
|
+
/**
|
|
1649
|
+
* The operations deleting the notes whose last live reference, in any
|
|
1650
|
+
* story, a tracked edit deleted: each note's text and paragraph marks,
|
|
1651
|
+
* deleted by the reference deletion's author at its date, as the reference
|
|
1652
|
+
* implementation records it. Rejecting the reference's deletion gives the
|
|
1653
|
+
* note its text back, and accepting it removes the note. A suggestion stays
|
|
1654
|
+
* its author's until it is accepted, so it deletes no note.
|
|
1655
|
+
*
|
|
1656
|
+
* The edit itself leaves the notes alone, so an operation touches only the
|
|
1657
|
+
* paragraphs it names; a compiler emitting the edit appends these.
|
|
1658
|
+
*/
|
|
1659
|
+
export declare const noteDeletionOps: ({ before, after, stamp, revisionIds }: NoteDeletionOpsOptions) => Result<NoteDeletion, DocumentOpRefusal>;
|
|
1228
1660
|
export declare const noteUsesCustomMark: (document: Document, note: Footnote | Endnote) => boolean;
|
|
1661
|
+
type WithParagraphCopiesOptions = {
|
|
1662
|
+
document: Document;
|
|
1663
|
+
story: OpStory;
|
|
1664
|
+
/**
|
|
1665
|
+
* Each paragraph of the story, at any depth or in a text box drawn there,
|
|
1666
|
+
* and the copy that takes its place.
|
|
1667
|
+
*/
|
|
1668
|
+
copies: ReadonlyMap<Paragraph, Paragraph>;
|
|
1669
|
+
};
|
|
1670
|
+
/**
|
|
1671
|
+
* `document` with paragraphs of `story`, at any depth, replaced by copies
|
|
1672
|
+
* that hold the same value under every field, in its section views too. A
|
|
1673
|
+
* copy may differ only in what is kept for it outside its fields, which the
|
|
1674
|
+
* contract never reads, so the result meets the contract when `document` is
|
|
1675
|
+
* known to.
|
|
1676
|
+
*/
|
|
1677
|
+
export declare const withParagraphCopies: ({ document, story, copies }: WithParagraphCopiesOptions) => Document;
|
|
1678
|
+
type WithParagraphRenderingsOptions = {
|
|
1679
|
+
document: Document;
|
|
1680
|
+
story: OpStory;
|
|
1681
|
+
/**
|
|
1682
|
+
* Each paragraph of the story, at any depth or in a text box drawn there,
|
|
1683
|
+
* and its list rendering normalized.
|
|
1684
|
+
*/
|
|
1685
|
+
renderings: ReadonlyMap<Paragraph, Paragraph>;
|
|
1686
|
+
};
|
|
1687
|
+
/**
|
|
1688
|
+
* `document` with paragraphs of `story` replaced by ones whose list rendering
|
|
1689
|
+
* was normalized: each may differ from the paragraph it replaces only in its
|
|
1690
|
+
* list rendering and the formatting fields that rendering derives, which the
|
|
1691
|
+
* contract never reads, so the result meets the contract when `document` is
|
|
1692
|
+
* known to. A rendering depends on where its paragraph stands, so a paragraph
|
|
1693
|
+
* the story holds at more than one place has no one rendering: then the
|
|
1694
|
+
* result is undefined, and the caller replaces the story's blocks by place.
|
|
1695
|
+
*/
|
|
1696
|
+
export declare const withParagraphRenderings: ({ document, story, renderings }: WithParagraphRenderingsOptions) => Document | undefined;
|
|
1697
|
+
/** Capture only fields owned by the lifecycle delta; absent values survive JSON as null. */
|
|
1698
|
+
export declare const captureStoryParts: (document: Document, owned: StoryParts) => StoryParts;
|
|
1699
|
+
type StoryPartsOpOptions = {
|
|
1700
|
+
before: Document;
|
|
1701
|
+
after: Document;
|
|
1702
|
+
};
|
|
1703
|
+
/**
|
|
1704
|
+
* The operation that turns `before`'s story parts (body, sections, headers,
|
|
1705
|
+
* footers, notes and settings) into `after`'s, for an edit computed on the
|
|
1706
|
+
* whole document; it is stale-checked against `before`.
|
|
1707
|
+
*/
|
|
1708
|
+
export declare const storyPartsOpOf: ({ before, after }: StoryPartsOpOptions) => RestoreStoryPartsOp;
|
|
1229
1709
|
export declare const sectionPropertiesAt: (document: Document, sectionIndex: number) => SectionProperties | undefined;
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1710
|
+
/**
|
|
1711
|
+
* A text box's `w:txbxContent`: a story drawn in a paragraph of another
|
|
1712
|
+
* story. Its paragraphs share the package's paragraph id space, so an
|
|
1713
|
+
* operation names them through the story that draws the box (see
|
|
1714
|
+
* `textBoxRouting.ts`); this address exists only while an operation is
|
|
1715
|
+
* applied to the box's own body.
|
|
1716
|
+
*/
|
|
1717
|
+
type TextBoxStory = {
|
|
1718
|
+
readonly kind: "textBox";
|
|
1719
|
+
/** The story whose paragraph draws the box. */
|
|
1720
|
+
readonly host: StoryAddress;
|
|
1721
|
+
/** That paragraph's `w14:paraId`. */
|
|
1722
|
+
readonly blockId: string;
|
|
1723
|
+
/** Which of the paragraph's text boxes, in leaf order. */
|
|
1724
|
+
readonly index: number;
|
|
1725
|
+
};
|
|
1726
|
+
/** A package story, or a text box inside one. */
|
|
1727
|
+
type StoryAddress = OpStory | TextBoxStory;
|
|
1233
1728
|
export declare const documentStories: (document: Document) => OpStory[];
|
|
1729
|
+
/**
|
|
1730
|
+
* Whether `story` lacks the paragraph a story ends with: the one a caret goes
|
|
1731
|
+
* in and a reader shows after a final table. The body, headers, footers and
|
|
1732
|
+
* notes end with one (a table cell already reads the paragraph it implies);
|
|
1733
|
+
* a story that ends in a table or holds no paragraph gains an empty one. A
|
|
1734
|
+
* separator note is left as read.
|
|
1735
|
+
*/
|
|
1736
|
+
export declare const storyLacksClosingParagraph: (document: Document, story: OpStory) => boolean;
|
|
1234
1737
|
type ReplaceStoryBodyOptions = {
|
|
1235
1738
|
document: Document;
|
|
1236
|
-
story:
|
|
1739
|
+
story: StoryAddress;
|
|
1237
1740
|
body: DocumentBody;
|
|
1238
1741
|
};
|
|
1239
1742
|
export declare const replaceStoryBody: ({ document, story, body }: ReplaceStoryBodyOptions) => Document;
|
|
@@ -1264,11 +1767,46 @@ export declare const storyParagraphs: (body: DocumentBody) => ParagraphLocation[
|
|
|
1264
1767
|
* for {@link sectionsInStep} to report.
|
|
1265
1768
|
*/
|
|
1266
1769
|
export declare const withBodyContent: (body: DocumentBody, content: BlockContent[]) => DocumentBody;
|
|
1770
|
+
/** The paragraph and its physical siblings, within the same body, wrapper or cell. */
|
|
1771
|
+
export declare const locateParagraphInBlockList: (body: DocumentBody, blockId: string) => {
|
|
1772
|
+
paragraph: Paragraph;
|
|
1773
|
+
blocks: readonly BlockContent[];
|
|
1774
|
+
index: number;
|
|
1775
|
+
} | undefined;
|
|
1776
|
+
/**
|
|
1777
|
+
* The content of each text box drawn in `story`, at any depth, a box before
|
|
1778
|
+
* the boxes drawn in it.
|
|
1779
|
+
*/
|
|
1780
|
+
export declare const textBoxContentsIn: (document: Document, story: OpStory) => readonly (readonly BlockContent[])[];
|
|
1781
|
+
type CloseTextBoxesOptions = {
|
|
1782
|
+
document: Document;
|
|
1783
|
+
story: OpStory;
|
|
1784
|
+
/** A new empty paragraph, with an id of its own. */
|
|
1785
|
+
closing: () => Paragraph;
|
|
1786
|
+
};
|
|
1787
|
+
/**
|
|
1788
|
+
* `document` with an empty paragraph after the blocks of each text box drawn
|
|
1789
|
+
* in `story`, nested ones included, that end without one: a text box is a
|
|
1790
|
+
* container, and a container ends with a paragraph.
|
|
1791
|
+
*/
|
|
1792
|
+
export declare const withTextBoxesClosed: ({ document, story, closing }: CloseTextBoxesOptions) => Document;
|
|
1793
|
+
/** A story's own paragraphs, then those of each text box drawn in it. */
|
|
1794
|
+
export declare const paragraphsThroughTextBoxes: (document: Document, story: OpStory) => ParagraphLocation[];
|
|
1795
|
+
/**
|
|
1796
|
+
* The paragraph `blockId` names in `story` and its physical siblings: one of
|
|
1797
|
+
* the story's own, or one in a text box drawn there.
|
|
1798
|
+
*/
|
|
1799
|
+
export declare const locateParagraphThroughTextBoxes: (document: Document, story: OpStory, blockId: string) => ReturnType<typeof locateParagraphInBlockList>;
|
|
1800
|
+
/** The innermost block-level control holding a paragraph, and every paragraph it holds. */
|
|
1801
|
+
export declare const blockControlHolding: (blocks: readonly BlockContent[], blockId: string) => {
|
|
1802
|
+
control: BlockSdt;
|
|
1803
|
+
paragraphs: Paragraph[];
|
|
1804
|
+
} | undefined;
|
|
1267
1805
|
/**
|
|
1268
1806
|
* The zero-width items a paragraph can hold, and whether each is content its
|
|
1269
1807
|
* mark must not take away. None is. A range boundary is a position, not
|
|
1270
|
-
* content: a paragraph that goes
|
|
1271
|
-
* (`paragraphRemains` in `rangeBoundaries.ts`), so it keeps no blank
|
|
1808
|
+
* content: a paragraph that goes hands it to the nearest paragraph that
|
|
1809
|
+
* stays (`paragraphRemains` in `rangeBoundaries.ts`), so it keeps no blank
|
|
1272
1810
|
* paragraph standing. A comment reference remains one logical offset unit,
|
|
1273
1811
|
* but moves as an anchor when its paragraph goes. A cached page break and a
|
|
1274
1812
|
* note's own marker mark nothing a reader placed.
|
|
@@ -1302,8 +1840,22 @@ export declare const paragraphContentVerdict: ({ width, zeroWidthItems }: {
|
|
|
1302
1840
|
width: number;
|
|
1303
1841
|
zeroWidthItems: Iterable<ZeroWidthItem>;
|
|
1304
1842
|
}) => ParagraphContentVerdict;
|
|
1843
|
+
/** Whether a paragraph holds content its mark must not take away. */
|
|
1844
|
+
export declare const paragraphHoldsContent: (paragraph: Paragraph) => ParagraphContentVerdict;
|
|
1845
|
+
/**
|
|
1846
|
+
* Whether a paragraph still holds content once every change in it is
|
|
1847
|
+
* accepted: what its pending deletions and moves away hold does not count.
|
|
1848
|
+
*/
|
|
1849
|
+
export declare const paragraphHoldsContentOnceAccepted: (paragraph: Paragraph) => ParagraphContentVerdict;
|
|
1305
1850
|
/** The number of logical units in a paragraph: its largest valid offset. */
|
|
1306
1851
|
export declare const paragraphLength: (paragraph: Paragraph) => number;
|
|
1852
|
+
/** A comment reference and the offset of the unit it takes. */
|
|
1853
|
+
type CommentReferenceOffset = {
|
|
1854
|
+
id: number;
|
|
1855
|
+
offset: number;
|
|
1856
|
+
};
|
|
1857
|
+
/** Where each comment reference of a paragraph stands, in document order. */
|
|
1858
|
+
export declare const commentReferenceOffsets: (paragraph: Paragraph) => CommentReferenceOffset[];
|
|
1307
1859
|
/** The character a unit that is not run text stands for in {@link paragraphLogicalText}. */
|
|
1308
1860
|
export declare const OBJECT_REPLACEMENT_CHARACTER = "";
|
|
1309
1861
|
/**
|
|
@@ -1313,7 +1865,7 @@ export declare const OBJECT_REPLACEMENT_CHARACTER = "";
|
|
|
1313
1865
|
*/
|
|
1314
1866
|
export declare const paragraphLogicalText: (paragraph: Paragraph) => string;
|
|
1315
1867
|
/** The single structural outcome of resolving a paragraph mark. */
|
|
1316
|
-
export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, holdsContentOnceAccepted, followingBlockCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable,
|
|
1868
|
+
export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdded, containerStillEndsWithParagraph, followingTableCanReceiveRunIn, holdsContentOnceAccepted, followingBlockCanReceiveRunIn, needsFollowingCommentHost, tableRemovalIsTrackable, emptyInsertedTableBoundary, precededByBlock }: {
|
|
1317
1869
|
/** `block` is a follower {@link isOpaqueFollower} admits. */
|
|
1318
1870
|
follows: "paragraph" | "table" | "block" | "nothing";
|
|
1319
1871
|
/** From {@link paragraphHoldsContent} or the editor's view of the same rule, never re-derived. */
|
|
@@ -1338,23 +1890,21 @@ export declare const paragraphMarkOutcome: ({ follows, holdsContent, markWasAdde
|
|
|
1338
1890
|
followingBlockCanReceiveRunIn?: boolean;
|
|
1339
1891
|
needsFollowingCommentHost?: boolean;
|
|
1340
1892
|
tableRemovalIsTrackable?: boolean;
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1893
|
+
/** Only a pending-review boundary proved free of source section/structure blockers. */
|
|
1894
|
+
emptyInsertedTableBoundary?: "unavailable" | "pendingReview";
|
|
1895
|
+
/** Whether a block stays before the paragraph to anchor what its removal leaves. */
|
|
1896
|
+
precededByBlock?: boolean;
|
|
1897
|
+
}) => {
|
|
1345
1898
|
kind: "join";
|
|
1346
|
-
}
|
|
1899
|
+
} | {
|
|
1347
1900
|
kind: "remove";
|
|
1348
|
-
}
|
|
1901
|
+
} | {
|
|
1349
1902
|
kind: "run-in";
|
|
1350
|
-
}
|
|
1903
|
+
} | {
|
|
1351
1904
|
kind: "keep";
|
|
1352
|
-
}
|
|
1905
|
+
} | {
|
|
1353
1906
|
kind: "refuse";
|
|
1354
1907
|
reason: "untrackable";
|
|
1355
|
-
} & SectionTransfer);
|
|
1356
|
-
type SectionTransfer = {
|
|
1357
|
-
sectionDestination: "none" | "preceding" | "following";
|
|
1358
1908
|
};
|
|
1359
1909
|
declare const BOUNDARY_SIDES: {
|
|
1360
1910
|
readonly bookmarkStart: {
|
|
@@ -1398,19 +1948,10 @@ type CommentAnchor$1 = CommentAnchorCarrier;
|
|
|
1398
1948
|
/** A boundary a block list holds between its blocks. */
|
|
1399
1949
|
type BlockBoundary = Exclude<Boundary, CommentAnchor$1>;
|
|
1400
1950
|
/**
|
|
1401
|
-
*
|
|
1402
|
-
*
|
|
1403
|
-
* comment anchors for the nearest paragraph that stays to take. When a
|
|
1404
|
-
* comment needs that host, every carrier travels there together in source
|
|
1405
|
-
* order. A comment with both anchors there becomes a point there, so the
|
|
1406
|
-
* comment and its anchor survive the paragraph.
|
|
1951
|
+
* Whether a block-list entry is a range boundary standing between blocks. A
|
|
1952
|
+
* block list holds no comment anchor, so every boundary in it is one of these.
|
|
1407
1953
|
*/
|
|
1408
|
-
export declare const
|
|
1409
|
-
all: (Boundary | CommentAnchor$1)[];
|
|
1410
|
-
blocks: BlockBoundary[];
|
|
1411
|
-
comments: CommentAnchor$1[];
|
|
1412
|
-
placement: "blocks" | "previous";
|
|
1413
|
-
};
|
|
1954
|
+
export declare const isBlockBoundary: (block: BlockContent) => block is BlockBoundary;
|
|
1414
1955
|
/** One range boundary in document order, as {@link planWellFormedRanges} reads it. */
|
|
1415
1956
|
type BoundaryOccurrence = {
|
|
1416
1957
|
/** The marker's element and id: what two copies of one boundary share. */
|
|
@@ -1420,6 +1961,18 @@ type BoundaryOccurrence = {
|
|
|
1420
1961
|
side: "start" | "end";
|
|
1421
1962
|
/** Whether a rejection kept it from removed content. */
|
|
1422
1963
|
kept: boolean;
|
|
1964
|
+
/**
|
|
1965
|
+
* Whether it is a copy an added revision still owns (its
|
|
1966
|
+
* `copyOriginAncestors`): rejecting that revision takes it away, so it is
|
|
1967
|
+
* never the boundary itself.
|
|
1968
|
+
*/
|
|
1969
|
+
copied: boolean;
|
|
1970
|
+
/**
|
|
1971
|
+
* Whether its kind records copies in copy ancestry, as bookmark and move
|
|
1972
|
+
* range boundaries do. Comment boundaries record none, so a kept one the
|
|
1973
|
+
* story holds otherwise is taken for a copy.
|
|
1974
|
+
*/
|
|
1975
|
+
copiesMarked: boolean;
|
|
1423
1976
|
/**
|
|
1424
1977
|
* The date of the revision a kept boundary came from. Of a kept start and
|
|
1425
1978
|
* end out of order, the one kept from the later revision moves: that edit
|
|
@@ -1439,13 +1992,23 @@ type WellFormedRangePlan = {
|
|
|
1439
1992
|
};
|
|
1440
1993
|
/**
|
|
1441
1994
|
* The one rule that makes every range a rejection kept boundaries of
|
|
1442
|
-
* well-formed, for the engine's model and the editor's document alike.
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
*
|
|
1447
|
-
*
|
|
1448
|
-
*
|
|
1995
|
+
* well-formed, for the engine's model and the editor's document alike.
|
|
1996
|
+
*
|
|
1997
|
+
* A bookmark or move range boundary that records copies never goes here,
|
|
1998
|
+
* whatever else the story holds: one without copy ancestry is the boundary
|
|
1999
|
+
* itself, and one with it goes only when its owner is rejected. Dropping
|
|
2000
|
+
* either because another occurrence stands would make the result depend on
|
|
2001
|
+
* which resolution came first, since accepting a copy leaves it standing as
|
|
2002
|
+
* inserting it directly does. A comment boundary records no copies, so a
|
|
2003
|
+
* kept one goes where the story holds it otherwise (of several kept and
|
|
2004
|
+
* nothing else, the first stays).
|
|
2005
|
+
*
|
|
2006
|
+
* A copy an added revision still owns that stands counts for no range's
|
|
2007
|
+
* order. Then, where such a range's end comes before its start, the
|
|
2008
|
+
* half the rejection kept closes on the other: a kept end moves to just
|
|
2009
|
+
* after the start, or else a kept start to just before the end. A boundary
|
|
2010
|
+
* that was standing never moves, and a range still with more than one start
|
|
2011
|
+
* or end is left as it is.
|
|
1449
2012
|
*/
|
|
1450
2013
|
export declare const planWellFormedRanges: (occurrences: readonly BoundaryOccurrence[]) => WellFormedRangePlan;
|
|
1451
2014
|
/** Capture own undefined fields before an operation enters its JSON journal. */
|
|
@@ -1484,7 +2047,23 @@ type AppliedDocumentOp = {
|
|
|
1484
2047
|
* folded or continued review are excluded; a direct operation reports none.
|
|
1485
2048
|
*/
|
|
1486
2049
|
revisions: readonly number[];
|
|
2050
|
+
/**
|
|
2051
|
+
* Existing revision ids whose pending property changes the operation
|
|
2052
|
+
* folded its edit into, in document order: the changes now carry its
|
|
2053
|
+
* stamp and record the properties it set, so accepting or rejecting one
|
|
2054
|
+
* of them accepts or rejects the edit too. Disjoint from `revisions`; a
|
|
2055
|
+
* direct operation reports none.
|
|
2056
|
+
*/
|
|
2057
|
+
folded: readonly number[];
|
|
1487
2058
|
};
|
|
2059
|
+
/** The revision ids a tracked operation's records carry. */
|
|
2060
|
+
type RecordedRevisionIds = Pick<AppliedDocumentOp, "revisions" | "folded">;
|
|
2061
|
+
/**
|
|
2062
|
+
* The revision ids of operations applied in turn, as one operation's: every
|
|
2063
|
+
* step's new ids, and the existing ids a step folded into that no step of
|
|
2064
|
+
* them allocated.
|
|
2065
|
+
*/
|
|
2066
|
+
export declare const combineRecordedRevisions: (steps: readonly RecordedRevisionIds[]) => RecordedRevisionIds;
|
|
1488
2067
|
/** Apply one operation to a document that meets the seed contract. */
|
|
1489
2068
|
export declare const applyDocumentOp: (document: Document, input: DocumentOp) => Result<AppliedDocumentOp, DocumentOpRefusal>;
|
|
1490
2069
|
/** Apply a journal envelope only when its schema matches this reader. */
|
|
@@ -1492,6 +2071,18 @@ export declare const applyDocumentOpEnvelope: (document: Document, envelope: {
|
|
|
1492
2071
|
schema: number;
|
|
1493
2072
|
op: DocumentOp;
|
|
1494
2073
|
}) => Result<AppliedDocumentOp, DocumentOpRefusal>;
|
|
2074
|
+
/**
|
|
2075
|
+
* An inverse whose whole-part restores expect the parts they meet when the
|
|
2076
|
+
* inverse runs, in order, on `document`.
|
|
2077
|
+
*
|
|
2078
|
+
* A restore records the parts its operation left, and refuses as stale when
|
|
2079
|
+
* the document it meets holds other ones. A caller that changes the document
|
|
2080
|
+
* after an operation (a derivation over the whole document, such as list
|
|
2081
|
+
* rendering) and puts its own inverse first rebases the restores onto that
|
|
2082
|
+
* document, so undo meets exactly what each restore expects. The inverse is
|
|
2083
|
+
* returned as it is when it holds no restore, or when it does not apply.
|
|
2084
|
+
*/
|
|
2085
|
+
export declare const inverseMeetingDocument: (document: Document, inverse: readonly DocumentOp[]) => readonly DocumentOp[];
|
|
1495
2086
|
/**
|
|
1496
2087
|
* Apply operations in order, atomically: the first refusal is returned and
|
|
1497
2088
|
* the document is unchanged. The inverse undoes the whole list, and
|
|
@@ -1517,6 +2108,13 @@ type HyperlinkEditorIntent = {
|
|
|
1517
2108
|
href: string;
|
|
1518
2109
|
tooltip?: string;
|
|
1519
2110
|
};
|
|
2111
|
+
/** The notes and comments pasted references and markers name, by those ids. */
|
|
2112
|
+
type PasteAnnotations = {
|
|
2113
|
+
notes: readonly (Footnote | Endnote)[];
|
|
2114
|
+
comments: readonly Comment[];
|
|
2115
|
+
};
|
|
2116
|
+
/** Accepted-view text without changing the canonical paragraph or its offset space. */
|
|
2117
|
+
export declare const paragraphVisibleText: (paragraph: Paragraph) => string;
|
|
1520
2118
|
type SplitParagraphIntent = {
|
|
1521
2119
|
type: "splitParagraph";
|
|
1522
2120
|
at: TextPosition;
|
|
@@ -1536,31 +2134,64 @@ type SplitParagraphIntent = {
|
|
|
1536
2134
|
type TableRowIntentOperation = Omit<InsertRowOp, "revision" | "newIds"> | Omit<DeleteRowOp, "revision" | "newIds">;
|
|
1537
2135
|
/**
|
|
1538
2136
|
* A table inserted after the paragraph `blockId`, with an empty paragraph
|
|
1539
|
-
* after it, as the editor inserts one
|
|
2137
|
+
* after it, as the editor inserts one, or between the blocks beside that
|
|
2138
|
+
* paragraph alone; or the table holding `blockId`,
|
|
1540
2139
|
* removed, or in suggesting mode recorded as deleted. An inserted table's
|
|
1541
2140
|
* paragraphs take fresh identities from the compiler.
|
|
1542
2141
|
*/
|
|
1543
|
-
type TableBlockIntentOperation = Omit<DeleteTableOp, "revision" | "newIds" | "expected"> | {
|
|
2142
|
+
type TableBlockIntentOperation = Omit<DeleteTableOp, "revision" | "newIds" | "expected"> | ({
|
|
1544
2143
|
type: typeof DOCUMENT_OP_TYPES.INSERT_TABLE;
|
|
1545
2144
|
story: OpStory;
|
|
1546
2145
|
blockId: string;
|
|
1547
2146
|
table: Table;
|
|
1548
2147
|
/**
|
|
1549
|
-
* Where the table goes against the anchor
|
|
2148
|
+
* Where the table goes against the anchor: after it (the
|
|
1550
2149
|
* default, as from a caret), or before it, as from a selection of the
|
|
1551
2150
|
* whole story, which the editor fills at the story's start.
|
|
1552
2151
|
*/
|
|
1553
2152
|
side?: "after" | "before";
|
|
2153
|
+
} & ({
|
|
2154
|
+
/** Existing callers default to a paragraph anchor. */
|
|
2155
|
+
anchor?: "paragraph";
|
|
1554
2156
|
/**
|
|
1555
2157
|
* An empty paragraph ahead of the table as well, as the editor writes
|
|
1556
2158
|
* a table it inserts after another, so the two never touch.
|
|
1557
2159
|
*/
|
|
1558
2160
|
separated?: boolean;
|
|
1559
|
-
|
|
2161
|
+
/**
|
|
2162
|
+
* The empty paragraph after the table: written, as the editor gives
|
|
2163
|
+
* the caret a place after a table it inserts (the default), or left
|
|
2164
|
+
* out, for a table that goes between blocks already standing on both
|
|
2165
|
+
* sides of it.
|
|
2166
|
+
*/
|
|
2167
|
+
paragraphAfter?: "empty" | "none";
|
|
2168
|
+
} | {
|
|
2169
|
+
/** Beside the innermost table holding blockId, without added paragraphs. */
|
|
2170
|
+
anchor: "table";
|
|
2171
|
+
separated?: never;
|
|
2172
|
+
paragraphAfter?: never;
|
|
2173
|
+
} | {
|
|
2174
|
+
/**
|
|
2175
|
+
* Before the first block of the block list holding blockId, without
|
|
2176
|
+
* added paragraphs: where no paragraph or table names the place.
|
|
2177
|
+
*/
|
|
2178
|
+
anchor: "containerStart";
|
|
2179
|
+
side?: never;
|
|
2180
|
+
separated?: never;
|
|
2181
|
+
paragraphAfter?: never;
|
|
2182
|
+
}));
|
|
1560
2183
|
/** Positions use canonical physical offsets, including retained deleted content. */
|
|
1561
2184
|
type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
|
|
1562
2185
|
type: "table";
|
|
1563
2186
|
operation: TableIntentOperation;
|
|
2187
|
+
/**
|
|
2188
|
+
* What each cell an inserted column creates holds, in row order: the
|
|
2189
|
+
* compiler writes it into the new cells after the column, as text
|
|
2190
|
+
* typed there, so a suggestion records it as inserted. A cell past
|
|
2191
|
+
* the list, or given no paragraphs, stays empty. Only a column
|
|
2192
|
+
* insertion takes it.
|
|
2193
|
+
*/
|
|
2194
|
+
cellContent?: readonly (readonly Paragraph[])[];
|
|
1564
2195
|
} | {
|
|
1565
2196
|
type: "tableRow";
|
|
1566
2197
|
operation: TableRowIntentOperation;
|
|
@@ -1569,13 +2200,13 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
|
|
|
1569
2200
|
operation: TableBlockIntentOperation;
|
|
1570
2201
|
} | {
|
|
1571
2202
|
/**
|
|
1572
|
-
* Whole paragraphs beside a paragraph
|
|
1573
|
-
*
|
|
1574
|
-
*
|
|
2203
|
+
* Whole paragraphs beside a paragraph or table: the compiler gives
|
|
2204
|
+
* each a fresh id, and a suggestion records each as inserted. Table-side
|
|
2205
|
+
* suggestions refuse boundaries without a reversible review plan.
|
|
1575
2206
|
*/
|
|
1576
2207
|
type: "insertParagraphs";
|
|
1577
2208
|
story: OpStory;
|
|
1578
|
-
at:
|
|
2209
|
+
at: TableInsertionPoint;
|
|
1579
2210
|
paragraphs: readonly Paragraph[];
|
|
1580
2211
|
/** A suggestion records the paragraphs as a move's destination. */
|
|
1581
2212
|
move?: true;
|
|
@@ -1588,6 +2219,13 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
|
|
|
1588
2219
|
blockIds: readonly string[];
|
|
1589
2220
|
/** A suggestion records the paragraphs as a move's source. */
|
|
1590
2221
|
move?: true;
|
|
2222
|
+
/**
|
|
2223
|
+
* Tracked, what the deletion does with the paragraphs a pending join
|
|
2224
|
+
* runs into the first one (`paragraphsJoinedInto`), read as the
|
|
2225
|
+
* document stands when it compiles: `deleted`, they go with it, as the
|
|
2226
|
+
* joined paragraph they make carries its id.
|
|
2227
|
+
*/
|
|
2228
|
+
joinedWords?: "deleted";
|
|
1591
2229
|
} | {
|
|
1592
2230
|
type: "replaceFragment";
|
|
1593
2231
|
from: TextPosition;
|
|
@@ -1595,6 +2233,25 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
|
|
|
1595
2233
|
paragraphs: readonly Paragraph[];
|
|
1596
2234
|
openStart: 0 | 1;
|
|
1597
2235
|
openEnd: 0 | 1;
|
|
2236
|
+
} | {
|
|
2237
|
+
/**
|
|
2238
|
+
* Clipboard blocks, tables among them, over a range: the range is
|
|
2239
|
+
* cleared, an open first or last paragraph joins the text at its edge,
|
|
2240
|
+
* and the blocks between go in before the caret's paragraph, split at
|
|
2241
|
+
* the caret when text stands before it. Without a table it is
|
|
2242
|
+
* `replaceFragment`.
|
|
2243
|
+
*/
|
|
2244
|
+
type: "pasteBlocks";
|
|
2245
|
+
from: TextPosition;
|
|
2246
|
+
to: TextPosition;
|
|
2247
|
+
blocks: readonly (Paragraph | Table)[];
|
|
2248
|
+
openStart: 0 | 1;
|
|
2249
|
+
openEnd: 0 | 1;
|
|
2250
|
+
/**
|
|
2251
|
+
* The notes and comments the blocks' references and markers name, by
|
|
2252
|
+
* those ids: each is copied under a fresh id where its reference lands.
|
|
2253
|
+
*/
|
|
2254
|
+
annotations?: PasteAnnotations;
|
|
1598
2255
|
} | {
|
|
1599
2256
|
type: "moveFragment";
|
|
1600
2257
|
from: TextPosition;
|
|
@@ -1608,6 +2265,13 @@ type EditorIntent = HyperlinkEditorIntent | GenerateTOCIntent | {
|
|
|
1608
2265
|
from: TextPosition;
|
|
1609
2266
|
to: TextPosition;
|
|
1610
2267
|
text: string;
|
|
2268
|
+
/** Where each piece of the inserted text takes its authored formatting. */
|
|
2269
|
+
formattingSources?: readonly {
|
|
2270
|
+
/** Exclusive UTF-16 offset in `text`, with contiguous pieces. */
|
|
2271
|
+
end: number;
|
|
2272
|
+
at: TextPosition;
|
|
2273
|
+
type: "character" | "caret";
|
|
2274
|
+
}[];
|
|
1611
2275
|
runProps?: TextFormatting;
|
|
1612
2276
|
runPropsPatch?: RunPropsPatch;
|
|
1613
2277
|
/**
|
|
@@ -1673,6 +2337,8 @@ type NewListInstance = {
|
|
|
1673
2337
|
type EditorIntentMode = {
|
|
1674
2338
|
/** Identities consumed during this editor lifetime, including undone insertions. */
|
|
1675
2339
|
reservedBlockIds?: ReadonlySet<string>;
|
|
2340
|
+
/** The only ids the compiler may mint, when the author holds a lease. */
|
|
2341
|
+
idLease?: IdLease;
|
|
1676
2342
|
} & ({
|
|
1677
2343
|
type: "editing";
|
|
1678
2344
|
newIds?: NewIds;
|
|
@@ -1681,9 +2347,23 @@ type EditorIntentMode = {
|
|
|
1681
2347
|
revision: RevisionStamp;
|
|
1682
2348
|
newIds: NewIds;
|
|
1683
2349
|
});
|
|
2350
|
+
/**
|
|
2351
|
+
* Where text an intent adds takes its formatting from: the caret's, as typing
|
|
2352
|
+
* continues the run it stands in, or the body text's, as an operation's text
|
|
2353
|
+
* is body text and never continues a note reference.
|
|
2354
|
+
*/
|
|
2355
|
+
export declare const TYPED_TEXT_FORMATTING: Readonly<{
|
|
2356
|
+
readonly CARET: "caret";
|
|
2357
|
+
readonly BODY_TEXT: "bodyText";
|
|
2358
|
+
}>;
|
|
2359
|
+
type TypedTextFormatting = (typeof TYPED_TEXT_FORMATTING)[keyof typeof TYPED_TEXT_FORMATTING];
|
|
1684
2360
|
type CompileEditorIntentOptions = {
|
|
1685
2361
|
intent: EditorIntent;
|
|
1686
2362
|
mode: EditorIntentMode;
|
|
2363
|
+
/** By default the caret's. */
|
|
2364
|
+
typedFormatting?: TypedTextFormatting;
|
|
2365
|
+
/** Source before this operation's other replacement pieces are compiled. */
|
|
2366
|
+
replacementFormattingDocument?: Document;
|
|
1687
2367
|
/** Lowest candidate for compiler-owned pasted block IDs, including retired session IDs. */
|
|
1688
2368
|
firstBlockId?: number;
|
|
1689
2369
|
};
|
|
@@ -1705,7 +2385,7 @@ type EditorIntentAllocation = EditorIntent | SplitParagraphIntent;
|
|
|
1705
2385
|
*/
|
|
1706
2386
|
export declare const createEditorIntentIdAllocator: ({ reservedBlockIds }?: {
|
|
1707
2387
|
reservedBlockIds?: ReadonlySet<string>;
|
|
1708
|
-
}) => (document: Document,
|
|
2388
|
+
}) => (document: Document, requested: EditorIntentAllocation, lease?: IdLease) => {
|
|
1709
2389
|
revisionId: number;
|
|
1710
2390
|
newBlockId: string;
|
|
1711
2391
|
newIds: {
|
|
@@ -1713,8 +2393,6 @@ export declare const createEditorIntentIdAllocator: ({ reservedBlockIds }?: {
|
|
|
1713
2393
|
control: number[];
|
|
1714
2394
|
};
|
|
1715
2395
|
};
|
|
1716
|
-
/** Accepted-view text without changing the canonical paragraph or its offset space. */
|
|
1717
|
-
export declare const paragraphVisibleText: (paragraph: Paragraph) => string;
|
|
1718
2396
|
/**
|
|
1719
2397
|
* Right-affine translation: a visible gap follows retained deleted content at
|
|
1720
2398
|
* that gap, so a new insertion never lands inside a deletion wrapper.
|
|
@@ -1727,12 +2405,70 @@ export declare const editorParagraphGroups: (document: Document, story: OpStory)
|
|
|
1727
2405
|
paragraphs: Paragraph[];
|
|
1728
2406
|
text: string;
|
|
1729
2407
|
}[];
|
|
2408
|
+
/**
|
|
2409
|
+
* {@link editorParagraphGroups} of `story` and of every text box drawn in it,
|
|
2410
|
+
* each box grouped within its own story: a box's paragraphs are named
|
|
2411
|
+
* through the story drawing it, and a mark pending deletion in a box joins
|
|
2412
|
+
* the box's next paragraph.
|
|
2413
|
+
*/
|
|
2414
|
+
export declare const editorParagraphGroupsThroughTextBoxes: (document: Document, story: OpStory) => ReturnType<typeof editorParagraphGroups>;
|
|
1730
2415
|
/** One logical paragraph and visible offset for a physical canonical address. */
|
|
1731
2416
|
export declare const editorPositionAtPhysicalPosition: (document: Document, at: TextPosition) => TextPosition;
|
|
1732
2417
|
/** Translate an editing-view paragraph gap to its physical canonical address. */
|
|
1733
2418
|
export declare const physicalPositionAtEditorOffset: (document: Document, at: TextPosition) => TextPosition;
|
|
2419
|
+
type JoinPropertyChangeLinkOptions = {
|
|
2420
|
+
/** The document before the operation that joined the paragraphs. */
|
|
2421
|
+
before: Document;
|
|
2422
|
+
/** The document after it. */
|
|
2423
|
+
after: Document;
|
|
2424
|
+
story: OpStory;
|
|
2425
|
+
/** The paragraph whose mark the join deletes. */
|
|
2426
|
+
blockId: string;
|
|
2427
|
+
/** The paragraph the operation set the joined properties on. */
|
|
2428
|
+
propertiesBlockId: string;
|
|
2429
|
+
};
|
|
2430
|
+
/**
|
|
2431
|
+
* The review op that makes the property change an operation left on the
|
|
2432
|
+
* paragraph its tracked join keeps belong to the paragraph-mark deletion the
|
|
2433
|
+
* operation recorded, so accepting or rejecting the join decides both.
|
|
2434
|
+
* `undefined` when the operation recorded no mark deletion (a mark already
|
|
2435
|
+
* pending deletion, an own added mark taken back), the paragraph holds no
|
|
2436
|
+
* change the operation made, or the change already belongs to a revision.
|
|
2437
|
+
*/
|
|
2438
|
+
export declare const joinPropertyChangeLink: ({ before, after, story, blockId, propertiesBlockId }: JoinPropertyChangeLinkOptions) => SetParagraphReviewOp | undefined;
|
|
1734
2439
|
/** Compile one batch; the caller applies it atomically and journals its exact inverse. */
|
|
1735
|
-
export declare const compileEditorIntent: (document: Document,
|
|
2440
|
+
export declare const compileEditorIntent: (document: Document, input: CompileEditorIntentOptions) => Result<CompiledEditorIntent, DocumentOpRefusal>;
|
|
2441
|
+
type InsertParagraphsIntent = Extract<EditorIntent, {
|
|
2442
|
+
type: "insertParagraphs";
|
|
2443
|
+
}>;
|
|
2444
|
+
type TrackedBatchOptions = {
|
|
2445
|
+
document: Document;
|
|
2446
|
+
count: number;
|
|
2447
|
+
reservedBlockIds?: ReadonlySet<string>;
|
|
2448
|
+
};
|
|
2449
|
+
type TrackedMemberOptions = {
|
|
2450
|
+
index: number;
|
|
2451
|
+
intent: InsertParagraphsIntent;
|
|
2452
|
+
mode: EditorIntentMode;
|
|
2453
|
+
};
|
|
2454
|
+
type TrackedInsertionCompilation = {
|
|
2455
|
+
type: "unsupported";
|
|
2456
|
+
} | {
|
|
2457
|
+
type: "operation";
|
|
2458
|
+
op: InsertBlocksOp;
|
|
2459
|
+
};
|
|
2460
|
+
type TrackedInsertionCompiler = {
|
|
2461
|
+
type: "unsupported";
|
|
2462
|
+
} | {
|
|
2463
|
+
type: "ready";
|
|
2464
|
+
compile: (options: TrackedMemberOptions) => Result<TrackedInsertionCompilation, DocumentOpRefusal>;
|
|
2465
|
+
};
|
|
2466
|
+
/**
|
|
2467
|
+
* Reserve the selection of fresh paragraph IDs for a private monotone run.
|
|
2468
|
+
* The caller uses each index once, in order, and discards the whole run if
|
|
2469
|
+
* any step fails or changes the original class of operations.
|
|
2470
|
+
*/
|
|
2471
|
+
export declare const beginTrackedInsertionCompilation: ({ document, count, reservedBlockIds }: TrackedBatchOptions) => TrackedInsertionCompiler;
|
|
1736
2472
|
type TocHeading = {
|
|
1737
2473
|
blockId: string;
|
|
1738
2474
|
text: string;
|
|
@@ -1756,12 +2492,89 @@ type PackageResourcesOpOptions = {
|
|
|
1756
2492
|
};
|
|
1757
2493
|
/** Describe the package resource difference as one operation carrying only changed entries. */
|
|
1758
2494
|
export declare const packageResourcesOpOf: ({ before, after }: PackageResourcesOpOptions) => SetPackageResourcesOp;
|
|
2495
|
+
type MemberEffect = DocumentEditEffects & RecordedRevisionIds & {
|
|
2496
|
+
op: InsertBlocksOp;
|
|
2497
|
+
};
|
|
2498
|
+
type FallbackReason = "compiler" | "sourceShape" | "sectionView" | "memberShape" | "effectShape" | "wideSpan" | "materialization";
|
|
2499
|
+
type TrackedInsertionGroupResult = {
|
|
2500
|
+
type: "fallback";
|
|
2501
|
+
reason: FallbackReason;
|
|
2502
|
+
} | {
|
|
2503
|
+
type: "fallback";
|
|
2504
|
+
reason: "refusal";
|
|
2505
|
+
index: number;
|
|
2506
|
+
refusal: DocumentOpRefusal;
|
|
2507
|
+
} | {
|
|
2508
|
+
type: "materialized";
|
|
2509
|
+
document: Document;
|
|
2510
|
+
members: readonly MemberEffect[];
|
|
2511
|
+
};
|
|
2512
|
+
type NextMember = {
|
|
2513
|
+
type: "member";
|
|
2514
|
+
op: InsertBlocksOp;
|
|
2515
|
+
} | {
|
|
2516
|
+
type: "done";
|
|
2517
|
+
} | {
|
|
2518
|
+
type: "fallback";
|
|
2519
|
+
};
|
|
2520
|
+
type TrackedInsertionGroupOptions = {
|
|
2521
|
+
document: Document;
|
|
2522
|
+
next: (previousRevisions: readonly number[] | undefined) => NextMember;
|
|
2523
|
+
};
|
|
2524
|
+
/**
|
|
2525
|
+
* Attempt a precompiled journal run at one physical main-story anchor. The
|
|
2526
|
+
* prepared members see all prior ids and the real current source/follower.
|
|
2527
|
+
* Publish a document and journal effects only when the whole group succeeds.
|
|
2528
|
+
* Keep the source document and all emitted operations immutable during the
|
|
2529
|
+
* synchronous compiler callback. The caller owns its journal copies.
|
|
2530
|
+
*/
|
|
2531
|
+
export declare const tryTrackedInsertionGroup: ({ document, next }: TrackedInsertionGroupOptions) => TrackedInsertionGroupResult;
|
|
2532
|
+
type SectionRejectPropertiesOptions = {
|
|
2533
|
+
live: SectionProperties;
|
|
2534
|
+
previousProperties: SectionProperties | undefined;
|
|
2535
|
+
previousReferences?: SectionPropertyChange["previousReferences"];
|
|
2536
|
+
};
|
|
2537
|
+
/**
|
|
2538
|
+
* Rejected section properties: the stored old sectPr wholesale, preserving
|
|
2539
|
+
* the live header/footer references — `EG_HdrFtrReferences` is not part of
|
|
2540
|
+
* the `CT_SectPrBase` payload a `w:sectPrChange` stores (ECMA-376
|
|
2541
|
+
* §17.13.5.32), so those children survive a native reject. An explicit
|
|
2542
|
+
* reference history replaces that selection, including restoring its
|
|
2543
|
+
* absence. The caller re-attaches whatever `propertyChanges` remain
|
|
2544
|
+
* unresolved.
|
|
2545
|
+
*/
|
|
2546
|
+
export declare const sectionRejectProperties: ({ live, previousProperties, previousReferences }: SectionRejectPropertiesOptions) => SectionProperties;
|
|
2547
|
+
type ResolveSectionChangeOptions = {
|
|
2548
|
+
current: SectionProperties;
|
|
2549
|
+
decision: RevisionDecision;
|
|
2550
|
+
id: number;
|
|
2551
|
+
};
|
|
2552
|
+
/**
|
|
2553
|
+
* `current` with its change `id` resolved, the changes after it rebased onto
|
|
2554
|
+
* what that resolution leaves; `null` when no change of `current` is `id`.
|
|
2555
|
+
*/
|
|
2556
|
+
export declare const resolveSectionChange: ({ current, decision, id }: ResolveSectionChangeOptions) => SectionProperties | null;
|
|
2557
|
+
/** `current` with its whole change history resolved; `null` when it has none. */
|
|
2558
|
+
export declare const resolveSectionChanges: (current: SectionProperties, decision: RevisionDecision) => SectionProperties | null;
|
|
2559
|
+
type SectionResolutionPatchOptions = {
|
|
2560
|
+
current: SectionProperties;
|
|
2561
|
+
next: SectionProperties;
|
|
2562
|
+
};
|
|
2563
|
+
/** The patch from `current` to `next`: explicit nulls remove what `next` no longer carries. */
|
|
2564
|
+
export declare const sectionResolutionPatch: ({ current, next }: SectionResolutionPatchOptions) => FormattingPatch<SectionProperties>;
|
|
1759
2565
|
type RegisterParagraphPropertySnapshotOptions = {
|
|
1760
|
-
paragraph
|
|
2566
|
+
/** A paragraph, or review fields an operation gives one. */
|
|
2567
|
+
paragraph: Pick<Paragraph, "formatting">;
|
|
1761
2568
|
snapshot: ParagraphFormatting | undefined;
|
|
1762
2569
|
};
|
|
1763
2570
|
/** Bind effective formatting to the authored properties a review must record. */
|
|
1764
2571
|
export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }: RegisterParagraphPropertySnapshotOptions) => void;
|
|
2572
|
+
/**
|
|
2573
|
+
* Register `paragraph`'s formatting as exactly what it states, as a rejected
|
|
2574
|
+
* property change restores the recorded properties: no list level or style
|
|
2575
|
+
* projects a value onto it.
|
|
2576
|
+
*/
|
|
2577
|
+
export declare const registerStatedParagraphFormatting: (paragraph: Pick<Paragraph, "formatting">) => void;
|
|
1765
2578
|
/**
|
|
1766
2579
|
* The registration a paragraph's snapshot stands on, as an opaque token: the
|
|
1767
2580
|
* same object while nothing registers or transfers another one for it. A pass
|
|
@@ -1769,6 +2582,18 @@ export declare const registerParagraphPropertySnapshot: ({ paragraph, snapshot }
|
|
|
1769
2582
|
* change nothing.
|
|
1770
2583
|
*/
|
|
1771
2584
|
export declare const paragraphPropertySnapshotToken: (paragraph: Paragraph) => object | undefined;
|
|
2585
|
+
type TransferParagraphPropertySnapshotOptions = {
|
|
2586
|
+
source: object;
|
|
2587
|
+
target: object;
|
|
2588
|
+
};
|
|
2589
|
+
/** Retain paragraph-owned snapshot bindings through sanctioned model copies. */
|
|
2590
|
+
export declare const transferParagraphPropertySnapshot: ({ source, target }: TransferParagraphPropertySnapshotOptions) => void;
|
|
2591
|
+
/**
|
|
2592
|
+
* Whether `paragraph`'s formatting is still the formatting an edit registered
|
|
2593
|
+
* as stated. A projector that infers stated properties from the effective
|
|
2594
|
+
* ones it projected before keeps every value such formatting holds.
|
|
2595
|
+
*/
|
|
2596
|
+
export declare const paragraphStatesItsFormatting: (paragraph: Pick<Paragraph, "formatting">) => boolean;
|
|
1772
2597
|
/**
|
|
1773
2598
|
* Every `TextFormatting` field, named so the comparison below is total.
|
|
1774
2599
|
*
|
|
@@ -1784,7 +2609,7 @@ type ComparedTextFormatting = ExhaustiveFields<TextFormatting, ComparedTextForma
|
|
|
1784
2609
|
* Uses deep comparison of all properties to determine if runs
|
|
1785
2610
|
* can be merged without losing formatting information.
|
|
1786
2611
|
*/
|
|
1787
|
-
export declare function formattingEquals(a: ComparedTextFormatting | undefined, b: ComparedTextFormatting | undefined): boolean;
|
|
2612
|
+
export declare function formattingEquals(a: DeepReadonly<ComparedTextFormatting> | undefined, b: DeepReadonly<ComparedTextFormatting> | undefined): boolean;
|
|
1788
2613
|
/**
|
|
1789
2614
|
* Check if a run contains only text content
|
|
1790
2615
|
* (runs with special content like images, fields, etc. should not be merged)
|
|
@@ -1828,18 +2653,10 @@ export declare const validateOpsDocument: (document: Document) => Result<Documen
|
|
|
1828
2653
|
* removed, and its section view derived again. Nothing else changes.
|
|
1829
2654
|
*/
|
|
1830
2655
|
export declare const normalizeForOps: (document: Document) => Document;
|
|
1831
|
-
/**
|
|
1832
|
-
|
|
1833
|
-
/** Every paragraph id of a package, each story walked once. */
|
|
1834
|
-
export declare const packageParagraphIds: (pkg: DocxPackage) => string[];
|
|
1835
|
-
/**
|
|
1836
|
-
* The key two spellings of one id share. `ST_LongHexNumber` is hex, so
|
|
1837
|
-
* `0000abcd` and `0000ABCD` are the same id; every lookup and comparison of
|
|
1838
|
-
* paragraph ids goes through this.
|
|
1839
|
-
*/
|
|
1840
|
-
export declare const idKey: (id: string) => string;
|
|
2656
|
+
/** The author of an edit and, for a pending suggestion, the suggestion it belongs to. */
|
|
2657
|
+
type RevisionOwner = Pick<RevisionStamp, "author" | "suggestionId">;
|
|
1841
2658
|
/** Package-aware explicit pools for every semantic comment anchor cut, including replies. */
|
|
1842
|
-
export declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp) => Result<NewIds, DocumentOpRefusal>;
|
|
2659
|
+
export declare const allocateCommentAnchorIds: (document: Document, op: CreateCommentOp, lease?: IdLease) => Result<NewIds, DocumentOpRefusal>;
|
|
1843
2660
|
/**
|
|
1844
2661
|
* How many `newIds.revision` entries an operation takes on a document,
|
|
1845
2662
|
* besides its stamp's id: the length of the shortest list of unused ids it
|
|
@@ -1883,11 +2700,7 @@ type PlanTrackedReplaceOptions = PlanTrackedDeletionOptions & {
|
|
|
1883
2700
|
tail: InlineSlice;
|
|
1884
2701
|
};
|
|
1885
2702
|
};
|
|
1886
|
-
/**
|
|
1887
|
-
* Plan a tracked replacement of a same-list range: the range's tracked
|
|
1888
|
-
* deletion followed by the replacement fragment as tracked insertions.
|
|
1889
|
-
* All physical revision ids come from one pool for the complete batch.
|
|
1890
|
-
*/
|
|
2703
|
+
/** Plan a same-list range deletion followed by tracked replacement insertions. */
|
|
1891
2704
|
export declare const planTrackedReplace: (document: Document, options: PlanTrackedReplaceOptions) => Result<DocumentOp[], DocumentOpRefusal>;
|
|
1892
2705
|
/** A batch applies atomically, in array order, against its stated revision. */
|
|
1893
2706
|
type DocumentBatch = {
|
|
@@ -1908,9 +2721,55 @@ type SequencedOpEffect = {
|
|
|
1908
2721
|
} | {
|
|
1909
2722
|
type: "joinBlocks";
|
|
1910
2723
|
firstLength: number;
|
|
2724
|
+
} | {
|
|
2725
|
+
type: "insertContent";
|
|
2726
|
+
/**
|
|
2727
|
+
* Whether the insertion cut a record carrying an id (a revision or a
|
|
2728
|
+
* content control) in two, its second half taking a new id.
|
|
2729
|
+
*/
|
|
2730
|
+
cutIdentified: boolean;
|
|
2731
|
+
} | {
|
|
2732
|
+
type: "deleteRange";
|
|
2733
|
+
/**
|
|
2734
|
+
* A direct deletion whose range held its note's own reference mark,
|
|
2735
|
+
* which it keeps: the gap before the mark. A point after the mark that
|
|
2736
|
+
* the deletion closes up to its start lands after the mark.
|
|
2737
|
+
*/
|
|
2738
|
+
keptMark?: Gap;
|
|
2739
|
+
} | {
|
|
2740
|
+
type: "setRunProps";
|
|
2741
|
+
/**
|
|
2742
|
+
* The records a direct format cut at both of its ends, outermost
|
|
2743
|
+
* first, by the gaps before their first leaf and after their last one
|
|
2744
|
+
* before the format: a run, and the text the range lay inside. Where
|
|
2745
|
+
* a concurrent deletion holds the format's range and reaches past
|
|
2746
|
+
* neither end of such a record, the deletion keeps it one record. In a
|
|
2747
|
+
* note, `keptMark` is the gap before the note's own reference mark a
|
|
2748
|
+
* record holds, which a direct deletion keeps as well.
|
|
2749
|
+
*/
|
|
2750
|
+
cutRecords?: readonly {
|
|
2751
|
+
from: Gap;
|
|
2752
|
+
to: Gap;
|
|
2753
|
+
keptMark?: Gap;
|
|
2754
|
+
}[];
|
|
1911
2755
|
} | {
|
|
1912
2756
|
type: "touchedBlocks";
|
|
2757
|
+
/** Paragraphs the operation changed, inserted or removed. */
|
|
1913
2758
|
blockIds: readonly string[];
|
|
2759
|
+
/**
|
|
2760
|
+
* For a table structure edit, every paragraph of the table before and
|
|
2761
|
+
* after it: another structure edit of that table conflicts with it.
|
|
2762
|
+
*/
|
|
2763
|
+
tableBlockIds?: readonly string[];
|
|
2764
|
+
/**
|
|
2765
|
+
* For a comment operation, the comments it added, removed or changed,
|
|
2766
|
+
* replies of a deleted thread among them, and whether it removed a
|
|
2767
|
+
* package relationship of the comment parts.
|
|
2768
|
+
*/
|
|
2769
|
+
comments?: {
|
|
2770
|
+
ids: readonly number[];
|
|
2771
|
+
relationshipRemoved: boolean;
|
|
2772
|
+
};
|
|
1914
2773
|
} | {
|
|
1915
2774
|
type: typeof NO_SEQUENCED_EFFECT;
|
|
1916
2775
|
};
|
|
@@ -1925,9 +2784,35 @@ export declare const BATCH_REJECTION_REASONS: {
|
|
|
1925
2784
|
readonly CONFLICT: "conflict";
|
|
1926
2785
|
readonly STALE_BASE: "staleBase";
|
|
1927
2786
|
readonly INVALID_OPERATION: "invalidOperation";
|
|
2787
|
+
/** A concurrent operation restructured the table this one restructures. */
|
|
1928
2788
|
readonly TABLE_REQUIRES_EXCLUSIVE_EDIT: "tableRequiresExclusiveEdit";
|
|
2789
|
+
/** A concurrent operation changed a paragraph this one addresses. */
|
|
2790
|
+
readonly BLOCK_CONFLICT: "blockConflict";
|
|
2791
|
+
/** A concurrent operation wrote a package part this one uses (`part`). */
|
|
2792
|
+
readonly PART_CONFLICT: "partConflict";
|
|
2793
|
+
/** The batch introduces an id its actor does not lease. */
|
|
2794
|
+
readonly OUTSIDE_ID_LEASE: "outsideIdLease";
|
|
1929
2795
|
};
|
|
1930
2796
|
type BatchRejectionReason = (typeof BATCH_REJECTION_REASONS)[keyof typeof BATCH_REJECTION_REASONS];
|
|
2797
|
+
/**
|
|
2798
|
+
* Package parts an operation reads or writes besides the paragraphs it
|
|
2799
|
+
* addresses. Concurrent operations conflict on a part when one writes it and
|
|
2800
|
+
* both name the same entry, or one names the whole part.
|
|
2801
|
+
*/
|
|
2802
|
+
export declare const EXCLUSIVE_PARTS: Readonly<{
|
|
2803
|
+
readonly NUMBERING: "numbering";
|
|
2804
|
+
readonly STYLES: "styles";
|
|
2805
|
+
readonly RELATIONSHIPS: "relationships";
|
|
2806
|
+
readonly MEDIA: "media";
|
|
2807
|
+
readonly SECTIONS: "sections";
|
|
2808
|
+
readonly HEADERS_FOOTERS: "headersFooters";
|
|
2809
|
+
readonly NOTES: "notes";
|
|
2810
|
+
readonly SETTINGS: "settings";
|
|
2811
|
+
readonly REVISIONS: "revisions";
|
|
2812
|
+
readonly COMMENTS: "comments";
|
|
2813
|
+
}>;
|
|
2814
|
+
/** One of {@link EXCLUSIVE_PARTS}. */
|
|
2815
|
+
type ExclusivePart = (typeof EXCLUSIVE_PARTS)[keyof typeof EXCLUSIVE_PARTS];
|
|
1931
2816
|
declare const BatchRejectionBase: TaggedErrorClass<"BatchRejection">;
|
|
1932
2817
|
export declare class BatchRejection extends BatchRejectionBase<{
|
|
1933
2818
|
message: string;
|
|
@@ -1935,6 +2820,10 @@ export declare class BatchRejection extends BatchRejectionBase<{
|
|
|
1935
2820
|
opId?: string;
|
|
1936
2821
|
opType?: DocumentOpType;
|
|
1937
2822
|
overType?: DocumentOpType;
|
|
2823
|
+
/** The kind of the id an out-of-lease batch introduces. */
|
|
2824
|
+
idKind?: IdLeaseKind;
|
|
2825
|
+
/** The package part a part conflict names. */
|
|
2826
|
+
part?: ExclusivePart;
|
|
1938
2827
|
}> {}
|
|
1939
2828
|
export declare const BATCH_WIRE_OP_TYPES: readonly string[];
|
|
1940
2829
|
/** Bound recursion and refuse values except JSON data and absent object fields. */
|
|
@@ -1950,6 +2839,57 @@ type TransformOptions = {
|
|
|
1950
2839
|
};
|
|
1951
2840
|
/** Rebase an atomic batch over an ordered journal tail. */
|
|
1952
2841
|
export declare const transformBatch: (batch: DocumentBatch, over: readonly SequencedBatch[], options?: TransformOptions) => Result<DocumentBatch, BatchRejection>;
|
|
2842
|
+
/**
|
|
2843
|
+
* Where a position lands after an ordered journal tail, by paragraph identity
|
|
2844
|
+
* and offset, never by an editor's own coordinates. At a foreign insertion's
|
|
2845
|
+
* or split's own offset, `before` keeps the position ahead of what was
|
|
2846
|
+
* inserted and `after` moves it past. Undefined when the tail removes the
|
|
2847
|
+
* position's paragraph or changes it in a way an offset cannot follow.
|
|
2848
|
+
*/
|
|
2849
|
+
export declare const transformPosition: (position: TextPosition, over: readonly SequencedBatch[], affinity?: "before" | "after") => TextPosition | undefined;
|
|
2850
|
+
type AppliedBatch = {
|
|
2851
|
+
document: Document;
|
|
2852
|
+
inverse: readonly DocumentOp[];
|
|
2853
|
+
effects: NonNullable<SequencedBatch["effects"]>;
|
|
2854
|
+
};
|
|
2855
|
+
/** Capture position facts before each operation, including within an atomic batch. */
|
|
2856
|
+
export declare const applyBatch: (document: Document, ops: readonly DocumentOp[]) => Result<AppliedBatch, DocumentOpRefusal>;
|
|
2857
|
+
/** How many ids one grant or renewal leases, per kind. */
|
|
2858
|
+
export declare const DEFAULT_ID_BLOCK_SIZES: Readonly<Record<IdLeaseKind, number>>;
|
|
2859
|
+
/** One block leased to one actor. */
|
|
2860
|
+
type IdLeaseGrant = {
|
|
2861
|
+
readonly actor: string;
|
|
2862
|
+
readonly block: IdBlock;
|
|
2863
|
+
};
|
|
2864
|
+
/** The highest id of a kind one actor's sequenced batches introduced. */
|
|
2865
|
+
type IdLeaseMinted = {
|
|
2866
|
+
readonly actor: string;
|
|
2867
|
+
readonly kind: IdLeaseKind;
|
|
2868
|
+
readonly highest: number;
|
|
2869
|
+
};
|
|
2870
|
+
/**
|
|
2871
|
+
* A room's lease table, part of its sequenced state: kept with the journal
|
|
2872
|
+
* and given back to a restarted sequencer, so each actor keeps its blocks.
|
|
2873
|
+
*/
|
|
2874
|
+
type IdLeaseState = {
|
|
2875
|
+
readonly blockSizes: Readonly<Record<IdLeaseKind, number>>;
|
|
2876
|
+
/** Every block granted, in grant order. */
|
|
2877
|
+
readonly grants: readonly IdLeaseGrant[];
|
|
2878
|
+
readonly minted: readonly IdLeaseMinted[];
|
|
2879
|
+
};
|
|
2880
|
+
export declare const ID_LEASE_REFUSAL_REASONS: Readonly<{
|
|
2881
|
+
readonly EXHAUSTED: "exhausted";
|
|
2882
|
+
readonly NOT_DUE: "notDue";
|
|
2883
|
+
readonly INVALID_STATE: "invalidState";
|
|
2884
|
+
readonly UNAVAILABLE: "unavailable";
|
|
2885
|
+
}>;
|
|
2886
|
+
type IdLeaseRefusalReason = (typeof ID_LEASE_REFUSAL_REASONS)[keyof typeof ID_LEASE_REFUSAL_REASONS];
|
|
2887
|
+
declare const IdLeaseRefusalBase: TaggedErrorClass<"IdLeaseRefusal">;
|
|
2888
|
+
export declare class IdLeaseRefusal extends IdLeaseRefusalBase<{
|
|
2889
|
+
message: string;
|
|
2890
|
+
reason: IdLeaseRefusalReason;
|
|
2891
|
+
kind?: IdLeaseKind;
|
|
2892
|
+
}> {}
|
|
1953
2893
|
type BatchAck = {
|
|
1954
2894
|
type: "ack";
|
|
1955
2895
|
opId: string;
|
|
@@ -1962,30 +2902,73 @@ type BatchReject = {
|
|
|
1962
2902
|
headRev: number;
|
|
1963
2903
|
};
|
|
1964
2904
|
type BatchSubmission = BatchAck | BatchReject;
|
|
1965
|
-
|
|
1966
|
-
|
|
2905
|
+
type SequencerOptions = {
|
|
2906
|
+
/** The room's lease table, as `idLeases` gave it before a restart. */
|
|
2907
|
+
idLeases?: IdLeaseState;
|
|
2908
|
+
};
|
|
2909
|
+
/**
|
|
2910
|
+
* Deterministic append-only authority; the caller supplies delivery and
|
|
2911
|
+
* storage. Every actor mints fresh ids only from the blocks the sequencer
|
|
2912
|
+
* leases it, and a batch introducing an id outside its actor's lease is
|
|
2913
|
+
* rejected, so concurrent actors never mint the same id.
|
|
2914
|
+
*/
|
|
2915
|
+
export declare const createSequencer: (document: Document, options?: SequencerOptions) => {
|
|
1967
2916
|
submit: (batch: DocumentBatch) => BatchSubmission;
|
|
2917
|
+
/** The actor's remaining lease; the first call grants one block per kind. */
|
|
2918
|
+
grantIdLease: (actor: string) => Result<IdLease, IdLeaseRefusal>;
|
|
2919
|
+
/** One more block of `kind` for an actor running low. */
|
|
2920
|
+
renewIdLease: (actor: string, kind: IdLeaseKind) => Result<IdBlock, IdLeaseRefusal>;
|
|
1968
2921
|
readonly document: Document;
|
|
1969
2922
|
readonly headRev: number;
|
|
1970
2923
|
readonly broadcasts: readonly SequencedBatch[];
|
|
2924
|
+
/** The lease table to persist with the journal. */
|
|
2925
|
+
readonly idLeases: IdLeaseState;
|
|
1971
2926
|
};
|
|
1972
2927
|
type ClientNotice = {
|
|
1973
2928
|
opId: string;
|
|
1974
2929
|
reason: BatchRejection;
|
|
1975
2930
|
ops: readonly DocumentOp[];
|
|
1976
2931
|
};
|
|
2932
|
+
/**
|
|
2933
|
+
* How the optimistic `document` moved when the authority answered: applied in
|
|
2934
|
+
* order to the document before the answer, `batch.ops` give the one after it.
|
|
2935
|
+
* `rebased`: a foreign revision rebased over every pending local batch, or a
|
|
2936
|
+
* refused local batch's inverse rebased over the ones after it, so positions
|
|
2937
|
+
* and history can be transformed over it. `replaced`: a pending batch could not
|
|
2938
|
+
* be rebased, or the rebased change would not reach the replayed document, so
|
|
2939
|
+
* the change undoes every pending batch, applies what the authority sequenced
|
|
2940
|
+
* and replays the survivors; only the document is exact. When every pending
|
|
2941
|
+
* batch survived and the rebased change reaches a document with the same
|
|
2942
|
+
* paragraphs at the same lengths (the two differ only in how records are cut
|
|
2943
|
+
* or which tracked change holds some content), `moves` is that rebased
|
|
2944
|
+
* change: positions move over it exactly as over a `rebased` one.
|
|
2945
|
+
*/
|
|
2946
|
+
type ClientDocumentChange = {
|
|
2947
|
+
type: "rebased";
|
|
2948
|
+
batch: SequencedBatch;
|
|
2949
|
+
} | {
|
|
2950
|
+
type: "replaced";
|
|
2951
|
+
batch: SequencedBatch;
|
|
2952
|
+
moves?: SequencedBatch;
|
|
2953
|
+
};
|
|
1977
2954
|
/** Optimistic state with ordered authoritative replay and one causal submission in flight. */
|
|
1978
2955
|
export declare const createClient: (document: Document) => {
|
|
1979
2956
|
enqueue: (batch: DocumentBatch) => Result<DocumentBatch, BatchRejection>;
|
|
1980
2957
|
nextSubmission: () => DocumentBatch | undefined;
|
|
1981
2958
|
receiveAck: (ack: BatchAck) => void;
|
|
1982
|
-
receiveReject: (rejection: BatchReject) =>
|
|
1983
|
-
receiveBroadcast: (batch: SequencedBatch) => Result<
|
|
2959
|
+
receiveReject: (rejection: BatchReject) => readonly ClientDocumentChange[];
|
|
2960
|
+
receiveBroadcast: (batch: SequencedBatch) => Result<readonly ClientDocumentChange[], BatchRejection>;
|
|
1984
2961
|
readonly document: Document;
|
|
1985
2962
|
readonly headRev: number;
|
|
1986
2963
|
readonly pending: readonly DocumentBatch[];
|
|
1987
2964
|
readonly notices: readonly ClientNotice[];
|
|
1988
2965
|
};
|
|
2966
|
+
/** What an annotation adds: run formatting, or a comment's anchor. */
|
|
2967
|
+
export declare const BATCH_ANNOTATION_KINDS: Readonly<{
|
|
2968
|
+
FORMATTING: "formatting";
|
|
2969
|
+
COMMENT: "comment";
|
|
2970
|
+
}>;
|
|
2971
|
+
type BatchAnnotationKind = (typeof BATCH_ANNOTATION_KINDS)[keyof typeof BATCH_ANNOTATION_KINDS];
|
|
1989
2972
|
/**
|
|
1990
2973
|
* The execution coordinates of an operation resolved against a batch's
|
|
1991
2974
|
* pre-state. Positions and table coordinates are ordered from right to left;
|
|
@@ -1993,9 +2976,14 @@ export declare const createClient: (document: Document) => {
|
|
|
1993
2976
|
* Annotations run before moving edits, while table-shape and column edits run
|
|
1994
2977
|
* after ordinary content edits. Table mutations in nested tables still run
|
|
1995
2978
|
* right to left before the phase order is applied within the same table.
|
|
2979
|
+
*
|
|
2980
|
+
* Formatting moves no position, and a later write of a property replaces an
|
|
2981
|
+
* earlier one, so formatting annotations run first and in input order, as
|
|
2982
|
+
* one at a time; comment annotations follow them.
|
|
1996
2983
|
*/
|
|
1997
2984
|
type BatchOrderAddress = {
|
|
1998
2985
|
type: "annotation";
|
|
2986
|
+
kind: BatchAnnotationKind;
|
|
1999
2987
|
position: number;
|
|
2000
2988
|
inputIndex: number;
|
|
2001
2989
|
} | {
|
|
@@ -2039,6 +3027,40 @@ type BatchBlockAccess<Block> = {
|
|
|
2039
3027
|
/** Blocks the operation deletes, or merges into the block before them. */
|
|
2040
3028
|
removes: readonly Block[];
|
|
2041
3029
|
};
|
|
3030
|
+
/** A paragraph before a container's final paragraph, and whether the batch deletes it. */
|
|
3031
|
+
type FinalBreakCandidate<Paragraph> = {
|
|
3032
|
+
paragraph: Paragraph;
|
|
3033
|
+
deleted: boolean;
|
|
3034
|
+
};
|
|
3035
|
+
/**
|
|
3036
|
+
* Which paragraph settles the deletion of a container's final paragraph:
|
|
3037
|
+
*
|
|
3038
|
+
* - `kept`: the nearest one before it the batch keeps. The final paragraph
|
|
3039
|
+
* goes, and its break retires onto that one.
|
|
3040
|
+
* - `runStart`: the batch deletes every paragraph back to the container's
|
|
3041
|
+
* start or another block. The final paragraph stays, emptied, with the
|
|
3042
|
+
* properties of the run's first paragraph: applied right to left, the run
|
|
3043
|
+
* collapses into that one. One at a time, the final paragraph's deletion
|
|
3044
|
+
* runs while that paragraph still stands, and the paragraph's own deletion
|
|
3045
|
+
* follows it.
|
|
3046
|
+
* - `none`: no paragraph precedes it; it stays, emptied, as it is.
|
|
3047
|
+
*/
|
|
3048
|
+
type FinalBreakCarrier<Paragraph> = {
|
|
3049
|
+
type: "kept";
|
|
3050
|
+
paragraph: Paragraph;
|
|
3051
|
+
} | {
|
|
3052
|
+
type: "runStart";
|
|
3053
|
+
paragraph: Paragraph;
|
|
3054
|
+
} | {
|
|
3055
|
+
type: "none";
|
|
3056
|
+
};
|
|
3057
|
+
/**
|
|
3058
|
+
* The carrier of a deleted final paragraph's break, from the paragraphs
|
|
3059
|
+
* before it in its container, nearest first, up to the container's start or
|
|
3060
|
+
* another block. The engine's batch and the one-at-a-time replay both read
|
|
3061
|
+
* it from here, so they settle the deletion on the same paragraph.
|
|
3062
|
+
*/
|
|
3063
|
+
export declare const finalBreakCarrier: <Paragraph>(before: readonly FinalBreakCandidate<Paragraph>[]) => FinalBreakCarrier<Paragraph>;
|
|
2042
3064
|
/**
|
|
2043
3065
|
* Whether deleting a block takes it out of the document. A container (a
|
|
2044
3066
|
* story, cell, note or text box) has to end with a paragraph, so deleting its
|
|
@@ -2047,7 +3069,7 @@ type BatchBlockAccess<Block> = {
|
|
|
2047
3069
|
*/
|
|
2048
3070
|
export declare const deletionRemovesBlock: (deletion: {
|
|
2049
3071
|
endsContainer: boolean;
|
|
2050
|
-
|
|
3072
|
+
carrier: FinalBreakCarrier<unknown>["type"];
|
|
2051
3073
|
}) => boolean;
|
|
2052
3074
|
/**
|
|
2053
3075
|
* A batch equals its operations applied one at a time with every operation
|
|
@@ -2069,4 +3091,54 @@ export declare const orderAddressingBeforeRemoval: <T, Block>(ordered: readonly
|
|
|
2069
3091
|
* requested sequence, which no series of single edits produces.
|
|
2070
3092
|
*/
|
|
2071
3093
|
export declare const groupInsertionRuns: <T>(operations: readonly T[], insertionPositionOf: (operation: T) => number | null, keepsGap?: (operation: T) => boolean) => T[][];
|
|
2072
|
-
|
|
3094
|
+
/** A document with its changes resolved one way, and what could not be. */
|
|
3095
|
+
type ResolvedDocumentView = {
|
|
3096
|
+
document: Document;
|
|
3097
|
+
/**
|
|
3098
|
+
* The stories whose resolution refused, left as they were: a reader shows
|
|
3099
|
+
* them with their changes still in place and says so.
|
|
3100
|
+
*/
|
|
3101
|
+
unresolved: readonly OpStory[];
|
|
3102
|
+
};
|
|
3103
|
+
/**
|
|
3104
|
+
* `document` with every revision resolved by `decision`, story by story. A
|
|
3105
|
+
* story the resolution of an earlier one removed (a note whose every
|
|
3106
|
+
* reference went) is not read again.
|
|
3107
|
+
*/
|
|
3108
|
+
export declare const resolvedDocumentView: (document: Document, decision: RevisionDecision) => ResolvedDocumentView;
|
|
3109
|
+
type WholeParagraphReplacementOptions = {
|
|
3110
|
+
document: Document;
|
|
3111
|
+
from: TextPosition;
|
|
3112
|
+
to: TextPosition;
|
|
3113
|
+
/**
|
|
3114
|
+
* Who a suggesting replacement records, absent for a direct edit. A
|
|
3115
|
+
* suggestion retracts only its own pending insertions; a host with
|
|
3116
|
+
* another owner's stays with the ordinary range planner.
|
|
3117
|
+
*/
|
|
3118
|
+
suggesting?: RevisionOwner | undefined;
|
|
3119
|
+
};
|
|
3120
|
+
type WholeParagraphReplacementPlan = {
|
|
3121
|
+
blockIds: readonly string[];
|
|
3122
|
+
commentIds: ReadonlySet<number>;
|
|
3123
|
+
};
|
|
3124
|
+
/**
|
|
3125
|
+
* Whole source hosts before a surviving paragraph can retire through range
|
|
3126
|
+
* deletion and joins. Their complete comment ownership needs no alignment
|
|
3127
|
+
* inside a surviving host. Partial first hosts, section endpoints and pending
|
|
3128
|
+
* removals, moves or property changes in a host stay with the ordinary range
|
|
3129
|
+
* planner.
|
|
3130
|
+
*/
|
|
3131
|
+
export declare const planWholeParagraphReplacement: ({ document, from, to, suggesting }: WholeParagraphReplacementOptions) => Result<WholeParagraphReplacementPlan | null, DocumentOpRefusal>;
|
|
3132
|
+
type PreservedCommentRangeMarker = {
|
|
3133
|
+
type: "commentRangeStart" | "commentRangeEnd";
|
|
3134
|
+
id: number;
|
|
3135
|
+
};
|
|
3136
|
+
/** Read the boundaries before the named row or cell, in authored order. */
|
|
3137
|
+
export declare const preservedCommentRangeMarkersAt: (children: readonly PreservedChild[] | undefined, { at, childCount }: {
|
|
3138
|
+
at: number;
|
|
3139
|
+
childCount: number;
|
|
3140
|
+
}) => PreservedCommentRangeMarker[];
|
|
3141
|
+
export declare const storyBody: (document: Document, story: OpStory) => DocumentBody;
|
|
3142
|
+
export declare const findStoryBody: (document: Document, story: OpStory) => DocumentBody | undefined;
|
|
3143
|
+
export declare const sameStory: (left: OpStory, right: OpStory) => boolean;
|
|
3144
|
+
export type { AddNoteOp, AppliedDocumentOp, BatchAck, BatchAnnotationKind, BatchBlockAccess, BatchOrderAddress, BatchReject, BatchRejectionReason, BatchSubmission, BlockBoundary, BlockInsertionPoint, BoundaryOccurrence, ClientDocumentChange, ClientNotice, CommentAnchor, CommentExhaustionInput, CommentReferenceOffset, CommentState, CopyOriginAncestorList, CreateCommentOp, CreateHeaderFooterOp, CreateNumberingInstanceOp, DeleteBlocksOp, DeleteColumnOp, DeleteCommentOp, DeleteNumberingInstanceOp, DeleteRangeOp, DeleteRowOp, DeleteTableOp, DocumentBatch, DocumentOp, DocumentOpEnvelope, DocumentOpRefusalReason, DocumentOpType, EditorIntent, EditorIntentMode, EmptyPropertySet, ExclusivePart, FinalBreakCandidate, FinalBreakCarrier, FormattingPatch, HeaderFooterStory, IdBlock, IdLease, IdLeaseGrant, IdLeaseKind, IdLeaseMinted, IdLeaseRefusalReason, IdLeaseState, InlineSlice, InsertBlocksOp, InsertColumnOp, InsertContentOp, InsertRowOp, InsertTableOp, InsertTextOp, InsertedRunProps, JoinBlocksOp, JoinInlineOp, KeptCutPiece, LeasedId, LeasedIdCensus, MergeCellsOp, NewIds, NewListInstance, NoteStory, NumberingPartState, OpStory, PackageResourceEntry, PackageResourceEntryChange, PackageResourceMapChange, PackageResourceMedia, PackageResourcePart, PackageResources, ParagraphAbsorption, ParagraphContentVerdict, ParagraphPropsPatch, ParagraphReviewFields, PasteAnnotations, PlanTrackedDeletionOptions, PlanTrackedReplaceOptions, PreservedCommentRangeMarker, RecordedRevisionIds, RemoveHeaderFooterOp, RemoveNoteOp, ReplaceBlocksOp, ReplaceInlineOp, ResolveRevisionOp, ResolvedDocumentView, RestoreCommentStateOp, RestoreStoryPartsOp, RevisionAbsorption, RevisionDecision, RevisionStamp, RunPropsPatch, SectionEndpoint, SectionMapState, SectionPropertiesState, SectionViewEntry, SectionViewState, SequencedBatch, SequencerOptions, SetCellPropsOp, SetCommentResolutionOp, SetContainerBlocksOp, SetContentControlOp, SetPackageResourcesOp, SetParagraphPropsOp, SetParagraphReviewOp, SetRowPropsOp, SetRunPropsOp, SetSectionEndpointOp, SetSectionPropsOp, SetTableGridOp, SetTableOp, SetTablePropsOp, SetTableRowsOp, SplitBlockOp, SplitCellOp, SplitHalf, SplitInlineOp, SplitParagraphFields, StoryParts, TableBlockIntentOperation, TableEditOp, TableInsertionPoint, TableIntentOperation, TableRowIntentOperation, TextPosition, TouchedBlocks, UpdateCommentContentOp, VersionOneKept, VersionOneKeptMarkers, WellFormedRangePlan, ZeroWidthItem };
|