Socket
Socket
Sign inDemoInstall

docx

Package Overview
Dependencies
19
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.6.0 to 7.7.0

build/file/paragraph/formatting/width.d.ts

2

build/file/core-properties/properties.d.ts
import { ICommentsOptions } from "../../file/paragraph/run/comment-run";
import { ICompatibilityOptions } from "../../file/settings/compatibility";
import { XmlComponent } from "../../file/xml-components";

@@ -33,2 +34,3 @@ import { ICustomPropertyOptions } from "../custom-properties";

readonly compatabilityModeVersion?: number;
readonly compatibility?: ICompatibilityOptions;
readonly customProperties?: readonly ICustomPropertyOptions[];

@@ -35,0 +37,0 @@ readonly evenAndOddHeaderAndFooters?: boolean;

import { XmlComponent } from "../../../file/xml-components";
export interface DocPropertiesOptions {
readonly name: string;
readonly description: string;
readonly title: string;
}
export declare class DocProperties extends XmlComponent {
constructor();
constructor({ name, description, title }?: DocPropertiesOptions);
}
import { IMediaData } from "../../file/media";
import { XmlComponent } from "../../file/xml-components";
import { DocPropertiesOptions } from "./doc-properties/doc-properties";
import { IFloating } from "./floating";

@@ -12,2 +13,3 @@ export interface IDistance {

readonly floating?: IFloating;
readonly docProperties?: DocPropertiesOptions;
}

@@ -14,0 +16,0 @@ export declare class Drawing extends XmlComponent {

import { IMediaData, IMediaDataTransformation } from "../../../file/media";
import { XmlComponent } from "../../../file/xml-components";
import { DocPropertiesOptions } from "./../doc-properties/doc-properties";
interface InlineOptions {
readonly mediaData: IMediaData;
readonly transform: IMediaDataTransformation;
readonly docProperties?: DocPropertiesOptions;
}
export declare class Inline extends XmlComponent {
private readonly extent;
private readonly graphic;
constructor(mediaData: IMediaData, transform: IMediaDataTransformation);
constructor({ mediaData, transform, docProperties }: InlineOptions);
}
export {};

1

build/file/index.d.ts

@@ -21,2 +21,1 @@ export * from "./paragraph";

export * from "./vertical-align";
export * from "./space-type";

@@ -44,2 +44,4 @@ import { IContext, IgnoreIfEmptyXmlComponent, IXmlableObject, XmlComponent } from "../../file/xml-components";

readonly suppressLineNumbers?: boolean;
readonly wordWrap?: boolean;
readonly scale?: number;
}

@@ -46,0 +48,0 @@ export declare class ParagraphProperties extends IgnoreIfEmptyXmlComponent {

/// <reference types="node" />
import { IContext, IXmlableObject } from "../../../file/xml-components";
import { DocPropertiesOptions } from "../../../file/drawing/doc-properties/doc-properties";
import { IFloating } from "../../drawing";

@@ -10,2 +11,3 @@ import { IMediaTransformation } from "../../media";

readonly floating?: IFloating;
readonly altText?: DocPropertiesOptions;
}

@@ -12,0 +14,0 @@ export declare class ImageRun extends Run {

import { IBorderOptions } from "../../../file/border";
import { IShadingAttributesProperties } from "../../../file/shading";
import { SpaceType } from "../../../file/space-type";
import { IChangedAttributesProperties } from "../../../file/track-revision/track-revision";

@@ -44,3 +43,5 @@ import { IgnoreIfEmptyXmlComponent, XmlComponent } from "../../../file/xml-components";

readonly border?: IBorderOptions;
readonly space?: SpaceType;
readonly vanish?: boolean;
readonly specVanish?: boolean;
readonly scale?: number;
}

