Skip to content

VideoSelectionModule

Auto-imported: YES (if VideoField is present in quill_options)

The VideoSelectionModule provides an interactive way to manage embedded videos within the editor. It adds a selection overlay with resize handles and a dedicated toolbar for quick actions.

This module is automatically enabled when the VideoField is used. If you don't use the VideoField but still want the module, you must add it manually to the modules option.

Features

  • Resize Handles: Drag corners to resize both width and height of the video.
  • Quick Alignment: Buttons for left (wrapped), left (block), center, and right alignments.
  • Preset Sizes: Quickly set width to 25%, 50%, 75%, or 100%.
  • Custom Size: Input exact width in pixels or percentage.
  • Play Button: Opens the video URL in a new tab.
  • Metadata Editing:
    • Edit URL: Change the embedded video source URL.
    • Edit Title: Set or update the title attribute for accessibility.
    • Edit Caption: Add or edit the figure caption.
    • Toggle Loading: Switch between lazy and eager loading.
  • Paragraph Insertion: Buttons to quickly insert an empty paragraph before or after the video.
  • Delete: Quickly remove the video and its figure from the editor.

Options

OptionTypeDefaultDescription
borderColorstring'#007bff'Color of the selection border and handles.
borderWidthstring'4px'Width of the selection border.
playTitlestring'Play video'Tooltip for the play button.
editUrlTitlestring'Edit video URL'Tooltip for the URL editing button.
editTitleTitlestring'Edit title'Tooltip for the title editing button.
editCaptionTitlestring'Edit caption'Tooltip for the caption editing button.
buttonBeforeLabelstring'¶+'Label for the "insert paragraph before" button.
buttonAfterLabelstring'+¶'Label for the "insert paragraph after" button.
buttonBeforeTitlestring'Insert a paragraph before'Tooltip for the "before" button.
buttonAfterTitlestring'Insert a paragraph after'Tooltip for the "after" button.
deleteTitlestring'Delete video'Tooltip for the delete button.
videoProvidersarray[]Custom video providers. See Custom providers below.
alignLabelsarraySee belowCustom labels for alignment tooltips.
sectionLabelsarraySee belowSmall labels displayed above toolbar sections. To disable, pass an empty array [].

alignLabels default values

php
'alignLabels' => [
    'left' => 'Left (wrapped)',
    'leftBlock' => 'Left (no wrap)',
    'center' => 'Align center',
    'right' => 'Right (wrapped)',
]

sectionLabels default values

php
'sectionLabels' => [
    'size' => 'Size',
    'align' => 'Align',
    'video' => 'Video',
    'insert' => 'Insert',
]

Usage example

Although it's usually auto-imported, you can manually configure it with custom options:

php
use Ehyiah\QuillJsBundle\DTO\Modules\VideoSelectionModule;

// ...

'modules' => [
    new VideoSelectionModule([
        'borderColor' => '#ff0000',
        'buttonBeforeLabel' => 'Insert Before',
        'alignLabels' => [
            'center' => 'Centrer la vidéo',
        ],
    ]),
],

Supported providers

When a video URL is pasted or inserted, it is automatically transformed into the correct embed format.

ProviderExample URLEmbed URL
YouTubehttps://youtube.com/watch?v=IDhttps://www.youtube.com/embed/ID
Vimeohttps://vimeo.com/123456https://player.vimeo.com/video/123456
Dailymotionhttps://dailymotion.com/video/IDhttps://www.dailymotion.com/embed/video/ID
Twitchhttps://twitch.tv/CHANNELhttps://player.twitch.tv/?channel=CHANNEL&parent=HOST
Facebookhttps://facebook.com/user/videos/123https://www.facebook.com/plugins/video.php?href=URL
Spotifyhttps://open.spotify.com/track/IDhttps://open.spotify.com/embed/track/ID
TikTokhttps://tiktok.com/@user/video/123https://www.tiktok.com/embed/v2/123

Any URL that doesn't match a known provider is inserted unchanged into the <iframe> — it will still work if the target supports embedding.

Custom providers

You can add your own video providers by passing the videoProviders option. Each provider requires:

FieldTypeDescription
namestringA label for the provider (informational only).
matchstringA JavaScript regex pattern to match URLs. Escape backslashes for PHP.
embedstringThe embed URL template. Use {1}, {2}, etc. for captured groups from the regex.

Example: adding TikTok support

php
use Ehyiah\QuillJsBundle\DTO\Modules\VideoSelectionModule;

'modules' => [
    new VideoSelectionModule([
        'videoProviders' => [
            [
                'name' => 'tiktok',
                'match' => 'tiktok\\.com/@[\\w-]+/video/(\\d+)',
                'embed' => 'https://www.tiktok.com/embed/v2/{1}',
            ],
        ],
    ]),
],

The regex match is evaluated as new RegExp(match) in JavaScript. Capture groups (…) are referenced as {1}, {2}, etc. in the embed template.

Try it live