Video
The Video extension allows you to add a video to your editor.
Usage
tsx
import { RichTextProvider } from 'reactjs-tiptap-editor'
// Base Kit
import { Document } from '@tiptap/extension-document'
import { Text } from '@tiptap/extension-text'
import { Paragraph } from '@tiptap/extension-paragraph'
import { Dropcursor, Gapcursor, Placeholder, TrailingNode } from '@tiptap/extensions'
import { HardBreak } from '@tiptap/extension-hard-break'
import { TextStyle } from '@tiptap/extension-text-style';
import { ListItem } from '@tiptap/extension-list';
// Extension
import { Video, RichTextVideo } from 'reactjs-tiptap-editor/video';
// ... other extensions
// Import CSS
import 'reactjs-tiptap-editor/style.css';
const extensions = [
// Base Extensions
Document,
Text,
Dropcursor,
Gapcursor,
HardBreak,
Paragraph,
TrailingNode,
ListItem,
TextStyle,
Placeholder.configure({
placeholder: 'Press \'/\' for commands',
})
...
// Import Extensions Here
Video
];
const RichTextToolbar = () => {
return (
<div className="flex items-center gap-2 flex-wrap border-b border-solid">
<RichTextVideo /> {}
</div>
)
}
const App = () => {
const editor = useEditor({
textDirection: 'auto', // global text direction
extensions,
});
return (
<RichTextProvider
editor={editor}
>
<RichTextToolbar />
<EditorContent
editor={editor}
/>
</RichTextProvider>
);
};Props
ts
interface VideoOptions extends GeneralOptions<VideoOptions> {
/**
* Indicates whether fullscreen play is allowed
*
* @default true
*/
allowFullscreen: boolean
/**
* Indicates whether to display the frameborder
*
* @default false
*/
frameborder: boolean
/**
* Width of the video, can be a number or string
*
* @default VIDEO_SIZE['size-medium']
*/
width: number | string
/** HTML attributes object for passing additional attributes */
HTMLAttributes: {
[key: string]: any
}
/** Function for uploading files */
upload?: (file: File) => Promise<string>
/** The source URL of the video */
resourceVideo: 'upload' | 'link' | 'both'
}Source
Contributors
Changelog
v1.0.0 on 12/7/202551948 - feat: refactor code, dynamic bubble, toolbar, fix errorv0.3.5 on 6/19/202510881 - fixed vimeo video links embedding + youtube shortsa7323 - feat(video): add alignment options for video elementsv0.3.3 on 5/13/20252cc0b - fix(active video button): added videoProviders prop + validation
Hung Hoang