monaco.js 1.1 KB

1234567891011121314151617181920212223242526272829
  1. o2.widget = o2.widget || {};
  2. o2.widget.monaco = {
  3. "callbackList": [],
  4. "load": function(callback){
  5. if (!window.monaco){
  6. this.callbackList.push(callback);
  7. if (!this.isLoadding){
  8. this.isLoadding = true;
  9. o2.load("monaco", {"sequence": true}, function(){
  10. var currentScriptPath = window.location.href;
  11. var baseUrl = currentScriptPath.substring(0, currentScriptPath.lastIndexOf('/') + 1) + '../o2_lib/'; // 计算 baseUrl
  12. require.config({
  13. baseUrl: baseUrl,
  14. paths: { "vs": "vs/min/vs" }
  15. });
  16. require(["vs/editor/editor.main"], function() {
  17. this.isLoadding = false;
  18. while (this.callbackList.length){
  19. this.callbackList.shift()();
  20. }
  21. }.bind(this));
  22. }.bind(this));
  23. }
  24. }else{
  25. if (callback) callback();
  26. }
  27. }
  28. };