-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(plugin-video): add docs for carta-video plugin
Add docs for carta-video plugin
- Loading branch information
Showing
3 changed files
with
140 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
--- | ||
section: Plugins | ||
title: Video | ||
--- | ||
|
||
<script> | ||
import Code from '$lib/components/code/Code.svelte'; | ||
import { Carta, CartaViewer } from 'carta-md'; | ||
import { video } from '@cartamd/plugin-video'; | ||
import '@cartamd/plugin-video/default.css'; | ||
|
||
const carta = new Carta({ | ||
extensions: [ | ||
video() | ||
] | ||
}); | ||
|
||
const youtube = `@[youtube](dQw4w9WgXcQ)`; | ||
const vimeo = `@[vimeo](https://vimeo.com/347119375)`; | ||
</script> | ||
|
||
This plugin adds ability to render online video from Youtube or Vimeo. | ||
|
||
## Installation | ||
|
||
<Code> | ||
|
||
``` | ||
npm i @cartamd/plugin-video | ||
``` | ||
|
||
</Code> | ||
|
||
## Setup | ||
|
||
### Styles | ||
|
||
Import the default theme, or create you own: | ||
|
||
<Code> | ||
|
||
```ts | ||
import '@cartamd/plugin-video/default.css'; | ||
``` | ||
|
||
Note that the `align` function needs the default css to work properly. | ||
|
||
</Code> | ||
|
||
### Extension | ||
|
||
<Code> | ||
|
||
```svelte | ||
<script> | ||
import { Carta, CartaEditor } from 'carta-md'; | ||
import { video } from '@cartamd/plugin-video'; | ||
const carta = new Carta({ | ||
extensions: [video()] | ||
}); | ||
</script> | ||
<CartaEditor {carta} /> | ||
``` | ||
|
||
</Code> | ||
|
||
## 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: | ||
|
||
<Code> | ||
|
||
```markdown | ||
@[youtube](dQw4w9WgXcQ) | ||
``` | ||
|
||
</Code> | ||
|
||
<CartaViewer {carta} value={youtube} /> | ||
|
||
For Vimeo: | ||
|
||
<Code> | ||
|
||
```markdown | ||
@[vimeo](https://vimeo.com/347119375) | ||
``` | ||
|
||
</Code> | ||
|
||
<CartaViewer {carta} value={vimeo} /> | ||
|
||
## Options | ||
|
||
Here are the options you can pass to `video()`: | ||
|
||
```ts | ||
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; | ||
} | ||
``` |