* commitAppend * This is like `commit`, but instead of adding `staging` after stable, * it replaces `stable` with `staging` and does not advance the history. * (It's somewhat like what `git commit --append` does.) * - Set annotation, sources, and other edit metadata properties * -
(options = {})
| 455 | * @throws Will throw if you try to append to the `base` edit |
| 456 | */ |
| 457 | commitAppend(options = {}) { |
| 458 | d3_select(document).interrupt('editTransition'); // complete any transition already in progress |
| 459 | |
| 460 | const context = this.context; |
| 461 | const staging = this.staging; |
| 462 | |
| 463 | if (this._index === 0) { |
| 464 | throw new Error(`Can not commitAppend to the base edit!`); |
| 465 | } |
| 466 | |
| 467 | const annotation = options.annotation ?? ''; |
| 468 | staging.annotation = annotation; |
| 469 | staging.selectedIDs = options.selectedIDs ?? []; |
| 470 | staging.sources = this._gatherSources(annotation); |
| 471 | staging.transform = context.viewport.transform.props; |
| 472 | |
| 473 | // Discard forward/redo history if any, and replace `stable` with `staging`. |
| 474 | this._history.splice(this._index, Infinity, staging); |
| 475 | // (At this point `stable` === `staging`) |
| 476 | |
| 477 | this._replaceStaging(); |
| 478 | this._updateChanges(); |
| 479 | } |
| 480 | |
| 481 | |
| 482 | /** |