Typix LogoTypix
Overlays

FloatingLinkUI

Inline link editor that hovers over a link node or the current selection, with edit / delete / open actions.

FloatingLinkUI reads link state from the extension-floating-link extension and renders an anchored popover with view + edit modes. Pass a render function as children to fully replace the default UI while keeping all the state plumbing.

Install

npx typix ui add floating-link

The CLI also installs @typix-editor/extension-floating-link if it isn't already present.

Import

import {
  FloatingLinkUI,
  DefaultFloatingLinkUI,
} from "@/components/typix/main/floating-link";

Props

PropTypeDefaultDescription
anchorElemHTMLElementdocument.bodyElement used as the positioning anchor.
children(props: FloatingLinkRenderProps) => ReactNodeCustom render function. Replaces the default UI entirely.
verticalOffsetnumber40Vertical offset in px for positioning below the link.

FloatingLinkRenderProps

The render function receives editing state and a set of actions:

FieldTypeDescription
isEditingbooleanWhether the input is visible.
linkUrlstringCurrent link URL from the node.
editedUrlstringURL being edited in the input.
isValidUrlbooleanWhether the edited URL is valid.
setEditedUrl(url: string) => voidUpdate the input value.
submitLink() => voidCommit the edited URL.
cancelEdit() => voidDiscard edits and return to view mode.
startEdit() => voidEnter edit mode.
deleteLink() => voidRemove the link entirely.
inputRefRefObject<HTMLInputElement>Ref for the URL input (auto-focused when editing).

Usage

Default UI — just drop it inside the editor provider:

import { FloatingLinkUI } from "@/components/typix/main/floating-link";

<TypixEditorContext.Provider value={{ editor }}>
  <EditorContent editor={editor} />
  <FloatingLinkUI />
</TypixEditorContext.Provider>

Custom render — wire your own UI to the render props:

<FloatingLinkUI>
  {({ isEditing, linkUrl, startEdit, deleteLink }) =>
    isEditing ? <MyLinkEditor /> : (
      <div>
        <a href={linkUrl} target="_blank">{linkUrl}</a>
        <button onClick={startEdit}>Edit</button>
        <button onClick={deleteLink}>Remove</button>
      </div>
    )
  }
</FloatingLinkUI>

On this page