Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix issues with video resizing and alignment #1246

Merged
merged 2 commits into from
Apr 24, 2019
Merged
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
28 changes: 16 additions & 12 deletions src/adapter/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,29 +439,32 @@ extend(
{
id: 'facebook',
tpl: `<iframe allowFullScreen="true" allowTransparency="true"
frameborder="0" height="${EMBED_VIDEO_HEIGHT}"
src="https://www.facebook.com/plugins/video.php?href={embedId}'
&show_text=0&width=${EMBED_VIDEO_WIDTH}&height=${EMBED_VIDEO_HEIGHT}" scrolling="no"
style="border:none;overflow:hidden" width="${EMBED_VIDEO_WIDTH}}"></iframe>`,
frameborder="0" height="${EMBED_VIDEO_HEIGHT}"
src="https://www.facebook.com/plugins/video.php?href={embedId}'
&show_text=0&width=${EMBED_VIDEO_WIDTH}&height=${EMBED_VIDEO_HEIGHT}" scrolling="no"
style="border:none;overflow:hidden" width="${EMBED_VIDEO_WIDTH}}"></iframe>`,
type: 'video',
urlSchemes: [
'(https?:\\/\\/(?:www\\.)?facebook.com\\/\\S*\\/videos\\/\\S*)',
],
},
{
id: 'twitch',
tpl: `<iframe allowfullscreen="true" frameborder="0"
height="${EMBED_VIDEO_HEIGHT}"
src="https://player.twitch.tv/?autoplay=false&video={embedId}"
scrolling="no" width="${EMBED_VIDEO_WIDTH}"></iframe>`,
height="${EMBED_VIDEO_HEIGHT}"
src="https://player.twitch.tv/?autoplay=false&video={embedId}"
scrolling="no" width="${EMBED_VIDEO_WIDTH}"></iframe>`,
type: 'video',
urlSchemes: [
'https?:\\/\\/(?:www\\.)?twitch.tv\\/videos\\/(\\S*)$',
],
},
{
id: 'vimeo',
tpl: `<iframe allowfullscreen frameborder="0" height="${EMBED_VIDEO_HEIGHT}"
mozallowfullscreen src="https://player.vimeo.com/video/{embedId}"
webkitallowfullscreen width="${EMBED_VIDEO_WIDTH}"></iframe>`,
mozallowfullscreen src="https://player.vimeo.com/video/{embedId}"
webkitallowfullscreen width="${EMBED_VIDEO_WIDTH}"></iframe>`,
type: 'video',
urlSchemes: [
'https?:\\/\\/(?:www\\.)?vimeo\\.com\\/album\\/.*\\/video\\/(\\S*)',
'https?:\\/\\/(?:www\\.)?vimeo\\.com\\/channels\\/.*\\/(\\S*)',
Expand All @@ -472,9 +475,10 @@ extend(
{
id: 'youtube',
tpl: `<iframe allow="autoplay; encrypted-media" allowfullscreen
height="${EMBED_VIDEO_HEIGHT}" frameborder="0"
src="https://www.youtube.com/embed/{embedId}?rel=0"
width="${EMBED_VIDEO_WIDTH}"></iframe>`,
height="${EMBED_VIDEO_HEIGHT}" frameborder="0"
src="https://www.youtube.com/embed/{embedId}?rel=0"
width="${EMBED_VIDEO_WIDTH}"></iframe>`,
type: 'video',
urlSchemes: [
'https?:\\/\\/(?:www\\.)?youtube.com\\/watch\\?v=(\\S*)$',
],
Expand Down
9 changes: 8 additions & 1 deletion src/components/buttons/button-embed-video-edit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ class ButtonEmbedVideoEdit extends React.Component {
* @method componentWillReceiveProps
*/
componentWillReceiveProps() {
this.replaceState(this.getInitialState());
const newState = this.getInitialState();

this.setState({
all: undefined,
keys: undefined,
new: newState,
old: undefined,
});
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/plugins/autolink.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ if (!CKEDITOR.plugins.get('ae_autolink')) {
_getLastWord(editor) {
const range = editor.getSelection().getRanges()[0];

if (!range) {
return;
}

const offset = range.startOffset;

let previousText = '';
Expand Down
17 changes: 12 additions & 5 deletions src/plugins/embedurl.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ if (!CKEDITOR.plugins.get('embedurl')) {

data.url = iframe.attributes.src;

delete element.attributes.style;

const embedContent = generateEmbedContent(
data.url,
element.getOuterHtml()
Expand All @@ -321,9 +323,8 @@ if (!CKEDITOR.plugins.get('embedurl')) {

upcastWidget = widgetFragment.children[0];

upcastWidget.attributes['data-styles'] = JSON.stringify(
element.styles
);
upcastWidget.attributes['data-styles'] =
element.attributes['data-styles'];
upcastWidget.removeClass('embed-responsive');
upcastWidget.removeClass('embed-responsive-16by9');

Expand Down Expand Up @@ -437,10 +438,16 @@ if (!CKEDITOR.plugins.get('embedurl')) {

embedContent.attributes.class =
'embed-responsive embed-responsive-16by9';
embedContent.attributes.style = CKEDITOR.tools.writeCssText(
widget.parent.styles

embedContent.attributes['data-styles'] = JSON.stringify(
CKEDITOR.tools.parseCssText(
widget.parent.attributes.style
)
);

embedContent.attributes.style =
widget.parent.attributes.style;

return embedContent;
},

Expand Down