relative image url/fix conflict when upload attachment again

This commit is contained in:
lealife
2016-12-24 15:16:23 +08:00
parent f49624d3eb
commit a8dd578624
24 changed files with 130 additions and 106 deletions

File diff suppressed because one or more lines are too long

View File

@ -523,8 +523,8 @@ function initEditor() {
// fix TinyMCE Removes site base url
// http://stackoverflow.com/questions/3360084/tinymce-removes-site-base-urls
convert_urls:true,
relative_urls:false,
convert_urls: false, // true会将url变成../api/
relative_urls: true,
remove_script_host:false,
selector : "#editorContent",

View File

@ -1 +1 @@
var MSG={"noTag":"Keine Tags","saveSuccess":"Speichern erfolgreich","none":"Keine","like":"Gefällt mir","unlike":"Gefällt mir nicht mehr","delete":"Löschen","cancel":"Abbrechen","confirm":"Bestätigen","chooseReason":"Grund angeben","reportSuccess":"Erfolg","error":"Fehler","reportComment?":"Kommentar?","reportBlog?":"Blog?","confirmDeleteComment":"Wirklich löschen?","scanQRCode":"weichat öffnen und QR Code scannen","justNow":"Jetzt","minutesAgo":"Minuten","hoursAgo":"Stunden","daysAgo":"Tage","weeksAgo":"Wochen","monthsAgo":"Monate"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
var MSG={"noTag":"Keine Tags","saveSuccess":"Speichern erfolgreich","none":"Keine","like":"Gefällt mir","unlike":"Gefällt mir nicht mehr","delete":"Löschen","cancel":"Abbrechen","confirm":"Bestätigen","chooseReason":"请选择举报理由","reportSuccess":"举报成功, 我们处理后会通知作者, 感谢您的监督","error":"Error","reportComment?":"举报该评论?","reportBlog?":"举报该博客?","confirmDeleteComment":"Sind Sie sicher?","scanQRCode":"Öffnen Sie weichat und scannen den QR Code","justNow":"Jetz","minutesAgo":"Minuten","hoursAgo":"Stunden","daysAgo":"Tage","weeksAgo":"Wochen","monthsAgo":"Monate"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}

View File

@ -1 +1 @@
var MSG={"noTag":"No tag","saveSuccess":"Save success","none":"None","like":"Like","unlike":"Unlike","delete":"Delete","cancel":"Cancel","confirm":"Confirm","chooseReason":"请选择举报理由","reportSuccess":"举报成功, 我们处理后会通知作者, 感谢您的监督","error":"Error","reportComment?":"举报该评论?","reportBlog?":"举报该博客?","confirmDeleteComment":"Are you sure?","scanQRCode":"Open weichat and scan the QR code","justNow":"Just now","minutesAgo":"minutes ago","hoursAgo":"hours ago","daysAgo":"days ago","weeksAgo":"weeks ago","monthsAgo":"months ago"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}
var MSG={"noTag":"No tag","saveSuccess":"Save success","none":"None","like":"Like","unlike":"Unlike","delete":"Delete","cancel":"Cancel","confirm":"Confirm","chooseReason":"Select report reason","reportSuccess":"Reporting success, we will notify the author, thank you for your monitor","error":"Error","reportComment?":"Report this comment?","reportBlog?":"Report this blog?","confirmDeleteComment":"Are you sure?","scanQRCode":"Open weichat and scan the QR code","justNow":"Just now","minutesAgo":"minutes ago","hoursAgo":"hours ago","daysAgo":"days ago","weeksAgo":"weeks ago","monthsAgo":"months ago"};function getMsg(key, data) {var msg = MSG[key];if(msg) {if(data) {if(!isArray(data)) {data = [data];}for(var i = 0; i < data.length; ++i) {msg = msg.replace("%s", data[i]);}}return msg;}return key;}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,5 @@
// for editor.
// drag image to editor
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
define('editor_drop_paste', ['fileupload'], function() {
// 在toggle成pre或ace时
@ -125,8 +124,7 @@ define('editor_drop_paste', ['fileupload'], function() {
(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;
data.src = urlPrefix + "/api/file/getImage?fileId=" + re.Id;
data.src = "/api/file/getImage?fileId=" + re.Id;
}
renderImage(data);
});
@ -180,7 +178,7 @@ define('editor_drop_paste', ['fileupload'], function() {
if (data.result.Ok == true) {
data.context.remove();
// life
var data2 = {src: urlPrefix + "/api/file/getImage?fileId=" + data.result.Id}
var data2 = {src: "/api/file/getImage?fileId=" + data.result.Id}
insertImage(data2);
} else {
data.context.empty();
@ -339,80 +337,20 @@ define('editor_drop_paste', ['fileupload'], function() {
data.process = process;
var jqXHR = data.submit();
}, 20);
/*
d.id = '__mcenew' + (new Date()).getTime();
d.src = "http://leanote.com/images/loading-24.gif"; // 写死了
var img = '<img src="' + d.src + '" id="' + d.id + '" />';
editor.insertContent(img);
var imgElm = $(d.id);
data.imgId = d.id;
data.context = imgElm;
*/
/*
// 上传之
var c = new FormData;
c.append("from", "pasteImage");
// var d;
// d = $.ajaxSettings.xhr();
// d.withCredentials = i;var d = {};
// 先显示loading...
var editor = tinymce.EditorManager.activeEditor;
var dom = editor.dom;
var d = {};
d.id = '__mcenew';
d.src = "http://leanote.com/images/loading-24.gif"; // 写死了
editor.insertContent(dom.createHTML('img', d));
var imgElm = dom.get('__mcenew');
$.ajax({url: "/file/pasteImage", contentType:false, processData:false , data: c, type: "POST"}
).done(function(re) {
if(!re || typeof re != "object" || !re.Ok) {
// 删除
dom.remove(imgElm);
return;
}
// 这里, 如果图片宽度过大, 这里设置成500px
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
var src = urlPrefix + "/api/file/getImage?fileId=" + re.Id;
getImageSize(src, function(wh) {
// life 4/25
if(wh && wh.width) {
if(wh.width > 600) {
wh.width = 600;
}
d.width = wh.width;
dom.setAttrib(imgElm, 'width', d.width);
}
dom.setAttrib(imgElm, 'src', src);
});
dom.setAttrib(imgElm, 'id', null);
});
};
reader.readAsDataURL(blob);
*/
},
done: function(e, data) {
if (data.result.Ok == true) {
// 这里, 如果图片宽度过大, 这里设置成500px
var re = data.result;
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
var src = urlPrefix + "/api/file/getImage?fileId=" + re.Id;
var src = "/api/file/getImage?fileId=" + re.Id;
if(curNote && !curNote.IsMarkdown) {
data.process.replace(src);
} else {
MD && MD.insertLink(src, 'title', true);
}
/*
getImageSize(src, function() {
$img.attr('src', src);
$img.removeAttr('id');
});
*/
} else {
data.process.remove();
}

File diff suppressed because one or more lines are too long