Writing a custom mode for CodeMirror, for use in Brackets

让人想犯罪 __ 提交于 2019-12-03 03:45:33

General answer - there actually are some fairly detailed resources for this:

Specific answer - I can spot a few issues in your sample code that will definitely cause problems:

  1. Use require("powershell") without the .js -- this is the format JS module loaders expect
  2. powershell.js should contain the same define(...) wrapper as your main.js. And it should use brackets.getModule() to get a reference to CodeMirror, same as main.js. (Using JSLint, which is built into Brackets, is helpful for warning you when you reference globals that you have forgotten to explicitly load as module dependencies).
  3. Your CM mode has a typo: startStat -> startState
  4. You need to call CodeMirror.defineMode() before calling LanguageManager.defineLanguage() - see "Custom CodeMirror modes" docs linked above. You could either do this in your powershell.js module, or early in main.js.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!