Components
Link Toolbar Button
Link Toolbar Button
Insert or manage hyperlinks using a toolbar button.
Installation
npx @udecode/plate-ui@latest add link-toolbar-button
Examples
🔗 Link
Add hyperlinks within your text to reference external sources or provide additional information using the Link plugin.
Effortlessly create hyperlinks using the toolbar or by pasting a URL while selecting the desired text.
import React from 'react';
import {
MARK_BOLD,
MARK_CODE,
MARK_ITALIC,
MARK_STRIKETHROUGH,
MARK_UNDERLINE,
} from '@udecode/plate-basic-marks';
import { useEditorReadOnly } from '@udecode/plate-common';
import { Icons } from '@/components/icons';
import { InsertDropdownMenu } from './insert-dropdown-menu';
import { MarkToolbarButton } from './mark-toolbar-button';
import { ModeDropdownMenu } from './mode-dropdown-menu';
import { ToolbarGroup } from './toolbar';
import { TurnIntoDropdownMenu } from './turn-into-dropdown-menu';
export function FixedToolbarButtons() {
const readOnly = useEditorReadOnly();
return (
<div className="w-full overflow-hidden">
<div
className="flex flex-wrap"
style={{
transform: 'translateX(calc(-1px))',
}}
>
{!readOnly && (
<>
<ToolbarGroup noSeparator>
<InsertDropdownMenu />
<TurnIntoDropdownMenu />
</ToolbarGroup>
<ToolbarGroup>
<MarkToolbarButton tooltip="Bold (⌘+B)" nodeType={MARK_BOLD}>
<Icons.bold />
</MarkToolbarButton>
<MarkToolbarButton tooltip="Italic (⌘+I)" nodeType={MARK_ITALIC}>
<Icons.italic />
</MarkToolbarButton>
<MarkToolbarButton
tooltip="Underline (⌘+U)"
nodeType={MARK_UNDERLINE}
>
<Icons.underline />
</MarkToolbarButton>
<MarkToolbarButton
tooltip="Strikethrough (⌘+⇧+M)"
nodeType={MARK_STRIKETHROUGH}
>
<Icons.strikethrough />
</MarkToolbarButton>
<MarkToolbarButton tooltip="Code (⌘+E)" nodeType={MARK_CODE}>
<Icons.code />
</MarkToolbarButton>
</ToolbarGroup>
</>
)}
<div className="grow" />
<ToolbarGroup noSeparator>
<ModeDropdownMenu />
</ToolbarGroup>
</div>
</div>
);
}
import React from 'react';
import {
MARK_BOLD,
MARK_CODE,
MARK_ITALIC,
MARK_STRIKETHROUGH,
MARK_UNDERLINE,
} from '@udecode/plate-basic-marks';
import { useEditorReadOnly } from '@udecode/plate-common';
import { Icons } from '@/components/icons';
import { MarkToolbarButton } from './mark-toolbar-button';
import { MoreDropdownMenu } from './more-dropdown-menu';
import { TurnIntoDropdownMenu } from './turn-into-dropdown-menu';
export function FloatingToolbarButtons() {
const readOnly = useEditorReadOnly();
return (
<>
{!readOnly && (
<>
<TurnIntoDropdownMenu />
<MarkToolbarButton nodeType={MARK_BOLD} tooltip="Bold (⌘+B)">
<Icons.bold />
</MarkToolbarButton>
<MarkToolbarButton nodeType={MARK_ITALIC} tooltip="Italic (⌘+I)">
<Icons.italic />
</MarkToolbarButton>
<MarkToolbarButton
nodeType={MARK_UNDERLINE}
tooltip="Underline (⌘+U)"
>
<Icons.underline />
</MarkToolbarButton>
<MarkToolbarButton
nodeType={MARK_STRIKETHROUGH}
tooltip="Strikethrough (⌘+⇧+M)"
>
<Icons.strikethrough />
</MarkToolbarButton>
<MarkToolbarButton nodeType={MARK_CODE} tooltip="Code (⌘+E)">
<Icons.code />
</MarkToolbarButton>
</>
)}
<MoreDropdownMenu />
</>
);
}