mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-30 13:59:35 +07:00
* Remove docs folder. This was a redirect from a GitHub pages site that does not appear to be in use. * Rename api folder to api-samples. * Move examples to functional-samples folder. * Move cookbook sample to functional-samples. * Move tutorials to functional-samples folder. * Move mv2 and apps folders to _archive. * Rename tools folder to .repo. * Move reference folder to functional-samples. * Update README. Update README with new relative links for reorg. * Update README.md Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com> --------- Co-authored-by: amysteamdev <37001393+AmySteam@users.noreply.github.com>
81 lines
2.4 KiB
HTML
81 lines
2.4 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>CodeMirror: Formatting Demo</title>
|
|
<link rel="stylesheet" href="../lib/codemirror.css">
|
|
<script src="../lib/codemirror.js"></script>
|
|
<script src="../lib/util/formatting.js"></script>
|
|
<script src="../mode/css/css.js"></script>
|
|
<script src="../mode/xml/xml.js"></script>
|
|
<script src="../mode/javascript/javascript.js"></script>
|
|
<script src="../mode/htmlmixed/htmlmixed.js"></script>
|
|
<link rel="stylesheet" href="../doc/docs.css">
|
|
|
|
<style type="text/css">
|
|
.CodeMirror {
|
|
border: 1px solid #eee;
|
|
}
|
|
td {
|
|
padding-right: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>CodeMirror: Formatting demo</h1>
|
|
|
|
<form><textarea id="code" name="code"><script> function (s,e){ for(var i=0; i < 1; i++) test("test();a=1");} </script>
|
|
<script>
|
|
function test(c){ for (var i = 0; i < 10; i++){ process("a.b();c = null;", 300);}
|
|
}
|
|
</script>
|
|
<table><tr><td>test 1</td></tr><tr><td>test 2</td></tr></table>
|
|
<script> function test() { return 1;} </script>
|
|
<style> .test { font-size: medium; font-family: monospace; }
|
|
</style></textarea></form>
|
|
|
|
<p>Select a piece of code and click one of the links below to apply automatic formatting to the selected text or comment/uncomment the selected text. Note that the formatting behavior depends on the current block's mode.
|
|
<table>
|
|
<tr>
|
|
<td>
|
|
<a href="javascript:autoFormatSelection()">
|
|
Autoformat Selected
|
|
</a>
|
|
</td>
|
|
<td>
|
|
<a href="javascript:commentSelection(true)">
|
|
Comment Selected
|
|
</a>
|
|
</td>
|
|
<td>
|
|
<a href="javascript:commentSelection(false)">
|
|
Uncomment Selected
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</p>
|
|
<script>
|
|
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
lineNumbers: true,
|
|
mode: "htmlmixed"
|
|
});
|
|
CodeMirror.commands["selectAll"](editor);
|
|
|
|
function getSelectedRange() {
|
|
return { from: editor.getCursor(true), to: editor.getCursor(false) };
|
|
}
|
|
|
|
function autoFormatSelection() {
|
|
var range = getSelectedRange();
|
|
editor.autoFormatRange(range.from, range.to);
|
|
}
|
|
|
|
function commentSelection(isComment) {
|
|
var range = getSelectedRange();
|
|
editor.commentRange(isComment, range.from, range.to);
|
|
}
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|