blueprintRangeToOverrideRange

Type: Function

Convert a BlueprintRange from a command/mutation to a OverrideRange for the arguments.

This can be used in a command/custom mutation to make a OverrideRange object for passing along in the argument to the next step in an operation. Make sure to do this at the very end, after any and all mutations have been done. To convert a overrideRange to a BlueprintRange see overrideRangeToBlueprintRange.

This function accepts a Range, BlueprintRange or BlueprintSelection. Ranges and BlueprintRanges are considered to always be forwards oriented. An empty BlueprintRange or BlueprintSelection is not supported and yields undefined results.

Example usage

JavaScript

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

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. blueprintRangeOrSelection

    A Range, BlueprintRange or BlueprintSelection from which to create a OverrideRange

Returns

The OverrideRange based on the given range or selection