From 0959cb067dc2ea403549c392c526ea86ded51e1e Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Sun, 16 Mar 2014 14:15:06 +0100 Subject: [PATCH] fixed insert issue --- app/assets/javascripts/application.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 06452cd..50fb36d 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -30,10 +30,20 @@ function insertAttachment(url,name) { var ext = url.split('.').pop().toLowerCase(); var img_ext = [ "jpg", "png", "bmp" , "jpeg" ]; + // if ( img_ext.indexOf(ext) > -1) { +// tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + ""); +// } +// else { +// tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + "" + name +""); +// } + + if ( img_ext.indexOf(ext) > -1) { - tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + ""); + tinymce.activeEditor.execCommand('mceInsertContent', false, ""); } else { - tinymce.activeEditor.setContent(tinymce.activeEditor.getContent({format : 'raw'}) + "" + name +""); + tinymce.activeEditor.execCommand('mceInsertContent', false, "" + name +""); } + + }