首页 > 解决方案 > CKEditor 提到 outputTemplate 插入为 HTML 内容

问题描述

我正在使用提及和自动完成插件使用 AJAX GET 方法从数据库中获取数据。我想做的是-从数据库中获取数据,然后将其插入编辑器。我的数据库行包含 html。这是我如何使用 CKeditor 提及的代码-

mentions: [{
    feed: function( options, callback ) {
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function() {
            if ( xhr.readyState == 4 ) {
                if ( xhr.status == 200 ) {
                    callback( JSON.parse( this.responseText ) );
                } else {
                    callback( [] );
                }
            }
        }
        xhr.open( 'GET', 'smart_drug.php?username=' + encodeURIComponent( options.query ) );
        xhr.send();
    },
itemTemplate: '<li data-id="{id}">' +
'<strong class="username">{d_name}</strong>' +
'<span class="fullname">{d_name}</span>' +
'</li>',    
minChars: 0,
outputTemplate:  '{body}',
}]

这是插入编辑器的 {body} 的输出 在此处输入图像描述

它不呈现 html 代码,只是作为纯文本插入。插入在编辑器上正确显示 HTML 的数据的方法是什么?

标签: ckeditorckeditor4.x

解决方案


推荐阅读