codemirror / dev

Development repository for the CodeMirror editor project
https://codemirror.net/
Other
5.95k stars 377 forks source link

HTML highlighting not working #1470

Closed Artem-Schander closed 1 week ago

Artem-Schander commented 1 week ago

Describe the issue

I'm using codemirror for Javascript, CSS and HTML. JS/CSS working fine, HTML not.

const view = new EditorView({
    doc: '<div>some html</div>',
    extensions: [
        basicSetup,
        // javascript(),
        html(),
    ],
    parent: this.$refs.editor,
});

I've tried to create a sandbox, but there is an error :(

Here is how it looks

Bildschirmfoto 2024-11-13 um 19 45 02

Autocompletion works. Only highlighting seems to be missing.

The CodeMirror sandbox works fine, so the issue must be on my end Please help

Browser and platform

No response

Reproduction link

https://codemirror.net/try/?c=aW1wb3J0IHtiYXNpY1NldHVwLCBFZGl0b3JWaWV3fSBmcm9tICJjb2RlbWlycm9yIgppbXBvcnQge2h0bWx9IGZyb20gIkBjb2RlbWlycm9yL2xhbmctaHRtbCIKCm5ldyBFZGl0b3JWaWV3KHsKICBkb2M6ICI8ZGl2PnNvbWUgaHRtbDwvZGl2PiIsCiAgZXh0ZW5zaW9uczogW2Jhc2ljU2V0dXAsIGh0bWwoKV0sCiAgcGFyZW50OiBkb2N1bWVudC5ib2R5Cn0pCg==

marijnh commented 1 week ago

I don't think I can help with an issue that I cannot reproduce. Try to clear your package lock (and make sure no packages are stuck on 0.x versions), and simplify your script until you figure out what the issue is.

Artem-Schander commented 1 week ago

Ok. I'll try. But what is with the codesandbox? why does it not run? maybe there would be a reproduction possible

EDIT:

<template>
    <div ref="container">
        <div class="codemirror-editor" ref="editor"></div>
    </div>
</template>

<script>
import { EditorView, basicSetup } from 'codemirror';
// import { EditorView } from "@codemirror/view";
import { html } from "@codemirror/lang-html";

export default {
    name: 'CodeMirror',
    mounted() {
        const element = document.querySelector("#app");
        const view = new EditorView({
            doc: '<p>Hello, World!</p>',
            parent: this.$refs.editor,
            extensions: [
                basicSetup,
                html(),
            ],
        });
    }
}
</script>

package versions:

"@codemirror/lang-html": "^6.4.9",
"codemirror": "^6.0.1",

result:

Bildschirmfoto 2024-11-13 um 22 27 30
Artem-Schander commented 1 week ago

I've deleted the lock file and the node_modules folder, reinstalled everything. now it works. thanks for the hint