Created
November 13, 2014 10:02
-
-
Save saschpe/19e3033ff663950d6951 to your computer and use it in GitHub Desktop.
GreaseMonkey User Script to convert (all) texteareas into HTML editors (powerered by CodeMirror)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name CodeMirror HTML Textareas | |
// @namespace saschpe | |
// @description Instanciate a CodeMirror HTML editor for every textarea... | |
// @author Sascha Peilicke <[email protected]> | |
// @include example.com | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/codemirror.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/css/css.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/javascript/javascript.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/xml/xml.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/htmlmixed/htmlmixed.min.js | |
// @require http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/mode/htmlembedded/htmlembedded.min.js | |
// @resource cm_css http://cdnjs.cloudflare.com/ajax/libs/codemirror/4.7.0/codemirror.min.css | |
// @version 1.1 | |
// @grant GM_addStyle | |
// @grant GM_getResourceText | |
// ==/UserScript== | |
this.$ = this.jQuery = jQuery.noConflict(true); | |
GM_addStyle(GM_getResourceText("cm_css")); | |
GM_addStyle(".CodeMirror { border: 1px solid #eee; }"); | |
$(function () { | |
$("textarea").each(function() { | |
CodeMirror.fromTextArea($(this)[0], { | |
mode: "htmlembedded", | |
indentWithTabs: false, | |
indentUnit: 4, | |
lineWrapping: true, | |
lineNumbers: true, | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment