Skip to content

Commit 4732126

Browse files
committed
Fixed importFromUrl should parse by the file extension, and move to-markdown dependency to bower
1 parent 2ecec3b commit 4732126

4 files changed

Lines changed: 19 additions & 701 deletions

File tree

bower.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"js-url": "~2.0.2",
3131
"socket.io-client": "~1.3.7",
3232
"viz.js": "~1.3.0",
33-
"js-yaml": "~3.4.6"
33+
"js-yaml": "~3.4.6",
34+
"to-markdown": "~1.3.0"
3435
}
3536
}

public/js/index.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,17 @@ $('#refreshModalRefresh').click(function () {
985985
function parseToEditor(data) {
986986
var parsed = toMarkdown(data);
987987
if (parsed)
988-
editor.replaceRange(parsed, {
989-
line: 0,
990-
ch: 0
991-
}, {
992-
line: editor.lastLine(),
993-
ch: editor.lastLine().length
994-
}, '+input');
988+
replaceAll(parsed);
989+
}
990+
991+
function replaceAll(data) {
992+
editor.replaceRange(data, {
993+
line: 0,
994+
ch: 0
995+
}, {
996+
line: editor.lastLine(),
997+
ch: editor.lastLine().length
998+
}, '+input');
995999
}
9961000

9971001
function importFromUrl(url) {
@@ -1005,7 +1009,11 @@ function importFromUrl(url) {
10051009
method: "GET",
10061010
url: url,
10071011
success: function (data) {
1008-
parseToEditor(data);
1012+
var extension = url.split('.').pop();
1013+
if (extension == 'html')
1014+
parseToEditor(data);
1015+
else
1016+
replaceAll(data);
10091017
},
10101018
error: function () {
10111019
alert('Import failed :(');

0 commit comments

Comments
 (0)