Skip to content

Commit b97b90b

Browse files
author
Michael Aufreiter
authored
Merge pull request #56 from substance/develop
Beta 6
2 parents a1ca6aa + 01de116 commit b97b90b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+1592
-1144
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ node_modules
3434

3535

3636
*.sqlite
37-
*.sqlite3
37+
*.sqlite3
38+
.DS_Store

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@ Here you can find a number of examples that cover various Substance API's.
44

55
## Install
66

7-
You can start playing around with the code by cloning this repo and starting the dev server.
7+
You can start playing around with the code by cloning this repo and starting the dev server.
88

99
```bash
1010
$ git clone https://github.com/substance/examples.git
11+
```
12+
13+
Now install dependencies and start the dev environment.
14+
15+
```bash
1116
$ npm install
1217
$ npm start
1318
```
1419

15-
And navigate to [http://localhost:5000](http://localhost:5000)
20+
Now you can navigate to [http://localhost:5555](http://localhost:5555)
1621

1722
## Questions
1823

code-editor/app.css

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/* Substance Component styles */
2-
@import '../lib/substance/substance.css';
3-
/* You may want to use your own reset and pagestyle */
4-
@import '../lib/substance/substance-reset.css';
5-
@import '../lib/substance/substance-pagestyle.css';
6-
@import url('../lib/font-awesome/css/font-awesome.min.css');
1+
@import '../common.css';
72

83
body {
94
overflow: hidden;
@@ -12,4 +7,4 @@ body {
127
.sc-script-editor {
138
background: #efefef;
149
padding: 5px 10px;
15-
}
10+
}

code-editor/app.js

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
const {
2-
Component, ProseEditor, ProseEditorConfigurator, DocumentSession,
1+
import {
2+
Component, ProseEditor, ProseEditorConfigurator, EditorSession,
33
ProseEditorPackage, BlockNode, Tool, InsertNodeCommand
4-
} = substance
4+
} from 'substance'
55

66
/*
77
Node definition
@@ -33,6 +33,7 @@ class ScriptEditor extends Component {
3333
}
3434

3535
didMount() {
36+
let editorSession = this.context.editorSession
3637
let node = this.props.node;
3738
let editor = ace.edit(this.refs.source.getNativeElement())
3839
// editor.setTheme("ace/theme/monokai");
@@ -59,11 +60,13 @@ class ScriptEditor extends Component {
5960
});
6061

6162
this.editor = editor
62-
this.props.node.on('source:changed', this._onModelChange, this)
63+
editorSession.onRender('document', this._onModelChange, this, {
64+
path: [node.id, 'source']
65+
})
6366
}
6467

6568
dispose() {
66-
this.props.node.off(this)
69+
this.context.editorSession.off(this)
6770
this.editor.destroy()
6871
}
6972

@@ -72,7 +75,7 @@ class ScriptEditor extends Component {
7275
let nodeId = this.props.node.id
7376
let source = editor.getValue()
7477
if (source !== this.props.node.source) {
75-
this.context.surface.transaction(function(tx) {
78+
this.context.editorSession.transaction(function(tx) {
7679
tx.set([nodeId, 'source'], editor.getValue())
7780
}, { source: this, skipSelection: true })
7881
}
@@ -109,7 +112,7 @@ let ScriptPackage = {
109112
config.addNode(Script)
110113
config.addComponent(Script.type, ScriptEditor)
111114
config.addCommand('insert-script', InsertScriptCommand)
112-
config.addTool('insert-script', Tool, {target: 'insert'})
115+
config.addTool('insert-script', Tool, {toolGroup: 'insert'})
113116
config.addIcon('insert-script', { 'fontawesome': 'fa-code' })
114117
config.addLabel('insert-script', 'Source Code')
115118
}
@@ -160,20 +163,16 @@ let fixture = function(tx) {
160163
/*
161164
Application
162165
*/
163-
let config = {
164-
name: 'code-editor-example',
165-
configure: function(config) {
166-
config.import(ProseEditorPackage)
167-
config.import(ScriptPackage)
168-
}
169-
}
170-
let configurator = new ProseEditorConfigurator().import(config)
166+
let cfg = new ProseEditorConfigurator()
167+
cfg.import(ProseEditorPackage)
168+
cfg.import(ScriptPackage)
171169

172170
window.onload = function() {
173-
let doc = configurator.createArticle(fixture)
174-
let documentSession = new DocumentSession(doc)
171+
let doc = cfg.createArticle(fixture)
172+
let editorSession = new EditorSession(doc, {
173+
configurator: cfg
174+
})
175175
ProseEditor.mount({
176-
documentSession: documentSession,
177-
configurator: configurator
176+
editorSession: editorSession
178177
}, document.body)
179178
}

collab-writer/README.md

Lines changed: 0 additions & 7 deletions
This file was deleted.

collab-writer/app.css

Lines changed: 0 additions & 35 deletions
This file was deleted.

collab-writer/app.js

Lines changed: 0 additions & 164 deletions
This file was deleted.

common.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import url('../lib/font-awesome/css/font-awesome.min.css');
2+
3+
/* styles shared by all examples */
4+
@import './node_modules/substance/substance.css';
5+
@import './node_modules/substance/substance-reset.css';
6+
@import './node_modules/substance/substance-pagestyle.css';

focused/app.css

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/* Substance Component styles */
2-
@import '../lib/substance/substance.css';
3-
/* You may want to use your own reset and pagestyle */
4-
@import '../lib/substance/substance-reset.css';
5-
@import '../lib/substance/substance-pagestyle.css';
6-
@import url('../lib/font-awesome/css/font-awesome.min.css');
1+
@import '../common.css';
72

83
body {
94
overflow: hidden;

0 commit comments

Comments
 (0)