var marked = require("marked");
var toMarkdown = require('to-markdown');
module.exports = function() {
$("#mode").on("change", function(event) {
var mode = $("#mode option:selected").val();
if (mode === "Mark Down") {
$('#cke_editor').hide();
$('#markdown').show();
$('#preview').hide();
$('#write').show();
$('.tab li').removeClass('active');
$('.tab li:first').addClass('active');
var data = ckeditor.getData();
var markdown = toMarkdown(data);
$('#write textarea').text(markdown);
} else if (mode === "Rich Text") {
$('#markdown').hide();
$('#cke_editor').show();
var text = $('#write textarea').val();
var html = marked(text);
ckeditor.setData(html);
}
});
$('.tab li').on('click', function(event) {
var tabname = event.target.dataset.tab;
if (tabname === 'preview') {
var text = $('#write textarea').val();
var html = marked(text);
$('#preview').html(html);
}
$('.tabcontent').hide();
$('.tab li').removeClass('active');
$('#' + tabname).css("display", "block");
$(event.currentTarget).addClass('active');
});
$('#write textarea').on('paste keyup', function(){
var isEmpty = $('#write textarea').val() === "";
$('#submit').prop('disabled', isEmpty);
});
}
This works perfectly in the initial project. But not when i convert the div into an iframe :JavaScript is a dynamic, object-based language commonly used for client-side scripting in web browsers. Recently, server side JavaScript frameworks have also emerged. JavaScript runs on nearly every operating system and in almost every mainstream web browser.
TRUSTED BY
ASKER
The url that loads the iframe is of same domain as the parent window one... Does in this case also will parent window wont be able to do anything with iframe ?