v1.0 beta init
This commit is contained in:
1 parent
8ae438272b
commit
593d2c2965
225 files changed
+27217
-3675
No files matched your search
@@ -19,11 +19,12 @@ tinymce.PluginManager.add('codemirror', function(editor, url) {
|
||||
editor.selection.setContent('<span class="CmCaReT" style="display:none">�</span>');
|
||||
|
||||
// Open editor window
|
||||
var height = $(document).height();
|
||||
var win = editor.windowManager.open({
|
||||
title: 'HTML source code',
|
||||
url: url + '/source.html',
|
||||
width: 800,
|
||||
height: 550,
|
||||
height: height-150,
|
||||
resizable : true,
|
||||
maximizable : true,
|
||||
buttons: [
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
tinymce.PluginManager.requireLangPack("codemirror"),tinymce.PluginManager.add("codemirror",function(e,o){function c(){e.focus(),e.selection.collapse(!0),e.selection.setContent('<span class="CmCaReT" style="display:none">�</span>');var c=e.windowManager.open({title:"HTML source code",url:o+"/source.html",width:800,height:550,resizable:!0,maximizable:!0,buttons:[{text:"Ok",subtype:"primary",onclick:function(){var e=document.querySelectorAll(".mce-container-body>iframe")[0];e.contentWindow.submit(),c.close()}},{text:"Cancel",onclick:"close"}]})}e.addButton("code",{title:"Source code",image:o+"/img/file-html.png",onclick:c}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:c})});
|
||||
tinymce.PluginManager.requireLangPack("codemirror"),tinymce.PluginManager.add("codemirror",function(e,o){function c(){e.focus(),e.selection.collapse(!0),e.selection.setContent('<span class="CmCaReT" style="display:none">�</span>');var c=$(document).height(),n=e.windowManager.open({title:"HTML source code",url:o+"/source.html",width:800,height:c-150,resizable:!0,maximizable:!0,buttons:[{text:"Ok",subtype:"primary",onclick:function(){var e=document.querySelectorAll(".mce-container-body>iframe")[0];e.contentWindow.submit(),n.close()}},{text:"Cancel",onclick:"close"}]})}e.addButton("code",{title:"Source code",image:o+"/img/file-html.png",onclick:c}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:c})});
|
||||
@@ -163,6 +163,8 @@ G.maxSelected = 10;
|
||||
<script src="public/js/jquery.fileupload.js"></script>
|
||||
<script src="public/js/jquery.iframe-transport.js"></script>
|
||||
<script src="public/js/jquery.pagination.js"></script>
|
||||
<!--
|
||||
<script src="public/js/jquery.lazyload.min.js"></script>
|
||||
-->
|
||||
<script src="public/js/main.js"></script>
|
||||
</html>
|
||||
@@ -61,10 +61,18 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
return html;
|
||||
}
|
||||
|
||||
var w = $(document).width() - 10;
|
||||
if(w > 885) {
|
||||
w = 885;
|
||||
}
|
||||
var h = $(document).height() - 100;
|
||||
if(h > 475) {
|
||||
h = 475;
|
||||
}
|
||||
win = editor.windowManager.open({
|
||||
title: "Manage Image",
|
||||
width : 885,
|
||||
height : 475,
|
||||
width : w,
|
||||
height : h,
|
||||
html: GetTheHtml(),
|
||||
buttons: [
|
||||
{
|
||||
@@ -146,7 +154,7 @@ tinymce.PluginManager.add('leaui_image', function(editor, url) {
|
||||
(function(data) {
|
||||
ajaxPost("/file/copyImage", {userId: UserInfo.UserId, fileId: fileId, toUserId: curNote.UserId}, function(re) {
|
||||
if(reIsOk(re) && re.Id) {
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
|
||||
data.src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
}
|
||||
renderImage(data);
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(t,e){function i(t,e){function i(t,i){n.parentNode.removeChild(n),e({width:t,height:i})}var n=document.createElement("img");n.onload=function(){i(n.clientWidth,n.clientHeight)},n.onerror=function(){i()},n.src=t;var r=n.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(n)}function n(){function n(){var t='<iframe id="leauiIfr" src="'+e+"/index.html?"+(new Date).getTime()+'" frameborder="0"></iframe>';return t}var r=t.dom,o=t.selection.getContent(),a=/<img.*?\/>/g,d=o.match(a),c=document.createElement("p"),l=[];for(var s in d){c.innerHTML=d[s];var g=c.firstChild;if(g&&"IMG"==g.nodeName){var h={};h.src=r.getAttrib(g,"data-src")||r.getAttrib(g,"src"),h.width=r.getAttrib(g,"width"),h.height=r.getAttrib(g,"height"),h.title=r.getAttrib(g,"title"),l.push(h)}}LEAUI_DATAS=l,win=t.windowManager.open({title:"Manage Image",width:885,height:475,html:n(),buttons:[{text:"Insert Image",subtype:"primary",onclick:function(n){for(var o=document.getElementById("leauiIfr").contentWindow,a=o.document.getElementById("preview"),d=a.childNodes,c=[],l=0;l<d.length;++l){var n=d[l];if(n.firstChild&&"IMG"==n.firstChild.nodeName){var s=n.firstChild,g={};g.src=s.getAttribute("src"),g.width=s.getAttribute("data-width"),g.height=s.getAttribute("data-height"),g.title=s.getAttribute("data-title"),c.push(g)}}for(var l in c){var h,f=c[l],u=f.src;h=-1!=u.indexOf("http://")||-1!=u.indexOf("https://")?u:e+"/"+u,f.src=h;var m=function(e){var n=function(e,i){var n,o={};return o.id="__mcenew"+i,o.src="http://leanote.com/images/loading-24.gif",n=r.createHTML("img",o),t.insertContent(n),n=r.get(o.id),function(t){t&&t.width&&(t.width>600&&(t.width=600),e.width=t.width),r.setAttrib(n,"src",e.src),r.setAttrib(n,"width",e.width),r.setAttrib(n,"title",e.title),r.setAttrib(n,"id",null)}}(e,l);i(e.src,n)},I="";if(fileIds=h.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(I=fileIds[1]),I){var p=Note.getCurNote();p&&p.UserId!=UserInfo.UserId?!function(t){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:I,toUserId:p.UserId},function(e){if(reIsOk(e)&&e.Id){var i=window.location.protocol+"//"+window.location.host;t.src=i+"/file/outputImage?fileId="+e.Id}m(t)})}(f):m(f)}else m(f)}this.parent().parent().close()}},{text:"Cancel",onclick:function(){this.parent().parent().close()}}]})}t.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:n,stateSelector:"img:not([data-mce-object])"}),t.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:n,context:"insert",prependToContext:!0});var r=!1;t.on("dragstart",function(){r=!0}),t.on("dragend",function(){r=!1}),t.on("dragover",function(){r||$("body").trigger("dragover")})});
|
||||
var LEAUI_DATAS=[];tinymce.PluginManager.add("leaui_image",function(t,e){function i(t,e){function i(t,i){n.parentNode.removeChild(n),e({width:t,height:i})}var n=document.createElement("img");n.onload=function(){i(n.clientWidth,n.clientHeight)},n.onerror=function(){i()},n.src=t;var r=n.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(n)}function n(){function n(){var t='<iframe id="leauiIfr" src="'+e+"/index.html?"+(new Date).getTime()+'" frameborder="0"></iframe>';return t}var r=t.dom,a=t.selection.getContent(),d=/<img.*?\/>/g,o=a.match(d),c=document.createElement("p"),l=[];for(var s in o){c.innerHTML=o[s];var g=c.firstChild;if(g&&"IMG"==g.nodeName){var h={};h.src=r.getAttrib(g,"data-src")||r.getAttrib(g,"src"),h.width=r.getAttrib(g,"width"),h.height=r.getAttrib(g,"height"),h.title=r.getAttrib(g,"title"),l.push(h)}}LEAUI_DATAS=l;var f=$(document).width()-10;f>885&&(f=885);var u=$(document).height()-100;u>475&&(u=475),win=t.windowManager.open({title:"Manage Image",width:f,height:u,html:n(),buttons:[{text:"Insert Image",subtype:"primary",onclick:function(n){for(var a=document.getElementById("leauiIfr").contentWindow,d=a.document.getElementById("preview"),o=d.childNodes,c=[],l=0;l<o.length;++l){var n=o[l];if(n.firstChild&&"IMG"==n.firstChild.nodeName){var s=n.firstChild,g={};g.src=s.getAttribute("src"),g.width=s.getAttribute("data-width"),g.height=s.getAttribute("data-height"),g.title=s.getAttribute("data-title"),c.push(g)}}for(var l in c){var h,f=c[l],u=f.src;h=-1!=u.indexOf("http://")||-1!=u.indexOf("https://")?u:e+"/"+u,f.src=h;var m=function(e){var n=function(e,i){var n,a={};return a.id="__mcenew"+i,a.src="http://leanote.com/images/loading-24.gif",n=r.createHTML("img",a),t.insertContent(n),n=r.get(a.id),function(t){t&&t.width&&(t.width>600&&(t.width=600),e.width=t.width),r.setAttrib(n,"src",e.src),r.setAttrib(n,"width",e.width),r.setAttrib(n,"title",e.title),r.setAttrib(n,"id",null)}}(e,l);i(e.src,n)},I="";if(fileIds=h.split("fileId="),2==fileIds.length&&fileIds[1].length=="53aecf8a8a039a43c8036282".length&&(I=fileIds[1]),I){var v=Note.getCurNote();v&&v.UserId!=UserInfo.UserId?!function(t){ajaxPost("/file/copyImage",{userId:UserInfo.UserId,fileId:I,toUserId:v.UserId},function(e){if(reIsOk(e)&&e.Id){var i=UrlPrefix;t.src=i+"/file/outputImage?fileId="+e.Id}m(t)})}(f):m(f)}else m(f)}this.parent().parent().close()}},{text:"Cancel",onclick:function(){this.parent().parent().close()}}]})}t.addButton("leaui_image",{icon:"image",tooltip:"Insert/edit image",onclick:n,stateSelector:"img:not([data-mce-object])"}),t.addMenuItem("leaui_image",{icon:"image",text:"Insert image",onclick:n,context:"insert",prependToContext:!0});var r=!1;t.on("dragstart",function(){r=!0}),t.on("dragend",function(){r=!1}),t.on("dragover",function(){r||$("body").trigger("dragover")})});
|
||||
@@ -73,7 +73,7 @@
|
||||
border: solid 2px #FF7300;
|
||||
}
|
||||
#imageList li img {
|
||||
max-width: 120px;
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
#imageList li .tools {
|
||||
@@ -103,7 +103,7 @@
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.tabs {
|
||||
height: 350px;
|
||||
/*height: 350px;*/
|
||||
}
|
||||
#preview {
|
||||
margin: 0;
|
||||
@@ -173,3 +173,41 @@
|
||||
#previewAttrs label {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@media screen and (max-width:700px) {
|
||||
#previewAttrs {
|
||||
display: none;
|
||||
}
|
||||
#drop {
|
||||
min-height: initial;
|
||||
padding: 10px 0;
|
||||
}
|
||||
#drop a {
|
||||
position: initial;
|
||||
margin: auto;
|
||||
}
|
||||
#url form {
|
||||
margin: 0 !important;
|
||||
margin: auto;
|
||||
}
|
||||
.form-inline .form-group {
|
||||
display: inline-block;
|
||||
margin-bottom: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.form-inline .form-control {
|
||||
width: auto;
|
||||
display: inline-block;
|
||||
}
|
||||
#preview li:nth-child(3n),
|
||||
#preview li:nth-child(4n),
|
||||
#preview li:nth-child(5),
|
||||
#preview li:nth-child(7),
|
||||
#preview li:nth-child(10)
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
#imageList li {
|
||||
width: 90px;
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
* {
|
||||
font-family: 'Open Sans', 'Helvetica Neue', Arial, 'Hiragino Sans GB', 'Microsoft YaHei', 'WenQuanYi Micro Hei', sans-serif;
|
||||
}
|
||||
/* upload */
|
||||
#upload{
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#drop {
|
||||
position: relative;
|
||||
width: 99%;
|
||||
min-height: 260px;
|
||||
border: 1px dotted #000000;
|
||||
z-index: 2;
|
||||
text-align: center;
|
||||
}
|
||||
#drop.in {
|
||||
border: 2px solid #000000;
|
||||
}
|
||||
|
||||
#drop a{
|
||||
left: 33%;
|
||||
top: 105px;
|
||||
z-index: 15;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
#drop input{
|
||||
display:none;
|
||||
}
|
||||
|
||||
#upload-msg{
|
||||
list-style-type: none;
|
||||
padding-left: 0px;
|
||||
margin-left: 0px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 10px;
|
||||
width: 300px;
|
||||
max-height: 240px;
|
||||
overflow: scroll;
|
||||
z-index: 3;
|
||||
}
|
||||
|
||||
/**/
|
||||
.tab-pane {
|
||||
padding: 10px;
|
||||
}
|
||||
#paginationContainer {
|
||||
text-align: right;
|
||||
}
|
||||
#imageList {
|
||||
margin: 0;
|
||||
margin-top: 10px;
|
||||
padding: 0;
|
||||
height: 196px;
|
||||
}
|
||||
#imageList li {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
padding: 0;
|
||||
margin: 0 3px 3px 0;
|
||||
position: relative;
|
||||
height: 90px;
|
||||
width: 122px;
|
||||
overflow: hidden;
|
||||
border: 1px solid #eee;
|
||||
}
|
||||
#imageList li .a-img {
|
||||
line-height: 80px;
|
||||
display: block;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#imageList li:hover {
|
||||
border: 1px solid #FF7300;
|
||||
}
|
||||
#imageList li.selected {
|
||||
border: solid 2px #FF7300;
|
||||
}
|
||||
#imageList li img {
|
||||
max-width: 120px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#imageList li .tools {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #fff;
|
||||
padding-right: 2px;
|
||||
text-align: right;
|
||||
opacity: 0.7;
|
||||
}
|
||||
.tools .file-title {
|
||||
width: 100px;
|
||||
height: 20px;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
#imageList li:hover .tools {
|
||||
display: block;
|
||||
opacity: 0.9;
|
||||
}
|
||||
.alert {
|
||||
padding: 5px;
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.tabs {
|
||||
height: 350px;
|
||||
}
|
||||
|
||||
#preview {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
margin-left: 10px;
|
||||
margin-top: 3px;
|
||||
margin-bottom: 3px;
|
||||
padding-top: 5px;
|
||||
border-top: 1px solid #eee;
|
||||
}
|
||||
|
||||
#preview li {
|
||||
position: relative;;
|
||||
display: inline-block;
|
||||
float: left;
|
||||
border: solid 1px #E6E5E3;
|
||||
background-color: #FFF;
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
overflow: hidden;
|
||||
margin-right: 10px;
|
||||
line-height: 64px;
|
||||
text-align: center;
|
||||
font-style: italic;
|
||||
color: #E1E1E1;
|
||||
font-size: 18px;
|
||||
cursor: pointer;
|
||||
}
|
||||
#preview li:hover {
|
||||
border: 1px solid #FF7300;
|
||||
}
|
||||
#preview li.selected {
|
||||
border: solid 2px #FF7300;
|
||||
}
|
||||
|
||||
#preview li .tools{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
font-size: 14px;
|
||||
text-align: right;
|
||||
}
|
||||
#preview li .tools a{
|
||||
color: red;
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
#imagePage {
|
||||
position: relative;
|
||||
}
|
||||
#imageMask {
|
||||
position: absolute;
|
||||
background: #fff;
|
||||
left:0;
|
||||
right:0;
|
||||
top:0;
|
||||
bottom: 20px;
|
||||
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
display: none;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
/**/
|
||||
#previewAttrs .form-control {
|
||||
width: auto;
|
||||
}
|
||||
#previewAttrs label {
|
||||
font-weight: normal;
|
||||
}
|
||||
@@ -1,11 +1,8 @@
|
||||
// for editor.
|
||||
// drag image to editor
|
||||
// Copyright leaui
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
|
||||
define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
var editor = tinymce.activeEditor;
|
||||
var dom = editor.dom;
|
||||
|
||||
// 当url改变时, 得到图片的大小
|
||||
function getImageSize(url, callback) {
|
||||
var img = document.createElement('img');
|
||||
@@ -36,6 +33,9 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
|
||||
var i = 1;
|
||||
function insertImage(data) {
|
||||
var editor = tinymce.activeEditor;
|
||||
var dom = editor.dom;
|
||||
|
||||
var renderImage = function(data2) {
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var d = {};
|
||||
@@ -44,7 +44,7 @@ define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
d.id = '__mcenew' + (i++);
|
||||
d.src = "http://leanote.com/images/loading-24.gif";
|
||||
imgElm = dom.createHTML('img', d);
|
||||
editor.insertContent(imgElm);
|
||||
tinymce.activeEditor.insertContent(imgElm);
|
||||
imgElm = dom.get(d.id);
|
||||
|
||||
function callback (wh) {
|
||||
|
||||
@@ -13,7 +13,7 @@ function retIsOk(ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = top.UrlPrefix;
|
||||
|
||||
// load image
|
||||
function getImageSize(url, callback) {
|
||||
@@ -262,8 +262,11 @@ var o = {
|
||||
var classes = "";
|
||||
// life edit
|
||||
// 之前的
|
||||
if(each.Path != "" && each.Path.substr(0, 7) == "/upload") {
|
||||
var src = urlPrefix + each.Path;
|
||||
if(each.Path != "" && each.Path[0] == "/") {
|
||||
each.Path = each.Path.substr(1);
|
||||
}
|
||||
if(each.Path != "" && each.Path.substr(0, 7) == "upload/") {
|
||||
var src = urlPrefix + "/" + each.Path;
|
||||
} else {
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + each.FileId;
|
||||
}
|
||||
@@ -272,7 +275,7 @@ var o = {
|
||||
classes = 'class="selected"';
|
||||
}
|
||||
html += '<li ' + classes + '>';
|
||||
html += '<a title="" href="javascript:;" class="a-img"><img alt="" data-original="' + src + '" ></a>';
|
||||
html += '<a title="" href="javascript:;" class="a-img"><img alt="" src="' + src + '" data-original="' + src + '" ></a>';
|
||||
// html += '<div class="tools"><a href="javascript:;" class="del" data-id="' + each.FileId + '"><span class="glyphicon glyphicon-trash"></span></a></div>';
|
||||
html += '<div class="tools clearfix" data-id="' + each.FileId + '"><div class="file-title pull-left">' + each.Title + '</div><div class="pull-right"><a href="javascript:;" class="del" data-id="' + each.FileId + '"><span class="glyphicon glyphicon-trash"></span></a></div></div>';
|
||||
html += "</li>";
|
||||
@@ -286,7 +289,7 @@ var o = {
|
||||
}
|
||||
|
||||
// $("#imageList img").lazyload({effect : "fadeIn"});
|
||||
$("#imageList img").lazyload();
|
||||
// $("#imageList img").lazyload();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -358,7 +361,13 @@ var o = {
|
||||
if(typeof $li == "object") {
|
||||
var src = $li.find("img").attr('src');
|
||||
} else {
|
||||
src = urlPrefix + "/file/outputImage?fileId=" + $li;
|
||||
// 也有可能来自url
|
||||
if($li.indexOf("http://") != -1 || $li.indexOf("https://") != -1) {
|
||||
src = $li;
|
||||
} else {
|
||||
// 来自内部
|
||||
src = urlPrefix + "/file/outputImage?fileId=" + $li;
|
||||
}
|
||||
}
|
||||
this.selectedImages.push(src);
|
||||
this.reRenderSelectedImages(false, src);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
|
||||
|
||||
/**
|
||||
* Clipboard.js
|
||||
*
|
||||
@@ -41,6 +43,20 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
*
|
||||
* @param {String} html HTML code to paste into the current selection.
|
||||
*/
|
||||
function copyImage(src, ids) {
|
||||
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
||||
if(reIsOk(ret)) {
|
||||
// 将图片替换之
|
||||
var src = urlPrefix + "/" + ret.Item;
|
||||
var dom = editor.dom
|
||||
for(var i in ids) {
|
||||
var id = ids[i];
|
||||
var imgElm = dom.get(id);
|
||||
dom.setAttrib(imgElm, 'src', src);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 粘贴HTML
|
||||
// 当在pre下时不能粘贴成HTML
|
||||
// life add text
|
||||
@@ -67,7 +83,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
dom.remove(tempBody);
|
||||
html = args.node.innerHTML;
|
||||
}
|
||||
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
// life
|
||||
var node = editor.selection.getNode();
|
||||
@@ -87,7 +103,41 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
text = text.replace(/>/g, ">");
|
||||
editor.insertRawContent(text);
|
||||
} else {
|
||||
editor.insertContent(html);
|
||||
// life 这里得到图片img, 复制到leanote下
|
||||
if(!self.copyImage) {
|
||||
editor.insertContent(html);
|
||||
} else {
|
||||
var urlPrefix = UrlPrefix;
|
||||
var needCopyImages = {}; // src => [id1,id2]
|
||||
var time = (new Date()).getTime();
|
||||
try {
|
||||
var $html = $("<div>" + html + "</div");
|
||||
var $imgs = $html.find("img");
|
||||
for(var i = 0; i < $imgs.length; ++i) {
|
||||
var $img = $imgs.eq(i)
|
||||
var src = $img.attr("src");
|
||||
// 是否是外链
|
||||
if(src.indexOf(urlPrefix) == -1) {
|
||||
time++;
|
||||
var id = "__LEANOTE_IMAGE_" + time;
|
||||
$img.attr("id", id);
|
||||
if(needCopyImages[src]) {
|
||||
needCopyImages[src].push(id);
|
||||
} else {
|
||||
needCopyImages[src] = [id];
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.insertContent($html.html());
|
||||
|
||||
for(var src in needCopyImages) {
|
||||
var ids = needCopyImages[src];
|
||||
copyImage(src, ids);
|
||||
}
|
||||
} catch(e) {
|
||||
editor.insertContent(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,7 +358,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return;
|
||||
}
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
getImageSize(src, function(wh) {
|
||||
// life 4/25
|
||||
|
||||
@@ -21,6 +21,7 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
"tinymce/pasteplugin/Quirks"
|
||||
], function(PluginManager, Clipboard, WordFilter, Quirks) {
|
||||
var userIsInformed;
|
||||
var userIsInformed2;
|
||||
|
||||
PluginManager.add('paste', function(editor) {
|
||||
var self = this, clipboard, settings = editor.settings;
|
||||
@@ -43,6 +44,22 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function togglePasteCopyImage() {
|
||||
if (clipboard.copyImage) {
|
||||
this.active(false);
|
||||
clipboard.copyImage = false
|
||||
} else {
|
||||
clipboard.copyImage = true;
|
||||
this.active(true);
|
||||
if (!userIsInformed2) {
|
||||
editor.windowManager.alert(
|
||||
"When copy other site's images (not in leanote) into editor, it will copy the image into your album."
|
||||
);
|
||||
userIsInformed2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.clipboard = clipboard = new Clipboard(editor);
|
||||
self.quirks = new Quirks(editor);
|
||||
@@ -99,6 +116,13 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
onclick: togglePlainTextPaste,
|
||||
active: self.clipboard.pasteFormat == "text"
|
||||
});
|
||||
|
||||
editor.addButton('pasteCopyImage', {
|
||||
icon: 'copy',
|
||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
||||
onclick: togglePasteCopyImage,
|
||||
active: self.clipboard.copyImage === true
|
||||
});
|
||||
|
||||
editor.addMenuItem('pastetext', {
|
||||
text: 'Paste as text',
|
||||
|
||||
@@ -117,4 +117,4 @@
|
||||
writeScripts();
|
||||
})(this);
|
||||
|
||||
// $hash: f3e95e8badf18b4ad870bbb7bb543313
|
||||
// $hash: 8101fda736fa79359448e30cd1d28b6c
|
||||
@@ -183,6 +183,8 @@ define("tinymce/pasteplugin/Utils", [
|
||||
|
||||
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
|
||||
|
||||
// Included from: js/tinymce/plugins/paste/classes/Clipboard.js
|
||||
|
||||
/**
|
||||
* Clipboard.js
|
||||
*
|
||||
@@ -226,6 +228,20 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
*
|
||||
* @param {String} html HTML code to paste into the current selection.
|
||||
*/
|
||||
function copyImage(src, ids) {
|
||||
ajaxPost("/file/copyHttpImage", {src: src}, function(ret) {
|
||||
if(reIsOk(ret)) {
|
||||
// 将图片替换之
|
||||
var src = urlPrefix + "/" + ret.Item;
|
||||
var dom = editor.dom
|
||||
for(var i in ids) {
|
||||
var id = ids[i];
|
||||
var imgElm = dom.get(id);
|
||||
dom.setAttrib(imgElm, 'src', src);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 粘贴HTML
|
||||
// 当在pre下时不能粘贴成HTML
|
||||
// life add text
|
||||
@@ -252,7 +268,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
dom.remove(tempBody);
|
||||
html = args.node.innerHTML;
|
||||
}
|
||||
|
||||
|
||||
if (!args.isDefaultPrevented()) {
|
||||
// life
|
||||
var node = editor.selection.getNode();
|
||||
@@ -272,7 +288,41 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
text = text.replace(/>/g, ">");
|
||||
editor.insertRawContent(text);
|
||||
} else {
|
||||
editor.insertContent(html);
|
||||
// life 这里得到图片img, 复制到leanote下
|
||||
if(!self.copyImage) {
|
||||
editor.insertContent(html);
|
||||
} else {
|
||||
var urlPrefix = UrlPrefix;
|
||||
var needCopyImages = {}; // src => [id1,id2]
|
||||
var time = (new Date()).getTime();
|
||||
try {
|
||||
var $html = $("<div>" + html + "</div");
|
||||
var $imgs = $html.find("img");
|
||||
for(var i = 0; i < $imgs.length; ++i) {
|
||||
var $img = $imgs.eq(i)
|
||||
var src = $img.attr("src");
|
||||
// 是否是外链
|
||||
if(src.indexOf(urlPrefix) == -1) {
|
||||
time++;
|
||||
var id = "__LEANOTE_IMAGE_" + time;
|
||||
$img.attr("id", id);
|
||||
if(needCopyImages[src]) {
|
||||
needCopyImages[src].push(id);
|
||||
} else {
|
||||
needCopyImages[src] = [id];
|
||||
}
|
||||
}
|
||||
}
|
||||
editor.insertContent($html.html());
|
||||
|
||||
for(var src in needCopyImages) {
|
||||
var ids = needCopyImages[src];
|
||||
copyImage(src, ids);
|
||||
}
|
||||
} catch(e) {
|
||||
editor.insertContent(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -493,7 +543,7 @@ define("tinymce/pasteplugin/Clipboard", [
|
||||
return;
|
||||
}
|
||||
// 这里, 如果图片宽度过大, 这里设置成500px
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
|
||||
var src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
|
||||
getImageSize(src, function(wh) {
|
||||
// life 4/25
|
||||
@@ -1004,6 +1054,7 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
"tinymce/pasteplugin/Quirks"
|
||||
], function(PluginManager, Clipboard, WordFilter, Quirks) {
|
||||
var userIsInformed;
|
||||
var userIsInformed2;
|
||||
|
||||
PluginManager.add('paste', function(editor) {
|
||||
var self = this, clipboard, settings = editor.settings;
|
||||
@@ -1026,6 +1077,22 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function togglePasteCopyImage() {
|
||||
if (clipboard.copyImage) {
|
||||
this.active(false);
|
||||
clipboard.copyImage = false
|
||||
} else {
|
||||
clipboard.copyImage = true;
|
||||
this.active(true);
|
||||
if (!userIsInformed2) {
|
||||
editor.windowManager.alert(
|
||||
"When copy other site's images (not in leanote) into editor, it will copy the image into your album."
|
||||
);
|
||||
userIsInformed2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.clipboard = clipboard = new Clipboard(editor);
|
||||
self.quirks = new Quirks(editor);
|
||||
@@ -1082,6 +1149,13 @@ define("tinymce/pasteplugin/Plugin", [
|
||||
onclick: togglePlainTextPaste,
|
||||
active: self.clipboard.pasteFormat == "text"
|
||||
});
|
||||
|
||||
editor.addButton('pasteCopyImage', {
|
||||
icon: 'copy',
|
||||
tooltip: "When Paste other site's image, copy it into my album as public image",
|
||||
onclick: togglePasteCopyImage,
|
||||
active: self.clipboard.copyImage === true
|
||||
});
|
||||
|
||||
editor.addMenuItem('pastetext', {
|
||||
text: 'Paste as text',
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
!function(e,t){"use strict";function n(e,t){for(var n,i=[],r=0;r<e.length;++r){if(n=s[e[r]]||a(e[r]),!n)throw"module definition dependecy not found: "+e[r];i.push(n)}t.apply(null,i)}function i(e,i,r){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(r===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=r.apply(null,arguments)})}function r(e){return!!s[e]}function a(t){for(var n=e,i=t.split(/[.\/]/),r=0;r<i.length;++r){if(!n[i[r]])return;n=n[i[r]]}return n}function o(n){for(var i=0;i<n.length;i++){for(var r=e,a=n[i],o=a.split(/[.\/]/),l=0;l<o.length-1;++l)r[o[l]]===t&&(r[o[l]]={}),r=r[o[l]];r[o[o.length-1]]=s[a]}}var s={},l="tinymce/pasteplugin/Utils",c="tinymce/util/Tools",d="tinymce/html/DomParser",p="tinymce/html/Schema",u="tinymce/pasteplugin/Clipboard",f="tinymce/Env",g="tinymce/util/VK",m="tinymce/pasteplugin/WordFilter",v="tinymce/html/Serializer",h="tinymce/html/Node",y="tinymce/pasteplugin/Quirks",b="tinymce/pasteplugin/Plugin",w="tinymce/PluginManager";i(l,[c,d,p],function(e,t,n){function i(t,n){return e.each(n,function(e){t=e.constructor==RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}function r(i){function r(e){var t=e.name,n=e;if("br"===t)return void(s+="\n");if(l[t]&&(s+=" "),c[t])return void(s+=" ");if(3==e.type&&(s+=e.value),!e.shortEnded&&(e=e.firstChild))do r(e);while(e=e.next);d[t]&&n.next&&(s+="\n","p"==t&&(s+="\n"))}var a=new n,o=new t({},a),s="",l=a.getShortEndedElements(),c=e.makeMap("script noscript style textarea video audio iframe object"," "),d=a.getBlockElements();return r(o.parse(i)),s}return{filter:i,innerText:r}}),i(u,[f,g,l],function(e,t,n){return function(i){function r(e,t){var n,r=i.dom;if(i.settings.paste_data_images||(e=e.replace(/<img[^>]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var a=r.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:a}),r.remove(a),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var o=i.selection.getNode();if("PRE"==o.nodeName){if(!t)try{t=$(e).text()}catch(s){}t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),i.insertRawContent(t)}else i.insertContent(e)}}}function a(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var a=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),a&&/^(PRE|DIV)$/.test(a.nodeName)||!o?e=n.filter(e,[[/\n/g,"<br>"]]):(e=n.filter(e,[[/\n\n/g,"</p>"+s],[/^(.*<\/p>)(<p>)$/,s+"$1"],[/\n/g,"<br />"]]),-1!=e.indexOf("<p>")&&(e=s+e)),r(e,t)}function o(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),r=i.inline?t.scrollTop:n.y,a=i.inline?t.clientHeight:n.h;s(),f=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(r+20)+"px;width: 10px; height: "+(a-40)+"px; overflow: hidden; opacity: 0"},v),e.setStyle(f,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(f,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),f.focus(),i.selection.select(f,!0)}function s(){f&&(i.dom.unbind(f),i.dom.remove(f),g&&i.selection.setRng(g)),h=!1,f=g=null}function l(){return f?f.innerHTML:v}function c(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var r=0;r<n.types.length;r++){var a=n.types[r];t[a]=n.getData(a)}}return t}function d(e,t){function n(e,n){i.parentNode.removeChild(i),t({width:e,height:n})}var i=document.createElement("img");i.onload=function(){n(i.clientWidth,i.clientHeight)},i.onerror=function(){n()},i.src=e;var r=i.style;r.visibility="hidden",r.position="fixed",r.bottom=r.left=0,r.width=r.height="auto",document.body.appendChild(i)}function p(e){var t=(e.clipboardData||e.originalEvent.clipboardData).items;log(JSON.stringify(t));for(var n,i=0;i<t.length;i++)0===t[i].type.indexOf("image")&&(n=t[i].getAsFile());if(n){var r=new FileReader;return r.onload=function(e){var t=new FormData;t.append("from","pasteImage"),t.append("file",n),t.append("noteId",Note.curNoteId);var i=tinymce.EditorManager.activeEditor,r=i.dom,a={};a.id="__mcenew",a.src="http://leanote.com/images/loading-24.gif",i.insertContent(r.createHTML("img",a));var o=r.get("__mcenew");$.ajax({url:"/file/pasteImage",contentType:!1,processData:!1,data:t,type:"POST"}).done(function(e){if(!e||"object"!=typeof e||!e.Ok)return void r.remove(o);var t=window.location.protocol+"//"+window.location.host,n=t+"/file/outputImage?fileId="+e.Id;d(n,function(e){e&&e.width&&(e.width>600&&(e.width=600),a.width=e.width,r.setAttrib(o,"width",a.width)),r.setAttrib(o,"src",n)}),r.setAttrib(o,"id",null)})},r.readAsDataURL(n),!0}return!1}vLine truncated
|
||||
!function(e,t){"use strict";function n(e,t){for(var n,i=[],a=0;a<e.length;++a){if(n=s[e[a]]||r(e[a]),!n)throw"module definition dependecy not found: "+e[a];i.push(n)}t.apply(null,i)}function i(e,i,a){if("string"!=typeof e)throw"invalid module definition, module id must be defined and be a string";if(i===t)throw"invalid module definition, dependencies must be specified";if(a===t)throw"invalid module definition, definition function must be specified";n(i,function(){s[e]=a.apply(null,arguments)})}function a(e){return!!s[e]}function r(t){for(var n=e,i=t.split(/[.\/]/),a=0;a<i.length;++a){if(!n[i[a]])return;n=n[i[a]]}return n}function o(n){for(var i=0;i<n.length;i++){for(var a=e,r=n[i],o=r.split(/[.\/]/),l=0;l<o.length-1;++l)a[o[l]]===t&&(a[o[l]]={}),a=a[o[l]];a[o[o.length-1]]=s[r]}}var s={},l="tinymce/pasteplugin/Utils",c="tinymce/util/Tools",d="tinymce/html/DomParser",p="tinymce/html/Schema",u="tinymce/pasteplugin/Clipboard",f="tinymce/Env",m="tinymce/util/VK",g="tinymce/pasteplugin/WordFilter",v="tinymce/html/Serializer",h="tinymce/html/Node",y="tinymce/pasteplugin/Quirks",b="tinymce/pasteplugin/Plugin",w="tinymce/PluginManager";i(l,[c,d,p],function(e,t,n){function i(t,n){return e.each(n,function(e){t=e.constructor==RegExp?t.replace(e,""):t.replace(e[0],e[1])}),t}function a(i){function a(e){var t=e.name,n=e;if("br"===t)return void(s+="\n");if(l[t]&&(s+=" "),c[t])return void(s+=" ");if(3==e.type&&(s+=e.value),!e.shortEnded&&(e=e.firstChild))do a(e);while(e=e.next);d[t]&&n.next&&(s+="\n","p"==t&&(s+="\n"))}var r=new n,o=new t({},r),s="",l=r.getShortEndedElements(),c=e.makeMap("script noscript style textarea video audio iframe object"," "),d=r.getBlockElements();return a(o.parse(i)),s}return{filter:i,innerText:a}}),i(u,[f,m,l],function(e,t,n){return function(i){function a(e,t){ajaxPost("/file/copyHttpImage",{src:e},function(e){if(reIsOk(e)){var n=urlPrefix+"/"+e.Item,a=i.dom;for(var r in t){var o=t[r],s=a.get(o);a.setAttrib(s,"src",n)}}})}function r(e,t){var n,r=i.dom;if(i.settings.paste_data_images||(e=e.replace(/<img[^>]+src=\"data:image[^>]+>/g,"")),n=i.fire("BeforePastePreProcess",{content:e}),n=i.fire("PastePreProcess",n),e=n.content,!n.isDefaultPrevented()){if(i.hasEventListeners("PastePostProcess")&&!n.isDefaultPrevented()){var o=r.add(i.getBody(),"div",{style:"display:none"},e);n=i.fire("PastePostProcess",{node:o}),r.remove(o),e=n.node.innerHTML}if(!n.isDefaultPrevented()){var s=i.selection.getNode();if("PRE"==s.nodeName){if(!t)try{t=$(e).text()}catch(l){}t=t.replace(/</g,"<"),t=t.replace(/>/g,">"),i.insertRawContent(t)}else if(f.copyImage){var c=UrlPrefix,d={},p=(new Date).getTime();try{for(var u=$("<div>"+e+"</div"),m=u.find("img"),g=0;g<m.length;++g){var v=m.eq(g),h=v.attr("src");if(-1==h.indexOf(c)){p++;var y="__LEANOTE_IMAGE_"+p;v.attr("id",y),d[h]?d[h].push(y):d[h]=[y]}}i.insertContent(u.html());for(var h in d){var b=d[h];a(h,b)}}catch(l){i.insertContent(e)}}else i.insertContent(e)}}}function o(e){var t=e;e=i.dom.encode(e).replace(/\r\n/g,"\n");var a=i.dom.getParent(i.selection.getStart(),i.dom.isBlock),o=i.settings.forced_root_block,s;o&&(s=i.dom.createHTML(o,i.settings.forced_root_block_attrs),s=s.substr(0,s.length-3)+">"),a&&/^(PRE|DIV)$/.test(a.nodeName)||!o?e=n.filter(e,[[/\n/g,"<br>"]]):(e=n.filter(e,[[/\n\n/g,"</p>"+s],[/^(.*<\/p>)(<p>)$/,s+"$1"],[/\n/g,"<br />"]]),-1!=e.indexOf("<p>")&&(e=s+e)),r(e,t)}function s(){var e=i.dom,t=i.getBody(),n=i.dom.getViewPort(i.getWin()),a=i.inline?t.scrollTop:n.y,r=i.inline?t.clientHeight:n.h;l(),m=e.add(i.getBody(),"div",{id:"mcepastebin",contentEditable:!0,"data-mce-bogus":"1",style:"position: absolute; top: "+(a+20)+"px;width: 10px; height: "+(r-40)+"px; overflow: hidden; opacity: 0"},h),e.setStyle(m,"left","rtl"==e.getStyle(t,"direction",!0)?65535:-65535),e.bind(m,"beforedeactivate focusin focusout",function(e){e.stopPropagation()}),g=i.selection.getRng(),m.focus(),i.selection.select(m,!0)}function l(){m&&(i.dom.unbind(m),i.dom.remove(m),g&&i.selection.setRng(g)),y=!1,m=g=null}function c(){return m?m.innerHTML:h}function d(e){var t={},n=e.clipboardData||i.getDoc().dataTransfer;if(n&&n.types){t["text/plain"]=n.getData("Text");for(var a=0;a<n.types.length;a++){var r=n.types[a];t[r]=n.getData(r)}}return t}function p(e,t){function n(e,n){i.parentNode.removeChild(i),t({width:e,height:n})}var i=document.createElement("img");i.onload=function(){n(i.clientWidth,i.clientHeight)},i.onerror=function(){n()},i.src=e;var a=i.style;a.visibility="hidden",a.position="fixed",a.bottom=a.left=0,a.width=a.height="auto",document.body.appendChild(i)}function u(e){var t=(e.clipboardData||e.originalEvent.clipboardData).items;log(JSON.stringify(t));for(var n,i=0;i<t.length;i++)0===t[i].type.indexOf("image")&&(n=t[i].getAsFile());if(n){var a=new FileReader;return a.onload=function(e){var t=new FormData;t.append("from","pasteImage"),t.append("file",n),t.append("noteId",Note.curNoteId);var i=tinymce.EditorManager.activeEditor,a=i.dom,r={};r.id="__mcenew",r.src="http://leano
Line truncated
|
||||
Reference in new issue
Block a user