chore: synchronize project dependencies and update vendor directory files
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
/**
|
||||
* @file
|
||||
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
|
||||
* http://www.absyx.fr
|
||||
*/
|
||||
|
||||
(function(undefined) {
|
||||
'use strict';
|
||||
|
||||
var trim = CKEDITOR.tools.trim;
|
||||
|
||||
var unbind = function(video$) {
|
||||
video$.onloadedmetadata = video$.onerror = null;
|
||||
};
|
||||
|
||||
var cache = {}, getMetadata = function(dialog, readyCallback) {
|
||||
var video$ = dialog.video.$;
|
||||
unbind(video$);
|
||||
var url = trim(dialog.getValueOf('info', 'src'));
|
||||
if (!url.length) {
|
||||
return false;
|
||||
}
|
||||
if (cache[url] !== undefined) {
|
||||
return cache[url];
|
||||
}
|
||||
video$.onloadedmetadata = video$.onerror = function() {
|
||||
unbind(video$);
|
||||
var w = video$.videoWidth;
|
||||
var h = video$.videoHeight;
|
||||
cache[url] = w && h ? {width: w, height: h} : false;
|
||||
readyCallback();
|
||||
};
|
||||
video$.src = url;
|
||||
};
|
||||
|
||||
var clearPreview = function(dialog) {
|
||||
var video = dialog.video.setStyle('display', 'none');
|
||||
var video$ = video.$;
|
||||
unbind(video$);
|
||||
video$.src = '';
|
||||
};
|
||||
|
||||
var updatePreview = function(dialog) {
|
||||
var metadata = getMetadata(dialog, function() {
|
||||
updatePreview(dialog);
|
||||
});
|
||||
var video = dialog.video;
|
||||
if (metadata) {
|
||||
dialog.commitContent(video);
|
||||
var ratio = (100 * metadata.height / metadata.width).toFixed(5) + '%';
|
||||
video.setStyle('display', 'block').getParent().getParent().setStyle('padding-top', ratio);
|
||||
}
|
||||
else {
|
||||
video.setStyle('display', 'none');
|
||||
}
|
||||
};
|
||||
|
||||
CKEDITOR.dialog.add('video', function(editor) {
|
||||
return {
|
||||
title: editor.lang.video.title,
|
||||
minWidth: 400,
|
||||
minHeight: 300,
|
||||
contents: [{
|
||||
id: 'info',
|
||||
label: editor.lang.common.generalTab,
|
||||
elements: [{
|
||||
id: 'src',
|
||||
type: 'text',
|
||||
label: editor.lang.common.url,
|
||||
required: true,
|
||||
onChange: function() {
|
||||
updatePreview(this.getDialog());
|
||||
},
|
||||
validate: CKEDITOR.dialog.validate.notEmpty(editor.lang.video.emptySrc),
|
||||
setup: function(element) {
|
||||
this.setValue(element && element.getAttribute('src') || '');
|
||||
},
|
||||
commit: function(element) {
|
||||
element.setAttribute('src', trim(this.getValue()));
|
||||
}
|
||||
}, {
|
||||
id: 'browse',
|
||||
type: 'button',
|
||||
filebrowser: 'info:src',
|
||||
hidden: true,
|
||||
label: editor.lang.common.browseServer
|
||||
}, {
|
||||
id: 'controls',
|
||||
type: 'checkbox',
|
||||
label: editor.lang.video.controls,
|
||||
'default': true,
|
||||
onChange: function() {
|
||||
var dialog = this.getDialog();
|
||||
if (!this.getValue()) {
|
||||
dialog.getContentElement('info', 'muted_looping_autoplay').setValue(true, true);
|
||||
}
|
||||
updatePreview(dialog);
|
||||
},
|
||||
setup: function(element) {
|
||||
this.setValue(!!(element && element.hasAttribute('controls')));
|
||||
},
|
||||
commit: function(element) {
|
||||
if (this.getValue()) {
|
||||
element.setAttribute('controls', 'controls');
|
||||
}
|
||||
else {
|
||||
element.removeAttribute('controls');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
id: 'muted_looping_autoplay',
|
||||
type: 'checkbox',
|
||||
label: editor.lang.video.mutedLoopingAutoplay,
|
||||
onChange: function() {
|
||||
var dialog = this.getDialog();
|
||||
if (!this.getValue()) {
|
||||
dialog.getContentElement('info', 'controls').setValue(true, true);
|
||||
}
|
||||
updatePreview(dialog);
|
||||
},
|
||||
setup: function(element) {
|
||||
this.setValue(!!(element && element.hasAttribute('autoplay')));
|
||||
},
|
||||
commit: function(element) {
|
||||
if (this.getValue()) {
|
||||
element.setAttributes({autoplay: 'autoplay', loop: 'loop', muted: 'muted'});
|
||||
}
|
||||
else {
|
||||
element.removeAttributes(['autoplay', 'loop', 'muted']);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
id: 'preview',
|
||||
type: 'html',
|
||||
html: '<label>' + editor.lang.video.preview + '</label><div class="cke_dialog_ui_labeled_content" style="position:relative;background-color:#f8f8f8;border:1px solid #d1d1d1;"><div style="height:0;padding-top:56.25%"><div style="position:absolute;bottom:0;left:0;right:0;top:0;"><video preload="metadata" style="width:100%;height:100%;display:none;"></video></div></div></div>'
|
||||
}]
|
||||
}],
|
||||
onLoad: function() {
|
||||
this.video = this.getContentElement('info', 'preview').getElement().getNext().getFirst().getFirst().getFirst();
|
||||
// Ensure browser does not ignore the muted attribute.
|
||||
this.video.$.addEventListener('loadedmetadata', function(e) {
|
||||
var video$ = e.target;
|
||||
video$.muted = video$.hasAttribute('muted');
|
||||
}, false);
|
||||
},
|
||||
onShow: function() {
|
||||
var element = this.getSelectedElement();
|
||||
if (element && element.data('cke-real-element-type') == 'video') {
|
||||
var realElement = editor.restoreRealElement(element);
|
||||
this.setupContent(realElement);
|
||||
updatePreview(this);
|
||||
}
|
||||
},
|
||||
onOk: function() {
|
||||
var dialog = this;
|
||||
var metadata = getMetadata(dialog, function() {
|
||||
dialog.definition.onOk.apply(dialog);
|
||||
});
|
||||
if (metadata) {
|
||||
var realElement = CKEDITOR.dom.element.createFromHtml('<cke:video></cke:video>', editor.document);
|
||||
realElement.setAttributes({
|
||||
preload: 'metadata',
|
||||
width: metadata.width,
|
||||
height: metadata.height
|
||||
});
|
||||
dialog.commitContent(realElement);
|
||||
var element = editor.createFakeElement(realElement, 'cke-video', 'video', false);
|
||||
element.$.src = CKEDITOR.tools.createImageData(metadata);
|
||||
editor.insertElement(element);
|
||||
dialog.hide();
|
||||
return;
|
||||
}
|
||||
if (metadata === false) {
|
||||
alert(editor.lang.video.invalidSrc);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
onHide: function() {
|
||||
clearPreview(this);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
})();
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 206 B |
Binary file not shown.
|
After Width: | Height: | Size: 196 B |
Binary file not shown.
|
After Width: | Height: | Size: 229 B |
@@ -0,0 +1,9 @@
|
||||
CKEDITOR.plugins.setLang('video', 'en', {
|
||||
button: 'Video',
|
||||
title: 'Video properties',
|
||||
emptySrc: 'URL must not be empty.',
|
||||
controls: 'Enable controls',
|
||||
mutedLoopingAutoplay: 'Muted looping autoplay',
|
||||
preview: 'Preview',
|
||||
invalidSrc: 'URL is invalid or video is not playable.'
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
CKEDITOR.plugins.setLang('video', 'fr', {
|
||||
button: 'Vidéo',
|
||||
title: 'Propriétés de la vidéo',
|
||||
emptySrc: 'L’URL doit être indiquée.',
|
||||
controls: 'Activer les contrôles',
|
||||
mutedLoopingAutoplay: 'Lecture automatique en boucle et muette',
|
||||
preview: 'Aperçu',
|
||||
invalidSrc: 'L’URL est invalide ou la vidéo n’est pas lisible.'
|
||||
});
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* @file
|
||||
* Written by Henri MEDOT <henri.medot[AT]absyx[DOT]fr>
|
||||
* http://www.absyx.fr
|
||||
*/
|
||||
|
||||
CKEDITOR.tools.createImageData = function(dimensions) {
|
||||
return 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" width="' + dimensions.width + '" height="' + dimensions.height + '"></svg>');
|
||||
};
|
||||
|
||||
CKEDITOR.plugins.add('video', {
|
||||
requires: 'dialog,fakeobjects',
|
||||
lang: 'en,fr',
|
||||
icons: 'video',
|
||||
hidpi: true,
|
||||
onLoad: function() {
|
||||
var url = CKEDITOR.getUrl(this.path + 'images/placeholder.png');
|
||||
CKEDITOR.addCss('img.cke-video{background:#f8f8f8 url(' + url + ') center center no-repeat;outline:1px solid #ccc;outline-offset:-1px;min-width:192px;min-height:108px;max-width:100%;width:auto!important;height:auto!important;}');
|
||||
},
|
||||
init: function(editor) {
|
||||
editor.addCommand('video', new CKEDITOR.dialogCommand('video', {
|
||||
allowedContent: 'video[autoplay,controls,height,loop,muted,preload,!src,width]'
|
||||
}));
|
||||
editor.ui.addButton('Video', {
|
||||
label: editor.lang.video.button,
|
||||
command: 'video'
|
||||
});
|
||||
CKEDITOR.dialog.add('video', this.path + 'dialogs/video.js');
|
||||
editor.on('doubleclick', function(e) {
|
||||
var element = e.data.element;
|
||||
if (element && element.is('img') && !element.isReadOnly() && element.data('cke-real-element-type') == 'video') {
|
||||
e.data.dialog = 'video';
|
||||
}
|
||||
});
|
||||
if (editor.addMenuItems) {
|
||||
editor.addMenuGroup('video', 11);
|
||||
editor.addMenuItems({
|
||||
video: {
|
||||
label: editor.lang.video.title,
|
||||
command: 'video',
|
||||
group: 'video'
|
||||
}
|
||||
});
|
||||
}
|
||||
if (editor.contextMenu) {
|
||||
editor.contextMenu.addListener(function(element) {
|
||||
if (element && element.is('img') && !element.isReadOnly() && element.data('cke-real-element-type') == 'video') {
|
||||
return {video: CKEDITOR.TRISTATE_OFF};
|
||||
}
|
||||
});
|
||||
}
|
||||
editor.filter.addElementCallback(function(element) {
|
||||
if (element.name == 'cke:video') {
|
||||
return CKEDITOR.FILTER_SKIP_TREE;
|
||||
}
|
||||
});
|
||||
editor.lang.fakeobjects.video = editor.lang.video.button;
|
||||
},
|
||||
afterInit: function(editor) {
|
||||
editor.on('toHtml', function(e) {
|
||||
var html = e.data.dataValue;
|
||||
html = html.replace(/(<\/?)video\b/gi, '$1cke:video');
|
||||
e.data.dataValue = html;
|
||||
}, null, null, 1);
|
||||
var dataProcessor = editor.dataProcessor;
|
||||
var dataFilter = dataProcessor && dataProcessor.dataFilter;
|
||||
if (dataFilter) {
|
||||
dataFilter.addRules({
|
||||
elements: {
|
||||
'cke:video': function(element) {
|
||||
var attributes = CKEDITOR.tools.extend({}, element.attributes);
|
||||
element = editor.createFakeParserElement(element, 'cke-video', 'video', false);
|
||||
element.attributes.src = CKEDITOR.tools.createImageData(attributes);
|
||||
return element;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user