@@ -47,0 +48,0 @@ export interface IRunPropertiesOptions extends IRunStylePropertiesOptions {

@@ -6,4 +6,5 @@ import { XmlComponent } from "../../../file/xml-components";

import { IRunPropertiesOptions, RunProperties } from "./properties";
import { Tab } from "./tab";
export interface IRunOptions extends IRunPropertiesOptions {
readonly children?: readonly (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | string)[];
readonly children?: readonly (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | Tab | string)[];
readonly break?: number;

@@ -10,0 +11,0 @@ readonly text?: string;

@@ -1,2 +0,2 @@

import { SpaceType } from "../../../file/space-type";
import { SpaceType } from "../../../file/shared";
import { XmlAttributeComponent } from "../../../file/xml-components";

@@ -3,0 +3,0 @@ export declare class TextAttributes extends XmlAttributeComponent<{

import { XmlComponent } from "../../file/xml-components";
export interface ICompatibilityOptions {
readonly version?: number;
readonly useSingleBorderforContiguousCells?: boolean;
readonly wordPerfectJustification?: boolean;
readonly noTabStopForHangingIndent?: boolean;
readonly noLeading?: boolean;
readonly spaceForUnderline?: boolean;
readonly noColumnBalance?: boolean;
readonly balanceSingleByteDoubleByteWidth?: boolean;
readonly noExtraLineSpacing?: boolean;
readonly doNotLeaveBackslashAlone?: boolean;
readonly underlineTrailingSpaces?: boolean;
readonly doNotExpandShiftReturn?: boolean;
readonly version?: number;
readonly spacingInWholePoints?: boolean;
readonly lineWrapLikeWord6?: boolean;
readonly printBodyTextBeforeHeader?: boolean;
readonly printColorsBlack?: boolean;
readonly spaceWidth?: boolean;
readonly showBreaksInFrames?: boolean;
readonly subFontBySize?: boolean;
readonly suppressBottomSpacing?: boolean;
readonly suppressTopSpacing?: boolean;
readonly suppressSpacingAtTopOfPage?: boolean;
readonly suppressTopSpacingWP?: boolean;
readonly suppressSpBfAfterPgBrk?: boolean;
readonly swapBordersFacingPages?: boolean;
readonly convertMailMergeEsc?: boolean;
readonly truncateFontHeightsLikeWP6?: boolean;
readonly macWordSmallCaps?: boolean;
readonly usePrinterMetrics?: boolean;
readonly doNotSuppressParagraphBorders?: boolean;
readonly wrapTrailSpaces?: boolean;
readonly footnoteLayoutLikeWW8?: boolean;
readonly shapeLayoutLikeWW8?: boolean;
readonly alignTablesRowByRow?: boolean;
readonly forgetLastTabAlignment?: boolean;
readonly adjustLineHeightInTable?: boolean;
readonly autoSpaceLikeWord95?: boolean;
readonly noSpaceRaiseLower?: boolean;
readonly doNotUseHTMLParagraphAutoSpacing?: boolean;
readonly layoutRawTableWidth?: boolean;
readonly layoutTableRowsApart?: boolean;
readonly useWord97LineBreakRules?: boolean;
readonly doNotBreakWrappedTables?: boolean;
readonly doNotSnapToGridInCell?: boolean;
readonly selectFieldWithFirstOrLastCharacter?: boolean;
readonly applyBreakingRules?: boolean;
readonly doNotWrapTextWithPunctuation?: boolean;
readonly doNotUseEastAsianBreakRules?: boolean;
readonly useWord2002TableStyleRules?: boolean;
readonly growAutofit?: boolean;
readonly useFELayout?: boolean;
readonly useNormalStyleForList?: boolean;
readonly doNotUseIndentAsNumberingTabStop?: boolean;
readonly useAlternateEastAsianLineBreakRules?: boolean;
readonly allowSpaceOfSameStyleInTable?: boolean;
readonly doNotSuppressIndentation?: boolean;
readonly doNotAutofitConstrainedTables?: boolean;
readonly autofitToFirstFixedWidthCell?: boolean;
readonly underlineTabInNumberingList?: boolean;
readonly displayHangulFixedWidth?: boolean;
readonly splitPgBreakAndParaMark?: boolean;
readonly doNotVerticallyAlignCellWithSp?: boolean;
readonly doNotBreakConstrainedForcedTable?: boolean;
readonly ignoreVerticalAlignmentInTextboxes?: boolean;
readonly useAnsiKerningPairs?: boolean;
readonly cachedColumnBalance?: boolean;
}

@@ -6,0 +70,0 @@ export declare class Compatibility extends XmlComponent {

import { XmlAttributeComponent, XmlComponent } from "../../file/xml-components";
import { ICompatibilityOptions } from "./compatibility";
export declare class SettingsAttributes extends XmlAttributeComponent<{

@@ -42,6 +43,7 @@ readonly wpc?: string;

export interface ISettingsOptions {
readonly compatabilityModeVersion?: number;
readonly compatibilityModeVersion?: number;
readonly evenAndOddHeaders?: boolean;
readonly trackRevisions?: boolean;
readonly updateFields?: boolean;
readonly compatibility?: ICompatibilityOptions;
}

@@ -48,0 +50,0 @@ export declare class Settings extends XmlComponent {

export * from "./alignment";
export * from "./number-format";
export * from "./space-type";

@@ -5,2 +5,1 @@ export * from "./table-properties";

export * from "./table-borders";
export * from "./table-overlap";
import { XmlAttributeComponent, XmlComponent } from "../../../file/xml-components";
import { OverlapType } from "./table-overlap";
export declare enum TableAnchorType {

@@ -23,2 +22,6 @@ MARGIN = "margin",

}
export declare enum OverlapType {
NEVER = "never",
OVERLAP = "overlap"
}
export interface ITableFloatOptions {

@@ -25,0 +28,0 @@ readonly horizontalAnchor?: TableAnchorType;

@@ -14,4 +14,7 @@ import { XmlComponent } from "../../file/xml-components";

}
export declare class StringEnumValueElement<T extends string> extends XmlComponent {
constructor(name: string, val: T);
}
export declare class StringContainer extends XmlComponent {
constructor(name: string, val: string);
}
{
"name": "docx",
"version": "7.6.0",
"version": "7.7.0",
"description": "Easily generate .docx files with JS/TS with a nice declarative API. Works for Node and on the Browser.",

@@ -78,3 +78,3 @@ "main": "build/index.js",

"buffer": "^6.0.3",
"chai": "^3.5.0",
"chai": "^4.3.6",
"cspell": "^6.2.2",

@@ -81,0 +81,0 @@ "docsify-cli": "^4.3.0",

import { ICommentsOptions } from "@file/paragraph/run/comment-run";
import { ICompatibilityOptions } from "@file/settings/compatibility";
import { StringContainer, XmlComponent } from "@file/xml-components";

@@ -38,2 +39,3 @@ import { dateTimeValue } from "@util/values";

readonly compatabilityModeVersion?: number;
readonly compatibility?: ICompatibilityOptions;
readonly customProperties?: readonly ICustomPropertyOptions[];

@@ -40,0 +42,0 @@ readonly evenAndOddHeaderAndFooters?: boolean;

@@ -1,3 +0,7 @@

import { assert } from "chai";
import { assert, expect } from "chai";
import { SinonStub, stub } from "sinon";
import { Formatter } from "@export/formatter";
import * as convenienceFunctions from "@util/convenience-functions";
import { Utility } from "tests/utility";

@@ -39,2 +43,10 @@

describe("Anchor", () => {
before(() => {
stub(convenienceFunctions, "uniqueNumericId").callsFake(() => 0);
});
after(() => {
(convenienceFunctions.uniqueNumericId as SinonStub).restore();
});
let anchor: Anchor;

@@ -366,3 +378,234 @@

});
it("should create a Drawing with doc properties", () => {
anchor = createAnchor({
floating: {
verticalPosition: {
offset: 0,
},
horizontalPosition: {
offset: 0,
},
zIndex: 120,
},
docProperties: {
name: "test",
description: "test",
title: "test",
},
});
const tree = new Formatter().format(anchor);
expect(tree).to.deep.equal({
"wp:anchor": [
{
_attr: {
allowOverlap: "1",
behindDoc: "0",
distB: 0,
distL: 0,
distR: 0,
distT: 0,
layoutInCell: "1",
locked: "0",
relativeHeight: 120,
simplePos: "0",
},
},
{
"wp:simplePos": {
_attr: {
x: 0,
y: 0,
},
},
},
{
"wp:positionH": [
{
_attr: {
relativeFrom: "page",
},
},
{
"wp:posOffset": ["0"],
},
],
},
{
"wp:positionV": [
{
_attr: {
relativeFrom: "page",
},
},
{
"wp:posOffset": ["0"],
},
],
},
{
"wp:extent": {
_attr: {
cx: 952500,
cy: 952500,
},
},
},
{
"wp:effectExtent": {
_attr: {
b: 0,
l: 0,
r: 0,
t: 0,
},
},
},
{
"wp:wrapNone": {},
},
{
"wp:docPr": {
_attr: {
descr: "test",
id: 0,
name: "test",
title: "test",
},
},
},
{
"wp:cNvGraphicFramePr": [
{
"a:graphicFrameLocks": {
_attr: {
noChangeAspect: 1,
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
},
},
},
],
},
{
"a:graphic": [
{
_attr: {
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
},
},
{
"a:graphicData": [
{
_attr: {
uri: "http://schemas.openxmlformats.org/drawingml/2006/picture",
},
},
{
"pic:pic": [
{
_attr: {
"xmlns:pic": "http://schemas.openxmlformats.org/drawingml/2006/picture",
},
},
{
"pic:nvPicPr": [
{
"pic:cNvPr": {
_attr: {
descr: "",
id: 0,
name: "",
},
},
},
{
"pic:cNvPicPr": [
{
"a:picLocks": {
_attr: {
noChangeArrowheads: 1,
noChangeAspect: 1,
},
},
},
],
},
],
},
{
"pic:blipFill": [
{
"a:blip": {
_attr: {
cstate: "none",
"r:embed": "rId{test.png}",
},
},
},
{
"a:srcRect": {},
},
{
"a:stretch": [
{
"a:fillRect": {},
},
],
},
],
},
{
"pic:spPr": [
{
_attr: {
bwMode: "auto",
},
},
{
"a:xfrm": [
{
_attr: {},
},
{
"a:off": {
_attr: {
x: 0,
y: 0,
},
},
},
{
"a:ext": {
_attr: {
cx: 952500,
cy: 952500,
},
},
},
],
},
{
"a:prstGeom": [
{
_attr: {
prst: "rect",
},
},
{
"a:avLst": {},
},
],
},
],
},
],
},
],
},
],
},
],
});
});
});
});

@@ -93,3 +93,3 @@ // http://officeopenxml.com/drwPicFloating.php

this.root.push(new DocProperties());
this.root.push(new DocProperties(drawingOptions.docProperties));
this.root.push(new GraphicFrameProperties());

@@ -96,0 +96,0 @@ this.root.push(new Graphic(mediaData, transform));

@@ -1,6 +0,26 @@

import { XmlComponent } from "@file/xml-components";
import { DocPropertiesAttributes } from "./doc-properties-attributes";
import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { uniqueNumericId } from "@util/convenience-functions";
class DocPropertiesAttributes extends XmlAttributeComponent<{
readonly id?: number;
readonly name?: string;
readonly description?: string;
readonly title?: string;
}> {
protected readonly xmlKeys = {
id: "id",
name: "name",
description: "descr",
title: "title",
};
}
export interface DocPropertiesOptions {
readonly name: string;
readonly description: string;
readonly title: string;
}
export class DocProperties extends XmlComponent {
public constructor() {
public constructor({ name, description, title }: DocPropertiesOptions = { name: "", description: "", title: "" }) {
super("wp:docPr");

@@ -10,5 +30,6 @@

new DocPropertiesAttributes({
id: 0,
name: "",
descr: "",
id: uniqueNumericId(),
name,
description,
title,
}),

@@ -15,0 +36,0 @@ );

import { expect } from "chai";
import { SinonStub, stub } from "sinon";
import { Formatter } from "@export/formatter";
import * as convenienceFunctions from "@util/convenience-functions";

@@ -29,2 +31,10 @@ import { Drawing, IDrawingOptions } from "./drawing";

describe("Drawing", () => {
before(() => {
stub(convenienceFunctions, "uniqueNumericId").callsFake(() => 0);
});
after(() => {
(convenienceFunctions.uniqueNumericId as SinonStub).restore();
});
let currentBreak: Drawing;

@@ -72,2 +82,3 @@

name: "",
title: "",
},

@@ -303,2 +314,3 @@ },

name: "",
title: "",
},

@@ -305,0 +317,0 @@ },

import { IMediaData } from "@file/media";
import { XmlComponent } from "@file/xml-components";
import { Anchor } from "./anchor";
import { DocPropertiesOptions } from "./doc-properties/doc-properties";
import { IFloating } from "./floating";

@@ -16,2 +18,3 @@ import { Inline } from "./inline";

readonly floating?: IFloating;
readonly docProperties?: DocPropertiesOptions;
}

@@ -33,3 +36,7 @@

if (!drawingOptions.floating) {
this.inline = new Inline(imageData, imageData.transformation);
this.inline = new Inline({
mediaData: imageData,
transform: imageData.transformation,
docProperties: drawingOptions.docProperties,
});
this.root.push(this.inline);

@@ -36,0 +43,0 @@ } else {

// http://officeopenxml.com/drwPicInline.php
import { IMediaData, IMediaDataTransformation } from "@file/media";
import { XmlComponent } from "@file/xml-components";
import { DocProperties } from "./../doc-properties/doc-properties";
import { DocProperties, DocPropertiesOptions } from "./../doc-properties/doc-properties";
import { EffectExtent } from "./../effect-extent/effect-extent";

@@ -11,2 +11,8 @@ import { Extent } from "./../extent/extent";

interface InlineOptions {
readonly mediaData: IMediaData;
readonly transform: IMediaDataTransformation;
readonly docProperties?: DocPropertiesOptions;
}
// <xsd:complexType name="CT_Inline">

@@ -30,3 +36,3 @@ // <xsd:sequence>

public constructor(mediaData: IMediaData, transform: IMediaDataTransformation) {
public constructor({ mediaData, transform, docProperties }: InlineOptions) {
super("wp:inline");

@@ -48,3 +54,3 @@

this.root.push(new EffectExtent());
this.root.push(new DocProperties());
this.root.push(new DocProperties(docProperties));
this.root.push(new GraphicFrameProperties());

@@ -51,0 +57,0 @@ this.root.push(this.graphic);

@@ -78,3 +78,4 @@ import { AppProperties } from "./app-properties/app-properties";

this.settings = new Settings({
compatabilityModeVersion: options.compatabilityModeVersion,
compatibilityModeVersion: options.compatabilityModeVersion,
compatibility: options.compatibility,
evenAndOddHeaders: options.evenAndOddHeaderAndFooters ? true : false,

@@ -81,0 +82,0 @@ trackRevisions: options.features?.trackRevisions,

@@ -21,2 +21,1 @@ export * from "./paragraph";

export * from "./vertical-align";
export * from "./space-type";

@@ -59,16 +59,32 @@ import { expect } from "chai";

const tree = new Formatter().format(concreteNumbering);
expect(tree["w:num"]).to.include({
"w:lvlOverride": [
expect(tree).to.deep.equal({
"w:num": [
{
_attr: {
"w:ilvl": 1,
"w:numId": 0,
},
},
{
"w:startOverride": {
"w:abstractNumId": {
_attr: {
"w:val": 9,
"w:val": 1,
},
},
},
{
"w:lvlOverride": [
{
_attr: {
"w:ilvl": 1,
},
},
{
"w:startOverride": {
_attr: {
"w:val": 9,
},
},
},
],
},
],

@@ -75,0 +91,0 @@ });

@@ -1,2 +0,2 @@

import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -3,0 +3,0 @@

@@ -6,2 +6,3 @@ import { assert, expect } from "chai";

import { HorizontalPositionAlign, VerticalPositionAlign } from "@file/shared";
import { Formatter } from "@export/formatter";

@@ -14,3 +15,2 @@ import { BorderStyle } from "@file/border";

import { ShadingType } from "../shading";
import { HorizontalPositionAlign, VerticalPositionAlign } from "../shared";
import { AlignmentType, HeadingLevel, LeaderType, PageBreak, TabStopPosition, TabStopType } from "./formatting";

@@ -30,2 +30,3 @@ import { FrameAnchorType } from "./frame";

(convenienceFunctions.uniqueId as SinonStub).restore();
(convenienceFunctions.uniqueNumericId as SinonStub).restore();
});

@@ -32,0 +33,0 @@

@@ -126,3 +126,22 @@ import { expect } from "chai";

});
it("should create with the wordWrap property", () => {
const properties = new ParagraphProperties({
wordWrap: true,
});
const tree = new Formatter().format(properties);
expect(tree).to.deep.equal({
"w:pPr": [
{
"w:wordWrap": {
_attr: {
"w:val": 0,
},
},
},
],
});
});
});
});

@@ -14,2 +14,3 @@ // http://officeopenxml.com/WPparagraphProperties.php

import { NumberProperties } from "./formatting/unordered-list";
import { WordWrap } from "./formatting/word-wrap";
import { FrameProperties, IFrameOptions } from "./frame/frame-properties";

@@ -54,2 +55,4 @@ import { OutlineLevel } from "./links";

readonly suppressLineNumbers?: boolean;
readonly wordWrap?: boolean;
readonly scale?: number;
}

@@ -133,2 +136,6 @@

if (options.wordWrap) {
this.push(new WordWrap());
}
/**

@@ -135,0 +142,0 @@ * FIX: Multitab support for Libre Writer

import { expect } from "chai";
import * as sinon from "sinon";

@@ -43,2 +44,13 @@ import { Formatter } from "@export/formatter";

describe("Comment", () => {
let clock: sinon.SinonFakeTimers;
beforeEach(() => {
const now = new Date(1999, 0, 1);
clock = sinon.useFakeTimers(now.getTime());
});
afterEach(() => {
clock.restore();
});
describe("#constructor()", () => {

@@ -76,2 +88,33 @@ it("should create", () => {

});
it("should create by using default date", () => {
const component = new Comment({
id: 0,
text: "test-comment",
});
const tree = new Formatter().format(component);
expect(tree).to.deep.equal({
"w:comment": [
{ _attr: { "w:id": 0, "w:date": "1999-01-01T00:00:00.000Z" } },
{
"w:p": [
{
"w:r": [
{
"w:t": [
{
_attr: {
"xml:space": "preserve",
},
},
"test-comment",
],
},
],
},
],
},
],
});
});
});

@@ -78,0 +121,0 @@ });

@@ -14,2 +14,3 @@ import { expect } from "chai";

stub(convenienceFunctions, "uniqueId").callsFake(() => "test-unique-id");
stub(convenienceFunctions, "uniqueNumericId").callsFake(() => 0);
});

@@ -19,2 +20,3 @@

(convenienceFunctions.uniqueId as SinonStub).restore();
(convenienceFunctions.uniqueNumericId as SinonStub).restore();
});

@@ -130,2 +132,3 @@

name: "",
title: "",
},

@@ -381,2 +384,3 @@ },

name: "",
title: "",
},

@@ -636,2 +640,3 @@ },

name: "",
title: "",
},

@@ -894,2 +899,3 @@ },

name: "",
title: "",
},

@@ -896,0 +902,0 @@ },

import { uniqueId } from "@util/convenience-functions";
import { IContext, IXmlableObject } from "@file/xml-components";
import { DocPropertiesOptions } from "@file/drawing/doc-properties/doc-properties";

@@ -14,2 +15,3 @@ import { Drawing, IFloating } from "../../drawing";

readonly floating?: IFloating;
readonly altText?: DocPropertiesOptions;
}

@@ -41,3 +43,3 @@

};
const drawing = new Drawing(this.imageData, { floating: options.floating });
const drawing = new Drawing(this.imageData, { floating: options.floating, docProperties: options.altText });

@@ -54,11 +56,12 @@ this.root.push(drawing);

private convertDataURIToBinary(dataURI: string): Uint8Array {
// https://gist.github.com/borismus/1032746
// https://github.com/mafintosh/base64-to-uint8array
const BASE64_MARKER = ";base64,";
if (typeof atob === "function") {
// https://gist.github.com/borismus/1032746
// https://github.com/mafintosh/base64-to-uint8array
const BASE64_MARKER = ";base64,";
const base64Index = dataURI.indexOf(BASE64_MARKER);
const base64Index = dataURI.indexOf(BASE64_MARKER) + BASE64_MARKER.length;
const base64IndexWithOffset = base64Index === -1 ? 0 : base64Index + BASE64_MARKER.length;
if (typeof atob === "function") {
return new Uint8Array(
atob(dataURI.substring(base64Index))
atob(dataURI.substring(base64IndexWithOffset))
.split("")

@@ -65,0 +68,0 @@ .map((c) => c.charCodeAt(0)),

@@ -1,2 +0,2 @@

import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -3,0 +3,0 @@

import { BorderElement, IBorderOptions } from "@file/border";
import { IShadingAttributesProperties, Shading } from "@file/shading";
import { SpaceType } from "@file/space-type";
import { ChangeAttributes, IChangedAttributesProperties } from "@file/track-revision/track-revision";
import { HpsMeasureElement, IgnoreIfEmptyXmlComponent, OnOffElement, StringValueElement, XmlComponent } from "@file/xml-components";
import {
HpsMeasureElement,
IgnoreIfEmptyXmlComponent,
NumberValueElement,
OnOffElement,
StringValueElement,
XmlComponent,
} from "@file/xml-components";

@@ -49,3 +55,5 @@ import { EmphasisMark, EmphasisMarkType } from "./emphasis-mark";

readonly border?: IBorderOptions;
readonly space?: SpaceType;
readonly vanish?: boolean;
readonly specVanish?: boolean;
readonly scale?: number;
}

@@ -221,2 +229,17 @@

}
if (options.vanish) {
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_vanish_topic_ID0E6W3O.html
// http://www.datypic.com/sc/ooxml/e-w_vanish-1.html
this.push(new OnOffElement("w:vanish", options.vanish));
}
if (options.specVanish) {
// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_specVanish_topic_ID0EIE1O.html
this.push(new OnOffElement("w:specVanish", options.vanish));
}
if (options.scale !== undefined) {
this.push(new NumberValueElement("w:w", options.scale));
}
}

@@ -223,0 +246,0 @@

@@ -1,2 +0,2 @@

import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -3,0 +3,0 @@

@@ -6,3 +6,2 @@ import { expect } from "chai";

import { ShadingType } from "@file/shading";
import { SpaceType } from "@file/space-type";

@@ -525,17 +524,63 @@ import { EmphasisMarkType } from "./emphasis-mark";

describe("#space", () => {
it("should correctly set the border", () => {
describe("#vanish and #specVanish", () => {
it("should correctly set vanish", () => {
const run = new Run({
space: SpaceType.PRESERVE,
vanish: true,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": {
_attr: {
"xml:space": "preserve",
"w:r": [
{
"w:rPr": [
{
"w:vanish": {},
},
],
},
},
],
});
});
it("should correctly set specVanish", () => {
const run = new Run({
specVanish: true,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{
"w:rPr": [
{
"w:specVanish": {},
},
],
},
],
});
});
describe("#scale", () => {
it("should correctly set the border", () => {
const run = new Run({
scale: 200,
});
const tree = new Formatter().format(run);
expect(tree).to.deep.equal({
"w:r": [
{
"w:rPr": [
{
"w:w": {
_attr: {
"w:val": 200,
},
},
},
],
},
],
});
});
});
});
});

@@ -12,6 +12,6 @@ // http://officeopenxml.com/WPtext.php

import { Text } from "./run-components/text";
import { TextAttributes } from "./text-attributes";
import { Tab } from "./tab";
export interface IRunOptions extends IRunPropertiesOptions {
readonly children?: readonly (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | string)[];
readonly children?: readonly (Begin | FieldInstruction | Separate | End | PageNumber | FootnoteReferenceRun | Tab | string)[];
readonly break?: number;

@@ -41,6 +41,2 @@ readonly text?: string;

if (options.space) {
this.root.push(new TextAttributes({ space: options.space }));
}
if (options.children) {

@@ -47,0 +43,0 @@ for (const child of options.children) {

// http://officeopenxml.com/WPfieldInstructions.php
import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -4,0 +4,0 @@

@@ -0,1 +1,2 @@

// https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_tab_topic_ID0EM6AO.html
import { XmlComponent } from "@file/xml-components";

@@ -2,0 +3,0 @@

@@ -1,2 +0,2 @@

import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlAttributeComponent } from "@file/xml-components";

@@ -3,0 +3,0 @@

import { expect } from "chai";
import { Formatter } from "@export/formatter";
import { EMPTY_OBJECT } from "@file/xml-components";

@@ -14,6 +13,139 @@ import { Compatibility } from "./compatibility";

const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": EMPTY_OBJECT });
expect(tree).to.deep.equal({ "w:compat": {} });
});
});
describe("#version", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
version: 10,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({
"w:compat": [
{
"w:compatSetting": {
_attr: {
"w:name": "compatibilityMode",
"w:uri": "http://schemas.microsoft.com/office/word",
"w:val": 10,
},
},
},
],
});
});
});
describe("#useSingleBorderforContiguousCells", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useSingleBorderforContiguousCells: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useSingleBorderforContiguousCells": {} }] });
});
});
describe("#wordPerfectJustification", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
wordPerfectJustification: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:wpJustification": {} }] });
});
});
describe("#noTabStopForHangingIndent", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
noTabStopForHangingIndent: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:noTabHangInd": {} }] });
});
});
describe("#noLeading", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
noLeading: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:noLeading": {} }] });
});
});
describe("#spaceForUnderline", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
spaceForUnderline: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:spaceForUL": {} }] });
});
});
describe("#noColumnBalance", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
noColumnBalance: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:noColumnBalance": {} }] });
});
});
describe("#balanceSingleByteDoubleByteWidth", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
balanceSingleByteDoubleByteWidth: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:balanceSingleByteDoubleByteWidth": {} }] });
});
});
describe("#noExtraLineSpacing", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
noExtraLineSpacing: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:noExtraLineSpacing": {} }] });
});
});
describe("#doNotLeaveBackslashAlone", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotLeaveBackslashAlone: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotLeaveBackslashAlone": {} }] });
});
});
describe("#underlineTrailingSpaces", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
underlineTrailingSpaces: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:ulTrailSpace": {} }] });
});
});
describe("#doNotExpandShiftReturn", () => {

@@ -26,5 +158,599 @@ it("should create a setting for not justifying lines ending in soft line break", () => {

const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotExpandShiftReturn": EMPTY_OBJECT }] });
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotExpandShiftReturn": {} }] });
});
});
describe("#spacingInWholePoints", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
spacingInWholePoints: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:spacingInWholePoints": {} }] });
});
});
describe("#lineWrapLikeWord6", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
lineWrapLikeWord6: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:lineWrapLikeWord6": {} }] });
});
});
describe("#printBodyTextBeforeHeader", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
printBodyTextBeforeHeader: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:printBodyTextBeforeHeader": {} }] });
});
});
describe("#printColorsBlack", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
printColorsBlack: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:printColBlack": {} }] });
});
});
describe("#spaceWidth", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
spaceWidth: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:wpSpaceWidth": {} }] });
});
});
describe("#showBreaksInFrames", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
showBreaksInFrames: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:showBreaksInFrames": {} }] });
});
});
describe("#subFontBySize", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
subFontBySize: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:subFontBySize": {} }] });
});
});
describe("#suppressBottomSpacing", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
suppressBottomSpacing: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:suppressBottomSpacing": {} }] });
});
});
describe("#suppressTopSpacing", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
suppressTopSpacing: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:suppressTopSpacing": {} }] });
});
});
describe("#suppressSpacingAtTopOfPage", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
suppressSpacingAtTopOfPage: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:suppressSpacingAtTopOfPage": {} }] });
});
});
describe("#suppressTopSpacingWP", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
suppressTopSpacingWP: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:suppressTopSpacingWP": {} }] });
});
});
describe("#suppressSpBfAfterPgBrk", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
suppressSpBfAfterPgBrk: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:suppressSpBfAfterPgBrk": {} }] });
});
});
describe("#swapBordersFacingPages", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
swapBordersFacingPages: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:swapBordersFacingPages": {} }] });
});
});
describe("#convertMailMergeEsc", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
convertMailMergeEsc: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:convMailMergeEsc": {} }] });
});
});
describe("#truncateFontHeightsLikeWP6", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
truncateFontHeightsLikeWP6: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:truncateFontHeightsLikeWP6": {} }] });
});
});
describe("#macWordSmallCaps", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
macWordSmallCaps: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:mwSmallCaps": {} }] });
});
});
describe("#usePrinterMetrics", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
usePrinterMetrics: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:usePrinterMetrics": {} }] });
});
});
describe("#doNotSuppressParagraphBorders", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotSuppressParagraphBorders: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotSuppressParagraphBorders": {} }] });
});
});
describe("#wrapTrailSpaces", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
wrapTrailSpaces: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:wrapTrailSpaces": {} }] });
});
});
describe("#footnoteLayoutLikeWW8", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
footnoteLayoutLikeWW8: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:footnoteLayoutLikeWW8": {} }] });
});
});
describe("#shapeLayoutLikeWW8", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
shapeLayoutLikeWW8: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:shapeLayoutLikeWW8": {} }] });
});
});
describe("#alignTablesRowByRow", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
alignTablesRowByRow: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:alignTablesRowByRow": {} }] });
});
});
describe("#forgetLastTabAlignment", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
forgetLastTabAlignment: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:forgetLastTabAlignment": {} }] });
});
});
describe("#adjustLineHeightInTable", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
adjustLineHeightInTable: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:adjustLineHeightInTable": {} }] });
});
});
describe("#autoSpaceLikeWord95", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
autoSpaceLikeWord95: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:autoSpaceLikeWord95": {} }] });
});
});
describe("#noSpaceRaiseLower", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
noSpaceRaiseLower: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:noSpaceRaiseLower": {} }] });
});
});
describe("#doNotUseHTMLParagraphAutoSpacing", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotUseHTMLParagraphAutoSpacing: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotUseHTMLParagraphAutoSpacing": {} }] });
});
});
describe("#layoutRawTableWidth", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
layoutRawTableWidth: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:layoutRawTableWidth": {} }] });
});
});
describe("#layoutTableRowsApart", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
layoutTableRowsApart: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:layoutTableRowsApart": {} }] });
});
});
describe("#useWord97LineBreakRules", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useWord97LineBreakRules: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useWord97LineBreakRules": {} }] });
});
});
describe("#doNotBreakWrappedTables", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotBreakWrappedTables: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotBreakWrappedTables": {} }] });
});
});
describe("#doNotSnapToGridInCell", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotSnapToGridInCell: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotSnapToGridInCell": {} }] });
});
});
describe("#selectFieldWithFirstOrLastCharacter", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
selectFieldWithFirstOrLastCharacter: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:selectFldWithFirstOrLastChar": {} }] });
});
});
describe("#applyBreakingRules", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
applyBreakingRules: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:applyBreakingRules": {} }] });
});
});
describe("#doNotWrapTextWithPunctuation", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotWrapTextWithPunctuation: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotWrapTextWithPunct": {} }] });
});
});
describe("#doNotUseEastAsianBreakRules", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotUseEastAsianBreakRules: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotUseEastAsianBreakRules": {} }] });
});
});
describe("#useWord2002TableStyleRules", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useWord2002TableStyleRules: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useWord2002TableStyleRules": {} }] });
});
});
describe("#growAutofit", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
growAutofit: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:growAutofit": {} }] });
});
});
describe("#useFELayout", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useFELayout: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useFELayout": {} }] });
});
});
describe("#useNormalStyleForList", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useNormalStyleForList: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useNormalStyleForList": {} }] });
});
});
describe("#doNotUseIndentAsNumberingTabStop", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotUseIndentAsNumberingTabStop: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotUseIndentAsNumberingTabStop": {} }] });
});
});
describe("#useAlternateEastAsianLineBreakRules", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useAlternateEastAsianLineBreakRules: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useAltKinsokuLineBreakRules": {} }] });
});
});
describe("#allowSpaceOfSameStyleInTable", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
allowSpaceOfSameStyleInTable: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:allowSpaceOfSameStyleInTable": {} }] });
});
});
describe("#doNotSuppressIndentation", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotSuppressIndentation: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotSuppressIndentation": {} }] });
});
});
describe("#doNotAutofitConstrainedTables", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotAutofitConstrainedTables: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotAutofitConstrainedTables": {} }] });
});
});
describe("#autofitToFirstFixedWidthCell", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
autofitToFirstFixedWidthCell: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:autofitToFirstFixedWidthCell": {} }] });
});
});
describe("#underlineTabInNumberingList", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
underlineTabInNumberingList: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:underlineTabInNumList": {} }] });
});
});
describe("#displayHangulFixedWidth", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
displayHangulFixedWidth: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:displayHangulFixedWidth": {} }] });
});
});
describe("#splitPgBreakAndParaMark", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
splitPgBreakAndParaMark: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:splitPgBreakAndParaMark": {} }] });
});
});
describe("#doNotVerticallyAlignCellWithSp", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotVerticallyAlignCellWithSp: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotVertAlignCellWithSp": {} }] });
});
});
describe("#doNotBreakConstrainedForcedTable", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
doNotBreakConstrainedForcedTable: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotBreakConstrainedForcedTable": {} }] });
});
});
describe("#ignoreVerticalAlignmentInTextboxes", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
ignoreVerticalAlignmentInTextboxes: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:doNotVertAlignInTxbx": {} }] });
});
});
describe("#useAnsiKerningPairs", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
useAnsiKerningPairs: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:useAnsiKerningPairs": {} }] });
});
});
describe("#cachedColumnBalance", () => {
it("should create a setting for not justifying lines ending in soft line break", () => {
const compatibility = new Compatibility({
cachedColumnBalance: true,
});
const tree = new Formatter().format(compatibility);
expect(tree).to.deep.equal({ "w:compat": [{ "w:cachedColBalance": {} }] });
});
});
});

@@ -0,1 +1,2 @@

// http://www.datypic.com/sc/ooxml/e-w_compat-1.html
import { OnOffElement, XmlComponent } from "@file/xml-components";

@@ -77,4 +78,133 @@ import { CompatibilitySetting } from "./compatibility-setting/compatibility-setting";

export interface ICompatibilityOptions {
readonly version?: number;
/** Use Simplified Rules For Table Border Conflicts */
readonly useSingleBorderforContiguousCells?: boolean;
/** Emulate WordPerfect 6.x Paragraph Justification */
readonly wordPerfectJustification?: boolean;
/** Do Not Create Custom Tab Stop for Hanging Indent */
readonly noTabStopForHangingIndent?: boolean;
/** Do Not Add Leading Between Lines of Text */
readonly noLeading?: boolean;
/** Add Additional Space Below Baseline For Underlined East Asian Text */
readonly spaceForUnderline?: boolean;
/** Do Not Balance Text Columns within a Section */
readonly noColumnBalance?: boolean;
/** Balance Single Byte and Double Byte Characters */
readonly balanceSingleByteDoubleByteWidth?: boolean;
/** Do Not Center Content on Lines With Exact Line Height */
readonly noExtraLineSpacing?: boolean;
/** Convert Backslash To Yen Sign When Entered */
readonly doNotLeaveBackslashAlone?: boolean;
/** Underline All Trailing Spaces */
readonly underlineTrailingSpaces?: boolean;
/** Don't Justify Lines Ending in Soft Line Break */
readonly doNotExpandShiftReturn?: boolean;
readonly version?: number;
/** Only Expand/Condense Text By Whole Points */
readonly spacingInWholePoints?: boolean;
/** Emulate Word 6.0 Line Wrapping for East Asian Text */
readonly lineWrapLikeWord6?: boolean;
/** Print Body Text before Header/Footer Contents */
readonly printBodyTextBeforeHeader?: boolean;
/** Print Colors as Black And White without Dithering */
readonly printColorsBlack?: boolean;
/** Space width */
readonly spaceWidth?: boolean;
/** Display Page/Column Breaks Present in Frames */
readonly showBreaksInFrames?: boolean;
/** Increase Priority Of Font Size During Font Substitution */
readonly subFontBySize?: boolean;
/** Ignore Exact Line Height for Last Line on Page */
readonly suppressBottomSpacing?: boolean;
/** Ignore Minimum and Exact Line Height for First Line on Page */
readonly suppressTopSpacing?: boolean;
/** Ignore Minimum Line Height for First Line on Page */
readonly suppressSpacingAtTopOfPage?: boolean;
/** Emulate WordPerfect 5.x Line Spacing */
readonly suppressTopSpacingWP?: boolean;
/** Do Not Use Space Before On First Line After a Page Break */
readonly suppressSpBfAfterPgBrk?: boolean;
/** Swap Paragraph Borders on Odd Numbered Pages */
readonly swapBordersFacingPages?: boolean;
/** Treat Backslash Quotation Delimiter as Two Quotation Marks */
readonly convertMailMergeEsc?: boolean;
/** Emulate WordPerfect 6.x Font Height Calculation */
readonly truncateFontHeightsLikeWP6?: boolean;
/** Emulate Word 5.x for the Macintosh Small Caps Formatting */
readonly macWordSmallCaps?: boolean;
/** Use Printer Metrics To Display Documents */
readonly usePrinterMetrics?: boolean;
/** Do Not Suppress Paragraph Borders Next To Frames */
readonly doNotSuppressParagraphBorders?: boolean;
/** Line Wrap Trailing Spaces */
readonly wrapTrailSpaces?: boolean;
/** Emulate Word 6.x/95/97 Footnote Placement */
readonly footnoteLayoutLikeWW8?: boolean;
/** Emulate Word 97 Text Wrapping Around Floating Objects */
readonly shapeLayoutLikeWW8?: boolean;
/** Align Table Rows Independently */
readonly alignTablesRowByRow?: boolean;
/** Ignore Width of Last Tab Stop When Aligning Paragraph If It Is Not Left Aligned */
readonly forgetLastTabAlignment?: boolean;
/** Add Document Grid Line Pitch To Lines in Table Cells */
readonly adjustLineHeightInTable?: boolean;
/** Emulate Word 95 Full-Width Character Spacing */
readonly autoSpaceLikeWord95?: boolean;
/** Do Not Increase Line Height for Raised/Lowered Text */
readonly noSpaceRaiseLower?: boolean;
/** Use Fixed Paragraph Spacing for HTML Auto Setting */
readonly doNotUseHTMLParagraphAutoSpacing?: boolean;
/** Ignore Space Before Table When Deciding If Table Should Wrap Floating Object */
readonly layoutRawTableWidth?: boolean;
/** Allow Table Rows to Wrap Inline Objects Independently */
readonly layoutTableRowsApart?: boolean;
/** Emulate Word 97 East Asian Line Breaking */
readonly useWord97LineBreakRules?: boolean;
/** Do Not Allow Floating Tables To Break Across Pages */
readonly doNotBreakWrappedTables?: boolean;
/** Do Not Snap to Document Grid in Table Cells with Objects */
readonly doNotSnapToGridInCell?: boolean;
/** Select Field When First or Last Character Is Selected */
readonly selectFieldWithFirstOrLastCharacter?: boolean;
/** Use Legacy Ethiopic and Amharic Line Breaking Rules */
readonly applyBreakingRules?: boolean;
/** Do Not Allow Hanging Punctuation With Character Grid */
readonly doNotWrapTextWithPunctuation?: boolean;
/** Do Not Compress Compressible Characters When Using Document Grid */
readonly doNotUseEastAsianBreakRules?: boolean;
/** Emulate Word 2002 Table Style Rules */
readonly useWord2002TableStyleRules?: boolean;
/** Allow Tables to AutoFit Into Page Margins */
readonly growAutofit?: boolean;
/** Do Not Bypass East Asian/Complex Script Layout Code */
readonly useFELayout?: boolean;
/** Do Not Automatically Apply List Paragraph Style To Bulleted/Numbered Text */
readonly useNormalStyleForList?: boolean;
/** Ignore Hanging Indent When Creating Tab Stop After Numbering */
readonly doNotUseIndentAsNumberingTabStop?: boolean;
/** Use Alternate Set of East Asian Line Breaking Rules */
readonly useAlternateEastAsianLineBreakRules?: boolean;
/** Allow Contextual Spacing of Paragraphs in Tables */
readonly allowSpaceOfSameStyleInTable?: boolean;
/** Do Not Ignore Floating Objects When Calculating Paragraph Indentation */
readonly doNotSuppressIndentation?: boolean;
/** Do Not AutoFit Tables To Fit Next To Wrapped Objects */
readonly doNotAutofitConstrainedTables?: boolean;
/** Allow Table Columns To Exceed Preferred Widths of Constituent Cells */
readonly autofitToFirstFixedWidthCell?: boolean;
/** Underline Following Character Following Numbering */
readonly underlineTabInNumberingList?: boolean;
/** Always Use Fixed Width for Hangul Characters */
readonly displayHangulFixedWidth?: boolean;
/** Always Move Paragraph Mark to Page after a Page Break */
readonly splitPgBreakAndParaMark?: boolean;
/** Don't Vertically Align Cells Containing Floating Objects */
readonly doNotVerticallyAlignCellWithSp?: boolean;
/** Don't Break Table Rows Around Floating Tables */
readonly doNotBreakConstrainedForcedTable?: boolean;
/** Ignore Vertical Alignment in Textboxes */
readonly ignoreVerticalAlignmentInTextboxes?: boolean;
/** Use ANSI Kerning Pairs from Fonts */
readonly useAnsiKerningPairs?: boolean;
/** Use Cached Paragraph Information for Column Balancing */
readonly cachedColumnBalance?: boolean;
}

@@ -86,11 +216,266 @@

// Don't justify lines ending in soft line break setting
if (options.doNotExpandShiftReturn !== undefined) {
if (options.version) {
this.root.push(new CompatibilitySetting(options.version));
}
if (options.useSingleBorderforContiguousCells) {
this.root.push(new OnOffElement("w:useSingleBorderforContiguousCells", options.useSingleBorderforContiguousCells));
}
if (options.wordPerfectJustification) {
this.root.push(new OnOffElement("w:wpJustification", options.wordPerfectJustification));
}
if (options.noTabStopForHangingIndent) {
this.root.push(new OnOffElement("w:noTabHangInd", options.noTabStopForHangingIndent));
}
if (options.noLeading) {
this.root.push(new OnOffElement("w:noLeading", options.noLeading));
}
if (options.spaceForUnderline) {
this.root.push(new OnOffElement("w:spaceForUL", options.spaceForUnderline));
}
if (options.noColumnBalance) {
this.root.push(new OnOffElement("w:noColumnBalance", options.noColumnBalance));
}
if (options.balanceSingleByteDoubleByteWidth) {
this.root.push(new OnOffElement("w:balanceSingleByteDoubleByteWidth", options.balanceSingleByteDoubleByteWidth));
}
if (options.noExtraLineSpacing) {
this.root.push(new OnOffElement("w:noExtraLineSpacing", options.noExtraLineSpacing));
}
if (options.doNotLeaveBackslashAlone) {
this.root.push(new OnOffElement("w:doNotLeaveBackslashAlone", options.doNotLeaveBackslashAlone));
}
if (options.underlineTrailingSpaces) {
this.root.push(new OnOffElement("w:ulTrailSpace", options.underlineTrailingSpaces));
}
if (options.doNotExpandShiftReturn) {
this.root.push(new OnOffElement("w:doNotExpandShiftReturn", options.doNotExpandShiftReturn));
}
if (options.version) {
this.root.push(new CompatibilitySetting(options.version));
if (options.spacingInWholePoints) {
this.root.push(new OnOffElement("w:spacingInWholePoints", options.spacingInWholePoints));
}
if (options.lineWrapLikeWord6) {
this.root.push(new OnOffElement("w:lineWrapLikeWord6", options.lineWrapLikeWord6));
}
if (options.printBodyTextBeforeHeader) {
this.root.push(new OnOffElement("w:printBodyTextBeforeHeader", options.printBodyTextBeforeHeader));
}
if (options.printColorsBlack) {
this.root.push(new OnOffElement("w:printColBlack", options.printColorsBlack));
}
if (options.spaceWidth) {
this.root.push(new OnOffElement("w:wpSpaceWidth", options.spaceWidth));
}
if (options.showBreaksInFrames) {
this.root.push(new OnOffElement("w:showBreaksInFrames", options.showBreaksInFrames));
}
if (options.subFontBySize) {
this.root.push(new OnOffElement("w:subFontBySize", options.subFontBySize));
}
if (options.suppressBottomSpacing) {
this.root.push(new OnOffElement("w:suppressBottomSpacing", options.suppressBottomSpacing));
}
if (options.suppressTopSpacing) {
this.root.push(new OnOffElement("w:suppressTopSpacing", options.suppressTopSpacing));
}
if (options.suppressSpacingAtTopOfPage) {
this.root.push(new OnOffElement("w:suppressSpacingAtTopOfPage", options.suppressSpacingAtTopOfPage));
}
if (options.suppressTopSpacingWP) {
this.root.push(new OnOffElement("w:suppressTopSpacingWP", options.suppressTopSpacingWP));
}
if (options.suppressSpBfAfterPgBrk) {
this.root.push(new OnOffElement("w:suppressSpBfAfterPgBrk", options.suppressSpBfAfterPgBrk));
}
if (options.swapBordersFacingPages) {
this.root.push(new OnOffElement("w:swapBordersFacingPages", options.swapBordersFacingPages));
}
if (options.convertMailMergeEsc) {
this.root.push(new OnOffElement("w:convMailMergeEsc", options.convertMailMergeEsc));
}
if (options.truncateFontHeightsLikeWP6) {
this.root.push(new OnOffElement("w:truncateFontHeightsLikeWP6", options.truncateFontHeightsLikeWP6));
}
if (options.macWordSmallCaps) {
this.root.push(new OnOffElement("w:mwSmallCaps", options.macWordSmallCaps));
}
if (options.usePrinterMetrics) {
this.root.push(new OnOffElement("w:usePrinterMetrics", options.usePrinterMetrics));
}
if (options.doNotSuppressParagraphBorders) {
this.root.push(new OnOffElement("w:doNotSuppressParagraphBorders", options.doNotSuppressParagraphBorders));
}
if (options.wrapTrailSpaces) {
this.root.push(new OnOffElement("w:wrapTrailSpaces", options.wrapTrailSpaces));
}
if (options.footnoteLayoutLikeWW8) {
this.root.push(new OnOffElement("w:footnoteLayoutLikeWW8", options.footnoteLayoutLikeWW8));
}
if (options.shapeLayoutLikeWW8) {
this.root.push(new OnOffElement("w:shapeLayoutLikeWW8", options.shapeLayoutLikeWW8));
}
if (options.alignTablesRowByRow) {
this.root.push(new OnOffElement("w:alignTablesRowByRow", options.alignTablesRowByRow));
}
if (options.forgetLastTabAlignment) {
this.root.push(new OnOffElement("w:forgetLastTabAlignment", options.forgetLastTabAlignment));
}
if (options.adjustLineHeightInTable) {
this.root.push(new OnOffElement("w:adjustLineHeightInTable", options.adjustLineHeightInTable));
}
if (options.autoSpaceLikeWord95) {
this.root.push(new OnOffElement("w:autoSpaceLikeWord95", options.autoSpaceLikeWord95));
}
if (options.noSpaceRaiseLower) {
this.root.push(new OnOffElement("w:noSpaceRaiseLower", options.noSpaceRaiseLower));
}
if (options.doNotUseHTMLParagraphAutoSpacing) {
this.root.push(new OnOffElement("w:doNotUseHTMLParagraphAutoSpacing", options.doNotUseHTMLParagraphAutoSpacing));
}
if (options.layoutRawTableWidth) {
this.root.push(new OnOffElement("w:layoutRawTableWidth", options.layoutRawTableWidth));
}
if (options.layoutTableRowsApart) {
this.root.push(new OnOffElement("w:layoutTableRowsApart", options.layoutTableRowsApart));
}
if (options.useWord97LineBreakRules) {
this.root.push(new OnOffElement("w:useWord97LineBreakRules", options.useWord97LineBreakRules));
}
if (options.doNotBreakWrappedTables) {
this.root.push(new OnOffElement("w:doNotBreakWrappedTables", options.doNotBreakWrappedTables));
}
if (options.doNotSnapToGridInCell) {
this.root.push(new OnOffElement("w:doNotSnapToGridInCell", options.doNotSnapToGridInCell));
}
if (options.selectFieldWithFirstOrLastCharacter) {
this.root.push(new OnOffElement("w:selectFldWithFirstOrLastChar", options.selectFieldWithFirstOrLastCharacter));
}
if (options.applyBreakingRules) {
this.root.push(new OnOffElement("w:applyBreakingRules", options.applyBreakingRules));
}
if (options.doNotWrapTextWithPunctuation) {
this.root.push(new OnOffElement("w:doNotWrapTextWithPunct", options.doNotWrapTextWithPunctuation));
}
if (options.doNotUseEastAsianBreakRules) {
this.root.push(new OnOffElement("w:doNotUseEastAsianBreakRules", options.doNotUseEastAsianBreakRules));
}
if (options.useWord2002TableStyleRules) {
this.root.push(new OnOffElement("w:useWord2002TableStyleRules", options.useWord2002TableStyleRules));
}
if (options.growAutofit) {
this.root.push(new OnOffElement("w:growAutofit", options.growAutofit));
}
if (options.useFELayout) {
this.root.push(new OnOffElement("w:useFELayout", options.useFELayout));
}
if (options.useNormalStyleForList) {
this.root.push(new OnOffElement("w:useNormalStyleForList", options.useNormalStyleForList));
}
if (options.doNotUseIndentAsNumberingTabStop) {
this.root.push(new OnOffElement("w:doNotUseIndentAsNumberingTabStop", options.doNotUseIndentAsNumberingTabStop));
}
if (options.useAlternateEastAsianLineBreakRules) {
this.root.push(new OnOffElement("w:useAltKinsokuLineBreakRules", options.useAlternateEastAsianLineBreakRules));
}
if (options.allowSpaceOfSameStyleInTable) {
this.root.push(new OnOffElement("w:allowSpaceOfSameStyleInTable", options.allowSpaceOfSameStyleInTable));
}
if (options.doNotSuppressIndentation) {
this.root.push(new OnOffElement("w:doNotSuppressIndentation", options.doNotSuppressIndentation));
}
if (options.doNotAutofitConstrainedTables) {
this.root.push(new OnOffElement("w:doNotAutofitConstrainedTables", options.doNotAutofitConstrainedTables));
}
if (options.autofitToFirstFixedWidthCell) {
this.root.push(new OnOffElement("w:autofitToFirstFixedWidthCell", options.autofitToFirstFixedWidthCell));
}
if (options.underlineTabInNumberingList) {
this.root.push(new OnOffElement("w:underlineTabInNumList", options.underlineTabInNumberingList));
}
if (options.displayHangulFixedWidth) {
this.root.push(new OnOffElement("w:displayHangulFixedWidth", options.displayHangulFixedWidth));
}
if (options.splitPgBreakAndParaMark) {
this.root.push(new OnOffElement("w:splitPgBreakAndParaMark", options.splitPgBreakAndParaMark));
}
if (options.doNotVerticallyAlignCellWithSp) {
this.root.push(new OnOffElement("w:doNotVertAlignCellWithSp", options.doNotVerticallyAlignCellWithSp));
}
if (options.doNotBreakConstrainedForcedTable) {
this.root.push(new OnOffElement("w:doNotBreakConstrainedForcedTable", options.doNotBreakConstrainedForcedTable));
}
if (options.ignoreVerticalAlignmentInTextboxes) {
this.root.push(new OnOffElement("w:doNotVertAlignInTxbx", options.ignoreVerticalAlignmentInTextboxes));
}
if (options.useAnsiKerningPairs) {
this.root.push(new OnOffElement("w:useAnsiKerningPairs", options.useAnsiKerningPairs));
}
if (options.cachedColumnBalance) {
this.root.push(new OnOffElement("w:cachedColBalance", options.cachedColumnBalance));
}
}
}

@@ -64,3 +64,78 @@ import { expect } from "chai";

});
it("should add compatibility setting with default compatability version", () => {
const settings = new Settings({
compatibility: {},
});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
expect(tree["w:settings"]).to.deep.include({
"w:compat": [
{
"w:compatSetting": {
_attr: {
"w:name": "compatibilityMode",
"w:uri": "http://schemas.microsoft.com/office/word",
"w:val": 15,
},
},
},
],
});
});
it("should add compatibility setting with version", () => {
const settings = new Settings({
compatibility: {
version: 99,
},
});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
expect(tree["w:settings"]).to.deep.include({
"w:compat": [
{
"w:compatSetting": {
_attr: {
"w:name": "compatibilityMode",
"w:uri": "http://schemas.microsoft.com/office/word",
"w:val": 99,
},
},
},
],
});
});
// TODO: Remove when deprecating compatibilityModeVersion
it("should add compatibility setting with legacy version", () => {
const settings = new Settings({
compatibilityModeVersion: 99,
});
const tree = new Formatter().format(settings);
expect(Object.keys(tree)).has.length(1);
expect(tree["w:settings"]).to.be.an("array");
expect(tree["w:settings"]).to.deep.include({
"w:compat": [
{
"w:compatSetting": {
_attr: {
"w:name": "compatibilityMode",
"w:uri": "http://schemas.microsoft.com/office/word",
"w:val": 99,
},
},
},
],
});
});
});
});
import { OnOffElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { Compatibility } from "./compatibility";
import { Compatibility, ICompatibilityOptions } from "./compatibility";

@@ -150,6 +150,7 @@ export class SettingsAttributes extends XmlAttributeComponent<{

export interface ISettingsOptions {
readonly compatabilityModeVersion?: number;
readonly compatibilityModeVersion?: number;
readonly evenAndOddHeaders?: boolean;
readonly trackRevisions?: boolean;
readonly updateFields?: boolean;
readonly compatibility?: ICompatibilityOptions;
}

@@ -203,3 +204,4 @@

new Compatibility({
version: options.compatabilityModeVersion || 15,
...(options.compatibility ?? {}),
version: options.compatibility?.version ?? options.compatibilityModeVersion ?? 15,
}),

@@ -206,0 +208,0 @@ );

export * from "./alignment";
export * from "./number-format";
export * from "./space-type";
// http://officeopenxml.com/WPfieldInstructions.php
import { TextAttributes } from "@file/paragraph/run/text-attributes";
import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -5,0 +5,0 @@

// http://www.datypic.com/sc/ooxml/e-w_sdtPr-1.html
import { XmlComponent } from "@file/xml-components";
import { Alias } from "./alias";
import { StringValueElement, XmlComponent } from "@file/xml-components";

@@ -8,4 +7,4 @@ export class StructuredDocumentTagProperties extends XmlComponent {

super("w:sdtPr");
this.root.push(new Alias(alias));
this.root.push(new StringValueElement("w:alias", alias));
}
}

