1

摘要:我想问的是——我们是否以完全错误的方式来解决这个问题,或者,有没有办法阻止 Sharepoint 或其富编辑器修改添加的 HTML?

我已经被“投入”到一个围绕 Sharepoint 2007 的项目中(相信我,我对此并不完全满意),其中一件事是使用丰富内容区域的方法用户放入“丰富的内容”,然后在内容中添加某些“附加内容”,例如可扩展的内容区域、对话框等。

最初的攻击计划是在 Sharepoint 富内容编辑器工具栏中添加一个自定义按钮,我们有代码来执行此操作,并且它可以工作等,并将 javascript 事件处理程序附加到某些元素 - 这也可以工作 - 到一个点。

我们正在做的一件事是使用一个<a>元素和一个后续元素<div>来设置一个对话框(使用 jQuery UI 来发挥作用)。当用户单击“插入对话框”按钮时,以下内容将插入到编辑器中:

<a href="#" class="dialog-trigger">Click me to open the dialog</a>
<div class="dialog-content">
    this is some dialog content etc
</div>

当页面加载时,我们挂钩 .dialog-trigger click 方法,获取a元素的兄弟元素 a.dialog-content并将其设置为对话框。只要您不想编辑任何内容,这“有效”。

我发现,只要您开始在.dialog-contentDIV 中编辑内容,内容丰富的编辑器就会开始编辑 HTML,例如,添加一个列表会添加以下 HTML:

<li><div class=dialog-content>Some list item</div></li>
<li><div class=dialog-content>Some list item 2</div></li>
<li><div class=dialog-content>Another list item</div></li>

正如你可以想象的那样,这种破坏了我们正在尝试做的事情。

总结一下我要问的问题 - 我们是否以完全错误的方式解决这个问题,或者,有没有办法阻止 Sharepoint 或其富编辑器修改添加的 HTML?

4

2 回答 2

0

If you're just putting the HTML as it is into the editor content, you won't be able to stop the editor from messing with your HTML. If you have some content that must be kept intact then you need to store it somewhere else and have a placeholder for it in the editor that contains an ID for the actual piece of content (e.g. a placeholder image with the ID in the alt attribute). You'll need to replace such placeholders with the real HTML content when the editor saves and vice versa when the editor loads.

于 2009-10-22T09:11:32.747 回答
0

我感受到了您的痛苦,与其他开源解决方案相比,SharePoint 的富文本编辑器并不是最好的。无论如何,也许您可​​以训练您的用户使用预定义的样式?然后使用 JQuery 做事。

如果您在 CSS 中执行以下操作

/*.ms-rteCustom-anything else you want*/
/*e.g.*/
.ms-rteCustom-DialogTrigger {
    color:#333333
}

现在共享点编辑器将在 Styles 下显示“DialogTrigger”并将其应用为 div。

或者,您可以在技术上使用另一个编辑器,并使用SPAPI或 JQuery + SharePoint Web服务将数据发布回SharePoint。

于 2010-03-07T04:49:21.313 回答