Tweaked ACE for performance
This commit is contained in:
parent
d7d7266593
commit
5ef7d22450
@ -28,7 +28,7 @@ define([
|
|||||||
], function($, _, crel, ace, constants, utils, storage, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
|
], function($, _, crel, ace, constants, utils, storage, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
|
||||||
|
|
||||||
var core = {};
|
var core = {};
|
||||||
|
|
||||||
// Used for periodic tasks
|
// Used for periodic tasks
|
||||||
var intervalId;
|
var intervalId;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ define([
|
|||||||
}
|
}
|
||||||
return userActive && windowUnique;
|
return userActive && windowUnique;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to only have 1 window of the application in the same browser
|
// Used to only have 1 window of the application in the same browser
|
||||||
var windowId;
|
var windowId;
|
||||||
function checkWindowUnique() {
|
function checkWindowUnique() {
|
||||||
@ -147,7 +147,7 @@ define([
|
|||||||
utils.setInputValue("#input-settings-pdf-page-size", settings.pdfPageSize);
|
utils.setInputValue("#input-settings-pdf-page-size", settings.pdfPageSize);
|
||||||
// SSH proxy
|
// SSH proxy
|
||||||
utils.setInputValue("#input-settings-ssh-proxy", settings.sshProxy);
|
utils.setInputValue("#input-settings-ssh-proxy", settings.sshProxy);
|
||||||
|
|
||||||
// Load shortcuts settings
|
// Load shortcuts settings
|
||||||
shortcutMgr.loadSettings();
|
shortcutMgr.loadSettings();
|
||||||
|
|
||||||
@ -250,6 +250,14 @@ define([
|
|||||||
aceEditor.session.setNewLineMode("unix");
|
aceEditor.session.setNewLineMode("unix");
|
||||||
aceEditor.session.setMode("libs/ace_mode");
|
aceEditor.session.setMode("libs/ace_mode");
|
||||||
aceEditor.session.$selectLongWords = true;
|
aceEditor.session.$selectLongWords = true;
|
||||||
|
aceEditor.setHighlightActiveLine(true);
|
||||||
|
aceEditor.setHighlightGutterLine(false);
|
||||||
|
aceEditor.setHighlightSelectedWord(false);
|
||||||
|
aceEditor.setDisplayIndentGuides(false);
|
||||||
|
aceEditor.setShowFoldWidgets(false);
|
||||||
|
aceEditor.setWrapBehavioursEnabled(false);
|
||||||
|
// Hack to disable bracket highlighting
|
||||||
|
aceEditor.$highlightBrackets = function() {};
|
||||||
|
|
||||||
// Make bold titles...
|
// Make bold titles...
|
||||||
(function(self) {
|
(function(self) {
|
||||||
@ -454,7 +462,7 @@ define([
|
|||||||
}
|
}
|
||||||
layout.resizeAll();
|
layout.resizeAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the PageDown editor
|
// Create the PageDown editor
|
||||||
var editor;
|
var editor;
|
||||||
var $editorElt;
|
var $editorElt;
|
||||||
@ -551,7 +559,7 @@ define([
|
|||||||
}
|
}
|
||||||
documentContent = newDocumentContent;
|
documentContent = newDocumentContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
var previewWrapper;
|
var previewWrapper;
|
||||||
if(window.lightMode) {
|
if(window.lightMode) {
|
||||||
editor = new Markdown.EditorLight(converter);
|
editor = new Markdown.EditorLight(converter);
|
||||||
@ -578,7 +586,7 @@ define([
|
|||||||
$(".modal-insert-image").modal();
|
$(".modal-insert-image").modal();
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(settings.lazyRendering === true) {
|
if(settings.lazyRendering === true) {
|
||||||
previewWrapper = function(makePreview) {
|
previewWrapper = function(makePreview) {
|
||||||
var debouncedMakePreview = _.debounce(makePreview, 500);
|
var debouncedMakePreview = _.debounce(makePreview, 500);
|
||||||
@ -658,7 +666,7 @@ define([
|
|||||||
$("#wmd-undo-button").append($('<i class="icon-reply">')).appendTo($btnGroupElt);
|
$("#wmd-undo-button").append($('<i class="icon-reply">')).appendTo($btnGroupElt);
|
||||||
$("#wmd-redo-button").append($('<i class="icon-forward">')).appendTo($btnGroupElt);
|
$("#wmd-redo-button").append($('<i class="icon-forward">')).appendTo($btnGroupElt);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Initialize multiple things and then fire eventMgr.onReady
|
// Initialize multiple things and then fire eventMgr.onReady
|
||||||
var isDocumentPanelShown = false;
|
var isDocumentPanelShown = false;
|
||||||
var isMenuPanelShown = false;
|
var isMenuPanelShown = false;
|
||||||
@ -675,13 +683,13 @@ define([
|
|||||||
$leftBtnDropdown = $navbarElt.find('.left-buttons-dropdown');
|
$leftBtnDropdown = $navbarElt.find('.left-buttons-dropdown');
|
||||||
$rightBtnDropdown = $navbarElt.find('.right-buttons-dropdown');
|
$rightBtnDropdown = $navbarElt.find('.right-buttons-dropdown');
|
||||||
$(window).bind("resize", adjustWindow);
|
$(window).bind("resize", adjustWindow);
|
||||||
|
|
||||||
// Initialize utils library
|
// Initialize utils library
|
||||||
utils.init();
|
utils.init();
|
||||||
|
|
||||||
// Populate shortcuts in settings
|
// Populate shortcuts in settings
|
||||||
shortcutMgr.addSettingEntries();
|
shortcutMgr.addSettingEntries();
|
||||||
|
|
||||||
// Hide shortcuts settings if light mode
|
// Hide shortcuts settings if light mode
|
||||||
if(window.lightMode) {
|
if(window.lightMode) {
|
||||||
$('.tab-settings-shortcuts').hide();
|
$('.tab-settings-shortcuts').hide();
|
||||||
@ -773,14 +781,14 @@ define([
|
|||||||
return $('<textarea id="wmd-input">').addClass(this.className).addClass('form-control');
|
return $('<textarea id="wmd-input">').addClass(this.className).addClass('form-control');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$editorElt = $("#wmd-input, .textarea-helper").css({
|
$editorElt = $("#wmd-input, .textarea-helper").css({
|
||||||
// Apply editor font
|
// Apply editor font
|
||||||
"font-family": settings.editorFontFamily,
|
"font-family": settings.editorFontFamily,
|
||||||
"font-size": settings.editorFontSize + "px",
|
"font-size": settings.editorFontSize + "px",
|
||||||
"line-height": Math.round(settings.editorFontSize * (20 / 12)) + "px"
|
"line-height": Math.round(settings.editorFontSize * (20 / 12)) + "px"
|
||||||
});
|
});
|
||||||
|
|
||||||
if(!window.lightMode) {
|
if(!window.lightMode) {
|
||||||
// ACE editor
|
// ACE editor
|
||||||
createAceEditor();
|
createAceEditor();
|
||||||
@ -811,7 +819,7 @@ 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
|
// In vertical mode, we have to offset the editor buttons otherwise they hide the editor buttons
|
||||||
if(!window.viewerMode && settings.layoutOrientation == "vertical") {
|
if(!window.viewerMode && settings.layoutOrientation == "vertical") {
|
||||||
$previewButtonsElt.css('right', parseInt($previewButtonsElt.css('right')) + $editorButtonsElt.width());
|
$previewButtonsElt.css('right', parseInt($previewButtonsElt.css('right')) + $editorButtonsElt.width());
|
||||||
@ -845,7 +853,7 @@ define([
|
|||||||
$(this).find(".modal-footer a:last").click();
|
$(this).find(".modal-footer a:last").click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Hide menu panel when clicking 'Save as' button
|
// Hide menu panel when clicking 'Save as' button
|
||||||
$('.collapse-save-as a').click(function() {
|
$('.collapse-save-as a').click(function() {
|
||||||
$menuPanelElt.collapse('hide');
|
$menuPanelElt.collapse('hide');
|
||||||
@ -1008,7 +1016,7 @@ define([
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createTooltip(".tooltip-lazy-rendering", 'Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity.');
|
createTooltip(".tooltip-lazy-rendering", 'Disable preview rendering while typing in order to offload CPU. Refresh preview after 500 ms of inactivity.');
|
||||||
createTooltip(".tooltip-default-content", [
|
createTooltip(".tooltip-default-content", [
|
||||||
'Thanks for supporting StackEdit by adding a backlink in your documents!<br/><br/>',
|
'Thanks for supporting StackEdit by adding a backlink in your documents!<br/><br/>',
|
||||||
@ -1028,7 +1036,7 @@ define([
|
|||||||
keyboard: false,
|
keyboard: false,
|
||||||
show: false
|
show: false
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load images
|
// Load images
|
||||||
_.each(document.querySelectorAll('img'), function(imgElt) {
|
_.each(document.querySelectorAll('img'), function(imgElt) {
|
||||||
var $imgElt = $(imgElt);
|
var $imgElt = $(imgElt);
|
||||||
|
Loading…
Reference in New Issue
Block a user