Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding styling for the md content rewriting the extension to use iframe

uggrock456d90324984
diff --git a/data/ext/viewerMD/css/clearness-dark.css b/data/ext/viewerMD/css/clearness-dark.css
new file mode 100644
index 000000000..e9752d4e4
--- /dev/null
+++ b/data/ext/viewerMD/css/clearness-dark.css
@@ -0,0 +1,58 @@
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * solarized-light style
+ * made by rhio.kim
+ * powered by http://ethanschoonover.com/solarized
+ */
+.clearness-dark {
+ padding: 20px;
+ color: #ffffff;
+ font-size: 15px;
+ font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif;
+ background: #282a36;
+ -webkit-font-smoothing: antialiased;
+}
+.clearness-dark a {
+ color: #e03300;
+}
+.clearness-dark a:hover {
+ color: #ff4a14;
+}
+.clearness-dark h2 {
+ border-bottom: 1px solid #21232d;
+ line-height: 1.7em;
+}
+.clearness-dark h6 {
+ color: #a4a296;
+}
+.clearness-dark hr {
+ border: 1px solid #21232d;
+}
+.clearness-dark pre > code {
+ font-size: .9em;
+ font-family: Consolas, Inconsolata, Courier, monospace;
+}
+.clearness-dark blockquote {
+ border-left: 4px solid #121319;
+ padding: 0 15px;
+ font-style: italic;
+}
+.clearness-dark table {
+ background-color: #303241;
+}
+.clearness-dark table tr th,
+.clearness-dark table tr td {
+ border: 1px solid #4b4e65;
+}
+.clearness-dark table tr:nth-child(2n) {
+ background-color: #373a4b;
+}
+/**
+ * after less
+ */
\ No newline at end of file
diff --git a/data/ext/viewerMD/css/clearness.css b/data/ext/viewerMD/css/clearness.css
new file mode 100644
index 000000000..8aa991c3a
--- /dev/null
+++ b/data/ext/viewerMD/css/clearness.css
@@ -0,0 +1,79 @@
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * solarized-light style
+ * made by rhio.kim
+ * powered by http://ethanschoonover.com/solarized
+ */
+.clearness {
+ padding: 20px;
+ color: #737373;
+ font-size: 15px;
+ font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif;
+ background: #ffffff;
+ -webkit-font-smoothing: antialiased;
+}
+.clearness a {
+ color: #1e6ea7;
+}
+.clearness a:hover {
+ color: #268bd2;
+}
+.clearness h1,
+.clearness h2,
+.clearness h3,
+.clearness h4,
+.clearness h5 {
+ color: #404040;
+}
+.clearness h2 {
+ border-bottom: 1px solid #cccccc;
+ line-height: 1.7em;
+}
+.clearness h6 {
+ color: #666666;
+}
+.clearness hr {
+ border: 1px solid #e6e6e6;
+}
+.clearness pre > code {
+ font-size: .9em;
+ font-family: Consolas, Inconsolata, Courier, monospace;
+}
+.clearness blockquote {
+ padding: 0 15px;
+ font-style: italic;
+}
+.clearness blockquote:before {
+ content: "\201C";
+ font-size: 40px;
+ margin-left: -20px;
+ color: #aaa;
+}
+.clearness table {
+ background-color: #ffffff;
+ border-collapse: separate;
+ border-spacing: 2px;
+}
+.clearness table tr th,
+.clearness table tr td {
+ border: 0px;
+ padding: .2em 1em;
+}
+.clearness table tr th {
+ border-bottom: 1px solid #bfbfbf;
+}
+.clearness table tr td {
+ border-bottom: 1px solid #d9d9d9;
+}
+.clearness table tr:nth-child(2n) {
+ background-color: #ffffff;
+}
+/**
+ * after less
+ */
\ No newline at end of file
diff --git a/data/ext/viewerMD/css/github.css b/data/ext/viewerMD/css/github.css
new file mode 100644
index 000000000..585373d68
--- /dev/null
+++ b/data/ext/viewerMD/css/github.css
@@ -0,0 +1,58 @@
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * solarized-light style
+ * made by rhio.kim
+ * powered by http://ethanschoonover.com/solarized
+ */
+.github {
+ padding: 20px;
+ color: #000000;
+ font-size: 15px;
+ font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif;
+ background: #ffffff;
+ -webkit-font-smoothing: antialiased;
+}
+.github a {
+ color: #3269a0;
+}
+.github a:hover {
+ color: #4183c4;
+}
+.github h2 {
+ border-bottom: 1px solid #e6e6e6;
+ line-height: 1.7em;
+}
+.github h6 {
+ color: #777;
+}
+.github hr {
+ border: 1px solid #e6e6e6;
+}
+.github pre > code {
+ font-size: .9em;
+ font-family: Consolas, Inconsolata, Courier, monospace;
+}
+.github blockquote {
+ border-left: 4px solid #e6e6e6;
+ padding: 0 15px;
+ font-style: italic;
+}
+.github table {
+ background-color: #fafafa;
+}
+.github table tr th,
+.github table tr td {
+ border: 1px solid #e6e6e6;
+}
+.github table tr:nth-child(2n) {
+ background-color: #f2f2f2;
+}
+/**
+ * after less
+ */
diff --git a/data/ext/viewerMD/css/haroopad.css b/data/ext/viewerMD/css/haroopad.css
new file mode 100644
index 000000000..949f4362c
--- /dev/null
+++ b/data/ext/viewerMD/css/haroopad.css
@@ -0,0 +1,100 @@
+/*
+@import url(http://fonts.googleapis.com/css?family=Tauri);
+@import url(http://fonts.googleapis.com/css?family=Roboto+Condensed:300italic,400italic,700italic,400,300,700);
+*/
+
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * solarized-light style
+ * made by rhio.kim
+ * powered by http://ethanschoonover.com/solarized
+ */
+.haroopad {
+ padding: 20px;
+ color: #222222;
+ font-size: 15px;
+ font-family: 'Roboto Condensed', 'Tauri', "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif;
+ background: #ffffff;
+ -webkit-font-smoothing: antialiased;
+}
+.haroopad a {
+ color: #3269a0;
+}
+.haroopad a:hover {
+ color: #4183c4;
+}
+.haroopad h2 {
+ border-bottom: 1px solid #e6e6e6;
+ line-height: 1.7em;
+}
+.haroopad h6 {
+ color: #777;
+}
+.haroopad hr {
+ border: 1px solid #e6e6e6;
+}
+.haroopad p > code {
+ font-family: Consolas, Inconsolata, Courier, monospace;
+ color: #BD006A;
+}
+.haroopad pre > code {
+ font-size: 1em;
+ font-family: Consolas, Inconsolata, Courier, monospace;
+ letter-spacing: -1px;
+ font-weight: bold;
+}
+.haroopad blockquote {
+ border-left: 4px solid #e6e6e6;
+ padding: 0 15px;
+ font-style: italic;
+}
+.haroopad table {
+ background-color: #fafafa;
+}
+.haroopad table tr th,
+.haroopad table tr td {
+ border: 1px solid #e6e6e6;
+}
+.haroopad table tr:nth-child(2n) {
+ background-color: #f2f2f2;
+}
+/**
+ * after less
+ */
+/*
+.haroopad {
+
+ img {
+ .bordered(@border-color, @border-color, @border-color, @border-color);
+ .rounded(3px);
+ .box-shadow(0 0 7px darken(@border-color, 18%));
+
+ &:hover {
+ -webkit-animation-duration: 1s;
+ -webkit-animation-delay: .2s;
+ .pulse;
+ }
+ }
+
+ h1 {
+ -webkit-animation-duration: .5s;
+ -webkit-animation-delay: .2s;
+ .tada;
+ }
+
+ &>ul {
+ &>li {
+ -webkit-animation-duration: .5s;
+ -webkit-animation-delay: .2s;
+ .fadeInLeft;
+ }
+ }
+
+}
+*/
\ No newline at end of file
diff --git a/data/ext/viewerMD/css/markdown.css b/data/ext/viewerMD/css/markdown.css
new file mode 100644
index 000000000..56de26522
--- /dev/null
+++ b/data/ext/viewerMD/css/markdown.css
@@ -0,0 +1,158 @@
+/**
+ * standard markdown style
+ */
+.markdown {
+ padding: 20px;
+}
+.markdown a {
+ text-decoration: none;
+ vertical-align: baseline;
+}
+.markdown a:hover {
+ text-decoration: underline;
+}
+.markdown h1 {
+ font-size: 2.2em;
+ font-weight: bold;
+ margin: 1.5em 0 1em 0;
+}
+.markdown h2 {
+ font-size: 1.8em;
+ font-weight: bold;
+ margin: 1.275em 0 0.85em 0;
+}
+.markdown h3 {
+ font-size: 1.6em;
+ font-weight: bold;
+ margin: 1.125em 0 0.75em 0;
+}
+.markdown h4 {
+ font-size: 1.4em;
+ font-weight: bold;
+ margin: 0.99em 0 0.66em 0;
+}
+.markdown h5 {
+ font-size: 1.2em;
+ font-weight: bold;
+ margin: 0.855em 0 0.57em 0;
+}
+.markdown h6 {
+ font-size: 1em;
+ font-weight: bold;
+ margin: 0.75em 0 0.5em 0;
+}
+.markdown h1:first-child,
+.markdown h2:first-child,
+.markdown h3:first-child,
+.markdown h4:first-child,
+.markdown h5:first-child,
+.markdown h6:first-child {
+ margin-top: 0;
+}
+.markdown h1 + p,
+.markdown h2 + p,
+.markdown h3 + p,
+.markdown h4 + p,
+.markdown h5 + p,
+.markdown h6 + p {
+ margin-top: 0;
+}
+.markdown hr {
+ border: 1px solid #cccccc;
+}
+.markdown p {
+ margin: 1em 0;
+ word-wrap: break-word;
+}
+.markdown ol {
+ list-style-type: decimal;
+}
+.markdown li {
+ display: list-item;
+ line-height: 1.4em;
+}
+.markdown blockquote {
+ margin: 1em 20px;
+}
+.markdown blockquote > :first-child {
+ margin-top: 0;
+}
+.markdown blockquote > :last-child {
+ margin-bottom: 0;
+}
+.markdown blockquote cite:before {
+ content: '\2014 \00A0';
+}
+.markdown .code {
+ border-radius: 3px;
+ word-break: break-all;
+ word-wrap: break-word;
+}
+.markdown pre {
+ border-radius: 3px;
+ word-break: break-all;
+ word-wrap: break-word;
+ overflow: auto;
+}
+.markdown pre code {
+ display: block;
+}
+.markdown pre > code {
+ border: 1px solid #cccccc;
+ white-space: pre;
+ padding: .5em;
+ margin: 0;
+}
+.markdown code {
+ border-radius: 3px;
+ word-break: break-all;
+ word-wrap: break-word;
+ border: 1px solid #cccccc;
+ padding: 0 5px;
+ margin: 0 2px;
+}
+.markdown img {
+ max-width: 100%;
+}
+.markdown table {
+ padding: 0;
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+.markdown table tr th,
+.markdown table tr td {
+ border: 1px solid #cccccc;
+ margin: 0;
+ padding: 6px 13px;
+}
+.markdown table tr th {
+ font-weight: bold;
+}
+.markdown table tr th > :first-child {
+ margin-top: 0;
+}
+.markdown table tr th > :last-child {
+ margin-bottom: 0;
+}
+.markdown table tr td > :first-child {
+ margin-top: 0;
+}
+.markdown table tr td > :last-child {
+ margin-bottom: 0;
+}
+.markdown {
+ /* custom rule for haroopad */
+
+}
+.markdown em.underline {
+ font-style: normal;
+ text-decoration: underline;
+}
+.markdown strong.highlight {
+ color: black;
+ padding: 0 5px;
+ background-color: #fdffb6;
+ -webkit-box-shadow: #fdffb6 0 0 5px;
+ -moz-box-shadow: #fdffb6 0 0 5px;
+ box-shadow: #fdffb6 0 0 5px;
+}
diff --git a/data/ext/viewerMD/css/metro-vibes.css b/data/ext/viewerMD/css/metro-vibes.css
new file mode 100644
index 000000000..cf420df93
--- /dev/null
+++ b/data/ext/viewerMD/css/metro-vibes.css
@@ -0,0 +1,108 @@
+/*@import url(http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800);*/
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * made by rhio.kim
+ */
+.metro-vibes {
+ padding: 20px;
+ color: #8e8071;
+ font-size: 15px;
+ font-family: 'Open Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', sans-serif;
+ background: #ffffff;
+ -webkit-font-smoothing: antialiased;
+}
+.metro-vibes a {
+ color: #3269a0;
+}
+.metro-vibes a:hover {
+ color: #4183c4;
+}
+.metro-vibes h1,
+.metro-vibes h2,
+.metro-vibes h3,
+.metro-vibes h4,
+.metro-vibes h5 {
+ font-weight: 400;
+ color: #5c5146;
+ letter-spacing: -1px;
+}
+.metro-vibes h2 {
+ border-bottom: 1px solid #e6e6e6;
+ line-height: 1.7em;
+}
+.metro-vibes h6 {
+ color: #777;
+}
+.metro-vibes hr {
+ border: 1px solid #e6e6e6;
+}
+.metro-vibes p {
+ line-height: 19px;
+}
+.metro-vibes p > code {
+ font-family: 'Open Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', sans-serif;
+ color: #e86741;
+ font-size: .9em;
+}
+.metro-vibes pre > code {
+ font-size: 1em;
+ font-family: 'Open Sans', AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', sans-serif;
+ letter-spacing: -1px;
+ font-weight: normal;
+}
+.metro-vibes blockquote {
+ border-left: 4px solid #e6e6e6;
+ padding: 0 15px;
+ font-style: italic;
+ color: #e86741;
+}
+.metro-vibes table {
+ background-color: #fafafa;
+}
+.metro-vibes table tr th,
+.metro-vibes table tr td {
+ border: 1px solid #e6e6e6;
+}
+.metro-vibes table tr:nth-child(2n) {
+ background-color: #f2f2f2;
+}
+/**
+ * after less
+ */
+/*
+.haroopad {
+
+ img {
+ .bordered(@border-color, @border-color, @border-color, @border-color);
+ .rounded(3px);
+ .box-shadow(0 0 7px darken(@border-color, 18%));
+
+ &:hover {
+ -webkit-animation-duration: 1s;
+ -webkit-animation-delay: .2s;
+ .pulse;
+ }
+ }
+
+ h1 {
+ -webkit-animation-duration: .5s;
+ -webkit-animation-delay: .2s;
+ .tada;
+ }
+
+ &>ul {
+ &>li {
+ -webkit-animation-duration: .5s;
+ -webkit-animation-delay: .2s;
+ .fadeInLeft;
+ }
+ }
+
+}
+*/
\ No newline at end of file
diff --git a/data/ext/viewerMD/css/solarized-dark.css b/data/ext/viewerMD/css/solarized-dark.css
new file mode 100644
index 000000000..ca07e23ba
--- /dev/null
+++ b/data/ext/viewerMD/css/solarized-dark.css
@@ -0,0 +1,64 @@
+/*---------------------------------------------------
+ LESS Elements 0.9
+ ---------------------------------------------------
+ A set of useful LESS mixins
+ More info at: http://lesselements.com
+ ---------------------------------------------------*/
+/**
+ * https://github.com/rhiokim/markdown-css
+ * solarized-dark style
+ * made by rhio.kim
+ * powered by http://ethanschoonover.com/solarized
+ */.solarized-dark {
+ padding: 20px;
+ color: #839496;
+ font-size: 15px;
+ font-family: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", AppleSDGothicNeo-Medium, 'Segoe UI', 'Malgun Gothic', Verdana, Tahoma, sans-serif;
+ background: #002b36;
+ -webkit-font-smoothing: antialiased;
+}
+.solarized-dark a {
+ color: #1e6ea7;
+}
+.solarized-dark a:hover {
+ color: #268bd2;
+}
+.solarized-dark h1,
+.solarized-dark h2,
+.solarized-dark h3,
+.solarized-dark h4,
+.solarized-dark h5 {
+ color: #b58900;
+}
+.solarized-dark h2 {
+ border-bottom: 1px solid #005469;
+ line-height: 1.7em;
+}
+.solarized-dark h6 {
+ color: #694f00;
+}
+.solarized-dark hr {
+ border: 1px solid #001f27;
+}
+.solarized-dark pre > code {
+ font-size: .9em;
+ font-family: Consolas, Inconsolata, Courier, monospace;
+}
+.solarized-dark blockquote {
+ border-left: 4px solid #000203;
+ padding: 0 15px;
+ font-style: italic;
+}
+.solarized-dark table {
+ background-color: #003441;
+}
+.solarized-dark table tr th,
+.solarized-dark table tr td {
+ border: 1px solid #005065;
+}
+.solarized-dark table tr:nth-child(2n) {
+ background-color: #003b4b;
+}
+/**
+ * after less
+ */
\ No newline at end of file
diff --git a/data/ext/viewerMD/extension.css b/data/ext/viewerMD/extension.css
index a34823942..21daab195 100644
--- a/data/ext/viewerMD/extension.css
+++ b/data/ext/viewerMD/extension.css
@@ -1,3 +1,29 @@
+#viewerMD {
+ padding: 2px;
+ background-color: transparent;
+ z-index: 9999999;
+ position:fixed;
+ bottom: 0;
+ right: 0;
+}
+
+#viewerMD .iconBackground {
+ color: rgba(0,0,0,0.8);
+}
+
+#viewerMD .iconForeground {
+ color: #f2f2f2;
+}
+
+#viewerMD #viewerImageToolbar {
+ padding: 2px;
+ background-color: transparent;
+ z-index: 9999999;
+ position:fixed;
+ bottom: 0;
+ right: 0;
+}
+
.viewerMDContainer *{margin:0;padding:0;}
.viewerMDContainer {
diff --git a/data/ext/viewerMD/extension.js b/data/ext/viewerMD/extension.js
index 9027eb45e..878d5b841 100644
--- a/data/ext/viewerMD/extension.js
+++ b/data/ext/viewerMD/extension.js
@@ -7,27 +7,68 @@ define(function(require, exports, module) {
console.log("Loading viewerMD");
- exports.id = "viewerMD"; // ID should be equal to the directory name where the ext. is located
- exports.title = "MD Viewer";
- exports.type = "editor";
- exports.supportedFileTypes = [ "md", "markdown", "mdown" ];
+ var extensionTitle = "MardDown Viewer";
+ var extensionID = "viewerMD"; // ID should be equal to the directory name where the ext. is located
+ var extensionType = "viewer";
+ var extensionIcon = "icon-list";
+ var extensionVersion = "1.0";
+ var extensionManifestVersion = 1;
+ var extensionLicense = "AGPL";
+ var extensionSupportedFileTypes = [ "md", "markdown", "mdown" ];
var TSCORE = require("tscore");
- var md2htmlConverter;
- var containerElID;
- var currentFilePath;
+ var md2htmlConverter,
+ containerElID,
+ currentFilePath,
+ $iframeViewer,
+ $containerElement,
+ viewerToolbar;
- var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+exports.id;
+ var extensionDirectory = TSCORE.Config.getExtensionPath()+"/"+extensionID;
// GFM https://help.github.com/articles/github-flavored-markdown
exports.init = function(filePath, containerElementID) {
console.log("Initalization MD Viewer...");
containerElID = containerElementID;
+
+ $containerElement = $('#'+containerElID);
+
currentFilePath = filePath;
- require(['css!'+extensionDirectory+'/extension.css']);
- require([extensionDirectory+'/marked/marked.js'], function(marked) {
+
+ //var fileExt = TSCORE.TagUtils.extractFileExtension(filePath);
+
+ $containerElement.empty();
+ $containerElement.css("background-color","white");
+
+ $containerElement.append($('<iframe>', {
+ sandbox: "allow-same-origin allow-scripts",
+ id: "iframeViewer",
+ "nwdisable": "",
+ "nwfaketop": ""
+ })
+ );
+
+ $iframeViewer = $("#iframeViewer");
+ if($iframeViewer != undefined) {
+ var $iframeViewerHead = $iframeViewer.contents().find('head');
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/extension.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/bootstrap/css/bootstrap.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/../../libs/font-awesome/css/font-awesome.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/markdown.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/github.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/haroopad.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/metro-vibes.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/solarized-dark.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness.css' }));
+ $iframeViewerHead.append($('<link/>', { rel: 'stylesheet', href: extensionDirectory+'/css/clearness-dark.css' }));
+ }
+
+ require([
+ extensionDirectory+'/marked/marked.js',
+ "text!"+extensionDirectory+'/mainUI.html'
+ ], function(marked, uiTPL) {
md2htmlConverter = marked;
md2htmlConverter.setOptions({
renderer: new marked.Renderer(),
@@ -41,6 +82,10 @@ define(function(require, exports, module) {
smartLists: true,
smartypants: false
});
+
+ var uiTemplate = Handlebars.compile( uiTPL );
+ viewerToolbar = uiTemplate({ id: extensionID });
+
TSCORE.IO.loadTextFile(filePath);
});
};
@@ -54,39 +99,84 @@ define(function(require, exports, module) {
};
exports.setContent = function(content) {
- var UTF8_BOM = "\ufeff";
-
- // removing the UTF8 bom because it brakes thing like #header1 in the beginning of the document
- if(content.indexOf(UTF8_BOM) === 0) {
- content = content.substring(1,content.length);
- }
-
- var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
- $('#'+containerElID).append($("<div>", { class: "viewerMDContainer" })
- .append(md2htmlConverter(cleanedContent))
- );
-
- var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
-
- // fixing embedding of local images
- $('#'+containerElID+" img[src]").each(function(){
- var currentSrc = $( this ).attr("src");
- if(currentSrc.indexOf("http://") === 0 || currentSrc.indexOf("https://") === 0 || currentSrc.indexOf("data:") === 0) {
- // do nothing if src begins with http(s)://
- } else {
- $( this ).attr("src","file://"+fileDirectory+TSCORE.dirSeparator+currentSrc);
- }
- });
-
- // making all links open in the user default browser
- $('#'+containerElID+ " a").bind('click', function(e){
- e.preventDefault();
- TSCORE.openLinkExternally($(this).attr("href"));
- });
+ var UTF8_BOM = "\ufeff";
+
+ // removing the UTF8 bom because it brakes thing like #header1 in the beginning of the document
+ if(content.indexOf(UTF8_BOM) === 0) {
+ content = content.substring(1,content.length);
+ }
+
+ var fileDirectory = TSCORE.TagUtils.extractContainingDirectoryPath(currentFilePath);
+
+ var cleanedContent = content.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,"");
+ var mdContent = md2htmlConverter(cleanedContent);
+
+ var styles = ['','github','haroopad','metro-vibes','solarized-dark','clearness','clearness-dark'];
+ var currentStyleIndex = 0;
+
+ if($iframeViewer != undefined) {
+ // TODO clear content
+ var $iframeViewerBody = $iframeViewer.contents().find('body');
+ $iframeViewerBody.children().remove();
+ $iframeViewerBody.append($('<div/>', { id: 'htmlContent', class: "markdown" }).append(mdContent));
+ $iframeViewerBody.append(viewerToolbar);
+
+ var $iframeHTMLContent = $iframeViewer.contents().find('#htmlContent'); // //"viewerMDContainer"
+
+ $iframeViewerBody.find( "#changeStyleButton" ).bind('click', function(){
+ currentStyleIndex = currentStyleIndex + 1;
+ if(currentStyleIndex >= styles.length) {
+ currentStyleIndex = 0;
+ }
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown');
+ $iframeHTMLContent.addClass(styles[currentStyleIndex]);
+ });
+
+ $iframeViewerBody.find( "#increaseFontSizeButton" ).bind('click', function(e){
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown');
+ $iframeHTMLContent.addClass(styles[currentStyleIndex]);
+ $iframeHTMLContent.addClass('zoomLarger');
+ });
+
+ $iframeViewerBody.find( "#decreaseFontSizeButton" ).bind('click', function(e){
+ $iframeHTMLContent.removeClass();
+ $iframeHTMLContent.addClass('markdown');
+ $iframeHTMLContent.addClass(styles[currentStyleIndex]);
+ $iframeHTMLContent.addClass('zoomDefault');
+ });
+
+ // making all links open in the user default browser
+ $iframeViewerBody.find( "a" ).bind('click', function(e){
+ e.preventDefault();
+ TSCORE.openLinkExternally($(this).attr("href"));
+ });
+
+ // fixing embedding of local images
+ $iframeViewerBody.find( "img[src]").each(function(){
+ var currentSrc = $( this ).attr("src");
+ if(currentSrc.indexOf("http://") == 0 || currentSrc.indexOf("https://") == 0 || currentSrc.indexOf("data:") == 0) {
+ // do nothing if src begins with http(s):// or data:
+ } else {
+ $( this ).attr("src","file://"+fileDirectory+TSCORE.dirSeparator+currentSrc);
+ }
+ });
+ }
};
exports.getContent = function() {
//$('#'+containerElID).html();
};
+ // Extension Vars
+ exports.Title = extensionTitle;
+ exports.ID = extensionID;
+ exports.Type = extensionType;
+ exports.Icon = extensionIcon;
+ exports.Version = extensionVersion;
+ exports.ManifestVersion = extensionManifestVersion;
+ exports.License = extensionLicense;
+ exports.SupportedFileTypes = extensionSupportedFileTypes;
+
});
\ No newline at end of file
diff --git a/data/ext/viewerMD/mainUI.html b/data/ext/viewerMD/mainUI.html
new file mode 100644
index 000000000..15f37a782
--- /dev/null
+++ b/data/ext/viewerMD/mainUI.html
@@ -0,0 +1,12 @@
+<div class="btn-toolbar" id="{{id}}">
+ <div class="btn-group">
+ <button class="btn btn-link btn-lg" id="changeStyleButton"><span class="fa-stack">
+ <i class="fa fa-circle fa-stack-base fa-stack-2x iconBackground"></i><i class="fa fa-adjust fa-stack-1x iconForeground"></i></span></button>
+ <button class="btn btn-link btn-lg" id="decreaseFontSizeButton"><span class="fa-stack">
+ <i class="fa fa-circle fa-stack-base fa-stack-2x iconBackground"></i><i class="fa fa-search-minus fa-stack-1x iconForeground"></i></span></button>
+ <button class="btn btn-link btn-lg" id="increaseFontSizeButton"><span class="fa-stack">
+ <i class="fa fa-circle fa-stack-base fa-stack-2x iconBackground"></i><i class="fa fa-search-plus fa-stack-1x iconForeground"></i></span></button>
+ <button class="btn btn-link btn-lg" id="ZoomReset"><span class="fa-stack">
+ <i class="fa fa-circle fa-stack-base fa-stack-2x iconBackground"></i><i class="fa fa-search fa-stack-1x iconForeground"></i></span></button>
+ </div>
+</div>