mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'master' of https://github.com/sharelatex/web-sharelatex
This commit is contained in:
commit
46374f39ff
5 changed files with 49 additions and 12 deletions
|
@ -129,11 +129,11 @@ module.exports = CompileController =
|
||||||
return next(new Error("invalid h parameter"))
|
return next(new Error("invalid h parameter"))
|
||||||
if not v?.match(/^\d+\.\d+$/)
|
if not v?.match(/^\d+\.\d+$/)
|
||||||
return next(new Error("invalid v parameter"))
|
return next(new Error("invalid v parameter"))
|
||||||
url = CompileController._getUrl(project_id, user_id, "sync/pdf")
|
|
||||||
destination = {url: url, qs: {page, h, v}}
|
|
||||||
# whether this request is going to a per-user container
|
# whether this request is going to a per-user container
|
||||||
CompileController._compileAsUser req, (error, user_id) ->
|
CompileController._compileAsUser req, (error, user_id) ->
|
||||||
return next(error) if error?
|
return next(error) if error?
|
||||||
|
url = CompileController._getUrl(project_id, user_id, "sync/pdf")
|
||||||
|
destination = {url: url, qs: {page, h, v}}
|
||||||
CompileController.proxyToClsi(project_id, destination, req, res, next)
|
CompileController.proxyToClsi(project_id, destination, req, res, next)
|
||||||
|
|
||||||
proxySyncCode: (req, res, next = (error) ->) ->
|
proxySyncCode: (req, res, next = (error) ->) ->
|
||||||
|
@ -145,10 +145,10 @@ module.exports = CompileController =
|
||||||
return next(new Error("invalid line parameter"))
|
return next(new Error("invalid line parameter"))
|
||||||
if not column?.match(/^\d+$/)
|
if not column?.match(/^\d+$/)
|
||||||
return next(new Error("invalid column parameter"))
|
return next(new Error("invalid column parameter"))
|
||||||
url = CompileController._getUrl(project_id, user_id, "sync/code")
|
|
||||||
destination = {url:url, qs: {file, line, column}}
|
|
||||||
CompileController._compileAsUser req, (error, user_id) ->
|
CompileController._compileAsUser req, (error, user_id) ->
|
||||||
return next(error) if error?
|
return next(error) if error?
|
||||||
|
url = CompileController._getUrl(project_id, user_id, "sync/code")
|
||||||
|
destination = {url:url, qs: {file, line, column}}
|
||||||
CompileController.proxyToClsi(project_id, destination, req, res, next)
|
CompileController.proxyToClsi(project_id, destination, req, res, next)
|
||||||
|
|
||||||
proxyToClsi: (project_id, url, req, res, next = (error) ->) ->
|
proxyToClsi: (project_id, url, req, res, next = (error) ->) ->
|
||||||
|
|
|
@ -125,7 +125,8 @@ define [
|
||||||
file.name = "#{file.path.replace(/^output\./, "")} file"
|
file.name = "#{file.path.replace(/^output\./, "")} file"
|
||||||
else
|
else
|
||||||
file.name = file.path
|
file.name = file.path
|
||||||
file.url = "/project/#{project_id}/output/#{file.path}"
|
if not file.url?
|
||||||
|
file.url = "/project/#{project_id}/output/#{file.path}"
|
||||||
if response.clsiServerId?
|
if response.clsiServerId?
|
||||||
file.url = file.url + "?clsiserverid=#{response.clsiServerId}"
|
file.url = file.url + "?clsiserverid=#{response.clsiServerId}"
|
||||||
$scope.pdf.outputFiles.push file
|
$scope.pdf.outputFiles.push file
|
||||||
|
@ -301,6 +302,9 @@ define [
|
||||||
$scope.startedFreeTrial = true
|
$scope.startedFreeTrial = true
|
||||||
|
|
||||||
App.factory "synctex", ["ide", "$http", "$q", (ide, $http, $q) ->
|
App.factory "synctex", ["ide", "$http", "$q", (ide, $http, $q) ->
|
||||||
|
# enable per-user containers if querystring includes isolated=true
|
||||||
|
perUserCompile = window.location?.search?.match(/isolated=true/)? or undefined
|
||||||
|
|
||||||
synctex =
|
synctex =
|
||||||
syncToPdf: (cursorPosition) ->
|
syncToPdf: (cursorPosition) ->
|
||||||
deferred = $q.defer()
|
deferred = $q.defer()
|
||||||
|
@ -350,18 +354,35 @@ define [
|
||||||
deferred.reject()
|
deferred.reject()
|
||||||
return deferred.promise
|
return deferred.promise
|
||||||
|
|
||||||
|
# FIXME: this actually works better if it's halfway across the
|
||||||
|
# page (or the visible part of the page). Synctex doesn't
|
||||||
|
# always find the right place in the file when the point is at
|
||||||
|
# the edge of the page, it sometimes returns the start of the
|
||||||
|
# next paragraph instead.
|
||||||
|
h = position.offset.left
|
||||||
|
|
||||||
|
# Compute the vertical position to pass to synctex, which
|
||||||
|
# works with coordinates increasing from the top of the page
|
||||||
|
# down. This matches the browser's DOM coordinate of the
|
||||||
|
# click point, but the pdf position is measured from the
|
||||||
|
# bottom of the page so we need to invert it.
|
||||||
|
if options.fromPdfPosition and position.pageSize?.height?
|
||||||
|
v = (position.pageSize.height - position.offset.top) or 0 # measure from pdf point (inverted)
|
||||||
|
else
|
||||||
|
v = position.offset.top or 0 # measure from html click position
|
||||||
|
|
||||||
# It's not clear exactly where we should sync to if it wasn't directly
|
# It's not clear exactly where we should sync to if it wasn't directly
|
||||||
# clicked on, but a little bit down from the very top seems best.
|
# clicked on, but a little bit down from the very top seems best.
|
||||||
if options.includeVisualOffset
|
if options.includeVisualOffset
|
||||||
position.offset.top = position.offset.top + 80
|
v += 72 # use the same value as in pdfViewer highlighting visual offset
|
||||||
|
|
||||||
$http({
|
$http({
|
||||||
url: "/project/#{ide.project_id}/sync/pdf",
|
url: "/project/#{ide.project_id}/sync/pdf",
|
||||||
method: "GET",
|
method: "GET",
|
||||||
params: {
|
params: {
|
||||||
page: position.page + 1
|
page: position.page + 1
|
||||||
h: position.offset.left.toFixed(2)
|
h: h.toFixed(2)
|
||||||
v: position.offset.top.toFixed(2)
|
v: v.toFixed(2)
|
||||||
clsiserverid:ide.clsiServerId
|
clsiserverid:ide.clsiServerId
|
||||||
isolated: perUserCompile
|
isolated: perUserCompile
|
||||||
}
|
}
|
||||||
|
@ -392,7 +413,7 @@ define [
|
||||||
|
|
||||||
$scope.syncToCode = () ->
|
$scope.syncToCode = () ->
|
||||||
synctex
|
synctex
|
||||||
.syncToCode($scope.pdf.position, includeVisualOffset: true)
|
.syncToCode($scope.pdf.position, includeVisualOffset: true, fromPdfPosition: true)
|
||||||
.then (data) ->
|
.then (data) ->
|
||||||
{doc, line} = data
|
{doc, line} = data
|
||||||
ide.editorManager.openDoc(doc, gotoLine: line)
|
ide.editorManager.openDoc(doc, gotoLine: line)
|
||||||
|
|
|
@ -50,7 +50,11 @@ define [
|
||||||
scope.scale = { scaleMode: 'scale_mode_fit_width' }
|
scope.scale = { scaleMode: 'scale_mode_fit_width' }
|
||||||
|
|
||||||
if (position = localStorage("pdf.position.#{attrs.key}"))
|
if (position = localStorage("pdf.position.#{attrs.key}"))
|
||||||
scope.position = { page: +position.page, offset: { "top": +position.offset.top, "left": +position.offset.left } }
|
scope.position =
|
||||||
|
page: +position.page,
|
||||||
|
offset:
|
||||||
|
"top": +position.offset.top
|
||||||
|
"left": +position.offset.left
|
||||||
|
|
||||||
#scope.position = pdfListView.getPdfPosition(true)
|
#scope.position = pdfListView.getPdfPosition(true)
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,8 @@ define [
|
||||||
# console.log 'converted to offset = ', pdfOffset
|
# console.log 'converted to offset = ', pdfOffset
|
||||||
newPosition = {
|
newPosition = {
|
||||||
"page": topPageIdx,
|
"page": topPageIdx,
|
||||||
"offset" : { "top" : pdfOffset[1], "left": 0 }
|
"offset" : { "top" : pdfOffset[1], "left": 0}
|
||||||
|
"pageSize": { "height": viewport.viewBox[3], "width": viewport.viewBox[2] }
|
||||||
}
|
}
|
||||||
return newPosition
|
return newPosition
|
||||||
|
|
||||||
|
@ -208,6 +209,8 @@ define [
|
||||||
return $scope.document.getPdfViewport(page.pageNum).then (viewport) ->
|
return $scope.document.getPdfViewport(page.pageNum).then (viewport) ->
|
||||||
page.viewport = viewport
|
page.viewport = viewport
|
||||||
pageOffset = viewport.convertToViewportPoint(offset.left, offset.top)
|
pageOffset = viewport.convertToViewportPoint(offset.left, offset.top)
|
||||||
|
# if the passed-in position doesn't have the page height/width add them now
|
||||||
|
position.pageSize ?= {"height": viewport.viewBox[3], "width": viewport.viewBox[2]}
|
||||||
# console.log 'addition offset =', pageOffset
|
# console.log 'addition offset =', pageOffset
|
||||||
# console.log 'total', pageTop + pageOffset[1]
|
# console.log 'total', pageTop + pageOffset[1]
|
||||||
Math.round(pageTop + pageOffset[1] + currentScroll) ## 10 is margin
|
Math.round(pageTop + pageOffset[1] + currentScroll) ## 10 is margin
|
||||||
|
@ -513,8 +516,17 @@ define [
|
||||||
|
|
||||||
first = highlights[0]
|
first = highlights[0]
|
||||||
|
|
||||||
pageNum = scope.pages[first.page].pageNum
|
# switching between split and full pdf views can cause
|
||||||
|
# highlights to appear before rendering
|
||||||
|
if !scope.pages
|
||||||
|
return # ignore highlight scroll if still rendering
|
||||||
|
|
||||||
|
pageNum = scope.pages[first.page]?.pageNum
|
||||||
|
|
||||||
|
if !pageNum?
|
||||||
|
return # ignore highlight scroll if page not found
|
||||||
|
|
||||||
|
# use a visual offset of 72pt to match the offset in PdfController syncToCode
|
||||||
scope.document.getPdfViewport(pageNum).then (viewport) ->
|
scope.document.getPdfViewport(pageNum).then (viewport) ->
|
||||||
position = {
|
position = {
|
||||||
page: first.page
|
page: first.page
|
||||||
|
|
BIN
services/web/public/img/about/paulo_reis.jpg
Normal file
BIN
services/web/public/img/about/paulo_reis.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 8.2 KiB |
Loading…
Reference in a new issue