diff --git a/node_modules/common.js b/node_modules/common.js index 41038feb..da46917e 100644 --- a/node_modules/common.js +++ b/node_modules/common.js @@ -60,6 +60,26 @@ var Common = { callback && callback(false); }); }, + inArray: function(arr, item) { + var me = this; + if(!arr) { + return false; + } + for(var i = 0; i < arr.length; i++) { + if(arr[i] == item) { + return true; + } + } + return false; + }, + isImageExt: function(ext) { + var me = this; + if(!ext) { + return false; + } + ext = ext.toLowerCase(); + return me.inArray(['jpg', 'jpeg', 'bmp', 'png', 'gif'], ext); + }, // 拆分filePath的各个部分 splitFile: function(fullFilePath) { var ret = { diff --git a/node_modules/file.js b/node_modules/file.js index 1bd6e028..b3513e54 100644 --- a/node_modules/file.js +++ b/node_modules/file.js @@ -180,6 +180,31 @@ var File = { } }, + // tinymce 或 mceeditor上传图片 + // callback({FileId: "xx"}) + uploadImage: function(imagePath, callback) { + var me = this; + // 读取文件, 查看是否是图片 + var filePathAttr = Common.splitFile(imagePath); + var ext = filePathAttr.ext; + if(!Common.isImageExt(ext)) { + return callback(false, 'Please select a image'); + } + var fileId = Common.objectId(); + // 复制到图片文件夹 + filePathAttr.nameNotExt = fileId + '_cp_'; + var newFilename = fileId + '.' + ext; + var newFilePath = User.getCurUserImagesPath() + '/' + newFilename; + // 复制之, 并写入到数据库中 + Common.copyFile(imagePath, newFilePath, function(ret) { + if(ret) { + me._addImage(fileId, newFilePath, callback); + } else { + callback(false); + } + }); + }, + // 附件操作 addAttach: function(filePaths, noteId, callback) { if(!noteId || !filePaths) { diff --git a/note.html b/note.html index 9b7e4659..46b342f0 100755 --- a/note.html +++ b/note.html @@ -201,25 +201,24 @@ function log(o) {
+
@@ -379,26 +378,26 @@ function log(o) {
-
+
+
+
@@ -755,6 +754,10 @@ function log(o) {
+ + + + diff --git a/public/css/theme/basic.less b/public/css/theme/basic.less index e531d6fe..b1654919 100644 --- a/public/css/theme/basic.less +++ b/public/css/theme/basic.less @@ -153,13 +153,12 @@ h1, h2, h3 { .dropdown-menu { border-radius: 3px; margin:0; - border: 1px solid @hColor; + // border: 1px solid @hColor; // border: 1px solid #e6eaed; /*overflow-x: hidden; */ /*overflow-y: scroll;*/ box-shadow: rgba(0, 0, 0, 0.172549) 0px 6px 12px 0px; - - &:before { + &:before { content: ""; width: 20px; height: 12px; @@ -182,6 +181,45 @@ h1, h2, h3 { } } +.sync-icon { + margin-left: 10px; +} +#myProfile { + .dropdown-menu { + top: -110px; + &:before { + top: auto; + bottom: -12px; + transform: rotate(180deg); + } + } + position: absolute; + left: 30px; + right: 0; + text-align: right; + .dropdown-toggle { + position: relative; + width: 100%; + display: block; + .username { + position: absolute; + display: block; + left: 0; + right: 18px; + line-height: 30px; + white-space: nowrap;text-overflow:ellipsis; overflow:hidden; + } + .account-more { + position: absolute; + right: 3px; + line-height: 30px; + } + } + + +} + + .dropdown-menu li { list-style: none; padding-left: 10px; @@ -1214,9 +1252,7 @@ top: 4px; // -.sync-icon { - padding: 0 3px; -} + #newMyNote { position: absolute; right: 3px; diff --git a/public/css/theme/default.css b/public/css/theme/default.css index fa8003e6..87cc7e6f 100644 --- a/public/css/theme/default.css +++ b/public/css/theme/default.css @@ -149,7 +149,6 @@ h3 { .dropdown-menu { border-radius: 3px; margin: 0; - border: 1px solid #0fb264; /*overflow-x: hidden; */ /*overflow-y: scroll;*/ box-shadow: rgba(0, 0, 0, 0.172549) 0px 6px 12px 0px; @@ -176,6 +175,43 @@ h3 { left: 190px; right: inherit; } +.sync-icon { + margin-left: 10px; +} +#myProfile { + position: absolute; + left: 30px; + right: 0; + text-align: right; +} +#myProfile .dropdown-menu { + top: -110px; +} +#myProfile .dropdown-menu:before { + top: auto; + bottom: -12px; + transform: rotate(180deg); +} +#myProfile .dropdown-toggle { + position: relative; + width: 100%; + display: block; +} +#myProfile .dropdown-toggle .username { + position: absolute; + display: block; + left: 0; + right: 18px; + line-height: 30px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +#myProfile .dropdown-toggle .account-more { + position: absolute; + right: 3px; + line-height: 30px; +} .dropdown-menu li { list-style: none; padding-left: 10px; @@ -1098,9 +1134,6 @@ h3 { .close:focus { outline: none; } -.sync-icon { - padding: 0 3px; -} #newMyNote { position: absolute; right: 3px; diff --git a/public/css/theme/simple.css b/public/css/theme/simple.css index ad8b729a..94b1c4ba 100644 --- a/public/css/theme/simple.css +++ b/public/css/theme/simple.css @@ -149,7 +149,6 @@ h3 { .dropdown-menu { border-radius: 3px; margin: 0; - border: 1px solid #0fb264; /*overflow-x: hidden; */ /*overflow-y: scroll;*/ box-shadow: rgba(0, 0, 0, 0.172549) 0px 6px 12px 0px; @@ -176,6 +175,43 @@ h3 { left: 190px; right: inherit; } +.sync-icon { + margin-left: 10px; +} +#myProfile { + position: absolute; + left: 30px; + right: 0; + text-align: right; +} +#myProfile .dropdown-menu { + top: -110px; +} +#myProfile .dropdown-menu:before { + top: auto; + bottom: -12px; + transform: rotate(180deg); +} +#myProfile .dropdown-toggle { + position: relative; + width: 100%; + display: block; +} +#myProfile .dropdown-toggle .username { + position: absolute; + display: block; + left: 0; + right: 18px; + line-height: 30px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +#myProfile .dropdown-toggle .account-more { + position: absolute; + right: 3px; + line-height: 30px; +} .dropdown-menu li { list-style: none; padding-left: 10px; @@ -1098,9 +1134,6 @@ h3 { .close:focus { outline: none; } -.sync-icon { - padding: 0 3px; -} #newMyNote { position: absolute; right: 3px; diff --git a/public/css/theme/writting-overwrite.css b/public/css/theme/writting-overwrite.css index a6b99bc0..7b55276a 100644 --- a/public/css/theme/writting-overwrite.css +++ b/public/css/theme/writting-overwrite.css @@ -149,7 +149,6 @@ h3 { .dropdown-menu { border-radius: 3px; margin: 0; - border: 1px solid #0fb264; /*overflow-x: hidden; */ /*overflow-y: scroll;*/ box-shadow: rgba(0, 0, 0, 0.172549) 0px 6px 12px 0px; @@ -176,6 +175,43 @@ h3 { left: 190px; right: inherit; } +.sync-icon { + margin-left: 10px; +} +#myProfile { + position: absolute; + left: 30px; + right: 0; + text-align: right; +} +#myProfile .dropdown-menu { + top: -110px; +} +#myProfile .dropdown-menu:before { + top: auto; + bottom: -12px; + transform: rotate(180deg); +} +#myProfile .dropdown-toggle { + position: relative; + width: 100%; + display: block; +} +#myProfile .dropdown-toggle .username { + position: absolute; + display: block; + left: 0; + right: 18px; + line-height: 30px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +#myProfile .dropdown-toggle .account-more { + position: absolute; + right: 3px; + line-height: 30px; +} .dropdown-menu li { list-style: none; padding-left: 10px; @@ -1098,9 +1134,6 @@ h3 { .close:focus { outline: none; } -.sync-icon { - padding: 0 3px; -} #newMyNote { position: absolute; right: 3px; diff --git a/public/css/theme/writting.css b/public/css/theme/writting.css index e776a6d3..d99e8e48 100644 --- a/public/css/theme/writting.css +++ b/public/css/theme/writting.css @@ -149,7 +149,6 @@ h3 { .dropdown-menu { border-radius: 3px; margin: 0; - border: 1px solid #0fb264; /*overflow-x: hidden; */ /*overflow-y: scroll;*/ box-shadow: rgba(0, 0, 0, 0.172549) 0px 6px 12px 0px; @@ -176,6 +175,43 @@ h3 { left: 190px; right: inherit; } +.sync-icon { + margin-left: 10px; +} +#myProfile { + position: absolute; + left: 30px; + right: 0; + text-align: right; +} +#myProfile .dropdown-menu { + top: -110px; +} +#myProfile .dropdown-menu:before { + top: auto; + bottom: -12px; + transform: rotate(180deg); +} +#myProfile .dropdown-toggle { + position: relative; + width: 100%; + display: block; +} +#myProfile .dropdown-toggle .username { + position: absolute; + display: block; + left: 0; + right: 18px; + line-height: 30px; + white-space: nowrap; + text-overflow: ellipsis; + overflow: hidden; +} +#myProfile .dropdown-toggle .account-more { + position: absolute; + right: 3px; + line-height: 30px; +} .dropdown-menu li { list-style: none; padding-left: 10px; @@ -1098,9 +1134,6 @@ h3 { .close:focus { outline: none; } -.sync-icon { - padding: 0 3px; -} #newMyNote { position: absolute; right: 3px; diff --git a/public/js/app/page.js b/public/js/app/page.js index 4b7e74a3..9f287372 100644 --- a/public/js/app/page.js +++ b/public/js/app/page.js @@ -498,11 +498,11 @@ function initEditor() { skin : "custom", language: LEA.locale, // 语言 plugins : [ - "autolink link leaui_image lists charmap hr", "paste", + "autolink link image lists charmap hr", "paste", "searchreplace leanote_nav leanote_code tabfocus", "table directionality textcolor" ], // nonbreaking - toolbar1 : "formatselect | forecolor backcolor | bold italic underline strikethrough | leaui_image | leanote_code leanote_inline_code | bullist numlist | alignleft aligncenter alignright alignjustify", + toolbar1 : "formatselect | forecolor backcolor | bold italic underline strikethrough | image | leanote_code leanote_inline_code | bullist numlist | alignleft aligncenter alignright alignjustify", toolbar2 : "outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript |searchreplace | pastetext pasteCopyImage | leanote_ace_pre | fontselect fontsizeselect", // 使用tab键: http://www.tinymce.com/wiki.php/Plugin3x:nonbreaking @@ -1372,3 +1372,31 @@ function initPage() { } }); } + +// 初始bind事件上传图片 +// tinymce, markdown触发之 +function initUploadImage() { + $('#chooseImageInput').change(function() { + var $this = $(this); + var imagePath = $this.val(); + $this.val(''); + // 上传之 + FileService.uploadImage(imagePath, function(newImage, msg) { + if(newImage) { + var note = Note.getCurNote(); + if(!note.IsMarkdown) { + var url = EvtService.getImageLocalUrl(newImage.FileId); + tinymce.activeEditor.insertContent(''); + } else { + // TODO markdown insert Image + } + } else { + alert(msg || "error"); + } + }); + }); + +} +$(function() { + initUploadImage(); +}); diff --git a/public/js/app/service.js b/public/js/app/service.js index d530d771..106e7c7e 100644 --- a/public/js/app/service.js +++ b/public/js/app/service.js @@ -21,7 +21,7 @@ var TagService = Service.tagService; var WebService = require('web'); var ServerService = require('server'); var FileService = require('file'); - +var EvtService = require('evt'); // 分发服务 // route = /note/notebook diff --git a/public/tinymce/plugins/image/plugin.js b/public/tinymce/plugins/image/plugin.js index f8f606c7..634f7001 100644 --- a/public/tinymce/plugins/image/plugin.js +++ b/public/tinymce/plugins/image/plugin.js @@ -10,26 +10,15 @@ /*global tinymce:true */ -// 与jbimages结合 -// 使用了jbimages/dialog-v4.htm -// jbimages/js/dialog-v4.js tinymce.PluginManager.add('image', function(editor, url) { // 弹框 function showDialog() { - // 与jbimages结合 - // Simple default dialog - win = editor.windowManager.open({ - title: 'Insert/edit image', - file : url + '/dialog.htm', - width : 550, - height: 345 - }); + $('#chooseImageInput').click(); } - // 添加按钮 editor.addButton('image', { icon: 'image', - tooltip: 'Insert/edit image', + tooltip: 'Insert image', onclick: showDialog, stateSelector: 'img:not([data-mce-object])' });