简体   繁体   中英

Custom javascript code completion for "this" in monaco editor

The scenario:

  • We are using the monaco editor in a javascript application to let the users enter custom javascript code (sort of a js-fiddle thing for an internal dashboarding application)
  • Within the javascript code that the users edit this is bound to a custom framework-provided object when the code is executed.

Question:

  • Is there a way to configure monaco so that it will provide code completion when the users type this. ?
  • The this object is compiled from a TypeScript class with type annotation. Is it possible to use the typescript compiler to produce data that the custom monaco code completion can use?

If I understood you correctly, you may use registerCompletionItemProvider . But I'm not sure if you are using any other library or something you've created. Because each autocomplete item needs to be defined one by one. If the library created dynamically maybe you can add this definition process to your main compilation process.

I'm guessing you might end up with more work than you expected to do.

https://microsoft.github.io/monaco-editor/api/modules/monaco.languages.html#registercompletionitemprovider

If you are expecting a cross-file autocompletion I believe your answer is here. Monaco Editor intellisense from multiple files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM