Commit 661b9e68 authored by Liang's avatar Liang

🐛 fixed #12282

parent 9a4cf0e7
This diff is collapsed.
...@@ -22,8 +22,9 @@ ...@@ -22,8 +22,9 @@
*/ */
Util.processClipBoard = function (text, cm) { Util.processClipBoard = function (text, cm) {
var text = toMarkdown(text, {converters: [ var text = toMarkdown(text, {
], gfm: true}); converters: [], gfm: true
});
// ascii 160 替换为 30 // ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' '); text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
...@@ -49,7 +50,8 @@ Util.processClipBoard = function (clipboardData, cm) { ...@@ -49,7 +50,8 @@ Util.processClipBoard = function (clipboardData, cm) {
return ''; return '';
} }
var text = toMarkdown(clipboardData.getData("text/html"), {converters: [ var text = toMarkdown(clipboardData.getData("text/html"), {
converters: [
{ {
filter: 'img', filter: 'img',
replacement: function (innerHTML, node) { replacement: function (innerHTML, node) {
...@@ -59,7 +61,19 @@ Util.processClipBoard = function (clipboardData, cm) { ...@@ -59,7 +61,19 @@ Util.processClipBoard = function (clipboardData, cm) {
return "![](" + node.src + ")"; 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 // ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' '); text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
...@@ -104,8 +118,10 @@ Util.initUploadFile = function (obj) { ...@@ -104,8 +118,10 @@ Util.initUploadFile = function (obj) {
formData: function (form) { formData: function (form) {
var data = form.serializeArray(); var data = form.serializeArray();
data.push({name: 'key', value: "file/" + (new Date()).getFullYear() + "/" data.push({
+ ((new Date()).getMonth() + 1) + '/' + filename}); name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename
});
data.push({name: 'token', value: obj.qiniuUploadToken}); data.push({name: 'token', value: obj.qiniuUploadToken});
...@@ -228,7 +244,10 @@ admin.editors.CodeMirror = { ...@@ -228,7 +244,10 @@ admin.editors.CodeMirror = {
{name: 'link'}, {name: 'link'},
{name: 'unordered-list'}, {name: 'unordered-list'},
{name: 'ordered-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: 'redo'},
{name: 'undo'}, {name: 'undo'},
{name: 'preview'}, {name: 'preview'},
......
...@@ -612,12 +612,13 @@ admin.editors.KindEditor = { ...@@ -612,12 +612,13 @@ admin.editors.KindEditor = {
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</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) { Util.processClipBoard = function (text, cm) {
var text = toMarkdown(text, {converters: [ var text = toMarkdown(text, {
], gfm: true}); converters: [], gfm: true
});
// ascii 160 替换为 30 // ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' '); text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
...@@ -643,7 +644,8 @@ Util.processClipBoard = function (clipboardData, cm) { ...@@ -643,7 +644,8 @@ Util.processClipBoard = function (clipboardData, cm) {
return ''; return '';
} }
var text = toMarkdown(clipboardData.getData("text/html"), {converters: [ var text = toMarkdown(clipboardData.getData("text/html"), {
converters: [
{ {
filter: 'img', filter: 'img',
replacement: function (innerHTML, node) { replacement: function (innerHTML, node) {
...@@ -653,7 +655,19 @@ Util.processClipBoard = function (clipboardData, cm) { ...@@ -653,7 +655,19 @@ Util.processClipBoard = function (clipboardData, cm) {
return "![](" + node.src + ")"; 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 // ascii 160 替换为 30
text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' '); text = $('<div>' + text + '</div>').text().replace(/\n{2,}/g, '\n\n').replace(/ /g, ' ');
...@@ -698,8 +712,10 @@ Util.initUploadFile = function (obj) { ...@@ -698,8 +712,10 @@ Util.initUploadFile = function (obj) {
formData: function (form) { formData: function (form) {
var data = form.serializeArray(); var data = form.serializeArray();
data.push({name: 'key', value: "file/" + (new Date()).getFullYear() + "/" data.push({
+ ((new Date()).getMonth() + 1) + '/' + filename}); name: 'key', value: "file/" + (new Date()).getFullYear() + "/"
+ ((new Date()).getMonth() + 1) + '/' + filename
});
data.push({name: 'token', value: obj.qiniuUploadToken}); data.push({name: 'token', value: obj.qiniuUploadToken});
...@@ -818,17 +834,16 @@ admin.editors.CodeMirror = { ...@@ -818,17 +834,16 @@ admin.editors.CodeMirror = {
toolbar: [ toolbar: [
{name: 'bold'}, {name: 'bold'},
{name: 'italic'}, {name: 'italic'},
'|',
{name: 'quote'}, {name: 'quote'},
{name: 'link'},
{name: 'unordered-list'}, {name: 'unordered-list'},
{name: 'ordered-list'}, {name: 'ordered-list'},
'|', {
{name: 'link'}, name: 'image',
{name: 'image', html: '<form id="' + conf.id + 'fileUpload" method="POST" enctype="multipart/form-data"><label class="icon-upload"><input type="file"/></label></form>'}, 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: 'redo'},
{name: 'undo'}, {name: 'undo'},
'|',
{name: 'preview'}, {name: 'preview'},
{name: 'fullscreen'}], {name: 'fullscreen'}],
extraKeys: { 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