@docx4j/core-ts 0.3.2 → 0.5.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/README.md +8 -3
- package/dist/html/convert.d.mts +116 -0
- package/dist/html/convert.mjs +565 -0
- package/dist/html/elements.d.mts +19 -0
- package/dist/html/elements.mjs +182 -0
- package/dist/html/index.d.mts +2 -0
- package/dist/html/index.mjs +4 -0
- package/dist/model/content/Body.d.mts +13 -1
- package/dist/model/content/Body.mjs +97 -19
- package/dist/model/content/Comment.mjs +7 -0
- package/dist/model/content/InlinePicture.d.mts +89 -10
- package/dist/model/content/InlinePicture.mjs +245 -35
- package/dist/model/content/List.mjs +10 -1
- package/dist/model/content/Paragraph.d.mts +28 -5
- package/dist/model/content/Paragraph.mjs +77 -37
- package/dist/model/content/Range.d.mts +18 -2
- package/dist/model/content/Range.mjs +194 -64
- package/dist/model/content/Table.d.mts +38 -0
- package/dist/model/content/Table.mjs +80 -2
- package/dist/model/content/TrackedChange.d.mts +129 -3
- package/dist/model/content/TrackedChange.mjs +577 -12
- package/dist/model/content/binder.d.mts +2 -1
- package/dist/model/content/binder.mjs +48 -1
- package/dist/model/content/index.d.mts +4 -3
- package/dist/model/content/index.mjs +3 -2
- package/dist/model/content/relationships.d.mts +30 -0
- package/dist/model/content/relationships.mjs +133 -0
- package/dist/model/content/stylesFacade.d.mts +4 -2
- package/dist/model/content/stylesFacade.mjs +20 -6
- package/dist/model/content/tableColumns.d.mts +48 -0
- package/dist/model/content/tableColumns.mjs +484 -0
- package/dist/model/content/tree.d.mts +52 -2
- package/dist/model/content/tree.mjs +48 -3
- package/dist/model/customxml/CustomXmlPartCollection.d.mts +6 -1
- package/dist/model/customxml/CustomXmlPartCollection.mjs +19 -3
- package/dist/model/customxml/bindings.d.mts +5 -2
- package/dist/model/customxml/bindings.mjs +21 -6
- package/dist/model/customxml/index.d.mts +3 -0
- package/dist/model/customxml/index.mjs +3 -0
- package/dist/model/customxml/opendope.d.mts +32 -0
- package/dist/model/customxml/opendope.mjs +56 -0
- package/dist/model/customxml/pictures.d.mts +57 -0
- package/dist/model/customxml/pictures.mjs +192 -0
- package/dist/model/customxml/xhtml.d.mts +42 -0
- package/dist/model/customxml/xhtml.mjs +162 -0
- package/dist/model/fonts/families.generated.mjs +2 -2
- package/dist/model/fonts/registry.mjs +7 -1
- package/dist/model/fonts/substitutions.generated.mjs +2 -2
- package/dist/model/fonts/themes.generated.mjs +1 -1
- package/dist/model/listnumbering/definitions.mjs +18 -0
- package/dist/model/properties/PropertyResolver.d.mts +27 -6
- package/dist/model/properties/PropertyResolver.mjs +83 -16
- package/dist/model/properties/catalogue.d.mts +15 -1
- package/dist/model/properties/catalogue.mjs +80 -27
- package/dist/model/properties/table.d.mts +16 -2
- package/dist/model/properties/table.mjs +13 -3
- package/dist/opc/Load.d.mts +9 -2
- package/dist/opc/index.d.mts +2 -2
- package/dist/opc/index.mjs +2 -2
- package/dist/opc/mce/preprocessor.d.mts +62 -6
- package/dist/opc/mce/preprocessor.mjs +142 -35
- package/dist/opc/mce/understood.d.mts +10 -0
- package/dist/opc/mce/understood.mjs +25 -3
- package/dist/packages/OpcPackage.d.mts +7 -0
- package/dist/packages/OpcPackage.mjs +15 -3
- package/dist/packages/WordprocessingMLPackage.d.mts +35 -2
- package/dist/packages/WordprocessingMLPackage.mjs +99 -2
- package/dist/parts/XmlPart.d.mts +26 -5
- package/dist/parts/XmlPart.mjs +67 -18
- package/dist/parts/wml/knownStyles.d.mts +1 -0
- package/dist/parts/wml/knownStyles.mjs +2233 -0
- package/package.json +7 -2
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type * as math from '@docx4j/generated-objects-ts/modules/org_docx4j_math';
|
|
2
3
|
import { type Element, type Located, type RevisionKind } from './tree.mjs';
|
|
3
4
|
import { Range } from './Range.mjs';
|
|
4
5
|
import type { Paragraph } from './Paragraph.mjs';
|
|
6
|
+
import type { Body } from './Body.mjs';
|
|
7
|
+
import type { Part } from '../../parts/Part.mjs';
|
|
8
|
+
import { type RelationshipRemovals } from './relationships.mjs';
|
|
5
9
|
/** Office JS `Word.ChangeTrackingState` (`Unknown` is not produced here). */
|
|
6
10
|
export type TrackedChangeType = 'Added' | 'Deleted' | 'Formatted' | 'None' | 'Unknown';
|
|
7
11
|
/** Which piece of revision markup a `TrackedChange` is over (an extension: Office JS has no such member). */
|
|
@@ -112,6 +116,51 @@ export type TrackedChangeTarget =
|
|
|
112
116
|
outer: [Element, Element];
|
|
113
117
|
inner: [Element, Element];
|
|
114
118
|
value: wml.CTTrackChange;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* A field Word inserted under tracking, in its own form: a `w:ins` around the field's begin and
|
|
122
|
+
* instruction runs and another around its end, the separator and the result between them plain
|
|
123
|
+
* (check 30, `field-inserted`). Office JS lists it as one `Added` change whose text is the result's,
|
|
124
|
+
* and Word's Reject All took the whole field away, the result with it (CR-002 section 44). `span` is
|
|
125
|
+
* the items of `owner` from the first `w:ins` to the last.
|
|
126
|
+
*/
|
|
127
|
+
| {
|
|
128
|
+
kind: 'field';
|
|
129
|
+
span: Element[];
|
|
130
|
+
owner: Element[];
|
|
131
|
+
value: wml.CTTrackChange;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* A `w:ins` or `w:del` inside an `m:r`, which is where Word writes an equation's text inserted or
|
|
135
|
+
* deleted (`m:r` > `w:ins` > `m:rPr`, `w:rPr`, `m:t`; docx4j's `tracked-changes-equations.docx`).
|
|
136
|
+
* `item` is the `w:ins` or `w:del` in the run's content, `run` the `m:r` and `runOwner` its list.
|
|
137
|
+
* Kept, its content takes its place in the run; not kept, it goes, and a run left with no text with it
|
|
138
|
+
* (CR-002 section 51). `equation` is the `m:oMath` or `m:oMathPara` in the paragraph that holds it.
|
|
139
|
+
*/
|
|
140
|
+
| {
|
|
141
|
+
kind: 'mathRun';
|
|
142
|
+
revision: 'ins' | 'del';
|
|
143
|
+
item: Element;
|
|
144
|
+
run: Element<math.CTR>;
|
|
145
|
+
runOwner: Element[];
|
|
146
|
+
value: wml.CTMathRunTrackChange;
|
|
147
|
+
equation?: Element;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* A `w:ins` or `w:del` in an equation structure's `m:ctrlPr`, Word's mark of an `m:sSup`, an `m:acc`,
|
|
151
|
+
* ... inserted or deleted as a whole. `structure` is that element and `owner` its list, two up from
|
|
152
|
+
* the `m:ctrlPr`; undefined for an argument's own `m:ctrlPr` (an `m:e`'s), which marks no structure.
|
|
153
|
+
* Kept, the marker goes and the run properties it recorded become the control's; not kept, the
|
|
154
|
+
* structure goes whole, as Word's Accept All and Reject All did (CR-002 section 51).
|
|
155
|
+
*/
|
|
156
|
+
| {
|
|
157
|
+
kind: 'mathStructure';
|
|
158
|
+
revision: 'ins' | 'del';
|
|
159
|
+
ctrlPr: math.CTCtrlPr;
|
|
160
|
+
structure?: Element;
|
|
161
|
+
owner?: Element[];
|
|
162
|
+
value: wml.CTRPrChange;
|
|
163
|
+
equation?: Element;
|
|
115
164
|
};
|
|
116
165
|
/**
|
|
117
166
|
* A subset of Office JS `Word.TrackedChange`: `type`, `author`, `date`, `text`, `accept()`,
|
|
@@ -122,9 +171,13 @@ export declare class TrackedChange {
|
|
|
122
171
|
readonly target: TrackedChangeTarget;
|
|
123
172
|
/** The paragraph the change is in; undefined for a row revision. */
|
|
124
173
|
readonly paragraph: Paragraph | undefined;
|
|
174
|
+
/** The body a change without a paragraph (a row, a cell) is in, for the notes it may take away. */
|
|
175
|
+
readonly body?: Body | undefined;
|
|
125
176
|
constructor(target: TrackedChangeTarget,
|
|
126
177
|
/** The paragraph the change is in; undefined for a row revision. */
|
|
127
|
-
paragraph: Paragraph | undefined
|
|
178
|
+
paragraph: Paragraph | undefined,
|
|
179
|
+
/** The body a change without a paragraph (a row, a cell) is in, for the notes it may take away. */
|
|
180
|
+
body?: Body | undefined);
|
|
128
181
|
/** Office JS `Word.ChangeTrackingState`. */
|
|
129
182
|
get type(): TrackedChangeType;
|
|
130
183
|
get author(): string;
|
|
@@ -147,13 +200,76 @@ export declare class TrackedChange {
|
|
|
147
200
|
* Either half of a move keeps the whole move, as Word's Review tab does (CR-002 section 29).
|
|
148
201
|
*/
|
|
149
202
|
accept(): void;
|
|
203
|
+
private acceptHere;
|
|
150
204
|
/**
|
|
151
205
|
* Puts back what was there: a `w:ins` is removed, a `w:del` restored, a `w:rPrChange` re-applied.
|
|
152
206
|
* Either half of a move rejects the whole move, as Word's Review tab does (CR-002 section 29).
|
|
153
207
|
*/
|
|
154
208
|
reject(): void;
|
|
209
|
+
private rejectHere;
|
|
210
|
+
/** The body the change is in. */
|
|
211
|
+
private get body_();
|
|
212
|
+
/** The package the change is in, which keeps the notes whose references it took away. */
|
|
213
|
+
private get package_();
|
|
155
214
|
private requireParagraph;
|
|
156
215
|
}
|
|
216
|
+
/** The ids of the footnotes and endnotes whose references removed content took with it. */
|
|
217
|
+
export interface NoteRemovals {
|
|
218
|
+
footnote: Set<number>;
|
|
219
|
+
endnote: Set<number>;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Runs `resolve`, then takes away what went with the content it removed:
|
|
223
|
+
* - **Notes**: Word took a footnote from the notes part when its reference went with the content
|
|
224
|
+
* around it, accepting a deletion and rejecting an insertion alike (the editor's `review-for-word`
|
|
225
|
+
* saves, Word 15 and Word 2010); the entries go when the package is saved
|
|
226
|
+
* (`WordprocessingMLPackage.pendingNoteRemovals`).
|
|
227
|
+
* - **Bookmarks**: Word removed a bookmark whole when its end went with a deletion it accepted, and
|
|
228
|
+
* when the insertion it was put around went with a reject (docx4j CR-043's probe, C11 and C11b, Word
|
|
229
|
+
* 16.0.20326). docx4j's rule from the two (its CR-043 section 3.2) is followed here: a bookmark with a
|
|
230
|
+
* marker in removed content goes whole, its other marker too, even with content left beside it; so
|
|
231
|
+
* does one with content between its markers that is left with none, a deletion it was around accepted
|
|
232
|
+
* among them (U15); and one that was empty before, as `_GoBack` is, stays. Those three are not measured.
|
|
233
|
+
* - **Relationships and parts**: Word's saves kept no part the resolved content alone referenced. A
|
|
234
|
+
* picture deleted and accepted, or inserted and rejected, took its image part (docx4j CR-043's probe,
|
|
235
|
+
* C05 and C04), and a section break deleted and accepted took the headers and footers of the section
|
|
236
|
+
* it ended (C06: six of each became three). docx4j's rule (its CR-043 section 3.2, D7) is followed: a
|
|
237
|
+
* relationship of the change's part that the removed content referenced, through any `r:` attribute,
|
|
238
|
+
* goes when nothing left in the part references it; its part goes when no relationship in the package
|
|
239
|
+
* targets it any more, and what that part alone related to goes with it. The kinds beyond pictures,
|
|
240
|
+
* headers and footers (charts, OLE objects, `v:imagedata`) are docx4j's reading, not measured.
|
|
241
|
+
* A change resolved inside another's (a row's cells, a group's pieces, `acceptAll`'s changes) shares the
|
|
242
|
+
* outer resolution, so the bookmarks are read twice for the lot, and not at all when nothing is removed.
|
|
243
|
+
*/
|
|
244
|
+
export declare function resolving(pkg: unknown, body: Body | undefined, resolve: () => void): void;
|
|
245
|
+
/** What `flushPendingNoteRemovals` needs of the main document part. */
|
|
246
|
+
interface NotesHost {
|
|
247
|
+
getContents(): Promise<unknown>;
|
|
248
|
+
footnotesPart?: Part & {
|
|
249
|
+
getContents(): Promise<wml.CTFootnotes>;
|
|
250
|
+
};
|
|
251
|
+
endnotesPart?: Part & {
|
|
252
|
+
getContents(): Promise<wml.CTEndnotes>;
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
/** Where a removed note's own content goes on to: the package's queues (`WordprocessingMLPackage`). */
|
|
256
|
+
interface NoteRemovalHost {
|
|
257
|
+
pendingCommentRemovals?: Set<number>;
|
|
258
|
+
pendingRelationshipRemovals?: RelationshipRemovals;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* The notes `pending` holds taken out of the notes parts, each unless a reference to it still stands in
|
|
262
|
+
* the main document (an accepted move keeps the reference its source had, say); then `pending` is
|
|
263
|
+
* empty. A note's entry goes, Word's separators never: their ids are never referenced. The notes parts
|
|
264
|
+
* are read only when something is pending, so a save with none leaves them untouched. Word's own save
|
|
265
|
+
* also renumbers the notes left (the editor's `review-for-word` saves); their ids stay here.
|
|
266
|
+
*
|
|
267
|
+
* What a removed note held goes on with it, as docx4j's `Removals.flush` takes it (CR-002 section 50,
|
|
268
|
+
* docx4j's reading, not measured): the relationships its content referenced (a picture's image) are
|
|
269
|
+
* queued on `host` for the notes part, to go when nothing else uses them, and a comment whose reference
|
|
270
|
+
* was in it is queued for removal, its anchor being gone.
|
|
271
|
+
*/
|
|
272
|
+
export declare function flushPendingNoteRemovals(main: NotesHost, pending: NoteRemovals, host?: NoteRemovalHost): Promise<void>;
|
|
157
273
|
/**
|
|
158
274
|
* The insertion of a content control or custom XML element, when `items[i]` is a
|
|
159
275
|
* `w:customXmlInsRangeStart` and what follows is Word's form for one (check 30): the element, whose
|
|
@@ -161,6 +277,15 @@ export declare class TrackedChange {
|
|
|
161
277
|
* one's end right after the element. Anything else is not one (a marker on its own is left alone).
|
|
162
278
|
*/
|
|
163
279
|
export declare function holderInsertionAt(items: Element[], i: number, paragraph: Paragraph | undefined): TrackedChange | undefined;
|
|
280
|
+
/**
|
|
281
|
+
* Word's form for a field inserted under tracking, when `items[i]` starts it: a `w:ins` that opens a
|
|
282
|
+
* field (a `w:fldChar` begin it does not end), then plain runs - the separator and the result - and
|
|
283
|
+
* markers, then a `w:ins` by the same author in which that field ends (check 30, `field-inserted`:
|
|
284
|
+
* begin and instruction in one, the end run in the other). Another revision, a run whose formatting
|
|
285
|
+
* changed, a run holder, or a field that ends in a plain run is not this form, and is listed as before.
|
|
286
|
+
* A field wholly inside one `w:ins` needs nothing of this: that `w:ins` already takes it whole.
|
|
287
|
+
*/
|
|
288
|
+
export declare function insertedFieldAt(items: Element[], i: number, paragraph: Paragraph | undefined): TrackedChange | undefined;
|
|
164
289
|
/**
|
|
165
290
|
* docx4j AcceptTrackedChanges: the paragraph takes the next one's content and properties, so the
|
|
166
291
|
* mark that survives is the next one's. Called when a deleted mark is accepted and when an
|
|
@@ -200,11 +325,11 @@ export declare function groupTouching(tokens: TrackedChangeToken[]): TrackedChan
|
|
|
200
325
|
* The `w:trPr/w:ins` and `w:trPr/w:del` revisions of a table row. `inner` is the revision markup
|
|
201
326
|
* of the row's own cells, which the row's change owns rather than reporting separately.
|
|
202
327
|
*/
|
|
203
|
-
export declare function trackedChangesOfRow(tr: Element<wml.Tr>, owner: Element[], inner?: TrackedChange[], table?: Located<wml.Tbl
|
|
328
|
+
export declare function trackedChangesOfRow(tr: Element<wml.Tr>, owner: Element[], inner?: TrackedChange[], table?: Located<wml.Tbl>, body?: Body): TrackedChange[];
|
|
204
329
|
/** The change a table's property records make, one per table, or undefined when they make none. */
|
|
205
330
|
export declare function tablePropertiesChangeOf(tbl: Element<wml.Tbl>): TrackedChange | undefined;
|
|
206
331
|
/** A cell's own revision, `w:cellIns` or `w:cellDel`, or undefined. */
|
|
207
|
-
export declare function cellChangeOf(tc: Element<wml.Tc>, owner: Element[], tr: wml.Tr): TrackedChange | undefined;
|
|
332
|
+
export declare function cellChangeOf(tc: Element<wml.Tc>, owner: Element[], tr: wml.Tr, body?: Body): TrackedChange | undefined;
|
|
208
333
|
/** The change to the body's last section (`w:body/w:sectPr/w:sectPrChange`), its text the section's paragraphs'. */
|
|
209
334
|
export declare function bodySectionChangeOf(container: {
|
|
210
335
|
content?: Element[];
|
|
@@ -219,3 +344,4 @@ export declare function bodySectionChangeOf(container: {
|
|
|
219
344
|
* the form `holderInsertionAt` lists marks nothing that can be found, and goes either way.
|
|
220
345
|
*/
|
|
221
346
|
export declare function resolveUnlisted(items: Element[], what: 'accept' | 'reject'): void;
|
|
347
|
+
export {};
|