registerContentQualityAnnotationType

Type: Function

How to get registerContentQualityAnnotationType?

JavaScript

import registerContentQualityAnnotationType from 'fontoxml-content-quality/src/registerContentQualityAnnotationType.js'

Overview

Add configuration for an annotation type. Can also be used to override an already existing configuration.

Out-of-the-box configurations

The product offers the following configurations out-of-the-box. They can be overridden by calling the registerContentQualityAnnotationType again with the same namespaceURI and localName.

The product configurations all use the same createContextualOperations function. Note that this function depends on data returned by the corresponding product annotators.

JavaScript

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

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

The CardContentComponents that are used are not copy/pasteable. Follow the configuration guide to create your own.

SpellCheckAnnotator configuration

Use SpellCheckAnnotator

JavaScript

registerContentQualityAnnotationType({
    namespaceURI: 'urn:fontoxml:content-quality:spelling:1.0.0',
    localName: 'spelling-error',
    heading: t('Spelling'),
    color: 'red',
    icon: 'fas fa-spell-check',
    CardContentComponent: REACT_COMPONENT_HERE,
    decoration: 'wavy-underline',
    createContextualOperations: ({ annotationId, metadata }) =>
        getContextMenuOperations(annotationId, metadata)
});

LanguageTool Grammar configuration

Use LanguageToolAnnotator

JavaScript

registerContentQualityAnnotationType({
    namespaceURI: 'urn:fontoxml:content-quality:language-tool:1.0.0',
    localName: 'grammar-error',
    heading: t('Grammar'),
    color: 'green',
    icon: 'fas fa-font',
    CardContentComponent: REACT_COMPONENT_HERE,
    decoration: 'wavy-underline',
    createContextualOperations: ({ annotationId, metadata }) =>
        getContextMenuOperations(annotationId, metadata)
});

LanguageTool Spelling configuration

Use LanguageToolAnnotator

JavaScript

registerContentQualityAnnotationType({
    namespaceURI: 'urn:fontoxml:content-quality:language-tool:1.0.0',
    localName: 'spelling-error',
    heading: t('Spelling'),
    color: 'red',
    icon: 'fas fa-spell-check',
    CardContentComponent: REACT_COMPONENT_HERE,
    decoration: 'wavy-underline',
    createContextualOperations: ({ annotationId, metadata }) =>
        getContextMenuOperations(annotationId, metadata)
});

Arguments