Repaired viewer
This commit is contained in:
parent
f732b99d91
commit
55a1e0f1b2
@ -1,9 +1,10 @@
|
|||||||
define(function() {
|
define(function() {
|
||||||
|
|
||||||
function Extension(extensionId, extensionName, isOptional) {
|
function Extension(extensionId, extensionName, isOptional, disableInViewer) {
|
||||||
this.extensionId = extensionId;
|
this.extensionId = extensionId;
|
||||||
this.extensionName = extensionName;
|
this.extensionName = extensionName;
|
||||||
this.isOptional = isOptional;
|
this.isOptional = isOptional;
|
||||||
|
this.disableInViewer = disableInViewer;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Extension;
|
return Extension;
|
||||||
|
@ -82,6 +82,9 @@ define([
|
|||||||
_.each(extensionList, function(extension) {
|
_.each(extensionList, function(extension) {
|
||||||
extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]);
|
extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]);
|
||||||
extension.config.enabled = !extension.isOptional || extension.config.enabled === undefined || extension.config.enabled === true;
|
extension.config.enabled = !extension.isOptional || extension.config.enabled === undefined || extension.config.enabled === true;
|
||||||
|
if(viewerMode === true && extension.disableInViewer) {
|
||||||
|
extension.config.enabled = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Call every onInit callbacks
|
// Call every onInit callbacks
|
||||||
@ -157,17 +160,18 @@ define([
|
|||||||
var previewContentsJQElt = undefined;
|
var previewContentsJQElt = undefined;
|
||||||
extensionMgr["onAsyncPreview"] = function() {
|
extensionMgr["onAsyncPreview"] = function() {
|
||||||
logger.log("onAsyncPreview");
|
logger.log("onAsyncPreview");
|
||||||
|
logger.log("Conversion time: " + (new Date() - extensionMgr.previewStartTime));
|
||||||
// Call onPreviewFinished callbacks when all async preview are finished
|
// Call onPreviewFinished callbacks when all async preview are finished
|
||||||
var counter = 0;
|
var counter = 0;
|
||||||
function tryFinished() {
|
function tryFinished() {
|
||||||
if(++counter === nbAsyncPreviewCallback) {
|
if(++counter === nbAsyncPreviewCallback) {
|
||||||
|
logger.log("Preview time: " + (new Date() - extensionMgr.previewStartTime));
|
||||||
_.defer(function() {
|
_.defer(function() {
|
||||||
var html = "";
|
var html = "";
|
||||||
_.each(previewContentsElt.children, function(elt) {
|
_.each(previewContentsElt.children, function(elt) {
|
||||||
html += elt.innerHTML;
|
html += elt.innerHTML;
|
||||||
});
|
});
|
||||||
onPreviewFinished(utils.trim(html));
|
onPreviewFinished(utils.trim(html));
|
||||||
logger.log("Preview time: " + (new Date() - extensionMgr.previewStartTime));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ define([
|
|||||||
"text!html/buttonHtmlCodeSettingsBlock.html",
|
"text!html/buttonHtmlCodeSettingsBlock.html",
|
||||||
], function($, _, utils, Extension, buttonHtmlCodeHTML, buttonHtmlCodeSettingsBlockHTML) {
|
], function($, _, utils, Extension, buttonHtmlCodeHTML, buttonHtmlCodeSettingsBlockHTML) {
|
||||||
|
|
||||||
var buttonHtmlCode = new Extension("buttonHtmlCode", 'Button "HTML code"', true);
|
var buttonHtmlCode = new Extension("buttonHtmlCode", 'Button "HTML code"', true, true);
|
||||||
buttonHtmlCode.settingsBlock = buttonHtmlCodeSettingsBlockHTML;
|
buttonHtmlCode.settingsBlock = buttonHtmlCodeSettingsBlockHTML;
|
||||||
buttonHtmlCode.defaultConfig = {
|
buttonHtmlCode.defaultConfig = {
|
||||||
template: "<%= documentHTML %>",
|
template: "<%= documentHTML %>",
|
||||||
@ -21,6 +21,11 @@ define([
|
|||||||
newConfig.template = utils.getInputValue("#textarea-html-code-template");
|
newConfig.template = utils.getInputValue("#textarea-html-code-template");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var extensionMgr = undefined;
|
||||||
|
buttonHtmlCode.onExtensionMgrCreated = function(extensionMgrParameter) {
|
||||||
|
extensionMgr = extensionMgrParameter;
|
||||||
|
};
|
||||||
|
|
||||||
buttonHtmlCode.onCreatePreviewButton = function() {
|
buttonHtmlCode.onCreatePreviewButton = function() {
|
||||||
return $(buttonHtmlCodeHTML);
|
return $(buttonHtmlCodeHTML);
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@ define([
|
|||||||
"text!html/buttonStatSettingsBlock.html",
|
"text!html/buttonStatSettingsBlock.html",
|
||||||
], function($, _, utils, Extension, buttonStatHTML, buttonStatSettingsBlockHTML) {
|
], function($, _, utils, Extension, buttonStatHTML, buttonStatSettingsBlockHTML) {
|
||||||
|
|
||||||
var buttonStat = new Extension("buttonStat", 'Button "Statistics"', true);
|
var buttonStat = new Extension("buttonStat", 'Button "Statistics"', true, true);
|
||||||
buttonStat.settingsBlock = buttonStatSettingsBlockHTML;
|
buttonStat.settingsBlock = buttonStatSettingsBlockHTML;
|
||||||
buttonStat.defaultConfig = {
|
buttonStat.defaultConfig = {
|
||||||
name1: "Characters",
|
name1: "Characters",
|
||||||
|
@ -7,7 +7,7 @@ define([
|
|||||||
"libs/jquery.mousewheel"
|
"libs/jquery.mousewheel"
|
||||||
], function($, _, Extension, scrollLinkSettingsBlockHTML) {
|
], function($, _, Extension, scrollLinkSettingsBlockHTML) {
|
||||||
|
|
||||||
var scrollLink = new Extension("scrollLink", "Scroll Link", true);
|
var scrollLink = new Extension("scrollLink", "Scroll Link", true, true);
|
||||||
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
||||||
|
|
||||||
var sectionList = undefined;
|
var sectionList = undefined;
|
||||||
|
@ -245,6 +245,9 @@
|
|||||||
Markdown.Extra.prototype.hashExtraBlock = function(block) {
|
Markdown.Extra.prototype.hashExtraBlock = function(block) {
|
||||||
return '\n<p>~X' + (this.hashBlocks.push(block) - 1) + 'X</p>\n';
|
return '\n<p>~X' + (this.hashBlocks.push(block) - 1) + 'X</p>\n';
|
||||||
};
|
};
|
||||||
|
Markdown.Extra.prototype.hashExtraInline = function(block) {
|
||||||
|
return '~X' + (this.hashBlocks.push(block) - 1) + 'X';
|
||||||
|
};
|
||||||
|
|
||||||
// Replace placeholder blocks in `text` with their corresponding
|
// Replace placeholder blocks in `text` with their corresponding
|
||||||
// html blocks in the hashBlocks array.
|
// html blocks in the hashBlocks array.
|
||||||
@ -252,7 +255,7 @@
|
|||||||
var self = this;
|
var self = this;
|
||||||
function recursiveUnHash() {
|
function recursiveUnHash() {
|
||||||
var hasHash = false;
|
var hasHash = false;
|
||||||
text = text.replace(/<p>~X(\d+)X<\/p>/g, function(wholeMatch, m1) {
|
text = text.replace(/(?:<p>)?~X(\d+)X(?:<\/p>)?/g, function(wholeMatch, m1) {
|
||||||
hasHash = true;
|
hasHash = true;
|
||||||
var key = parseInt(m1, 10);
|
var key = parseInt(m1, 10);
|
||||||
return self.hashBlocks[key];
|
return self.hashBlocks[key];
|
||||||
@ -495,9 +498,10 @@
|
|||||||
}
|
}
|
||||||
footnoteCounter++;
|
footnoteCounter++;
|
||||||
self.usedFootnotes.push(id);
|
self.usedFootnotes.push(id);
|
||||||
return '<a href="#fn:' + id + '" id="fnref:' + id
|
var html = '<a href="#fn:' + id + '" id="fnref:' + id
|
||||||
+ '" title="See footnote" class="footnote">' + footnoteCounter
|
+ '" title="See footnote" class="footnote">' + footnoteCounter
|
||||||
+ '</a>';
|
+ '</a>';
|
||||||
|
return self.hashExtraInline(html);
|
||||||
});
|
});
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
|
27
viewer.html
27
viewer.html
@ -2,7 +2,8 @@
|
|||||||
<html manifest="cache.manifest">
|
<html manifest="cache.manifest">
|
||||||
<head>
|
<head>
|
||||||
<title>StackEdit Viewer</title>
|
<title>StackEdit Viewer</title>
|
||||||
<link rel="canonical" href="http://benweet.github.io/stackedit/viewer.html">
|
<link rel="canonical"
|
||||||
|
href="http://benweet.github.io/stackedit/viewer.html">
|
||||||
<link rel="icon" href="img/stackedit-32.ico" type="image/x-icon">
|
<link rel="icon" href="img/stackedit-32.ico" type="image/x-icon">
|
||||||
<link rel="shortcut icon" href="img/stackedit-32.ico"
|
<link rel="shortcut icon" href="img/stackedit-32.ico"
|
||||||
type="image/x-icon">
|
type="image/x-icon">
|
||||||
@ -22,7 +23,12 @@
|
|||||||
if(theme) {
|
if(theme) {
|
||||||
document.write('<link href="themes/' + theme + '/' + theme + '.css" rel="stylesheet">');
|
document.write('<link href="themes/' + theme + '/' + theme + '.css" rel="stylesheet">');
|
||||||
}
|
}
|
||||||
var require = { baseUrl : "js", deps : [ "main" + suffix ] };
|
var require = {
|
||||||
|
baseUrl: "js",
|
||||||
|
deps: [
|
||||||
|
"main" + suffix
|
||||||
|
]
|
||||||
|
};
|
||||||
var viewerMode = true;
|
var viewerMode = true;
|
||||||
</script>
|
</script>
|
||||||
<script src="js/libs/require.js"></script>
|
<script src="js/libs/require.js"></script>
|
||||||
@ -50,7 +56,8 @@
|
|||||||
class="icon-download-alt"></i> Save as HTML</a></li>
|
class="icon-download-alt"></i> Save as HTML</a></li>
|
||||||
<li><a class="action-download-template" href="#"><i
|
<li><a class="action-download-template" href="#"><i
|
||||||
class="icon-download-alt"></i> Save using template</a></li>
|
class="icon-download-alt"></i> Save using template</a></li>
|
||||||
</ul></li>
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="btn-group">
|
<li class="btn-group">
|
||||||
<button class="btn dropdown-toggle action-open-file"
|
<button class="btn dropdown-toggle action-open-file"
|
||||||
data-toggle="dropdown" title="Open local document">
|
data-toggle="dropdown" title="Open local document">
|
||||||
@ -63,10 +70,12 @@
|
|||||||
type="text" id="file-search" class="span3">
|
type="text" id="file-search" class="span3">
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul></li>
|
</ul>
|
||||||
|
</li>
|
||||||
<li class="btn-group"><button class="btn action-open-stackedit"
|
<li class="btn-group"><button class="btn action-open-stackedit"
|
||||||
title="Open StackEdit"><i
|
title="Open StackEdit">
|
||||||
class="icon-stackedit"></i></button></li>
|
<i class="icon-stackedit"></i>
|
||||||
|
</button></li>
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li><i class="working-indicator icon-none"></i></li>
|
<li><i class="working-indicator icon-none"></i></li>
|
||||||
@ -76,7 +85,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="wmd-button-bar" class="hide"></div>
|
<div id="wmd-button-bar" class="hide"></div>
|
||||||
<textarea id="wmd-input" class="hide"></textarea>
|
<textarea id="wmd-input" class="hide"></textarea>
|
||||||
<div id="preview-container"></div>
|
<div class="preview-container">
|
||||||
|
<div id="preview-contents">
|
||||||
|
<div id="wmd-preview" class="preview-content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="modal-non-unique" class="modal hide">
|
<div id="modal-non-unique" class="modal hide">
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
|
Loading…
Reference in New Issue
Block a user