* commit * This finalizes the `staging` work-in-progress edit. * (It's somewhat like what `git commit` does.) * - Set annotation, sources, and other edit metadata properties * - Add the `staging` edit to the end of the history (at this point `staging` becomes `stable`) * - Finally,
(options = {})
| 401 | * @param {Array} options.selectedIDs - Array of selectedIDs |
| 402 | */ |
| 403 | commit(options = {}) { |
| 404 | d3_select(document).interrupt('editTransition'); // complete any transition already in progress |
| 405 | |
| 406 | const context = this.context; |
| 407 | const staging = this.staging; |
| 408 | |
| 409 | const annotation = options.annotation ?? ''; |
| 410 | staging.annotation = annotation; |
| 411 | staging.selectedIDs = options.selectedIDs ?? []; |
| 412 | staging.sources = this._gatherSources(annotation); |
| 413 | staging.transform = context.viewport.transform.props; |
| 414 | |
| 415 | // Discard forward/redo history if any, and add `staging` after `stable` |
| 416 | this._history.splice(this._index + 1, Infinity, staging); |
| 417 | this._index++; |
| 418 | // (At this point `stable` === `staging`) |
| 419 | |
| 420 | this._replaceStaging(); |
| 421 | this._updateChanges(); |
| 422 | } |
| 423 | |
| 424 | |
| 425 | /** |