某些站点的编辑器中可能会出现word粘贴功能不能正常使用的问题,特给出以下解决方法:
该方法可能不一定完全解决你的问题,如果不能解决,请跟帖询问
打开文件:\static\js\edit.js
查找:- function pasteWord(str) {
- var mstest = /<\w[^>]* class="?[MsoNormal|xl]"?/gi;
- if(mstest.test(str)){
- str = str.replace(/<!--\[if[\s\S]+?<!\[endif\]-->/gi, "");
- str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
- str = str.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, function ($1, $2, $3, $4) {
- var style = '';
- re = new RegExp('(^|[;\\s])color:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'color:' + match[2] + ';';
- }
- re = new RegExp('(^|[;\\s])text-indent:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'text-indent:' + parseInt(parseInt(match[2]) / 10) + 'em;';
- }
- re = new RegExp('(^|[;\\s])font-size:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'font-size:' + match[2] + ';';
- }
- if(style) {
- style = ' style="' + style + '"';
- }
- return '<' + $2 + style + $4;
- });
- str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
- str = str.replace(/<\\?\?xml[^>]*>/gi, "");
- str = str.replace(/<\/?\w+:[^>]*>/gi, "");
- str = str.replace(/ /, " ");
- var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)", 'ig');
- str = str.replace(re, "<div$2</div>");
- if(!wysiwyg) {
- str = html2bbcode(str);
- }
- insertText(str, str.length, 0);
- }
- }
复制代码 替换为:- function pasteWord(str) {
- var mstest = /<\w[^>]* class="?[MsoNormal|xl]"?/gi;
- //if(mstest.test(str)){
- str = str.replace(/<!--\[if[\s\S]+?<!\[endif\]-->/gi, "");
- str = str.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3");
- str = str.replace(/<(\w[^>]*) style="([^"]*)"([^>]*)/gi, function ($1, $2, $3, $4) {
- var style = '';
- re = new RegExp('(^|[;\\s])color:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'color:' + match[2] + ';';
- }
- re = new RegExp('(^|[;\\s])text-indent:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'text-indent:' + parseInt(parseInt(match[2]) / 10) + 'em;';
- }
- re = new RegExp('(^|[;\\s])font-size:\\s*([^;]+);?', 'ig');
- match = re.exec($3);
- if(match != null) {
- style += 'font-size:' + parseInt(match[2]) + 'pt;';
- }
- if(style) {
- style = ' style="' + style + '"';
- }
- return '<' + $2 + style + $4;
- });
- str = str.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3");
- str = str.replace(/<\\?\?xml[^>]*>/gi, "");
- str = str.replace(/<\/?\w+:[^>]*>/gi, "");
- str = str.replace(/ /, " ");
- var re = new RegExp("(<P)([^>]*>.*?)(<\/P>)", 'ig');
- str = str.replace(re, "<div$2</div>");
- if(!wysiwyg) {
- str = html2bbcode(str);
- }
- insertText(str, str.length, 0);
- //}
- }
复制代码 |