File tree Expand file tree Collapse file tree 3 files changed +22
-52
lines changed Expand file tree Collapse file tree 3 files changed +22
-52
lines changed Original file line number Diff line number Diff line change 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 >
Original file line number Diff line number Diff line change @@ -9,14 +9,12 @@ app.component(require('d-showdown'));
99// Routes render on client as well as server
1010app . 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- } ;
Original file line number Diff line number Diff line change 1- @import "../node_modules/derby-starter/styles/reset.css"
2-
3- body {
4- color : #0 0 0 ;
5- background : #f7 f7 f7 ;
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 : #1 1 1 ;
13- text-shadow : 0 1px #f7 f7 f7 ;
14- }
15-
16- header {
17- background : #d d d ;
18- background : linear-gradient (#e7 e7 e7 , #d0 d0 d0 );
19- box-shadow : inset 0 1px #f7 f7 f7 , 0 1px #8 8 8 , 0 2px #e7 e7 e7 ;
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 : #e7 e7 e7
3+
4+ .editor ,.preview
5+ box-sizing : border-box
6+ padding : 10px
7+ width : 50%
8+ display : inline-block
9+ vertical-align : top
You can’t perform that action at this time.
0 commit comments