将新的Uploader添加到Ckeditor5

时间:2018-08-30 06:14:20

标签: javascript php ckeditor5

这怎么可能向ckeditor5添加新的上传器功能,例如上传音频或视频?

我尝试使用ckeditor5文档,但目前还不清楚。 我将这个vue文件用于ckeditor5。在此文件中,我为项目使用了自定义的uploadadapter,但是现在我不知道如何以这种态度上传其他类型的文件,例如音频和视频

<script>
    import ClassicEditor from '@ckeditor/ckeditor5-build-classic/build/ckeditor';
    import MyUploadAdapter from '../adapter/UploadAdapter';

    export default {
        data() {
            return {
                instance: null,
                article: {
                    data: '',
                },
            }
        },

        mounted() {
            this.initialize();
        },

        methods: {
            // Initializing Editor
            initialize: function () {
                ClassicEditor
                    .create(document.querySelector("#editor"), this.config)
                    .then(editor => {
                        // get initial instance object of editor
                        this.instance = editor;

                        // set initial binder of editor on start
                        editor.model.document.on('change', () => {
                            this.valueBinder(editor.getData())
                        });

                        editor.plugins.get('FileDialogButtonView')


                        // This place loads the adapter.
                        editor.plugins.get('FileRepository').createUploadAdapter = (loader, article) => {
                            return new MyUploadAdapter(loader, this.article);

                        }
                    })
                    .catch(error => {
                        console.error(error);
                    });
            },

            }
        },
    }

</script>

1 个答案:

答案 0 :(得分:0)

对于上传文件,您可以使用CKFinder

有关CKfinder的配置,请参阅此link

ClassicEditor
    .create( editorElement, {
        ckfinder: {
            uploadUrl: '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files&responseType=json' // here you can set your own file path
        }
    } )
    .then( ... )
    .catch( ... );