From 473212676ade788b6603a7a3c2bec726c6ca1579 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Tue, 12 Jan 2016 08:03:56 -0600 Subject: Fixed importFromUrl should parse by the file extension, and move to-markdown dependency to bower --- public/js/index.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'public/js') diff --git a/public/js/index.js b/public/js/index.js index 34cca1f8..1dfadc9a 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -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 :('); -- cgit v1.2.3