(events, newGroup, instantiateSel)
| 8032 | // Used both to provide a JSON-safe object in .getHistory, and, when |
| 8033 | // detaching a document, to split the history in two |
| 8034 | function copyHistoryArray(events, newGroup, instantiateSel) { |
| 8035 | for (var i = 0, copy = []; i < events.length; ++i) { |
| 8036 | var event = events[i]; |
| 8037 | if (event.ranges) { |
| 8038 | copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); |
| 8039 | continue; |
| 8040 | } |
| 8041 | var changes = event.changes, newChanges = []; |
| 8042 | copy.push({changes: newChanges}); |
| 8043 | for (var j = 0; j < changes.length; ++j) { |
| 8044 | var change = changes[j], m; |
| 8045 | newChanges.push({from: change.from, to: change.to, text: change.text}); |
| 8046 | if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { |
| 8047 | if (indexOf(newGroup, Number(m[1])) > -1) { |
| 8048 | lst(newChanges)[prop] = change[prop]; |
| 8049 | delete change[prop]; |
| 8050 | } |
| 8051 | } |
| 8052 | } |
| 8053 | } |
| 8054 | return copy; |
| 8055 | } |
| 8056 | |
| 8057 | // Rebasing/resetting history to deal with externally-sourced changes |
| 8058 |
no test coverage detected