tinyMCE编辑器删除div元素中的自定义标签

时间:2012-08-07 08:51:43

标签: tinymce custom-tag

我需要在tinyMCE中添加一些自定义标签。如果它们仅在body标签中就可以了,但是如果我将它们放入div标签中,那么编辑器会删除它。这是一个例子:

我需要添加“unsubthis”标签,所以我有这个配置文件

  <script type="text/javascript">
  tinyMCE.init({
  mode: "textareas",
  verify_html : false,
  skin: "o2k7",
  theme: "advanced",
  entity_encoding: "raw",
  plugins: "fullpage,safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
  theme_advanced_buttons1: "newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
  theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
  theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
  theme_advanced_buttons4: "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
  theme_advanced_toolbar_location: "top",
  theme_advanced_statusbar_location: "bottom",
  theme_advanced_toolbar_align: "left",      
  custom_elements: "unsubthis",
  valid_children: "+div[unsubthis]",
  extended_valid_elements: "unsubthis"
});

如果我打开编辑器并将其放入HTML

<html>
<head>
<title>Document Title 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
   <unsubthis></unsubthis>
</body>
</html>

然后更新然后一切都很好,如果我查看HTML,代码看起来一样。如果我尝试将HTML放入HTML中,就会出现问题:

<html>
<head>
<title>Document Title 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <div>
      <unsubthis></unsubthis>
    </div>
</body>
</html>

然后,在更新后,unsubthis将被删除,我将获得此代码

<html>
<head>
<title>Document Title 1</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
    <div></div>
</body>
</html>

仅当unsubthis标记为空时才会出现问题,我该如何解决?

我目前正在使用3.5.6版本。

0 个答案:

没有答案