mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #321 from sharelatex/ace-syntax-validator-minimal-change
Ace syntax validator minimal change
This commit is contained in:
commit
bba6008e4d
6 changed files with 2254 additions and 12 deletions
|
@ -176,6 +176,8 @@ module.exports = (grunt) ->
|
||||||
name: "libs"
|
name: "libs"
|
||||||
},{
|
},{
|
||||||
name: "ace/mode-latex"
|
name: "ace/mode-latex"
|
||||||
|
},{
|
||||||
|
name: "ace/worker-latex"
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -130,10 +130,11 @@ block content
|
||||||
- var pdfPath = 'libs/pdfjs-1.3.91p1/pdf.worker.js'
|
- var pdfPath = 'libs/pdfjs-1.3.91p1/pdf.worker.js'
|
||||||
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
- var fingerprintedPath = fingerprint(jsPath+pdfPath)
|
||||||
- var pdfJsWorkerPath = buildJsPath(pdfPath, {cdn:false,qs:{fingerprint:fingerprintedPath}}) // don't use worker for cdn
|
- 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').
|
script(type='text/javascript').
|
||||||
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
window.pdfJsWorkerPath = "#{pdfJsWorkerPath}";
|
||||||
|
window.aceWorkerPath = "#{aceWorkerPath}";
|
||||||
|
|
||||||
script(
|
script(
|
||||||
data-main=buildJsPath("ide.js", {fingerprint:false}),
|
data-main=buildJsPath("ide.js", {fingerprint:false}),
|
||||||
|
|
|
@ -99,16 +99,17 @@ block content
|
||||||
|
|
||||||
| !{moduleIncludes("userSettings", locals)}
|
| !{moduleIncludes("userSettings", locals)}
|
||||||
|
|
||||||
|
hr
|
||||||
|
|
||||||
|
h3
|
||||||
|
| #{translate("sharelatex_beta_program")}
|
||||||
|
|
||||||
if (user.betaProgram)
|
if (user.betaProgram)
|
||||||
hr
|
|
||||||
|
|
||||||
h3
|
|
||||||
| #{translate("sharelatex_beta_program")}
|
|
||||||
|
|
||||||
p.small
|
p.small
|
||||||
| #{translate("beta_program_already_participating")}
|
| #{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
|
hr
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,13 @@ define [
|
||||||
"ide/editor/directives/aceEditor/cursor-position/CursorPositionManager"
|
"ide/editor/directives/aceEditor/cursor-position/CursorPositionManager"
|
||||||
], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager) ->
|
], (App, Ace, SearchBox, UndoManager, AutoCompleteManager, SpellCheckManager, HighlightsManager, CursorPositionManager) ->
|
||||||
EditSession = ace.require('ace/edit_session').EditSession
|
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
|
# Ace loads its script itself, so we need to hook in to be able to clear
|
||||||
# the cache.
|
# the cache.
|
||||||
if !ace.config._moduleUrl?
|
if !ace.config._moduleUrl?
|
||||||
|
@ -174,7 +180,6 @@ define [
|
||||||
editor.setValue(text, -1)
|
editor.setValue(text, -1)
|
||||||
session = editor.getSession()
|
session = editor.getSession()
|
||||||
session.setUseWrapMode(true)
|
session.setUseWrapMode(true)
|
||||||
session.setMode("ace/mode/latex")
|
|
||||||
|
|
||||||
scope.$watch "annotations", (annotations) ->
|
scope.$watch "annotations", (annotations) ->
|
||||||
session = editor.getSession()
|
session = editor.getSession()
|
||||||
|
@ -199,7 +204,10 @@ define [
|
||||||
|
|
||||||
attachToAce = (sharejs_doc) ->
|
attachToAce = (sharejs_doc) ->
|
||||||
lines = sharejs_doc.getSnapshot().split("\n")
|
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()
|
resetSession()
|
||||||
session = editor.getSession()
|
session = editor.getSession()
|
||||||
|
|
||||||
|
|
|
@ -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";
|
"use strict";
|
||||||
|
|
||||||
var oop = require("../lib/oop");
|
var oop = require("../lib/oop");
|
||||||
|
@ -203,10 +203,61 @@ var TextMode = require("./text").Mode;
|
||||||
var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules;
|
var LatexHighlightRules = require("./latex_highlight_rules").LatexHighlightRules;
|
||||||
var LatexFoldMode = require("./folding/latex").FoldMode;
|
var LatexFoldMode = require("./folding/latex").FoldMode;
|
||||||
var Range = require("../range").Range;
|
var Range = require("../range").Range;
|
||||||
|
var WorkerClient = require("ace/worker/worker_client").WorkerClient;
|
||||||
|
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.HighlightRules = LatexHighlightRules;
|
this.HighlightRules = LatexHighlightRules;
|
||||||
this.foldingRules = new LatexFoldMode();
|
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);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
|
|
2179
services/web/public/js/ace/worker-latex.js
Normal file
2179
services/web/public/js/ace/worker-latex.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue