update file/numbering with schema comments and values functions
This commit is contained in:
@ -11,6 +11,25 @@ export interface IDocumentOptions {
|
|||||||
readonly background: IDocumentBackgroundOptions;
|
readonly background: IDocumentBackgroundOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:element name="document" type="CT_Document"/>
|
||||||
|
//
|
||||||
|
// <xsd:complexType name="CT_Document">
|
||||||
|
// <xsd:complexContent>
|
||||||
|
// <xsd:extension base="CT_DocumentBase">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="body" type="CT_Body" minOccurs="0" maxOccurs="1"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// <xsd:attribute name="conformance" type="s:ST_ConformanceClass"/>
|
||||||
|
// <xsd:attribute ref="mc:Ignorable" use="optional" />
|
||||||
|
// </xsd:extension>
|
||||||
|
// </xsd:complexContent>
|
||||||
|
// </xsd:complexType>
|
||||||
|
//
|
||||||
|
// <xsd:complexType name="CT_DocumentBase">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="background" type="CT_Background" minOccurs="0"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// </xsd:complexType>
|
||||||
export class Document extends XmlComponent {
|
export class Document extends XmlComponent {
|
||||||
private readonly body: Body;
|
private readonly body: Body;
|
||||||
|
|
||||||
|
@ -1,8 +1,24 @@
|
|||||||
|
import { decimalNumber } from "file/values";
|
||||||
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
import { XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
import { ILevelsOptions, Level } from "./level";
|
import { ILevelsOptions, Level } from "./level";
|
||||||
import { MultiLevelType } from "./multi-level-type";
|
import { MultiLevelType } from "./multi-level-type";
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_AbstractNum">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="nsid" type="CT_LongHexNumber" minOccurs="0"/>
|
||||||
|
// <xsd:element name="multiLevelType" type="CT_MultiLevelType" minOccurs="0"/>
|
||||||
|
// <xsd:element name="tmpl" type="CT_LongHexNumber" minOccurs="0"/>
|
||||||
|
// <xsd:element name="name" type="CT_String" minOccurs="0"/>
|
||||||
|
// <xsd:element name="styleLink" type="CT_String" minOccurs="0"/>
|
||||||
|
// <xsd:element name="numStyleLink" type="CT_String" minOccurs="0"/>
|
||||||
|
// <xsd:element name="lvl" type="CT_Lvl" minOccurs="0" maxOccurs="9"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// <xsd:attribute name="abstractNumId" type="ST_DecimalNumber" use="required"/>
|
||||||
|
// </xsd:complexType>
|
||||||
|
|
||||||
|
// <xsd:attribute name="restartNumberingAfterBreak" type="w12:ST_OnOff"/>
|
||||||
|
// https://docs.microsoft.com/en-us/openspecs/office_standards/ms-docx/cbddeff8-01aa-4486-a48e-6a83dede4f13
|
||||||
class AbstractNumberingAttributes extends XmlAttributeComponent<{
|
class AbstractNumberingAttributes extends XmlAttributeComponent<{
|
||||||
readonly abstractNumId: number;
|
readonly abstractNumId: number;
|
||||||
readonly restartNumberingAfterBreak: number;
|
readonly restartNumberingAfterBreak: number;
|
||||||
@ -20,7 +36,7 @@ export class AbstractNumbering extends XmlComponent {
|
|||||||
super("w:abstractNum");
|
super("w:abstractNum");
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new AbstractNumberingAttributes({
|
new AbstractNumberingAttributes({
|
||||||
abstractNumId: id,
|
abstractNumId: decimalNumber(id),
|
||||||
restartNumberingAfterBreak: 0,
|
restartNumberingAfterBreak: 0,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// http://officeopenxml.com/WPnumbering-numFmt.php
|
// http://officeopenxml.com/WPnumbering-numFmt.php
|
||||||
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
import { decimalNumber } from "file/values";
|
||||||
|
import { Attributes, NumberValueElement, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
import { AlignmentType } from "../paragraph/formatting";
|
import { AlignmentType } from "../paragraph/formatting";
|
||||||
import { IParagraphStylePropertiesOptions, ParagraphProperties } from "../paragraph/properties";
|
import { IParagraphStylePropertiesOptions, ParagraphProperties } from "../paragraph/properties";
|
||||||
import { IRunStylePropertiesOptions, RunProperties } from "../paragraph/run/properties";
|
import { IRunStylePropertiesOptions, RunProperties } from "../paragraph/run/properties";
|
||||||
@ -31,17 +32,10 @@ class LevelAttributes extends XmlAttributeComponent<{
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class Start extends XmlComponent {
|
// <xsd:complexType name="CT_NumFmt">
|
||||||
constructor(value: number) {
|
// <xsd:attribute name="val" type="ST_NumberFormat" use="required"/>
|
||||||
super("w:start");
|
// <xsd:attribute name="format" type="s:ST_String" use="optional"/>
|
||||||
this.root.push(
|
// </xsd:complexType>
|
||||||
new Attributes({
|
|
||||||
val: value,
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class NumberFormat extends XmlComponent {
|
class NumberFormat extends XmlComponent {
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:numFmt");
|
super("w:numFmt");
|
||||||
@ -53,6 +47,10 @@ class NumberFormat extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_LevelText">
|
||||||
|
// <xsd:attribute name="val" type="s:ST_String" use="optional"/>
|
||||||
|
// <xsd:attribute name="null" type="s:ST_OnOff" use="optional"/>
|
||||||
|
// </xsd:complexType>
|
||||||
class LevelText extends XmlComponent {
|
class LevelText extends XmlComponent {
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:lvlText");
|
super("w:lvlText");
|
||||||
@ -94,6 +92,16 @@ export interface ILevelsOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_LevelSuffix">
|
||||||
|
// <xsd:attribute name="val" type="ST_LevelSuffix" use="required"/>
|
||||||
|
// </xsd:complexType>
|
||||||
|
// <xsd:simpleType name="ST_LevelSuffix">
|
||||||
|
// <xsd:restriction base="xsd:string">
|
||||||
|
// <xsd:enumeration value="tab"/>
|
||||||
|
// <xsd:enumeration value="space"/>
|
||||||
|
// <xsd:enumeration value="nothing"/>
|
||||||
|
// </xsd:restriction>
|
||||||
|
// </xsd:simpleType>
|
||||||
class Suffix extends XmlComponent {
|
class Suffix extends XmlComponent {
|
||||||
constructor(value: LevelSuffix) {
|
constructor(value: LevelSuffix) {
|
||||||
super("w:suff");
|
super("w:suff");
|
||||||
@ -105,6 +113,25 @@ class Suffix extends XmlComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_Lvl">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="start" type="CT_DecimalNumber" minOccurs="0"/>
|
||||||
|
// <xsd:element name="numFmt" type="CT_NumFmt" minOccurs="0"/>
|
||||||
|
// <xsd:element name="lvlRestart" type="CT_DecimalNumber" minOccurs="0"/>
|
||||||
|
// <xsd:element name="pStyle" type="CT_String" minOccurs="0"/>
|
||||||
|
// <xsd:element name="isLgl" type="CT_OnOff" minOccurs="0"/>
|
||||||
|
// <xsd:element name="suff" type="CT_LevelSuffix" minOccurs="0"/>
|
||||||
|
// <xsd:element name="lvlText" type="CT_LevelText" minOccurs="0"/>
|
||||||
|
// <xsd:element name="lvlPicBulletId" type="CT_DecimalNumber" minOccurs="0"/>
|
||||||
|
// <xsd:element name="legacy" type="CT_LvlLegacy" minOccurs="0"/>
|
||||||
|
// <xsd:element name="lvlJc" type="CT_Jc" minOccurs="0"/>
|
||||||
|
// <xsd:element name="pPr" type="CT_PPrGeneral" minOccurs="0"/>
|
||||||
|
// <xsd:element name="rPr" type="CT_RPr" minOccurs="0"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// <xsd:attribute name="ilvl" type="ST_DecimalNumber" use="required"/>
|
||||||
|
// <xsd:attribute name="tplc" type="ST_LongHexNumber" use="optional"/>
|
||||||
|
// <xsd:attribute name="tentative" type="s:ST_OnOff" use="optional"/>
|
||||||
|
// </xsd:complexType>
|
||||||
export class LevelBase extends XmlComponent {
|
export class LevelBase extends XmlComponent {
|
||||||
private readonly paragraphProperties: ParagraphProperties;
|
private readonly paragraphProperties: ParagraphProperties;
|
||||||
private readonly runProperties: RunProperties;
|
private readonly runProperties: RunProperties;
|
||||||
@ -112,7 +139,7 @@ export class LevelBase extends XmlComponent {
|
|||||||
constructor({ level, format, text, alignment = AlignmentType.START, start = 1, style, suffix }: ILevelsOptions) {
|
constructor({ level, format, text, alignment = AlignmentType.START, start = 1, style, suffix }: ILevelsOptions) {
|
||||||
super("w:lvl");
|
super("w:lvl");
|
||||||
|
|
||||||
this.root.push(new Start(start));
|
this.root.push(new NumberValueElement("w:start", decimalNumber(start)));
|
||||||
|
|
||||||
if (format) {
|
if (format) {
|
||||||
this.root.push(new NumberFormat(format));
|
this.root.push(new NumberFormat(format));
|
||||||
@ -136,7 +163,7 @@ export class LevelBase extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new LevelAttributes({
|
new LevelAttributes({
|
||||||
ilvl: level,
|
ilvl: decimalNumber(level),
|
||||||
tentative: 1,
|
tentative: 1,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -1,5 +1,19 @@
|
|||||||
import { Attributes, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_AbstractNum">
|
||||||
|
// ...
|
||||||
|
// <xsd:element name="multiLevelType" type="CT_MultiLevelType" minOccurs="0"/>
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_MultiLevelType">
|
||||||
|
// <xsd:attribute name="val" type="ST_MultiLevelType" use="required"/>
|
||||||
|
// </xsd:complexType>
|
||||||
|
// <xsd:simpleType name="ST_MultiLevelType">
|
||||||
|
// <xsd:restriction base="xsd:string">
|
||||||
|
// <xsd:enumeration value="singleLevel"/>
|
||||||
|
// <xsd:enumeration value="multilevel"/>
|
||||||
|
// <xsd:enumeration value="hybridMultilevel"/>
|
||||||
|
// </xsd:restriction>
|
||||||
|
// </xsd:simpleType>
|
||||||
export class MultiLevelType extends XmlComponent {
|
export class MultiLevelType extends XmlComponent {
|
||||||
constructor(value: string) {
|
constructor(value: string) {
|
||||||
super("w:multiLevelType");
|
super("w:multiLevelType");
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { decimalNumber } from "file/values";
|
||||||
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
import { Attributes, XmlAttributeComponent, XmlComponent } from "file/xml-components";
|
||||||
|
|
||||||
class AbstractNumId extends XmlComponent {
|
class AbstractNumId extends XmlComponent {
|
||||||
@ -28,6 +29,17 @@ export interface IConcreteNumberingOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_Numbering">
|
||||||
|
// ...
|
||||||
|
// <xsd:element name="num" type="CT_Num" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
|
||||||
|
// <xsd:complexType name="CT_Num">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="abstractNumId" type="CT_DecimalNumber" minOccurs="1"/>
|
||||||
|
// <xsd:element name="lvlOverride" type="CT_NumLvl" minOccurs="0" maxOccurs="9"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// <xsd:attribute name="numId" type="ST_DecimalNumber" use="required"/>
|
||||||
|
// </xsd:complexType>
|
||||||
export class ConcreteNumbering extends XmlComponent {
|
export class ConcreteNumbering extends XmlComponent {
|
||||||
public readonly numId: number;
|
public readonly numId: number;
|
||||||
public readonly reference: string;
|
public readonly reference: string;
|
||||||
@ -42,11 +54,11 @@ export class ConcreteNumbering extends XmlComponent {
|
|||||||
|
|
||||||
this.root.push(
|
this.root.push(
|
||||||
new NumAttributes({
|
new NumAttributes({
|
||||||
numId: options.numId,
|
numId: decimalNumber(options.numId),
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.root.push(new AbstractNumId(options.abstractNumId));
|
this.root.push(new AbstractNumId(decimalNumber(options.abstractNumId)));
|
||||||
|
|
||||||
if (options.overrideLevel) {
|
if (options.overrideLevel) {
|
||||||
this.root.push(new LevelOverride(options.overrideLevel.num, options.overrideLevel.start));
|
this.root.push(new LevelOverride(options.overrideLevel.num, options.overrideLevel.start));
|
||||||
|
@ -16,6 +16,16 @@ export interface INumberingOptions {
|
|||||||
}[];
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <xsd:element name="numbering" type="CT_Numbering"/>
|
||||||
|
//
|
||||||
|
// <xsd:complexType name="CT_Numbering">
|
||||||
|
// <xsd:sequence>
|
||||||
|
// <xsd:element name="numPicBullet" type="CT_NumPicBullet" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
// <xsd:element name="abstractNum" type="CT_AbstractNum" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
// <xsd:element name="num" type="CT_Num" minOccurs="0" maxOccurs="unbounded"/>
|
||||||
|
// <xsd:element name="numIdMacAtCleanup" type="CT_DecimalNumber" minOccurs="0"/>
|
||||||
|
// </xsd:sequence>
|
||||||
|
// </xsd:complexType>
|
||||||
export class Numbering extends XmlComponent {
|
export class Numbering extends XmlComponent {
|
||||||
private readonly abstractNumberingMap = new Map<string, AbstractNumbering>();
|
private readonly abstractNumberingMap = new Map<string, AbstractNumbering>();
|
||||||
private readonly concreteNumberingMap = new Map<string, ConcreteNumbering>();
|
private readonly concreteNumberingMap = new Map<string, ConcreteNumbering>();
|
||||||
|
Reference in New Issue
Block a user