chore: organise the demos into a folder for each topic (#3552)
* chore: organise the demos into a folder for each topic The demos were one flat list of 124 numbered files, which made it hard to find the one you wanted. Each is now in a folder for its topic, such as demo/tables/basic-table.ts, with a name that says what it shows instead of a number. npm run demo lists every demo and narrows the list as you type. It also takes a demo's path or name, a topic, or search words. The demos' images moved to demo/assets/images, as images is now a topic. The docs' links, the Demos workflow, the shape render script and its reference images use the new paths and names. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ * fix: list only a topic's own demos, and drop stale output file names npm run demo text also offered the text-boxes demos and others with "text" in their name, so a topic now searches for "text/". Three demos logged their old numbered file name after writing My Document.docx. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@@ -34,5 +34,5 @@ Uses **Vitest**. Tests are co-located with source files as `*.spec.ts`.
|
||||
## Running Demos
|
||||
|
||||
```bash
|
||||
npm run run-ts -- ./demo/<demo-file>.ts
|
||||
npm run run-ts -- ./demo/<topic>/<demo>.ts
|
||||
```
|
||||
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
- name: Run and validate the demos
|
||||
shell: bash
|
||||
run: |
|
||||
for demo in $(ls demo/[0-9]*.ts | sort -V | awk -v n=${{ strategy.job-total }} -v i=${{ strategy.job-index }} 'NR % n == i'); do
|
||||
for demo in $(find demo -mindepth 2 -name "*.ts" -not -path "demo/assets/*" | sort | awk -v n=${{ strategy.job-total }} -v i=${{ strategy.job-index }} 'NR % n == i'); do
|
||||
echo "::group::$demo"
|
||||
rm -rf ./*.docx embeddings
|
||||
npm run --silent run-ts -- "$demo"
|
||||
|
||||
@@ -27,5 +27,5 @@ TypeScript library for generating .docx files. Declarative API, works in Node.js
|
||||
## Running Demos
|
||||
|
||||
```bash
|
||||
npm run run-ts -- ./demo/<demo-file>.ts
|
||||
npm run run-ts -- ./demo/<topic>/<demo>.ts
|
||||
```
|
||||
|
||||
|
Before Width: | Height: | Size: 154 KiB After Width: | Height: | Size: 154 KiB |
|
Before Width: | Height: | Size: 190 KiB After Width: | Height: | Size: 190 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 71 KiB After Width: | Height: | Size: 71 KiB |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 310 KiB After Width: | Height: | Size: 310 KiB |
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Demo 101: Comment replies (threading) and resolved comments.
|
||||
* Comment replies (threading) and resolved comments.
|
||||
*
|
||||
* Shows two comment threads: one active with replies, one resolved.
|
||||
* See docs/usage/comments.md for full documentation.
|
||||
@@ -22,7 +22,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
data: fs.readFileSync("./demo/assets/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -1,9 +1,9 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<script src="../dist/index.umd.cjs"></script>
|
||||
<script src="../../dist/index.umd.cjs"></script>
|
||||
<!-- docx/shapes: load it after docx. It adds the docxShapes global -->
|
||||
<script src="../dist/shapes.umd.cjs"></script>
|
||||
<script src="../../dist/shapes.umd.cjs"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
|
||||
</head>
|
||||
|
||||
@@ -68,7 +68,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
data: fs.readFileSync("./demo/assets/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -12,7 +12,7 @@ const table = new Table({
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
type: "jpg",
|
||||
transformation: {
|
||||
width: 100,
|
||||
@@ -50,7 +50,7 @@ const table = new Table({
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
type: "jpg",
|
||||
transformation: {
|
||||
width: 100,
|
||||
@@ -78,7 +78,7 @@ const doc = new Document({
|
||||
new Paragraph({
|
||||
children: [
|
||||
new ImageRun({
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
type: "gif",
|
||||
transformation: {
|
||||
width: 100,
|
||||
@@ -14,7 +14,7 @@ const doc = new Document({
|
||||
new TextRun("Hello World"),
|
||||
new ImageRun({
|
||||
type: "bmp",
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
data: fs.readFileSync("./demo/assets/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -26,7 +26,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -38,7 +38,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "png",
|
||||
data: fs.readFileSync("./demo/images/dog.png"),
|
||||
data: fs.readFileSync("./demo/assets/images/dog.png"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -50,7 +50,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
data: fs.readFileSync("./demo/assets/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -62,7 +62,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "bmp",
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
data: fs.readFileSync("./demo/assets/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -32,7 +32,7 @@ const table = new Table({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -51,7 +51,7 @@ const table = new Table({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -36,7 +36,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -13,7 +13,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "bmp",
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
data: fs.readFileSync("./demo/assets/images/parrots.bmp"),
|
||||
transformation: { width: 200, height: 150 },
|
||||
altText: { name: "Parrots", description: "Two parrots on a branch", title: "Parrots" },
|
||||
link: "https://en.wikipedia.org/wiki/Parrot",
|
||||
@@ -25,7 +25,7 @@ const doc = new Document({
|
||||
new TextRun("A decorative image, which screen readers skip: "),
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: { width: 40, height: 40 },
|
||||
decorative: true,
|
||||
}),
|
||||
@@ -36,7 +36,7 @@ const doc = new Document({
|
||||
new TextRun("A floating image can have a link too."),
|
||||
new ImageRun({
|
||||
type: "png",
|
||||
data: fs.readFileSync("./demo/images/dog.png"),
|
||||
data: fs.readFileSync("./demo/assets/images/dog.png"),
|
||||
transformation: { width: 100, height: 100 },
|
||||
floating: {
|
||||
horizontalPosition: { relative: HorizontalPositionRelativeFrom.PAGE, offset: 5000000 },
|
||||
@@ -13,7 +13,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -31,7 +31,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -22,7 +22,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -39,7 +39,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "png",
|
||||
data: fs.readFileSync("./demo/images/dog.png").toString("base64"),
|
||||
data: fs.readFileSync("./demo/assets/images/dog.png").toString("base64"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -56,7 +56,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
data: fs.readFileSync("./demo/assets/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -77,7 +77,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "bmp",
|
||||
data: fs.readFileSync("./demo/images/parrots.bmp"),
|
||||
data: fs.readFileSync("./demo/assets/images/parrots.bmp"),
|
||||
transformation: {
|
||||
width: 150,
|
||||
height: 150,
|
||||
@@ -93,7 +93,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
@@ -109,7 +109,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
@@ -131,7 +131,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/cat.jpg"),
|
||||
data: fs.readFileSync("./demo/assets/images/cat.jpg"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
@@ -154,14 +154,14 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "svg",
|
||||
data: fs.readFileSync("./demo/images/linux-svg.svg"),
|
||||
data: fs.readFileSync("./demo/assets/images/linux-svg.svg"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
},
|
||||
fallback: {
|
||||
type: "png",
|
||||
data: fs.readFileSync("./demo/images/linux-png.png"),
|
||||
data: fs.readFileSync("./demo/assets/images/linux-png.png"),
|
||||
},
|
||||
}),
|
||||
],
|
||||
@@ -12,7 +12,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 50,
|
||||
height: 50,
|
||||
@@ -24,7 +24,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -36,7 +36,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 250,
|
||||
height: 250,
|
||||
@@ -48,7 +48,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 400,
|
||||
height: 400,
|
||||
@@ -13,7 +13,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -25,7 +25,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -37,7 +37,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -21,7 +21,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 200,
|
||||
height: 200,
|
||||
@@ -1,68 +1,72 @@
|
||||
/* eslint-disable no-console */
|
||||
// Runs a demo. The demos are in a folder for each topic, such as demo/tables/basic-table.ts
|
||||
//
|
||||
// npm run demo pick a demo from the list, typing to search it
|
||||
// npm run demo tables/basic-table run that demo
|
||||
// npm run demo basic-table run the demo with that name
|
||||
// npm run demo tables pick from the demos in that topic
|
||||
// npm run demo table border run the only demo matching every word, or pick from the ones that do
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import inquirer from "inquirer";
|
||||
import { $ } from "execa";
|
||||
|
||||
export type Answers = {
|
||||
readonly type: "list" | "number";
|
||||
readonly demoNumber?: number;
|
||||
readonly demoFile?: number;
|
||||
};
|
||||
|
||||
const dir = "./demo";
|
||||
const fileNames = fs.readdirSync(dir);
|
||||
|
||||
const keys = fileNames.map((f) => path.parse(f).name);
|
||||
const getFileNumber = (file: string): number => {
|
||||
const [firstPart] = file.split("-");
|
||||
// Every demo, as its topic and name, such as "tables/basic-table"
|
||||
const demos = fs
|
||||
.readdirSync(dir, { withFileTypes: true })
|
||||
.filter((entry) => entry.isDirectory() && entry.name !== "assets")
|
||||
.flatMap((topic) =>
|
||||
fs
|
||||
.readdirSync(path.join(dir, topic.name))
|
||||
.filter((file) => file.endsWith(".ts"))
|
||||
.map((file) => `${topic.name}/${path.parse(file).name}`),
|
||||
)
|
||||
.sort();
|
||||
|
||||
return Number(firstPart);
|
||||
// The demos whose topic or name has every word of the search in it
|
||||
const search = (term: string): readonly string[] => {
|
||||
const words = term.toLowerCase().split(/\s+/).filter(Boolean);
|
||||
|
||||
return demos.filter((demo) => words.every((word) => demo.includes(word)));
|
||||
};
|
||||
|
||||
const demoFiles = keys.filter((file) => !isNaN(getFileNumber(file))).sort((a, b) => getFileNumber(a) - getFileNumber(b));
|
||||
// A path to a demo works too, such as demo/tables/basic-table.ts
|
||||
const term = process.argv
|
||||
.slice(2)
|
||||
.join(" ")
|
||||
.replace(/^(\.\/)?demo\//, "")
|
||||
.replace(/\.ts$/, "");
|
||||
const topics = new Set(demos.map((demo) => path.dirname(demo)));
|
||||
// A demo's name runs it, but a topic's name lists its demos, even when one of them has the topic's name.
|
||||
// Searching for "text/" rather than "text" leaves out the demos of other topics, such as text-boxes
|
||||
const query = topics.has(term) ? `${term}/` : term;
|
||||
const found = demos.includes(term) ? [term] : topics.has(term) ? [] : demos.filter((demo) => demo.endsWith(`/${term}`));
|
||||
const matches = found.length === 1 ? found : search(query);
|
||||
|
||||
const firstArg = process.argv[2];
|
||||
const firstArgNumber = Number.parseInt(firstArg, 10);
|
||||
let demoNumber: number;
|
||||
if (firstArg && !isNaN(firstArgNumber)) {
|
||||
demoNumber = firstArgNumber;
|
||||
let demo: string;
|
||||
if (matches.length === 0) {
|
||||
console.error(`No demo matches "${term}". Run npm run demo to pick one from the list`);
|
||||
process.exit(1);
|
||||
} else if (term && matches.length === 1) {
|
||||
demo = matches[0];
|
||||
} else {
|
||||
const answers = await inquirer.prompt<Answers>([
|
||||
const answers = await inquirer.prompt<{ readonly demo: string }>([
|
||||
{
|
||||
type: "select",
|
||||
name: "type",
|
||||
message: "Select demo from a list or via number",
|
||||
choices: ["list", "number"],
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
name: "demoFile",
|
||||
message: "What demo do you wish to run?",
|
||||
choices: demoFiles,
|
||||
filter: (input: string) => parseInt(input.split("-")[0], 10),
|
||||
when: (a) => a.type === "list",
|
||||
},
|
||||
{
|
||||
type: "number",
|
||||
name: "demoNumber",
|
||||
message: "What demo do you wish to run? (Enter a number)",
|
||||
default: 1,
|
||||
when: (a) => a.type === "number",
|
||||
type: "search",
|
||||
name: "demo",
|
||||
message: "Which demo do you want to run? Type to search",
|
||||
source: (input: string | undefined) => search(input ?? ""),
|
||||
initialValue: query,
|
||||
pageSize: 20,
|
||||
},
|
||||
]);
|
||||
demoNumber = answers.demoNumber ?? answers.demoFile ?? 1;
|
||||
demo = answers.demo;
|
||||
}
|
||||
|
||||
const files = fs.readdirSync(dir).filter((fn) => fn.startsWith(demoNumber.toString()));
|
||||
|
||||
if (files.length === 0) {
|
||||
console.error(`demo number ${demoNumber} does not exist`);
|
||||
} else {
|
||||
const filePath = path.join(dir, files[0]);
|
||||
|
||||
console.log(`Running demo ${demoNumber}: ${files[0]}`);
|
||||
const { stdout } = await $`tsx ${filePath}`;
|
||||
console.log(stdout);
|
||||
console.log("Successfully created document!");
|
||||
}
|
||||
const filePath = path.join(dir, `${demo}.ts`);
|
||||
console.log(`Running demo ${demo}`);
|
||||
const { stdout } = await $`tsx ${filePath}`;
|
||||
console.log(stdout);
|
||||
console.log("Successfully created document!");
|
||||
|
||||
@@ -99,7 +99,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "jpg",
|
||||
data: fs.readFileSync("./demo/images/image1.jpeg"),
|
||||
data: fs.readFileSync("./demo/assets/images/image1.jpeg"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -11,7 +11,7 @@ const label = (text: string, color = "FFFFFF"): Paragraph =>
|
||||
|
||||
const arrow = { color: "404040", width: 1.25, endArrow: "triangle" } as const;
|
||||
|
||||
const logo = { type: "png", data: fs.readFileSync("./demo/images/linux-png.png") } as const;
|
||||
const logo = { type: "png", data: fs.readFileSync("./demo/assets/images/linux-png.png") } as const;
|
||||
|
||||
// A card: a picture and a caption, grouped so they move together. Its children are positioned relative to each other
|
||||
const card = (id: string, caption: string, left: number): IShapeCanvasChildOptions => ({
|
||||
@@ -12,7 +12,7 @@ const space = (): TextRun => new TextRun(" ");
|
||||
const centred = (text: string, color = "000000"): Paragraph =>
|
||||
new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text, color, bold: true })] });
|
||||
|
||||
const photo = { type: "jpg", data: fs.readFileSync("./demo/images/cat.jpg") } as const;
|
||||
const photo = { type: "jpg", data: fs.readFileSync("./demo/assets/images/cat.jpg") } as const;
|
||||
|
||||
const doc = new Document({
|
||||
sections: [
|
||||
@@ -223,7 +223,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -273,7 +273,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||
@@ -289,7 +289,7 @@ const doc = new Document({
|
||||
children: [
|
||||
new ImageRun({
|
||||
type: "gif",
|
||||
data: fs.readFileSync("./demo/images/pizza.gif"),
|
||||
data: fs.readFileSync("./demo/assets/images/pizza.gif"),
|
||||
transformation: {
|
||||
width: 100,
|
||||
height: 100,
|
||||