createContextualOperationsCallback

Type: Function

A callback function that returns contextual operations.

This function should return the ContextualOperations for this annotation.

Note that the Content Quality product already renders the heading and the 'Show more details' button on the root level. Do not render a menuGroupHeading on the root level of your configuration, or make sure it does not conflict with the product generated heading.

Example usage

JavaScript

(annotationId, metadata) => {
    if (!annotationId || !metadata || !metadata.replacements) {
        return [];
    }

    return metadata.replacements
        .map(replacement => {
            return {
                operationData: {
                    annotationId,
                    text: replacement
                },
                name: 'my-custom-operation',
                label: replacement,
                icon: 'fas fa-font'
            };
        })
        .slice(0, 6);
};

Arguments

  1. annotationId

    The annotation identifier.

  2. metadata

    (Required)

    Type: Object

    The annotation metadata.

Returns

The contextual operations for this annotation.