mirror of
https://github.com/overleaf/overleaf.git
synced 2025-03-15 03:55:53 +00:00
Allow track changes to be toggled on and off
This commit is contained in:
parent
60a81beb11
commit
2ac405e58c
3 changed files with 25 additions and 13 deletions
|
@ -101,7 +101,8 @@ define [
|
|||
|
||||
# If the insert is overlapping another insert, either at the beginning in the middle or touching the end,
|
||||
# then we merge them into one.
|
||||
if is_change_overlapping and
|
||||
if @track_changes and
|
||||
is_change_overlapping and
|
||||
!is_insert_blocked_by_delete and
|
||||
!already_merged and
|
||||
is_same_user
|
||||
|
@ -115,7 +116,7 @@ define [
|
|||
# If not merged above, then it must be blocked by a delete, and will be after this insert, so we shift it along as well
|
||||
change.op.p += op_length
|
||||
moved_changes.push change
|
||||
else if !is_same_user and change_start < op_start < change_end
|
||||
else if (!is_same_user or !@track_changes) and change_start < op_start < change_end
|
||||
# This user is inserting inside a change by another user, so we need to split the
|
||||
# other user's change into one before and after this one.
|
||||
offset = op_start - change_start
|
||||
|
@ -139,7 +140,7 @@ define [
|
|||
|
||||
previous_change = change
|
||||
|
||||
if !already_merged
|
||||
if @track_changes and !already_merged
|
||||
@_addOp op, metadata
|
||||
for {op, metadata} in new_changes
|
||||
@_addOp op, metadata
|
||||
|
@ -216,21 +217,27 @@ define [
|
|||
op_modifications.push modification
|
||||
else if change.op.d?
|
||||
change_start = change.op.p
|
||||
if op_end < change_start
|
||||
# Shift ops after us (but not touching) back by our length
|
||||
if op_end < change_start or (!@track_changes and op_end == change_start)
|
||||
# Shift ops after us back by our length.
|
||||
# If we're tracking changes, it must be strictly before, since we'll merge
|
||||
# below if they are touching. Otherwise, touching is fine.
|
||||
change.op.p -= op_length
|
||||
moved_changes.push change
|
||||
else if op_start <= change_start <= op_end
|
||||
# If we overlap a delete, add it in our content, and delete the existing change
|
||||
offset = change_start - op_start
|
||||
op_modifications.push { i: change.op.d, p: offset }
|
||||
remove_changes.push change
|
||||
if @track_changes
|
||||
# If we overlap a delete, add it in our content, and delete the existing change
|
||||
offset = change_start - op_start
|
||||
op_modifications.push { i: change.op.d, p: offset }
|
||||
remove_changes.push change
|
||||
else
|
||||
change.op.p = op_start
|
||||
moved_changes.push change
|
||||
|
||||
for change in remove_changes
|
||||
@_removeChange change
|
||||
|
||||
op.d = @_applyOpModifications(op.d, op_modifications)
|
||||
if op.d.length > 0
|
||||
if @track_changes and op.d.length > 0
|
||||
@_addOp op, metadata
|
||||
else
|
||||
# It's possible that we deleted an insert between two other inserts. I.e.
|
||||
|
@ -240,9 +247,10 @@ define [
|
|||
# |-- user_1 insert --||-- user_1 insert --|
|
||||
# We need to merge these together again
|
||||
results = @_scanAndMergeAdjacentUpdates()
|
||||
moved_changed = moved_changes.concat(results.moved_changes)
|
||||
moved_changes = moved_changes.concat(results.moved_changes)
|
||||
for change in results.remove_changes
|
||||
@_removeChange change
|
||||
moved_changes = moved_changes.filter (c) -> c != change
|
||||
|
||||
if moved_changes.length > 0
|
||||
@emit "changes:moved", moved_changes
|
||||
|
|
|
@ -9,19 +9,25 @@ define [
|
|||
|
||||
constructor: (@$scope, @editor, @element) ->
|
||||
@changesTracker = new ChangesTracker()
|
||||
@changesTracker.track_changes = true
|
||||
@changeIdToMarkerIdMap = {}
|
||||
@enabled = false
|
||||
window.changesTracker ?= @changesTracker
|
||||
|
||||
@changesTracker.on "insert:added", (change) =>
|
||||
sl_console.log "[insert:added]", change
|
||||
@_onInsertAdded(change)
|
||||
@changesTracker.on "insert:removed", (change) =>
|
||||
sl_console.log "[insert:removed]", change
|
||||
@_onInsertRemoved(change)
|
||||
@changesTracker.on "delete:added", (change) =>
|
||||
sl_console.log "[delete:added]", change
|
||||
@_onDeleteAdded(change)
|
||||
@changesTracker.on "delete:removed", (change) =>
|
||||
sl_console.log "[delete:removed]", change
|
||||
@_onDeleteRemoved(change)
|
||||
@changesTracker.on "changes:moved", (changes) =>
|
||||
sl_console.log "[changes:moved]", changes
|
||||
@_onChangesMoved(changes)
|
||||
|
||||
onChange = (e) =>
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
define [
|
||||
"base"
|
||||
], (App) ->
|
||||
console.log "Defingint", "reviePanelSorted"
|
||||
App.directive "reviewPanelSorted", () ->
|
||||
return {
|
||||
link: (scope, element, attrs) ->
|
||||
scope.$watch "reviewPanel.entries", (value) ->
|
||||
return if !value?
|
||||
console.log "reviewPanel.entries updates", entries
|
||||
entries = []
|
||||
for el in element.find(".review-entry")
|
||||
entries.push {
|
||||
|
|
Loading…
Reference in a new issue