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", "js-url": "~2.0.2",
"socket.io-client": "~1.3.7", "socket.io-client": "~1.3.7",
"viz.js": "~1.3.0", "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) { function parseToEditor(data) {
var parsed = toMarkdown(data); var parsed = toMarkdown(data);
if (parsed) if (parsed)
editor.replaceRange(parsed, { replaceAll(parsed);
line: 0, }
ch: 0
}, { function replaceAll(data) {
line: editor.lastLine(), editor.replaceRange(data, {
ch: editor.lastLine().length line: 0,
}, '+input'); ch: 0
}, {
line: editor.lastLine(),
ch: editor.lastLine().length
}, '+input');
} }
function importFromUrl(url) { function importFromUrl(url) {
@ -1005,7 +1009,11 @@ function importFromUrl(url) {
method: "GET", method: "GET",
url: url, url: url,
success: function (data) { success: function (data) {
parseToEditor(data); var extension = url.split('.').pop();
if (extension == 'html')
parseToEditor(data);
else
replaceAll(data);
}, },
error: function () { error: function () {
alert('Import failed :('); 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/moment/min/moment-with-locales.js" defer></script>
<script src="/vendor/handlebars/handlebars.min.js" defer></script> <script src="/vendor/handlebars/handlebars.min.js" defer></script>
<script src="/vendor/emojify/js/emojify.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/raphael-min.js" defer></script>
<script src="/vendor/lodash.min.js" defer></script> <script src="/vendor/lodash.min.js" defer></script>
<script src="/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script> <script src="/vendor/sequence-diagrams/sequence-diagram-min.js" defer></script>