Components
A Plate editor element that renders inline hyperlinks with primary-colored underline styling and hover states.
Loading preview...
"use client";
import { LinkElement } from "@/components/ui/link-node";
import * as React from "react";
import { LinkPlugin } from "@platejs/link/react";
import { Plate, PlateContent, usePlateEditor } from "platejs/react";
const initialValue = [
{
type: "p",
children: [
{ text: "Visit " },
{
type: "a",
url: "https://platejs.org",
children: [{ text: "platejs.org" }],
},
{ text: " to learn more about building rich-text editors." },
],
},
];
export default function LinkDemo() {
const editor = usePlateEditor({
plugins: [
LinkPlugin.configure({
render: { node: LinkElement },
}),
],
value: initialValue,
});
return (
<div className="w-full max-w-xl rounded-lg border p-4">
<Plate editor={editor}>
<PlateContent className="outline-none" />
</Plate>
</div>
);
}