@@ -5,2 +5,1 @@ export * from "./table-properties";

export * from "./table-borders";
export * from "./table-overlap";

@@ -5,4 +5,9 @@ import { expect } from "chai";

import { RelativeHorizontalPosition, RelativeVerticalPosition, TableAnchorType, TableFloatProperties } from "./table-float-properties";
import { OverlapType } from "./table-overlap";
import {
OverlapType,
RelativeHorizontalPosition,
RelativeVerticalPosition,
TableAnchorType,
TableFloatProperties,
} from "./table-float-properties";

@@ -9,0 +14,0 @@ describe("Table Float Properties", () => {

@@ -1,6 +0,4 @@

import { XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { StringEnumValueElement, XmlAttributeComponent, XmlComponent } from "@file/xml-components";
import { signedTwipsMeasureValue, twipsMeasureValue } from "@util/values";
import { OverlapType, TableOverlap } from "./table-overlap";
export enum TableAnchorType {

@@ -29,2 +27,13 @@ MARGIN = "margin",

// <xsd:simpleType name="ST_TblOverlap">
// <xsd:restriction base="xsd:string">
// <xsd:enumeration value="never"/>
// <xsd:enumeration value="overlap"/>
// </xsd:restriction>
// </xsd:simpleType>
export enum OverlapType {
NEVER = "never",
OVERLAP = "overlap",
}
export interface ITableFloatOptions {

@@ -175,5 +184,8 @@ /* cSpell:disable */

if (options.overlap) {
this.root.push(new TableOverlap(options.overlap));
// <xsd:complexType name="CT_TblOverlap">
// <xsd:attribute name="val" type="ST_TblOverlap" use="required"/>
// </xsd:complexType>
this.root.push(new StringEnumValueElement<OverlapType>("w:tblOverlap", options.overlap));
}
}
}
import { TextAttributes } from "@file/paragraph/run/text-attributes";
import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -4,0 +4,0 @@

import { TextAttributes } from "@file/paragraph/run/text-attributes";
import { SpaceType } from "@file/space-type";
import { SpaceType } from "@file/shared";
import { XmlComponent } from "@file/xml-components";

@@ -4,0 +4,0 @@

@@ -6,3 +6,3 @@ import { expect } from "chai";

import { convertToXmlComponent, ImportedXmlComponent } from "./imported-xml-component";
import { convertToXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent } from "./imported-xml-component";
import { IContext } from "./base";

@@ -94,3 +94,27 @@

});
it("should return undefined if xml type is invalid", () => {
const xmlObj = { type: "invalid" } as Element;
const converted = convertToXmlComponent(xmlObj);
expect(converted).to.equal(undefined);
});
});
});
describe("ImportedRootElementAttributes", () => {
let attributes: ImportedRootElementAttributes;
beforeEach(() => {
attributes = new ImportedRootElementAttributes({});
});
describe("#prepForXml()", () => {
it("should work", () => {
// tslint:disable-next-line: no-object-literal-type-assertion
const converted = attributes.prepForXml({} as IContext);
expect(converted).to.deep.equal({
_attr: {},
});
});
});
});

@@ -56,2 +56,9 @@ import { Attributes, XmlComponent } from "@file/xml-components";

export class StringEnumValueElement<T extends string> extends XmlComponent {
public constructor(name: string, val: T) {
super(name);
this.root.push(new Attributes({ val }));
}
}
// Simple nodes containing text.

@@ -58,0 +65,0 @@ //

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc