Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] HTML language does not recognize inline <script type="module"> as JavaScript #2962

Open
1 of 2 tasks
Yoplitein opened this issue Feb 11, 2022 · 11 comments
Open
1 of 2 tasks
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities

Comments

@Yoplitein
Copy link

Yoplitein commented Feb 11, 2022

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Code

monaco.editor.create(document.getElementById('container'), {
	value: `<script type="module">\n\tconsole.log("hello");\n</script>`,
	language: 'html'
});

Actual Behavior

The contents of the script tag are marked as language vs.editor.nullLanguage, precluding highlighting and, upon editing or merely moving the cursor within the tag, causing various callbacks for editor features to throw Unexpected languageId when calling LanguageConfigurationRegistry.getLanguageConfiguration.

Expected Behavior

Inline code is recognized as JavaScript, is syntax highlighted, and editing/navigation does not raise exceptions.

Additional Context

This began causing exceptions in version 0.32.0, with 0.31.1 and prior nothing is raised but the inline code is still similarly marked as vs.editor.nullMode.

@hediet hediet added the bug Issue identified by VS Code Team member as probable bug label Feb 14, 2022
@hediet
Copy link
Member

hediet commented Feb 14, 2022

I can reproduce. It seems like type="module" tokenizes the content as language module, which does not exist - thus the error. type="html"or type="css" works as expected.

@CetinSert
Copy link

Interestingly, type=module (no quotes) works just fine!

image

@hediet
Copy link
Member

hediet commented Mar 11, 2022

We fixed this in vscode. The next monaco editor version will be released soon.

@Prinzhorn
Copy link

Seems fixed in 0.33.0, my app works again. You can also close #3090

@Delagen
Copy link

Delagen commented Sep 9, 2022

0.34.0 has this issue also

<script type="text/javascript">
var qd = {};
</script>

Any click inside script tag produce

image

@jonatanklosko
Copy link
Contributor

jonatanklosko commented Oct 9, 2022

Same with Markdown, when annotating a code code block with unknown language:

```mermaid
graph TD;
  A-->B;
  A-->C;
  B-->D;
  C-->D;
```

Error:

errors.ts:21 Uncaught Error: Language id "vs.editor.nullLanguage" is not configured nor known

Error: Language id "vs.editor.nullLanguage" is not configured nor known
    at f (languageConfigurationRegistry.ts:130:10)
    at c.getLanguageConfiguration (languageConfigurationRegistry.ts:113:13)
    at u.getLanguageConfiguration (tokenizationTextModelPart.ts:329:45)
    at u.getWordAtPosition (tokenizationTextModelPart.ts:350:9)
    at Ot.getWordAtPosition (textModel.ts:1860:42)
    at F._getWord (wordHighlighter.ts:355:21)
    at F._run (wordHighlighter.ts:373:21)
    at F._onPositionChanged (wordHighlighter.ts:347:8)
    at wordHighlighter.ts:224:9
    at t.invoke (event.ts:607:17)
    at errors.ts:26:12

(reproduced on the https://microsoft.github.io/monaco-editor playground).

Note that this worked fine on 0.33.0 and broke on 0.34.0.

silverwind added a commit to silverwind/gitea that referenced this issue Oct 12, 2022
1. Apparently, mermaid 9.1.7 no longer sets a `height` attribute on the
   SVG it produces. Workaround by extracting height from `viewBox`
   instead.
2. Filter out unresolvable Monaco errors from error display.

Fixes: go-gitea#21427
Ref: microsoft/monaco-editor#2962
undefined-moe added a commit to hydro-dev/Hydro that referenced this issue Oct 21, 2022
@pansinm
Copy link

pansinm commented Nov 3, 2022

  1. reproducible in the monaco editor playground
monaco.editor.create(document.getElementById('container'), {
	value: "```notsupport\nerror when press enter\n```",
	language: 'markdown'
});
  1. solve this problem
+ monaco.languages.register({id: 'vs.editor.nullLanguage'})
+ monaco.languages.setLanguageConfiguration('vs.editor.nullLanguage', {})

monaco.editor.create(document.getElementById('container'), {
	value: "```notsupport\nerror when press enter\n```",
	language: 'markdown'
});

@hediet hediet modified the milestone: February 2023 Feb 7, 2023
@hediet hediet added feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities and removed bug Issue identified by VS Code Team member as probable bug labels Feb 7, 2023
@hediet
Copy link
Member

hediet commented Feb 7, 2023

Error: Language id "vs.editor.nullLanguage" is not configured nor known

This will be fixed with the next release of the monaco editor.

Inline code is recognized as JavaScript, is syntax highlighted,

This is the remaining feature request of this issue.

@silverwind
Copy link
Contributor

silverwind commented Apr 17, 2024

This will be fixed with the next release of the monaco editor.

Was this fix released?

@silverwind
Copy link
Contributor

silverwind commented May 7, 2024

Tested #2962 (comment) in playground, the error is present in 0.34.1 and gone in 0.35.0 so this issue should be closed.

techknowlogick pushed a commit to go-gitea/gitea that referenced this issue May 8, 2024
This workaround is not neccessary any more since monaco 0.35.0.

Ref: microsoft/monaco-editor#2962
Ref: microsoft/vscode#173688
@CetinSert
Copy link

I have just tested this again:

DennisRasey pushed a commit to DennisRasey/forgejo that referenced this issue May 14, 2024
This workaround is not neccessary any more since monaco 0.35.0.

Ref: microsoft/monaco-editor#2962
Ref: microsoft/vscode#173688
(cherry picked from commit d9b37d085acb7e93409061e541b6a3aa53261bb0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

9 participants