2

我正在使用 tinyMCE,您可以在下面看到实现。现在的问题是:当我从 EXCEL 复制一些记录并将它们粘贴到我的 tinymce 字段中时。它对我来说已经足够好(使用插件:粘贴,他实际上会显示字段)当我从我的字段中询问值时,我会得到一个表结构的返回值,该表结构取决于你粘贴的内容。但我不想要任何 html,请看下面我想要的。

实现代码:

tinyMCE.init({ 
mode : "exact", 
elements: "id", 
theme : "advanced", 
plugins : "bbcode, inlinepopups", 
content_css : "tinymce.css", 
entity_encoding : "raw", 
remove_linebreaks : false, 
forced_root_block: false, 
force_br_newlines: true, 
invalid_elements : "p, div, span", 
force_p_newlines: false, t
heme_advanced_buttons1 : $cur_buttons, 
theme_advanced_buttons2: "", 
theme_advanced_buttons3: "", 
init_instance_callback : "tiny_mce_callback"});

从 tinyMCE 对象返回:

<table style="border-collapse: collapse;" width="216" border="0"
       cellspacing="0" cellpadding="0">
<!--StartFragment-->
<colgroup>
  <col style="mso-width-source: userset; mso-width-alt: 1152;" width="27"/>
  <col width="55" />
  <col style="mso-width-source: userset; mso-width-alt: 2858;"
       span="2" width="67"/>
</colgroup>
<tbody>
<tr style="mso-height-source: userset;">
<td class="xl24" width="27" height="12">1</td>
<td class="xl26" width="55">26/05/12</td>
<td class="xl24" width="67">Amsterdam</td>
<td class="xl24" width="67">Casablanca</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">2</td>
<td class="xl25">27/05/12</td>
<td class="xl24">Casablanca</td>
<td class="xl24">Rabat</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">3</td>
<td class="xl25">28/05/12</td>
<td class="xl24">Rabat</td>
<td class="xl24">Fes</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">4</td>
<td class="xl25">29/05/12</td>
<td class="xl24">Fes</td>
<td class="xl24"> </td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">5</td>
<td class="xl25">30/05/12</td>
<td class="xl24">Fes</td>
<td class="xl24">Erg Chebbi</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">6</td>
<td class="xl25">31/05/12</td>
<td class="xl24">Erg Chebbi</td>
<td class="xl24">Dades Vallei</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">7</td>
<td class="xl25">01/06/12</td>
<td class="xl24">Dades Vallei</td>
<td class="xl24">Ouarzazate</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">8</td>
<td class="xl25">02/06/12</td>
<td class="xl24">Ouarzazate</td>
<td class="xl24">Marrakesh</td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">9</td>
<td class="xl25">03/06/12</td>
<td class="xl24">Marrakesh</td>
<td class="xl24"> </td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">10</td>
<td class="xl25">04/06/12</td>
<td class="xl24">Marrakesh</td>
<td class="xl24"> </td>
</tr>
<tr style="mso-height-source: userset;">
<td class="xl24" height="12">11</td>
<td class="xl25">05/06/12</td>
<td class="xl24">Marrakesh</td>
<td class="xl24">Amsterdam</td>
</tr>
<!--EndFragment--></tbody>
</table>

预期收益:

1   26/05/12    Amsterdam   Casablanca
2   27/05/12    Casablanca  Rabat
3   28/05/12    Rabat   Fes
4   29/05/12    Fes 
5   30/05/12    Fes Erg Chebbi
6   31/05/12    Erg Chebbi  Dades Vallei
7   01/06/12    Dades Vallei    Ouarzazate
8   02/06/12    Ouarzazate  Marrakesh
9   03/06/12    Marrakesh   
10  04/06/12    Marrakesh   
11  05/06/12    Marrakesh   Amsterdam
4

1 回答 1

0

您应该查看有关 paste 插件的tinymce 配置选项。

另一种选择是去掉所有不需要的 html 标签,只使用纯文本:TinyMCE 粘贴为纯文本

于 2012-05-04T13:17:57.513 回答