Merge branch 'master' into sk-passport

This commit is contained in:
Shane Kilkelly 2016-09-26 09:43:19 +01:00
commit fb6f6c13c9
6 changed files with 2254 additions and 12 deletions

View file

@ -176,6 +176,8 @@ module.exports = (grunt) ->
name: "libs"
},{
name: "ace/mode-latex"
},{
name: "ace/worker-latex"
}
]

View file

@ -130,10 +130,11 @@ block content
- var pdfPath = 'libs/pdfjs-1.3.91p1/pdf.worker.js'
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
- var pdfJsWorkerPath = buildJsPath(pdfPath, {cdn:false,qs:{fingerprint:fingerprintedPath}}) // don't use worker for cdn
- var aceWorkerPath = user.betaProgram ? buildJsPath("ace", {cdn:false,fingerprint:false}) : "" // don't use worker for cdn
script(type='text/javascript').
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
window.aceWorkerPath = "#{aceWorkerPath}";
script(
data-main=buildJsPath("ide.js", {fingerprint:false}),

View file

@ -99,16 +99,17 @@ block content
| !{moduleIncludes("userSettings", locals)}
hr
h3
| #{translate("sharelatex_beta_program")}
if (user.betaProgram)
hr
h3
| #{translate("sharelatex_beta_program")}
p.small
| #{translate("beta_program_already_participating")}
div
a(id="beta-program-participate-link" href="/beta/participate") #{translate("manage_beta_program_membership")}
div
a(id="beta-program-participate-link" href="/beta/participate") #{translate("manage_beta_program_membership")}
hr

View file

@ -9,7 +9,13 @@ define [
"ide/editor/directives/aceEditor/cursor-position/CursorPositionManager"
], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager) ->
EditSession = ace.require('ace/edit_session').EditSession
# set the path for ace workers if using a CDN (from editor.jade)
if window.aceWorkerPath != ""
ace.config.set('workerPath', "#{window.aceWorkerPath}")
else
ace.config.setDefaultValue("session", "useWorker", false)
# Ace loads its script itself, so we need to hook in to be able to clear
# the cache.
if !ace.config._moduleUrl?
@ -174,7 +180,6 @@ define [
editor.setValue(text, -1)
session = editor.getSession()
session.setUseWrapMode(true)
session.setMode("ace/mode/latex")
scope.$watch "annotations", (annotations) ->
session = editor.getSession()
@ -199,7 +204,10 @@ define [
attachToAce = (sharejs_doc) ->
lines = sharejs_doc.getSnapshot().split("\n")
editor.setSession(new EditSession(lines))
session = editor.getSession()
if session?
session.destroy()
editor.setSession(new EditSession(lines, "ace/mode/latex"))
resetSession()
session = editor.getSession()

View file

@ -195,7 +195,7 @@ oop.inherits(FoldMode, BaseFoldMode);
});
ace.define("ace/mode/latex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/latex_highlight_rules","ace/mode/folding/latex","ace/range"], function(require, exports, module) {
ace.define("ace/mode/latex",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/latex_highlight_rules","ace/mode/folding/latex","ace/range","ace/worker/worker_client"], function(require, exports, module) {
"use strict";
var oop = require("../lib/oop");
@ -203,10 +203,61 @@ var TextMode = require("./text").Mode;
var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules;
var LatexFoldMode = require("./folding/latex").FoldMode;
var Range = require("../range").Range;
var WorkerClient = require("ace/worker/worker_client").WorkerClient;
var Mode = function() {
this.HighlightRules = LatexHighlightRules;
this.foldingRules = new LatexFoldMode();
this.createWorker = function(session) {
var worker = new WorkerClient(["ace"], "ace/mode/latex_worker", "LatexWorker");
var savedRange = {};
worker.attachToDocument(session.getDocument());
worker.on("lint", function(results) {
var newRange = {};
for (var i = 0; i<results.data.length; i++) {
var start_row = results.data[i].start_row;
var end_row = results.data[i].end_row;
var key = start_row + ":" + end_row;
newRange[key] = results.data[i];
}
var newKeys = Object.keys(newRange);
var oldKeys = Object.keys(savedRange);
for (i = 0; i < newKeys.length; i++) {
key = newKeys[i];
if (!savedRange[key]) {
var new_range = newRange[key];
var range = new Range(new_range.start_row, 0, new_range.end_row, Infinity);
range.id = session.addMarker(range, "ace_error-marker", "fullLine");
savedRange[key] = range;
}
}
for (i = 0; i < oldKeys.length; i++) {
key = oldKeys[i];
if (!newRange[key]) {
range = savedRange[key];
session.removeMarker(range.id);
delete savedRange[key];
}
}
});
worker.on("terminate", function() {
var oldKeys = Object.keys(savedRange);
for (var i = 0; i < oldKeys.length; i++) {
var key = oldKeys[i];
var range = savedRange[key];
session.removeMarker(range.id);
delete savedRange[key];
}
});
return worker;
};
};
oop.inherits(Mode, TextMode);

File diff suppressed because it is too large Load diff