Merge pull request #279 from filippomuscolino/settings-fix

Fix: settings are ignored by Word without relationship and content type
This commit is contained in:
Dolan
2019-03-05 17:44:21 +00:00
committed by GitHub
3 changed files with 30 additions and 4 deletions

View File

@ -79,6 +79,26 @@ describe("ContentTypes", () => {
}, },
], ],
}); });
expect(tree["Types"][13]).to.deep.equal({
Override: [
{
_attr: {
ContentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml",
PartName: "/word/footnotes.xml",
},
},
],
});
expect(tree["Types"][14]).to.deep.equal({
Override: [
{
_attr: {
ContentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml",
PartName: "/word/settings.xml",
},
},
],
});
}); });
}); });
@ -88,7 +108,7 @@ describe("ContentTypes", () => {
contentTypes.addFooter(102); contentTypes.addFooter(102);
const tree = new Formatter().format(contentTypes); const tree = new Formatter().format(contentTypes);
expect(tree["Types"][14]).to.deep.equal({ expect(tree["Types"][15]).to.deep.equal({
Override: [ Override: [
{ {
_attr: { _attr: {
@ -99,7 +119,7 @@ describe("ContentTypes", () => {
], ],
}); });
expect(tree["Types"][15]).to.deep.equal({ expect(tree["Types"][16]).to.deep.equal({
Override: [ Override: [
{ {
_attr: { _attr: {
@ -118,7 +138,7 @@ describe("ContentTypes", () => {
contentTypes.addHeader(202); contentTypes.addHeader(202);
const tree = new Formatter().format(contentTypes); const tree = new Formatter().format(contentTypes);
expect(tree["Types"][14]).to.deep.equal({ expect(tree["Types"][15]).to.deep.equal({
Override: [ Override: [
{ {
_attr: { _attr: {
@ -129,7 +149,7 @@ describe("ContentTypes", () => {
], ],
}); });
expect(tree["Types"][15]).to.deep.equal({ expect(tree["Types"][16]).to.deep.equal({
Override: [ Override: [
{ {
_attr: { _attr: {

View File

@ -30,6 +30,7 @@ export class ContentTypes extends XmlComponent {
this.root.push(new Override("application/vnd.openxmlformats-officedocument.extended-properties+xml", "/docProps/app.xml")); this.root.push(new Override("application/vnd.openxmlformats-officedocument.extended-properties+xml", "/docProps/app.xml"));
this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", "/word/numbering.xml")); this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", "/word/numbering.xml"));
this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", "/word/footnotes.xml")); this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.footnotes+xml", "/word/footnotes.xml"));
this.root.push(new Override("application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml", "/word/settings.xml"));
} }
public addFooter(index: number): void { public addFooter(index: number): void {

View File

@ -324,6 +324,11 @@ export class File {
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes",
"footnotes.xml", "footnotes.xml",
); );
this.docRelationships.createRelationship(
this.currentRelationshipId++,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings",
"settings.xml",
);
} }
private groupHeaders(headers: IDocumentHeader[], group: IHeaderFooterGroup<HeaderWrapper> = {}): IHeaderFooterGroup<HeaderWrapper> { private groupHeaders(headers: IDocumentHeader[], group: IHeaderFooterGroup<HeaderWrapper> = {}): IHeaderFooterGroup<HeaderWrapper> {