如何通过requirejs加载ckeditor
我在尝试通过 requirejs 加载 ckeditor 时遇到问题(我尝试将主 ckeditor js 文件转换为单独的模块,但这导致一切都崩溃了),所以我现在正在检查是否有一个非常我错过了执行此操作的简单方法。
我知道 requirejs 允许你加载普通的 js 脚本,所以也许只是加载 ckeditor.js 文件(未编辑,所以它仍然是一个 IIFE/自执行函数) - 这是否可以与 requirejs 一起使用,或者如果你使用 requirejs 来加载模块,那么整个项目是否需要基于模块?
任何帮助表示赞赏。
亲切的问候, 标记
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.
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?
Any help appreciated.
Kind regards,
Mark
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
或者,您可以创建一个 RequireJS shim 以正确的顺序加载内容,并将正确的 RequireJS 模块名称别名为 CKEditor 分发文件。
这意味着你的模块仍然声明它依赖于 CKEditor,这比让它神奇地显示要好得多。
然后在模块中,您可以依赖 ckeditor-jquery (或 ckeditor-core,如果您不需要 jQuery 集成)并知道它将可用:
Alternatively, you can create a RequireJS shim to load things in the correct order, and alias proper RequireJS module names to the CKEditor distribution files.
This means your module still declares it is dependant on CKEditor, which is a lot nicer than having it just show up by magic.
then in a module you can depend on ckeditor-jquery (or ckeditor-core for that matter, if you don't need the jQuery integration) and know it'll be available:
另一种方法可以做到这一点:
Another way to do that:
好吧,看来我在这里回答了我自己的问题。
我没有尝试将 ckeditor 分解为模块,而是使用 RequireJs 来完整加载脚本。
````
OK, it seems I answered my own question here.
Instead of trying to break ckeditor down into modules I just used RequireJs to load the script in it's entirety.
```