Socket
Socket
Sign inDemoInstall

carta-plugin-video

Package Overview
Dependencies
24
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    carta-plugin-video

This plugin adds ability to render online video from Youtube or Vimeo.


Version published
Weekly downloads
192
decreased by-18.64%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

plugin-video

carta-plugin-video

This plugin adds ability to render online video from Youtube or Vimeo.

Inspired by markdown-it-video

Installation

npm i carta-plugin-video

Setup

Styles

Import the default theme, or create you own:

import 'carta-plugin-video/default.css';

Note that the align function needs the default css to work properly.

For custom styles, this is an example of the generated HTML:

<div class="video-container center">
	<iframe
		width="640"
		height="390"
		src="<the URL>"
		frameborder="0"
		allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
		allowfullscreen>
	</iframe>
</div>

Extension

<script>
	import { Carta, CartaEditor } from 'carta-md';
	import { video } from 'carta-plugin-video';
	import 'carta-plugin-video/default.css';

	const carta = new Carta({
		extensions: [
			video({
				// Optional options
			}),
		],
	});
</script>

<CartaEditor {carta} />

Usage

You can use either video ID (e.g: dQw4w9WgXcQ) or video URL (e.g: https://www.youtube.com/watch?v=dQw4w9WgXcQ&ab_channel=RickAstley)

For Youtube:

@[youtube](dQw4w9WgXcQ)
@[youtube](https://www.youtube.com/watch?v=dQw4w9WgXcQ)

For Vimeo:

@[vimeo](347119375)
@[vimeo](https://vimeo.com/347119375)

Options

Here are the options you can pass to video():

export interface VideoExtensionOptions {
	/**
	 * Width of the video (in pixels or percentage string), defaults to 640.
	 */
	width?: number | string;
	/**
	 * Height of the video (in pixel or percentage string), defaults to 360.
	 */
	height?: number | string;
	/**
	 * Horizontal alignment of the video, defaults to 'center'.
	 */
	align?: 'left' | 'center' | 'right';
	/**
	 * Allow fullscreen, defaults to true.
	 */
	allowFullscreen?: boolean;
	/**
	 * Use youtube-nocookie.com domain, defaults to false.
	 */
	noCookie?: boolean;
}

Keywords

FAQs

Last updated on 21 Jan 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc