@arbidocs/coedit 0.4.111 → 0.4.112
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/commands.cjs +687 -0
- package/dist/commands.cjs.map +1 -1
- package/dist/commands.d.cts +263 -157
- package/dist/commands.d.ts +263 -157
- package/dist/commands.js +646 -2
- package/dist/commands.js.map +1 -1
- package/dist/port-ip7WByvH.d.cts +188 -0
- package/dist/port-ip7WByvH.d.ts +188 -0
- package/dist/server.cjs +675 -65
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +15 -4
- package/dist/server.d.ts +15 -4
- package/dist/server.js +676 -67
- package/dist/server.js.map +1 -1
- package/dist/template.d.cts +3 -17
- package/dist/template.d.ts +3 -17
- package/dist/track-eYC94jTp.d.cts +17 -0
- package/dist/track-eYC94jTp.d.ts +17 -0
- package/package.json +1 -1
package/dist/commands.d.cts
CHANGED
|
@@ -1,163 +1,21 @@
|
|
|
1
|
+
import { g as DocParagraph, k as ListItemInfo, j as LevelOf, R as ReferencesPort, a as CrossReferenceTarget, h as DocPoint, O as OoxmlNodeLike, b as DefinitionsPort, i as DocumentNumbering } from './port-ip7WByvH.cjs';
|
|
2
|
+
export { B as BROKEN_CROSS_REFERENCE_STYLE, C as CROSS_REFERENCE_STYLE, D as DEFINED_TERM_STYLE, c as DocField, d as DocLink, e as DocMark, f as DocNote, F as FIELD_ATOM, L as LevelInfo, N as NumberingSource, W as WATCHED_STYLES, l as documentNumbering, m as filterTargets, n as listTargets, p as paragraphNumber, r as readParagraphs, s as styleNames } from './port-ip7WByvH.cjs';
|
|
1
3
|
import { OoxmlProperty, TabStopWrite, TreeDocOp } from '@docx-editor.dev/core/store';
|
|
4
|
+
import { R as Revision } from './track-eYC94jTp.cjs';
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
|
-
*
|
|
5
|
-
* (text in the engine's offset vocabulary, bookmarks, internal links, fields, note references),
|
|
6
|
-
* read from the engine's OOXML tree. The same tree comes from a live editor
|
|
7
|
-
* (`surface.session.part().root`) or from document bytes (`openHeadlessDocument`), so the toolbar
|
|
8
|
-
* and ARBI's headless tools read a document the same way.
|
|
9
|
-
*/
|
|
10
|
-
/** Character style of an inserted term: a dotted underline, so a defined term reads as one. */
|
|
11
|
-
declare const DEFINED_TERM_STYLE = "DefinedTerm";
|
|
12
|
-
/** Character style of a cross-reference: a muted blue with a dotted underline (Word's name). */
|
|
13
|
-
declare const CROSS_REFERENCE_STYLE = "CrossReference";
|
|
14
|
-
/** Character style of a cross-reference whose target is gone: its last text, flagged. */
|
|
15
|
-
declare const BROKEN_CROSS_REFERENCE_STYLE = "CrossReferenceBroken";
|
|
16
|
-
/** A position: a paragraph (the engine's node id) and a UTF-16 offset into its text. */
|
|
17
|
-
interface DocPoint {
|
|
18
|
-
paragraphId: string;
|
|
19
|
-
offset: number;
|
|
20
|
-
}
|
|
21
|
-
/** An internal link in a paragraph. */
|
|
22
|
-
interface DocLink {
|
|
23
|
-
anchor: string;
|
|
24
|
-
text: string;
|
|
25
|
-
/** Where its text starts in the paragraph's text. */
|
|
26
|
-
offset?: number;
|
|
27
|
-
}
|
|
28
|
-
/** A footnote or endnote reference: one character of the paragraph, as the engine counts it. */
|
|
29
|
-
interface DocNote {
|
|
30
|
-
offset: number;
|
|
31
|
-
kind: 'footnote' | 'endnote';
|
|
32
|
-
/** `w:id` of the note. */
|
|
33
|
-
id: string;
|
|
34
|
-
}
|
|
35
|
-
/** One paragraph, in document order. */
|
|
36
|
-
interface DocParagraph {
|
|
37
|
-
id: string;
|
|
38
|
-
/** `w14:paraId`, the id that is the same in every replica of a collaboration room. */
|
|
39
|
-
paraId?: string;
|
|
40
|
-
text: string;
|
|
41
|
-
/** Styled as a heading (a `Heading n` style or an outline level). */
|
|
42
|
-
heading: boolean;
|
|
43
|
-
styleId?: string;
|
|
44
|
-
/** A paragraph of the body itself, not inside a table. */
|
|
45
|
-
topLevel: boolean;
|
|
46
|
-
/** Names of the bookmarks that start in it. */
|
|
47
|
-
bookmarks: string[];
|
|
48
|
-
/** Its internal links (`w:hyperlink w:anchor`). */
|
|
49
|
-
links: DocLink[];
|
|
50
|
-
/** Its complex fields: where each sits (its one-character offset), its instruction and result. */
|
|
51
|
-
fields?: DocField[];
|
|
52
|
-
/** Its runs in a watched character style (a broken cross-reference's mark), with their text. */
|
|
53
|
-
marks?: DocMark[];
|
|
54
|
-
/** Its footnote and endnote references. */
|
|
55
|
-
notes?: DocNote[];
|
|
56
|
-
}
|
|
57
|
-
/** A stretch of a paragraph's text in a watched character style. */
|
|
58
|
-
interface DocMark {
|
|
59
|
-
styleId: string;
|
|
60
|
-
offset: number;
|
|
61
|
-
text: string;
|
|
62
|
-
}
|
|
63
|
-
/** Character styles whose runs a paragraph read reports as marks. */
|
|
64
|
-
declare const WATCHED_STYLES: Set<string>;
|
|
65
|
-
/** A complex field of a paragraph. */
|
|
66
|
-
interface DocField {
|
|
67
|
-
offset: number;
|
|
68
|
-
instruction: string;
|
|
69
|
-
result: string;
|
|
70
|
-
}
|
|
71
|
-
type OoxmlNodeLike = {
|
|
72
|
-
id: string;
|
|
73
|
-
kind: string;
|
|
74
|
-
localName?: string;
|
|
75
|
-
value?: string;
|
|
76
|
-
attributes?: readonly {
|
|
77
|
-
localName: string;
|
|
78
|
-
value: string;
|
|
79
|
-
}[];
|
|
80
|
-
children?: readonly OoxmlNodeLike[];
|
|
81
|
-
};
|
|
82
|
-
/** How a field (or a note reference) counts in a paragraph's text (the engine's model vocabulary). */
|
|
83
|
-
declare const FIELD_ATOM = "\uFFFC";
|
|
84
|
-
/** The paragraphs of a part's body, read from the engine's OOXML tree. */
|
|
85
|
-
declare function readParagraphs(root: OoxmlNodeLike): DocParagraph[];
|
|
86
|
-
/** Style id to style name (`Heading1` → `heading 1`), from a styles part's tree. */
|
|
87
|
-
declare function styleNames(root: OoxmlNodeLike | null | undefined): Map<string, string>;
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Cross-reference targets: the document's numbered paragraphs (clauses, sub-clauses, numbered
|
|
91
|
-
* captions) and its headings, with the number Word's `REF \r` shows for each.
|
|
7
|
+
* Cross-references, the way Word does them, and their status.
|
|
92
8
|
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
numId: string;
|
|
104
|
-
ilvl: number;
|
|
105
|
-
markerText: string;
|
|
106
|
-
numFmt: string;
|
|
107
|
-
}
|
|
108
|
-
/** A list level's definition: its level text (`%1.%2`) and number format. */
|
|
109
|
-
interface LevelInfo {
|
|
110
|
-
lvlText: string;
|
|
111
|
-
numFmt: string;
|
|
112
|
-
}
|
|
113
|
-
type LevelOf = (numId: string, ilvl: number) => LevelInfo | null;
|
|
114
|
-
/**
|
|
115
|
-
* The number `REF \r` shows for a paragraph, or null when it is not numbered. `order` is every
|
|
116
|
-
* paragraph id in document order (for the markers of the levels above it).
|
|
117
|
-
*/
|
|
118
|
-
declare function paragraphNumber(order: readonly string[], items: ReadonlyMap<string, ListItemInfo>, levelOf: LevelOf, paragraphId: string): string | null;
|
|
119
|
-
/** One place a cross-reference can point at. */
|
|
120
|
-
interface CrossReferenceTarget {
|
|
121
|
-
paragraphId: string;
|
|
122
|
-
/** A numbered paragraph (clause, sub-clause, caption) or an unnumbered heading. */
|
|
123
|
-
kind: 'numbered' | 'heading';
|
|
124
|
-
/** What `REF \r` shows (`8.2`), or null for an unnumbered heading. */
|
|
125
|
-
number: string | null;
|
|
126
|
-
/** The paragraph's list marker as painted (`8.2`, `(a)`), or empty. */
|
|
127
|
-
marker: string;
|
|
128
|
-
/** The paragraph's text (without its marker). */
|
|
129
|
-
text: string;
|
|
130
|
-
heading: boolean;
|
|
131
|
-
/** Its list level (0 for a top-level clause), or 0 for a heading. */
|
|
132
|
-
level: number;
|
|
133
|
-
}
|
|
134
|
-
/** Every numbered paragraph and every heading, in document order. */
|
|
135
|
-
declare function listTargets(paragraphs: readonly DocParagraph[], items: ReadonlyMap<string, ListItemInfo>, levelOf: LevelOf): CrossReferenceTarget[];
|
|
136
|
-
/** Targets whose number or text contains the query (case-insensitive). */
|
|
137
|
-
declare function filterTargets(targets: readonly CrossReferenceTarget[], query: string): CrossReferenceTarget[];
|
|
138
|
-
/** What the engine's numbering needs of a document: its parts' trees. */
|
|
139
|
-
interface NumberingSource {
|
|
140
|
-
/** The main document part's root. */
|
|
141
|
-
root(): OoxmlNodeLike;
|
|
142
|
-
stylesRoot(): unknown;
|
|
143
|
-
numberingRoot(): unknown;
|
|
144
|
-
settingsRoot(): unknown;
|
|
145
|
-
}
|
|
146
|
-
/** A document's list numbering as the engine resolves it. */
|
|
147
|
-
interface DocumentNumbering {
|
|
148
|
-
/** Each numbered paragraph's list item, by paragraph (node) id. */
|
|
149
|
-
listItems(): ReadonlyMap<string, ListItemInfo>;
|
|
150
|
-
levelOf: LevelOf;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* The numbering of a document, as the editor paints it: from a live editor's session or from a
|
|
154
|
-
* headless document view alike.
|
|
155
|
-
*/
|
|
156
|
-
declare function documentNumbering(source: NumberingSource): DocumentNumbering;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* The cross-references of a document (`REF` fields to `_Ref` bookmarks), each with what it shows
|
|
160
|
-
* and what its target now is: current, stale (a clause renumbered, a heading reworded) or broken
|
|
9
|
+
* Within the document: a hidden `_Ref…` bookmark on the target paragraph and a `REF` field at the
|
|
10
|
+
* caret — `REF _Ref123 \\r \\h` for a numbered paragraph (Word's Cross-reference › Numbered item ›
|
|
11
|
+
* Paragraph number), `REF _Ref123 \\h` for a heading's text. The field's cached result is the value
|
|
12
|
+
* the editor computes, so it updates live when the clauses are renumbered, and Word updates it
|
|
13
|
+
* with the document's other fields.
|
|
14
|
+
*
|
|
15
|
+
* To another document: a hyperlink with the reference text ("SPA, clause 8.2"), aimed at the app
|
|
16
|
+
* address of that document's passage (so it works from Word too), with a screen tip saying so.
|
|
17
|
+
*
|
|
18
|
+
* Every cross-reference reads as current, stale (a clause renumbered, a heading reworded) or broken
|
|
161
19
|
* (the target is gone).
|
|
162
20
|
*/
|
|
163
21
|
|
|
@@ -214,6 +72,82 @@ declare function crossReferences(port: ReferencesReader): CrossReference[];
|
|
|
214
72
|
declare function staleCrossReferences(port: ReferencesReader): StaleReference[];
|
|
215
73
|
/** The broken cross-references marked in the document, in document order. */
|
|
216
74
|
declare function brokenCrossReferences(port: Pick<ReferencesReader, 'paragraphs'>): BrokenReference[];
|
|
75
|
+
/** A new `_Ref` bookmark name: Word's shape (`_Ref` and nine digits), not yet in the document. */
|
|
76
|
+
declare function newRefBookmark(taken: ReadonlySet<string>, random?: () => number): string;
|
|
77
|
+
/**
|
|
78
|
+
* A complex `REF` field with its cached result, every run in the Cross Reference style (Word gives
|
|
79
|
+
* an updated result the formatting of the field's first run).
|
|
80
|
+
*/
|
|
81
|
+
declare function refFieldXml(instruction: string, cached: string): string;
|
|
82
|
+
/** The screen tip of a reference to this document: "Cross-reference to clause 2.2". */
|
|
83
|
+
declare const refTooltip: (value: string, mode: CrossReferenceMode) => string;
|
|
84
|
+
/**
|
|
85
|
+
* A reference to this document: the `REF` field inside a link to the same bookmark, which carries
|
|
86
|
+
* the screen tip Word shows on hover ("Cross-reference to clause 2.2").
|
|
87
|
+
*/
|
|
88
|
+
declare function crossReferenceXml(bookmark: string, mode: CrossReferenceMode, value: string): string;
|
|
89
|
+
/** The field instruction for a target: its paragraph number, or its text. */
|
|
90
|
+
declare const refInstruction: (bookmark: string, mode: CrossReferenceMode) => string;
|
|
91
|
+
/** What the reference reads in the text. */
|
|
92
|
+
declare const refResult: (target: CrossReferenceTarget, mode: CrossReferenceMode) => string;
|
|
93
|
+
/**
|
|
94
|
+
* The `_Ref` bookmark a target carries: an existing one at the paragraph, else a new one. For a
|
|
95
|
+
* paragraph number it is an empty bookmark at the paragraph's start (the number is the
|
|
96
|
+
* paragraph's); for heading text it wraps the heading's runs (REF shows the bookmarked text).
|
|
97
|
+
*/
|
|
98
|
+
declare function ensureTargetBookmark(port: ReferencesPort, target: CrossReferenceTarget, mode: CrossReferenceMode): string;
|
|
99
|
+
/**
|
|
100
|
+
* Mark a cross-reference's target (see {@link ensureTargetBookmark}): what the reference will
|
|
101
|
+
* address and read. A paragraph number falls back to the heading text when it has none. Done as a
|
|
102
|
+
* direct edit even while suggesting — the bookmark is hidden, and a heading's text is put back as
|
|
103
|
+
* it was — so rejecting the reference leaves the target as it was.
|
|
104
|
+
*/
|
|
105
|
+
declare function markCrossReferenceTarget(port: ReferencesPort, target: CrossReferenceTarget, mode: CrossReferenceMode): {
|
|
106
|
+
bookmark: string;
|
|
107
|
+
mode: CrossReferenceMode;
|
|
108
|
+
value: string;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Insert the `REF` field of a marked target at `caret`; the caret ends after it. With a port
|
|
112
|
+
* whose pastes are tracked, the reference is one suggestion.
|
|
113
|
+
*/
|
|
114
|
+
declare function insertCrossReferenceField(port: ReferencesPort, { bookmark, mode, value }: {
|
|
115
|
+
bookmark: string;
|
|
116
|
+
mode: CrossReferenceMode;
|
|
117
|
+
value: string;
|
|
118
|
+
}, caret: DocPoint): {
|
|
119
|
+
bookmark: string;
|
|
120
|
+
};
|
|
121
|
+
/** Insert a cross-reference to a target of this document at `caret`; the caret ends after it. */
|
|
122
|
+
declare function insertCrossReference(port: ReferencesPort, target: CrossReferenceTarget, mode: CrossReferenceMode, caret: DocPoint): {
|
|
123
|
+
bookmark: string;
|
|
124
|
+
};
|
|
125
|
+
/** The screen tip of a reference to another document: "Cross-reference: SPA, clause 8.2 — opens in ARBI". */
|
|
126
|
+
declare const documentReferenceTooltip: (text: string, appName?: string) => string;
|
|
127
|
+
/**
|
|
128
|
+
* Insert a reference to another document's passage: the reference text in the Cross Reference
|
|
129
|
+
* style, linked to the passage's (absolute) app address, at `caret`.
|
|
130
|
+
*/
|
|
131
|
+
declare function insertDocumentReference(port: ReferencesPort, reference: {
|
|
132
|
+
text: string;
|
|
133
|
+
url: string;
|
|
134
|
+
appName?: string;
|
|
135
|
+
}, caret: DocPoint): void;
|
|
136
|
+
interface RefreshResult {
|
|
137
|
+
/** References rewritten with their current number or text. */
|
|
138
|
+
refreshed: number;
|
|
139
|
+
/** References whose target is gone, now (or already) marked broken. */
|
|
140
|
+
broken: BrokenReference[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Bring every cross-reference up to date: a stale one is replaced by the same reference with its
|
|
144
|
+
* current value (and screen tip); one whose target was deleted becomes its last text in the Cross
|
|
145
|
+
* Reference Broken style — never Word's "Error! Reference source not found." A field directly
|
|
146
|
+
* after another field is left alone: a paste there would land inside the previous field.
|
|
147
|
+
*/
|
|
148
|
+
declare function refreshCrossReferences(port: ReferencesPort): RefreshResult;
|
|
149
|
+
/** A paragraph's runs as XML (formatting kept), or null for anything but plain runs. */
|
|
150
|
+
declare function paragraphRunsXml(paragraph: OoxmlNodeLike): string | null;
|
|
217
151
|
|
|
218
152
|
/**
|
|
219
153
|
* Undo for the changes ARBI applies directly (they cannot be tracked): a paragraph style or format,
|
|
@@ -293,11 +227,181 @@ declare function fieldNodeIds(paragraph: OoxmlNodeLike): string[];
|
|
|
293
227
|
*/
|
|
294
228
|
declare function undoOps(root: OoxmlNodeLike, record: UndoRecord): TreeDocOp[] | null;
|
|
295
229
|
|
|
230
|
+
/**
|
|
231
|
+
* The minimal WordprocessingML a command writes: escaped text, a `word/document.xml` and
|
|
232
|
+
* `word/styles.xml` around it, and the `.docx` package that carries them (a paste fragment).
|
|
233
|
+
*/
|
|
234
|
+
declare const W_NAMESPACES = "xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"";
|
|
235
|
+
/** Text as XML character data or an attribute value. */
|
|
236
|
+
declare const esc: (text: string) => string;
|
|
237
|
+
/** A `word/document.xml` around body content (paragraphs, tables, then the section). */
|
|
238
|
+
declare const documentXml: (body: string) => string;
|
|
239
|
+
/** `word/styles.xml` holding the given style definitions. */
|
|
240
|
+
declare const stylesXml: (defaults: string, styles: string) => string;
|
|
241
|
+
/** A relationship to an external hyperlink target, for `w:hyperlink r:id`. */
|
|
242
|
+
declare const hyperlinkRelationship: (id: string, url: string) => string;
|
|
243
|
+
/** The minimal `.docx` package: a document, its styles, and its title and time. */
|
|
244
|
+
declare function docxPackage(parts: {
|
|
245
|
+
document: string;
|
|
246
|
+
styles: string;
|
|
247
|
+
title: string;
|
|
248
|
+
/** ISO time; default now. */
|
|
249
|
+
at?: string;
|
|
250
|
+
/** Further `word/document.xml` relationships (e.g. {@link hyperlinkRelationship}). */
|
|
251
|
+
relationships?: string;
|
|
252
|
+
}): Uint8Array;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Defined terms in text: a definition's term read from the start of its text (`"Shares" means …`,
|
|
256
|
+
* `**Business Day** shall mean …`, `Completion: the date …`), the order of a glossary, and the hidden
|
|
257
|
+
* Word bookmark a term links to. Shared by the editor's Defined Terms and ARBI's headless tools.
|
|
258
|
+
*/
|
|
259
|
+
/** A definition's text split into its term and the rest. */
|
|
260
|
+
interface ParsedDefinition {
|
|
261
|
+
/** The term as written, without quotes or emphasis (`Business Day`). */
|
|
262
|
+
term: string;
|
|
263
|
+
/** What follows the term, its connecting word included (`means a day …`, `: the date …`). */
|
|
264
|
+
rest: string;
|
|
265
|
+
/** Just the meaning, the connecting word dropped (`a day …`). */
|
|
266
|
+
meaning: string;
|
|
267
|
+
}
|
|
268
|
+
/** A definition as the commands insert it: the id of its fact, its term and the rest. */
|
|
269
|
+
interface DefinitionText extends Pick<ParsedDefinition, 'term' | 'rest'> {
|
|
270
|
+
id: string;
|
|
271
|
+
}
|
|
272
|
+
/** The matching key of a term: case and whitespace folded, quotes and emphasis dropped. */
|
|
273
|
+
declare function termKey(term: string): string;
|
|
274
|
+
/**
|
|
275
|
+
* Read a definition's term from the start of its text, or `null` when it does not start with one.
|
|
276
|
+
*
|
|
277
|
+
* Optional straight or curly quotes and bold markers around the term are dropped; the term is what
|
|
278
|
+
* comes before "means", "shall mean", "includes", "has the meaning", a colon, or a dash. A quoted
|
|
279
|
+
* term is taken whole, so `"Long-Stop Date" means …` keeps its hyphen.
|
|
280
|
+
*/
|
|
281
|
+
declare function parseDefinition(text: string): ParsedDefinition | null;
|
|
282
|
+
/** Alphabetical order of terms, as a reader sorts a glossary (case and accents folded). */
|
|
283
|
+
declare const compareTerms: (a: string, b: string) => number;
|
|
284
|
+
/** Prefix of every bookmark a defined term links to: hidden in Word (leading underscore). */
|
|
285
|
+
declare const DEFINITION_BOOKMARK_PREFIX = "_dt_";
|
|
286
|
+
/**
|
|
287
|
+
* The Word bookmark of a definition: `_dt_` and the fact id in valid bookmark characters
|
|
288
|
+
* (`fct-AbC12345` → `_dt_fct_AbC12345`), at most 40 characters as Word requires.
|
|
289
|
+
*/
|
|
290
|
+
declare function definitionBookmark(factId: string): string;
|
|
291
|
+
/** The fact id a definition bookmark names, or `null` for any other bookmark. */
|
|
292
|
+
declare function definitionIdOfBookmark(name: string): string | null;
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Defined-term and cross-reference content as WordprocessingML, and the clipboard fragment (a small
|
|
296
|
+
* `.docx` package) that carries it into a document. The engine has no "insert bookmark" command, but
|
|
297
|
+
* its paste lands an embedded fragment with everything in it — `w:bookmarkStart`/`w:bookmarkEnd` and
|
|
298
|
+
* `w:hyperlink w:anchor` included — freshening bookmark ids as it goes.
|
|
299
|
+
*/
|
|
300
|
+
|
|
301
|
+
type Definition$1 = Pick<ParsedDefinition, 'term' | 'rest'>;
|
|
302
|
+
/**
|
|
303
|
+
* The character styles the inserted content uses. A paste brings a style the document does not
|
|
304
|
+
* define; one it already defines (a house template's) is used as it is, so only the missing ones
|
|
305
|
+
* go into a fragment (see {@link stylesUsed}).
|
|
306
|
+
*/
|
|
307
|
+
declare const CHARACTER_STYLES: Record<string, string>;
|
|
308
|
+
/** The character styles a fragment's runs use (`w:rStyle`), as ids. */
|
|
309
|
+
declare function stylesUsed(body: string): string[];
|
|
310
|
+
/** What Word shows on hover over a term: its definition, as one line of at most 255 characters. */
|
|
311
|
+
declare function definitionTooltip(definition: Definition$1): string;
|
|
312
|
+
/** The definition paragraph's text as the document shows it: `“Shares” means the issued shares.` */
|
|
313
|
+
declare const definitionParagraphText: (definition: Definition$1) => string;
|
|
314
|
+
/**
|
|
315
|
+
* A definition paragraph: the quoted term in bold, bookmarked (`bookmark`), then the definition as
|
|
316
|
+
* the fact writes it. `id` is the bookmark id inside the fragment; the paste renumbers it.
|
|
317
|
+
*/
|
|
318
|
+
declare function definitionParagraphXml(definition: Definition$1, bookmark: string, id?: number): string;
|
|
319
|
+
/** A heading paragraph: the document's own heading style when it has one, else bold text. */
|
|
320
|
+
declare function headingParagraphXml(text: string, styleId?: string): string;
|
|
321
|
+
/** The term as an internal link to its definition's bookmark, with the definition as its tooltip. */
|
|
322
|
+
declare function termLinkXml(term: string, bookmark: string, tooltip: string): string;
|
|
323
|
+
/**
|
|
324
|
+
* The fragment package carrying `body` (paragraph XML). `covered` says the last paragraph mark is
|
|
325
|
+
* part of it: the paste then ends with a whole paragraph (a block inserted before the caret's
|
|
326
|
+
* paragraph) instead of running into the text after the caret (inline). With a `revision`, the
|
|
327
|
+
* fragment is one tracked insertion by it.
|
|
328
|
+
*/
|
|
329
|
+
declare function fragmentPackage(body: string, covered: boolean, { revision, relationships, styles, }?: {
|
|
330
|
+
revision?: Revision | null;
|
|
331
|
+
/** Relationships the body refers to (a hyperlink's target). */
|
|
332
|
+
relationships?: string;
|
|
333
|
+
/** The character styles to bring (default: every one the body uses). */
|
|
334
|
+
styles?: readonly string[];
|
|
335
|
+
}): Uint8Array;
|
|
336
|
+
/** The style ids a document's styles part defines. */
|
|
337
|
+
declare function documentStyleIds(root: OoxmlNodeLike | null | undefined): Set<string>;
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* The defined-term commands: insert a term as a link to its definition (adding the definition to
|
|
341
|
+
* the document's Definitions section when it is not there yet). Written against
|
|
342
|
+
* {@link DefinitionsPort}, so they run on the live editor and on the in-memory model the tests use
|
|
343
|
+
* alike.
|
|
344
|
+
*
|
|
345
|
+
* Where the Definitions section is: the first top-level paragraph titled "Definitions",
|
|
346
|
+
* "Definitions and interpretation", "Interpretation", "Defined terms" or "Glossary" (clause numbers
|
|
347
|
+
* ignored), up to the next heading. A document without one gets a "Definitions" heading at its end:
|
|
348
|
+
* appended, it never splits the clause being drafted, and it is where a reader of a draft looks
|
|
349
|
+
* for a schedule of terms. Inside the section, definitions are kept in alphabetical order.
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
type Definition = DefinitionText;
|
|
353
|
+
/** Title of a Definitions section the commands create. */
|
|
354
|
+
declare const DEFINITIONS_HEADING = "Definitions";
|
|
355
|
+
/** Whether a paragraph titles a Definitions section. */
|
|
356
|
+
declare function isDefinitionsTitle(paragraph: DocParagraph): boolean;
|
|
357
|
+
/** The Definitions section: its title's index and the paragraphs after it, up to the next heading. */
|
|
358
|
+
interface DefinitionsSection {
|
|
359
|
+
title: number;
|
|
360
|
+
/** First paragraph after the title. */
|
|
361
|
+
start: number;
|
|
362
|
+
/** Index after the section's last paragraph (the next heading, a table, or the end). */
|
|
363
|
+
end: number;
|
|
364
|
+
}
|
|
365
|
+
declare function findDefinitionsSection(paragraphs: readonly DocParagraph[]): DefinitionsSection | null;
|
|
366
|
+
/**
|
|
367
|
+
* Where a definition of `term` goes in the section, alphabetically: before the first definition
|
|
368
|
+
* whose term sorts after it, else after the last definition (else right after the title).
|
|
369
|
+
*/
|
|
370
|
+
declare function insertionIndex(paragraphs: readonly DocParagraph[], section: DefinitionsSection, term: string, skip?: ReadonlySet<string>): number;
|
|
371
|
+
/**
|
|
372
|
+
* Add a definition paragraph to the Definitions section (made at the end of the document when there
|
|
373
|
+
* is none), in alphabetical order. Answers where `keep` moved to.
|
|
374
|
+
*/
|
|
375
|
+
declare function addDefinition(port: DefinitionsPort, definition: Definition, keep?: DocPoint): DocPoint | undefined;
|
|
376
|
+
interface InsertTermResult {
|
|
377
|
+
/** The definition was not in the document yet and was added to its Definitions section. */
|
|
378
|
+
addedDefinition: boolean;
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Insert a defined term at the caret: the term as an internal link to its definition's bookmark
|
|
382
|
+
* (its definition as the link's tooltip), the definition added to the Definitions section first
|
|
383
|
+
* when the document does not have it. `replace` characters before the caret (a typed `@@query`)
|
|
384
|
+
* are removed first. The caret ends after the term.
|
|
385
|
+
*/
|
|
386
|
+
declare function insertDefinedTerm(port: DefinitionsPort, definition: Definition, options?: {
|
|
387
|
+
replace?: number;
|
|
388
|
+
}): InsertTermResult;
|
|
389
|
+
/** Term groups keyed for quick lookup of the definition a bookmark points at. */
|
|
390
|
+
declare function definitionsById<D extends Definition>(definitions: readonly D[]): Map<string, D>;
|
|
391
|
+
/** The definition an internal link points at, from its bookmark name. */
|
|
392
|
+
declare function definitionOfAnchor<D extends Definition>(anchor: string, definitions: ReadonlyMap<string, D>): D | undefined;
|
|
393
|
+
|
|
296
394
|
/** A document's parts as trees: a live editor's session or a headless view (`openHeadlessDocument`). */
|
|
297
395
|
interface DocumentTrees {
|
|
298
396
|
part(): {
|
|
299
397
|
root: unknown;
|
|
300
398
|
};
|
|
399
|
+
/** The package, for its notes parts (absent on a live editor's session). */
|
|
400
|
+
currentPackage?(): {
|
|
401
|
+
parts: ReadonlyMap<string, {
|
|
402
|
+
root: unknown;
|
|
403
|
+
}>;
|
|
404
|
+
};
|
|
301
405
|
stylesRoot(): unknown;
|
|
302
406
|
numberingRoot(): unknown;
|
|
303
407
|
settingsRoot(): unknown;
|
|
@@ -306,10 +410,12 @@ interface DocumentTrees {
|
|
|
306
410
|
interface DocumentReader extends ReferencesReader, DocumentNumbering {
|
|
307
411
|
/** A style's name (`heading 1`) by its id, or the id when the document does not name it. */
|
|
308
412
|
styleName(styleId: string): string;
|
|
413
|
+
/** A footnote's or endnote's text by its `w:id`. */
|
|
414
|
+
noteText(kind: 'footnote' | 'endnote', id: string): string | undefined;
|
|
309
415
|
}
|
|
310
416
|
/** Read a document whose trees do not change while the reader is used (a headless view). */
|
|
311
417
|
declare function documentReader(view: DocumentTrees): DocumentReader;
|
|
312
418
|
/** Read a document from its bytes (a collaboration room's `readRoom`). Throws on a bad package. */
|
|
313
419
|
declare function readDocument(bytes: Uint8Array): DocumentReader;
|
|
314
420
|
|
|
315
|
-
export { AGENT_UNDO_MAP,
|
|
421
|
+
export { AGENT_UNDO_MAP, type BrokenReference, CHARACTER_STYLES, type CrossReference, type CrossReferenceMode, CrossReferenceTarget, DEFINITIONS_HEADING, DEFINITION_BOOKMARK_PREFIX, type DefinitionText, DefinitionsPort, type DefinitionsSection, DocParagraph, DocPoint, DocumentNumbering, type DocumentReader, type DocumentTrees, type InsertTermResult, LevelOf, ListItemInfo, OoxmlNodeLike, type ParagraphState, type ParsedDefinition, REF_BOOKMARK_PREFIX, ReferencesPort, type ReferencesReader, type RefreshResult, type SectionState, type StaleReference, type UndoRecord, W_NAMESPACES, addDefinition, brokenCrossReferences, compareTerms, crossReferenceXml, crossReferences, definitionBookmark, definitionIdOfBookmark, definitionOfAnchor, definitionParagraphText, definitionParagraphXml, definitionTooltip, definitionsById, documentReader, documentReferenceTooltip, documentStyleIds, documentXml, docxPackage, ensureTargetBookmark, esc, fieldNodeIds, findDefinitionsSection, fragmentPackage, headingParagraphXml, hyperlinkRelationship, insertCrossReference, insertCrossReferenceField, insertDefinedTerm, insertDocumentReference, insertionIndex, isDefinitionsTitle, markCrossReferenceTarget, newRefBookmark, paragraphIndex, paragraphRunsXml, paragraphState, parseDefinition, readDocument, refFieldXml, refInstruction, refResult, refTooltip, refreshCrossReferences, sectionStates, staleCrossReferences, stylesUsed, stylesXml, tableOf, tableState, termKey, termLinkXml, undoOps };
|