From d43a758a372a46eebceaa6154d9a4914075192ca Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Tue, 30 Apr 2013 17:54:19 +0100 Subject: [PATCH] Markdown mode added, fix to tag display Markdown added as a mode CodeMirror changed their object structure to include another child - htmlState If it's a markdown file we're editing, after loading our file into the stickyTab, onload of this parse our content through mmd to this window --- lib/ice-coder.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 2daa7be..832d9df 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -215,6 +215,7 @@ var ICEcoder = { : fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby") : fileName.indexOf('.css')>0 ? cM.setOption("mode","css") : fileName.indexOf('.less')>0 ? cM.setOption("mode","less") + : fileName.indexOf('.md')>0 ? cM.setOption("mode","markdown") : cM.setOption("mode","application/x-httpd-php"); } }, @@ -1008,7 +1009,7 @@ var ICEcoder = { state = cM.getTokenAt(cM.getCursor()).state; if ("undefined" != typeof state.curState) { ICEcoder.htmlTagArray = []; - for (cx = state.curState.context; cx; cx = cx.prev) { + for (cx = state.curState.htmlState.context; cx; cx = cx.prev) { if ("undefined" != typeof cx.tagName) { ICEcoder.htmlTagArray.unshift(cx.tagName); } @@ -1107,7 +1108,8 @@ var ICEcoder = { else if (fileName.indexOf(".coffee")>0) {caretLocType="CoffeeScript"} else if (fileName.indexOf(".rb")>0) {caretLocType="Ruby"} else if (fileName.indexOf(".css")>0) {caretLocType="CSS"} - else if (fileName.indexOf(".less")>0) {caretLocType="LESS"}; + else if (fileName.indexOf(".less")>0) {caretLocType="LESS"} + else if (fileName.indexOf(".md")>0) {caretLocType="Markdown"}; ICEcoder.caretLocType = caretLocType; }, @@ -2047,7 +2049,14 @@ var ICEcoder = { // CTRL+Enter (Open Webpage) } else if(key==13 && evt.ctrlKey && top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1] != "/[NEW]") { if (top.ICEcoder.stickyTabMaybe) { - top.ICEcoder.stickyTab = window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1],"stickyTab"); + var filepath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]; + var filename = filepath.substr(filepath.lastIndexOf("/")+1); + var fileExt = filename.substr(filename.lastIndexOf(".")+1); + var cM = ICEcoder.getcMInstance(); + top.ICEcoder.stickyTab = window.open(filepath,"stickyTab"); + if (["md"].indexOf(fileExt) > -1) { + top.ICEcoder.stickyTab.onload = function() {top.ICEcoder.stickyTab.document.documentElement.innerHTML = mmd(cM.getValue())}; + } } else { window.open(top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]); }