Reputation: 105
I want the mode htmlmixed in codemirror. I start searching in the codemirror API but i cannot find it. I included the following:
<script src="cm/lib/codemirror.js"></script>
<link rel="stylesheet" href="cm/lib/codemirror.css">
<script src="cm/mode/htmlmixed/htmlmixed.js"></script>
And this is my code:
MCM = CodeMirror(JY.get("devroot"), {
mode: "htmlmixed",
value: "<p>Hello</p>"
});
But it doesn't work. Does somebody know this?
Upvotes: 3
Views: 3404
Reputation: 1769
@Marjin gave the correct answer. But the full code will look like this:
<script src="/js/codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="/js/codemirror/lib/codemirror.css">
<script src="/js/codemirror/mode/xml/xml.js"></script>
<script src="/js/codemirror/mode/javascript/javascript.js"></script>
<script src="/js/codemirror/mode/css/css.js"></script>
<script src="/js/codemirror/mode/htmlmixed/htmlmixed.js"></script>
<div class="page-wrap-editor">
<h3 class="editor-head">HTML код</h3>
<textarea id="ta"></textarea>
</div>
<script>
const ta = document.getElementById(`ta`);
const editor = CodeMirror.fromTextArea(ta, {
lineNumbers: true,
mode: "htmlmixed",
value: "<p>Hello</p>"
});
</script>
Upvotes: 5
Reputation: 8929
You must also include the mode scripts cm/mode/xml/xml.js
, cm/mode/javascript/javascript.js
, and cm/mode/css/css.js
, which are dependencies of the htmlmixed mode.
Upvotes: 10