Commit 661b9e68 authored by Liang's avatar Liang

🐛 fixed #12282

parent 9a4cf0e7
This diff is collapsed.
......@@ -22,8 +22,9 @@
*/
Util.processClipBoard = function (text, cm) {
var text = toMarkdown(text, {converters: [
], gfm: true});
var text = toMarkdown(text, {
converters: [], gfm: true
});
// ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
......@@ -49,7 +50,8 @@ Util.processClipBoard = function (clipboardData, cm) {
return '';
}
var text = toMarkdown(clipboardData.getData("text/html"), {converters: [
var text = toMarkdown(clipboardData.getData("text/html"), {
converters: [
{
filter: 'img',
replacement: function (innerHTML, node) {
......@@ -59,7 +61,19 @@ Util.processClipBoard = function (clipboardData, cm) {
return "![](" + node.src + ")";
}
}
], gfm: true});
], gfm: true
});
// code 中 <, > 进行转义
var codes = text.split('```');
if (codes.length > 1) {
for (var i = 0, iMax = codes.length; i < iMax; i++) {
if (i % 2 === 1) {
codes[i] = codes[i].replace(/<\/span><span style="color:#\w{6};">/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
}
}
text = codes.join('```');
// ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
......@@ -104,8 +118,10 @@ Util.initUploadFile = function (obj) {
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename});
data.push({
name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename
});
data.push({name: 'token', value: obj.qiniuUploadToken});
......@@ -228,7 +244,10 @@ admin.editors.CodeMirror = {
{name: 'link'},
{name: 'unordered-list'},
{name: 'ordered-list'},
{name: 'image', html: '<span style="display: inline-block;top:1px" class="tooltipped tooltipped-n" aria-label="' + Label.uploadFilesLabel + '" ><form id="' + conf.id + 'fileUpload" method="POST" enctype="multipart/form-data"><label class="icon-upload"><input type="file"/></label></form></span>'},
{
name: 'image',
html: '<span style="display: inline-block;top:1px" class="tooltipped tooltipped-n" aria-label="' + Label.uploadFilesLabel + '" ><form id="' + conf.id + 'fileUpload" method="POST" enctype="multipart/form-data"><label class="icon-upload"><input type="file"/></label></form></span>'
},
{name: 'redo'},
{name: 'undo'},
{name: 'preview'},
......
......@@ -612,12 +612,13 @@ admin.editors.KindEditor = {
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.1.4, Jan 21, 2017
* @version 1.4.2.4, Apr 25, 2017
*/
Util.processClipBoard = function (text, cm) {
var text = toMarkdown(text, {converters: [
], gfm: true});
var text = toMarkdown(text, {
converters: [], gfm: true
});
// ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
......@@ -643,7 +644,8 @@ Util.processClipBoard = function (clipboardData, cm) {
return '';
}
var text = toMarkdown(clipboardData.getData("text/html"), {converters: [
var text = toMarkdown(clipboardData.getData("text/html"), {
converters: [
{
filter: 'img',
replacement: function (innerHTML, node) {
......@@ -653,7 +655,19 @@ Util.processClipBoard = function (clipboardData, cm) {
return "![](" + node.src + ")";
}
}
], gfm: true});
], gfm: true
});
// code 中 <, > 进行转义
var codes = text.split('```');
if (codes.length > 1) {
for (var i = 0, iMax = codes.length; i < iMax; i++) {
if (i % 2 === 1) {
codes[i] = codes[i].replace(/<\/span><span style="color:#\w{6};">/g, '').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}
}
}
text = codes.join('```');
// ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
......@@ -698,8 +712,10 @@ Util.initUploadFile = function (obj) {
formData: function (form) {
var data = form.serializeArray();
data.push({name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename});
data.push({
name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename
});
data.push({name: 'token', value: obj.qiniuUploadToken});
......@@ -818,17 +834,16 @@ admin.editors.CodeMirror = {
toolbar: [
{name: 'bold'},
{name: 'italic'},
'|',
{name: 'quote'},
{name: 'link'},
{name: 'unordered-list'},
{name: 'ordered-list'},
'|',
{name: 'link'},
{name: 'image', html: '<form id="' + conf.id + 'fileUpload" method="POST" enctype="multipart/form-data"><label class="icon-upload"><input type="file"/></label></form>'},
'|',
{
name: 'image',
html: '<span style="display: inline-block;top:1px" class="tooltipped tooltipped-n" aria-label="' + Label.uploadFilesLabel + '" ><form id="' + conf.id + 'fileUpload" method="POST" enctype="multipart/form-data"><label class="icon-upload"><input type="file"/></label></form></span>'
},
{name: 'redo'},
{name: 'undo'},
'|',
{name: 'preview'},
{name: 'fullscreen'}],
extraKeys: {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment