dev-setup.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. (function() {
  2. function getQueryStringValue (key) {
  3. return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(key).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
  4. }
  5. // Resolve paths
  6. // should run the editor and/or plugins from source? (or from the node module)
  7. if (getQueryStringValue('editor') === 'dev') {
  8. METADATA.CORE.path = METADATA.CORE.srcPath;
  9. } else {
  10. METADATA.CORE.path = '/monaco-editor/' + METADATA.CORE.path;
  11. }
  12. METADATA.PLUGINS.forEach(function(plugin) {
  13. // should run the editor plugins from source? (or from node modules)
  14. if (plugin.srcPath && getQueryStringValue(plugin.name) === 'dev') {
  15. plugin.path = plugin.srcPath;
  16. } else {
  17. plugin.path = '/monaco-editor/' + plugin.path;
  18. }
  19. });
  20. })();
  21. function loadEditor(callback) {
  22. var pathsConfig = {};
  23. METADATA.PLUGINS.forEach(function(plugin) {
  24. pathsConfig[plugin.modulePrefix] = plugin.path;
  25. });
  26. pathsConfig['vs'] = METADATA.CORE.path;
  27. require.config({
  28. paths: pathsConfig
  29. });
  30. require(['vs/editor/editor.main'], function() {
  31. // At this point we've loaded the monaco-editor-core
  32. require(METADATA.PLUGINS.map(function(plugin) { return plugin.contrib; }), function() {
  33. // At this point we've loaded all the plugins
  34. callback();
  35. // require(['./index'], function() {});
  36. });
  37. });
  38. }