Smart hyperlinks with automatic validation and security. Non-inclusive mark that validates protocols and trims whitespace intelligently.

OOXML Structure

<!-- External link -->
<w:hyperlink r:id="rId1">
  <w:r>
    <w:rPr><w:u/></w:rPr>
    <w:t>Link text</w:t>
  </w:r>
</w:hyperlink>

<!-- Internal anchor -->
<w:hyperlink w:anchor="bookmark1">
  <w:r>
    <w:t>Jump to section</w:t>
  </w:r>
</w:hyperlink>

Why you’d use this

  • External references - Link to sources
  • Email contacts - Direct mailto: links
  • Phone numbers - Click to call
  • Internal navigation - Document anchors
  • Cross-references - Link between sections

Commands

Create or update a link
Automatically adds underline formatting and trims whitespace from link boundaries
// Link selected text
setLink({ href: 'https://example.com' })

// Link with custom text
setLink({
  href: 'https://example.com',
  text: 'Visit Example'
})
Parameters:
options
Object
required
Link configuration
options.href
string
required
URL for the link
options.text
string
Display text (uses selection if omitted)
Returns: function Command - Creates link with underline Remove link and associated formatting
Also removes underline and text color
unsetLink()
Returns: function Command - Removes link, underline, and color Toggle link on selection
// Add link
toggleLink({ href: 'https://example.com' })

// Remove link
toggleLink()
Parameters:
options
Object
Link configuration
options.href
string
required
URL for the link
options.text
string
Display text
Returns: function Command - Creates link if href provided, removes otherwise

Types

LinkAttributes

Link attributes