diff --git a/static/mrdoc/mrdoc.editor.js b/static/mrdoc/mrdoc.editor.js index e66273a..1a01896 100644 --- a/static/mrdoc/mrdoc.editor.js +++ b/static/mrdoc/mrdoc.editor.js @@ -382,9 +382,9 @@ element.on('tab(img-tab)', function(data){ insertImg = function(e){ console.log(e); if(editor_mode == 3){ - editor.addValue('') + editor.addValue('') }else{ - editor.insertValue("\n![](" + e.getAttribute('data-url') + ")"); + editor.insertValue("\n![](" + e.getAttribute('data-url').replace(" ",'%20') + ")"); editor.focus() } diff --git a/template/app_doc/editor/tpl_editor_editormd.html b/template/app_doc/editor/tpl_editor_editormd.html index 2b3d9a7..90607ef 100644 --- a/template/app_doc/editor/tpl_editor_editormd.html +++ b/template/app_doc/editor/tpl_editor_editormd.html @@ -284,118 +284,4 @@ return null; } }; - //监听图片Tab选项卡切换 - element.on('tab(img-tab)', function(data){ - //console.log(this); //当前Tab标题所在的原始DOM元素 - //console.log(data.index); //得到当前Tab的所在下标 - //console.log(data.elem); //得到当前的Tab大容器 - if(data.index == 1){ - layer.load(1); - console.log('选择图片') - $("#select-img-group").empty(); //删除已有分组按钮 - //请求新的分组数据 - $.post("{% url 'manage_img_group' %}",{'types':3},function(r){ - if(r.status){ - group_btn_str = '' - for(var i in r.data){ - group_btn_str += '' - }; - $("#select-img-group").append(group_btn_str) - } - }); - //请求全部图片数据 - $.post("{% url 'manage_image' %}",{'types':2,'group_id':0},function(r){ - if(r.status){ - //调用分页显示 - laypage.render({ - elem: 'select-img-page',//分页的div - count: r.data.length, //数据总数 - limit:15, //单页数 - jump: function(obj){ - //渲染HTML - document.getElementById('select-img').innerHTML = function(){ - var arr = [] - var thisData = r.data.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit); - layui.each(thisData, function(index, item){ - arr.push('
  • '); - }); - return arr.join(''); - }(); - } - }); - layer.closeAll("loading"); - }else{ - layer.closeAll("loading"); - layer.msg("获取图片失败") - } - }) - } - }); - // 插入选择的图片到编辑器 - insertImg = function(e){ - // console.log(e); - editor.insertValue("\n![](" + e.getAttribute('data-url') + ")"); - editor.focus() - }; - // 按钮点击插入输入框图片链接 - insertImgUrl = function(){ - editor.insertValue("\n![](" + $("#img_url_input").val() + ")"); - $("#img_url_input").val("") - layer.closeAll(); - editor.focus() - }; - // 切换图片分组 - switchImgGroup = function(e){ - layer.load(1); - $.post("{% url 'manage_image' %}", { - 'types': 2, - 'group_id': e - }, - function(r) { - if (r.status) { - //调用分页显示 - laypage.render({ - elem: 'select-img-page',//分页的div - count: r.data.length,//数据总数 - limit: 15,//单页数 - jump: function(obj) { - //渲染HTML - document.getElementById('select-img').innerHTML = function() { - var arr = [] - var thisData = r.data.concat().splice(obj.curr * obj.limit - obj.limit, obj.limit); - layui.each(thisData, - function(index, item) { - arr.push('
  • '); - }); - return arr.join(''); - } (); - } - }); - layer.closeAll("loading"); //关闭加载提示 - } else { - layer.closeAll("loading"); - layer.msg("获取分组图片失败") - } - }) - }; - // 插入选择的附件到编辑器 - insertAttach = function(e){ - editor.insertValue("\n[【附件】"+ $(e).data('name') + "](/media/" + $(e).data('path') + ")"); - layer.closeAll(); - } - // 插入音视频到编辑器 - insertMultimedia = function(e){ - if(e === 'audio'){ - editor.insertValue("\n![=audio](" + $("#audio_input").val() + ")"); - }else if(e === 'video'){ - editor.insertValue("\n![=video](" + $("#video_input").val() + ")"); - }else if(e === 'video_iframe'){ - editor.insertValue("\n![=video_iframe](" + $("#video_iframe_input").val() + ")"); - } - $("#audio_input").val('') - $("#video_input").val('') - $("#video_iframe_input").val('') - layer.closeAll(); - editor.focus() - }