【问题标题】:Icons not found in tinyMCE laravel 7在 tinyMCE laravel 7 中找不到图标
【发布时间】:2020-12-12 11:26:16
【问题描述】:

我希望你们一切都好。我正在开发一个需要 tinyMCE 编辑器的 laravel 项目。 TinyMCE 运行良好,但显示的是“未找到”而不是菜单图标。

我如何设置 tinyMCE

  1. npm install -D tinymce(在 package.json 中添加 tinymce 依赖)

2。资源/js/app.js

require('tinymce/themes/silver');
import tinymce from 'tinymce';
tinymce.init({     selector: 'textarea#inputCategoryContent', //textarea id    height: 400,    skin: false,    content_css: false,
})

错误

控制台

我想要什么

我们将不胜感激任何帮助:)

【问题讨论】:

标签: laravel tinymce


【解决方案1】:

将此脚本放入刀片中:

<script>
    tinymce.init({
        selector: '#editor',
        images_upload_handler: function (blobInfo, success, failure) {
            var xhr, formData;
            xhr = new XMLHttpRequest();
            xhr.withCredentials = false;
            xhr.open('POST', '/upload');
            var token = '{{ csrf_token() }}';
            xhr.setRequestHeader("X-CSRF-Token", token);
            xhr.onload = function() {
                var json;
                if (xhr.status != 200) {
                    failure('HTTP Error: ' + xhr.status);
                    return;
                }
                json = JSON.parse(xhr.responseText);

                if (!json || typeof json.location != 'string') {
                    failure('Invalid JSON: ' + xhr.responseText);
                    return;
                }
                success(json.location);
            };
            formData = new FormData();
            formData.append('file', blobInfo.blob(), blobInfo.filename());
            xhr.send(formData);
        }
    });
</script>

不要忘记设置您的 tinymce id 和上传路径

【讨论】:

    猜你喜欢
    • 2021-01-04
    • 2021-01-06
    • 1970-01-01
    • 2020-07-10
    • 1970-01-01
    • 2022-07-15
    • 2021-10-14
    • 2023-03-19
    • 2020-01-20
    相关资源
    最近更新 更多