Skip to content

Commit

Permalink
Merge pull request #554 from themeum/sazedul-haque
Browse files Browse the repository at this point in the history
Youtube video end screen and TinyMCE vulnerability fix
  • Loading branch information
harunollyo authored Sep 13, 2023
2 parents b6faf24 + 0dcc691 commit 557dcc6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
12 changes: 8 additions & 4 deletions assets/react/front/tutor-front.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,24 @@ jQuery(document).ready(function($) {

player.on('play', () => {
that.played_once = true;

if (_tutorobject.tutor_pro_url && player.provider === 'youtube') {
$('.plyr--youtube.plyr__poster-enabled .plyr__poster').css('opacity', 0);
}
});

player.on('ended', function(event) {
const video_data = that.video_data();
const instance = event.detail.plyr;
const data = { is_ended: true };
that.sync_time(instance, data);
console.log(
video_data.autoload_next_course_content,
that.played_once,
);
if (video_data.autoload_next_course_content && that.played_once) {
that.autoload_content();
}

if (_tutorobject.tutor_pro_url && player.provider === 'youtube') {
$('.plyr--youtube.plyr__poster-enabled .plyr__poster').css('opacity', 1);
}
});
}
},
Expand Down
23 changes: 21 additions & 2 deletions assets/react/v2/qna.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ window.jQuery(document).ready($=>{
let question_id = button.closest('[data-question_id]').data('question_id');
let course_id = button.closest('[data-course_id]').data('course_id');
let context = button.closest('[data-context]').data('context');
let answer = '' !== currentEditor ? tinymce.get(currentEditor).getContent({format: 'raw'}) : form.find('textarea').val();
let answer = '' !== currentEditor ? tinymce.get(currentEditor).getContent() : form.find('textarea').val();

let back_url = $(this).data('back_url');

const btnInnerHtml = button.html().trim();
Expand Down Expand Up @@ -173,6 +173,25 @@ window.jQuery(document).ready($=>{
// Reinitialize new added question/reply editor.
tinymce.execCommand('mceRemoveEditor', false, editor_id);
tinymce.execCommand('mceAddEditor', false, editor_id);

// Highlight code snippets
$('.tutor-qna-single-question pre').each(function () {
let el = $(this),
fallback = 'javascript',
lang = el.attr('class').trim().replace('language-', '') || fallback,
highlighted = null;

if (Prism) {
try {
highlighted = Prism.highlight(el.text(), Prism.languages[lang], lang);
} catch (error) {
highlighted = Prism.highlight(el.text(), Prism.languages[fallback], fallback);
}

highlighted ? el.html(highlighted) : null
}
});

} else {
// Clear question & reply textarea.
if ($(".tutor-quesanswer-askquestion textarea")) {
Expand Down

0 comments on commit 557dcc6

Please sign in to comment.