From a669f0750a3db1e9abebe9ca85214b6168a72e1c Mon Sep 17 00:00:00 2001 From: life Date: Mon, 19 Oct 2015 14:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=99=A8=E7=BC=A9=E8=BF=9B,?= =?UTF-8?q?=20=E5=9B=BE=E7=89=87=E6=8B=96=E5=8A=A8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/leanote/desktop-app/issues/64 --- public/js/app/note.js | 17 ++++++++++------- public/tinymce/plugins/image/plugin.js | 14 ++++++++++++++ public/tinymce/plugins/image/plugin.min.js | 1 - 3 files changed, 24 insertions(+), 8 deletions(-) delete mode 100644 public/tinymce/plugins/image/plugin.min.js diff --git a/public/js/app/note.js b/public/js/app/note.js index b89f7395..d3d965c4 100644 --- a/public/js/app/note.js +++ b/public/js/app/note.js @@ -1719,13 +1719,13 @@ Note.deleteNoteTag = function(item, tag) { } }; -Note.readOnly = true; +Note.readOnly = false; // 默认为false要好? +LEA.readOnly = false; // 切换只读模式 Note.toggleReadOnly = function() { var me = this; var note = me.getCurNote(); - // console.log('((((((((((((((((((((((('); // tinymce var $editor = $('#editor'); $editor.addClass('read-only').removeClass('all-tool'); // 不要全部的 @@ -1748,6 +1748,9 @@ Note.toggleReadOnly = function() { $('#infoToolbar .created-time').html(goNowToDatetime(note.CreatedTime)); $('#infoToolbar .updated-time').html(goNowToDatetime(note.UpdatedTime)); } + + Note.readOnly = true; + LEA.readOnly = true; if(note.readOnly) { return; @@ -1761,11 +1764,10 @@ Note.toggleReadOnly = function() { } note.readOnly = true; - Note.readOnly = true; }; // 切换到编辑模式 -Note.toggleWriteable = function() { - var me = this; +LEA.toggleWriteable = Note.toggleWriteable = function() { + var me = Note; // $('#infoToolbar').hide(); $('#editor').removeClass('read-only'); @@ -1779,6 +1781,9 @@ Note.toggleWriteable = function() { return; } + Note.readOnly = false; + LEA.readOnly = false; + if(!note.readOnly) { return; } @@ -1794,9 +1799,7 @@ Note.toggleWriteable = function() { MD.onResize(); } } - note.readOnly = false; - Note.readOnly = false; }; // 渲染列表 diff --git a/public/tinymce/plugins/image/plugin.js b/public/tinymce/plugins/image/plugin.js index d358cdce..df612f3d 100644 --- a/public/tinymce/plugins/image/plugin.js +++ b/public/tinymce/plugins/image/plugin.js @@ -22,4 +22,18 @@ tinymce.PluginManager.add('image', function(editor, url) { onclick: showDialog, stateSelector: 'img:not([data-mce-object])' }); + + // 为解决在editor里拖动图片问题 + var dragStart = false; + editor.on("dragstart", function(e) { + // 只读模式下不能拖动 + if (LEA.readOnly) { + e.preventDefault(); + e.stopPropagation(); + } + }); + editor.on("dragend", function(e) { + }); + editor.on("dragover", function(e) { + }); }); \ No newline at end of file diff --git a/public/tinymce/plugins/image/plugin.min.js b/public/tinymce/plugins/image/plugin.min.js deleted file mode 100644 index 56eeb01c..00000000 --- a/public/tinymce/plugins/image/plugin.min.js +++ /dev/null @@ -1 +0,0 @@ -tinymce.PluginManager.add("image",function(i,t){function e(){win=i.windowManager.open({title:"Insert/edit image",file:t+"/dialog.htm",width:550,height:345})}i.addButton("image",{icon:"image",tooltip:"Insert/edit image",onclick:e,stateSelector:"img:not([data-mce-object])"})}); \ No newline at end of file