Optimize XML output by properly constructing objects to send to the xml library so that it can produce proper empty elements.
Rework the way attributes are stored in ImportedXmlComponent to match elsewhere (required allowing for a null xmlKeys in the XmlAttributeComponent interface). Rework the way paragraphs get added to the end of table cells if needed. The goal in both reworks is to not mess around with the objects output from `prepForXml` if we can avoid it. Made the output of RunProperties, ParagraphProperties, TableCellProperties, TableRowProperties, and TableProperties all optional based on whether they contain any attributes or children. Changed code in PageBorders, TableCellMargin, and TableCellBorders that implemented this same thing by overriding `prepForXml` so that it uses the new XmlComponent subclass instead. Removed commented out code that attempted to fix-up XML output and make proper empty elements. Fixed all affected tests. Turn off `no-null-keyword` in the linter as we need to use null to signal to the `xml` library to create an empty element with no attributes (`undefined` will not work in its place). Fixes #306
This commit is contained in:
@ -71,24 +71,34 @@ describe("External styles factory", () => {
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
_attr: {
|
||||
"w:ascii": "Arial",
|
||||
"w:cstheme": "minorHAnsi",
|
||||
"w:eastAsiaTheme": "minorHAnsi",
|
||||
"w:hAnsi": "Arial",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:ascii": "Arial",
|
||||
"w:cstheme": "minorHAnsi",
|
||||
"w:eastAsiaTheme": "minorHAnsi",
|
||||
"w:hAnsi": "Arial",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:rFonts",
|
||||
},
|
||||
{
|
||||
_attr: {
|
||||
"w:bidi": "ar-SA",
|
||||
"w:eastAsia": "en-US",
|
||||
"w:val": "en-US",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:bidi": "ar-SA",
|
||||
"w:eastAsia": "en-US",
|
||||
"w:val": "en-US",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:lang",
|
||||
},
|
||||
],
|
||||
@ -104,13 +114,18 @@ describe("External styles factory", () => {
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
_attr: {
|
||||
"w:after": "160",
|
||||
"w:line": "259",
|
||||
"w:lineRule": "auto",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:after": "160",
|
||||
"w:line": "259",
|
||||
"w:lineRule": "auto",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:spacing",
|
||||
},
|
||||
],
|
||||
@ -123,12 +138,17 @@ describe("External styles factory", () => {
|
||||
rootKey: "w:docDefaults",
|
||||
});
|
||||
expect(importedStyle.root[2]).to.deep.equal({
|
||||
_attr: {
|
||||
"w:defLockedState": "1",
|
||||
"w:defUIPriority": "99",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:defLockedState": "1",
|
||||
"w:defUIPriority": "99",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:latentStyles",
|
||||
});
|
||||
});
|
||||
@ -139,19 +159,28 @@ describe("External styles factory", () => {
|
||||
|
||||
expect(importedStyle.root.length).to.equal(5);
|
||||
expect(importedStyle.root[3]).to.deep.equal({
|
||||
_attr: {
|
||||
"w:default": "1",
|
||||
"w:styleId": "Normal",
|
||||
"w:type": "paragraph",
|
||||
},
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "Normal",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: {
|
||||
"w:default": "1",
|
||||
"w:styleId": "Normal",
|
||||
"w:type": "paragraph",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
{
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:val": "Normal",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:name",
|
||||
},
|
||||
{
|
||||
@ -164,26 +193,40 @@ describe("External styles factory", () => {
|
||||
});
|
||||
|
||||
expect(importedStyle.root[4]).to.deep.equal({
|
||||
_attr: {
|
||||
"w:styleId": "Heading1",
|
||||
"w:type": "paragraph",
|
||||
},
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "heading 1",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: {
|
||||
"w:styleId": "Heading1",
|
||||
"w:type": "paragraph",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
{
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:val": "heading 1",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:name",
|
||||
},
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "Normal",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:val": "Normal",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:basedOn",
|
||||
},
|
||||
{
|
||||
@ -203,14 +246,19 @@ describe("External styles factory", () => {
|
||||
deleted: false,
|
||||
root: [
|
||||
{
|
||||
_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:sz": "4",
|
||||
"w:val": "single",
|
||||
},
|
||||
deleted: false,
|
||||
root: [],
|
||||
root: [
|
||||
{
|
||||
deleted: false,
|
||||
root: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:sz": "4",
|
||||
"w:val": "single",
|
||||
},
|
||||
rootKey: "_attr",
|
||||
},
|
||||
],
|
||||
rootKey: "w:bottom",
|
||||
},
|
||||
],
|
||||
|
@ -12,18 +12,15 @@ describe("CharacterStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{ "w:rPr": [] },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -35,19 +32,16 @@ describe("CharacterStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Style Name" } } },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -61,20 +55,17 @@ describe("CharacterStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{ "w:rPr": [] },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "otherId" } }] },
|
||||
{ "w:basedOn": { _attr: { "w:val": "otherId" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -88,19 +79,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }, { "w:szCs": [{ _attr: { "w:val": 24 } }] }],
|
||||
"w:rPr": [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 24 } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -114,19 +103,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -139,19 +126,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -164,19 +149,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "005599" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -192,27 +175,23 @@ describe("CharacterStyle", () => {
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:vertAlign": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "superscript",
|
||||
},
|
||||
"w:vertAlign": {
|
||||
_attr: {
|
||||
"w:val": "superscript",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -225,19 +204,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "123456" } }] }],
|
||||
"w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -250,19 +227,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:b": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -275,19 +250,17 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:i": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -300,21 +273,16 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
{ "w:link": [{ _attr: { "w:val": "MyLink" } }] },
|
||||
{ "w:link": { _attr: { "w:val": "MyLink" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -326,19 +294,14 @@ describe("CharacterStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:rPr": [],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{ "w:unhideWhenUsed": [] },
|
||||
{ "w:semiHidden": [] },
|
||||
{ "w:unhideWhenUsed": null },
|
||||
{ "w:semiHidden": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -6,48 +6,48 @@ describe("Style components", () => {
|
||||
it("Name#constructor", () => {
|
||||
const style = new components.Name("Style Name");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:name": [{ _attr: { "w:val": "Style Name" } }] });
|
||||
expect(tree).to.deep.equal({ "w:name": { _attr: { "w:val": "Style Name" } } });
|
||||
});
|
||||
|
||||
it("BasedOn#constructor", () => {
|
||||
const style = new components.BasedOn("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:basedOn": [{ _attr: { "w:val": "otherId" } }] });
|
||||
expect(tree).to.deep.equal({ "w:basedOn": { _attr: { "w:val": "otherId" } } });
|
||||
});
|
||||
|
||||
it("Next#constructor", () => {
|
||||
const style = new components.Next("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:next": [{ _attr: { "w:val": "otherId" } }] });
|
||||
expect(tree).to.deep.equal({ "w:next": { _attr: { "w:val": "otherId" } } });
|
||||
});
|
||||
|
||||
it("Link#constructor", () => {
|
||||
const style = new components.Link("otherId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:link": [{ _attr: { "w:val": "otherId" } }] });
|
||||
expect(tree).to.deep.equal({ "w:link": { _attr: { "w:val": "otherId" } } });
|
||||
});
|
||||
|
||||
it("UiPriority#constructor", () => {
|
||||
const style = new components.UiPriority("123");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:uiPriority": [{ _attr: { "w:val": "123" } }] });
|
||||
expect(tree).to.deep.equal({ "w:uiPriority": { _attr: { "w:val": "123" } } });
|
||||
});
|
||||
|
||||
it("UnhideWhenUsed#constructor", () => {
|
||||
const style = new components.UnhideWhenUsed();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:unhideWhenUsed": [] });
|
||||
expect(tree).to.deep.equal({ "w:unhideWhenUsed": null });
|
||||
});
|
||||
|
||||
it("QuickFormat#constructor", () => {
|
||||
const style = new components.QuickFormat();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:qFormat": [] });
|
||||
expect(tree).to.deep.equal({ "w:qFormat": null });
|
||||
});
|
||||
|
||||
it("SemiHidden#constructor", () => {
|
||||
const style = new components.SemiHidden();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({ "w:semiHidden": [] });
|
||||
expect(tree).to.deep.equal({ "w:semiHidden": null });
|
||||
});
|
||||
});
|
||||
|
@ -9,12 +9,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading1" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 1" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 1" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -25,12 +23,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Title" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Title" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Title" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -41,12 +37,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading1" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 1" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 1" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -57,12 +51,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading2" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 2" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 2" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -73,12 +65,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading3" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 3" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 3" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -89,12 +79,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading4" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 4" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 4" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -105,12 +93,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading5" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 5" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 5" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -121,12 +107,10 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "Heading6" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Heading 6" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:next": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Heading 6" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:next": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -137,11 +121,9 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "ListParagraph" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "List Paragraph" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:qFormat": [] },
|
||||
{ "w:name": { _attr: { "w:val": "List Paragraph" } } },
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:qFormat": null },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -152,60 +134,52 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "FootnoteText" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "footnote text" } }] },
|
||||
{ "w:name": { _attr: { "w:val": "footnote text" } } },
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:spacing": [
|
||||
{
|
||||
_attr: {
|
||||
"w:after": 0,
|
||||
"w:line": 240,
|
||||
"w:lineRule": "auto",
|
||||
},
|
||||
"w:spacing": {
|
||||
_attr: {
|
||||
"w:after": 0,
|
||||
"w:line": 240,
|
||||
"w:lineRule": "auto",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:sz": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
"w:sz": {
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:szCs": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
"w:szCs": {
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "Normal" } }] },
|
||||
{ "w:link": [{ _attr: { "w:val": "FootnoteTextChar" } }] },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:basedOn": { _attr: { "w:val": "Normal" } } },
|
||||
{ "w:link": { _attr: { "w:val": "FootnoteTextChar" } } },
|
||||
{
|
||||
"w:semiHidden": [],
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:semiHidden": null,
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -217,36 +191,32 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "FootnoteReference" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "footnote reference" } }] },
|
||||
{ "w:name": { _attr: { "w:val": "footnote reference" } } },
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:vertAlign": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "superscript",
|
||||
},
|
||||
"w:vertAlign": {
|
||||
_attr: {
|
||||
"w:val": "superscript",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
},
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "DefaultParagraphFont" } }] },
|
||||
{
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
|
||||
|
||||
{
|
||||
"w:semiHidden": [],
|
||||
"w:semiHidden": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -258,45 +228,39 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "FootnoteTextChar" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Footnote Text Char" } }] },
|
||||
{ "w:name": { _attr: { "w:val": "Footnote Text Char" } } },
|
||||
{
|
||||
"w:rPr": [
|
||||
{
|
||||
"w:sz": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
"w:sz": {
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:szCs": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
"w:szCs": {
|
||||
_attr: {
|
||||
"w:val": 20,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
},
|
||||
},
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "DefaultParagraphFont" } }] },
|
||||
{ "w:link": [{ _attr: { "w:val": "FootnoteText" } }] },
|
||||
{
|
||||
"w:semiHidden": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
|
||||
{ "w:link": { _attr: { "w:val": "FootnoteText" } } },
|
||||
{
|
||||
"w:semiHidden": null,
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -308,23 +272,21 @@ describe("Default Styles", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "Hyperlink" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Hyperlink" } }] },
|
||||
{ "w:name": { _attr: { "w:val": "Hyperlink" } } },
|
||||
{
|
||||
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "0563C1" } }] }, { "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||
"w:rPr": [{ "w:color": { _attr: { "w:val": "0563C1" } } }, { "w:u": { _attr: { "w:val": "single" } } }],
|
||||
},
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "DefaultParagraphFont" } }] },
|
||||
{ "w:basedOn": { _attr: { "w:val": "DefaultParagraphFont" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -10,7 +10,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||
"w:style": { _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
});
|
||||
});
|
||||
|
||||
@ -20,9 +20,7 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Style Name" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -35,9 +33,7 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:basedOn": [{ _attr: { "w:val": "otherId" } }] },
|
||||
{ "w:basedOn": { _attr: { "w:val": "otherId" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -46,12 +42,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").quickFormat();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:qFormat": [] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:qFormat": null }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,9 +52,7 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:next": [{ _attr: { "w:val": "otherId" } }] },
|
||||
{ "w:next": { _attr: { "w:val": "otherId" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -77,9 +66,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:ind": [{ _attr: { "w:left": 720 } }] }],
|
||||
"w:pPr": [{ "w:ind": { _attr: { "w:left": 720 } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -91,9 +79,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:spacing": [{ _attr: { "w:before": 50, "w:after": 150 } }] }],
|
||||
"w:pPr": [{ "w:spacing": { _attr: { "w:before": 50, "w:after": 150 } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -105,9 +92,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "center" } }] }],
|
||||
"w:pPr": [{ "w:jc": { _attr: { "w:val": "center" } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -118,9 +104,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:spacing": [{ _attr: { "w:val": 24 } }] }],
|
||||
"w:rPr": [{ "w:spacing": { _attr: { "w:val": 24 } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -133,9 +118,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "left" } }] }],
|
||||
"w:pPr": [{ "w:jc": { _attr: { "w:val": "left" } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -147,9 +131,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "right" } }] }],
|
||||
"w:pPr": [{ "w:jc": { _attr: { "w:val": "right" } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -161,9 +144,8 @@ describe("ParagraphStyle", () => {
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{
|
||||
"w:pPr": [{ "w:jc": [{ _attr: { "w:val": "both" } }] }],
|
||||
"w:pPr": [{ "w:jc": { _attr: { "w:val": "both" } } }],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -179,22 +161,19 @@ describe("ParagraphStyle", () => {
|
||||
{
|
||||
"w:pBdr": [
|
||||
{
|
||||
"w:bottom": [
|
||||
{
|
||||
_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:val": "single",
|
||||
"w:sz": "6",
|
||||
},
|
||||
"w:bottom": {
|
||||
_attr: {
|
||||
"w:color": "auto",
|
||||
"w:space": "1",
|
||||
"w:val": "single",
|
||||
"w:sz": "6",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -208,11 +187,10 @@ describe("ParagraphStyle", () => {
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "left", "w:pos": 1200 } }] }],
|
||||
"w:tabs": [{ "w:tab": { _attr: { "w:val": "left", "w:pos": 1200 } } }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -226,11 +204,10 @@ describe("ParagraphStyle", () => {
|
||||
{
|
||||
"w:pPr": [
|
||||
{
|
||||
"w:tabs": [{ "w:tab": [{ _attr: { "w:val": "right", "w:pos": 9026 } }] }],
|
||||
"w:tabs": [{ "w:tab": { _attr: { "w:val": "right", "w:pos": 9026 } } }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -239,11 +216,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").keepLines();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:keepLines": [] }] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepLines": null }] }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -251,11 +224,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").keepNext();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:keepNext": [] }] },
|
||||
{ "w:rPr": [] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:pPr": [{ "w:keepNext": null }] }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -265,8 +234,7 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [{ "w:outlineLvl": [{ _attr: { "w:val": "1" } }] }] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:pPr": [{ "w:outlineLvl": { _attr: { "w:val": "1" } } }] },
|
||||
],
|
||||
});
|
||||
});
|
||||
@ -279,9 +247,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:sz": [{ _attr: { "w:val": 24 } }] }, { "w:szCs": [{ _attr: { "w:val": 24 } }] }],
|
||||
"w:rPr": [{ "w:sz": { _attr: { "w:val": 24 } } }, { "w:szCs": { _attr: { "w:val": 24 } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -293,9 +260,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:smallCaps": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:smallCaps": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -307,9 +273,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:caps": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:caps": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -321,9 +286,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:strike": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:strike": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -335,9 +299,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:dstrike": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:dstrike": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -349,9 +312,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "subscript" } }] }],
|
||||
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "subscript" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -363,9 +325,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:vertAlign": [{ _attr: { "w:val": "superscript" } }] }],
|
||||
"w:rPr": [{ "w:vertAlign": { _attr: { "w:val": "superscript" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -377,10 +338,9 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [
|
||||
{ "w:rFonts": [{ _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } }] },
|
||||
{ "w:rFonts": { _attr: { "w:ascii": "Times", "w:cs": "Times", "w:eastAsia": "Times", "w:hAnsi": "Times" } } },
|
||||
],
|
||||
},
|
||||
],
|
||||
@ -393,9 +353,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:b": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:b": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -407,9 +366,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:i": [{ _attr: { "w:val": true } }] }],
|
||||
"w:rPr": [{ "w:i": { _attr: { "w:val": true } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -422,9 +380,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "single" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "single" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -436,9 +393,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "double" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -450,9 +406,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:u": [{ _attr: { "w:val": "double", "w:color": "005599" } }] }],
|
||||
"w:rPr": [{ "w:u": { _attr: { "w:val": "double", "w:color": "005599" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -465,9 +420,8 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{
|
||||
"w:rPr": [{ "w:color": [{ _attr: { "w:val": "123456" } }] }],
|
||||
"w:rPr": [{ "w:color": { _attr: { "w:val": "123456" } } }],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -477,12 +431,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").link("MyLink");
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:link": [{ _attr: { "w:val": "MyLink" } }] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:link": { _attr: { "w:val": "MyLink" } } }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -490,12 +439,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").semiHidden();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:semiHidden": [] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:semiHidden": null }],
|
||||
});
|
||||
});
|
||||
|
||||
@ -505,16 +449,12 @@ describe("ParagraphStyle", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -524,12 +464,7 @@ describe("ParagraphStyle", () => {
|
||||
const style = new ParagraphStyle("myStyleId").unhideWhenUsed();
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:unhideWhenUsed": [] },
|
||||
],
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } }, { "w:unhideWhenUsed": null }],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -12,7 +12,7 @@ describe("Style", () => {
|
||||
});
|
||||
const tree = new Formatter().format(style);
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } }],
|
||||
"w:style": { _attr: { "w:type": "paragraph", "w:styleId": "myStyleId", "w:default": true } },
|
||||
});
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@ describe("Style", () => {
|
||||
expect(tree).to.deep.equal({
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "myStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Style Name" } }] },
|
||||
{ "w:name": { _attr: { "w:val": "Style Name" } } },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ describe("Styles", () => {
|
||||
const tree = new Formatter().format(styles)["w:styles"].filter((x) => !x._attr);
|
||||
expect(tree).to.deep.equal([
|
||||
{
|
||||
"w:style": [{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } }, { "w:pPr": [] }, { "w:rPr": [] }],
|
||||
"w:style": { _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } },
|
||||
},
|
||||
]);
|
||||
});
|
||||
@ -40,9 +40,7 @@ describe("Styles", () => {
|
||||
{
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "paragraph", "w:styleId": "pStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Paragraph Style" } }] },
|
||||
{ "w:pPr": [] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Paragraph Style" } } },
|
||||
],
|
||||
},
|
||||
]);
|
||||
@ -58,18 +56,15 @@ describe("Styles", () => {
|
||||
{
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "pStyleId" } },
|
||||
{ "w:rPr": [] },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -84,19 +79,16 @@ describe("Styles", () => {
|
||||
{
|
||||
"w:style": [
|
||||
{ _attr: { "w:type": "character", "w:styleId": "pStyleId" } },
|
||||
{ "w:name": [{ _attr: { "w:val": "Character Style" } }] },
|
||||
{ "w:rPr": [] },
|
||||
{ "w:name": { _attr: { "w:val": "Character Style" } } },
|
||||
{
|
||||
"w:uiPriority": [
|
||||
{
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
"w:uiPriority": {
|
||||
_attr: {
|
||||
"w:val": "99",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
"w:unhideWhenUsed": [],
|
||||
"w:unhideWhenUsed": null,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
Reference in New Issue
Block a user