1

我需要在 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>
<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 版本。

4

0 回答 0