mirror of https://github.com/requarks/wiki
parent
dab4a97094
commit
4625a302f6
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,49 @@
|
||||
|
||||
const videoRules = {
|
||||
'youtube': new RegExp(/(?:(?:youtu\.be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|\&v(?:i)?=))([^#\&\?]*).*/, 'i'),
|
||||
'vimeo': new RegExp(/vimeo.com\/(?:channels\/(?:\w+\/)?|groups\/(?:[^\/]*)\/videos\/|album\/(?:\d+)\/video\/|)(\d+)(?:$|\/|\?)/, 'i'),
|
||||
'dailymotion': new RegExp(/(?:dailymotion\.com(?:\/embed)?(?:\/video|\/hub)|dai\.ly)\/([0-9a-z]+)(?:[\-_0-9a-zA-Z]+(?:#video=)?([a-z0-9]+)?)?/, 'i')
|
||||
};
|
||||
|
||||
// Vue Video instance
|
||||
|
||||
let vueVideo = new Vue({
|
||||
el: '#modal-editor-video',
|
||||
data: {
|
||||
link: ''
|
||||
},
|
||||
methods: {
|
||||
open: (ev) => {
|
||||
$('#modal-editor-video').addClass('is-active');
|
||||
$('#modal-editor-video input').focus();
|
||||
},
|
||||
cancel: (ev) => {
|
||||
mdeModalOpenState = false;
|
||||
$('#modal-editor-video').removeClass('is-active');
|
||||
vueVideo.link = '';
|
||||
},
|
||||
insertVideo: (ev) => {
|
||||
|
||||
if(mde.codemirror.doc.somethingSelected()) {
|
||||
mde.codemirror.execCommand('singleSelection');
|
||||
}
|
||||
|
||||
// Guess video type
|
||||
|
||||
let videoType = _.findKey(videoRules, (vr) => {
|
||||
return vr.test(vueVideo.link);
|
||||
});
|
||||
if(_.isNil(videoType)) {
|
||||
videoType = 'video';
|
||||
}
|
||||
|
||||
// Insert video tag
|
||||
|
||||
let videoText = '[video](' + vueVideo.link + '){.' + videoType + '}\n';
|
||||
|
||||
mde.codemirror.doc.replaceSelection(videoText);
|
||||
vueVideo.cancel();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
@ -1,16 +1,14 @@
|
||||
#alerts
|
||||
ul
|
||||
template(v-for="aItem in children", track-by='_uid')
|
||||
.notification(v-bind:class='aItem.class')
|
||||
li(v-bind:class='aItem.class')
|
||||
button.delete(v-on:click='acknowledge(aItem._uid)')
|
||||
h3 {{ aItem.title }}
|
||||
span {{ aItem.message }}
|
||||
|
||||
if appflash.length > 0
|
||||
script(type='text/javascript')
|
||||
| var alertsData =
|
||||
!= JSON.stringify(appflash)
|
||||
| ;
|
||||
script(type='text/javascript').
|
||||
var alertsData = !{JSON.stringify(appflash)};
|
||||
else
|
||||
script(type='text/javascript')
|
||||
| var alertsData = [];
|
||||
script(type='text/javascript').
|
||||
var alertsData = [];
|
@ -0,0 +1,28 @@
|
||||
|
||||
.modal#modal-editor-video
|
||||
.modal-background
|
||||
.modal-container
|
||||
.modal-content
|
||||
header.is-green Insert Video Player
|
||||
section
|
||||
label.label Enter the link to the video to be embedded:
|
||||
p.control.is-fullwidth
|
||||
input.input(type='text', placeholder='https://www.youtube.com/watch?v=xxxxxxxxxxx', v-model='link')
|
||||
span.help.is-red.is-hidden This URL is invalid or not supported!
|
||||
.note The following are supported:
|
||||
ul
|
||||
li
|
||||
i.icon-youtube-play
|
||||
span Youtube
|
||||
li
|
||||
i.icon-vimeo
|
||||
span Vimeo
|
||||
li
|
||||
i.icon-film
|
||||
span Dailymotion
|
||||
li
|
||||
i.icon-video
|
||||
span Any standard MP4 file
|
||||
footer
|
||||
a.button.is-grey.is-outlined(v-on:click="cancel") Discard
|
||||
a.button.is-green(v-on:click="insertVideo") Insert Video
|
Loading…
Reference in new issue