onCitationClick in Libra.init() to handle navigation in-place. It fires for every citation that resolves to a research source. The SDK still opens the citation in a new tab by default; call event.preventDefault() to claim the ones you want to handle yourself. You don’t need to open the rest; just leave them alone:
The event
data: the clicked citation.source: the canonicalResearchSourceIdthat owns the citation, e.g.'wko_de'. Covers both research-source results and host-supplied external documents (see Document suggestions).url: the navigation target. May include adocumentAnchorquery parameter for scroll-to-section.content: the extracted text of the cited passage. Present when the user clicked the citation badge or “To source” in the tooltip (a specific passage); absent when they clicked “View source” in the citation list (the full document).
preventDefault(): call it to stop the SDK from openingdata.urlin a new tab, when you’re handling navigation yourself.
The default open is restricted to
http(s) URLs. The citation URL originates from model output, so the SDK blocks any other scheme — and a malformed URL — with a console warning before it could execute in your origin.What the widget cannot open
The embedded widget ships no document viewer. Citations into user-uploaded documents therefore expose no “To source” or “View source” control at all, and generated Word documents offer download only, with no in-widget preview. Citations into research sources and host-supplied external documents — the ones that reachonCitationClick — are unaffected. This is a deliberate difference from the Libra web app, so a behaviour you see there may simply not exist inside the iframe.
Patterns
Own only your sources. Compareevent.data.source against the sources your product hosts (see Products and sources) and leave everything else to the default. Users still reach external sources; you avoid rendering documents you don’t have.
Scroll to the passage. When content is present, search for it in your document view after navigating to url; it is the exact cited text. When it is absent, the user asked for the whole document.
Round-trip back to the chat. If the user leaves your document view and wants the conversation back, the chat handoff guide covers reopening a chat by ID.
