Can we create "Hyperlink" at the paragraph level?
See original GitHub issueI know there are two ways of creating hyperlinks, either with hyperlinkRef(id)
or doc.createHyperlink(link, text)
but there are a couple things with that.
For the first, I have to have pre-defined all my hyperlinks, which I don’t necessarily want to do. For the second, I have to have pre-defined “doc”, which I’ve found storing a big table of text in another sheet breaks if it initialises before I’ve defined doc.
I’d like to have something like:
paragraph = new Paragraph({
children: [
new docx.TextRun("you need to provide a "),
new docx.HyperlinkRef("linkhere", text.content),
new docs.TextRun(" if you wish to be considered for this job.")
]
})
In this example, the link stays the same, but the text is variable, and code-wise, hyperlinks would “flow” more nicely with TextRuns.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Creating hyperlinks - Learn web development | MDN
A basic link is created by wrapping the text or other content, see Block level links, inside an <a> element and using the...
Read more >How to create absolute hyperlinks and relative ...
How to use absolute hyperlinks instead of relative hyperlinks · Open the document in which you want to use an absolute hyperlink. ·...
Read more >How to Add a Hyperlink in a Microsoft Word Document
In this post, we look at adding a hyperlink to a Microsoft Word document, as well as how to edit and remove hyperlinks....
Read more >Identifying the purpose of a link using link text combined ...
Check that text of the link combined with the text of its enclosing paragraph describes the purpose of the link. Expected Results. Steps...
Read more >HTML Anchors: Here's How To Create Links For Fast ...
In this short tutorial we'll cover the attributes you can use to add a destination anchor to your hyperlinks, tell the browser what...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Great question @supervanya, and the answer to that is yes
Now hyperlinks are entirely fully customizable, you can change it to whatever style you want.
Hyperlinks now take a child component, which means hyperlinks can even be images etc!
Will be done in:
#784
No need to define a hyperlink at the root level, and then reference it at the paragraph. That is ugly. The new solution is much more intuitive and only requires adding one single component to the Paragraph.
@dolanmiu thank you so much for this fix!
What is the timeline for a new release? Hyperlinks, alongside with compatibility mode improvements, are two huge features my team would really like to take advantage as soon as possible.
Also, if you want you can add our logo and website to the
used by
section on the repo readme! We have been using the library quite a bit and it is such a lifesaver! Let me know if you’d like me to make the PR.