Open lifubang opened 6 years ago
JS and CSS autocompletion within HTML files is something that would be very useful for me too. It looks like this feature exists on a branch of monaco-html
(https://github.com/Microsoft/monaco-html/tree/rebornix/EmbeddedLanguage). It's not clear what happened to this.
@rebornix Do you have any idea if your work is likely to end up being merged?
It dose not work. Maybe an example will help..
Error: "Loading "vscode-languageserver-types" failed"
Error: "Loading "vscode-languageserver-types" failed"
@LucaGabi Your error does not make sense in the context of Monaco. Monaco has no dependencies on vscode-languageserver-types
. Please clarify what you are doing or trying to do.
asialgearoid said there is another branch that has support for css and js in html files and when I tried to test it compiles but when opening test/index.html I get that error. I think the one who tried was unsuccessful as well maybe ?
My branch of embed language was just a prototype as without the concept of workspace, the intellisense/autocomplete is not ideal. One good example is if we import a module in <script>
tag and we need some way to load the content of that module to typescript language server.
As browsers are adopting ESM gradually, I think we can revisit this feature when EMS is somewhat mature (especially lazy loading, otherwise developers still use bundlers). Then when we have a esm module in script
tag, it imports some module and we can leverage the browser api to load the content and feed it to TS LSP and provide proper language features.
Did it work at any moment ? Sure it would be good to have workspaces but it is sometime also useful even without (the same idea is also true for the editor itself).
I get errors when I try to build (and there is nothing in release/dev also)
Thank anyway.
It worked in the end .. It is useful even with no workspace (for css at least).
@alexdima @rebornix
Have there been any developments regarding the implementation of this feature? Intellisense for JavaScript files is not working inside of <script></script>
tags within HTML documents (i.e. - not treating the <script></script>
tags as a JS file). Is there a workaround that anyone has found?
I have tried going about it in a few different ways but haven't had success. Here are my attempts:
First Way
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- no need to directly reference index.js, but included it anyway to show it doesn't work with or without reference to it -->
<script src="./intellisense/index.js" type="module"></script>
<title>Document</title>
</head>
<script >
// this is where I am expecting intellisense to show up from the referenced file above
someObj.someProperty
</script>
<body>
</body>
</html>
Second Way
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<script>
// don't need to reference index.js in filepath from imports with JS (have tried it both with and without; neither work)
import { someObj } from './intellisense/index.js';
// this is where I am expecting intellisense to show up from the imported file above
someObj.someProperty
</script>
<body>
</body>
</html>
Neither way seems to be working.
Thoughts?
I have also posted a parallel issue on microsoft/vs-code: https://github.com/microsoft/vscode/issues/26338
@shuaihuGao claims to have fixed it within vscode, but it is still not available within Monaco directly.
@williamleiby i am having same issue on ver 0.20 and even tag have intellisense issue.. did you find any solution to it?
I would consider HTML JS & CSS autocompletion to be document agnostic and just give base autocompletion features of the embedded language. No need to track variables and references along 10 script blocks on the same HTML document, just autocompletion on globals and common structs.
@alexdima @rebornix
Have there been any developments regarding the implementation of this feature? Intellisense for JavaScript files is not working inside of
<script></script>
tags within HTML documents (i.e. - not treating the<script></script>
tags as a JS file). Is there a workaround that anyone has found?I have tried going about it in a few different ways but haven't had success. Here are my attempts:
First Way
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- no need to directly reference index.js, but included it anyway to show it doesn't work with or without reference to it --> <script src="./intellisense/index.js" type="module"></script> <title>Document</title> </head> <script > // this is where I am expecting intellisense to show up from the referenced file above someObj.someProperty </script> <body> </body> </html>
Second Way
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <script> // don't need to reference index.js in filepath from imports with JS (have tried it both with and without; neither work) import { someObj } from './intellisense/index.js'; // this is where I am expecting intellisense to show up from the imported file above someObj.someProperty </script> <body> </body> </html>
Neither way seems to be working.
Thoughts?
I have also posted a parallel issue on microsoft/vs-code: microsoft/vscode#26338
@shuaihuGao claims to have fixed it within vscode, but it is still not available within Monaco directly.
You can try Monaco-editor-ex ,I build up this for my work.
Any update on this feature?
Sorry, I can't open a question in stackoverflow.com because it has a js error.
Help:
When I use import in es6, how to use js IntelliSense from module in another file?
List.js