@docx4j/core-ts 0.2.1 → 0.3.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.
@@ -44,6 +44,54 @@ export type TrackedChangeTarget =
44
44
  owner: Element[];
45
45
  value: wml.CTTrackChange;
46
46
  inner: TrackedChange[];
47
+ }
48
+ /**
49
+ * Touching insertions, deletions or formatting changes by one author - `w:ins` or `w:del` around
50
+ * runs and inserted or deleted paragraph marks, or runs' `w:rPrChange`, with nothing unrevised
51
+ * between them - which Office JS lists as one change (CR-002 section 29, checks 22, 23 and 28): a
52
+ * deleted paragraph's text and mark, a deletion across a mark, bold put on two runs of different
53
+ * formatting. `pieces` are the single changes, in document order; `value` is the first's.
54
+ */
55
+ | {
56
+ kind: 'group';
57
+ revision: 'ins' | 'del' | 'format';
58
+ pieces: TrackedChange[];
59
+ value: wml.CTTrackChange;
60
+ }
61
+ /**
62
+ * A table's property records - `w:tblPrChange`, `w:tblGridChange`, `w:tblPrExChange`, and every
63
+ * `w:trPrChange` and `w:tcPrChange` in it - which Word writes as one set for one change and Office
64
+ * JS lists as one `Formatted` change (CR-002 section 35, checks 27 and 28). `value` is the table's
65
+ * record, else the first row's or cell's.
66
+ */
67
+ | {
68
+ kind: 'tableProperties';
69
+ tbl: Element<wml.Tbl>;
70
+ value: wml.CTTrackChange;
71
+ }
72
+ /** `w:tcPr/w:cellIns` or `w:tcPr/w:cellDel`: an inserted or deleted cell (section 35, check 27). */
73
+ | {
74
+ kind: 'cell';
75
+ cell: 'ins' | 'del';
76
+ tc: Element<wml.Tc>;
77
+ owner: Element[];
78
+ tr: wml.Tr;
79
+ value: wml.CTTrackChange;
80
+ }
81
+ /** `w:pPr/w:rPr/w:rPrChange`: a paragraph mark's formatting, which groups with its runs' (check 27). */
82
+ | {
83
+ kind: 'markProperties';
84
+ value: wml.ParaRPrChange;
85
+ }
86
+ /**
87
+ * `w:sectPr/w:sectPrChange`: a section's properties, at a paragraph's section break or the body's
88
+ * last section. `text` is the section's, as Office JS reports it (check 27: the text, then `\f`).
89
+ */
90
+ | {
91
+ kind: 'sectionProperties';
92
+ sectPr: wml.SectPr;
93
+ value: wml.CTSectPrChange;
94
+ text: string;
47
95
  };
48
96
  /**
49
97
  * A subset of Office JS `Word.TrackedChange`: `type`, `author`, `date`, `text`, `accept()`,
@@ -60,19 +108,29 @@ export declare class TrackedChange {
60
108
  /** Office JS `Word.ChangeTrackingState`. */
61
109
  get type(): TrackedChangeType;
62
110
  get author(): string;
63
- /** `w:date`, when the markup carries one. */
111
+ /**
112
+ * When the change was made: `w16du:dateUtc` if the markup has it, else `w:date` read as Word writes
113
+ * it, local wall-clock time (`revisionDateOf`, CR-002 section 29); a group's is its first piece's,
114
+ * as Office JS reports it.
115
+ */
64
116
  get date(): Date | undefined;
65
117
  /** The annotation id (`w:id`; an extension). */
66
118
  get id(): number;
67
119
  /** The markup this change is over (an extension): the `w:ins` element, the `w:rPrChange`, ... */
68
120
  get element(): object;
69
- /** The text the change covers; '' for a paragraph mark, whose range is the paragraph. */
121
+ /** The text the change covers; `\r` for a paragraph mark, as Office JS gives it (check 22). */
70
122
  get text(): string;
71
123
  /** The range the change covers; a deletion is a collapsed range where it sits in the accepted text. */
72
124
  getRange(): Range | undefined;
73
- /** Keeps the change: a `w:ins` is unwrapped, a `w:del` removed, a deleted mark joins the paragraphs. */
125
+ /**
126
+ * Keeps the change: a `w:ins` is unwrapped, a `w:del` removed, a deleted mark joins the paragraphs.
127
+ * Either half of a move keeps the whole move, as Word's Review tab does (CR-002 section 29).
128
+ */
74
129
  accept(): void;
