@docx4j/core-ts 0.1.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/LICENSE +202 -0
- package/NOTICE +12 -0
- package/README.md +126 -0
- package/dist/index.d.mts +7 -0
- package/dist/index.mjs +10 -0
- package/dist/model/content/Body.d.mts +107 -0
- package/dist/model/content/Body.mjs +363 -0
- package/dist/model/content/Font.d.mts +46 -0
- package/dist/model/content/Font.mjs +50 -0
- package/dist/model/content/Paragraph.d.mts +99 -0
- package/dist/model/content/Paragraph.mjs +364 -0
- package/dist/model/content/Range.d.mts +34 -0
- package/dist/model/content/Range.mjs +94 -0
- package/dist/model/content/index.d.mts +7 -0
- package/dist/model/content/index.mjs +9 -0
- package/dist/model/content/search.d.mts +12 -0
- package/dist/model/content/search.mjs +68 -0
- package/dist/model/content/tree.d.mts +40 -0
- package/dist/model/content/tree.mjs +120 -0
- package/dist/model/index.d.mts +1 -0
- package/dist/model/index.mjs +2 -0
- package/dist/opc/ContentTypeManager.d.mts +37 -0
- package/dist/opc/ContentTypeManager.mjs +126 -0
- package/dist/opc/ContentTypes.d.mts +118 -0
- package/dist/opc/ContentTypes.mjs +139 -0
- package/dist/opc/FlatOpcPartStore.d.mts +42 -0
- package/dist/opc/FlatOpcPartStore.mjs +151 -0
- package/dist/opc/Load.d.mts +18 -0
- package/dist/opc/Load.mjs +123 -0
- package/dist/opc/PartName.d.mts +46 -0
- package/dist/opc/PartName.mjs +132 -0
- package/dist/opc/PartStore.d.mts +45 -0
- package/dist/opc/PartStore.mjs +54 -0
- package/dist/opc/Save.d.mts +9 -0
- package/dist/opc/Save.mjs +52 -0
- package/dist/opc/ZipPartStore.d.mts +32 -0
- package/dist/opc/ZipPartStore.mjs +117 -0
- package/dist/opc/exceptions.d.mts +17 -0
- package/dist/opc/exceptions.mjs +22 -0
- package/dist/opc/index.d.mts +12 -0
- package/dist/opc/index.mjs +13 -0
- package/dist/opc/mce/preprocessor.d.mts +15 -0
- package/dist/opc/mce/preprocessor.mjs +74 -0
- package/dist/opc/mce/understood.d.mts +1 -0
- package/dist/opc/mce/understood.mjs +98 -0
- package/dist/packages/OpcPackage.d.mts +62 -0
- package/dist/packages/OpcPackage.mjs +133 -0
- package/dist/packages/PresentationMLPackage.d.mts +12 -0
- package/dist/packages/PresentationMLPackage.mjs +39 -0
- package/dist/packages/SpreadsheetMLPackage.d.mts +12 -0
- package/dist/packages/SpreadsheetMLPackage.mjs +38 -0
- package/dist/packages/WordprocessingMLPackage.d.mts +49 -0
- package/dist/packages/WordprocessingMLPackage.mjs +130 -0
- package/dist/packages/index.d.mts +5 -0
- package/dist/packages/index.mjs +6 -0
- package/dist/packages/registry.d.mts +7 -0
- package/dist/packages/registry.mjs +18 -0
- package/dist/parts/BinaryPart.d.mts +38 -0
- package/dist/parts/BinaryPart.mjs +72 -0
- package/dist/parts/DefaultXmlPart.d.mts +29 -0
- package/dist/parts/DefaultXmlPart.mjs +63 -0
- package/dist/parts/Namespaces.d.mts +99 -0
- package/dist/parts/Namespaces.mjs +99 -0
- package/dist/parts/Part.d.mts +50 -0
- package/dist/parts/Part.mjs +68 -0
- package/dist/parts/PartRegistry.d.mts +20 -0
- package/dist/parts/PartRegistry.mjs +142 -0
- package/dist/parts/Parts.d.mts +13 -0
- package/dist/parts/Parts.mjs +28 -0
- package/dist/parts/RelationshipsPart.d.mts +66 -0
- package/dist/parts/RelationshipsPart.mjs +224 -0
- package/dist/parts/XmlPart.d.mts +46 -0
- package/dist/parts/XmlPart.mjs +87 -0
- package/dist/parts/customXml/index.d.mts +9 -0
- package/dist/parts/customXml/index.mjs +11 -0
- package/dist/parts/dml/index.d.mts +54 -0
- package/dist/parts/dml/index.mjs +83 -0
- package/dist/parts/docProps/index.d.mts +14 -0
- package/dist/parts/docProps/index.mjs +18 -0
- package/dist/parts/index.d.mts +14 -0
- package/dist/parts/index.mjs +15 -0
- package/dist/parts/pml/index.d.mts +53 -0
- package/dist/parts/pml/index.mjs +90 -0
- package/dist/parts/sml/index.d.mts +61 -0
- package/dist/parts/sml/index.mjs +107 -0
- package/dist/parts/wml/defaultStyles.d.mts +1 -0
- package/dist/parts/wml/defaultStyles.mjs +500 -0
- package/dist/parts/wml/index.d.mts +102 -0
- package/dist/parts/wml/index.mjs +213 -0
- package/dist/xml/dom.d.mts +22 -0
- package/dist/xml/dom.mjs +92 -0
- package/package.json +75 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { isElement, typeNameOf } from '@docx4j/generated-objects-ts/builders/wml';
|
|
2
|
+
export { isElement, typeNameOf, walk, find, linkParents, textOf, W_NS } from '@docx4j/generated-objects-ts/builders/wml';
|
|
3
|
+
/** Types whose value holds runs (directly or through sdtContent); w:del is not among them: deleted text is not the text. */
|
|
4
|
+
const RUN_HOLDERS = new Set([
|
|
5
|
+
'org_docx4j_wml.P.Hyperlink', 'org_docx4j_wml.SdtRun', 'org_docx4j_wml.RunIns', 'org_docx4j_wml.CTSmartTagRun',
|
|
6
|
+
'org_docx4j_wml.CTCustomXmlRun', 'org_docx4j_wml.P.Dir', 'org_docx4j_wml.P.Bdo', 'org_docx4j_wml.CTSimpleField',
|
|
7
|
+
'org_docx4j_wml.RunTrackChange', 'org_docx4j_wml.CTSdtContentRun',
|
|
8
|
+
]);
|
|
9
|
+
/**
|
|
10
|
+
* The run-level items a holder keeps, by the model's own property names: `content` for most,
|
|
11
|
+
* `customXmlOrSmartTagOrSdt` for w:ins, w:del, w:moveFrom and w:moveTo (docx4j's names for
|
|
12
|
+
* the choice groups), `sdtContent.content` for a run-level content control.
|
|
13
|
+
*/
|
|
14
|
+
export function runItemsOf(value) {
|
|
15
|
+
const v = value;
|
|
16
|
+
if (Array.isArray(v.content))
|
|
17
|
+
return v.content;
|
|
18
|
+
if (Array.isArray(v.customXmlOrSmartTagOrSdt))
|
|
19
|
+
return v.customXmlOrSmartTagOrSdt;
|
|
20
|
+
if (v.sdtContent)
|
|
21
|
+
return runItemsOf(v.sdtContent);
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
function itemText(item) {
|
|
25
|
+
var _a, _b;
|
|
26
|
+
const t = item.name.localPart;
|
|
27
|
+
const v = item.value;
|
|
28
|
+
switch (t) {
|
|
29
|
+
case 't': return String((_a = v.value) !== null && _a !== void 0 ? _a : '');
|
|
30
|
+
case 'tab': return '\t';
|
|
31
|
+
case 'br': return '\n';
|
|
32
|
+
case 'cr': return '\n';
|
|
33
|
+
case 'noBreakHyphen': return '‑';
|
|
34
|
+
case 'softHyphen': return '';
|
|
35
|
+
case 'sym': {
|
|
36
|
+
const code = (_b = v._char) !== null && _b !== void 0 ? _b : v.char;
|
|
37
|
+
return typeof code === 'string' && /^[0-9A-Fa-f]{4}$/.test(code) ? String.fromCharCode(parseInt(code, 16)) : '';
|
|
38
|
+
}
|
|
39
|
+
default: return undefined;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** The text segments of a paragraph (or any run holder) in order. Deleted text (w:del) is skipped. */
|
|
43
|
+
export function segmentsOf(container) {
|
|
44
|
+
const out = [];
|
|
45
|
+
let pos = 0;
|
|
46
|
+
const visitRuns = (items) => {
|
|
47
|
+
var _a;
|
|
48
|
+
if (!items)
|
|
49
|
+
return;
|
|
50
|
+
for (let i = 0; i < items.length; i++) {
|
|
51
|
+
const el = items[i];
|
|
52
|
+
const tn = typeNameOf(el);
|
|
53
|
+
if (tn === 'org_docx4j_wml.R') {
|
|
54
|
+
const run = el.value;
|
|
55
|
+
const content = (_a = run.content) !== null && _a !== void 0 ? _a : [];
|
|
56
|
+
for (let j = 0; j < content.length; j++) {
|
|
57
|
+
const item = content[j];
|
|
58
|
+
const text = itemText(item);
|
|
59
|
+
if (text === undefined)
|
|
60
|
+
continue;
|
|
61
|
+
out.push({ item, owner: content, index: j, run, runOwner: items, runIndex: i, text, start: pos, end: pos + text.length, editable: item.name.localPart === 't' });
|
|
62
|
+
pos += text.length;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else if (tn !== undefined && RUN_HOLDERS.has(tn)) {
|
|
66
|
+
visitRuns(runItemsOf(el.value));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
visitRuns(runItemsOf(container));
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
/** The runs of a paragraph, direct and nested in hyperlinks, content controls and insertions, in order. */
|
|
74
|
+
export function runsOf(container) {
|
|
75
|
+
const out = [];
|
|
76
|
+
const visit = (items) => {
|
|
77
|
+
if (!items)
|
|
78
|
+
return;
|
|
79
|
+
for (const el of items) {
|
|
80
|
+
const tn = typeNameOf(el);
|
|
81
|
+
if (tn === 'org_docx4j_wml.R')
|
|
82
|
+
out.push(el);
|
|
83
|
+
else if (tn !== undefined && RUN_HOLDERS.has(tn))
|
|
84
|
+
visit(runItemsOf(el.value));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
visit(runItemsOf(container));
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
/** The block-level children of a container: body, header, footer, cell, sdt content, table (rows), row (cells). */
|
|
91
|
+
export function childrenOf(value) {
|
|
92
|
+
var _a;
|
|
93
|
+
const v = value;
|
|
94
|
+
if (v.TYPE_NAME === 'org_docx4j_wml.SdtBlock')
|
|
95
|
+
return (_a = v.sdtContent) === null || _a === void 0 ? void 0 : _a.content;
|
|
96
|
+
return Array.isArray(v.content) ? v.content : undefined;
|
|
97
|
+
}
|
|
98
|
+
/** True for what a body or cell may hold directly (the Body content union), by TYPE_NAME. */
|
|
99
|
+
export const BLOCK_LEVEL_TYPES = new Set([
|
|
100
|
+
'org_docx4j_wml.P', 'org_docx4j_wml.Tbl', 'org_docx4j_wml.SdtBlock', 'org_docx4j_wml.CTCustomXmlBlock', 'org_docx4j_wml.CTAltChunk',
|
|
101
|
+
'org_docx4j_wml.ProofErr', 'org_docx4j_wml.RangePermissionStart', 'org_docx4j_wml.CTPerm', 'org_docx4j_wml.CTBookmark',
|
|
102
|
+
'org_docx4j_wml.CTMarkupRange', 'org_docx4j_wml.CTMoveBookmark', 'org_docx4j_wml.CTMoveFromRangeEnd', 'org_docx4j_wml.CTMoveToRangeEnd',
|
|
103
|
+
'org_docx4j_wml.CommentRangeStart', 'org_docx4j_wml.CommentRangeEnd', 'org_docx4j_wml.CTTrackChange', 'org_docx4j_wml.CTMarkup',
|
|
104
|
+
'org_docx4j_wml.RunIns', 'org_docx4j_wml.RunDel', 'org_docx4j_wml.RunTrackChange', 'org_docx4j_math.CTOMathPara', 'org_docx4j_math.CTOMath',
|
|
105
|
+
]);
|
|
106
|
+
/** A run element with the given items and, optionally, run properties (the builders' r() takes text; this takes items). */
|
|
107
|
+
export function runOf(items, rPr) {
|
|
108
|
+
const value = { TYPE_NAME: 'org_docx4j_wml.R', content: items };
|
|
109
|
+
if (rPr)
|
|
110
|
+
value.rPr = rPr;
|
|
111
|
+
return { name: { namespaceURI: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', localPart: 'r' }, value };
|
|
112
|
+
}
|
|
113
|
+
/** A paragraph element with the given runs and, optionally, paragraph properties. */
|
|
114
|
+
export function paragraphOf(runs, pPr) {
|
|
115
|
+
const value = { TYPE_NAME: 'org_docx4j_wml.P', content: runs };
|
|
116
|
+
if (pPr)
|
|
117
|
+
value.pPr = pPr;
|
|
118
|
+
return { name: { namespaceURI: 'http://schemas.openxmlformats.org/wordprocessingml/2006/main', localPart: 'p' }, value };
|
|
119
|
+
}
|
|
120
|
+
export { isElement as isTypedElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './content/index.mjs';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PartName } from './PartName.mjs';
|
|
2
|
+
export declare const CONTENT_TYPES_NS = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
3
|
+
/**
|
|
4
|
+
* `[Content_Types].xml` (docx4j org.docx4j.openpackaging.contenttype.ContentTypeManager):
|
|
5
|
+
* `Default` maps an extension to a content type, `Override` a part name. Lookups are
|
|
6
|
+
* case-insensitive; the names are written back as given.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ContentTypeManager {
|
|
9
|
+
/** Extension (lower case) to content type. */
|
|
10
|
+
private readonly defaults;
|
|
11
|
+
/** Lower-cased part name to [part name as written, content type]. */
|
|
12
|
+
private readonly overrides;
|
|
13
|
+
/** A manager with the two defaults every package needs: rels and xml. */
|
|
14
|
+
static createDefault(): ContentTypeManager;
|
|
15
|
+
/** Parses `[Content_Types].xml`. */
|
|
16
|
+
static parse(xml: string): ContentTypeManager;
|
|
17
|
+
/** The XML of `[Content_Types].xml`, defaults first as Word writes it. */
|
|
18
|
+
toXml(): string;
|
|
19
|
+
/** The content type of a part: its override if any, else the default for its extension. */
|
|
20
|
+
getContentType(partName: PartName | string): string | undefined;
|
|
21
|
+
addDefaultContentType(extension: string, contentType: string): void;
|
|
22
|
+
addOverrideContentType(partName: PartName | string, contentType: string): void;
|
|
23
|
+
/** Registers a part's content type: as a default when one already covers the extension, else as an override (docx4j RelationshipsPart.addPart). */
|
|
24
|
+
addContentType(partName: PartName | string, contentType: string): void;
|
|
25
|
+
/** Removes the override for a part; when there is none, the default for its extension (docx4j semantics). */
|
|
26
|
+
removeContentType(partName: PartName | string): void;
|
|
27
|
+
removeOverrideContentType(partName: PartName | string): void;
|
|
28
|
+
removeDefaultContentType(extension: string): void;
|
|
29
|
+
getDefaultContentType(extension: string): string | undefined;
|
|
30
|
+
getOverrideContentType(partName: PartName | string): string | undefined;
|
|
31
|
+
/** Whether any default or override names this content type. */
|
|
32
|
+
isContentTypeRegistered(contentType: string): boolean;
|
|
33
|
+
/** Part names overridden to a content type (docx4j getPartNameOverridenByContentType, all of them). */
|
|
34
|
+
getPartNamesForContentType(contentType: string): PartName[];
|
|
35
|
+
get defaultEntries(): ReadonlyMap<string, string>;
|
|
36
|
+
get overrideEntries(): [PartName, string][];
|
|
37
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { PartName } from './PartName.mjs';
|
|
2
|
+
import { ContentTypes } from './ContentTypes.mjs';
|
|
3
|
+
import { InvalidFormatException } from './exceptions.mjs';
|
|
4
|
+
import { XML_DECLARATION, parseXml, childElements } from '../xml/dom.mjs';
|
|
5
|
+
export const CONTENT_TYPES_NS = 'http://schemas.openxmlformats.org/package/2006/content-types';
|
|
6
|
+
/**
|
|
7
|
+
* `[Content_Types].xml` (docx4j org.docx4j.openpackaging.contenttype.ContentTypeManager):
|
|
8
|
+
* `Default` maps an extension to a content type, `Override` a part name. Lookups are
|
|
9
|
+
* case-insensitive; the names are written back as given.
|
|
10
|
+
*/
|
|
11
|
+
export class ContentTypeManager {
|
|
12
|
+
constructor() {
|
|
13
|
+
/** Extension (lower case) to content type. */
|
|
14
|
+
this.defaults = new Map();
|
|
15
|
+
/** Lower-cased part name to [part name as written, content type]. */
|
|
16
|
+
this.overrides = new Map();
|
|
17
|
+
}
|
|
18
|
+
/** A manager with the two defaults every package needs: rels and xml. */
|
|
19
|
+
static createDefault() {
|
|
20
|
+
const ctm = new ContentTypeManager();
|
|
21
|
+
ctm.addDefaultContentType('rels', ContentTypes.RELATIONSHIPS_PART);
|
|
22
|
+
ctm.addDefaultContentType('xml', ContentTypes.APPLICATION_XML);
|
|
23
|
+
return ctm;
|
|
24
|
+
}
|
|
25
|
+
/** Parses `[Content_Types].xml`. */
|
|
26
|
+
static parse(xml) {
|
|
27
|
+
const ctm = new ContentTypeManager();
|
|
28
|
+
const doc = parseXml(xml);
|
|
29
|
+
const root = doc.documentElement;
|
|
30
|
+
if (root.localName !== 'Types')
|
|
31
|
+
throw new InvalidFormatException(`[Content_Types].xml: expected Types, found ${root.nodeName}`);
|
|
32
|
+
for (const el of childElements(root)) {
|
|
33
|
+
if (el.localName === 'Default') {
|
|
34
|
+
const ext = el.getAttribute('Extension');
|
|
35
|
+
const ct = el.getAttribute('ContentType');
|
|
36
|
+
if (ext !== null && ct !== null)
|
|
37
|
+
ctm.addDefaultContentType(ext, ct);
|
|
38
|
+
}
|
|
39
|
+
else if (el.localName === 'Override') {
|
|
40
|
+
const name = el.getAttribute('PartName');
|
|
41
|
+
const ct = el.getAttribute('ContentType');
|
|
42
|
+
if (name !== null && ct !== null)
|
|
43
|
+
ctm.addOverrideContentType(name, ct);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return ctm;
|
|
47
|
+
}
|
|
48
|
+
/** The XML of `[Content_Types].xml`, defaults first as Word writes it. */
|
|
49
|
+
toXml() {
|
|
50
|
+
let out = `${XML_DECLARATION}<Types xmlns="${CONTENT_TYPES_NS}">`;
|
|
51
|
+
for (const [ext, ct] of this.defaults)
|
|
52
|
+
out += `<Default Extension="${escapeAttr(ext)}" ContentType="${escapeAttr(ct)}"/>`;
|
|
53
|
+
for (const [, [name, ct]] of this.overrides)
|
|
54
|
+
out += `<Override PartName="${escapeAttr(name)}" ContentType="${escapeAttr(ct)}"/>`;
|
|
55
|
+
return out + '</Types>';
|
|
56
|
+
}
|
|
57
|
+
/** The content type of a part: its override if any, else the default for its extension. */
|
|
58
|
+
getContentType(partName) {
|
|
59
|
+
const pn = PartName.of(partName);
|
|
60
|
+
const override = this.overrides.get(pn.key);
|
|
61
|
+
if (override)
|
|
62
|
+
return override[1];
|
|
63
|
+
return this.defaults.get(pn.extension.toLowerCase());
|
|
64
|
+
}
|
|
65
|
+
addDefaultContentType(extension, contentType) {
|
|
66
|
+
this.defaults.set(extension.toLowerCase(), contentType);
|
|
67
|
+
}
|
|
68
|
+
addOverrideContentType(partName, contentType) {
|
|
69
|
+
const pn = PartName.of(partName);
|
|
70
|
+
this.overrides.set(pn.key, [pn.name, contentType]);
|
|
71
|
+
}
|
|
72
|
+
/** Registers a part's content type: as a default when one already covers the extension, else as an override (docx4j RelationshipsPart.addPart). */
|
|
73
|
+
addContentType(partName, contentType) {
|
|
74
|
+
const pn = PartName.of(partName);
|
|
75
|
+
if (this.defaults.get(pn.extension.toLowerCase()) === contentType)
|
|
76
|
+
return;
|
|
77
|
+
this.addOverrideContentType(pn, contentType);
|
|
78
|
+
}
|
|
79
|
+
/** Removes the override for a part; when there is none, the default for its extension (docx4j semantics). */
|
|
80
|
+
removeContentType(partName) {
|
|
81
|
+
const pn = PartName.of(partName);
|
|
82
|
+
if (this.overrides.delete(pn.key))
|
|
83
|
+
return;
|
|
84
|
+
this.defaults.delete(pn.extension.toLowerCase());
|
|
85
|
+
}
|
|
86
|
+
removeOverrideContentType(partName) {
|
|
87
|
+
this.overrides.delete(PartName.of(partName).key);
|
|
88
|
+
}
|
|
89
|
+
removeDefaultContentType(extension) {
|
|
90
|
+
this.defaults.delete(extension.toLowerCase());
|
|
91
|
+
}
|
|
92
|
+
getDefaultContentType(extension) {
|
|
93
|
+
return this.defaults.get(extension.toLowerCase());
|
|
94
|
+
}
|
|
95
|
+
getOverrideContentType(partName) {
|
|
96
|
+
var _a;
|
|
97
|
+
return (_a = this.overrides.get(PartName.of(partName).key)) === null || _a === void 0 ? void 0 : _a[1];
|
|
98
|
+
}
|
|
99
|
+
/** Whether any default or override names this content type. */
|
|
100
|
+
isContentTypeRegistered(contentType) {
|
|
101
|
+
for (const ct of this.defaults.values())
|
|
102
|
+
if (ct === contentType)
|
|
103
|
+
return true;
|
|
104
|
+
for (const [, ct] of this.overrides.values())
|
|
105
|
+
if (ct === contentType)
|
|
106
|
+
return true;
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
/** Part names overridden to a content type (docx4j getPartNameOverridenByContentType, all of them). */
|
|
110
|
+
getPartNamesForContentType(contentType) {
|
|
111
|
+
const out = [];
|
|
112
|
+
for (const [name, ct] of this.overrides.values())
|
|
113
|
+
if (ct === contentType)
|
|
114
|
+
out.push(PartName.of(name));
|
|
115
|
+
return out;
|
|
116
|
+
}
|
|
117
|
+
get defaultEntries() {
|
|
118
|
+
return this.defaults;
|
|
119
|
+
}
|
|
120
|
+
get overrideEntries() {
|
|
121
|
+
return [...this.overrides.values()].map(([name, ct]) => [PartName.of(name), ct]);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function escapeAttr(s) {
|
|
125
|
+
return s.replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
|
126
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/** Content type constants, as docx4j org.docx4j.openpackaging.contenttype.ContentTypes. */
|
|
2
|
+
export declare const ContentTypes: {
|
|
3
|
+
readonly CONTENT_TYPES_PART: "application/vnd.openxmlformats-package.content-types+xml";
|
|
4
|
+
readonly RELATIONSHIPS_PART: "application/vnd.openxmlformats-package.relationships+xml";
|
|
5
|
+
readonly APPLICATION_XML: "application/xml";
|
|
6
|
+
readonly XML: "text/xml";
|
|
7
|
+
readonly PACKAGE_COREPROPERTIES: "application/vnd.openxmlformats-package.core-properties+xml";
|
|
8
|
+
readonly OFFICEDOCUMENT_CUSTOMPROPERTIES: "application/vnd.openxmlformats-officedocument.custom-properties+xml";
|
|
9
|
+
readonly OFFICEDOCUMENT_EXTENDEDPROPERTIES: "application/vnd.openxmlformats-officedocument.extended-properties+xml";
|
|
10
|
+
readonly OFFICEDOCUMENT_CUSTOMXML_DATASTORAGEPROPERTIES: "application/vnd.openxmlformats-officedocument.customXmlProperties+xml";
|
|
11
|
+
readonly OFFICEDOCUMENT_CUSTOMXML_DATASTORAGE: "application/xml";
|
|
12
|
+
readonly OFFICEDOCUMENT_THEME: "application/vnd.openxmlformats-officedocument.theme+xml";
|
|
13
|
+
readonly OFFICEDOCUMENT_THEME_OVERRIDE: "application/vnd.openxmlformats-officedocument.themeOverride+xml";
|
|
14
|
+
readonly OFFICEDOCUMENT_FONT: "application/vnd.openxmlformats-officedocument.obfuscatedFont";
|
|
15
|
+
readonly TRUETYPE_FONT: "application/x-font-ttf";
|
|
16
|
+
readonly OFFICEDOCUMENT_VBA_PROJECT: "application/vnd.ms-office.vbaProject";
|
|
17
|
+
readonly OFFICEDOCUMENT_VBA_DATA: "application/vnd.ms-word.vbaData+xml";
|
|
18
|
+
readonly OFFICEDOCUMENT_VBA_PROJECT_SIGNATURE: "application/vnd.ms-office.vbaProjectSignature";
|
|
19
|
+
readonly OFFICEDOCUMENT_OLE_OBJECT: "application/vnd.openxmlformats-officedocument.oleObject";
|
|
20
|
+
readonly OFFICEDOCUMENT_ACTIVEX_OBJECT: "application/vnd.ms-office.activeX";
|
|
21
|
+
readonly OFFICEDOCUMENT_ACTIVEX_XML_OBJECT: "application/vnd.ms-office.activeX+xml";
|
|
22
|
+
readonly WEB_EXTENSION_TASKPANES: "application/vnd.ms-office.webextensiontaskpanes+xml";
|
|
23
|
+
readonly WEB_EXTENSION_WEBEXTENSION: "application/vnd.ms-office.webextension+xml";
|
|
24
|
+
readonly WORDPROCESSINGML_DOCUMENT: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
|
|
25
|
+
readonly WORDPROCESSINGML_DOCUMENT_MACROENABLED: "application/vnd.ms-word.document.macroEnabled.main+xml";
|
|
26
|
+
readonly WORDPROCESSINGML_TEMPLATE: "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml";
|
|
27
|
+
readonly WORDPROCESSINGML_TEMPLATE_MACROENABLED: "application/vnd.ms-word.template.macroEnabledTemplate.main+xml";
|
|
28
|
+
readonly WORDPROCESSINGML_COMMENTS: "application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml";
|
|
29
|
+
readonly WORDPROCESSINGML_COMMENTS_EXTENDED: "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml";
|
|
30
|
+
readonly WORDPROCESSINGML_COMMENTS_IDS: "application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml";
|
|
31
|
+
readonly WORDPROCESSINGML_ENDNOTES: "application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml";
|
|
32
|
+
readonly WORDPROCESSINGML_FONTTABLE: "application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml";
|
|
33
|
+
readonly WORDPROCESSINGML_FOOTER: "application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml";
|
|
34
|
+
readonly WORDPROCESSINGML_FOOTNOTES: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml";
|
|
35
|
+
readonly WORDPROCESSINGML_GLOSSARYDOCUMENT: "application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml";
|
|
36
|
+
readonly WORDPROCESSINGML_HEADER: "application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml";
|
|
37
|
+
readonly MS_WORD_KEYMAP: "application/vnd.ms-word.keyMapCustomizations+xml";
|
|
38
|
+
readonly WORDPROCESSINGML_NUMBERING: "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml";
|
|
39
|
+
readonly WORDPROCESSINGML_PEOPLE: "application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml";
|
|
40
|
+
readonly WORDPROCESSINGML_SETTINGS: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml";
|
|
41
|
+
readonly WORDPROCESSINGML_STYLES: "application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml";
|
|
42
|
+
readonly WORDPROCESSINGML_STYLESWITHEFFECTS: "application/vnd.ms-word.stylesWithEffects+xml";
|
|
43
|
+
readonly WORDPROCESSINGML_WEBSETTINGS: "application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml";
|
|
44
|
+
readonly DRAWINGML_DIAGRAM_DATA: "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml";
|
|
45
|
+
readonly DRAWINGML_DIAGRAM_LAYOUT: "application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml";
|
|
46
|
+
readonly DRAWINGML_DIAGRAM_COLORS: "application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml";
|
|
47
|
+
readonly DRAWINGML_DIAGRAM_STYLE: "application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml";
|
|
48
|
+
readonly DRAWINGML_DIAGRAM_LAYOUT_HEADER: "application/vnd.openxmlformats-officedocument.drawingml.diagramLayoutHeader+xml";
|
|
49
|
+
readonly DRAWINGML_DIAGRAM_DRAWING: "application/vnd.ms-office.drawingml.diagramDrawing+xml";
|
|
50
|
+
readonly DRAWINGML_CHART: "application/vnd.openxmlformats-officedocument.drawingml.chart+xml";
|
|
51
|
+
readonly DRAWINGML_DRAWING: "application/vnd.openxmlformats-officedocument.drawing+xml";
|
|
52
|
+
readonly DRAWINGML_CHART_SHAPES: "application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml";
|
|
53
|
+
readonly CHART_EX: "application/vnd.ms-office.chartex+xml";
|
|
54
|
+
readonly CHART_STYLE: "application/vnd.ms-office.chartstyle+xml";
|
|
55
|
+
readonly CHART_COLOR_STYLE: "application/vnd.ms-office.chartcolorstyle+xml";
|
|
56
|
+
readonly VML_DRAWING: "application/vnd.openxmlformats-officedocument.vmlDrawing";
|
|
57
|
+
readonly PRESENTATION: "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
58
|
+
readonly PRESENTATIONML_MAIN: "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml";
|
|
59
|
+
readonly PRESENTATIONML_MACROENABLED: "application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml";
|
|
60
|
+
readonly PRESENTATIONML_TEMPLATE: "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml";
|
|
61
|
+
readonly PRESENTATIONML_TEMPLATE_MACROENABLED: "application/vnd.ms-powerpoint.template.macroEnabled.main+xml";
|
|
62
|
+
readonly PRESENTATIONML_SLIDESHOW: "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml";
|
|
63
|
+
readonly PRESENTATIONML_COMMENTS: "application/vnd.openxmlformats-officedocument.presentationml.comments+xml";
|
|
64
|
+
readonly PRESENTATIONML_COMMENT_AUTHORS: "application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml";
|
|
65
|
+
readonly PRESENTATIONML_FONT_DATA: "application/x-fontdata";
|
|
66
|
+
readonly PRESENTATIONML_SLIDE: "application/vnd.openxmlformats-officedocument.presentationml.slide+xml";
|
|
67
|
+
readonly PRESENTATIONML_SLIDE_MASTER: "application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml";
|
|
68
|
+
readonly PRESENTATIONML_SLIDE_LAYOUT: "application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml";
|
|
69
|
+
readonly PRESENTATIONML_TABLE_STYLES: "application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml";
|
|
70
|
+
readonly PRESENTATIONML_PRES_PROPS: "application/vnd.openxmlformats-officedocument.presentationml.presProps+xml";
|
|
71
|
+
readonly PRESENTATIONML_VIEW_PROPS: "application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml";
|
|
72
|
+
readonly PRESENTATIONML_TAGS: "application/vnd.openxmlformats-officedocument.presentationml.tags+xml";
|
|
73
|
+
readonly PRESENTATIONML_NOTES_SLIDE: "application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml";
|
|
74
|
+
readonly PRESENTATIONML_NOTES_MASTER: "application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml";
|
|
75
|
+
readonly PRESENTATIONML_HANDOUT_MASTER: "application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml";
|
|
76
|
+
readonly SPREADSHEETML_WORKBOOK: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml";
|
|
77
|
+
readonly SPREADSHEETML_WORKBOOK_MACROENABLED: "application/vnd.ms-excel.sheet.macroEnabled.main+xml";
|
|
78
|
+
readonly SPREADSHEETML_TEMPLATE: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml";
|
|
79
|
+
readonly SPREADSHEETML_TEMPLATE_MACROENABLED: "application/vnd.ms-excel.template.macroEnabled.main+xml";
|
|
80
|
+
readonly SPREADSHEETML_PRINTER_SETTINGS: "application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings";
|
|
81
|
+
readonly SPREADSHEETML_STYLES: "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml";
|
|
82
|
+
readonly SPREADSHEETML_WORKSHEET: "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
|
|
83
|
+
readonly SPREADSHEETML_CHARTSHEET: "application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml";
|
|
84
|
+
readonly SPREADSHEETML_CALC_CHAIN: "application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml";
|
|
85
|
+
readonly SPREADSHEETML_SHARED_STRINGS: "application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml";
|
|
86
|
+
readonly SPREADSHEETML_PIVOT_CACHE_DEFINITION: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml";
|
|
87
|
+
readonly SPREADSHEETML_PIVOT_CACHE_RECORDS: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml";
|
|
88
|
+
readonly SPREADSHEETML_PIVOT_TABLE: "application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml";
|
|
89
|
+
readonly SPREADSHEETML_QUERY_TABLE: "application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml";
|
|
90
|
+
readonly SPREADSHEETML_TABLE: "application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml";
|
|
91
|
+
readonly SPREADSHEETML_COMMENTS: "application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml";
|
|
92
|
+
readonly SPREADSHEETML_CONNECTIONS: "application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml";
|
|
93
|
+
readonly SPREADSHEETML_EXTERNAL_LINK: "application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml";
|
|
94
|
+
readonly DIGITAL_SIGNATURE_ORIGIN_PART: "application/vnd.openxmlformats-package.digital-signature-origin";
|
|
95
|
+
readonly DIGITAL_SIGNATURE_XML_SIGNATURE_PART: "application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml";
|
|
96
|
+
readonly INK_ML: "application/inkml+xml";
|
|
97
|
+
readonly IMAGE_EMF: "image/x-emf";
|
|
98
|
+
readonly IMAGE_EMF2: "image/emf";
|
|
99
|
+
readonly IMAGE_WMF: "image/x-wmf";
|
|
100
|
+
readonly IMAGE_GIF: "image/gif";
|
|
101
|
+
readonly IMAGE_JPEG: "image/jpeg";
|
|
102
|
+
readonly IMAGE_JPEG_XR: "image/vnd.ms-photo";
|
|
103
|
+
readonly IMAGE_PICT: "image/pict";
|
|
104
|
+
readonly IMAGE_PNG: "image/png";
|
|
105
|
+
readonly IMAGE_X_PNG: "image/x-png";
|
|
106
|
+
readonly IMAGE_TIFF: "image/tiff";
|
|
107
|
+
readonly IMAGE_WEBP: "image/webp";
|
|
108
|
+
readonly IMAGE_EPS: "application/postscript";
|
|
109
|
+
readonly IMAGE_BMP: "image/bmp";
|
|
110
|
+
readonly IMAGE_SVG: "image/svg+xml";
|
|
111
|
+
readonly OCTET_STREAM: "application/octet-stream";
|
|
112
|
+
};
|
|
113
|
+
/** Content type by lower-case file extension for the image kinds the object model relates to. */
|
|
114
|
+
export declare const IMAGE_CONTENT_TYPES_BY_EXTENSION: Readonly<Record<string, string>>;
|
|
115
|
+
/** Whether bytes of this content type are XML (parsed to a DOM when the registry has no typed part). */
|
|
116
|
+
export declare function isXmlContentType(contentType: string | undefined): boolean;
|
|
117
|
+
/** Already-compressed media, stored rather than deflated in a zip (docx4j ZipPartStore.shouldCompress). */
|
|
118
|
+
export declare function isStoredUncompressed(contentType: string | undefined): boolean;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Content type constants, as docx4j org.docx4j.openpackaging.contenttype.ContentTypes. */
|
|
2
|
+
export const ContentTypes = {
|
|
3
|
+
CONTENT_TYPES_PART: 'application/vnd.openxmlformats-package.content-types+xml',
|
|
4
|
+
RELATIONSHIPS_PART: 'application/vnd.openxmlformats-package.relationships+xml',
|
|
5
|
+
APPLICATION_XML: 'application/xml',
|
|
6
|
+
XML: 'text/xml',
|
|
7
|
+
PACKAGE_COREPROPERTIES: 'application/vnd.openxmlformats-package.core-properties+xml',
|
|
8
|
+
OFFICEDOCUMENT_CUSTOMPROPERTIES: 'application/vnd.openxmlformats-officedocument.custom-properties+xml',
|
|
9
|
+
OFFICEDOCUMENT_EXTENDEDPROPERTIES: 'application/vnd.openxmlformats-officedocument.extended-properties+xml',
|
|
10
|
+
OFFICEDOCUMENT_CUSTOMXML_DATASTORAGEPROPERTIES: 'application/vnd.openxmlformats-officedocument.customXmlProperties+xml',
|
|
11
|
+
OFFICEDOCUMENT_CUSTOMXML_DATASTORAGE: 'application/xml',
|
|
12
|
+
OFFICEDOCUMENT_THEME: 'application/vnd.openxmlformats-officedocument.theme+xml',
|
|
13
|
+
OFFICEDOCUMENT_THEME_OVERRIDE: 'application/vnd.openxmlformats-officedocument.themeOverride+xml',
|
|
14
|
+
OFFICEDOCUMENT_FONT: 'application/vnd.openxmlformats-officedocument.obfuscatedFont',
|
|
15
|
+
TRUETYPE_FONT: 'application/x-font-ttf',
|
|
16
|
+
OFFICEDOCUMENT_VBA_PROJECT: 'application/vnd.ms-office.vbaProject',
|
|
17
|
+
OFFICEDOCUMENT_VBA_DATA: 'application/vnd.ms-word.vbaData+xml',
|
|
18
|
+
OFFICEDOCUMENT_VBA_PROJECT_SIGNATURE: 'application/vnd.ms-office.vbaProjectSignature',
|
|
19
|
+
OFFICEDOCUMENT_OLE_OBJECT: 'application/vnd.openxmlformats-officedocument.oleObject',
|
|
20
|
+
OFFICEDOCUMENT_ACTIVEX_OBJECT: 'application/vnd.ms-office.activeX',
|
|
21
|
+
OFFICEDOCUMENT_ACTIVEX_XML_OBJECT: 'application/vnd.ms-office.activeX+xml',
|
|
22
|
+
WEB_EXTENSION_TASKPANES: 'application/vnd.ms-office.webextensiontaskpanes+xml',
|
|
23
|
+
WEB_EXTENSION_WEBEXTENSION: 'application/vnd.ms-office.webextension+xml',
|
|
24
|
+
WORDPROCESSINGML_DOCUMENT: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml',
|
|
25
|
+
WORDPROCESSINGML_DOCUMENT_MACROENABLED: 'application/vnd.ms-word.document.macroEnabled.main+xml',
|
|
26
|
+
WORDPROCESSINGML_TEMPLATE: 'application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml',
|
|
27
|
+
WORDPROCESSINGML_TEMPLATE_MACROENABLED: 'application/vnd.ms-word.template.macroEnabledTemplate.main+xml',
|
|
28
|
+
WORDPROCESSINGML_COMMENTS: 'application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml',
|
|
29
|
+
WORDPROCESSINGML_COMMENTS_EXTENDED: 'application/vnd.openxmlformats-officedocument.wordprocessingml.commentsExtended+xml',
|
|
30
|
+
WORDPROCESSINGML_COMMENTS_IDS: 'application/vnd.openxmlformats-officedocument.wordprocessingml.commentsIds+xml',
|
|
31
|
+
WORDPROCESSINGML_ENDNOTES: 'application/vnd.openxmlformats-officedocument.wordprocessingml.endnotes+xml',
|
|
32
|
+
WORDPROCESSINGML_FONTTABLE: 'application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml',
|
|
33
|
+
WORDPROCESSINGML_FOOTER: 'application/vnd.openxmlformats-officedocument.wordprocessingml.footer+xml',
|
|
34
|
+
WORDPROCESSINGML_FOOTNOTES: 'application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml',
|
|
35
|
+
WORDPROCESSINGML_GLOSSARYDOCUMENT: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.glossary+xml',
|
|
36
|
+
WORDPROCESSINGML_HEADER: 'application/vnd.openxmlformats-officedocument.wordprocessingml.header+xml',
|
|
37
|
+
MS_WORD_KEYMAP: 'application/vnd.ms-word.keyMapCustomizations+xml',
|
|
38
|
+
WORDPROCESSINGML_NUMBERING: 'application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml',
|
|
39
|
+
WORDPROCESSINGML_PEOPLE: 'application/vnd.openxmlformats-officedocument.wordprocessingml.people+xml',
|
|
40
|
+
WORDPROCESSINGML_SETTINGS: 'application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml',
|
|
41
|
+
WORDPROCESSINGML_STYLES: 'application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml',
|
|
42
|
+
WORDPROCESSINGML_STYLESWITHEFFECTS: 'application/vnd.ms-word.stylesWithEffects+xml',
|
|
43
|
+
WORDPROCESSINGML_WEBSETTINGS: 'application/vnd.openxmlformats-officedocument.wordprocessingml.webSettings+xml',
|
|
44
|
+
DRAWINGML_DIAGRAM_DATA: 'application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml',
|
|
45
|
+
DRAWINGML_DIAGRAM_LAYOUT: 'application/vnd.openxmlformats-officedocument.drawingml.diagramLayout+xml',
|
|
46
|
+
DRAWINGML_DIAGRAM_COLORS: 'application/vnd.openxmlformats-officedocument.drawingml.diagramColors+xml',
|
|
47
|
+
DRAWINGML_DIAGRAM_STYLE: 'application/vnd.openxmlformats-officedocument.drawingml.diagramStyle+xml',
|
|
48
|
+
DRAWINGML_DIAGRAM_LAYOUT_HEADER: 'application/vnd.openxmlformats-officedocument.drawingml.diagramLayoutHeader+xml',
|
|
49
|
+
DRAWINGML_DIAGRAM_DRAWING: 'application/vnd.ms-office.drawingml.diagramDrawing+xml',
|
|
50
|
+
DRAWINGML_CHART: 'application/vnd.openxmlformats-officedocument.drawingml.chart+xml',
|
|
51
|
+
DRAWINGML_DRAWING: 'application/vnd.openxmlformats-officedocument.drawing+xml',
|
|
52
|
+
DRAWINGML_CHART_SHAPES: 'application/vnd.openxmlformats-officedocument.drawingml.chartshapes+xml',
|
|
53
|
+
CHART_EX: 'application/vnd.ms-office.chartex+xml',
|
|
54
|
+
CHART_STYLE: 'application/vnd.ms-office.chartstyle+xml',
|
|
55
|
+
CHART_COLOR_STYLE: 'application/vnd.ms-office.chartcolorstyle+xml',
|
|
56
|
+
VML_DRAWING: 'application/vnd.openxmlformats-officedocument.vmlDrawing',
|
|
57
|
+
PRESENTATION: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
58
|
+
PRESENTATIONML_MAIN: 'application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml',
|
|
59
|
+
PRESENTATIONML_MACROENABLED: 'application/vnd.ms-powerpoint.presentation.macroEnabled.main+xml',
|
|
60
|
+
PRESENTATIONML_TEMPLATE: 'application/vnd.openxmlformats-officedocument.presentationml.template.main+xml',
|
|
61
|
+
PRESENTATIONML_TEMPLATE_MACROENABLED: 'application/vnd.ms-powerpoint.template.macroEnabled.main+xml',
|
|
62
|
+
PRESENTATIONML_SLIDESHOW: 'application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml',
|
|
63
|
+
PRESENTATIONML_COMMENTS: 'application/vnd.openxmlformats-officedocument.presentationml.comments+xml',
|
|
64
|
+
PRESENTATIONML_COMMENT_AUTHORS: 'application/vnd.openxmlformats-officedocument.presentationml.commentAuthors+xml',
|
|
65
|
+
PRESENTATIONML_FONT_DATA: 'application/x-fontdata',
|
|
66
|
+
PRESENTATIONML_SLIDE: 'application/vnd.openxmlformats-officedocument.presentationml.slide+xml',
|
|
67
|
+
PRESENTATIONML_SLIDE_MASTER: 'application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml',
|
|
68
|
+
PRESENTATIONML_SLIDE_LAYOUT: 'application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml',
|
|
69
|
+
PRESENTATIONML_TABLE_STYLES: 'application/vnd.openxmlformats-officedocument.presentationml.tableStyles+xml',
|
|
70
|
+
PRESENTATIONML_PRES_PROPS: 'application/vnd.openxmlformats-officedocument.presentationml.presProps+xml',
|
|
71
|
+
PRESENTATIONML_VIEW_PROPS: 'application/vnd.openxmlformats-officedocument.presentationml.viewProps+xml',
|
|
72
|
+
PRESENTATIONML_TAGS: 'application/vnd.openxmlformats-officedocument.presentationml.tags+xml',
|
|
73
|
+
PRESENTATIONML_NOTES_SLIDE: 'application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml',
|
|
74
|
+
PRESENTATIONML_NOTES_MASTER: 'application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml',
|
|
75
|
+
PRESENTATIONML_HANDOUT_MASTER: 'application/vnd.openxmlformats-officedocument.presentationml.handoutMaster+xml',
|
|
76
|
+
SPREADSHEETML_WORKBOOK: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml',
|
|
77
|
+
SPREADSHEETML_WORKBOOK_MACROENABLED: 'application/vnd.ms-excel.sheet.macroEnabled.main+xml',
|
|
78
|
+
SPREADSHEETML_TEMPLATE: 'application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml',
|
|
79
|
+
SPREADSHEETML_TEMPLATE_MACROENABLED: 'application/vnd.ms-excel.template.macroEnabled.main+xml',
|
|
80
|
+
SPREADSHEETML_PRINTER_SETTINGS: 'application/vnd.openxmlformats-officedocument.spreadsheetml.printerSettings',
|
|
81
|
+
SPREADSHEETML_STYLES: 'application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml',
|
|
82
|
+
SPREADSHEETML_WORKSHEET: 'application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml',
|
|
83
|
+
SPREADSHEETML_CHARTSHEET: 'application/vnd.openxmlformats-officedocument.spreadsheetml.chartsheet+xml',
|
|
84
|
+
SPREADSHEETML_CALC_CHAIN: 'application/vnd.openxmlformats-officedocument.spreadsheetml.calcChain+xml',
|
|
85
|
+
SPREADSHEETML_SHARED_STRINGS: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sharedStrings+xml',
|
|
86
|
+
SPREADSHEETML_PIVOT_CACHE_DEFINITION: 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheDefinition+xml',
|
|
87
|
+
SPREADSHEETML_PIVOT_CACHE_RECORDS: 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotCacheRecords+xml',
|
|
88
|
+
SPREADSHEETML_PIVOT_TABLE: 'application/vnd.openxmlformats-officedocument.spreadsheetml.pivotTable+xml',
|
|
89
|
+
SPREADSHEETML_QUERY_TABLE: 'application/vnd.openxmlformats-officedocument.spreadsheetml.queryTable+xml',
|
|
90
|
+
SPREADSHEETML_TABLE: 'application/vnd.openxmlformats-officedocument.spreadsheetml.table+xml',
|
|
91
|
+
SPREADSHEETML_COMMENTS: 'application/vnd.openxmlformats-officedocument.spreadsheetml.comments+xml',
|
|
92
|
+
SPREADSHEETML_CONNECTIONS: 'application/vnd.openxmlformats-officedocument.spreadsheetml.connections+xml',
|
|
93
|
+
SPREADSHEETML_EXTERNAL_LINK: 'application/vnd.openxmlformats-officedocument.spreadsheetml.externalLink+xml',
|
|
94
|
+
DIGITAL_SIGNATURE_ORIGIN_PART: 'application/vnd.openxmlformats-package.digital-signature-origin',
|
|
95
|
+
DIGITAL_SIGNATURE_XML_SIGNATURE_PART: 'application/vnd.openxmlformats-package.digital-signature-xmlsignature+xml',
|
|
96
|
+
INK_ML: 'application/inkml+xml',
|
|
97
|
+
IMAGE_EMF: 'image/x-emf',
|
|
98
|
+
IMAGE_EMF2: 'image/emf',
|
|
99
|
+
IMAGE_WMF: 'image/x-wmf',
|
|
100
|
+
IMAGE_GIF: 'image/gif',
|
|
101
|
+
IMAGE_JPEG: 'image/jpeg',
|
|
102
|
+
IMAGE_JPEG_XR: 'image/vnd.ms-photo',
|
|
103
|
+
IMAGE_PICT: 'image/pict',
|
|
104
|
+
IMAGE_PNG: 'image/png',
|
|
105
|
+
IMAGE_X_PNG: 'image/x-png',
|
|
106
|
+
IMAGE_TIFF: 'image/tiff',
|
|
107
|
+
IMAGE_WEBP: 'image/webp',
|
|
108
|
+
IMAGE_EPS: 'application/postscript',
|
|
109
|
+
IMAGE_BMP: 'image/bmp',
|
|
110
|
+
IMAGE_SVG: 'image/svg+xml',
|
|
111
|
+
OCTET_STREAM: 'application/octet-stream',
|
|
112
|
+
};
|
|
113
|
+
/** Content type by lower-case file extension for the image kinds the object model relates to. */
|
|
114
|
+
export const IMAGE_CONTENT_TYPES_BY_EXTENSION = {
|
|
115
|
+
png: ContentTypes.IMAGE_PNG,
|
|
116
|
+
jpg: ContentTypes.IMAGE_JPEG,
|
|
117
|
+
jpeg: ContentTypes.IMAGE_JPEG,
|
|
118
|
+
gif: ContentTypes.IMAGE_GIF,
|
|
119
|
+
bmp: ContentTypes.IMAGE_BMP,
|
|
120
|
+
tif: ContentTypes.IMAGE_TIFF,
|
|
121
|
+
tiff: ContentTypes.IMAGE_TIFF,
|
|
122
|
+
emf: ContentTypes.IMAGE_EMF,
|
|
123
|
+
wmf: ContentTypes.IMAGE_WMF,
|
|
124
|
+
svg: ContentTypes.IMAGE_SVG,
|
|
125
|
+
webp: ContentTypes.IMAGE_WEBP,
|
|
126
|
+
wdp: ContentTypes.IMAGE_JPEG_XR,
|
|
127
|
+
eps: ContentTypes.IMAGE_EPS,
|
|
128
|
+
};
|
|
129
|
+
/** Whether bytes of this content type are XML (parsed to a DOM when the registry has no typed part). */
|
|
130
|
+
export function isXmlContentType(contentType) {
|
|
131
|
+
if (contentType === undefined)
|
|
132
|
+
return false;
|
|
133
|
+
return contentType.endsWith('+xml') || contentType === ContentTypes.APPLICATION_XML || contentType === ContentTypes.XML;
|
|
134
|
+
}
|
|
135
|
+
/** Already-compressed media, stored rather than deflated in a zip (docx4j ZipPartStore.shouldCompress). */
|
|
136
|
+
export function isStoredUncompressed(contentType) {
|
|
137
|
+
return contentType === ContentTypes.IMAGE_PNG || contentType === ContentTypes.IMAGE_X_PNG
|
|
138
|
+
|| contentType === ContentTypes.IMAGE_JPEG || contentType === ContentTypes.IMAGE_GIF;
|
|
139
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type PackageElement } from '@docx4j/generated-objects-ts';
|
|
2
|
+
import type { PartStore, PartSink, PutOptions } from './PartStore.mjs';
|
|
3
|
+
export declare const PKG_NS = "http://schemas.microsoft.com/office/2006/xmlPackage";
|
|
4
|
+
/**
|
|
5
|
+
* A flat OPC package (`pkg:package`, what Office JS `getOoxml()` returns) as a container
|
|
6
|
+
* (docx4j org.docx4j.openpackaging.io3.stores.FlatOpcPartStore is not a class there, but the
|
|
7
|
+
* same job is done by `FlatOpcXmlImporter`). The content types are carried per part, so
|
|
8
|
+
* `[Content_Types].xml` is synthesised. XML parts are serialised back to bytes on `load`; the
|
|
9
|
+
* document loaded from them is therefore not byte-identical to what Office would have zipped.
|
|
10
|
+
*/
|
|
11
|
+
export declare class FlatOpcPartStore implements PartStore {
|
|
12
|
+
private readonly parts;
|
|
13
|
+
private readonly order;
|
|
14
|
+
private readonly cache;
|
|
15
|
+
private contentTypesXml?;
|
|
16
|
+
/** From the `pkg:package` string. */
|
|
17
|
+
constructor(source: string | PackageElement);
|
|
18
|
+
private readString;
|
|
19
|
+
private readPackageElement;
|
|
20
|
+
private add;
|
|
21
|
+
/** The content type of a part as carried by the flat package. */
|
|
22
|
+
contentTypeOf(partName: string): string | undefined;
|
|
23
|
+
partNames(): Iterable<string>;
|
|
24
|
+
has(partName: string): boolean;
|
|
25
|
+
load(partName: string): Promise<Uint8Array>;
|
|
26
|
+
private buildContentTypes;
|
|
27
|
+
}
|
|
28
|
+
export interface FlatOpcSinkOptions {
|
|
29
|
+
/** The `mso-application` processing instruction's progid, e.g. 'Word.Document'; omitted when undefined. */
|
|
30
|
+
progId?: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Produces the `pkg:package` string for Office JS `insertOoxml()`. XML parts are embedded as
|
|
34
|
+
* XML (their declaration removed), everything else as base64 with the padding Word writes.
|
|
35
|
+
*/
|
|
36
|
+
export declare class FlatOpcPartSink implements PartSink<string> {
|
|
37
|
+
private readonly parts;
|
|
38
|
+
private readonly progId;
|
|
39
|
+
constructor(options?: FlatOpcSinkOptions);
|
|
40
|
+
put(partName: string, bytes: Uint8Array, options?: PutOptions): void;
|
|
41
|
+
finish(): Promise<string>;
|
|
42
|
+
}
|