Fixed importFromUrl should parse by the file extension, and move to-markdown dependency to bower

This commit is contained in:
Wu Cheng-Han 2016-01-12 08:03:56 -06:00
parent 2ecec3b59a
commit 473212676a
4 changed files with 19 additions and 701 deletions

View file

@ -30,6 +30,7 @@
"js-url": "~2.0.2",
"socket.io-client": "~1.3.7",
"viz.js": "~1.3.0",
"js-yaml": "~3.4.6"
"js-yaml": "~3.4.6",
"to-markdown": "~1.3.0"
}
}

View file

@ -985,13 +985,17 @@ $('#refreshModalRefresh').click(function () {
function parseToEditor(data) {
var parsed = toMarkdown(data);
if (parsed)
editor.replaceRange(parsed, {
line: 0,
ch: 0
}, {
line: editor.lastLine(),
ch: editor.lastLine().length
}, '+input');
replaceAll(parsed);
}
function replaceAll(data) {
editor.replaceRange(data, {
line: 0,
ch: 0
}, {
line: editor.lastLine(),
ch: editor.lastLine().length
}, '+input');
}
function importFromUrl(url) {
@ -1005,7 +1009,11 @@ function importFromUrl(url) {
method: "GET",
url: url,
success: function (data) {
parseToEditor(data);
var extension = url.split('.').pop();
if (extension == 'html')
parseToEditor(data);
else
replaceAll(data);
},
error: function () {
alert('Import failed :(');

File diff suppressed because one or more lines are too long

View file

@ -35,7 +35,7 @@
<script src="/vendor/moment/min/moment-with-locales.js" defer></script>
<script src="/vendor/handlebars/handlebars.min.js" defer></script>
<script src="/vendor/emojify/js/emojify.js" defer></script>
<script src="/vendor/to-markdown.js" defer></script>
<script src="/vendor/to-markdown/dist/to-markdown.js" defer></script>
<script src="/vendor/raphael-min.js" defer></script>
<script src="/vendor/lodash.min.js" defer></script>
<script src="/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script>