Deploying to gh-pages from @ dolanmiu/docx@7f26badbc9 🚀

This commit is contained in:
dolanmiu
2025-04-16 07:56:22 +00:00
parent 0efc76f7e1
commit edd4d8c548
388 changed files with 733 additions and 724 deletions

View File

@ -16,12 +16,10 @@ const chapter1 = new Paragraph({
children: [
new Bookmark({
id: "anchorForChapter1",
children: [
new TextRun("Chapter 1"),
],
children: [new TextRun("Chapter 1")],
}),
],
})
});
```
Then you can create an hyperlink pointing to that bookmark with an `InternalHyperLink`:
@ -35,20 +33,32 @@ const link = new InternalHyperlink({
}),
],
anchor: "anchorForChapter1",
})
});
```
### Page reference
You can also get the page number of the bookmark by creating a page reference to it:
```ts
const paragraph = new Paragraph({
children: [
new TextRun("Chapter 1 can be seen on page "),
new PageReference("anchorForChapter1"),
],
children: [new TextRun("Chapter 1 can be seen on page "), new PageReference("anchorForChapter1")],
});
```
### Numbered item reference
You can also create cross references for numbered items with `NumberedItemReference`.
```ts
const paragraph = new Paragraph({
children: [new TextRun("See Paragraph "), new NumberedItemReference("anchorForParagraph1", "1.1")],
});
```
> [!NOTE]
> The `NumberedItemReference` currently needs a cached value (in this case `1.1`)
## External
To create an external hyperlink you just need to specify the url and the text of the link, then add it to a paragraph:
@ -69,7 +79,6 @@ const paragraph = new Paragraph({
});
```
## Styling hyperlinks
It is possible to set the style of the text of both internal and external hyperlinks. This can be done applying run formatting on any of the `TextRun` children of the hyperlink. Use the `style: "Hyperlink"` property to show the default link styles, which can be combined with any other style.