(events, newGroup, instantiateSel)
| 8064 | // Used both to provide a JSON-safe object in .getHistory, and, when |
| 8065 | // detaching a document, to split the history in two |
| 8066 | function copyHistoryArray(events, newGroup, instantiateSel) { |
| 8067 | for (var i = 0, copy = []; i < events.length; ++i) { |
| 8068 | var event = events[i]; |
| 8069 | if (event.ranges) { |
| 8070 | copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event); |
| 8071 | continue; |
| 8072 | } |
| 8073 | var changes = event.changes, newChanges = []; |
| 8074 | copy.push({changes: newChanges}); |
| 8075 | for (var j = 0; j < changes.length; ++j) { |
| 8076 | var change = changes[j], m; |
| 8077 | newChanges.push({from: change.from, to: change.to, text: change.text}); |
| 8078 | if (newGroup) for (var prop in change) if (m = prop.match(/^spans_(\d+)$/)) { |
| 8079 | if (indexOf(newGroup, Number(m[1])) > -1) { |
| 8080 | lst(newChanges)[prop] = change[prop]; |
| 8081 | delete change[prop]; |
| 8082 | } |
| 8083 | } |
| 8084 | } |
| 8085 | } |
| 8086 | return copy; |
| 8087 | } |
| 8088 | |
| 8089 | // Rebasing/resetting history to deal with externally-sourced changes |
| 8090 |
no test coverage detected