Repaired viewer
This commit is contained in:
parent
f732b99d91
commit
55a1e0f1b2
@ -1,9 +1,10 @@
|
||||
define(function() {
|
||||
|
||||
function Extension(extensionId, extensionName, isOptional) {
|
||||
function Extension(extensionId, extensionName, isOptional, disableInViewer) {
|
||||
this.extensionId = extensionId;
|
||||
this.extensionName = extensionName;
|
||||
this.isOptional = isOptional;
|
||||
this.disableInViewer = disableInViewer;
|
||||
}
|
||||
|
||||
return Extension;
|
||||
|
@ -82,6 +82,9 @@ define([
|
||||
_.each(extensionList, function(extension) {
|
||||
extension.config = _.extend({}, extension.defaultConfig, extensionSettings[extension.extensionId]);
|
||||
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
|
||||
@ -157,17 +160,18 @@ define([
|
||||
var previewContentsJQElt = undefined;
|
||||
extensionMgr["onAsyncPreview"] = function() {
|
||||
logger.log("onAsyncPreview");
|
||||
logger.log("Conversion time: " + (new Date() - extensionMgr.previewStartTime));
|
||||
// Call onPreviewFinished callbacks when all async preview are finished
|
||||
var counter = 0;
|
||||
function tryFinished() {
|
||||
if(++counter === nbAsyncPreviewCallback) {
|
||||
logger.log("Preview time: " + (new Date() - extensionMgr.previewStartTime));
|
||||
_.defer(function() {
|
||||
var html = "";
|
||||
_.each(previewContentsElt.children, function(elt) {
|
||||
html += elt.innerHTML;
|
||||
});
|
||||
onPreviewFinished(utils.trim(html));
|
||||
logger.log("Preview time: " + (new Date() - extensionMgr.previewStartTime));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
"text!html/buttonHtmlCodeSettingsBlock.html",
|
||||
], 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.defaultConfig = {
|
||||
template: "<%= documentHTML %>",
|
||||
@ -21,6 +21,11 @@ define([
|
||||
newConfig.template = utils.getInputValue("#textarea-html-code-template");
|
||||
};
|
||||
|
||||
var extensionMgr = undefined;
|
||||
buttonHtmlCode.onExtensionMgrCreated = function(extensionMgrParameter) {
|
||||
extensionMgr = extensionMgrParameter;
|
||||
};
|
||||
|
||||
buttonHtmlCode.onCreatePreviewButton = function() {
|
||||
return $(buttonHtmlCodeHTML);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
"text!html/buttonStatSettingsBlock.html",
|
||||
], 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.defaultConfig = {
|
||||
name1: "Characters",
|
||||
|
@ -7,7 +7,7 @@ define([
|
||||
"libs/jquery.mousewheel"
|
||||
], function($, _, Extension, scrollLinkSettingsBlockHTML) {
|
||||
|
||||
var scrollLink = new Extension("scrollLink", "Scroll Link", true);
|
||||
var scrollLink = new Extension("scrollLink", "Scroll Link", true, true);
|
||||
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
||||
|
||||
var sectionList = undefined;
|
||||
|
@ -245,6 +245,9 @@
|
||||
Markdown.Extra.prototype.hashExtraBlock = function(block) {
|
||||
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
|
||||
// html blocks in the hashBlocks array.
|
||||
@ -252,7 +255,7 @@
|
||||
var self = this;
|
||||
function recursiveUnHash() {
|
||||
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;
|
||||
var key = parseInt(m1, 10);
|
||||
return self.hashBlocks[key];
|
||||
@ -495,9 +498,10 @@
|
||||
}
|
||||
footnoteCounter++;
|
||||
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
|
||||
+ '</a>';
|
||||
return self.hashExtraInline(html);
|
||||
});
|
||||
|
||||
return text;
|
||||
|
27
viewer.html
27
viewer.html
@ -2,7 +2,8 @@
|
||||
<html manifest="cache.manifest">
|
||||
<head>
|
||||
<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="shortcut icon" href="img/stackedit-32.ico"
|
||||
type="image/x-icon">
|
||||
@ -22,7 +23,12 @@
|
||||
if(theme) {
|
||||
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;
|
||||
</script>
|
||||
<script src="js/libs/require.js"></script>
|
||||
@ -50,7 +56,8 @@
|
||||
class="icon-download-alt"></i> Save as HTML</a></li>
|
||||
<li><a class="action-download-template" href="#"><i
|
||||
class="icon-download-alt"></i> Save using template</a></li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="btn-group">
|
||||
<button class="btn dropdown-toggle action-open-file"
|
||||
data-toggle="dropdown" title="Open local document">
|
||||
@ -63,10 +70,12 @@
|
||||
type="text" id="file-search" class="span3">
|
||||
</div>
|
||||
</li>
|
||||
</ul></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="btn-group"><button class="btn action-open-stackedit"
|
||||
title="Open StackEdit"><i
|
||||
class="icon-stackedit"></i></button></li>
|
||||
title="Open StackEdit">
|
||||
<i class="icon-stackedit"></i>
|
||||
</button></li>
|
||||
</ul>
|
||||
<ul class="nav pull-right">
|
||||
<li><i class="working-indicator icon-none"></i></li>
|
||||
@ -76,7 +85,11 @@
|
||||
</div>
|
||||
<div id="wmd-button-bar" class="hide"></div>
|
||||
<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 class="modal-header">
|
||||
|
Loading…
Reference in New Issue
Block a user