platejs

Media File Element

Component

About

A file attachment element for the Plate editor that renders a downloadable file link with an editable caption.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Media File Element to your project and fits it to your theme.

Code

How Media File Element is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import * as React from "react";

import { FileElement } from "@/components/ui/media-file-node";

import { FilePlugin } from "@platejs/media/react";
import { Plate, PlateContent, usePlateEditor } from "platejs/react";

export default function Demo() {
  const editor = usePlateEditor({
    plugins: [FilePlugin.withComponent(FileElement)],
    value: [
      {
        children: [{ text: "" }],
        name: "sample.pdf",
        type: "file",
        url: "https://s26.q4cdn.com/900411403/files/doc_downloads/test.pdf",
      },
    ],
  });

  return (
    <div className="p-8">
      <Plate editor={editor}>
        <PlateContent
          className="rounded-md border p-4 focus-visible:outline-none"
          readOnly
        />
      </Plate>
    </div>
  );
}

Dependencies

More by platejs

View all
  • Math Base Kit

    Math Base Kit

    15
  • Highlight Leaf

    Highlight Leaf

    6
  • Cursor Overlay

    Cursor Overlay

    5
  • Editor

    Editor

    4
  • Link Element

    Link Element

    3
  • Resize Handle

    Resize Handle

    3
  • Inline Combobox

    Inline Combobox

    1
  • List

    List

    1