(events, newGroup, instantiateSel)
| 6749 | // Used both to provide a JSON-safe object in .getHistory, and, when |
| 6750 | // detaching a document, to split the history in two |
| 6751 | function copyHistoryArray(events, newGroup, instantiateSel) { |
| 6752 | for (var i = 0, copy = []; i < events.length; ++i) { |
| 6753 | var event = events[i]; |
| 6754 | if (event.ranges) { |
| 6755 | copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); |
| 6756 | continue; |
| 6757 | } |
| 6758 | var changes = event.changes, newChanges = []; |
| 6759 | copy.push({changes: newChanges}); |
| 6760 | for (var j = 0; j < changes.length; ++j) { |
| 6761 | var change = changes[j], m; |
| 6762 | newChanges.push({from: change.from, to: change.to, text: change.text}); |
| 6763 | if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { |
| 6764 | if (indexOf(newGroup, Number(m[1])) > -1) { |
| 6765 | lst(newChanges)[prop] = change[prop]; |
| 6766 | delete change[prop]; |
| 6767 | } |
| 6768 | } |
| 6769 | } |
| 6770 | } |
| 6771 | return copy; |
| 6772 | } |
| 6773 | |
| 6774 | // Rebasing/resetting history to deal with externally-sourced changes |
| 6775 |
no test coverage detected
searching dependent graphs…