v1.0 beta init
This commit is contained in:
@ -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 @@
|
||||
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 @@
|
||||
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',
|
||||
|
2
public/tinymce/plugins/paste/plugin.min.js
vendored
2
public/tinymce/plugins/paste/plugin.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user