|
editor.js
- case 'pasteword':
- pasteWord($(ctrlid + '_param_1').contentWindow.document.body.innerHTML);
- hideMenu('', 'win');
- break;
- case 'index':
- if (wysiwyg) {
- str = '';
- } else {
- str = '';
- }
- insertText(str, str.length, 0, false, sel);
- hideMenu('', 'win');
- break;
复制代码 以下为pasteWord函数的定义, 若将其中[^ |>] 改为[^>] 即可解决上述问题- 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);
- }
- }
复制代码 |
|