Skip to content
This repository was archived by the owner on Nov 6, 2024. It is now read-only.

Commit 2e42588

Browse files
authored
Merge pull request #1 from mint-lang/development
3.0.0
2 parents ca16e92 + 8086868 commit 2e42588

File tree

3 files changed

+33
-36
lines changed

3 files changed

+33
-36
lines changed

mint.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@
55
],
66
"external-javascripts": [
77
"assets/asset-loader.js"
8-
],
9-
"dependencies": {
10-
"mint-core": {
11-
"repository": "https://github.com/mint-lang/mint-core",
12-
"constraint": "0.2.0 <= v < 1.0.0"
13-
}
14-
}
8+
]
159
}

source/AssetLoader.mint

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ module AssetLoader {
1111
}
1212

1313
/* Waits for all promises to load. */
14-
fun loadAll(method : Function(String, Promise(Never, Void)), urls : Array(String)) : Promise(Never, Void) {
14+
fun loadAll (
15+
method : Function(String, Promise(Never, Void)),
16+
urls : Array(String)
17+
) : Promise(Never, Void) {
1518
`Assets.loadAll(method, urls)`
1619
}
1720
}

source/CodeMirror.mint

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22
component CodeMirror {
33
/* The JavaScript files of Codemirror to load, either locally or from a CDN. */
44
property javascripts : Array(String) = [
5-
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.39.0/codemirror.min.js"
5+
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.39.0" \
6+
"/codemirror.min.js"
67
]
78

89
/* The CSS files of Codemirror to load, either locally or from a CDN. */
910
property styles : Array(String) = [
10-
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.39.0/codemirror.min.css"
11+
"https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.39.0" \
12+
"/codemirror.min.css"
1113
]
1214

1315
/* Handler for the change event. */
14-
property onChange : Function(String, Void) = ((value : String) : Void => { void })
16+
property onChange : Function(String, a) = ((value : String) : Void => { void })
1517

1618
/* The content to display until the editor is loaded. */
17-
property loadingContent : Html = Html.empty()
19+
property loadingContent : Html = <></>
1820

1921
/* Whether or not show line numbers. */
2022
property lineNumbers : Bool = true
@@ -29,8 +31,8 @@ component CodeMirror {
2931
property mode : String = ""
3032

3133
/* Loads all assets when the components mounts. */
32-
fun componentDidMount : Void {
33-
do {
34+
fun componentDidMount : Promise(Never, Void) {
35+
sequence {
3436
AssetLoader.loadAll(AssetLoader.loadScript, javascripts)
3537
AssetLoader.loadAll(AssetLoader.loadStyle, styles)
3638
initializeEditor()
@@ -48,27 +50,25 @@ component CodeMirror {
4850
}
4951

5052
/* Initializes the editor for the given dom element. */
51-
fun initializeEditor () : Void {
52-
do {
53-
`
54-
(() => {
55-
if (!this.element) { return }
56-
if (this.editor) { return }
57-
58-
this.editor = CodeMirror.fromTextArea(this.element, {
59-
lineNumbers: this.lineNumbers,
60-
theme: this.theme,
61-
mode: this.mode,
62-
})
63-
64-
this.editor.on('change', (value) => {
65-
this.onChange(this.editor.getValue())
66-
})
67-
68-
this.forceUpdate()
69-
})()
70-
`
71-
}
53+
fun initializeEditor : Void {
54+
`
55+
(() => {
56+
if (!this.element) { return }
57+
if (this.editor) { return }
58+
59+
this.editor = CodeMirror.fromTextArea(this.element, {
60+
lineNumbers: this.lineNumbers,
61+
theme: this.theme,
62+
mode: this.mode,
63+
})
64+
65+
this.editor.on('change', (value) => {
66+
this.onChange(this.editor.getValue())
67+
})
68+
69+
this.forceUpdate()
70+
})()
71+
`
7272
}
7373

7474
/* After an update, update the underlying editor instance. */
@@ -107,7 +107,7 @@ component CodeMirror {
107107
[
108108
<textarea::editor ref={saveReference}/>,
109109
if (`this.editor`) {
110-
Html.empty()
110+
<></>
111111
} else {
112112
loadingContent
113113
}

0 commit comments

Comments
 (0)