Removed ACE
This commit is contained in:
parent
0b6742873e
commit
c410aa8eae
10
bower.json
10
bower.json
@ -17,19 +17,13 @@
|
|||||||
"stacktrace": "~0.5.3",
|
"stacktrace": "~0.5.3",
|
||||||
"requirejs-text": "~2.0.10",
|
"requirejs-text": "~2.0.10",
|
||||||
"bootstrap-tour": "~0.7.1",
|
"bootstrap-tour": "~0.7.1",
|
||||||
"ace": "https://github.com/benweet/ace.git#798a03b2f8b1315fa8ba2d867cee242b90960557",
|
|
||||||
"pagedown-ace": "https://github.com/benweet/pagedown-ace.git#84d5e1b7ff233a1c8cafa9716e825228d275120c",
|
|
||||||
"pagedown-extra": "https://github.com/jmcmanus/pagedown-extra.git#bd0870e3e871e15bde1fa5a427e3e10028a09789",
|
"pagedown-extra": "https://github.com/jmcmanus/pagedown-extra.git#bd0870e3e871e15bde1fa5a427e3e10028a09789",
|
||||||
"crel": "https://github.com/KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
"crel": "https://github.com/KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1",
|
||||||
"waitForImages": "https://github.com/alexanderdickson/waitForImages.git#~1.4.2",
|
"waitForImages": "https://github.com/alexanderdickson/waitForImages.git#~1.4.2",
|
||||||
"to-markdown": "https://github.com/benweet/to-markdown.git#jquery",
|
"to-markdown": "https://github.com/benweet/to-markdown.git#jquery",
|
||||||
"Typo.js": "https://github.com/cfinke/Typo.js.git",
|
|
||||||
"xregexp": "d06eff50f87d81d2dd3afc1e854784c38b17bcc4",
|
"xregexp": "d06eff50f87d81d2dd3afc1e854784c38b17bcc4",
|
||||||
"yaml.js": "https://github.com/jeremyfa/yaml.js.git#~0.1.4",
|
"yaml.js": "https://github.com/jeremyfa/yaml.js.git#~0.1.4",
|
||||||
"lz-string": "https://github.com/pieroxy/lz-string.git"
|
"stackedit-pagedown": "https://github.com/benweet/stackedit-pagedown.git#d81b3689a99c84832d8885f607e6de860fb7d94a",
|
||||||
},
|
"prism": "gh-pages"
|
||||||
"resolutions": {
|
|
||||||
"jquery": "2.0.3",
|
|
||||||
"bootstrap": "v3.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
ᥢ䐪䀨ौްݜրᎠ娢ᠥ̠䨤桠ᓠ㎠䬡ء氢㠢瀾怭䂃FżθאĀƀҀڀ܀ༀప@䀼圸Ⱐᤠ愠ᄠ唠焠夠Ԡठ↜òĊzĄⳋㆣ഼Ⲡȱバä഻ࠦಪ䅤悢傐碤䑔ቌ໌ᳶ叱ᥢ呁夁يጨ䈦ᄢ悇灐㣈汄Nㅽ`͡"㨡䰽ⱸ⪶弰妽䷫棵䊊疜ۆ䐭Ω䩢澸怡桀ú&ᨪ7‥⃢Ჾ乚ဠਬ∟㣃̑䐊瑡ဠ氠瘬"憙ଧ〢⨆Ế涓ᷮ⎯⎔㱨㨠Ѓ楔梡䩆䠍»䏁ќ㴬ᔽ椕ᣖᯁ礃唂䟀ᬢ彰㰵լ昼佋䀸娰េ䦅Ჹ䞷摅ၽᮓ㴞⪮㰐墇ᘫ䈈㨫ᥫ䌠ၣ嚸ܜ羘Ԣহ㘠ٰ͢₤㘴棕ⴰ໑溔桤㏝沔癆秚ۗᷗ沖畣溕㴡俀搖深珄ᾖᬁ䒛棔瓑咝ᡬ㶌ᯅᴕ匰㽆櫯篚ᅀର⒐᷒㐕䖙淉⡕嶇沒ᮽ玑氀栬㮄ᘠ縖Ш刉ぃ䗌㲗珮夢➼㵤ᔔ㸍⩫䆟〡璨叐琊ᔨƺ熊ᔇ價⁽⿇爓奷㫨ᘥݣᇏߤڟ徣ᗻ㷛湂ᔂ绿䋱Ề㧶ೆ圁圑稶凴㸫䘓㹐∐䇟已ၴᘯۛ䢢Ƨ䋰夗劓廄⤭ۀ䁡♂ᰔ兮巳尠⠩Ɨ傥ᘼ⎐呣尒ᢞ岩稢㌒㹴弜⎑䐲═ᇠ㢨䀠ੰ➞ᕔ煏ށ㕚▉㥏㠾濶㈰䁸撎㘦嬰獊䕞∲搹ਨ䏞ิ珱㯶ㆁ䡁搹䉀碙擶綩擙㝑♠⊬旾䠫晚呦寡୶ᑠ摑榰刮䉙杁厥ᣐᑅ㥔ᜅ睇棅䓲ص籐Թ㯷Ț棇毵㣕ㅹⓂ͕哚䓰X囙勂檕㤕淯嘅⛐ᚭ彈䞞圡嗭෭ቅ䗖摎咻❚巼㐭࠾㓕㔅绕㕑䡙㓭嫇殊卛箊㗝ᚰ廘瑭疽磊撥ៗ㟝懘䊍睿グ#杀ҟᶔ㝠㐬睰㸮曛暁絳撮㽑ᩢȍ吗㾄㋵⡬㑴燔㾮ਊ墬紳হ潊㋷尸㡻㽋ʭ慡Э䶵䋶㋷姮㜧嬆㇆ᵞ㔦ᶌ㘶垏旃⦿⍌媾Υ㌐椺瀰ಮ၌ۏᆪౡ䡍㻍疨Šල㱣植㺏ෳ㲍䡊䫚ⶬ完涪ଊ涺̍巂㷗ⴄ㷫ㅡ䠾嬌ᷣ㐼竴䘿ᇈ缌淸縌ϣタИ笏⚼䏴禎ᐂা琀熿⏝㤼㋢棚ɿ⮺䁀淪無弻㜙殦畼㠶燡寫㣿剫㵺Ⱆ無㕀篣㙀ΎШـ淎㕝ុ㞍䢕礍៊䇜Ǝ矞Ḃɽࡗ⿎ⶠցǂෝࡀณ㜏圥愷䒲羏䐥恫怜繖浹䷲浻忚ව筿֓宐爂恌üⰤ㳧䈠C叚ⶦӀ旕䢔ೡ䎈恢㇢䇛䆠涱Ө㲑䠨䓁⨳ℱţ㧶䉘ਧᆻܰ㔬嬦м㘳㚼ᯣౄ䈯䮧桡砨匬䢦Ŏᤱᆶ淼ᥤ⊴㹧྿宐犕ゲ焀ㄥḭෝѐ㢴⎙࡙ݐ懐敨爖崎亶ᖼ燰Ძ兘淍Ҁ䷖悭㤡Dଢ㹚处ࠤђ㇁ᔢԄ杀㊮䋡澬አ
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -2,26 +2,12 @@ define([
|
|||||||
"underscore",
|
"underscore",
|
||||||
"utils",
|
"utils",
|
||||||
"storage",
|
"storage",
|
||||||
"ace/range"
|
], function(_, utils, storage) {
|
||||||
], function(_, utils, storage, range) {
|
|
||||||
var Range = range.Range;
|
|
||||||
|
|
||||||
function FileDescriptor(fileIndex, title, syncLocations, publishLocations) {
|
function FileDescriptor(fileIndex, title, syncLocations, publishLocations) {
|
||||||
this.fileIndex = fileIndex;
|
this.fileIndex = fileIndex;
|
||||||
this._title = title || storage[fileIndex + ".title"];
|
this._title = title || storage[fileIndex + ".title"];
|
||||||
this._editorScrollTop = parseInt(storage[fileIndex + ".editorScrollTop"]) || 0;
|
this._editorScrollTop = parseInt(storage[fileIndex + ".editorScrollTop"]) || 0;
|
||||||
this._editorSelectRange = (function() {
|
|
||||||
try {
|
|
||||||
var rangeComponents = storage[fileIndex + ".editorSelectRange"].split(';');
|
|
||||||
rangeComponents = _.map(rangeComponents, function(component) {
|
|
||||||
return parseInt(component);
|
|
||||||
});
|
|
||||||
return new Range(rangeComponents[0], rangeComponents[1], rangeComponents[2], rangeComponents[3]);
|
|
||||||
}
|
|
||||||
catch(e) {
|
|
||||||
return new Range(0, 0, 0, 0);
|
|
||||||
}
|
|
||||||
})();
|
|
||||||
this._editorStart = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
this._editorStart = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||||
this._editorEnd = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
this._editorEnd = parseInt(storage[fileIndex + ".editorEnd"]) || 0;
|
||||||
this._previewScrollTop = parseInt(storage[fileIndex + ".previewScrollTop"]) || 0;
|
this._previewScrollTop = parseInt(storage[fileIndex + ".previewScrollTop"]) || 0;
|
||||||
@ -72,20 +58,6 @@ define([
|
|||||||
storage[this.fileIndex + ".editorEnd"] = editorEnd;
|
storage[this.fileIndex + ".editorEnd"] = editorEnd;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Object.defineProperty(this, 'editorSelectRange', {
|
|
||||||
get: function() {
|
|
||||||
return this._editorSelectRange;
|
|
||||||
},
|
|
||||||
set: function(range) {
|
|
||||||
this._editorSelectRange = range;
|
|
||||||
storage[this.fileIndex + ".editorSelectRange"] = [
|
|
||||||
range.start.row,
|
|
||||||
range.start.column,
|
|
||||||
range.end.row,
|
|
||||||
range.end.column
|
|
||||||
].join(';');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Object.defineProperty(this, 'previewScrollTop', {
|
Object.defineProperty(this, 'previewScrollTop', {
|
||||||
get: function() {
|
get: function() {
|
||||||
return this._previewScrollTop;
|
return this._previewScrollTop;
|
||||||
|
@ -3,7 +3,6 @@ define([
|
|||||||
"jquery",
|
"jquery",
|
||||||
"underscore",
|
"underscore",
|
||||||
"crel",
|
"crel",
|
||||||
"ace",
|
|
||||||
"editor",
|
"editor",
|
||||||
"constants",
|
"constants",
|
||||||
"utils",
|
"utils",
|
||||||
@ -18,15 +17,8 @@ define([
|
|||||||
"text!html/settingsUserCustomExtensionTooltip.html",
|
"text!html/settingsUserCustomExtensionTooltip.html",
|
||||||
"storage",
|
"storage",
|
||||||
"uilayout",
|
"uilayout",
|
||||||
'pagedown-ace',
|
'pagedown',
|
||||||
'pagedown-light',
|
], function($, _, crel, editor, constants, utils, storage, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
|
||||||
'libs/ace_mode',
|
|
||||||
'ace/requirejs/text!ace/css/editor.css',
|
|
||||||
'ace/requirejs/text!ace/theme/textmate.css',
|
|
||||||
'ace/ext/spellcheck',
|
|
||||||
'ace/ext/searchbox'
|
|
||||||
|
|
||||||
], function($, _, crel, ace, editor, constants, utils, storage, settings, eventMgr, shortcutMgr, mousetrap, bodyIndexHTML, bodyViewerHTML, settingsTemplateTooltipHTML, settingsUserCustomExtensionTooltipHTML) {
|
|
||||||
|
|
||||||
var core = {};
|
var core = {};
|
||||||
|
|
||||||
@ -128,8 +120,8 @@ define([
|
|||||||
utils.setInputValue("#input-settings-max-width", settings.maxWidth);
|
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);
|
||||||
// Mode
|
// Edit mode
|
||||||
utils.setInputRadio("radio-settings-mode", storage.mode || '_ace_');
|
utils.setInputRadio("radio-settings-mode", settings.editMode);
|
||||||
// Commit message
|
// Commit message
|
||||||
utils.setInputValue("#input-settings-publish-commit-msg", settings.commitMsg);
|
utils.setInputValue("#input-settings-publish-commit-msg", settings.commitMsg);
|
||||||
// Gdrive multi-accounts
|
// Gdrive multi-accounts
|
||||||
@ -174,8 +166,8 @@ define([
|
|||||||
newSettings.maxWidth = utils.getInputIntValue("#input-settings-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");
|
||||||
// Mode
|
// Edit mode
|
||||||
var mode = utils.getInputRadio("radio-settings-mode");
|
newSettings.editMode = utils.getInputRadio("radio-settings-mode");
|
||||||
// Commit message
|
// Commit message
|
||||||
newSettings.commitMsg = utils.getInputTextValue("#input-settings-publish-commit-msg", event);
|
newSettings.commitMsg = utils.getInputTextValue("#input-settings-publish-commit-msg", event);
|
||||||
// Gdrive multi-accounts
|
// Gdrive multi-accounts
|
||||||
@ -209,7 +201,6 @@ define([
|
|||||||
$.extend(settings, newSettings);
|
$.extend(settings, newSettings);
|
||||||
storage.settings = JSON.stringify(settings);
|
storage.settings = JSON.stringify(settings);
|
||||||
storage.themeV3 = theme;
|
storage.themeV3 = theme;
|
||||||
storage.mode = mode;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,95 +230,6 @@ define([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create ACE editor
|
|
||||||
var aceEditor;
|
|
||||||
function createAceEditor() {
|
|
||||||
aceEditor = ace.edit("wmd-input");
|
|
||||||
aceEditor.setOption("spellcheck", true);
|
|
||||||
aceEditor.renderer.setShowGutter(false);
|
|
||||||
aceEditor.renderer.setPrintMarginColumn(false);
|
|
||||||
aceEditor.renderer.setPadding(constants.EDITOR_DEFAULT_PADDING);
|
|
||||||
aceEditor.session.setUseWrapMode(true);
|
|
||||||
aceEditor.session.setNewLineMode("unix");
|
|
||||||
aceEditor.session.setMode("libs/ace_mode");
|
|
||||||
aceEditor.session.$selectLongWords = true;
|
|
||||||
aceEditor.setShowPrintMargin(true);
|
|
||||||
aceEditor.setHighlightActiveLine(false);
|
|
||||||
aceEditor.setHighlightGutterLine(false);
|
|
||||||
aceEditor.setHighlightSelectedWord(false);
|
|
||||||
aceEditor.setDisplayIndentGuides(false);
|
|
||||||
aceEditor.setShowFoldWidgets(false);
|
|
||||||
aceEditor.setWrapBehavioursEnabled(false);
|
|
||||||
// Hack to disable bracket highlighting
|
|
||||||
aceEditor.$highlightBrackets = function() {};
|
|
||||||
|
|
||||||
// Hack to make bold titles
|
|
||||||
(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() {
|
|
||||||
// Duplicate from background_tokenizer.js
|
|
||||||
if(!self.running) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var workerStart = new Date();
|
|
||||||
var currentLine = self.currentLine;
|
|
||||||
var endLine = -1;
|
|
||||||
var doc = self.doc;
|
|
||||||
|
|
||||||
while (self.lines[currentLine]) {
|
|
||||||
currentLine++;
|
|
||||||
}
|
|
||||||
|
|
||||||
var startLine = currentLine;
|
|
||||||
|
|
||||||
var len = doc.getLength();
|
|
||||||
var processedLines = 0;
|
|
||||||
self.running = false;
|
|
||||||
while (currentLine < len) {
|
|
||||||
self.$tokenizeRow(currentLine);
|
|
||||||
endLine = currentLine;
|
|
||||||
do {
|
|
||||||
checkLine(currentLine); // benweet
|
|
||||||
currentLine++;
|
|
||||||
} while (self.lines[currentLine]);
|
|
||||||
|
|
||||||
// only check every 5 lines
|
|
||||||
processedLines++;
|
|
||||||
if((processedLines % 5 === 0) && (new Date() - workerStart) > 20) {
|
|
||||||
self.running = setTimeout(customWorker, 20); // benweet
|
|
||||||
self.currentLine = currentLine;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.currentLine = currentLine;
|
|
||||||
|
|
||||||
if(startLine <= endLine) {
|
|
||||||
self.fireUpdateEvent(startLine, endLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.$worker = function() {
|
|
||||||
self.lines.splice(0, self.lines.length);
|
|
||||||
self.states.splice(0, self.states.length);
|
|
||||||
self.currentLine = 0;
|
|
||||||
customWorker();
|
|
||||||
};
|
|
||||||
|
|
||||||
})(aceEditor.session.bgTokenizer);
|
|
||||||
|
|
||||||
shortcutMgr.configureAce(aceEditor);
|
|
||||||
eventMgr.onAceCreated(aceEditor);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the layout
|
// Create the layout
|
||||||
var $editorButtonsElt;
|
var $editorButtonsElt;
|
||||||
var maxWidthMap = [
|
var maxWidthMap = [
|
||||||
@ -395,22 +297,6 @@ define([
|
|||||||
'padding-right': padding + 'px'
|
'padding-right': padding + 'px'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if(aceEditor !== undefined && paneName == 'center') {
|
|
||||||
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() {
|
|
||||||
var padding = (aceEditor.renderer.$size.scrollerWidth - getMaxWidth()) / 2;
|
|
||||||
if(padding < constants.EDITOR_DEFAULT_PADDING) {
|
|
||||||
padding = constants.EDITOR_DEFAULT_PADDING;
|
|
||||||
}
|
|
||||||
if(padding !== aceEditor.renderer.$padding) {
|
|
||||||
aceEditor.renderer.setPadding(padding);
|
|
||||||
aceEditor.resize(true);
|
|
||||||
}
|
|
||||||
}, 5);
|
|
||||||
}
|
|
||||||
eventMgr.onLayoutResize(paneName);
|
eventMgr.onLayoutResize(paneName);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -498,7 +384,6 @@ define([
|
|||||||
var $editorElt;
|
var $editorElt;
|
||||||
var fileDesc;
|
var fileDesc;
|
||||||
var documentContent;
|
var documentContent;
|
||||||
var UndoManager = require("ace/undomanager").UndoManager;
|
|
||||||
core.initEditor = function(fileDescParam) {
|
core.initEditor = function(fileDescParam) {
|
||||||
if(fileDesc !== undefined) {
|
if(fileDesc !== undefined) {
|
||||||
eventMgr.onFileClosed(fileDesc);
|
eventMgr.onFileClosed(fileDesc);
|
||||||
@ -507,43 +392,16 @@ define([
|
|||||||
documentContent = undefined;
|
documentContent = undefined;
|
||||||
var initDocumentContent = fileDesc.content;
|
var initDocumentContent = fileDesc.content;
|
||||||
|
|
||||||
if(aceEditor !== undefined) {
|
|
||||||
aceEditor.setValue(initDocumentContent, -1);
|
|
||||||
aceEditor.getSession().setUndoManager(new UndoManager());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//$editorElt.val(initDocumentContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pagedownEditor !== undefined) {
|
if(pagedownEditor !== undefined) {
|
||||||
// If the editor is already created
|
// If the editor is already created
|
||||||
$editorElt.val(initDocumentContent);
|
$editorElt.val(initDocumentContent);
|
||||||
aceEditor && aceEditor.selection.setSelectionRange(fileDesc.editorSelectRange);
|
pagedownEditor.undoManager.reinit(initDocumentContent, fileDesc.editorStart, fileDesc.editorEnd, fileDesc.editorScrollTop);
|
||||||
aceEditor || pagedownEditor.undoManager.reinit(initDocumentContent, fileDesc.editorStart, fileDesc.editorEnd, fileDesc.editorScrollTop);
|
$editorElt.focus();
|
||||||
aceEditor ? aceEditor.focus() : $editorElt.focus();
|
|
||||||
//pagedownEditor.refreshPreview();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $previewContainerElt = $(".preview-container");
|
var $previewContainerElt = $(".preview-container");
|
||||||
|
|
||||||
if(!window.lightMode) {
|
|
||||||
// Store editor scrollTop on scroll event
|
|
||||||
var saveScroll = _.debounce(function() {
|
|
||||||
if(documentContent !== undefined) {
|
|
||||||
fileDesc.editorScrollTop = aceEditor.renderer.getScrollTop();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
aceEditor.session.on('changeScrollTop', saveScroll);
|
|
||||||
// Store editor selection on change
|
|
||||||
var saveSelection = _.debounce(function() {
|
|
||||||
if(documentContent !== undefined) {
|
|
||||||
fileDesc.editorSelectRange = aceEditor.getSelectionRange();
|
|
||||||
}
|
|
||||||
}, 100);
|
|
||||||
aceEditor.session.selection.on('changeSelection', saveSelection);
|
|
||||||
aceEditor.session.selection.on('changeCursor', saveSelection);
|
|
||||||
}
|
|
||||||
// Store preview scrollTop on scroll event
|
// Store preview scrollTop on scroll event
|
||||||
$previewContainerElt.scroll(function() {
|
$previewContainerElt.scroll(function() {
|
||||||
if(documentContent !== undefined) {
|
if(documentContent !== undefined) {
|
||||||
@ -565,37 +423,6 @@ define([
|
|||||||
};
|
};
|
||||||
converter.setOptions(options);
|
converter.setOptions(options);
|
||||||
|
|
||||||
function checkDocumentChanges() {
|
|
||||||
var newDocumentContent = $editorElt.text();
|
|
||||||
if(aceEditor !== undefined) {
|
|
||||||
newDocumentContent = aceEditor.getValue();
|
|
||||||
}
|
|
||||||
if(documentContent == newDocumentContent) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(documentContent !== undefined) {
|
|
||||||
fileDesc.content = newDocumentContent;
|
|
||||||
eventMgr.onContentChanged(fileDesc);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
eventMgr.onFileOpen(fileDesc);
|
|
||||||
$previewContainerElt.scrollTop(fileDesc.previewScrollTop);
|
|
||||||
if(window.lightMode) {
|
|
||||||
$editorElt.scrollTop(fileDesc.editorScrollTop);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
_.defer(function() {
|
|
||||||
aceEditor.renderer.scrollToY(fileDesc.editorScrollTop);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
documentContent = newDocumentContent;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
var previewWrapper;
|
|
||||||
if(window.lightMode) {
|
if(window.lightMode) {
|
||||||
pagedownEditor = new Markdown.EditorLight(converter);
|
pagedownEditor = new Markdown.EditorLight(converter);
|
||||||
}
|
}
|
||||||
@ -622,38 +449,12 @@ define([
|
|||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if(settings.lazyRendering === true) {
|
|
||||||
previewWrapper = function(makePreview) {
|
|
||||||
var debouncedMakePreview = _.debounce(makePreview, 500);
|
|
||||||
return function() {
|
|
||||||
var debounce = documentContent !== undefined;
|
|
||||||
if(checkDocumentChanges()) {
|
|
||||||
debounce ? debouncedMakePreview() : makePreview();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
previewWrapper = function(makePreview) {
|
|
||||||
return function() {
|
|
||||||
checkDocumentChanges() && makePreview();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
eventMgr.onPagedownConfigure(pagedownEditor);
|
eventMgr.onPagedownConfigure(pagedownEditor);
|
||||||
pagedownEditor.hooks.chain("onPreviewRefresh", eventMgr.onAsyncPreview);
|
pagedownEditor.hooks.chain("onPreviewRefresh", eventMgr.onAsyncPreview);
|
||||||
if(window.lightMode) {
|
|
||||||
pagedownEditor.run();
|
pagedownEditor.run();
|
||||||
$editorElt.val(initDocumentContent);
|
$editorElt.val(initDocumentContent);
|
||||||
pagedownEditor.undoManager.reinit(initDocumentContent, fileDesc.editorStart, fileDesc.editorEnd, fileDesc.editorScrollTop);
|
pagedownEditor.undoManager.reinit(initDocumentContent, fileDesc.editorStart, fileDesc.editorEnd, fileDesc.editorScrollTop);
|
||||||
$editorElt.focus();
|
$editorElt.focus();
|
||||||
}
|
|
||||||
else {
|
|
||||||
pagedownEditor.run(aceEditor, previewWrapper);
|
|
||||||
aceEditor.selection.setSelectionRange(fileDesc.editorSelectRange);
|
|
||||||
aceEditor.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hide default buttons
|
// Hide default buttons
|
||||||
$(".wmd-button-row li").addClass("btn btn-success").css("left", 0).find("span").hide();
|
$(".wmd-button-row li").addClass("btn btn-success").css("left", 0).find("span").hide();
|
||||||
@ -681,6 +482,9 @@ define([
|
|||||||
var isDocumentPanelShown = false;
|
var isDocumentPanelShown = false;
|
||||||
var isMenuPanelShown = false;
|
var isMenuPanelShown = false;
|
||||||
core.onReady = function() {
|
core.onReady = function() {
|
||||||
|
// Add RTL class
|
||||||
|
settings.editMode == 'rtl' && $(document.body).addClass('rtl');
|
||||||
|
|
||||||
if(window.viewerMode === true) {
|
if(window.viewerMode === true) {
|
||||||
document.body.innerHTML = bodyViewerHTML;
|
document.body.innerHTML = bodyViewerHTML;
|
||||||
}
|
}
|
||||||
@ -788,7 +592,7 @@ define([
|
|||||||
isMenuPanelShown = false;
|
isMenuPanelShown = false;
|
||||||
menuPanelBackdropElt.removeBackdrop();
|
menuPanelBackdropElt.removeBackdrop();
|
||||||
$menuPanelElt.removeClass('move-to-front');
|
$menuPanelElt.removeClass('move-to-front');
|
||||||
aceEditor ? aceEditor.focus() : $editorElt.focus();
|
$editorElt.focus();
|
||||||
}
|
}
|
||||||
}).on('hidden.bs.collapse', function(e) {
|
}).on('hidden.bs.collapse', function(e) {
|
||||||
if(e.target === $menuPanelElt[0]) {
|
if(e.target === $menuPanelElt[0]) {
|
||||||
@ -820,7 +624,7 @@ define([
|
|||||||
isDocumentPanelShown = false;
|
isDocumentPanelShown = false;
|
||||||
documentPanelBackdropElt.removeBackdrop();
|
documentPanelBackdropElt.removeBackdrop();
|
||||||
$documentPanelElt.removeClass('move-to-front');
|
$documentPanelElt.removeClass('move-to-front');
|
||||||
aceEditor ? aceEditor.focus() : $editorElt.focus();
|
$editorElt.focus();
|
||||||
}
|
}
|
||||||
}).on('hidden.bs.collapse', function(e) {
|
}).on('hidden.bs.collapse', function(e) {
|
||||||
if(e.target === $documentPanelElt[0]) {
|
if(e.target === $documentPanelElt[0]) {
|
||||||
@ -829,26 +633,13 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Editor
|
// Create UI layout
|
||||||
if(window.lightMode) {
|
|
||||||
// In pre mode, we replace ACE with an editable pre
|
|
||||||
$('#wmd-input').replaceWith(function() {
|
|
||||||
return $('<pre id="wmd-input">').addClass(this.className).addClass('form-control');
|
|
||||||
});
|
|
||||||
|
|
||||||
// Create UI layout after textarea
|
|
||||||
createLayout();
|
createLayout();
|
||||||
|
|
||||||
|
// Editor
|
||||||
|
$editorElt = $('#wmd-input');
|
||||||
|
|
||||||
editor.init(document.querySelector('#wmd-input'), document.querySelector('.preview-container'));
|
editor.init(document.querySelector('#wmd-input'), document.querySelector('.preview-container'));
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Create UI layout before ACE editor
|
|
||||||
createLayout();
|
|
||||||
|
|
||||||
// ACE editor
|
|
||||||
createAceEditor();
|
|
||||||
}
|
|
||||||
$editorElt = $('#wmd-input');
|
|
||||||
|
|
||||||
// Do periodic tasks
|
// Do periodic tasks
|
||||||
intervalId = window.setInterval(function() {
|
intervalId = window.setInterval(function() {
|
||||||
@ -892,7 +683,7 @@ define([
|
|||||||
}).on('hidden.bs.modal', function() {
|
}).on('hidden.bs.modal', function() {
|
||||||
// Focus on the editor when modal is gone
|
// Focus on the editor when modal is gone
|
||||||
isModalShown = false;
|
isModalShown = false;
|
||||||
aceEditor ? aceEditor.focus() : $editorElt.focus();
|
$editorElt.focus();
|
||||||
// Revert to current theme when settings modal is closed
|
// Revert to current theme when settings modal is closed
|
||||||
applyTheme(window.theme);
|
applyTheme(window.theme);
|
||||||
}).keyup(function(e) {
|
}).keyup(function(e) {
|
||||||
|
@ -29,14 +29,12 @@ define([
|
|||||||
"extensions/mathJax",
|
"extensions/mathJax",
|
||||||
"extensions/emailConverter",
|
"extensions/emailConverter",
|
||||||
"extensions/scrollLink",
|
"extensions/scrollLink",
|
||||||
"extensions/buttonFocusMode",
|
|
||||||
"extensions/buttonSync",
|
"extensions/buttonSync",
|
||||||
"extensions/buttonPublish",
|
"extensions/buttonPublish",
|
||||||
"extensions/buttonStat",
|
"extensions/buttonStat",
|
||||||
"extensions/buttonHtmlCode",
|
"extensions/buttonHtmlCode",
|
||||||
"extensions/buttonViewer",
|
"extensions/buttonViewer",
|
||||||
"extensions/welcomeTour",
|
"extensions/welcomeTour",
|
||||||
"extensions/spellCheck",
|
|
||||||
"extensions/userCustom",
|
"extensions/userCustom",
|
||||||
"bootstrap",
|
"bootstrap",
|
||||||
"jquery-waitforimages",
|
"jquery-waitforimages",
|
||||||
@ -211,9 +209,6 @@ define([
|
|||||||
addEventHook("onSectionsCreated");
|
addEventHook("onSectionsCreated");
|
||||||
addEventHook("onMarkdownTrim");
|
addEventHook("onMarkdownTrim");
|
||||||
|
|
||||||
// Operation on ACE
|
|
||||||
addEventHook("onAceCreated");
|
|
||||||
|
|
||||||
// Refresh twitter buttons
|
// Refresh twitter buttons
|
||||||
addEventHook("onTweet");
|
addEventHook("onTweet");
|
||||||
|
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
define([
|
|
||||||
"jquery",
|
|
||||||
"underscore",
|
|
||||||
"crel",
|
|
||||||
"classes/Extension"
|
|
||||||
], function($, _, crel, Extension) {
|
|
||||||
|
|
||||||
var buttonFocusMode = new Extension("buttonFocusMode", 'Button "Focus Mode"', true, true);
|
|
||||||
buttonFocusMode.settingsBlock = "When typing, scrolls automatically the editor to always have the caret centered verticaly.";
|
|
||||||
|
|
||||||
var aceEditor;
|
|
||||||
buttonFocusMode.onAceCreated = function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
};
|
|
||||||
|
|
||||||
var isMouseActive = false;
|
|
||||||
function doFocusMode() {
|
|
||||||
if(aceEditor) {
|
|
||||||
if(isMouseActive === true) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var positionInDocument = aceEditor.selection.getCursor();
|
|
||||||
var positionInScreen = aceEditor.session.documentToScreenPosition(positionInDocument.row, positionInDocument.column);
|
|
||||||
aceEditor.session.setScrollTop((positionInScreen.row + 0.5) * aceEditor.renderer.lineHeight - aceEditor.renderer.$size.scrollerHeight / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonFocusMode.onReady = function() {
|
|
||||||
if(aceEditor) {
|
|
||||||
aceEditor.getSession().selection.on('changeCursor', doFocusMode);
|
|
||||||
aceEditor.container.addEventListener('keydown', function() {
|
|
||||||
isMouseActive = false;
|
|
||||||
}, true);
|
|
||||||
aceEditor.container.addEventListener('mousedown', function() {
|
|
||||||
isMouseActive = true;
|
|
||||||
}, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return buttonFocusMode;
|
|
||||||
});
|
|
@ -29,11 +29,6 @@ define([
|
|||||||
newConfig.shortcutNext = utils.getInputTextValue("#input-document-selector-shortcut-next", event);
|
newConfig.shortcutNext = utils.getInputTextValue("#input-document-selector-shortcut-next", event);
|
||||||
};
|
};
|
||||||
|
|
||||||
var aceEditor;
|
|
||||||
documentSelector.onAceCreated = function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
};
|
|
||||||
|
|
||||||
var fileMgr;
|
var fileMgr;
|
||||||
documentSelector.onFileMgrCreated = function(fileMgrParameter) {
|
documentSelector.onFileMgrCreated = function(fileMgrParameter) {
|
||||||
fileMgr = fileMgrParameter;
|
fileMgr = fileMgrParameter;
|
||||||
@ -74,9 +69,6 @@ define([
|
|||||||
if(!$liElt.hasClass("disabled")) {
|
if(!$liElt.hasClass("disabled")) {
|
||||||
fileMgr.selectFile(fileDesc);
|
fileMgr.selectFile(fileDesc);
|
||||||
}
|
}
|
||||||
else if(aceEditor !== undefined) {
|
|
||||||
aceEditor.focus();
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
$editorElt.focus();
|
$editorElt.focus();
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,6 @@ define([
|
|||||||
var scrollLink = new Extension("scrollLink", "Scroll Link", true, true);
|
var scrollLink = new Extension("scrollLink", "Scroll Link", true, true);
|
||||||
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
scrollLink.settingsBlock = scrollLinkSettingsBlockHTML;
|
||||||
|
|
||||||
var aceEditor;
|
|
||||||
scrollLink.onAceCreated = function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
};
|
|
||||||
|
|
||||||
var sectionList;
|
var sectionList;
|
||||||
scrollLink.onSectionsCreated = function(sectionListParam) {
|
scrollLink.onSectionsCreated = function(sectionListParam) {
|
||||||
sectionList = sectionListParam;
|
sectionList = sectionListParam;
|
||||||
@ -35,9 +30,7 @@ define([
|
|||||||
}
|
}
|
||||||
mdSectionList = [];
|
mdSectionList = [];
|
||||||
var mdSectionOffset;
|
var mdSectionOffset;
|
||||||
var firstSectionOffset = offsetBegin;
|
|
||||||
var scrollHeight;
|
var scrollHeight;
|
||||||
if(window.lightMode) {
|
|
||||||
var editorScrollTop = $editorElt.scrollTop();
|
var editorScrollTop = $editorElt.scrollTop();
|
||||||
$editorElt.find(".wmd-input-section").each(function() {
|
$editorElt.find(".wmd-input-section").each(function() {
|
||||||
if(mdSectionOffset === undefined) {
|
if(mdSectionOffset === undefined) {
|
||||||
@ -62,24 +55,6 @@ define([
|
|||||||
endOffset: scrollHeight,
|
endOffset: scrollHeight,
|
||||||
height: scrollHeight - mdSectionOffset
|
height: scrollHeight - mdSectionOffset
|
||||||
});
|
});
|
||||||
}
|
|
||||||
else {
|
|
||||||
var mdTextOffset = 0;
|
|
||||||
_.each(sectionList, function(section) {
|
|
||||||
mdTextOffset += section.text.length + firstSectionOffset;
|
|
||||||
firstSectionOffset = 0;
|
|
||||||
var documentPosition = aceEditor.session.doc.indexToPosition(mdTextOffset);
|
|
||||||
var screenPosition = aceEditor.session.documentToScreenPosition(documentPosition.row, documentPosition.column);
|
|
||||||
var newSectionOffset = screenPosition.row * aceEditor.renderer.lineHeight;
|
|
||||||
var sectionHeight = newSectionOffset - mdSectionOffset;
|
|
||||||
mdSectionList.push({
|
|
||||||
startOffset: mdSectionOffset,
|
|
||||||
endOffset: newSectionOffset,
|
|
||||||
height: sectionHeight
|
|
||||||
});
|
|
||||||
mdSectionOffset = newSectionOffset;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find corresponding sections in the preview
|
// Find corresponding sections in the preview
|
||||||
htmlSectionList = [];
|
htmlSectionList = [];
|
||||||
@ -124,7 +99,7 @@ define([
|
|||||||
if(!isPreviewVisible || mdSectionList.length === 0 || mdSectionList.length !== htmlSectionList.length) {
|
if(!isPreviewVisible || mdSectionList.length === 0 || mdSectionList.length !== htmlSectionList.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var editorScrollTop = window.lightMode ? $editorElt.scrollTop() : aceEditor.renderer.getScrollTop();
|
var editorScrollTop = $editorElt.scrollTop();
|
||||||
editorScrollTop < 0 && (editorScrollTop = 0);
|
editorScrollTop < 0 && (editorScrollTop = 0);
|
||||||
var previewScrollTop = $previewElt.scrollTop();
|
var previewScrollTop = $previewElt.scrollTop();
|
||||||
function getDestScrollTop(srcScrollTop, srcSectionList, destSectionList) {
|
function getDestScrollTop(srcScrollTop, srcSectionList, destSectionList) {
|
||||||
@ -188,20 +163,10 @@ define([
|
|||||||
// Animate the editor
|
// Animate the editor
|
||||||
lastPreviewScrollTop = previewScrollTop;
|
lastPreviewScrollTop = previewScrollTop;
|
||||||
destScrollTop = getDestScrollTop(previewScrollTop, htmlSectionList, mdSectionList);
|
destScrollTop = getDestScrollTop(previewScrollTop, htmlSectionList, mdSectionList);
|
||||||
if(window.lightMode) {
|
|
||||||
destScrollTop = _.min([
|
destScrollTop = _.min([
|
||||||
destScrollTop,
|
destScrollTop,
|
||||||
$editorElt.prop('scrollHeight') - $editorElt.outerHeight()
|
$editorElt.prop('scrollHeight') - $editorElt.outerHeight()
|
||||||
]);
|
]);
|
||||||
}
|
|
||||||
else {
|
|
||||||
destScrollTop = _.min([
|
|
||||||
destScrollTop,
|
|
||||||
aceEditor.session.getScreenLength() * aceEditor.renderer.lineHeight + aceEditor.renderer.scrollMargin.bottom - aceEditor.renderer.$size.scrollerHeight
|
|
||||||
]);
|
|
||||||
// If negative, set it to zero
|
|
||||||
destScrollTop < 0 && (destScrollTop = 0);
|
|
||||||
}
|
|
||||||
if(Math.abs(destScrollTop - editorScrollTop) <= 9) {
|
if(Math.abs(destScrollTop - editorScrollTop) <= 9) {
|
||||||
// Skip the animation if diff is <= 9
|
// Skip the animation if diff is <= 9
|
||||||
lastEditorScrollTop = editorScrollTop;
|
lastEditorScrollTop = editorScrollTop;
|
||||||
@ -216,12 +181,7 @@ define([
|
|||||||
step: function(now) {
|
step: function(now) {
|
||||||
isEditorMoving = true;
|
isEditorMoving = true;
|
||||||
lastEditorScrollTop = editorScrollTop + now;
|
lastEditorScrollTop = editorScrollTop + now;
|
||||||
if(window.lightMode) {
|
|
||||||
$editorElt.scrollTop(lastEditorScrollTop);
|
$editorElt.scrollTop(lastEditorScrollTop);
|
||||||
}
|
|
||||||
else {
|
|
||||||
aceEditor.session.setScrollTop(lastEditorScrollTop);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
done: function() {
|
done: function() {
|
||||||
_.defer(function() {
|
_.defer(function() {
|
||||||
@ -278,12 +238,7 @@ define([
|
|||||||
doScrollLink();
|
doScrollLink();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if(window.lightMode) {
|
|
||||||
$editorElt.scroll(handleEditorScroll);
|
$editorElt.scroll(handleEditorScroll);
|
||||||
}
|
|
||||||
else {
|
|
||||||
aceEditor.session.on("changeScrollTop", handleEditorScroll);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var $previewContentsElt;
|
var $previewContentsElt;
|
||||||
|
@ -1,224 +0,0 @@
|
|||||||
define([
|
|
||||||
"jquery",
|
|
||||||
"underscore",
|
|
||||||
"crel",
|
|
||||||
"utils",
|
|
||||||
"classes/Extension",
|
|
||||||
"xregexp",
|
|
||||||
"text!bower-libs/Typo.js/typo/typo.js",
|
|
||||||
"text!bower-libs/lz-string/libs/lz-string-1.3.3.js",
|
|
||||||
"text!workers/spellCheckWorker.js",
|
|
||||||
"text!html/spellCheckSettingsBlock.html",
|
|
||||||
], function($, _, crel, utils, Extension, XRegExp, typoJS, LZStringJS, spellCheckWorkerJS, spellCheckSettingsBlockHTML) {
|
|
||||||
|
|
||||||
var spellCheck = new Extension("spellCheck", "Spell Check", true, true, true);
|
|
||||||
spellCheck.settingsBlock = spellCheckSettingsBlockHTML;
|
|
||||||
spellCheck.defaultConfig = {
|
|
||||||
locale: "en_US",
|
|
||||||
};
|
|
||||||
|
|
||||||
spellCheck.onLoadSettings = function() {
|
|
||||||
utils.setInputValue("#select-spell-check-locale", spellCheck.config.locale);
|
|
||||||
};
|
|
||||||
|
|
||||||
spellCheck.onSaveSettings = function(newConfig) {
|
|
||||||
newConfig.locale = utils.getInputValue("#select-spell-check-locale");
|
|
||||||
};
|
|
||||||
|
|
||||||
var worker;
|
|
||||||
var isInited = false;
|
|
||||||
spellCheck.onInit = function() {
|
|
||||||
// Create a web worker
|
|
||||||
worker = new Worker('res/worker.js');
|
|
||||||
worker.postMessage(spellCheckWorkerJS);
|
|
||||||
require([
|
|
||||||
'text!../libs/dictionaries/' + spellCheck.config.locale + '.dic.lz',
|
|
||||||
'text!../libs/dictionaries/' + spellCheck.config.locale + '.aff.lz',
|
|
||||||
], function(dic, aff) {
|
|
||||||
worker.postMessage(JSON.stringify(['init', typoJS, LZStringJS, spellCheck.config.locale, aff, dic]));
|
|
||||||
isInited = true;
|
|
||||||
start();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
var aceEditor;
|
|
||||||
var wordRegExp = XRegExp('\\p{L}+(?:\'\\p{L}+)*', 'g');
|
|
||||||
var markers = [];
|
|
||||||
var timeoutId;
|
|
||||||
|
|
||||||
var currentRowCheck;
|
|
||||||
|
|
||||||
function rowCheck(rowIndex) {
|
|
||||||
var tokens = aceEditor.session.getTokens(rowIndex).slice();
|
|
||||||
var tokenOffset = 0;
|
|
||||||
var self = this;
|
|
||||||
self.checkToken = function() {
|
|
||||||
if (tokens.length === 0) {
|
|
||||||
!timeoutId && (timeoutId = setTimeout(check, 5));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var token = tokens.shift();
|
|
||||||
var words = [];
|
|
||||||
if (!/code|code_block|link|reference|string|keyword|tag|markup\.underline/.test(token.type)) {
|
|
||||||
token.value.replace(wordRegExp, function(word, offset) {
|
|
||||||
words.push({
|
|
||||||
value: word,
|
|
||||||
offset: offset + tokenOffset
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
tokenOffset += token.value.length;
|
|
||||||
if (words.length === 0) {
|
|
||||||
self.checkToken();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
worker.onmessage = function(e) {
|
|
||||||
var message = JSON.parse(e.data);
|
|
||||||
if (message[0] != 'check') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var checkedWords = message[1];
|
|
||||||
if (self.stopped) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var Range = require('ace/range').Range;
|
|
||||||
_.each(checkedWords, function(word) {
|
|
||||||
if (!word.check) {
|
|
||||||
var range = new Range(rowIndex, word.offset, rowIndex, word.offset + word.value.length);
|
|
||||||
var markerId = aceEditor.session.addMarker(range, "misspelled", "typo", true);
|
|
||||||
var marker = aceEditor.session.getMarkers(true)[markerId];
|
|
||||||
markers.push(marker);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
self.checkToken();
|
|
||||||
};
|
|
||||||
worker.postMessage(JSON.stringify(['check', words]));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var rowIndex = 0;
|
|
||||||
|
|
||||||
function check() {
|
|
||||||
timeoutId = undefined;
|
|
||||||
currentRowCheck && (currentRowCheck.stopped = true);
|
|
||||||
currentRowCheck = new rowCheck(rowIndex++);
|
|
||||||
currentRowCheck.checkToken();
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop() {
|
|
||||||
currentRowCheck && (currentRowCheck.stopped = true);
|
|
||||||
timeoutId && clearTimeout(timeoutId);
|
|
||||||
timeoutId = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
function start() {
|
|
||||||
if(isInited === false || aceEditor === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var savedMarkers = [];
|
|
||||||
_.each(markers, function(marker) {
|
|
||||||
if (marker.range.start.row < rowIndex) {
|
|
||||||
savedMarkers.push(marker);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
aceEditor.session.removeMarker(marker.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
markers = savedMarkers;
|
|
||||||
timeoutId = setTimeout(check, 2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
var dropdownElt;
|
|
||||||
var $dropdownElt;
|
|
||||||
var liEltTmpl = [
|
|
||||||
'<li>',
|
|
||||||
' <a href="#">',
|
|
||||||
' <%= suggestion %>',
|
|
||||||
' </a>',
|
|
||||||
'</li>'
|
|
||||||
].join('');
|
|
||||||
|
|
||||||
var currentWordSuggest = undefined;
|
|
||||||
|
|
||||||
function wordSuggest(marker) {
|
|
||||||
var word = aceEditor.session.getTextRange(marker.range);
|
|
||||||
var self = this;
|
|
||||||
self.run = function() {
|
|
||||||
worker.onmessage = function(e) {
|
|
||||||
var message = JSON.parse(e.data);
|
|
||||||
if (message[0] != 'suggest') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var suggestions = message[1];
|
|
||||||
if (self.stopped) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
console.log(suggestions);
|
|
||||||
var liListHtml = _.reduce(suggestions, function(result, suggestion) {
|
|
||||||
return result + _.template(liEltTmpl, {
|
|
||||||
suggestion: suggestion,
|
|
||||||
});
|
|
||||||
}, '');
|
|
||||||
dropdownElt.innerHTML = liListHtml;
|
|
||||||
$(dropdownElt).dropdown('toggle');
|
|
||||||
};
|
|
||||||
worker.postMessage(JSON.stringify(['suggest', word]));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
var fileOpen = false;
|
|
||||||
spellCheck.onFileClose = function() {
|
|
||||||
stop();
|
|
||||||
fileOpen = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
spellCheck.onFileOpen = function() {
|
|
||||||
fileOpen = true;
|
|
||||||
rowIndex = 0;
|
|
||||||
stop();
|
|
||||||
start();
|
|
||||||
};
|
|
||||||
|
|
||||||
spellCheck.onAceCreated = function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
aceEditor.session.on('change', function(e) {
|
|
||||||
if (fileOpen === true) {
|
|
||||||
var modifiedRowIndex = e.data.range.start.row;
|
|
||||||
if (modifiedRowIndex < rowIndex) {
|
|
||||||
rowIndex = modifiedRowIndex;
|
|
||||||
}
|
|
||||||
stop();
|
|
||||||
start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Suggestions are disabled. Too much CPU consumption.
|
|
||||||
/*
|
|
||||||
aceEditor.on("click", function(ev) {
|
|
||||||
var screenCoordinates = aceEditor.renderer.pixelToScreenCoordinates(ev.x, ev.y);
|
|
||||||
var documentPosition = aceEditor.session.screenToDocumentPosition(screenCoordinates.row, screenCoordinates.column);
|
|
||||||
_.each(markers, function(marker) {
|
|
||||||
if (marker.range.contains(documentPosition.row, documentPosition.column)) {
|
|
||||||
currentWordSuggest && (currentWordSuggest.stopped = true);
|
|
||||||
currentWordSuggest = new wordSuggest(marker);
|
|
||||||
currentWordSuggest.run();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
spellCheck.onReady = function() {
|
|
||||||
dropdownElt = crel('ul', {
|
|
||||||
class: 'dropdown-menu dropdown-spell-checker'
|
|
||||||
});
|
|
||||||
document.querySelector('.ui-layout-resizer-north').appendChild(crel('div', crel('div', {
|
|
||||||
'data-toggle': 'dropdown'
|
|
||||||
}), dropdownElt));
|
|
||||||
$dropdownElt = $(dropdownElt).dropdown();
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
|
|
||||||
return spellCheck;
|
|
||||||
});
|
|
@ -160,11 +160,6 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var aceEditor;
|
|
||||||
eventMgr.addListener('onAceCreated', function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
});
|
|
||||||
|
|
||||||
eventMgr.addListener("onReady", function() {
|
eventMgr.addListener("onReady", function() {
|
||||||
var $editorElt = $("#wmd-input");
|
var $editorElt = $("#wmd-input");
|
||||||
fileMgr.selectFile();
|
fileMgr.selectFile();
|
||||||
@ -204,7 +199,7 @@ define([
|
|||||||
eventMgr.onTitleChanged(fileDesc);
|
eventMgr.onTitleChanged(fileDesc);
|
||||||
}
|
}
|
||||||
$fileTitleInputElt.val(fileDesc.title);
|
$fileTitleInputElt.val(fileDesc.title);
|
||||||
aceEditor ? aceEditor.focus() : $editorElt.focus();
|
$editorElt.focus();
|
||||||
}
|
}
|
||||||
$fileTitleInputElt.blur(function() {
|
$fileTitleInputElt.blur(function() {
|
||||||
applyTitle();
|
applyTitle();
|
||||||
@ -222,9 +217,6 @@ define([
|
|||||||
});
|
});
|
||||||
$(".action-edit-document").click(function() {
|
$(".action-edit-document").click(function() {
|
||||||
var content = $editorElt.val();
|
var content = $editorElt.val();
|
||||||
if(aceEditor !== undefined) {
|
|
||||||
content = aceEditor.getValue();
|
|
||||||
}
|
|
||||||
var title = fileMgr.currentFile.title;
|
var title = fileMgr.currentFile.title;
|
||||||
var fileDesc = fileMgr.createFile(title, content);
|
var fileDesc = fileMgr.createFile(title, content);
|
||||||
fileMgr.selectFile(fileDesc);
|
fileMgr.selectFile(fileDesc);
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="wmd-input" class="ui-layout-center"></div>
|
<pre id="wmd-input" class="ui-layout-center form-control"></pre>
|
||||||
<div class="ui-layout-east preview-container"></div>
|
<div class="ui-layout-east preview-container"></div>
|
||||||
<div class="ui-layout-south preview-container"></div>
|
<div class="ui-layout-south preview-container"></div>
|
||||||
<div id="wmd-button-bar" class="hide"></div>
|
<div id="wmd-button-bar" class="hide"></div>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,312 +0,0 @@
|
|||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var lang = require("ace/lib/lang");
|
|
||||||
var config = require("ace/config");
|
|
||||||
var Range = require('ace/range').Range
|
|
||||||
|
|
||||||
function bindKey(win, mac) {
|
|
||||||
return {
|
|
||||||
win: win,
|
|
||||||
mac: mac
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.commands = [{
|
|
||||||
name: "overwrite",
|
|
||||||
bindKey: "Insert",
|
|
||||||
exec: function(editor) { editor.toggleOverwrite(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selecttostart",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectFileStart(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotostart",
|
|
||||||
bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"),
|
|
||||||
exec: function(editor) { editor.navigateFileStart(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectup",
|
|
||||||
bindKey: bindKey("Shift-Up", "Shift-Up"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectUp(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "golineup",
|
|
||||||
bindKey: bindKey("Up", "Up"),
|
|
||||||
exec: function(editor, args) { editor.navigateUp(args.times); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selecttoend",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectFileEnd(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotoend",
|
|
||||||
bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"),
|
|
||||||
exec: function(editor) { editor.navigateFileEnd(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectdown",
|
|
||||||
bindKey: bindKey("Shift-Down", "Shift-Down"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectDown(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "golinedown",
|
|
||||||
bindKey: bindKey("Down", "Down"),
|
|
||||||
exec: function(editor, args) { editor.navigateDown(args.times); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectwordleft",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Left", "Option-Shift-Left"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectWordLeft(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotowordleft",
|
|
||||||
bindKey: bindKey("Ctrl-Left", "Option-Left"),
|
|
||||||
exec: function(editor) { editor.navigateWordLeft(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selecttolinestart",
|
|
||||||
bindKey: bindKey("Alt-Shift-Left", "Command-Shift-Left"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectLineStart(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotolinestart",
|
|
||||||
bindKey: bindKey("Alt-Left|Home", "Command-Left|Home"),
|
|
||||||
exec: function(editor) { editor.navigateLineStart(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectleft",
|
|
||||||
bindKey: bindKey("Shift-Left", "Shift-Left"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectLeft(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotoleft",
|
|
||||||
bindKey: bindKey("Left", "Left"),
|
|
||||||
exec: function(editor, args) { editor.navigateLeft(args.times); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectwordright",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Right", "Option-Shift-Right"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectWordRight(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotowordright",
|
|
||||||
bindKey: bindKey("Ctrl-Right", "Option-Right"),
|
|
||||||
exec: function(editor) { editor.navigateWordRight(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selecttolineend",
|
|
||||||
bindKey: bindKey("Alt-Shift-Right", "Command-Shift-Right"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectLineEnd(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotolineend",
|
|
||||||
bindKey: bindKey("Alt-Right|End", "Command-Right|End"),
|
|
||||||
exec: function(editor) { editor.navigateLineEnd(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectright",
|
|
||||||
bindKey: bindKey("Shift-Right", "Shift-Right"),
|
|
||||||
exec: function(editor) { editor.getSelection().selectRight(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotoright",
|
|
||||||
bindKey: bindKey("Right", "Right"),
|
|
||||||
exec: function(editor, args) { editor.navigateRight(args.times); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectpagedown",
|
|
||||||
bindKey: "Shift-PageDown",
|
|
||||||
exec: function(editor) { editor.selectPageDown(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "pagedown",
|
|
||||||
bindKey: bindKey(null, "Option-PageDown"),
|
|
||||||
exec: function(editor) { editor.scrollPageDown(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotopagedown",
|
|
||||||
bindKey: bindKey("PageDown", "PageDown"),
|
|
||||||
exec: function(editor) { editor.gotoPageDown(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectpageup",
|
|
||||||
bindKey: "Shift-PageUp",
|
|
||||||
exec: function(editor) { editor.selectPageUp(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "pageup",
|
|
||||||
bindKey: bindKey(null, "Option-PageUp"),
|
|
||||||
exec: function(editor) { editor.scrollPageUp(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "gotopageup",
|
|
||||||
bindKey: "PageUp",
|
|
||||||
exec: function(editor) { editor.gotoPageUp(); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "scrollup",
|
|
||||||
bindKey: bindKey("Ctrl-Up", null),
|
|
||||||
exec: function(e) { e.renderer.scrollBy(0, -2 * e.renderer.layerConfig.lineHeight); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "scrolldown",
|
|
||||||
bindKey: bindKey("Ctrl-Down", null),
|
|
||||||
exec: function(e) { e.renderer.scrollBy(0, 2 * e.renderer.layerConfig.lineHeight); },
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectlinestart",
|
|
||||||
bindKey: "Shift-Home",
|
|
||||||
exec: function(editor) { editor.getSelection().selectLineStart(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
}, {
|
|
||||||
name: "selectlineend",
|
|
||||||
bindKey: "Shift-End",
|
|
||||||
exec: function(editor) { editor.getSelection().selectLineEnd(); },
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: true
|
|
||||||
},
|
|
||||||
|
|
||||||
// commands disabled in readOnly mode
|
|
||||||
{
|
|
||||||
name: "cut",
|
|
||||||
exec: function(editor) {
|
|
||||||
var range = editor.getSelectionRange();
|
|
||||||
editor._emit("cut", range);
|
|
||||||
|
|
||||||
if (!editor.selection.isEmpty()) {
|
|
||||||
editor.session.remove(range);
|
|
||||||
editor.clearSelection();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "undo",
|
|
||||||
bindKey: bindKey("Ctrl-Z", "Command-Z"),
|
|
||||||
exec: function(editor) { editor.undo(); }
|
|
||||||
}, {
|
|
||||||
name: "redo",
|
|
||||||
bindKey: bindKey("Ctrl-Shift-Z|Ctrl-Y", "Command-Shift-Z|Command-Y"),
|
|
||||||
exec: function(editor) { editor.redo(); }
|
|
||||||
}, {
|
|
||||||
name: "del",
|
|
||||||
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
|
|
||||||
exec: function(editor) { editor.remove("right"); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "backspace",
|
|
||||||
bindKey: bindKey(
|
|
||||||
"Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
|
||||||
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
|
|
||||||
),
|
|
||||||
exec: function(editor) { editor.remove("left"); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "removetolinestart",
|
|
||||||
bindKey: bindKey("Alt-Backspace", "Command-Backspace"),
|
|
||||||
exec: function(editor) { editor.removeToLineStart(); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "removetolineend",
|
|
||||||
bindKey: bindKey("Alt-Delete", "Ctrl-K"),
|
|
||||||
exec: function(editor) { editor.removeToLineEnd(); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "removewordleft",
|
|
||||||
bindKey: bindKey("Ctrl-Backspace", "Alt-Backspace|Ctrl-Alt-Backspace"),
|
|
||||||
exec: function(editor) { editor.removeWordLeft(); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "removewordright",
|
|
||||||
bindKey: bindKey("Ctrl-Delete", "Alt-Delete"),
|
|
||||||
exec: function(editor) { editor.removeWordRight(); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "outdent",
|
|
||||||
bindKey: bindKey("Shift-Tab", "Shift-Tab"),
|
|
||||||
exec: function(editor) { editor.blockOutdent(); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "indent",
|
|
||||||
bindKey: bindKey("Tab", "Tab"),
|
|
||||||
exec: function(editor) {
|
|
||||||
// Perform block indent if the caret is at the begining of a list item
|
|
||||||
var selectionRange = editor.getSelectionRange();
|
|
||||||
var range = new Range(selectionRange.end.row, 0, selectionRange.end.row, selectionRange.end.column);
|
|
||||||
var startText = editor.session.getTextRange(range);
|
|
||||||
var token = editor.session.getTokenAt(selectionRange.end.row, selectionRange.end.column);
|
|
||||||
if(token && token.type == "markup.list" && /^\s*(?:[-+*]|\d+\.)\s+$/.test(startText)) {
|
|
||||||
editor.blockIndent();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
editor.indent();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "insertstring",
|
|
||||||
exec: function(editor, str) { editor.insert(str); },
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}, {
|
|
||||||
name: "inserttext",
|
|
||||||
exec: function(editor, args) {
|
|
||||||
editor.insert(lang.stringRepeat(args.text || "", args.times || 1));
|
|
||||||
},
|
|
||||||
multiSelectAction: "forEach"
|
|
||||||
}];
|
|
||||||
|
|
||||||
});
|
|
@ -1,96 +0,0 @@
|
|||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var oop = require("ace/lib/oop");
|
|
||||||
var TextMode = require("ace/mode/text").Mode;
|
|
||||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
|
||||||
var MarkdownHighlightRules = require("./ace_mode_highlight_rules").MarkdownHighlightRules;
|
|
||||||
var MarkdownFoldMode = require("ace/mode/folding/markdown").FoldMode;
|
|
||||||
var eventMgr = require('eventMgr');
|
|
||||||
var Range = require('ace/range').Range
|
|
||||||
var editor = undefined;
|
|
||||||
eventMgr.addListener('onAceCreated', function(editorParam) {
|
|
||||||
editor = editorParam;
|
|
||||||
});
|
|
||||||
|
|
||||||
var Mode = function() {
|
|
||||||
var highlighter = new MarkdownHighlightRules();
|
|
||||||
|
|
||||||
this.$tokenizer = new Tokenizer(highlighter.getRules());
|
|
||||||
this.$embeds = highlighter.getEmbeds();
|
|
||||||
|
|
||||||
//this.foldingRules = new MarkdownFoldMode();
|
|
||||||
};
|
|
||||||
oop.inherits(Mode, TextMode);
|
|
||||||
|
|
||||||
var isIndentingList = false;
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
this.type = "text";
|
|
||||||
this.lineCommentStart = ">";
|
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
if(isIndentingList === true && (state == "listblock" || state == "listblock-start") && /^\s*(?:[-+*]|\d+\.)\s+$/.test(line)) {
|
|
||||||
// When hitting enter twice in a listblock, remove the previous line
|
|
||||||
var rows = editor.$getSelectedRows();
|
|
||||||
if (rows.last > 1) {
|
|
||||||
var range = new Range(
|
|
||||||
rows.last - 2, editor.session.getLine(rows.last - 2).length,
|
|
||||||
rows.last - 1, editor.session.getLine(rows.last - 1).length);
|
|
||||||
var previousLine = editor.session.getTextRange(range);
|
|
||||||
if(/^\s*(?:[-+*]|\d+\.)\s+$/.test(previousLine)) {
|
|
||||||
editor.session.remove(range);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
isIndentingList = false;
|
|
||||||
return this.$getIndent(line);
|
|
||||||
}
|
|
||||||
isIndentingList = false;
|
|
||||||
if (state == "listblock") {
|
|
||||||
var match = /^(\s*)(?:([-+*])|(\d+)\.)(\s+)/.exec(line);
|
|
||||||
if (!match)
|
|
||||||
return "";
|
|
||||||
var marker = match[2];
|
|
||||||
if (!marker)
|
|
||||||
marker = parseInt(match[3], 10) + 1 + ".";
|
|
||||||
isIndentingList = true;
|
|
||||||
return match[1] + marker + match[4];
|
|
||||||
} else {
|
|
||||||
return this.$getIndent(line);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}).call(Mode.prototype);
|
|
||||||
|
|
||||||
exports.Mode = Mode;
|
|
||||||
});
|
|
@ -1,239 +0,0 @@
|
|||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Distributed under the BSD license:
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010, Ajax.org B.V.
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of Ajax.org B.V. nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
define(function(require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
var oop = require("ace/lib/oop");
|
|
||||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
|
||||||
var HtmlHighlightRules = require("ace/mode/html_highlight_rules").HtmlHighlightRules;
|
|
||||||
|
|
||||||
var MarkdownHighlightRules = function() {
|
|
||||||
HtmlHighlightRules.call(this);
|
|
||||||
|
|
||||||
// regexp must not have capturing parentheses
|
|
||||||
// regexps are ordered -> the first match is used
|
|
||||||
this.$rules["start"].unshift({
|
|
||||||
token : "empty_line",
|
|
||||||
regex : '^$',
|
|
||||||
next: "allowBlock"
|
|
||||||
}, { // h1
|
|
||||||
token: "markup.heading.multi.1",
|
|
||||||
regex: "^=+(?=\\s*$)"
|
|
||||||
}, { // h2
|
|
||||||
token: "markup.heading.multi.2",
|
|
||||||
regex: "^\\-+(?=\\s*$)"
|
|
||||||
}, {
|
|
||||||
token : function(value) {
|
|
||||||
return "markup.heading." + value.length;
|
|
||||||
},
|
|
||||||
regex : /^#{1,6}(?=\s*[^ #]|\s+#.)/,
|
|
||||||
next : "header"
|
|
||||||
},
|
|
||||||
{ // Github style block
|
|
||||||
token : "constant.language.escape",
|
|
||||||
regex : "^```\\s*[a-zA-Z]*(?:{.*?\\})?\\s*$",
|
|
||||||
next : "githubblock"
|
|
||||||
}, { // block quote
|
|
||||||
token : ["constant.language.escape", "blockquote"],
|
|
||||||
regex : "(^\\s*>\\s*(?:[*+-]|\\d+\\.)?)(\\s+)",
|
|
||||||
next : "blockquote"
|
|
||||||
}, { // HR * - _
|
|
||||||
token : "constant",
|
|
||||||
regex : "^ {0,2}(?:(?: ?\\* ?){3,}|(?: ?\\- ?){3,}|(?: ?\\_ ?){3,})\\s*$",
|
|
||||||
next: "allowBlock"
|
|
||||||
}, { // list
|
|
||||||
token : ["constant.language.escape", "markup.list"],
|
|
||||||
regex : "(^\\s{0,3}(?:[*+-]|\\d+\\.))(\\s+)",
|
|
||||||
next : "listblock-start"
|
|
||||||
}, { // Math block
|
|
||||||
token : "constant.language.escape",
|
|
||||||
regex : "\\$\\$|\\\\\\\\\\[|\\\\\\\\\\\\\\\\\\(",
|
|
||||||
next : "mathblock"
|
|
||||||
}, { // LaTeX block
|
|
||||||
token : ["keyword", "text"],
|
|
||||||
regex : "(\\\\?\\\\begin)(\\{[a-z]*\\*?\\})",
|
|
||||||
next : "latexblock"
|
|
||||||
}, {
|
|
||||||
token : "doccomment",
|
|
||||||
regex : "<\\!---", next :
|
|
||||||
"doccomment"
|
|
||||||
}, {
|
|
||||||
include : "basic"
|
|
||||||
});
|
|
||||||
|
|
||||||
this.addRules({
|
|
||||||
"basic" : [{
|
|
||||||
token : "constant.language.escape",
|
|
||||||
regex : /\\[\\`*_{}\[\]()#+\-.!]/
|
|
||||||
}, { // Escaped $
|
|
||||||
token : "text",
|
|
||||||
regex : "\\\\\\$",
|
|
||||||
}, { // Math inline
|
|
||||||
token : ["constant.language.escape", "keyword", "constant.language.escape"],
|
|
||||||
regex : "(\\$)(.*?)(\\$)"
|
|
||||||
}, { // code span `
|
|
||||||
token : ["constant.language.escape", "code", "constant.language.escape"],
|
|
||||||
regex : "(`+)(.*?[^`])(\\1)"
|
|
||||||
}, { // reference
|
|
||||||
token : ["constant.language.escape", "reference", "constant.language.escape", "link", "description", "constant.language.escape"],
|
|
||||||
regex : "^([ ]{0,3}\\[)([^\\]]+)(\\]:\\s*)([^ ]+)(\\s*(?:[\"][^\"]+[\"])?(\\s*))$"
|
|
||||||
}, { // link by reference
|
|
||||||
token : ["constant.language.escape", "markup.underline", "constant.language.escape", "reference", "constant.language.escape"],
|
|
||||||
regex : "(\\[)((?:[[^\\]]*\\]|[^\\[\\]])*)(\\][ ]?(?:\\n[ ]*)?\\[)(.*?)(\\])"
|
|
||||||
}, { // link by url
|
|
||||||
token : ["constant.language.escape", "markup.underline", "constant.language.escape", "link", "description", "constant.language.escape"],
|
|
||||||
regex : "(\\[)"+
|
|
||||||
"(\\[[^\\]]*\\]|[^\\[\\]]*)"+
|
|
||||||
"(\\]\\([ \\t]*)"+
|
|
||||||
"(<?(?:(?:[^\\(]*?\\([^\\)]*?\\)\\S*?)|(?:.*?))>?)"+
|
|
||||||
"((?:[ \t]*\"(?:.*?)\"[ \\t]*)?)"+
|
|
||||||
"(\\))"
|
|
||||||
}, { // strong ** __
|
|
||||||
token : ["constant.language.escape", "strong", "constant.language.escape"],
|
|
||||||
regex : "([*]{2}|[_]{2}(?=\\S))(.*?\\S[*_]*)(\\1)"
|
|
||||||
}, { // emphasis * _
|
|
||||||
token : ["constant.language.escape", "emphasis", "constant.language.escape"],
|
|
||||||
regex : "([*]|[_](?=\\S))(.*?\\S[*_]*)(\\1)"
|
|
||||||
}, { //
|
|
||||||
token : ["text", "url", "text"],
|
|
||||||
regex : "(<)("+
|
|
||||||
"(?:https?|ftp|dict):[^'\">\\s]+"+
|
|
||||||
"|"+
|
|
||||||
"(?:mailto:)?[-.\\w]+\\@[-a-z0-9]+(?:\\.[-a-z0-9]+)*\\.[a-z]+"+
|
|
||||||
")(>)"
|
|
||||||
}],
|
|
||||||
|
|
||||||
// code block
|
|
||||||
"allowBlock": [
|
|
||||||
{token : ["text", "code_block"], regex : "^( {4}|\\t)(.+)", next : "allowBlock"},
|
|
||||||
{token : "empty", regex : "", next : "start"}
|
|
||||||
],
|
|
||||||
|
|
||||||
"header" : [{
|
|
||||||
regex: "$",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
include: "basic"
|
|
||||||
}, {
|
|
||||||
defaultToken : "markup.heading"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
"listblock-start" : [{
|
|
||||||
token : "checkbox",
|
|
||||||
regex : /(?:\[[ x]\])?/,
|
|
||||||
next : "listblock"
|
|
||||||
}],
|
|
||||||
|
|
||||||
"listblock" : [ { // Lists only escape on completely blank lines.
|
|
||||||
token : "empty_line",
|
|
||||||
regex : "^$",
|
|
||||||
next : "start"
|
|
||||||
}, { // list
|
|
||||||
token : ["constant.language.escape", "markup.list"],
|
|
||||||
regex : "(^\\s{0,3}(?:[*+-]|\\d+\\.))(\\s+)",
|
|
||||||
next : "listblock-start"
|
|
||||||
}, {
|
|
||||||
include : "basic", noEscape: true
|
|
||||||
}, {
|
|
||||||
defaultToken : "markup.list"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
"blockquote" : [ { // BLockquotes only escape on blank lines.
|
|
||||||
token : "empty_line",
|
|
||||||
regex : "^\\s*$",
|
|
||||||
next : "start"
|
|
||||||
}, { // block quote
|
|
||||||
token : ["constant.language.escape", "blockquote"],
|
|
||||||
regex : "(^\\s*>\\s*(?:[*+-]|\\d+\\.)?)(\\s+)",
|
|
||||||
next : "blockquote"
|
|
||||||
}, {
|
|
||||||
include : "basic", noEscape: true
|
|
||||||
}, {
|
|
||||||
defaultToken : "blockquote"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
"githubblock" : [ {
|
|
||||||
token : "constant.language.escape",
|
|
||||||
regex : "^```",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
token : "code_block",
|
|
||||||
regex : ".+"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
"mathblock" : [ {
|
|
||||||
token : "constant.language.escape",
|
|
||||||
regex : "\\$\\$|\\\\\\\\\\]|\\\\\\\\\\\\\\\\\\)",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
include : "latex"
|
|
||||||
} ],
|
|
||||||
|
|
||||||
"latexblock" : [{
|
|
||||||
token : ["keyword", "text"],
|
|
||||||
regex : "(\\\\?\\\\end)(\\{[a-z]*\\*?\\})",
|
|
||||||
next : "start"
|
|
||||||
}, {
|
|
||||||
include : "latex"
|
|
||||||
}],
|
|
||||||
|
|
||||||
"latex" : [{
|
|
||||||
// A tex command e.g. \foo
|
|
||||||
token : "keyword",
|
|
||||||
regex : "\\\\(?:[^a-zA-Z]|[a-zA-Z]+)"
|
|
||||||
}, {
|
|
||||||
// Curly and square braces
|
|
||||||
token : "lparen",
|
|
||||||
regex : "[[({]"
|
|
||||||
}, {
|
|
||||||
// Curly and square braces
|
|
||||||
token : "rparen",
|
|
||||||
regex : "[\\])}]"
|
|
||||||
}, {
|
|
||||||
// A comment. Tex comments start with % and go to
|
|
||||||
// the end of the line
|
|
||||||
token : "comment",
|
|
||||||
regex : "%.*$"
|
|
||||||
}],
|
|
||||||
|
|
||||||
doccomment : [
|
|
||||||
{token : "doccomment", regex : "-->", next : "start"},
|
|
||||||
{defaultToken : "doccomment"}
|
|
||||||
],
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
this.normalizeRules();
|
|
||||||
};
|
|
||||||
oop.inherits(MarkdownHighlightRules, TextHighlightRules);
|
|
||||||
|
|
||||||
exports.MarkdownHighlightRules = MarkdownHighlightRules;
|
|
||||||
});
|
|
@ -1,11 +0,0 @@
|
|||||||
(function() {
|
|
||||||
|
|
||||||
define(function (require, exports, module) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
exports.load = function (name, req, onLoad, config) {
|
|
||||||
onLoad('', 'utf8');
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
})();
|
|
@ -3,11 +3,6 @@
|
|||||||
requirejs.config({
|
requirejs.config({
|
||||||
waitSeconds: 0,
|
waitSeconds: 0,
|
||||||
packages: [
|
packages: [
|
||||||
{
|
|
||||||
name: 'ace',
|
|
||||||
location: 'bower-libs/ace/lib/ace',
|
|
||||||
main: 'ace'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'css',
|
name: 'css',
|
||||||
location: 'bower-libs/require-css',
|
location: 'bower-libs/require-css',
|
||||||
@ -48,24 +43,18 @@ requirejs.config({
|
|||||||
'bootstrap-tour': 'bower-libs/bootstrap-tour/build/js/bootstrap-tour',
|
'bootstrap-tour': 'bower-libs/bootstrap-tour/build/js/bootstrap-tour',
|
||||||
css_browser_selector: 'bower-libs/css_browser_selector/css_browser_selector',
|
css_browser_selector: 'bower-libs/css_browser_selector/css_browser_selector',
|
||||||
'jquery-mousewheel': 'bower-libs/jquery-mousewheel/jquery.mousewheel',
|
'jquery-mousewheel': 'bower-libs/jquery-mousewheel/jquery.mousewheel',
|
||||||
'pagedown-ace': 'bower-libs/pagedown-ace/Markdown.Editor',
|
|
||||||
'pagedown-light': 'libs/Markdown.Editor.light',
|
|
||||||
'pagedown-extra': 'bower-libs/pagedown-extra/Markdown.Extra',
|
'pagedown-extra': 'bower-libs/pagedown-extra/Markdown.Extra',
|
||||||
'ace/requirejs/text': 'libs/ace_text',
|
'pagedown': 'bower-libs/stackedit-pagedown/Markdown.Editor',
|
||||||
'ace/commands/default_commands': 'libs/ace_commands',
|
|
||||||
'require-css': 'bower-libs/require-css/css',
|
'require-css': 'bower-libs/require-css/css',
|
||||||
xregexp: 'bower-libs/xregexp/xregexp-all',
|
xregexp: 'bower-libs/xregexp/xregexp-all',
|
||||||
yaml: 'bower-libs/yaml.js',
|
yaml: 'bower-libs/yaml.js',
|
||||||
'yaml.js': 'bower-libs/yaml.js',
|
'yaml.js': 'bower-libs/yaml.js',
|
||||||
'yaml-js': 'bower-libs/yaml.js/bin/yaml',
|
'yaml-js': 'bower-libs/yaml.js/bin/yaml',
|
||||||
Typo: 'bower-libs/Typo.js',
|
|
||||||
'Typo.js': 'bower-libs/Typo.js',
|
|
||||||
css: 'bower-libs/require-css/css',
|
css: 'bower-libs/require-css/css',
|
||||||
'css-builder': 'bower-libs/require-css/css-builder',
|
'css-builder': 'bower-libs/require-css/css-builder',
|
||||||
normalize: 'bower-libs/require-css/normalize',
|
normalize: 'bower-libs/require-css/normalize',
|
||||||
prism: 'bower-libs/prism/prism',
|
prism: 'bower-libs/prism/prism',
|
||||||
'prism-core': 'bower-libs/prism/components/prism-core',
|
'prism-core': 'bower-libs/prism/components/prism-core'
|
||||||
caret: 'bower-libs/caret.js/src/jquery.caret'
|
|
||||||
},
|
},
|
||||||
shim: {
|
shim: {
|
||||||
underscore: {
|
underscore: {
|
||||||
@ -126,9 +115,6 @@ requirejs.config({
|
|||||||
bootstrap: [
|
bootstrap: [
|
||||||
'jquery'
|
'jquery'
|
||||||
],
|
],
|
||||||
'caret': [
|
|
||||||
'jquery'
|
|
||||||
],
|
|
||||||
'jquery-waitforimages': [
|
'jquery-waitforimages': [
|
||||||
'jquery'
|
'jquery'
|
||||||
],
|
],
|
||||||
@ -156,15 +142,12 @@ requirejs.config({
|
|||||||
'jquery-ui-core': [
|
'jquery-ui-core': [
|
||||||
'jquery'
|
'jquery'
|
||||||
],
|
],
|
||||||
|
'pagedown': [
|
||||||
|
'bower-libs/stackedit-pagedown/Markdown.Converter'
|
||||||
|
],
|
||||||
'pagedown-extra': [
|
'pagedown-extra': [
|
||||||
'pagedown-ace'
|
'bower-libs/stackedit-pagedown/Markdown.Converter'
|
||||||
],
|
],
|
||||||
'pagedown-ace': [
|
|
||||||
'bower-libs/pagedown-ace/Markdown.Converter'
|
|
||||||
],
|
|
||||||
'pagedown-light': [
|
|
||||||
'bower-libs/pagedown-ace/Markdown.Converter'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,13 +170,6 @@ catch (e) {
|
|||||||
// Viewer mode is deduced from the body class
|
// Viewer mode is deduced from the body class
|
||||||
window.viewerMode = /(^| )viewer($| )/.test(document.body.className);
|
window.viewerMode = /(^| )viewer($| )/.test(document.body.className);
|
||||||
|
|
||||||
// Light mode is for mobile or viewer
|
|
||||||
window.lightMode = window.viewerMode || /_light_/.test(localStorage.mode) || /(\?|&)light($|&)/.test(location.search) || (function(a) {
|
|
||||||
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
})(navigator.userAgent || navigator.vendor || window.opera);
|
|
||||||
|
|
||||||
// Keep the theme in a global variable
|
// Keep the theme in a global variable
|
||||||
window.theme = localStorage.themeV3 || 'default';
|
window.theme = localStorage.themeV3 || 'default';
|
||||||
var themeModule = "less!themes/" + window.theme;
|
var themeModule = "less!themes/" + window.theme;
|
||||||
@ -211,9 +187,6 @@ themeModule, ], function($, core, eventMgr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
// Add RTL class
|
|
||||||
/_rtl_/.test(localStorage.mode) && $(document.body).addClass('rtl');
|
|
||||||
|
|
||||||
// Here, all the modules are loaded and the DOM is ready
|
// Here, all the modules are loaded and the DOM is ready
|
||||||
core.onReady();
|
core.onReady();
|
||||||
|
|
||||||
|
@ -283,21 +283,7 @@ define([
|
|||||||
pagedownEditor = pagedownEditorParam;
|
pagedownEditor = pagedownEditorParam;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Keep a link to the ACE editor
|
|
||||||
var realtimeContext;
|
|
||||||
var aceEditor;
|
|
||||||
var isAceUpToDate = true;
|
|
||||||
eventMgr.addListener('onAceCreated', function(aceEditorParam) {
|
|
||||||
aceEditor = aceEditorParam;
|
|
||||||
// Listen to editor's changes
|
|
||||||
aceEditor.session.on('change', function() {
|
|
||||||
// Update the real time model if any
|
|
||||||
realtimeContext && realtimeContext.string && realtimeContext.string.setText(aceEditor.getValue());
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Start realtime synchronization
|
// Start realtime synchronization
|
||||||
var Range = require('ace/range').Range;
|
|
||||||
gdriveProvider.startRealtimeSync = function(fileDesc, syncAttributes) {
|
gdriveProvider.startRealtimeSync = function(fileDesc, syncAttributes) {
|
||||||
var localContext = {};
|
var localContext = {};
|
||||||
realtimeContext = localContext;
|
realtimeContext = localContext;
|
||||||
|
@ -6,6 +6,7 @@ define([
|
|||||||
|
|
||||||
var settings = {
|
var settings = {
|
||||||
layoutOrientation: "horizontal",
|
layoutOrientation: "horizontal",
|
||||||
|
mode: 'ltr',
|
||||||
lazyRendering: true,
|
lazyRendering: true,
|
||||||
editorFontFamily: 'Menlo, Consolas, "Courier New", Courier, monospace',
|
editorFontFamily: 'Menlo, Consolas, "Courier New", Courier, monospace',
|
||||||
editorFontSize: 13,
|
editorFontSize: 13,
|
||||||
|
@ -249,6 +249,12 @@ define([
|
|||||||
|
|
||||||
if(version == "v17") {
|
if(version == "v17") {
|
||||||
localStorage.removeItem('focusMode');
|
localStorage.removeItem('focusMode');
|
||||||
|
localStorage.removeItem('mode');
|
||||||
|
_.each(_.keys(localStorage), function(key) {
|
||||||
|
if(key.match(/file\.\S+\.editorSelectRange/)); {
|
||||||
|
localStorage.removeItem(key);
|
||||||
|
}
|
||||||
|
});
|
||||||
version = "v18";
|
version = "v18";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
@import "base.less";
|
@import "base.less";
|
||||||
@import (less) "../bower-libs/ace/lib/ace/css/editor.css";
|
|
||||||
@import (less) "../bower-libs/ace/lib/ace/ext/searchbox.css";
|
|
||||||
@import (less) "../bower-libs/ace/lib/ace/theme/textmate.css";
|
|
||||||
@import "../bower-libs/bootstrap-tour/src/less/bootstrap-tour.less";
|
@import "../bower-libs/bootstrap-tour/src/less/bootstrap-tour.less";
|
||||||
@import (less) "jquery.jgrowl.css";
|
@import (less) "jquery.jgrowl.css";
|
||||||
|
|
||||||
@ -1013,192 +1010,6 @@ a {
|
|||||||
* Editor
|
* Editor
|
||||||
*****************************/
|
*****************************/
|
||||||
|
|
||||||
.ace_editor {
|
|
||||||
color: @tertiary-color-dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace-tm {
|
|
||||||
background-color: @tertiary-bg;
|
|
||||||
|
|
||||||
.ace_text-input {
|
|
||||||
box-sizing: initial;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_cursor {
|
|
||||||
color: darken(@primary-desaturated, 30%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_print-margin-layer {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_marker-layer .ace_bracket {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_markup.ace_heading {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_markup.ace_list {
|
|
||||||
color: @tertiary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_constant.ace_language {
|
|
||||||
color: @tertiary-color-light;
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_meta.ace_tag {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_keyword.ace_operator {
|
|
||||||
color: @tertiary-color-dark;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_storage, .ace_keyword {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_entity.ace_name.ace_function {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_string {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_invalid {
|
|
||||||
color: inherit;
|
|
||||||
background: inherit;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_strong {
|
|
||||||
color: @tertiary-color-dark;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_emphasis {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_blockquote {
|
|
||||||
color: @tertiary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_code {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
background-color: @code-bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_code_block {
|
|
||||||
color: @tertiary-color-darker;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_link {
|
|
||||||
color: @tertiary-color;
|
|
||||||
background-color: @code-bg;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_description {
|
|
||||||
color: @tertiary-color;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_constant {
|
|
||||||
color: @tertiary-color-dark;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_comment {
|
|
||||||
color: @tertiary-color-light;
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_doccomment {
|
|
||||||
color: fade(@state-danger-text, 90%);
|
|
||||||
font-style: italic;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_marker-layer .misspelled {
|
|
||||||
position: absolute;
|
|
||||||
z-index: -2;
|
|
||||||
border-bottom: 1px dotted red;
|
|
||||||
margin-bottom: -1px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.ace_search {
|
|
||||||
background-color: @secondary-bg-light;
|
|
||||||
border: 1px solid @secondary-border-color-light;
|
|
||||||
border-top: 0;
|
|
||||||
padding: 10px 15px 5px;
|
|
||||||
font-family: @font-family-base;
|
|
||||||
min-width: 318px;
|
|
||||||
.ace_search_form, .ace_replace_form {
|
|
||||||
border-color: @input-border;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.ace_search_field {
|
|
||||||
width: 185px;
|
|
||||||
}
|
|
||||||
.ace_search_field, .ace_searchbtn, .ace_replacebtn {
|
|
||||||
height: @input-height-small;
|
|
||||||
padding: 0 @padding-base-horizontal;
|
|
||||||
font-size: @font-size-base;
|
|
||||||
line-height: @line-height-base;
|
|
||||||
color: @input-color;
|
|
||||||
vertical-align: middle;
|
|
||||||
background-color: @secondary-bg-lighter;
|
|
||||||
border-color: @input-border;
|
|
||||||
.box-shadow(~"@{form-control-inset-shadow}");
|
|
||||||
}
|
|
||||||
.ace_searchbtn {
|
|
||||||
background-image: none;
|
|
||||||
font-family: "fontello";
|
|
||||||
width: auto;
|
|
||||||
font-size: 16px;
|
|
||||||
&.next:before {
|
|
||||||
content: '\e880';
|
|
||||||
}
|
|
||||||
&.prev:before {
|
|
||||||
content: '\e87f';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.ace_replacebtn {
|
|
||||||
padding: 0 4px;
|
|
||||||
}
|
|
||||||
.ace_searchbtn_close {
|
|
||||||
background: transparent;
|
|
||||||
margin: 0;
|
|
||||||
font-size: (@font-size-base * 1.5);
|
|
||||||
font-weight: @close-font-weight;
|
|
||||||
text-shadow: @close-text-shadow;
|
|
||||||
.opacity(.3);
|
|
||||||
&:before {
|
|
||||||
content: '\d7';
|
|
||||||
}
|
|
||||||
&:hover,
|
|
||||||
&:focus {
|
|
||||||
color: @close-color;
|
|
||||||
text-decoration: none;
|
|
||||||
cursor: pointer;
|
|
||||||
.opacity(.5);
|
|
||||||
background: transparent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: 'PT Sans';
|
font-family: 'PT Sans';
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
@ -1224,7 +1035,6 @@ a {
|
|||||||
src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url("../font/PTSans-BoldItalic-webfont.woff") format('woff');
|
src: local('PT Sans Bold Italic'), local('PTSans-BoldItalic'), url("../font/PTSans-BoldItalic-webfont.woff") format('woff');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#wmd-input {
|
#wmd-input {
|
||||||
font-family: @font-family-monospace;
|
font-family: @font-family-monospace;
|
||||||
letter-spacing: normal;
|
letter-spacing: normal;
|
||||||
|
Loading…
Reference in New Issue
Block a user