@atlaskit/renderer
Version:
Renderer component
30 lines • 1.01 kB
JavaScript
import React from 'react';
import { useIntl } from 'react-intl';
import CodeBidiWarning from '@atlaskit/code/bidi-warning';
import { codeBidiWarningMessages } from '@atlaskit/editor-common/messages';
import codeBidiWarningDecorator from '@atlaskit/code/bidi-warning-decorator';
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
export const useBidiWarnings = ({
enableWarningTooltip = true
}) => {
const intl = useIntl();
const warningLabel = intl.formatMessage(codeBidiWarningMessages.label);
const renderBidiWarnings = text => {
if (expValEquals('platform_editor_remove_bidi_char_warning', 'isEnabled', true)) {
return text;
}
return codeBidiWarningDecorator(text, ({
bidiCharacter,
index
}) => /*#__PURE__*/React.createElement(CodeBidiWarning, {
bidiCharacter: bidiCharacter,
key: index,
label: warningLabel,
tooltipEnabled: enableWarningTooltip
}));
};
return {
renderBidiWarnings,
warningLabel
};
};