Skip to content

Commit fd900c0

Browse files
committed
quick fixes to codemirror example
1 parent 5916cbe commit fd900c0

File tree

3 files changed

+22
-52
lines changed

3 files changed

+22
-52
lines changed

codemirror/index.html

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
11
<Head:>
22
<view is="d-codemirror:includes" static='/cm'></view>
33
<view is="d-showdown:includes" static='/showdown'></view>
4-
<Body:>
5-
<!--Templates define both HTML and model-view bindings-->
6-
<header>
7-
<h1>CodeMirror Example</h1>
8-
</header>
9-
10-
<section id="mirror-wrapper">
11-
<view is="d-codemirror" text="{{codemirror.text}}" options="{{ { tabSize: 2, mode: 'markdown' } }}"></view>
12-
</section>
13-
<section>
14-
<view is="d-showdown" text="{{codemirror.text}}" html="{{_page.markdown}}" options="{{ {} }}"></view>
15-
<div as="md">
16-
{{markdown(_page.markdown)}}
17-
</div>
18-
</section>
194

5+
<Body:>
6+
<div class="editor">
7+
<view is="d-codemirror" text="{{codemirror.text}}" options="{{ {tabSize: 2, mode: 'markdown'} }}"></view>
8+
</div>
9+
<div class="preview">
10+
<view is="d-showdown" text="{{codemirror.text}}" html="{{_page.markdown}}"></view>
11+
{{unescaped _page.markdown}}
12+
</div>

codemirror/index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ app.component(require('d-showdown'));
99
// Routes render on client as well as server
1010
app.get('/', function(page, model) {
1111
// Subscribe specifies the data to sync
12-
model.subscribe('codemirror.text', function() {
12+
var text = model.at('codemirror.text');
13+
text.subscribe(function() {
1314
// we set default content if none has been set
14-
model.setNull('codemirror.text', '<style>.example{ border: 1px solid orange; }</style>\n<div class="example">hello world</div>')
15+
if (text.get() == null) {
16+
text.create('# Hello world');
17+
}
1518
page.render();
1619
});
1720
});
18-
19-
app.proto.markdown = function(html) {
20-
if(!this.md) return;
21-
this.md.innerHTML = html;
22-
};

codemirror/index.styl

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,9 @@
1-
@import "../node_modules/derby-starter/styles/reset.css"
2-
3-
body {
4-
color: #000;
5-
background: #f7f7f7;
6-
}
7-
h1 {
8-
font: 26px/24px "Helvetica Neue", Helvetica, Arial, sans-serif;
9-
font-weight: bold;
10-
letter-spacing: -1px;
11-
margin-bottom: 12px;
12-
color: #111;
13-
text-shadow: 0 1px #f7f7f7;
14-
}
15-
16-
header {
17-
background: #ddd;
18-
background: linear-gradient(#e7e7e7, #d0d0d0);
19-
box-shadow: inset 0 1px #f7f7f7, 0 1px #888, 0 2px #e7e7e7;
20-
padding: 12px 16px;
21-
white-space: nowrap;
22-
}
23-
24-
section {
25-
padding: 12px 16px;
26-
}
27-
28-
section#mirror-wrapper {
29-
background-color: white;
30-
}
1+
body
2+
background: #e7e7e7
3+
4+
.editor,.preview
5+
box-sizing: border-box
6+
padding: 10px
7+
width: 50%
8+
display: inline-block
9+
vertical-align: top

0 commit comments

Comments
 (0)