Switch to ACE editor
This commit is contained in:
parent
ca34415d22
commit
99e5b27fa4
@ -18,6 +18,6 @@
|
|||||||
"stacktrace": "~0.5.3",
|
"stacktrace": "~0.5.3",
|
||||||
"requirejs-text": "~2.0.10",
|
"requirejs-text": "~2.0.10",
|
||||||
"bootstrap-tour": "~0.6.0",
|
"bootstrap-tour": "~0.6.0",
|
||||||
"ace": "~1.1.1"
|
"ace": "#51b7cb67a63998c9c0b7d089a85c60e032a7cc17"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
118
res/core.js
118
res/core.js
@ -118,8 +118,8 @@ define([
|
|||||||
utils.setInputValue("#input-settings-editor-font-family", settings.editorFontFamily);
|
utils.setInputValue("#input-settings-editor-font-family", settings.editorFontFamily);
|
||||||
// Editor font size
|
// Editor font size
|
||||||
utils.setInputValue("#input-settings-editor-font-size", settings.editorFontSize);
|
utils.setInputValue("#input-settings-editor-font-size", settings.editorFontSize);
|
||||||
// Editor max width
|
// Max width
|
||||||
utils.setInputValue("#input-settings-editor-max-width", settings.editorMaxWidth);
|
utils.setInputValue("#input-settings-max-width", settings.maxWidth);
|
||||||
// Default content
|
// Default content
|
||||||
utils.setInputValue("#textarea-settings-default-content", settings.defaultContent);
|
utils.setInputValue("#textarea-settings-default-content", settings.defaultContent);
|
||||||
// Commit message
|
// Commit message
|
||||||
@ -147,8 +147,8 @@ define([
|
|||||||
newSettings.editorFontFamily = utils.getInputTextValue("#input-settings-editor-font-family", event);
|
newSettings.editorFontFamily = utils.getInputTextValue("#input-settings-editor-font-family", event);
|
||||||
// Editor font size
|
// Editor font size
|
||||||
newSettings.editorFontSize = utils.getInputIntValue("#input-settings-editor-font-size", event, 1, 99);
|
newSettings.editorFontSize = utils.getInputIntValue("#input-settings-editor-font-size", event, 1, 99);
|
||||||
// Editor max width
|
// Max width
|
||||||
newSettings.editorMaxWidth = utils.getInputIntValue("#input-settings-editor-max-width", event, 1);
|
newSettings.maxWidth = utils.getInputIntValue("#input-settings-max-width", event, 1);
|
||||||
// Default content
|
// Default content
|
||||||
newSettings.defaultContent = utils.getInputValue("#textarea-settings-default-content");
|
newSettings.defaultContent = utils.getInputValue("#textarea-settings-default-content");
|
||||||
// Commit message
|
// Commit message
|
||||||
@ -212,52 +212,73 @@ define([
|
|||||||
aceEditor.renderer.setPadding(EDITOR_DEFAULT_PADDING);
|
aceEditor.renderer.setPadding(EDITOR_DEFAULT_PADDING);
|
||||||
aceEditor.session.setUseWrapMode(true);
|
aceEditor.session.setUseWrapMode(true);
|
||||||
aceEditor.session.setMode("libs/ace_mode");
|
aceEditor.session.setMode("libs/ace_mode");
|
||||||
// Make titles bold...
|
|
||||||
|
// Make bold titles...
|
||||||
(function(self) {
|
(function(self) {
|
||||||
|
function checkLine(currentLine) {
|
||||||
|
var line = self.lines[currentLine];
|
||||||
|
if(line.length !== 0) {
|
||||||
|
if(line[0].type.indexOf("markup.heading.multi") === 0) {
|
||||||
|
_.each(self.lines[currentLine - 1], function(previousLineObject) {
|
||||||
|
previousLineObject.type = "markup.heading.prev.multi";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function customWorker() {
|
function customWorker() {
|
||||||
if (!self.running) { return; }
|
// Duplicate from background_tokenizer.js
|
||||||
|
if(!self.running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var workerStart = new Date();
|
var workerStart = new Date();
|
||||||
var startLine = self.currentLine;
|
var currentLine = self.currentLine;
|
||||||
|
var endLine = -1;
|
||||||
var doc = self.doc;
|
var doc = self.doc;
|
||||||
|
|
||||||
var processedLines = 0;
|
while (self.lines[currentLine]) {
|
||||||
|
currentLine++;
|
||||||
|
}
|
||||||
|
|
||||||
|
var startLine = currentLine;
|
||||||
|
|
||||||
var len = doc.getLength();
|
var len = doc.getLength();
|
||||||
while (self.currentLine < len) {
|
var processedLines = 0;
|
||||||
self.$tokenizeRow(self.currentLine);
|
self.running = false;
|
||||||
while (self.lines[self.currentLine]) {
|
while (currentLine < len) {
|
||||||
var line = self.lines[self.currentLine];
|
self.$tokenizeRow(currentLine);
|
||||||
if(line.length !== 0 && line[0].type.indexOf("markup.heading.multi") === 0) {
|
endLine = currentLine;
|
||||||
_.each(self.lines[self.currentLine-1], function(previousLineObject) {
|
do {
|
||||||
previousLineObject.type = "markup.heading.prev.multi";
|
checkLine(currentLine); // benweet
|
||||||
});
|
currentLine++;
|
||||||
}
|
} while (self.lines[currentLine]);
|
||||||
self.currentLine++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// only check every 5 lines
|
// only check every 5 lines
|
||||||
processedLines ++;
|
processedLines++;
|
||||||
if ((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
|
if((processedLines % 5 == 0) && (new Date() - workerStart) > 20) {
|
||||||
self.fireUpdateEvent(startLine, self.currentLine-1);
|
self.running = setTimeout(customWorker, 20); // benweet
|
||||||
self.running = setTimeout(customWorker, 20);
|
self.currentLine = currentLine;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
self.currentLine = currentLine;
|
||||||
|
|
||||||
self.running = false;
|
if(startLine <= endLine)
|
||||||
|
self.fireUpdateEvent(startLine, endLine);
|
||||||
self.fireUpdateEvent(startLine, len - 1);
|
|
||||||
}
|
}
|
||||||
|
;
|
||||||
self.$worker = function() {
|
self.$worker = function() {
|
||||||
self.currentLine = self.currentLine ? self.currentLine - 1 : 0;
|
self.lines.splice(0, self.lines.length);
|
||||||
|
self.states.splice(0, self.states.length);
|
||||||
|
self.currentLine = 0;
|
||||||
customWorker();
|
customWorker();
|
||||||
};
|
};
|
||||||
|
|
||||||
})(aceEditor.session.bgTokenizer);
|
})(aceEditor.session.bgTokenizer);
|
||||||
|
|
||||||
eventMgr.onAceCreated(aceEditor);
|
eventMgr.onAceCreated(aceEditor);
|
||||||
window.aceEditor = aceEditor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the layout
|
// Create the layout
|
||||||
function createLayout() {
|
function createLayout() {
|
||||||
var layoutGlobalConfig = {
|
var layoutGlobalConfig = {
|
||||||
@ -291,8 +312,11 @@ define([
|
|||||||
onresize_end: function(paneName) {
|
onresize_end: function(paneName) {
|
||||||
if(aceEditor !== undefined && paneName == 'center') {
|
if(aceEditor !== undefined && paneName == 'center') {
|
||||||
aceEditor.resize();
|
aceEditor.resize();
|
||||||
|
var bottomMargin = (aceEditor.renderer.$size.scrollerHeight - aceEditor.renderer.lineHeight) / 2;
|
||||||
|
bottomMargin < 0 && (bottomMargin = 0);
|
||||||
|
aceEditor.renderer.setScrollMargin(0, bottomMargin, 0, 0);
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
var padding = (aceEditor.renderer.$size.scrollerWidth - settings.editorMaxWidth)/2;
|
var padding = (aceEditor.renderer.$size.scrollerWidth - settings.maxWidth) / 2;
|
||||||
if(padding < EDITOR_DEFAULT_PADDING) {
|
if(padding < EDITOR_DEFAULT_PADDING) {
|
||||||
padding = EDITOR_DEFAULT_PADDING;
|
padding = EDITOR_DEFAULT_PADDING;
|
||||||
}
|
}
|
||||||
@ -301,7 +325,7 @@ define([
|
|||||||
aceEditor.resize(true);
|
aceEditor.resize(true);
|
||||||
}
|
}
|
||||||
}, 5);
|
}, 5);
|
||||||
}
|
}
|
||||||
eventMgr.onLayoutResize(paneName);
|
eventMgr.onLayoutResize(paneName);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -324,6 +348,7 @@ define([
|
|||||||
south__minSize: 200
|
south__minSize: 200
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
settings.maxWidth && $('#preview-contents').css('max-width', (settings.maxWidth + 30) + 'px');
|
||||||
$(".navbar").click(function() {
|
$(".navbar").click(function() {
|
||||||
layout.allowOverflow('north');
|
layout.allowOverflow('north');
|
||||||
});
|
});
|
||||||
@ -335,16 +360,16 @@ define([
|
|||||||
// have fixed position
|
// have fixed position
|
||||||
// We also move the north toggler to the east or south resizer as the
|
// We also move the north toggler to the east or south resizer as the
|
||||||
// north resizer is very small
|
// north resizer is very small
|
||||||
var $previewButtonsContainerElt = $('<div class="preview-button-container">');
|
// var $previewButtonsContainerElt = $('<div
|
||||||
$previewButtonsElt = $('<div class="extension-preview-buttons">').appendTo($previewButtonsContainerElt);
|
// class="preview-button-container">');
|
||||||
|
$previewButtonsElt = $('<div class="extension-preview-buttons">');
|
||||||
$editorButtonsElt = $('<div class="extension-editor-buttons">');
|
$editorButtonsElt = $('<div class="extension-editor-buttons">');
|
||||||
if(settings.layoutOrientation == "horizontal") {
|
if(viewerMode || settings.layoutOrientation == "horizontal") {
|
||||||
$('.ui-layout-resizer-north').append($previewButtonsContainerElt);
|
$('.ui-layout-resizer-north').append($previewButtonsElt);
|
||||||
$('.ui-layout-resizer-east').append($northTogglerElt).append($editorButtonsElt);
|
$('.ui-layout-resizer-east').append($northTogglerElt).append($editorButtonsElt);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$previewButtonsContainerElt.append($editorButtonsElt);
|
$('.ui-layout-resizer-south').append($previewButtonsElt).append($editorButtonsElt).append($northTogglerElt);
|
||||||
$('.ui-layout-resizer-south').append($previewButtonsContainerElt).append($northTogglerElt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setPanelVisibility();
|
setPanelVisibility();
|
||||||
@ -374,7 +399,7 @@ define([
|
|||||||
else {
|
else {
|
||||||
$editorElt.val(initDocumentContent);
|
$editorElt.val(initDocumentContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(editor !== undefined) {
|
if(editor !== undefined) {
|
||||||
// If the editor is already created
|
// If the editor is already created
|
||||||
aceEditor && aceEditor.selection.setSelectionRange(fileDesc.editorSelectRange);
|
aceEditor && aceEditor.selection.setSelectionRange(fileDesc.editorSelectRange);
|
||||||
@ -432,7 +457,7 @@ define([
|
|||||||
eventMgr.onSectionsCreated(sectionList);
|
eventMgr.onSectionsCreated(sectionList);
|
||||||
return text;
|
return text;
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkDocumentChanges() {
|
function checkDocumentChanges() {
|
||||||
var newDocumentContent = $editorElt.val();
|
var newDocumentContent = $editorElt.val();
|
||||||
if(aceEditor !== undefined) {
|
if(aceEditor !== undefined) {
|
||||||
@ -444,7 +469,7 @@ define([
|
|||||||
}
|
}
|
||||||
documentContent = newDocumentContent;
|
documentContent = newDocumentContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!lightMode) {
|
if(!lightMode) {
|
||||||
editor = new Markdown.Editor(converter);
|
editor = new Markdown.Editor(converter);
|
||||||
// Custom insert link dialog
|
// Custom insert link dialog
|
||||||
@ -490,7 +515,9 @@ define([
|
|||||||
$editorElt.on("input propertychange", previewWrapper);
|
$editorElt.on("input propertychange", previewWrapper);
|
||||||
editor = {
|
editor = {
|
||||||
hooks: hooks,
|
hooks: hooks,
|
||||||
getConverter: function () { return converter; },
|
getConverter: function() {
|
||||||
|
return converter;
|
||||||
|
},
|
||||||
run: previewWrapper,
|
run: previewWrapper,
|
||||||
refreshPreview: previewWrapper
|
refreshPreview: previewWrapper
|
||||||
};
|
};
|
||||||
@ -502,10 +529,10 @@ define([
|
|||||||
var debouncedMakePreview = _.debounce(makePreview, 500);
|
var debouncedMakePreview = _.debounce(makePreview, 500);
|
||||||
return function() {
|
return function() {
|
||||||
if(documentContent === undefined) {
|
if(documentContent === undefined) {
|
||||||
aceEditor.renderer.scrollToY(fileDesc.editorScrollTop);
|
|
||||||
makePreview();
|
makePreview();
|
||||||
$previewContainerElt.scrollTop(fileDesc.previewScrollTop);
|
$previewContainerElt.scrollTop(fileDesc.previewScrollTop);
|
||||||
_.defer(function() {
|
_.defer(function() {
|
||||||
|
aceEditor.renderer.scrollToY(fileDesc.editorScrollTop);
|
||||||
eventMgr.onFileOpen(fileDesc);
|
eventMgr.onFileOpen(fileDesc);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -639,7 +666,7 @@ define([
|
|||||||
|
|
||||||
// ACE editor
|
// ACE editor
|
||||||
createAceEditor();
|
createAceEditor();
|
||||||
|
|
||||||
// Editor's element
|
// Editor's element
|
||||||
$editorElt = $("#wmd-input").css({
|
$editorElt = $("#wmd-input").css({
|
||||||
// Apply editor font
|
// Apply editor font
|
||||||
@ -666,6 +693,11 @@ define([
|
|||||||
|
|
||||||
// Other initialization that are not prioritary
|
// Other initialization that are not prioritary
|
||||||
eventMgr.addListener("onReady", function() {
|
eventMgr.addListener("onReady", function() {
|
||||||
|
|
||||||
|
// In vertical mode, we have to offset the editor buttons otherwise they hide the editor buttons
|
||||||
|
if(!viewerMode && settings.layoutOrientation == "vertical") {
|
||||||
|
$previewButtonsElt.css('right', parseInt($previewButtonsElt.css('right')) + $editorButtonsElt.width());
|
||||||
|
}
|
||||||
|
|
||||||
var isModalShown = false;
|
var isModalShown = false;
|
||||||
$('.modal').on('show.bs.modal', function() {
|
$('.modal').on('show.bs.modal', function() {
|
||||||
|
@ -7,7 +7,6 @@ define([
|
|||||||
"settings",
|
"settings",
|
||||||
"text!html/settingsExtensionsAccordion.html",
|
"text!html/settingsExtensionsAccordion.html",
|
||||||
"extensions/partialRendering",
|
"extensions/partialRendering",
|
||||||
"extensions/userCustom",
|
|
||||||
"extensions/buttonMarkdownSyntax",
|
"extensions/buttonMarkdownSyntax",
|
||||||
"extensions/googleAnalytics",
|
"extensions/googleAnalytics",
|
||||||
"extensions/dialogAbout",
|
"extensions/dialogAbout",
|
||||||
@ -33,6 +32,7 @@ define([
|
|||||||
"extensions/buttonHtmlCode",
|
"extensions/buttonHtmlCode",
|
||||||
"extensions/buttonViewer",
|
"extensions/buttonViewer",
|
||||||
"extensions/welcomeTour",
|
"extensions/welcomeTour",
|
||||||
|
"extensions/userCustom",
|
||||||
"bootstrap",
|
"bootstrap",
|
||||||
"jquery-waitforimages"
|
"jquery-waitforimages"
|
||||||
], function($, _, crel, utils, Extension, settings, settingsExtensionsAccordionHTML) {
|
], function($, _, crel, utils, Extension, settings, settingsExtensionsAccordionHTML) {
|
||||||
@ -136,8 +136,8 @@ define([
|
|||||||
addEventHook("onError");
|
addEventHook("onError");
|
||||||
addEventHook("onOfflineChanged");
|
addEventHook("onOfflineChanged");
|
||||||
addEventHook("onUserActive");
|
addEventHook("onUserActive");
|
||||||
addEventHook("onAsyncRunning", true);
|
addEventHook("onAsyncRunning");
|
||||||
addEventHook("onPeriodicRun", true);
|
addEventHook("onPeriodicRun");
|
||||||
|
|
||||||
// To access modules that are loaded after extensions
|
// To access modules that are loaded after extensions
|
||||||
addEventHook("onFileMgrCreated");
|
addEventHook("onFileMgrCreated");
|
||||||
@ -184,17 +184,13 @@ define([
|
|||||||
|
|
||||||
var onPreviewFinished = createEventHook("onPreviewFinished");
|
var onPreviewFinished = createEventHook("onPreviewFinished");
|
||||||
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");
|
var onAsyncPreviewListenerList = getExtensionListenerList("onAsyncPreview");
|
||||||
// The number of times we expect tryFinished to be called
|
|
||||||
var nbAsyncPreviewListener = onAsyncPreviewListenerList.length + 1;
|
|
||||||
var previewContentsElt = undefined;
|
var previewContentsElt = undefined;
|
||||||
var $previewContentsElt = undefined;
|
var $previewContentsElt = undefined;
|
||||||
eventMgr["onAsyncPreview"] = function() {
|
eventMgr["onAsyncPreview"] = function() {
|
||||||
logger.log("onAsyncPreview");
|
logger.log("onAsyncPreview");
|
||||||
logger.log("Conversion time: " + (new Date() - eventMgr.previewStartTime));
|
logger.log("Conversion time: " + (new Date() - eventMgr.previewStartTime));
|
||||||
// Call onPreviewFinished listeners when all async preview are finished
|
function recursiveCall(callbackList) {
|
||||||
var counter = 0;
|
var callback = callbackList.length ? callbackList.shift() : function() {
|
||||||
function tryFinished() {
|
|
||||||
if(++counter === nbAsyncPreviewListener) {
|
|
||||||
logger.log("Preview time: " + (new Date() - eventMgr.previewStartTime));
|
logger.log("Preview time: " + (new Date() - eventMgr.previewStartTime));
|
||||||
_.defer(function() {
|
_.defer(function() {
|
||||||
var html = "";
|
var html = "";
|
||||||
@ -203,13 +199,15 @@ define([
|
|||||||
});
|
});
|
||||||
onPreviewFinished(utils.trim(html));
|
onPreviewFinished(utils.trim(html));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
callback(function() {
|
||||||
|
recursiveCall(callbackList);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// We assume images are loading in the preview
|
recursiveCall(onAsyncPreviewListenerList.concat([function(callback) {
|
||||||
$previewContentsElt.waitForImages(tryFinished);
|
// We assume some images are loading asynchronously after the preview
|
||||||
_.each(onAsyncPreviewListenerList, function(asyncPreviewListener) {
|
$previewContentsElt.waitForImages(callback);
|
||||||
asyncPreviewListener(tryFinished);
|
}]));
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var onReady = createEventHook("onReady");
|
var onReady = createEventHook("onReady");
|
||||||
@ -255,27 +253,6 @@ define([
|
|||||||
});
|
});
|
||||||
document.getElementById('extension-buttons').appendChild(extensionButtonsFragment);
|
document.getElementById('extension-buttons').appendChild(extensionButtonsFragment);
|
||||||
|
|
||||||
// Create extension preview buttons
|
|
||||||
logger.log("onCreatePreviewButton");
|
|
||||||
var onCreatePreviewButtonListenerList = getExtensionListenerList("onCreatePreviewButton");
|
|
||||||
var extensionPreviewButtonsFragment = document.createDocumentFragment();
|
|
||||||
_.each(onCreatePreviewButtonListenerList, function(listener) {
|
|
||||||
extensionPreviewButtonsFragment.appendChild(createBtn(listener));
|
|
||||||
});
|
|
||||||
var previewButtonsElt = document.querySelector('.extension-preview-buttons');
|
|
||||||
previewButtonsElt.appendChild(extensionPreviewButtonsFragment);
|
|
||||||
|
|
||||||
// A bit of jQuery...
|
|
||||||
var $previewButtonsElt = $(previewButtonsElt);
|
|
||||||
var previewButtonsWidth = $previewButtonsElt.width();
|
|
||||||
$previewButtonsElt.find('.btn-group').each(function() {
|
|
||||||
var $btnGroupElt = $(this);
|
|
||||||
// Align dropdown to the left of the screen
|
|
||||||
$btnGroupElt.find('.dropdown-menu').css({
|
|
||||||
right: -previewButtonsWidth + $btnGroupElt.width() + $btnGroupElt.position().left
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create extension editor buttons
|
// Create extension editor buttons
|
||||||
logger.log("onCreateEditorButton");
|
logger.log("onCreateEditorButton");
|
||||||
var onCreateEditorButtonListenerList = getExtensionListenerList("onCreateEditorButton");
|
var onCreateEditorButtonListenerList = getExtensionListenerList("onCreateEditorButton");
|
||||||
@ -287,6 +264,27 @@ define([
|
|||||||
editorButtonsElt.appendChild(extensionEditorButtonsFragment);
|
editorButtonsElt.appendChild(extensionEditorButtonsFragment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create extension preview buttons
|
||||||
|
logger.log("onCreatePreviewButton");
|
||||||
|
var onCreatePreviewButtonListenerList = getExtensionListenerList("onCreatePreviewButton");
|
||||||
|
var extensionPreviewButtonsFragment = document.createDocumentFragment();
|
||||||
|
_.each(onCreatePreviewButtonListenerList, function(listener) {
|
||||||
|
extensionPreviewButtonsFragment.appendChild(createBtn(listener));
|
||||||
|
});
|
||||||
|
var previewButtonsElt = document.querySelector('.extension-preview-buttons');
|
||||||
|
previewButtonsElt.appendChild(extensionPreviewButtonsFragment);
|
||||||
|
|
||||||
|
// A bit of jQuery...
|
||||||
|
var $previewButtonsElt = $(previewButtonsElt);
|
||||||
|
var previewButtonsWidth = $previewButtonsElt.width();
|
||||||
|
$previewButtonsElt.find('.btn-group').each(function() {
|
||||||
|
var $btnGroupElt = $(this);
|
||||||
|
// Align dropdown to the left of the screen
|
||||||
|
$btnGroupElt.find('.dropdown-menu').css({
|
||||||
|
right: -previewButtonsWidth + $btnGroupElt.width() + $btnGroupElt.position().left
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Call onReady listeners
|
// Call onReady listeners
|
||||||
onReady();
|
onReady();
|
||||||
};
|
};
|
||||||
|
@ -4,7 +4,7 @@ define([
|
|||||||
"text!html/buttonMarkdownSyntax.html",
|
"text!html/buttonMarkdownSyntax.html",
|
||||||
], function($, Extension, buttonMarkdownSyntaxHTML) {
|
], function($, Extension, buttonMarkdownSyntaxHTML) {
|
||||||
|
|
||||||
var buttonMarkdownSyntax = new Extension("buttonMarkdownSyntax", 'Button "Markdown syntax', true);
|
var buttonMarkdownSyntax = new Extension("buttonMarkdownSyntax", 'Button "Markdown syntax', true, true);
|
||||||
buttonMarkdownSyntax.settingsBlock = '<p>Adds a "Markdown syntax" button over the preview.</p>';
|
buttonMarkdownSyntax.settingsBlock = '<p>Adds a "Markdown syntax" button over the preview.</p>';
|
||||||
|
|
||||||
buttonMarkdownSyntax.onCreatePreviewButton = function() {
|
buttonMarkdownSyntax.onCreatePreviewButton = function() {
|
||||||
|
@ -4,7 +4,7 @@ define([
|
|||||||
"text!html/buttonViewer.html",
|
"text!html/buttonViewer.html",
|
||||||
], function($, Extension, buttonViewerHTML) {
|
], function($, Extension, buttonViewerHTML) {
|
||||||
|
|
||||||
var buttonViewer = new Extension("buttonViewer", 'Button "Viewer"', true);
|
var buttonViewer = new Extension("buttonViewer", 'Button "Viewer"', true, true);
|
||||||
buttonViewer.settingsBlock = '<p>Adds a "Viewer" button over the preview.</p>';
|
buttonViewer.settingsBlock = '<p>Adds a "Viewer" button over the preview.</p>';
|
||||||
|
|
||||||
buttonViewer.onCreatePreviewButton = function() {
|
buttonViewer.onCreatePreviewButton = function() {
|
||||||
|
@ -9,6 +9,7 @@ define([
|
|||||||
var dialogAbout = new Extension("dialogAbout", 'Dialog "About"');
|
var dialogAbout = new Extension("dialogAbout", 'Dialog "About"');
|
||||||
|
|
||||||
var libraries = {
|
var libraries = {
|
||||||
|
"ACE": "http://ace.c9.io/",
|
||||||
"Bootstrap": "http://getbootstrap.com/",
|
"Bootstrap": "http://getbootstrap.com/",
|
||||||
"Bootstrap Tour": "http://bootstraptour.com/",
|
"Bootstrap Tour": "http://bootstraptour.com/",
|
||||||
"crel": "https://github.com/KoryNunn/crel",
|
"crel": "https://github.com/KoryNunn/crel",
|
||||||
|
@ -65,7 +65,7 @@ define([
|
|||||||
Markdown.Extra.init(converter, options);
|
Markdown.Extra.init(converter, options);
|
||||||
|
|
||||||
// Store extensions list in converter for partialRendering
|
// Store extensions list in converter for partialRendering
|
||||||
converter.extraExtensions = markdownExtra.config.extensions;
|
converter.setExtraExtension && converter.setExtraExtension(markdownExtra.config.extensions);
|
||||||
};
|
};
|
||||||
|
|
||||||
return markdownExtra;
|
return markdownExtra;
|
||||||
|
@ -122,7 +122,7 @@ define([
|
|||||||
class: 'wmd-preview-section preview-content'
|
class: 'wmd-preview-section preview-content'
|
||||||
});
|
});
|
||||||
var isFirst = true;
|
var isFirst = true;
|
||||||
while(childNode) {
|
while (childNode) {
|
||||||
var nextNode = childNode.nextSibling;
|
var nextNode = childNode.nextSibling;
|
||||||
if(isFirst === false && /(^| )wmd-title($| )/.test(childNode.className)) {
|
if(isFirst === false && /(^| )wmd-title($| )/.test(childNode.className)) {
|
||||||
// Stop when encountered the next wmd-title
|
// Stop when encountered the next wmd-title
|
||||||
@ -140,7 +140,8 @@ define([
|
|||||||
sectionElt.appendChild(childNode);
|
sectionElt.appendChild(childNode);
|
||||||
}
|
}
|
||||||
childNode = nextNode;
|
childNode = nextNode;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
newSectionEltList.appendChild(sectionElt);
|
newSectionEltList.appendChild(sectionElt);
|
||||||
});
|
});
|
||||||
wmdPreviewElt.innerHTML = '';
|
wmdPreviewElt.innerHTML = '';
|
||||||
@ -184,6 +185,11 @@ define([
|
|||||||
editor.hooks.chain("onPreviewRefresh", function() {
|
editor.hooks.chain("onPreviewRefresh", function() {
|
||||||
refreshSections();
|
refreshSections();
|
||||||
});
|
});
|
||||||
|
converter.setExtraExtension = function(extraExtensions) {
|
||||||
|
doFootnotes = _.some(extraExtensions, function(extension) {
|
||||||
|
return extension == "footnotes";
|
||||||
|
});
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
partialRendering.onReady = function() {
|
partialRendering.onReady = function() {
|
||||||
@ -199,13 +205,5 @@ define([
|
|||||||
fileChanged = true;
|
fileChanged = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
partialRendering.onFileOpen = function() {
|
|
||||||
if(converter.extraExtensions) {
|
|
||||||
doFootnotes = _.some(converter.extraExtensions, function(extension) {
|
|
||||||
return extension == "footnotes";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return partialRendering;
|
return partialRendering;
|
||||||
});
|
});
|
@ -946,10 +946,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-lg-4 control-label"
|
<label class="col-lg-4 control-label"
|
||||||
for="input-settings-editor-max-width">Editor max width</label>
|
for="input-settings-max-width">Max width</label>
|
||||||
<div class="col-lg-8 form-inline">
|
<div class="col-lg-8 form-inline">
|
||||||
<input type="text"
|
<input type="text"
|
||||||
id="input-settings-editor-max-width"
|
id="input-settings-max-width"
|
||||||
class="form-control col-lg-3"> px
|
class="form-control col-lg-3"> px
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,7 +48,7 @@ var Mode = function() {
|
|||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.type = "text";
|
||||||
this.lineCommentStart = ">";
|
this.lineCommentStart = ">";
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
@ -113,7 +113,7 @@ var MarkdownHighlightRules = function() {
|
|||||||
}, { // list
|
}, { // list
|
||||||
token : "markup.list",
|
token : "markup.list",
|
||||||
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
||||||
next : "listblock"
|
next : "listblock-start"
|
||||||
}, {
|
}, {
|
||||||
include : "basic"
|
include : "basic"
|
||||||
}],
|
}],
|
||||||
@ -127,13 +127,11 @@ var MarkdownHighlightRules = function() {
|
|||||||
defaultToken : "markup.heading"
|
defaultToken : "markup.heading"
|
||||||
} ],
|
} ],
|
||||||
|
|
||||||
/* don't need checkbox highlighting...
|
|
||||||
"listblock-start" : [{
|
"listblock-start" : [{
|
||||||
token : "checkbox",
|
token : "checkbox",
|
||||||
regex : /(?:\[[ x]\])?/,
|
regex : /(?:\[[ x]\])?/,
|
||||||
next : "listblock"
|
next : "listblock"
|
||||||
}],
|
}],
|
||||||
*/
|
|
||||||
|
|
||||||
"listblock" : [ { // Lists only escape on completely blank lines.
|
"listblock" : [ { // Lists only escape on completely blank lines.
|
||||||
token : "empty_line",
|
token : "empty_line",
|
||||||
@ -142,7 +140,7 @@ var MarkdownHighlightRules = function() {
|
|||||||
}, { // list
|
}, { // list
|
||||||
token : "markup.list",
|
token : "markup.list",
|
||||||
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
regex : "^\\s{0,3}(?:[*+-]|\\d+\\.)\\s+",
|
||||||
next : "listblock"
|
next : "listblock-start"
|
||||||
}, {
|
}, {
|
||||||
include : "basic", noEscape: true
|
include : "basic", noEscape: true
|
||||||
}, {
|
}, {
|
||||||
|
@ -8,7 +8,7 @@ define([
|
|||||||
lazyRendering: true,
|
lazyRendering: true,
|
||||||
editorFontFamily: 'Menlo, Consolas, "Courier New", Courier, monospace',
|
editorFontFamily: 'Menlo, Consolas, "Courier New", Courier, monospace',
|
||||||
editorFontSize: 12,
|
editorFontSize: 12,
|
||||||
editorMaxWidth: 960,
|
maxWidth: 960,
|
||||||
defaultContent: "\n\n\n> Written with [StackEdit](" + MAIN_URL + ").",
|
defaultContent: "\n\n\n> Written with [StackEdit](" + MAIN_URL + ").",
|
||||||
commitMsg: "Published with " + MAIN_URL,
|
commitMsg: "Published with " + MAIN_URL,
|
||||||
template: [
|
template: [
|
||||||
|
@ -112,7 +112,7 @@ body {
|
|||||||
|
|
||||||
#preview-contents {
|
#preview-contents {
|
||||||
padding: 15px;
|
padding: 15px;
|
||||||
margin-bottom: 50px;
|
margin: 0 auto 50px;
|
||||||
.ui-layout-east & {
|
.ui-layout-east & {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
@ -567,19 +567,11 @@ body {
|
|||||||
* Preview/Editor extensions buttons
|
* Preview/Editor extensions buttons
|
||||||
********************/
|
********************/
|
||||||
|
|
||||||
.preview-button-container {
|
|
||||||
position: absolute;
|
|
||||||
right: 0;
|
|
||||||
.extension-editor-buttons {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.extension-preview-buttons {
|
.extension-preview-buttons {
|
||||||
display: inline-block;
|
position: absolute;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
margin-top: 6px;
|
margin-top: 6px;
|
||||||
margin-right: 30px;
|
right: 30px;
|
||||||
.ui-layout-resizer-south-closed & {
|
.ui-layout-resizer-south-closed & {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
@ -1231,11 +1223,6 @@ div.jGrowl {
|
|||||||
line-height: @input-height-base;
|
line-height: @input-height-base;
|
||||||
}
|
}
|
||||||
|
|
||||||
#preview-contents {
|
|
||||||
max-width: 1024px;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.document-panel .search-bar {
|
.document-panel .search-bar {
|
||||||
padding: 20px 20px 10px;
|
padding: 20px 20px 10px;
|
||||||
.input-group-btn {
|
.input-group-btn {
|
||||||
|
Loading…
Reference in New Issue
Block a user