@docx4j/core-ts 0.1.0 → 0.1.1
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 +410 -10
- package/dist/model/content/Body.d.mts +109 -4
- package/dist/model/content/Body.mjs +300 -29
- package/dist/model/content/Comment.d.mts +78 -0
- package/dist/model/content/Comment.mjs +429 -0
- package/dist/model/content/ContentControl.d.mts +173 -0
- package/dist/model/content/ContentControl.mjs +638 -0
- package/dist/model/content/Font.d.mts +48 -8
- package/dist/model/content/Font.mjs +55 -13
- package/dist/model/content/InlinePicture.d.mts +103 -0
- package/dist/model/content/InlinePicture.mjs +361 -0
- package/dist/model/content/List.d.mts +253 -0
- package/dist/model/content/List.mjs +778 -0
- package/dist/model/content/Paragraph.d.mts +213 -16
- package/dist/model/content/Paragraph.mjs +611 -57
- package/dist/model/content/Range.d.mts +48 -4
- package/dist/model/content/Range.mjs +161 -4
- package/dist/model/content/Table.d.mts +130 -0
- package/dist/model/content/Table.mjs +429 -0
- package/dist/model/content/TrackedChange.d.mts +96 -0
- package/dist/model/content/TrackedChange.mjs +352 -0
- package/dist/model/content/comments.d.mts +122 -0
- package/dist/model/content/comments.mjs +248 -0
- package/dist/model/content/index.d.mts +13 -3
- package/dist/model/content/index.mjs +15 -3
- package/dist/model/content/ooxml.d.mts +17 -0
- package/dist/model/content/ooxml.mjs +214 -0
- package/dist/model/content/styles.d.mts +21 -0
- package/dist/model/content/styles.mjs +86 -0
- package/dist/model/content/tracking.d.mts +104 -0
- package/dist/model/content/tracking.mjs +313 -0
- package/dist/model/content/tree.d.mts +56 -9
- package/dist/model/content/tree.mjs +104 -31
- package/dist/model/customxml/CustomXmlPart.d.mts +158 -0
- package/dist/model/customxml/CustomXmlPart.mjs +415 -0
- package/dist/model/customxml/CustomXmlPartCollection.d.mts +68 -0
- package/dist/model/customxml/CustomXmlPartCollection.mjs +183 -0
- package/dist/model/customxml/XmlMapping.d.mts +46 -0
- package/dist/model/customxml/XmlMapping.mjs +98 -0
- package/dist/model/customxml/bindings.d.mts +41 -0
- package/dist/model/customxml/bindings.mjs +230 -0
- package/dist/model/customxml/index.d.mts +7 -0
- package/dist/model/customxml/index.mjs +9 -0
- package/dist/model/customxml/insert.d.mts +20 -0
- package/dist/model/customxml/insert.mjs +22 -0
- package/dist/model/customxml/kinds.d.mts +103 -0
- package/dist/model/customxml/kinds.mjs +267 -0
- package/dist/model/customxml/xpath.d.mts +52 -0
- package/dist/model/customxml/xpath.mjs +205 -0
- package/dist/model/fonts/CJKToEnglish.d.mts +2 -0
- package/dist/model/fonts/CJKToEnglish.mjs +16 -0
- package/dist/model/fonts/FontFallback.d.mts +58 -0
- package/dist/model/fonts/FontFallback.mjs +219 -0
- package/dist/model/fonts/IdentityPlusMapper.d.mts +7 -0
- package/dist/model/fonts/IdentityPlusMapper.mjs +19 -0
- package/dist/model/fonts/LanguageTagToScriptMapping.d.mts +7 -0
- package/dist/model/fonts/LanguageTagToScriptMapping.mjs +67 -0
- package/dist/model/fonts/Mapper.d.mts +190 -0
- package/dist/model/fonts/Mapper.mjs +481 -0
- package/dist/model/fonts/PhysicalFont.d.mts +34 -0
- package/dist/model/fonts/PhysicalFont.mjs +62 -0
- package/dist/model/fonts/RunFontSelector.d.mts +194 -0
- package/dist/model/fonts/RunFontSelector.mjs +441 -0
- package/dist/model/fonts/ThemeFonts.d.mts +17 -0
- package/dist/model/fonts/ThemeFonts.mjs +76 -0
- package/dist/model/fonts/defaultTheme.d.mts +37 -0
- package/dist/model/fonts/defaultTheme.mjs +57 -0
- package/dist/model/fonts/families.generated.d.mts +11 -0
- package/dist/model/fonts/families.generated.mjs +17 -0
- package/dist/model/fonts/fontsInUse.d.mts +39 -0
- package/dist/model/fonts/fontsInUse.mjs +183 -0
- package/dist/model/fonts/index.d.mts +14 -0
- package/dist/model/fonts/index.mjs +29 -0
- package/dist/model/fonts/lookup.d.mts +5 -0
- package/dist/model/fonts/lookup.mjs +12 -0
- package/dist/model/fonts/registry.d.mts +31 -0
- package/dist/model/fonts/registry.mjs +103 -0
- package/dist/model/fonts/scripts.d.mts +2 -0
- package/dist/model/fonts/scripts.mjs +78 -0
- package/dist/model/fonts/substitutions.generated.d.mts +30 -0
- package/dist/model/fonts/substitutions.generated.mjs +12 -0
- package/dist/model/fonts/themes.generated.d.mts +6 -0
- package/dist/model/fonts/themes.generated.mjs +11 -0
- package/dist/model/index.d.mts +5 -0
- package/dist/model/index.mjs +13 -1
- package/dist/model/listnumbering/Emulator.d.mts +187 -0
- package/dist/model/listnumbering/Emulator.mjs +332 -0
- package/dist/model/listnumbering/definitions.d.mts +251 -0
- package/dist/model/listnumbering/definitions.mjs +571 -0
- package/dist/model/listnumbering/formats.d.mts +25 -0
- package/dist/model/listnumbering/formats.mjs +320 -0
- package/dist/model/listnumbering/index.d.mts +4 -0
- package/dist/model/listnumbering/index.mjs +15 -0
- package/dist/model/listnumbering/state.d.mts +97 -0
- package/dist/model/listnumbering/state.mjs +179 -0
- package/dist/model/properties/PropertyResolver.d.mts +216 -0
- package/dist/model/properties/PropertyResolver.mjs +524 -0
- package/dist/model/properties/catalogue.d.mts +179 -0
- package/dist/model/properties/catalogue.mjs +860 -0
- package/dist/model/properties/index.d.mts +4 -0
- package/dist/model/properties/index.mjs +9 -0
- package/dist/model/properties/log.d.mts +7 -0
- package/dist/model/properties/log.mjs +25 -0
- package/dist/model/properties/styleUtil.d.mts +112 -0
- package/dist/model/properties/styleUtil.mjs +359 -0
- package/dist/node/index.d.mts +1 -0
- package/dist/node/index.mjs +12 -0
- package/dist/office-js/document.d.mts +111 -0
- package/dist/office-js/document.mjs +267 -0
- package/dist/office-js/enums.d.mts +187 -0
- package/dist/office-js/enums.mjs +176 -0
- package/dist/office-js/errors.d.mts +29 -0
- package/dist/office-js/errors.mjs +39 -0
- package/dist/office-js/extras.d.mts +5 -0
- package/dist/office-js/extras.mjs +29 -0
- package/dist/office-js/fragment.d.mts +10 -0
- package/dist/office-js/fragment.mjs +23 -0
- package/dist/office-js/index.d.mts +183 -0
- package/dist/office-js/index.mjs +54 -0
- package/dist/office-js/proxy.d.mts +72 -0
- package/dist/office-js/proxy.mjs +279 -0
- package/dist/office-js/run.d.mts +32 -0
- package/dist/office-js/run.mjs +66 -0
- package/dist/office-js/supported.d.mts +7 -0
- package/dist/office-js/supported.generated.d.mts +1 -0
- package/dist/office-js/supported.generated.mjs +235 -0
- package/dist/office-js/supported.mjs +53 -0
- package/dist/office-js/toApiScript.d.mts +25 -0
- package/dist/office-js/toApiScript.mjs +394 -0
- package/dist/opc/ContentTypes.d.mts +1 -0
- package/dist/opc/ContentTypes.mjs +1 -0
- package/dist/opc/DirectoryPartStore.d.mts +47 -0
- package/dist/opc/DirectoryPartStore.mjs +123 -0
- package/dist/opc/exceptions.d.mts +30 -0
- package/dist/opc/exceptions.mjs +38 -0
- package/dist/opc/index.d.mts +1 -1
- package/dist/opc/index.mjs +1 -1
- package/dist/packages/OpcPackage.d.mts +19 -1
- package/dist/packages/OpcPackage.mjs +29 -0
- package/dist/packages/PresentationMLPackage.d.mts +71 -1
- package/dist/packages/PresentationMLPackage.mjs +179 -0
- package/dist/packages/SpreadsheetMLPackage.d.mts +30 -1
- package/dist/packages/SpreadsheetMLPackage.mjs +78 -0
- package/dist/packages/WordprocessingMLPackage.d.mts +124 -2
- package/dist/packages/WordprocessingMLPackage.mjs +309 -2
- package/dist/packages/index.d.mts +1 -1
- package/dist/packages/index.mjs +1 -1
- package/dist/parts/DefaultXmlPart.d.mts +18 -0
- package/dist/parts/DefaultXmlPart.mjs +34 -5
- package/dist/parts/PartRegistry.mjs +1 -0
- package/dist/parts/XmlPart.d.mts +33 -0
- package/dist/parts/XmlPart.mjs +105 -2
- package/dist/parts/pml/defaults.d.mts +6 -0
- package/dist/parts/pml/defaults.mjs +53 -0
- package/dist/parts/pml/index.d.mts +66 -3
- package/dist/parts/pml/index.mjs +206 -7
- package/dist/parts/pml/placeholders.d.mts +71 -0
- package/dist/parts/pml/placeholders.mjs +141 -0
- package/dist/parts/sml/index.d.mts +19 -1
- package/dist/parts/sml/index.mjs +60 -1
- package/dist/parts/wml/comments.d.mts +1 -0
- package/dist/parts/wml/comments.mjs +179 -0
- package/dist/parts/wml/defaultNumbering.d.mts +1 -0
- package/dist/parts/wml/defaultNumbering.mjs +216 -0
- package/dist/parts/wml/index.d.mts +121 -0
- package/dist/parts/wml/index.mjs +291 -0
- package/dist/xml/dom.mjs +1 -2
- package/package.json +25 -4
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type { ContentControl } from '../content/ContentControl.mjs';
|
|
3
|
+
import type { CustomXmlPart, CustomXmlNode } from './CustomXmlPart.mjs';
|
|
4
|
+
/** What `XmlMapping` needs of `pkg.customXmlParts`, so that this module does not import the package. */
|
|
5
|
+
export interface CustomXmlPartLookup {
|
|
6
|
+
readonly items: CustomXmlPart[];
|
|
7
|
+
getItem(id: string): CustomXmlPart | undefined;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A subset of Office JS `Word.XmlMapping`: the content control's data binding. `isMapped` is
|
|
11
|
+
* whether the control has a `w:dataBinding`; `customXmlNode` evaluates the XPath now, so it needs
|
|
12
|
+
* the XPath engine to be warm (`await pkg.customXmlParts.load()` once, CR-002 section 3.6).
|
|
13
|
+
*/
|
|
14
|
+
export declare class XmlMapping {
|
|
15
|
+
/** The control this mapping belongs to. */
|
|
16
|
+
readonly contentControl: ContentControl;
|
|
17
|
+
private readonly lookup;
|
|
18
|
+
constructor(
|
|
19
|
+
/** The control this mapping belongs to. */
|
|
20
|
+
contentControl: ContentControl, lookup: CustomXmlPartLookup | undefined);
|
|
21
|
+
/** The `w:dataBinding` value, or undefined when the control has none (extension). */
|
|
22
|
+
get dataBinding(): wml.CTDataBinding | undefined;
|
|
23
|
+
get isMapped(): boolean;
|
|
24
|
+
get xpath(): string;
|
|
25
|
+
get prefixMappings(): string;
|
|
26
|
+
/** `w:storeItemID`, the itemID of the custom XML part (extension: Office JS reports the part). */
|
|
27
|
+
get storeItemID(): string;
|
|
28
|
+
/** The part the binding names, when the package has it. */
|
|
29
|
+
get customXmlPart(): CustomXmlPart | undefined;
|
|
30
|
+
/** The node the XPath selects now, or undefined when it selects nothing. */
|
|
31
|
+
get customXmlNode(): CustomXmlNode | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Binds the control to what the XPath selects, as Word's own mapping does: the part is the one
|
|
34
|
+
* given, else the one the control is already bound to, else the first custom XML part (the
|
|
35
|
+
* built-in property stores last) in which the XPath selects a node. Returns false and changes
|
|
36
|
+
* nothing when nothing is selected, which is what Word reports.
|
|
37
|
+
*/
|
|
38
|
+
setMapping(xpath: string, prefixMappings?: string, part?: CustomXmlPart): boolean;
|
|
39
|
+
/** Binds to a node: its canonical XPath and the prefixes that path needs, as Word writes them. */
|
|
40
|
+
setMappingByNode(node: CustomXmlNode): boolean;
|
|
41
|
+
/** Removes the binding (`w:dataBinding`); the control keeps the content it shows. */
|
|
42
|
+
delete(): void;
|
|
43
|
+
private write;
|
|
44
|
+
/** The parts to try, the customer's data before Word's property stores. */
|
|
45
|
+
private candidates;
|
|
46
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import * as el from '@docx4j/generated-objects-ts/el/org_docx4j_wml';
|
|
2
|
+
import { sdtProperty } from '@docx4j/generated-objects-ts/builders/wml';
|
|
3
|
+
import { canonicalXPathOf } from './xpath.mjs';
|
|
4
|
+
/** The Word 2012 (w15) namespace; not imported from `ContentControl`, which imports this module. */
|
|
5
|
+
const W15_NS = 'http://schemas.microsoft.com/office/word/2012/wordml';
|
|
6
|
+
/**
|
|
7
|
+
* A subset of Office JS `Word.XmlMapping`: the content control's data binding. `isMapped` is
|
|
8
|
+
* whether the control has a `w:dataBinding`; `customXmlNode` evaluates the XPath now, so it needs
|
|
9
|
+
* the XPath engine to be warm (`await pkg.customXmlParts.load()` once, CR-002 section 3.6).
|
|
10
|
+
*/
|
|
11
|
+
export class XmlMapping {
|
|
12
|
+
constructor(
|
|
13
|
+
/** The control this mapping belongs to. */
|
|
14
|
+
contentControl, lookup) {
|
|
15
|
+
this.contentControl = contentControl;
|
|
16
|
+
this.lookup = lookup;
|
|
17
|
+
}
|
|
18
|
+
/** The `w:dataBinding` value, or undefined when the control has none (extension). */
|
|
19
|
+
get dataBinding() {
|
|
20
|
+
var _a;
|
|
21
|
+
const pr = this.contentControl.sdt.sdtPr;
|
|
22
|
+
// Word 2013 writes `w15:dataBinding` on a repeating section and on a rich-text control bound
|
|
23
|
+
// to a container; everywhere else the binding is `w:dataBinding`. Both are CT_DataBinding.
|
|
24
|
+
const item = (_a = sdtProperty(pr, 'dataBinding')) !== null && _a !== void 0 ? _a : sdtProperty(pr, 'dataBinding', W15_NS);
|
|
25
|
+
return item === null || item === void 0 ? void 0 : item.value;
|
|
26
|
+
}
|
|
27
|
+
get isMapped() {
|
|
28
|
+
return this.dataBinding !== undefined;
|
|
29
|
+
}
|
|
30
|
+
get xpath() {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
return (_b = (_a = this.dataBinding) === null || _a === void 0 ? void 0 : _a.xpath) !== null && _b !== void 0 ? _b : '';
|
|
33
|
+
}
|
|
34
|
+
get prefixMappings() {
|
|
35
|
+
var _a, _b;
|
|
36
|
+
return (_b = (_a = this.dataBinding) === null || _a === void 0 ? void 0 : _a.prefixMappings) !== null && _b !== void 0 ? _b : '';
|
|
37
|
+
}
|
|
38
|
+
/** `w:storeItemID`, the itemID of the custom XML part (extension: Office JS reports the part). */
|
|
39
|
+
get storeItemID() {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return (_b = (_a = this.dataBinding) === null || _a === void 0 ? void 0 : _a.storeItemID) !== null && _b !== void 0 ? _b : '';
|
|
42
|
+
}
|
|
43
|
+
/** The part the binding names, when the package has it. */
|
|
44
|
+
get customXmlPart() {
|
|
45
|
+
var _a;
|
|
46
|
+
const id = this.storeItemID;
|
|
47
|
+
return id === '' ? undefined : (_a = this.lookup) === null || _a === void 0 ? void 0 : _a.getItem(id);
|
|
48
|
+
}
|
|
49
|
+
/** The node the XPath selects now, or undefined when it selects nothing. */
|
|
50
|
+
get customXmlNode() {
|
|
51
|
+
const part = this.customXmlPart;
|
|
52
|
+
const binding = this.dataBinding;
|
|
53
|
+
if (!part || !binding)
|
|
54
|
+
return undefined;
|
|
55
|
+
return part.selectSingleNode(binding.xpath, binding.prefixMappings);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Binds the control to what the XPath selects, as Word's own mapping does: the part is the one
|
|
59
|
+
* given, else the one the control is already bound to, else the first custom XML part (the
|
|
60
|
+
* built-in property stores last) in which the XPath selects a node. Returns false and changes
|
|
61
|
+
* nothing when nothing is selected, which is what Word reports.
|
|
62
|
+
*/
|
|
63
|
+
setMapping(xpath, prefixMappings, part) {
|
|
64
|
+
const candidates = part ? [part] : this.candidates();
|
|
65
|
+
for (const candidate of candidates) {
|
|
66
|
+
const node = candidate.selectSingleNode(xpath, prefixMappings);
|
|
67
|
+
if (!node)
|
|
68
|
+
continue;
|
|
69
|
+
this.write(xpath, prefixMappings !== null && prefixMappings !== void 0 ? prefixMappings : '', candidate.id);
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
/** Binds to a node: its canonical XPath and the prefixes that path needs, as Word writes them. */
|
|
75
|
+
setMappingByNode(node) {
|
|
76
|
+
const { xpath, prefixMappings } = canonicalXPathOf(node.node);
|
|
77
|
+
this.write(xpath, prefixMappings, node.ownerPart.id);
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/** Removes the binding (`w:dataBinding`); the control keeps the content it shows. */
|
|
81
|
+
delete() {
|
|
82
|
+
this.contentControl.removeProperty('dataBinding');
|
|
83
|
+
}
|
|
84
|
+
write(xpath, prefixMappings, storeItemID) {
|
|
85
|
+
const binding = { TYPE_NAME: 'org_docx4j_wml.CTDataBinding', xpath, storeItemID };
|
|
86
|
+
if (prefixMappings !== '')
|
|
87
|
+
binding.prefixMappings = prefixMappings;
|
|
88
|
+
this.contentControl.putProperty(el.dataBinding(binding));
|
|
89
|
+
}
|
|
90
|
+
/** The parts to try, the customer's data before Word's property stores. */
|
|
91
|
+
candidates() {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
const current = this.customXmlPart;
|
|
94
|
+
const all = (_b = (_a = this.lookup) === null || _a === void 0 ? void 0 : _a.items) !== null && _b !== void 0 ? _b : [];
|
|
95
|
+
const rest = all.filter((p) => p !== current);
|
|
96
|
+
return [...(current ? [current] : []), ...rest.filter((p) => !p.builtIn), ...rest.filter((p) => p.builtIn)];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type { Element } from '../content/tree.mjs';
|
|
3
|
+
import type { ContentControl } from '../content/ContentControl.mjs';
|
|
4
|
+
/** The style Word gives placeholder text, and the text docx4j's placeholder.xml carries. */
|
|
5
|
+
export declare const PLACEHOLDER_STYLE = "PlaceholderText";
|
|
6
|
+
export declare const PLACEHOLDER_TEXT = "Click here to enter text.";
|
|
7
|
+
/** What `applyBindings` and `updateFromContentControls` report. */
|
|
8
|
+
export interface BindingResult {
|
|
9
|
+
/** Controls carrying a `w:dataBinding`. */
|
|
10
|
+
bound: number;
|
|
11
|
+
/** Controls whose value was written (into the document, or into the custom XML). */
|
|
12
|
+
updated: number;
|
|
13
|
+
/** Controls left alone: the part is missing, the XPath selects nothing, or the kind is not handled. */
|
|
14
|
+
skipped: number;
|
|
15
|
+
}
|
|
16
|
+
/** docx4j ValueInserterPlainTextImpl: the runs for a value, with the w:sdtPr run properties. */
|
|
17
|
+
export declare function runsForValue(value: string, rPr: wml.RPr | undefined, multiLine: boolean): Element[];
|
|
18
|
+
/**
|
|
19
|
+
* A date in Word's `w:dateFormat` pattern (the .NET forms Word writes: `d MMMM yyyy`,
|
|
20
|
+
* `dddd, d MMMM yyyy`, `d/MM/yyyy`), in the control's `w:lid` locale. Month and day names come
|
|
21
|
+
* from `Intl`; text inside single or double quotes is literal. docx4j uses Java's
|
|
22
|
+
* `SimpleDateFormat` with `dddd` mapped to `EEEE`; this is the same vocabulary.
|
|
23
|
+
*/
|
|
24
|
+
export declare function formatDate(pattern: string, date: Date, locale?: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Pushes the custom XML value into one control (docx4j BindingHandler's per-sdt work). Returns
|
|
27
|
+
* false when nothing was written: no binding, no part, an XPath that selects nothing, or a kind
|
|
28
|
+
* this phase does not handle (pictures, explicit rich text).
|
|
29
|
+
*/
|
|
30
|
+
export declare function applyBindingTo(control: ContentControl): boolean;
|
|
31
|
+
/** `applyBindings` over a list of controls. */
|
|
32
|
+
export declare function applyBindingsTo(controls: ContentControl[]): BindingResult;
|
|
33
|
+
/**
|
|
34
|
+
* Writes what one control shows back into the node it is bound to (docx4j
|
|
35
|
+
* UpdateXmlFromDocumentSurface). A checkbox writes 'true' or 'false' and a list writes the entry's
|
|
36
|
+
* value rather than its display text, which is what the data meant in the first place (docx4j
|
|
37
|
+
* writes the rendered glyph; section 12).
|
|
38
|
+
*/
|
|
39
|
+
export declare function updateFromControl(control: ContentControl): boolean;
|
|
40
|
+
/** `updateFromContentControls` over a list of controls. */
|
|
41
|
+
export declare function updateFromControls(controls: ContentControl[]): BindingResult;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import { deepCopy } from '@docx4j/generated-objects-ts';
|
|
2
|
+
import * as el from '@docx4j/generated-objects-ts/el/org_docx4j_wml';
|
|
3
|
+
import { sdtProperty } from '@docx4j/generated-objects-ts/builders/wml';
|
|
4
|
+
/** The style Word gives placeholder text, and the text docx4j's placeholder.xml carries. */
|
|
5
|
+
export const PLACEHOLDER_STYLE = 'PlaceholderText';
|
|
6
|
+
export const PLACEHOLDER_TEXT = 'Click here to enter text.';
|
|
7
|
+
function isTrue(value) {
|
|
8
|
+
const v = value.trim().toLowerCase();
|
|
9
|
+
return v === 'true' || v === '1' || v === 'on' || v === 'yes';
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Kinds that hold structure rather than a value. Word maps a repeating section to a node set and
|
|
13
|
+
* repeats what is inside it; writing a bound value into one would flatten the repeat, so these are
|
|
14
|
+
* left alone in both directions (CR-002 section 12) — as is any control that holds a table or
|
|
15
|
+
* another control.
|
|
16
|
+
*/
|
|
17
|
+
const CONTAINER_KINDS = new Set(['RepeatingSection', 'RepeatingSectionItem', 'Group', 'BuildingBlockGallery']);
|
|
18
|
+
function isContainer(control) {
|
|
19
|
+
if (CONTAINER_KINDS.has(control.type))
|
|
20
|
+
return true;
|
|
21
|
+
if (control.contentControls.length > 0)
|
|
22
|
+
return true;
|
|
23
|
+
return control.form === 'Block' && control.tables.length > 0;
|
|
24
|
+
}
|
|
25
|
+
/** docx4j ValueInserterPlainTextImpl: the runs for a value, with the w:sdtPr run properties. */
|
|
26
|
+
export function runsForValue(value, rPr, multiLine) {
|
|
27
|
+
if (value === '')
|
|
28
|
+
return [placeholderRun(rPr)];
|
|
29
|
+
const lines = multiLine ? value.split(/[\n\r\f]+/).filter((line) => line !== '') : [value.replace(/[\n\r\f]+/g, '')];
|
|
30
|
+
const out = [];
|
|
31
|
+
lines.forEach((line, i) => {
|
|
32
|
+
if (i > 0)
|
|
33
|
+
out.push(el.r({ ...(rPr ? { rPr: deepCopy(rPr) } : {}), content: [el.br({})] }));
|
|
34
|
+
const text = { TYPE_NAME: 'org_docx4j_wml.Text', value: line };
|
|
35
|
+
if (line.startsWith(' ') || line.endsWith(' '))
|
|
36
|
+
text.space = 'preserve';
|
|
37
|
+
out.push(el.r({ ...(rPr ? { rPr: deepCopy(rPr) } : {}), content: [el.t(text)] }));
|
|
38
|
+
});
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
/** docx4j's placeholder.xml: a PlaceholderText-styled run, which goes with w:showingPlcHdr. */
|
|
42
|
+
function placeholderRun(rPr) {
|
|
43
|
+
const properties = rPr ? deepCopy(rPr) : {};
|
|
44
|
+
properties.rStyle = { val: PLACEHOLDER_STYLE };
|
|
45
|
+
return el.r({ rPr: properties, content: [el.t({ value: PLACEHOLDER_TEXT })] });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A date in Word's `w:dateFormat` pattern (the .NET forms Word writes: `d MMMM yyyy`,
|
|
49
|
+
* `dddd, d MMMM yyyy`, `d/MM/yyyy`), in the control's `w:lid` locale. Month and day names come
|
|
50
|
+
* from `Intl`; text inside single or double quotes is literal. docx4j uses Java's
|
|
51
|
+
* `SimpleDateFormat` with `dddd` mapped to `EEEE`; this is the same vocabulary.
|
|
52
|
+
*/
|
|
53
|
+
export function formatDate(pattern, date, locale = 'en-US') {
|
|
54
|
+
const pad = (n, width) => String(n).padStart(width, '0');
|
|
55
|
+
const name = (options) => {
|
|
56
|
+
try {
|
|
57
|
+
return new Intl.DateTimeFormat(locale, options).format(date);
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return new Intl.DateTimeFormat('en-US', options).format(date);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const hours12 = date.getHours() % 12 === 0 ? 12 : date.getHours() % 12;
|
|
64
|
+
return pattern.replace(/d{1,4}|M{1,4}|y{2,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|tt|'[^']*'|"[^"]*"/g, (token) => {
|
|
65
|
+
if (token.startsWith("'") || token.startsWith('"'))
|
|
66
|
+
return token.slice(1, -1);
|
|
67
|
+
switch (token) {
|
|
68
|
+
case 'd': return String(date.getDate());
|
|
69
|
+
case 'dd': return pad(date.getDate(), 2);
|
|
70
|
+
case 'ddd': return name({ weekday: 'short' });
|
|
71
|
+
case 'dddd': return name({ weekday: 'long' });
|
|
72
|
+
case 'M': return String(date.getMonth() + 1);
|
|
73
|
+
case 'MM': return pad(date.getMonth() + 1, 2);
|
|
74
|
+
case 'MMM': return name({ month: 'short' });
|
|
75
|
+
case 'MMMM': return name({ month: 'long' });
|
|
76
|
+
case 'yy': return pad(date.getFullYear() % 100, 2);
|
|
77
|
+
case 'yyy':
|
|
78
|
+
case 'yyyy': return String(date.getFullYear());
|
|
79
|
+
case 'H': return String(date.getHours());
|
|
80
|
+
case 'HH': return pad(date.getHours(), 2);
|
|
81
|
+
case 'h': return String(hours12);
|
|
82
|
+
case 'hh': return pad(hours12, 2);
|
|
83
|
+
case 'm': return String(date.getMinutes());
|
|
84
|
+
case 'mm': return pad(date.getMinutes(), 2);
|
|
85
|
+
case 's': return String(date.getSeconds());
|
|
86
|
+
case 'ss': return pad(date.getSeconds(), 2);
|
|
87
|
+
case 'tt': return date.getHours() < 12 ? 'AM' : 'PM';
|
|
88
|
+
default: return token;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** Word's stored date form, `2015-01-29T00:00:00` (local, as `w:fullDate` without a zone). */
|
|
93
|
+
function isoOf(date) {
|
|
94
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
95
|
+
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
|
|
96
|
+
}
|
|
97
|
+
/** The date a bound value holds, when it is one (`2015-01-29T00:00:00`, `2015-01-29`, or with a Z). */
|
|
98
|
+
function dateOf(value) {
|
|
99
|
+
if (!/^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2})?)?/.test(value))
|
|
100
|
+
return undefined;
|
|
101
|
+
const parsed = new Date(value.replace(/Z$/, '').replace(' ', 'T'));
|
|
102
|
+
return Number.isNaN(parsed.getTime()) ? undefined : parsed;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Pushes the custom XML value into one control (docx4j BindingHandler's per-sdt work). Returns
|
|
106
|
+
* false when nothing was written: no binding, no part, an XPath that selects nothing, or a kind
|
|
107
|
+
* this phase does not handle (pictures, explicit rich text).
|
|
108
|
+
*/
|
|
109
|
+
export function applyBindingTo(control) {
|
|
110
|
+
var _a;
|
|
111
|
+
const mapping = control.xmlMapping;
|
|
112
|
+
if (!mapping.isMapped)
|
|
113
|
+
return false;
|
|
114
|
+
const node = mapping.customXmlNode;
|
|
115
|
+
if (!node)
|
|
116
|
+
return false;
|
|
117
|
+
const value = node.text.trim();
|
|
118
|
+
// A picture binding carries base64 image data; docx4j replaces the a:blip embed. Deferred (section 12).
|
|
119
|
+
if (control.type === 'Picture')
|
|
120
|
+
return false;
|
|
121
|
+
// Explicit rich text is bound from flat OPC or XHTML in docx4j; deferred, as it is there for this route.
|
|
122
|
+
if (sdtProperty(control.sdt.sdtPr, 'richText') !== undefined)
|
|
123
|
+
return false;
|
|
124
|
+
if (isContainer(control))
|
|
125
|
+
return false;
|
|
126
|
+
if (control.type === 'CheckBox') {
|
|
127
|
+
const checkbox = control.checkboxContentControl;
|
|
128
|
+
if (!checkbox)
|
|
129
|
+
return false;
|
|
130
|
+
checkbox.isChecked = isTrue(value);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
let display = value;
|
|
134
|
+
if (control.type === 'DropDownList' || control.type === 'ComboBox') {
|
|
135
|
+
const list = (_a = control.dropDownListContentControl) !== null && _a !== void 0 ? _a : control.comboBoxContentControl;
|
|
136
|
+
if (list) {
|
|
137
|
+
const match = list.listItems.find((item) => item.value === value);
|
|
138
|
+
if (match)
|
|
139
|
+
display = match.displayText;
|
|
140
|
+
list.lastValue = value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else if (control.type === 'DatePicker') {
|
|
144
|
+
const date = control.datePickerContentControl;
|
|
145
|
+
const parsed = dateOf(value);
|
|
146
|
+
if (date && parsed) {
|
|
147
|
+
date.fullDate = parsed;
|
|
148
|
+
// Word shows the date in w:dateFormat, not the stored form (docx4j formats it the same way)
|
|
149
|
+
if (date.dateFormat !== '')
|
|
150
|
+
display = formatDate(date.dateFormat, parsed, date.dateDisplayLocale || undefined);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
control.setBoundContent(runsForValue(display, control.runProperties, control.isMultiLine), display === '');
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
/** `applyBindings` over a list of controls. */
|
|
157
|
+
export function applyBindingsTo(controls) {
|
|
158
|
+
const result = { bound: 0, updated: 0, skipped: 0 };
|
|
159
|
+
for (const control of controls) {
|
|
160
|
+
if (!control.xmlMapping.isMapped)
|
|
161
|
+
continue;
|
|
162
|
+
result.bound++;
|
|
163
|
+
if (applyBindingTo(control))
|
|
164
|
+
result.updated++;
|
|
165
|
+
else
|
|
166
|
+
result.skipped++;
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Writes what one control shows back into the node it is bound to (docx4j
|
|
172
|
+
* UpdateXmlFromDocumentSurface). A checkbox writes 'true' or 'false' and a list writes the entry's
|
|
173
|
+
* value rather than its display text, which is what the data meant in the first place (docx4j
|
|
174
|
+
* writes the rendered glyph; section 12).
|
|
175
|
+
*/
|
|
176
|
+
export function updateFromControl(control) {
|
|
177
|
+
var _a, _b;
|
|
178
|
+
const mapping = control.xmlMapping;
|
|
179
|
+
if (!mapping.isMapped)
|
|
180
|
+
return false;
|
|
181
|
+
const node = mapping.customXmlNode;
|
|
182
|
+
if (!node)
|
|
183
|
+
return false;
|
|
184
|
+
if (control.type === 'Picture')
|
|
185
|
+
return false;
|
|
186
|
+
if (sdtProperty(control.sdt.sdtPr, 'richText') !== undefined)
|
|
187
|
+
return false;
|
|
188
|
+
if (isContainer(control))
|
|
189
|
+
return false;
|
|
190
|
+
// A control showing its placeholder holds no value.
|
|
191
|
+
if (control.isShowingPlaceholder)
|
|
192
|
+
return false;
|
|
193
|
+
let value = control.text;
|
|
194
|
+
if (control.type === 'CheckBox') {
|
|
195
|
+
const checkbox = control.checkboxContentControl;
|
|
196
|
+
if (!checkbox)
|
|
197
|
+
return false;
|
|
198
|
+
value = checkbox.isChecked ? 'true' : 'false';
|
|
199
|
+
}
|
|
200
|
+
else if (control.type === 'DropDownList' || control.type === 'ComboBox') {
|
|
201
|
+
const list = (_a = control.dropDownListContentControl) !== null && _a !== void 0 ? _a : control.comboBoxContentControl;
|
|
202
|
+
const match = list === null || list === void 0 ? void 0 : list.listItems.find((item) => item.displayText === value);
|
|
203
|
+
if (match)
|
|
204
|
+
value = match.value;
|
|
205
|
+
}
|
|
206
|
+
else if (control.type === 'DatePicker') {
|
|
207
|
+
// the control shows the formatted date; the data keeps Word's stored form (docx4j skips dates)
|
|
208
|
+
const full = (_b = control.datePickerContentControl) === null || _b === void 0 ? void 0 : _b.fullDate;
|
|
209
|
+
if (full)
|
|
210
|
+
value = isoOf(full);
|
|
211
|
+
}
|
|
212
|
+
if (node.text === value)
|
|
213
|
+
return false;
|
|
214
|
+
node.text = value;
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
/** `updateFromContentControls` over a list of controls. */
|
|
218
|
+
export function updateFromControls(controls) {
|
|
219
|
+
const result = { bound: 0, updated: 0, skipped: 0 };
|
|
220
|
+
for (const control of controls) {
|
|
221
|
+
if (!control.xmlMapping.isMapped)
|
|
222
|
+
continue;
|
|
223
|
+
result.bound++;
|
|
224
|
+
if (updateFromControl(control))
|
|
225
|
+
result.updated++;
|
|
226
|
+
else
|
|
227
|
+
result.skipped++;
|
|
228
|
+
}
|
|
229
|
+
return result;
|
|
230
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { type XPathEngine, type XPathValue, DefaultXPathEngine, parsePrefixMappings, formatPrefixMappings, canonicalXPathOf, xmlOf, type CanonicalXPath } from './xpath.mjs';
|
|
2
|
+
export { CustomXmlPart, CustomXmlNode, CustomXmlPrefixMappingCollection, type CustomXmlNodeType, type CustomXmlPrefixMapping, type CustomXmlPartOwner } from './CustomXmlPart.mjs';
|
|
3
|
+
export { CustomXmlPartCollection, type CustomXmlHost } from './CustomXmlPartCollection.mjs';
|
|
4
|
+
export { XmlMapping, type CustomXmlPartLookup } from './XmlMapping.mjs';
|
|
5
|
+
export { CheckboxContentControl, DatePickerContentControl, ListContentControl, ContentControlListItem, PictureContentControl, RepeatingSectionContentControl, GroupContentControl, checkboxRun, CHECKED_SYMBOL, UNCHECKED_SYMBOL, CHECKBOX_FONT, } from './kinds.mjs';
|
|
6
|
+
export { applyBindingsTo, applyBindingTo, updateFromControls, updateFromControl, runsForValue, formatDate, PLACEHOLDER_STYLE, PLACEHOLDER_TEXT, type BindingResult } from './bindings.mjs';
|
|
7
|
+
export { controlIdScope, sdtKindFor, isRunLevel } from './insert.mjs';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// CR-002 phase E: custom XML parts, XML mapping, the XPath engine and the typed content controls
|
|
2
|
+
// (CR-002 sections 3.5 and 3.6). Exported from '.' and './model', as the content API is.
|
|
3
|
+
export { DefaultXPathEngine, parsePrefixMappings, formatPrefixMappings, canonicalXPathOf, xmlOf } from './xpath.mjs';
|
|
4
|
+
export { CustomXmlPart, CustomXmlNode, CustomXmlPrefixMappingCollection } from './CustomXmlPart.mjs';
|
|
5
|
+
export { CustomXmlPartCollection } from './CustomXmlPartCollection.mjs';
|
|
6
|
+
export { XmlMapping } from './XmlMapping.mjs';
|
|
7
|
+
export { CheckboxContentControl, DatePickerContentControl, ListContentControl, ContentControlListItem, PictureContentControl, RepeatingSectionContentControl, GroupContentControl, checkboxRun, CHECKED_SYMBOL, UNCHECKED_SYMBOL, CHECKBOX_FONT, } from './kinds.mjs';
|
|
8
|
+
export { applyBindingsTo, applyBindingTo, updateFromControls, updateFromControl, runsForValue, formatDate, PLACEHOLDER_STYLE, PLACEHOLDER_TEXT } from './bindings.mjs';
|
|
9
|
+
export { controlIdScope, sdtKindFor, isRunLevel } from './insert.mjs';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SdtKind } from '@docx4j/generated-objects-ts/builders/wml';
|
|
2
|
+
import type { XmlPart } from '../../parts/XmlPart.mjs';
|
|
3
|
+
import { type Element } from '../content/tree.mjs';
|
|
4
|
+
import type { ContentControlType } from '../content/ContentControl.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* The kind the builders' `sdt` takes: Office JS's `Unknown` has no kind element, as `RichText`
|
|
7
|
+
* has none (Word reports an untyped control as rich text).
|
|
8
|
+
*/
|
|
9
|
+
export declare function sdtKindFor(kind: ContentControlType | undefined): SdtKind | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The tree a new control's `w:id` must be free in (what `nextSdtId` scans): the part's whole
|
|
12
|
+
* contents when the body has a part, so that a control added inside another control, a cell or a
|
|
13
|
+
* header still gets an id free in the part; the container itself otherwise.
|
|
14
|
+
*/
|
|
15
|
+
export declare function controlIdScope(body: {
|
|
16
|
+
part?: XmlPart<unknown> | undefined;
|
|
17
|
+
container: object;
|
|
18
|
+
}): object;
|
|
19
|
+
/** True for a run-level item (what a Range wraps). */
|
|
20
|
+
export declare function isRunLevel(element: Element): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { typeNameOf } from '../content/tree.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* The kind the builders' `sdt` takes: Office JS's `Unknown` has no kind element, as `RichText`
|
|
4
|
+
* has none (Word reports an untyped control as rich text).
|
|
5
|
+
*/
|
|
6
|
+
export function sdtKindFor(kind) {
|
|
7
|
+
return kind === undefined || kind === 'Unknown' ? undefined : kind;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The tree a new control's `w:id` must be free in (what `nextSdtId` scans): the part's whole
|
|
11
|
+
* contents when the body has a part, so that a control added inside another control, a cell or a
|
|
12
|
+
* header still gets an id free in the part; the container itself otherwise.
|
|
13
|
+
*/
|
|
14
|
+
export function controlIdScope(body) {
|
|
15
|
+
const part = body.part;
|
|
16
|
+
return (part === null || part === void 0 ? void 0 : part.isUnmarshalled) ? part.contents : body.container;
|
|
17
|
+
}
|
|
18
|
+
/** True for a run-level item (what a Range wraps). */
|
|
19
|
+
export function isRunLevel(element) {
|
|
20
|
+
const tn = typeNameOf(element);
|
|
21
|
+
return tn === 'org_docx4j_wml.R' || tn === 'org_docx4j_wml.SdtRun' || tn === 'org_docx4j_wml.P.Hyperlink';
|
|
22
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type * as wml from '@docx4j/generated-objects-ts/modules/org_docx4j_wml';
|
|
2
|
+
import type * as w14 from '@docx4j/generated-objects-ts/modules/org_docx4j_w14';
|
|
3
|
+
import type * as w15 from '@docx4j/generated-objects-ts/modules/org_docx4j_w15';
|
|
4
|
+
import type { Element } from '../content/tree.mjs';
|
|
5
|
+
import type { ContentControl } from '../content/ContentControl.mjs';
|
|
6
|
+
import type { InlinePicture } from '../content/InlinePicture.mjs';
|
|
7
|
+
/** Word's default checkbox glyphs (docx4j BindingTraverserXSLT uses the same two). */
|
|
8
|
+
export declare const CHECKED_SYMBOL = "\u2612";
|
|
9
|
+
export declare const UNCHECKED_SYMBOL = "\u2610";
|
|
10
|
+
/** The font Word writes with them. */
|
|
11
|
+
export declare const CHECKBOX_FONT = "MS Gothic";
|
|
12
|
+
/** Office JS `Word.CheckboxContentControl` over `w14:checkbox`. */
|
|
13
|
+
export declare class CheckboxContentControl {
|
|
14
|
+
private readonly control;
|
|
15
|
+
private readonly checkbox;
|
|
16
|
+
constructor(control: ContentControl, checkbox: w14.CTSdtCheckbox);
|
|
17
|
+
get isChecked(): boolean;
|
|
18
|
+
set isChecked(value: boolean);
|
|
19
|
+
/** The glyph shown when checked (`w14:checkedState/@w14:val`, a hex character code). */
|
|
20
|
+
get checkedSymbol(): string;
|
|
21
|
+
set checkedSymbol(symbol: string);
|
|
22
|
+
get uncheckedSymbol(): string;
|
|
23
|
+
set uncheckedSymbol(symbol: string);
|
|
24
|
+
/** The font of the two glyphs (extension; Word writes MS Gothic). */
|
|
25
|
+
get font(): string;
|
|
26
|
+
}
|
|
27
|
+
/** Office JS `Word.DatePickerContentControl` over `w:date`. */
|
|
28
|
+
export declare class DatePickerContentControl {
|
|
29
|
+
private readonly date;
|
|
30
|
+
constructor(date: wml.CTSdtDate);
|
|
31
|
+
/** `w:dateFormat`, Word's .NET date pattern ('d MMMM yyyy'). Office JS calls it dateDisplayFormat. */
|
|
32
|
+
get dateFormat(): string;
|
|
33
|
+
set dateFormat(format: string);
|
|
34
|
+
/** Office JS's name for the same property. */
|
|
35
|
+
get dateDisplayFormat(): string;
|
|
36
|
+
set dateDisplayFormat(format: string);
|
|
37
|
+
/** `w:lid`, the language the date is shown in ('en-AU'). */
|
|
38
|
+
get dateDisplayLocale(): string;
|
|
39
|
+
set dateDisplayLocale(locale: string);
|
|
40
|
+
/** `w:calendar` ('gregorian', 'hijri', ...). */
|
|
41
|
+
get dateCalendarType(): string;
|
|
42
|
+
set dateCalendarType(calendar: string);
|
|
43
|
+
/** `w:storeMappedDataAs`: how a bound date is written into the custom XML ('dateTime', 'date', 'text'). */
|
|
44
|
+
get dateStorageFormat(): string;
|
|
45
|
+
set dateStorageFormat(format: string);
|
|
46
|
+
/** `w:fullDate`, the date itself when Word has one (extension). */
|
|
47
|
+
get fullDate(): Date | undefined;
|
|
48
|
+
set fullDate(value: Date | undefined);
|
|
49
|
+
}
|
|
50
|
+
/** One entry of a drop-down list or combo box (Office JS `Word.ContentControlListItem`). */
|
|
51
|
+
export declare class ContentControlListItem {
|
|
52
|
+
private readonly items;
|
|
53
|
+
private readonly item;
|
|
54
|
+
constructor(items: wml.CTSdtListItem[], item: wml.CTSdtListItem);
|
|
55
|
+
get displayText(): string;
|
|
56
|
+
set displayText(text: string);
|
|
57
|
+
get value(): string;
|
|
58
|
+
set value(value: string);
|
|
59
|
+
get index(): number;
|
|
60
|
+
delete(): void;
|
|
61
|
+
}
|
|
62
|
+
/** Office JS `Word.DropDownListContentControl` / `Word.ComboBoxContentControl`: the same shape. */
|
|
63
|
+
export declare class ListContentControl {
|
|
64
|
+
private readonly list;
|
|
65
|
+
constructor(list: wml.CTSdtDropDownList | wml.CTSdtComboBox);
|
|
66
|
+
get listItems(): ContentControlListItem[];
|
|
67
|
+
/** Adds an entry; `value` defaults to the display text, `index` appends when omitted. */
|
|
68
|
+
addListItem(displayText: string, value?: string, index?: number): ContentControlListItem;
|
|
69
|
+
deleteAllListItems(): void;
|
|
70
|
+
/** `w:lastValue`, what Word last showed (extension). */
|
|
71
|
+
get lastValue(): string;
|
|
72
|
+
set lastValue(value: string);
|
|
73
|
+
}
|
|
74
|
+
/** Office JS `Word.PictureContentControl`. */
|
|
75
|
+
export declare class PictureContentControl {
|
|
76
|
+
private readonly control;
|
|
77
|
+
constructor(control: ContentControl);
|
|
78
|
+
/** The picture the control holds, if any. */
|
|
79
|
+
get inlinePicture(): InlinePicture | undefined;
|
|
80
|
+
}
|
|
81
|
+
/** Office JS `Word.RepeatingSectionContentControl` over `w15:repeatingSection`. */
|
|
82
|
+
export declare class RepeatingSectionContentControl {
|
|
83
|
+
private readonly control;
|
|
84
|
+
private readonly section;
|
|
85
|
+
constructor(control: ContentControl, section: w15.CTSdtRepeatedSection);
|
|
86
|
+
/** The repeated items: the `w15:repeatingSectionItem` controls directly inside. */
|
|
87
|
+
get items(): ContentControl[];
|
|
88
|
+
get sectionTitle(): string;
|
|
89
|
+
set sectionTitle(title: string);
|
|
90
|
+
/** Whether Word offers the + and x buttons (`w15:doNotAllowInsertDeleteSection`, inverted). */
|
|
91
|
+
get allowInsertDeleteSection(): boolean;
|
|
92
|
+
set allowInsertDeleteSection(allow: boolean);
|
|
93
|
+
/**
|
|
94
|
+
* Adds a copy of the item at `index` after it, as Word's + button does, and returns the new
|
|
95
|
+
* item's control. The copy is a deep copy with its PARENT links rebuilt by the container.
|
|
96
|
+
*/
|
|
97
|
+
insertItemAfter(index: number): ContentControl;
|
|
98
|
+
}
|
|
99
|
+
/** Office JS `Word.GroupContentControl`: no members of its own. */
|
|
100
|
+
export declare class GroupContentControl {
|
|
101
|
+
}
|
|
102
|
+
/** The `w:sdtContent` glyph run of a checkbox, as Word writes it (docx4j's binding does the same). */
|
|
103
|
+
export declare function checkboxRun(symbol: string, font: string, rPr?: wml.RPr): Element;
|