MCPcopy Create free account
hub / github.com/facebook/Rapid / commitAppend

Method commitAppend

modules/core/EditSystem.js:457–479  ·  view source on GitHub ↗

* 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 = {})

Source from the content-addressed store, hash-verified

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 /**

Callers 6

_changeTagsFunction · 0.80
_revertTagsFunction · 0.80
operationFunction · 0.80
_keydownMethod · 0.80
fnFunction · 0.80
EditSystem.test.jsFile · 0.80

Calls 3

_gatherSourcesMethod · 0.95
_replaceStagingMethod · 0.95
_updateChangesMethod · 0.95

Tested by 1

fnFunction · 0.64