How to load ace editor theme from CDN with requirejs?

断了今生、忘了曾经 提交于 2019-12-22 11:28:12

问题


I am trying to load an ace theme from a CDN with requirejs.

Here is a plunkr which illustrates my problem. The theme can not be found in the following case:

requirejs.config({
  paths: { ace: ['//cdnjs.cloudflare.com/ajax/libs/ace/1.1.9/'] }
})

$('h1').text("loading ace...");
requirejs([ 'ace/ace'], function(ace) {
  $('h1').text("ace loaded.")
  console.log(ace)
  editor = ace.edit('editor')
  editor.setTheme("ace/theme/monokai")
  return
})

Note: I asked this question to load ace editor with requirejs from CDN, but it does not explain how can I load an ace theme.


回答1:


Seems like there is a bug in ace, and one needs to call

ace.config.set("packaged", true)
ace.config.set("basePath", require.toUrl("ace"))

before ace.edit to configure paths.



来源:https://stackoverflow.com/questions/31211331/how-to-load-ace-editor-theme-from-cdn-with-requirejs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!