75
- /** Puts back what was there: a `w:ins` is removed, a `w:del` restored, a `w:rPrChange` re-applied. */
130
+ /**
131
+ * Puts back what was there: a `w:ins` is removed, a `w:del` restored, a `w:rPrChange` re-applied.
132
+ * Either half of a move rejects the whole move, as Word's Review tab does (CR-002 section 29).
133
+ */
76
134
  reject(): void;
77
135
  private requireParagraph;
78
136
  }
@@ -86,11 +144,50 @@ export declare class TrackedChange {
86
144
  * with: the paragraph then goes, its content joining the one before. With neither neighbour the
87
145
  * mark is simply dropped.
88
146
  */
89
- export declare function joinWithNext(paragraph: Paragraph, fallbackToPrevious?: boolean): void;
90
- /** The tracked changes of one paragraph, in document order. */
147
+ export declare function joinWithNext(paragraph: Pick<Paragraph, 'container' | 'element' | 'p'>, fallbackToPrevious?: boolean): void;
148
+ /**
149
+ * The tracked changes of one paragraph, in document order, touching pieces grouped as Office JS
150
+ * groups them (`groupTouching`). Office JS lists the changes that start in the paragraph (check 22):
151
+ * pieces that carry on a change from the paragraph before - its inserted or deleted mark - are left
152
+ * to that paragraph, and a change running on into the next is cut at this paragraph's end.
153
+ */
91
154
  export declare function trackedChangesOfParagraph(paragraph: Paragraph): TrackedChange[];
155
+ /** Between two tracked changes: something unrevised - text, a paragraph mark, a table - that keeps them apart. */
156
+ export declare const BREAK: "break";
157
+ export type TrackedChangeToken = TrackedChange | typeof BREAK;
158
+ /**
159
+ * A paragraph's single changes in document order, its mark last, with a `BREAK` wherever unrevised
160
+ * content stands between two of them: `groupTouching` makes the groups from these.
161
+ */
162
+ export declare function trackedChangeTokensOfParagraph(paragraph: Paragraph): TrackedChangeToken[];
163
+ /**
164
+ * Tokens made into the changes Office JS lists: consecutive pieces of one kind (inserted, deleted, or
165
+ * a run's formatting) by one author, nothing unrevised between them, are one change (checks 22, 23
166
+ * and 28: text and marks alike, dates regardless, formatting whatever it recorded; another author, or
167
+ * one kind against another, starts a new one). A change that does not group - a paragraph's
168
+ * properties, a move - is listed where it stands and does not break a group. A group of one piece is
169
+ * that piece.
170
+ */
171
+ export declare function groupTouching(tokens: TrackedChangeToken[]): TrackedChange[];
92
172
  /**
93
173
  * The `w:trPr/w:ins` and `w:trPr/w:del` revisions of a table row. `inner` is the revision markup
94
174
  * of the row's own cells, which the row's change owns rather than reporting separately.
95
175
  */
96
176
  export declare function trackedChangesOfRow(tr: Element<wml.Tr>, owner: Element[], inner?: TrackedChange[]): TrackedChange[];
177
+ /** The change a table's property records make, one per table, or undefined when they make none. */
178
+ export declare function tablePropertiesChangeOf(tbl: Element<wml.Tbl>): TrackedChange | undefined;
179
+ /** A cell's own revision, `w:cellIns` or `w:cellDel`, or undefined. */
180
+ export declare function cellChangeOf(tc: Element<wml.Tc>, owner: Element[], tr: wml.Tr): TrackedChange | undefined;
181
+ /** The change to the body's last section (`w:body/w:sectPr/w:sectPrChange`), its text the section's paragraphs'. */
182
+ export declare function bodySectionChangeOf(container: {
183
+ content?: Element[];
184
+ sectPr?: wml.SectPr;
185
+ }): TrackedChange | undefined;
186
+ /**
187
+ * What `acceptAll` and `rejectAll` resolve that is never listed: a `w:cellMerge`, which Office JS
188
+ * cannot list (check 27: `getTrackedChanges` throws); a `w:numberingChange`, which Word no longer
189
+ * writes and drops when one is put in, and whose record is the old number's text, so that a reject
190
+ * too can only drop it; and a table's records that change nothing. A merge rejected gets the merge it
191
+ * recorded back (docx4j's reading; unmeasured).
192
+ */
193
+ export declare function resolveUnlisted(items: Element[], what: 'accept' | 'reject'): void;