Skip to content

Commit

Permalink
example showing that only one editor mode works at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
thlorenz committed Apr 22, 2013
1 parent 526820d commit 867481f
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 17 deletions.
4 changes: 3 additions & 1 deletion example/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ var browserify = require('browserify')
, fs = require('fs');

browserify()
.require(require.resolve('./main'), { entry: true })
.require(require.resolve('./javascript-editor'), { entry: true })
// .require(require.resolve('./coffee-editor'), { entry: true })
// .require(require.resolve('./css-editor'), { entry: true })
.bundle({ debug: true })
.pipe(fs.createWriteStream(__dirname + '/bundle.js'));
10 changes: 10 additions & 0 deletions example/coffee-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// initialize ace editor customized for coffee
var ace = require('brace/coffee');

// initialize coffee mode and monokai theme after editor itself
require('brace/mode/coffee');
require('brace/theme/monokai');

var editor = ace.edit('coffee-editor');
editor.setTheme('ace/theme/monokai');
editor.getSession().setMode('ace/mode/coffee');
10 changes: 10 additions & 0 deletions example/css-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// initialize ace editor customized for css
var ace = require('brace/css');

// initialize css mode and monokai theme after editor itself
require('brace/mode/css');
require('brace/theme/monokai');

var editor = ace.edit('css-editor');
editor.setTheme('ace/theme/monokai');
editor.getSession().setMode('ace/mode/css');
23 changes: 18 additions & 5 deletions example/index.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
#editor {
div.editor {
position: absolute;
top: 49px;
right: 0;
bottom: 0;
width: 50%;
height: 50%;
background: black;
}

#javascript-editor {
left: 0;
width: 100%;
top: 0;
}

#coffee-editor {
top: 50%;
bottom: 0;
}

#css-editor {
top: 0;
left: 50%;
}

h1 {
Expand Down
7 changes: 5 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
</head>

<body>
<h1>JavaScript Ace Editor provided by brace</h1>
<div id="editor"></div>
<h1>Ace Editors provided by brace</h1>
<div id="javascript-editor" class="editor"></div>
<div id="coffee-editor" class="editor"></div>
<div id="css-editor" class="editor"></div>
<!--<div id="lua-editor" class="editor"></div>-->
<script type="text/javascript" src="./bundle.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions example/javascript-editor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// initialize ace editor customized for javascript
var ace = require('brace/javascript');

// initialize javascript mode and monokai theme after editor itself
require('brace/mode/javascript');
require('brace/theme/monokai');

var editor = ace.edit('javascript-editor');
editor.setTheme('ace/theme/monokai');
editor.getSession().setMode('ace/mode/javascript');
9 changes: 0 additions & 9 deletions example/main.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
'use strict';

// initialize ace editor customized for javascript
var ace = require('brace/javascript');

// initialize javascript mode and monokai theme after editor itself
require('brace/mode/javascript');
require('brace/theme/monokai');

var editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/javascript");

0 comments on commit 867481f

Please sign in to comment.