Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Added support for preview of Facebook video #6105 #94

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/mediaembedediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,26 @@ export default class MediaEmbedEditing extends Plugin {
name: 'flickr',
url: /^flickr\.com/
},
{
name: 'facebook-video',
url: [
/(https:\/\/www\.facebook\.com\/([\S]*)\/videos\/([0-9]*))/,
/(https:\/\/www\.facebook\.com\/watch\/\?v=(([0-9]*)))/
],
html: match => {
const id = match[ 3 ];

return (
'<div style="position: relative; padding-bottom: 100%; height: 0;">' +
'<iframe src="https://www.facebook.com/plugins/video.php?show_text=false&href=' +
`https://www.facebook.com/watch/?v=${ id }" ` +
'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
'frameborder="0" allow="encrypted-media">' +
'</iframe>' +
'</div>'
);
}
},
{
name: 'facebook',
url: /^facebook\.com/
Expand Down
14 changes: 14 additions & 0 deletions tests/mediaembedediting.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,20 @@ describe( 'MediaEmbedEditing', () => {
'</iframe>' +
'</div>' );
} );

it( 'upcasts the URL (facebook-video)', () => {
testMediaUpcast( [
'https://www.facebook.com/xyz/videos/1234',
'https://www.facebook.com/watch/?v=1234'
],
'<div style="position: relative; padding-bottom: 100%; height: 0;">' +
'<iframe src="https://www.facebook.com/plugins/video.php?show_text=false&href=' +
'https://www.facebook.com/watch/?v=1234" ' +
'style="position: absolute; width: 100%; height: 100%; top: 0; left: 0;" ' +
'frameborder="0" allow="encrypted-media">' +
'</iframe>' +
'</div>' );
} );
} );

describe( 'preview-less', () => {
Expand Down