From 5bcb88ee2cdb96907cb93ed6ba65ebf52a0cb7fc Mon Sep 17 00:00:00 2001 From: Paul Schneider Date: Tue, 24 Jan 2017 15:42:21 +0100 Subject: [PATCH] fixes switch between MD code edition & Quill edition --- Yavsc/Views/Blogspot/Edit.cshtml | 75 ++++++++++++++++---------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/Yavsc/Views/Blogspot/Edit.cshtml b/Yavsc/Views/Blogspot/Edit.cshtml index aa86a5c7..022117fc 100644 --- a/Yavsc/Views/Blogspot/Edit.cshtml +++ b/Yavsc/Views/Blogspot/Edit.cshtml @@ -52,7 +52,8 @@ var onchange = function(){ var nv = $(this).val(); var tid = $(this).data('from'); - $('#'+tid).html(htmlize(nv)) + $('#'+tid).html(htmlize(nv)); + initQuill(); }; $("#Content").change(onchange); $("#Title").change(onchange); @@ -68,44 +69,42 @@ $(".mdcoding").addClass('hidden'); } }); - var editortitre = new Quill('#titleview', { - modules: { toolbar: '#Titletoolbar' }, - theme: 'snow' - }); - var editorcontenu = new Quill('#contentview', { - modules: { toolbar: '#contentbar' }, - theme: 'snow' - }); - editortitre.on('selection-change', function(range) { - if (range) { - $('#contentbar').addClass('hidden'); - $('#Titletoolbar').removeClass('hidden'); - } -}); -editortitre.on('text-change',function(delta,source){ - if (source=='user') - { - updateMD('Title',$('#titleview').html()) - } -}); - editorcontenu.on('selection-change', function(range) { - if (range) { - $('#contentbar').removeClass('hidden'); - $('#Titletoolbar').addClass('hidden'); - } -}); -editorcontenu.on('text-change',function(delta,source){ - if (source=='user') - { - updateMD('Content',$('#contentview').html()) - } -}); - - $('#contentview').focus(function(){ - $('#contentbar').removeClass('hidden'); - $('#Titletoolbar').addClass('hidden'); - }) + var initQuill = function() { + var editortitre = new Quill('#titleview', { + modules: { toolbar: '#Titletoolbar' }, + theme: 'snow' + }); + var editorcontenu = new Quill('#contentview', { + modules: { toolbar: '#contentbar' }, + theme: 'snow' + }); + editortitre.on('selection-change', function(range) { + if (range) { + $('#contentbar').addClass('hidden'); + $('#Titletoolbar').removeClass('hidden'); + } + }); + editortitre.on('text-change',function(delta,source){ + if (source=='user') + { + updateMD('Title',$('#titleview').html()) + } + }); + editorcontenu.on('selection-change', function(range) { + if (range) { + $('#contentbar').removeClass('hidden'); + $('#Titletoolbar').addClass('hidden'); + } + }); + editorcontenu.on('text-change',function(delta,source){ + if (source=='user') + { + updateMD('Content',$('#contentview').html()) + } + }); + }; + initQuill(); Dropzone.options.postfiles= { maxFilesize: 2, // MB