The UtilsController exposes a set of useful utilities that can be used to make some repeated tasks a bit easier Methods inside this controller can be called by window.SDK.utils.{method-name}

Methods

  • This method can round a value to a certain precision, default is 2

    Parameters

    • val: number

      the value that needs to be rounded

    • Optionalprecision: number

      the precision of the rounding operation

    Returns EditorResponse<number>

    the rounded value as a number

  • This method can help you stage a file to the CHILI GraFx Environment API for upload.

    Parameters

    • files: File[] | Blob[]

      The Files or Blobs to stage.

    • remoteConnectorId: string

      The connector ID from Environment API to stage the files for.

    • OptionalvalidationConfiguration: UploadValidationConfiguration

      The validation configuration to use for the files.

    Returns Promise<FilePointer[]>

    Promise<FilePointer[]> referencing the staged data.

  • Evaluates a unit expression and returns its value as a number in the specified conversionUnit, or in the current layout measurement unit if conversionUnit is not provided.

    Returns null if unitExpression is null, empty, or cannot be evaluated.

    Example:

    const value = await SDK.utils.unitEvaluate('10cm', MeasurementUnit.px);
    // value is the numeric value in px

    Parameters

    • unitExpression: null | string

      The unit expression to evaluate (e.g., "10px", "5mm + 2cm", null)

    • OptionalconversionUnit: MeasurementUnit

      Optional target unit for conversion. If not provided, uses the current layout measurement unit.

    Returns Promise<EditorResponse<null | number>>

    The evaluated result as a number, or null if the expression cannot be evaluated