如何通过requirejs加载ckeditor [英] How to load ckeditor via requirejs

查看:175
本文介绍了如何通过requirejs加载ckeditor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试通过requirejs加载ckeditor时遇到问题(我已经尝试将主ckeditor js文件转换为单独的模块,但这只是导致所有地狱崩溃了),所以我现在要检查是否存在是我错过的一种非常简单的方法。

I'm having issues trying to load ckeditor via requirejs (I've tried converting the main ckeditor js file into individual modules but that has just caused all hell to break loose) and so I'm now checking to see if there is a very simple way to do this that I've missed.

我知道requirejs允许您加载普通的js脚本,因此也许只是加载ckeditor.js文件( -edited,因此它仍然是IIFE /自我执行功能)-是否可以与requirejs一起使用,或者如果您正在使用requirejs加载模块,那么整个项目是否需要基于模块?

I know requirejs allows you to load normal js scripts so maybe just loading the ckeditor.js file (un-edited, so it's still an IIFE/self-executing function) - would that work with requirejs or if you're using requirejs for loading modules, does the entire project then need to be module based?

感谢任何帮助。

亲切的问候,
马克

Kind regards, Mark

推荐答案

好,看来我在这里回答了自己的问题。

OK, it seems I answered my own question here.

不是试图将ckeditor分解为模块,而是使用RequireJs加载

Instead of trying to break ckeditor down into modules I just used RequireJs to load the script in it's entirety.

require(['require', 'dependancy-A', 'dependancy-B', 'dependancy-C'], function(require, A, B, C){

    // this = [object DOMWindow]
    // CKEDITOR_BASEPATH is a global variable
    this.CKEDITOR_BASEPATH = '/ckeditor/';

    require(['/ckeditor/ckeditor'], function(){
        // Code to create a new editor instance
    });

});

`

这篇关于如何通过requirejs加载ckeditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