summaryrefslogtreecommitdiff
path: root/lib/documents.js
blob: 5f64059bc009f915dc4d65ca624b5c3686dea3d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
function Document(children) {
    return {
        type: "document",
        children: children
    };
}

function Paragraph(children, properties) {
    properties = properties || {};
    return {
        type: "paragraph",
        children: children,
        styleName: properties.styleName || null,
        numbering: properties.numbering || null
    };
}

function Run(children, properties) {
    properties = properties || {};
    return {
        type: "run",
        children: children,
        styleName: properties.styleName || null,
        isBold: properties.isBold,
        isItalic: properties.isItalic
    };
}

function Text(value) {
    return {
        type: "text",
        value: value
    };
}

function Hyperlink(children, options) {
    return {
        type: "hyperlink",
        children: children,
        href: options.href
    };
}

function ElementWithChildren(type) {
    return function(children, properties) {
        return {
            type: type,
            children: children,
            properties: properties || {}
        };
    };
}

function Image(options) {
    return {
        type: "image",
        read: options.readImage,
        altText: options.altText,
        contentType: options.contentType
    };
}

exports.Document = Document;
exports.Paragraph = Paragraph;
exports.Run = Run;
exports.Text = Text;
exports.Hyperlink = Hyperlink;
exports.Image = Image;