【发布时间】:2015-09-19 06:08:55
【问题描述】:
目前在我们正在构建的 web cms 中,我们允许用户包含任意内容(无论是纯文本还是任何 html 内容)以显示在网站的任何部分。这些块称为小部件(显然,出于安全目的,我们会采取措施清理它们)。
我希望能够在必要时突出显示这些块以进行调试,但是我不能将它们包装在任何其他元素(例如 div)中,因为它可能会破坏布局。我在这个网站上发现了几个问题,对同一个问题进行了重新评分,但还没有任何好的解决方案。
如果我们被允许使用某种非布局元素(例如评论标签)来包裹内容块以能够执行一些操作(例如像这样突出显示),那就太好了,但我没有找到任何方法来做到这一点。
我对任何解决方案(js、基于服务器等)都很满意,只要它允许我在不破坏布局的情况下勾勒出任何内容块。如果您有任何建议,请告诉我。
小部件内容的几个示例:
纯文本小部件:
this is a the content of text only widget, there is also no wrapper here.
HTML 小部件:
<h1>Hello world </h1>
<section class="content">
The problem here is that we do not want to force the users to
always wrap their contents inside a root element.
In this example you can see that the content contains 1 h1 element
and 1 section element. To outline this whole widget we may need to
wrap it by an outer element which may break the layout.
</section>
【问题讨论】:
-
您如何识别它们以进行清理?
标签: javascript html css