From 24f95aee8bb483200c5d41542bc2d4a2edcf4300 Mon Sep 17 00:00:00 2001 From: Dolan Date: Mon, 15 Mar 2021 03:46:34 +0000 Subject: [PATCH] Add custom bullet point example --- demo/3-numbering-and-bullet-points.ts | 115 +++++++++++++++++++++++++- 1 file changed, 114 insertions(+), 1 deletion(-) diff --git a/demo/3-numbering-and-bullet-points.ts b/demo/3-numbering-and-bullet-points.ts index 375c1439a7..acff5772cc 100644 --- a/demo/3-numbering-and-bullet-points.ts +++ b/demo/3-numbering-and-bullet-points.ts @@ -1,7 +1,7 @@ // Numbering and bullet points example // Import from 'docx' rather than '../build' if you install from npm import * as fs from "fs"; -import { AlignmentType, convertInchesToTwip, Document, LevelFormat, Packer, Paragraph } from "../build"; +import { AlignmentType, convertInchesToTwip, Document, HeadingLevel, LevelFormat, Packer, Paragraph } from "../build"; const doc = new Document({ numbering: { @@ -55,6 +55,66 @@ const doc = new Document({ }, ], }, + { + reference: "my-unique-bullet-points", + levels: [ + { + level: 0, + format: LevelFormat.BULLET, + text: "\u1F60", + alignment: AlignmentType.LEFT, + style: { + paragraph: { + indent: { left: convertInchesToTwip(0.5), hanging: convertInchesToTwip(0.25) }, + }, + }, + }, + { + level: 1, + format: LevelFormat.BULLET, + text: "\u00A5", + alignment: AlignmentType.LEFT, + style: { + paragraph: { + indent: { left: convertInchesToTwip(1), hanging: convertInchesToTwip(0.25) }, + }, + }, + }, + { + level: 2, + format: LevelFormat.BULLET, + text: "\u273F", + alignment: AlignmentType.LEFT, + style: { + paragraph: { + indent: { left: 2160, hanging: convertInchesToTwip(0.25) }, + }, + }, + }, + { + level: 3, + format: LevelFormat.BULLET, + text: "\u267A", + alignment: AlignmentType.LEFT, + style: { + paragraph: { + indent: { left: 2880, hanging: convertInchesToTwip(0.25) }, + }, + }, + }, + { + level: 4, + format: LevelFormat.BULLET, + text: "\u2603", + alignment: AlignmentType.LEFT, + style: { + paragraph: { + indent: { left: 3600, hanging: convertInchesToTwip(0.25) }, + }, + }, + }, + ], + }, ], }, }); @@ -134,6 +194,59 @@ doc.addSection({ level: 0, }, }), + new Paragraph({ + text: "Custom Bullet points", + heading: HeadingLevel.HEADING_1, + }), + new Paragraph({ + text: "What's up fam", + numbering: { + reference: "my-unique-bullet-points", + level: 0, + }, + }), + new Paragraph({ + text: "Hey you", + numbering: { + reference: "my-unique-bullet-points", + level: 0, + }, + }), + new Paragraph({ + text: "What's up fam", + numbering: { + reference: "my-unique-bullet-points", + level: 1, + }, + }), + new Paragraph({ + text: "Hello World 2", + numbering: { + reference: "my-unique-bullet-points", + level: 2, + }, + }), + new Paragraph({ + text: "Yeah boi", + numbering: { + reference: "my-unique-bullet-points", + level: 3, + }, + }), + new Paragraph({ + text: "my Awesome numbering", + numbering: { + reference: "my-unique-bullet-points", + level: 4, + }, + }), + new Paragraph({ + text: "Back to level 1", + numbering: { + reference: "my-unique-bullet-points", + level: 1, + }, + }), ], });