monaco-editor

Provide type hints to monaco editor

送分小仙女□ 提交于 2019-12-06 07:16:29
问题 I am trying to provide intellisense / code completion into a javascript editor using the Monaco editor. The code needs to be valid javascript, not typescript. Given some user entered script like this: function onMyEvent(event) { event.someProperty } I want to provide code completion on the event parameter, which is a typescript class I have the t.ds of, and can infer at runtime. Ideally, I would just like to tell Monaco that the type of event is SomeEventClass , and let it do the rest. Even

Provide type hints to monaco editor

て烟熏妆下的殇ゞ 提交于 2019-12-04 15:26:06
I am trying to provide intellisense / code completion into a javascript editor using the Monaco editor. The code needs to be valid javascript, not typescript. Given some user entered script like this: function onMyEvent(event) { event.someProperty } I want to provide code completion on the event parameter, which is a typescript class I have the t.ds of, and can infer at runtime. Ideally, I would just like to tell Monaco that the type of event is SomeEventClass , and let it do the rest. Even if that meant adding type hints to the script. But I can't see how to do that. I tried using JSDoc

How to use addExtraLib in Monaco with an external type definition

北城以北 提交于 2019-12-03 13:04:09
问题 I can see how to use addExtraLib in Monaco to add an ambient declaration file. What's not clear is how to use this function with an external declaration file so that Typescript code in the editor can do a: import * as External from "external" External.foo(); On the Monaco set-up side, this doesn't seem to work: // compiler options monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2016, allowNonTsExtensions: true,

Syntax validation of a custom language in Monaco editor

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 11:31:34
问题 I'm trying to integrate a custom language to monaco editor and I went through https://microsoft.github.io/monaco-editor/monarch.html to get an idea on syntax highlighting. But I couldn't find any doc on how we can add error/warning validations through syntax validation for this. In Ace editor we did this by writing a worker and performing validation function within it. Appreciate any links/help on this. 回答1: I recently done this successfully i just used monaco-css as boiler-plate and the only

How to use addExtraLib in Monaco with an external type definition

此生再无相见时 提交于 2019-12-03 03:12:37
I can see how to use addExtraLib in Monaco to add an ambient declaration file. What's not clear is how to use this function with an external declaration file so that Typescript code in the editor can do a: import * as External from "external" External.foo(); On the Monaco set-up side, this doesn't seem to work: // compiler options monaco.languages.typescript.typescriptDefaults.setCompilerOptions({ target: monaco.languages.typescript.ScriptTarget.ES2016, allowNonTsExtensions: true, moduleResolution: monaco.languages.typescript.ModuleResolutionKind.NodeJs, module: monaco.languages.typescript

Syntax validation of a custom language in Monaco editor

早过忘川 提交于 2019-12-03 01:57:20
I'm trying to integrate a custom language to monaco editor and I went through https://microsoft.github.io/monaco-editor/monarch.html to get an idea on syntax highlighting. But I couldn't find any doc on how we can add error/warning validations through syntax validation for this. In Ace editor we did this by writing a worker and performing validation function within it. Appreciate any links/help on this. I recently done this successfully i just used monaco-css as boiler-plate and the only thing that i have to do now is write a parser for my language and other features that I want in in it. and

Adding JavaScript type hints for VSCode/Monaco Intellisence

那年仲夏 提交于 2019-11-30 22:30:35
Is there a way to hint to VSCode/Monaco's intellisense the types of variables. I have some code like this var loc = window.location; var gl = context1.getContext("webgl"); var ctx = context2.getContext("2d"); I see that VSCode knows that loc is a URL But it doesn't know what gl is Nor does it know what ctx is Which makes sense, having a function return different types based on its input is a somewhat unusual case. But it does have type data for WebGLRenderingContext and it knows CanvasRenderingContext2D Is there a way to for me to tell vscode/monaco that gl is an instance of

Adding JavaScript type hints for VSCode/Monaco Intellisence

浪尽此生 提交于 2019-11-30 17:06:12
问题 Is there a way to hint to VSCode/Monaco's intellisense the types of variables. I have some code like this var loc = window.location; var gl = context1.getContext("webgl"); var ctx = context2.getContext("2d"); I see that VSCode knows that loc is a URL But it doesn't know what gl is Nor does it know what ctx is Which makes sense, having a function return different types based on its input is a somewhat unusual case. But it does have type data for WebGLRenderingContext and it knows

Get the value of Monaco Editor

前提是你 提交于 2019-11-29 11:05:02
问题 Microsoft recently open sourced their monaco editor (similar to ace/codemirror). https://github.com/Microsoft/monaco-editor I've got it up and running in the browser, but still can't figure out how to get the current text of the editor, like if I wanted to save it. Example: <!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > </head> <body> <div id="container" style="width:800px;height:600px