如何在TinyMCE 5.06版中显示表情符号?

时间:2019-06-03 19:53:04

标签: tinymce emoticons tinymce-5

我正在尝试使用TinyMCE 5.06版本插入表情符号,但是有关此插入的错误。当我在Asp.Net MVC中使用Html.Raw()时,表情符号不会出现。看起来像这样的“ ????”。我怎样才能解决这个问题 ?

  //tinymce plugin and toolbar options
        $scope.tinymceOptions = {
            selector: '#post',         
            plugins: [
               "advlist autolink autoresize link image fullscreen  lists charmap paste print preview hr anchor pagebreak",
                "searchreplace wordcount visualblocks visualchars insertdatetime media nonbreaking wordcount  ",
                "table contextmenu directionality emoticons paste template spellchecker searchreplace help imagetools media "
            ], 
            mobile: {
                theme: "mobile",
                plugins: [ 'autosave', 'lists', 'autolink' ],
                toolbar: [ 'undo', 'bold', 'italic', 'styleselect' ]
            },
            toolbar: "insertfile undo redo | styleselect | bold italic underline left aligncenter alignright alignjustify | forecolor  backcolor | fontselect fontsizeselect| bullist numlist outdent indent | link image media  preview |  emoticons | searchreplace  help ",
            toolbar_items_size: 'small',
            file_picker_types: 'file image media',
            image_title: true,
            automatic_uploads: true,          
            file_picker_types: 'image',
            relative_urls: false,
            file_picker_callback: function (cb, value, meta) {
                var input = document.createElement('input');
                input.setAttribute('type', 'file');
                input.setAttribute('accept', 'image/*');
                input.onchange = function () {
                    var file = this.files[0];

                    var reader = new FileReader();
                    reader.onload = function () {

                        var id = 'blobid' + (new Date()).getTime();
                        var blobCache =  tinymce.activeEditor.editorUpload.blobCache;
                        var base64 = reader.result.split(',')[1];
                        var blobInfo = blobCache.create(id, file, base64);
                        blobCache.add(blobInfo);
                        cb(blobInfo.blobUri(), { title: file.name });
                    };
                    reader.readAsDataURL(file);
                };
                input.click();
            },

            media_url_resolver: function (data, resolve/*, reject*/) {
                if (data.url.indexOf('YOUR_SPECIAL_VIDEO_URL') !== -1) {
                    var embedHtml = '<iframe src="' + data.url +
                    '" width="400" height="400" ></iframe>';
                    resolve({html: embedHtml});
                } else {
                    resolve({html: ''});
                }
            },
            width: "98%",
        };

我希望输出是?或?,但是实际输出是??。

2 个答案:

答案 0 :(得分:1)

出现此问题。

entity_encoding: "numeric"

这会将表情符号作为HTML Dec代码发送到您的数据库,然后在将它们显示为HTML dec代码时,浏览器会将其转换为表情符号。

答案 1 :(得分:0)

检查用于处理HTML字符串的字符集。当您不小心将字符串从复杂的字符集(表情符号所需)(例如Unicode或UTF-8)转换为更简单的字符(例如ASCII)时,就会发生这种情况。