为什么SP2010中的WYSIWYG编辑器会不断添加不需要的<p>标签?</p>

时间:2011-09-23 14:29:06

标签: sharepoint-2010 editor wysiwyg

我有posted this already once但是,没有得到我认为是解决方案的任何好选择。根本不使用WYSIWYG编辑器是“不好”的解决方案。

无论使用何种浏览器,编辑器都会在未经我同意的情况下添加和删除HTML。以下是一些例子:

在“页面内容”区域内进行编辑时(完全空白,还没有HTML)我插入了一个“可重用内容”对象并点击我的回车键进行回车。代码如下:

<p><span class="ms-reusableTextView ms-rtestate-read" id="__publishingReusableFragment" contenteditable="false" fragmentid="/ReusableContent/4_.000"><p><img src="/Style%20Library/Images/company_logo.jpg" alt="" style="margin: 5px"/></p>
    <table class="ms-rteTable-default" cellspacing="2" cellpadding="3" style="border-bottom: 0px; border-left: 0px; background-color: #840039; width: 750px; font-size: 1em; border-top: 0px"><tbody><tr><td width="66%">&#160;</td>
    <td width="8%"><a href="/pages/faq.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> FAQs</a> </td>
    <td width="17%"><a href="/pages/security.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Account Security</a> </td>
    <td width="9%"><a href="/pages/home.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Home</a> </td></tr></tbody></table></span></p>
    <p>&#160;</p>

现在,陌生感开始了。如果我输入一些文字,比如“Hello world!”然后说我点击“字体颜色”的图标。如果我将鼠标移到调色板上,对于每种颜色,我将鼠标悬停在其中包含&#160;<p>&#160;</p>的代码行中。因此,例如,代码在将鼠标悬停在颜色上后现在看起来像这样(同样,无论使用什么图标,我都碰巧使用字体颜色):

<p><span class="ms-reusableTextView ms-rtestate-read" id="__publishingReusableFragment" contenteditable="false" fragmentid="/ReusableContent/4_.000"><p><img src="/Style%20Library/Images/company_logo.jpg" alt="" style="margin: 5px"/></p>
    <table class="ms-rteTable-default" cellspacing="2" cellpadding="3" style="border-bottom: 0px; border-left: 0px; background-color: #840039; width: 750px; font-size: 1em; border-top: 0px"><tbody><tr><td width="66%">&#160;</td>
    <td width="8%"><a href="/pages/faq.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> FAQs</a> </td>
    <td width="17%"><a href="/pages/security.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Account Security</a> </td>
    <td width="9%"><a href="/pages/home.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Home</a> </td></tr></tbody></table></span>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    &#160;<p>&#160;</p>
    <p>&#160;</p>
    <p>Hello world!</p>

所以,我第二次尝试摆脱这种奇怪的行为是遵循我给出的建议。该建议是添加“可重用内容”对象,创建回车符,然后输入“内容编辑器”Web部件。这导致完全不同的错误发生,因此也不起作用。基本上代码如下(在点击Save&amp; Close之前):

<p><span class="ms-reusableTextView ms-rtestate-read" id="__publishingReusableFragment" contenteditable="false" fragmentid="/ReusableContent/4_.000"><p><img src="/Style%20Library/Images/company_logo.jpg" alt="" style="margin: 5px"/></p>
    <table class="ms-rteTable-default" cellspacing="2" cellpadding="3" style="border-bottom: 0px; border-left: 0px; background-color: #840039; width: 750px; font-size: 1em; border-top: 0px"><tbody><tr><td width="66%">&#160;</td>
    <td width="8%"><a href="/pages/faq.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> FAQs</a> </td>
    <td width="17%"><a href="/pages/security.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Account Security</a> </td>
    <td width="9%"><a href="/pages/home.htm" style="color: #ffffff; font-size: 10px; font-weight: normal; text-decoration: none"><img width="11" height="11" src="/Style%20Library/Images/bullet_square_grey.jpg" border="0" alt=""/> Home</a> </td></tr></tbody></table></span>&#160;</p>
    <p>&#160;</p>
    <p>&#160;</p>
    <div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false"><div class="ms-rtestate-notify  ms-rtestate-read 7899d743-6ee1-4a15-b1b1-2462bb804e6a" id="div_7899d743-6ee1-4a15-b1b1-2462bb804e6a"></div>
    <div id="vid_7899d743-6ee1-4a15-b1b1-2462bb804e6a" style="display: none"></div></div>
    <p>&#160;</p>

但是,当我点击“保存并关闭”时,它会将代码转换为以下内容:

<div id="__publishingReusableFragmentIdSection"><a href="/ReusableContent/4_.000">a</a></div>
    <p><span id="__publishingReusableFragment"></span>&#160;</p>
    <p>&#160;</p>
    <p>&#160;</p>
    <div class="ms-rtestate-read ms-rte-wpbox" contenteditable="false"><div class="ms-rtestate-notify  ms-rtestate-read 7899d743-6ee1-4a15-b1b1-2462bb804e6a" id="div_7899d743-6ee1-4a15-b1b1-2462bb804e6a"></div>
    <span id="__publishingReusableFragment"></span><div id="vid_7899d743-6ee1-4a15-b1b1-2462bb804e6a" style="display: none">&#160;</div></div>
    <p>&#160;</p>

目前我对如何纠正这个问题感到茫然。由于这是开箱即用的功能,我不确定为什么我似乎是唯一一个遇到此问题的人。这已在多台计算机,服务器场和浏览器上经过测试和验证。我真的可以在这里使用一些帮助。

0 个答案:

没有答案