Kendo UI Editor,在编辑器中使用编码html实体显示HTML

时间:2017-11-13 17:01:02

标签: kendo-ui html-entities html-encode kendo-editor

我想在Kendo UI编辑器中看到HTML,如



<h1>Hello World</h1>
&#13;
&#13;
&#13;

我该怎么做?

1 个答案:

答案 0 :(得分:1)

我的示例展示在:https://dojo.telerik.com/ezOPAz/3

  $("#editor").kendoEditor({
    value: "<h1>Hello World</h1>",
    encoded: false,
            tools: [
                "viewHtml"
            ],
    deserialization: {
              custom: function(html) {
                 var encodedStr = html.replace(/[\u00A0-\u9999<>\&]/gim, function(i) {
                     return '&#'+i.charCodeAt(0)+';';
                  });
                return encodedStr;
              }
          }
  });