question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can we create "Hyperlink" at the paragraph level?

See original GitHub issue

I 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:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
dolanmiucommented, Feb 27, 2021

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.

1reaction
supervanyacommented, Mar 2, 2021

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found