Skip to content

Commit

Permalink
#933 Discriminated union for frame alignment (#2477)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolanmiu authored Dec 29, 2023
1 parent 2550da1 commit b8f9755
Show file tree
Hide file tree
Showing 5 changed files with 321 additions and 190 deletions.
103 changes: 103 additions & 0 deletions demo/61-text-frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import * as fs from "fs";
import {
AlignmentType,
BorderStyle,
Document,
FrameAnchorType,
Expand All @@ -20,6 +21,7 @@ const doc = new Document({
children: [
new Paragraph({
frame: {
type: "absolute",
position: {
x: 1000,
y: 3000,
Expand All @@ -30,6 +32,54 @@ const doc = new Document({
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
},
border: {
top: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
bottom: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
left: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
right: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
},
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
children: [new Tab(), "Github is the best"],
bold: true,
}),
],
}),
new Paragraph({
frame: {
type: "alignment",
width: 4000,
height: 1000,
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
alignment: {
x: HorizontalPositionAlign.CENTER,
y: VerticalPositionAlign.TOP,
Expand Down Expand Up @@ -73,6 +123,59 @@ const doc = new Document({
}),
],
}),
new Paragraph({
frame: {
type: "alignment",
width: 4000,
height: 1000,
anchor: {
horizontal: FrameAnchorType.MARGIN,
vertical: FrameAnchorType.MARGIN,
},
alignment: {
x: HorizontalPositionAlign.CENTER,
y: VerticalPositionAlign.BOTTOM,
},
},
border: {
top: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
bottom: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
left: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
right: {
color: "auto",
space: 1,
style: BorderStyle.SINGLE,
size: 6,
},
},
alignment: AlignmentType.RIGHT,
children: [
new TextRun("Hello World"),
new TextRun({
text: "Foo Bar",
bold: true,
}),
new TextRun({
children: [new Tab(), "Github is the best"],
bold: true,
}),
],
}),
],
},
],
Expand Down
Loading

0 comments on commit b8f9755

Please sign in to comment.