overrideRangeToBlueprintRange

Type: Function

Convert an OverrideRange from command/custom mutation arguments to a BlueprintSelection.

Note: for historical reasons this is named overrideRangeToBlueprintRange, even though the return type is a BlueprintSelection. A BlueprintSelection can be used wherever a BlueprintRange is expected.

This can be used in a custom mutation to create a BlueprintSelection for performing the mutations on, instead of the selectionRange. Be sure to also update argument.overrideRange at the end of the custom mutation using blueprintRangeToOverrideRange.

Example usage

JavaScript

var range = selectionRange;
if (argument.overrideRange) {
	range = overrideRangeToBlueprintRange(argument.overrideRange, blueprint);
}

Custom mutation example

JavaScript

function myCustomMutation (argument, blueprint, format, selectionRange) {
	var range = selectionRange;
	if (argument.overrideRange) {
		range = overrideRangeToBlueprintRange(argument.overrideRange, blueprint);
	}

	var success = performDomMutationsHere();

	optionallyCorrectRangeAfterMutations(range);

	if (success && argument.overrideRange) {
		argument.overrideRange = blueprintRangeToOverrideRange(range).
	}

	return success ? CustomMutationResult.ok() : CustomMutationResult.notAllowed();
}

Refer to baseFlowUtils for more information on how to import and use this function.

Arguments

  1. overrideRange

    (Required)

    A override range object to containing nodeIds and offsets

  2. blueprint

    (Required)

    Type: Blueprint

    The blueprint in which to consider the range

Returns

The blueprint selection based on the OverrideRange