Docs
Media

Media

Embed medias like videos or tweets into your document.

📸 Image

Add images by either uploading them or providing the image URL:

Customize image captions and resize images.

📺 Embed

Embed various types of content, such as videos and tweets:




Features

  • Allows insertion of embeddable media: images, videos, and tweets.
  • Supports multiple media providers: video, youtube, vimeo, dailymotion, youku, coub, twitter.
  • Editable captions.
  • Resizable.
  • Use Plate Cloud for easy cloud uploads and server-side image resizing.

Installation

npm install @udecode/plate-media

Plugins

import {
  ELEMENT_IMAGE,
  ELEMENT_MEDIA_EMBED,
  createImagePlugin,
  createMediaEmbedPlugin,
} from '@udecode/plate-media';
import { createSelectOnBackspacePlugin } from '@udecode/plate-select';
 
const plugins = [
  // ...otherPlugins,
  createImagePlugin(),
  createMediaEmbedPlugin(),
  createSelectOnBackspacePlugin({
    options: {
      query: {
        allow: [ELEMENT_IMAGE, ELEMENT_MEDIA_EMBED],
      },
    },
  }),
];

API Media

MediaPlugin

Common attributes shared by image and media embed plugins.

Attributes

Collapse all

    A function to check whether a text string is a URL.

    A function to transform the URL.

    List of rules. The first rule that matches the URL will be used, i.e. its component will be used to render the media.

    Disables captions for media if set to true.

EmbedUrlData

A type defining the data returned from parsing an embed URL.

Attributes

Collapse all

    The URL of the embedded content.

    The provider of the embedded content.

    The unique identifier for the embedded content.

    The component to be rendered for the embedded content.

insertMedia

parseMediaUrl

submitFloatingMedia

API Image

createImagePlugin

Attributes

Collapse all

    Options extends MediaPlugin.

    An optional method that will upload the image to a server. The method receives the base64 dataUrl of the uploaded image, and should return the URL of the uploaded image.

    Disables file upload on data insertion if set to true.

    Disables URL embed on data insertion if set to true.

insertImage

isImageUrl

withImageUpload

withImageEmbed

API Media Embed

createMediaEmbedPlugin

Options extends MediaPlugin.

insertMediaEmbed

parseIframeUrl

parseTwitterUrl

parseVideoUrl

API Components

floatingMediaStore

mediaStore

resizableStore

Resizable

useFloatingMedia

useFloatingMediaEditButton

useFloatingMediaUrlInput

useImage

useMediaEmbed

useMediaEmbedTweet

useMediaEmbedVideo

useMediaState

useMediaToolbarButton

Tweet