CodeMirror et color pickup
J'essaye d'intégrer in color picker dans codemirror.
J'ai trouvé ce script http://enjalot.github.io/Inlet/ how to do.
Merci.
Ce code ci dessous fonctionne parfaitement .
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <script src="lib/CodeMirror3/lib/codemirror.js"></script>
<script src="lib/CodeMirror3/mode/javascript/javascript.js"></script>
<script src="inlet.js"></script>
<div id='editor'></div>
<script>
var editor = CodeMirror(document.getElementById("editor"),{
//default code for example:
value: '//Click on the hex value or number below:\n\nvar color = "#D1FFDB"\n\nvar theAnswer = 42;\n\nvar is = true;\n\n//Usage looks like:\n//var editor = CodeMirror(...);\n//Inlet(editor);\n\n//You can also use hsl colors, try replacing #D1FFDB with hsl(133,100%,91%)',
lineNumbers: true,
});
editor.on("change", changeFunction)
function changeFunction() {
eval(editor.getValue());
};
changeFunction();
var inlet = Inlet(editor);
</script> |
Si j'essaye ceci afin de pouvoir prendre dans un texarea la couleur ce ne fonctionne pas.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<link rel="stylesheet" href="lib/CodeMirror3/lib/codemirror.css">
<script src="lib/CodeMirror3/lib/codemirror.js"></script>
<script src="lib/CodeMirror3/addon/selection/active-line.js"></script>
<cript src="inlet.js"></script>
<textarea style="display: none;" name="code" cols="5" rows="" id="code"><style>color:#3300db;</style></textarea>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
styleActiveLine: true,
lineNumbers: true,
lineWrapping: true,
viewportMargin: Infinity
});
editor.on("change", changeFunction)
function changeFunction() {
eval(editor.getValue());
};
changeFunction();
var inlet = Inlet(editor);
</script> |