diff --git a/src/text-transform/utils.ts b/src/text-transform/utils.ts index 1925a1ef6..e75e872b6 100644 --- a/src/text-transform/utils.ts +++ b/src/text-transform/utils.ts @@ -4,6 +4,8 @@ import Typograf from 'typograf'; import {Lang} from '../utils/configure'; +import AddRuleOptions = typograf.AddRuleOptions; + export enum TransformType { Text = 'text', Html = 'html', @@ -40,37 +42,11 @@ export const sanitizeStripOptions: sanitize.IOptions = { allowedAttributes: {}, }; -Typograf.addRule({ - name: 'common/html/sup', - queue: 'end', - /* TODO mange with it: in typograf types AddRuleOptions.handler takes only one param: text. - But in cloud-www was used this notation with 3 params */ - //@ts-ignore - handler: function (text, settings, context) { - const {prefs: {htmlEntity: {type = ''} = {}} = {}} = context; - - let symbols; - switch (type) { - case 'digit': - symbols = '®|©|™'; - break; - case 'name': - symbols = '®|©|™'; - break; - default: - symbols = '®|©|™'; - break; - } - - const symbolsRegex = new RegExp( - `(?\\s*)(${symbols})|(${symbols})(?!\\s*<\\/sup>)`, - 'gi', - ); - - return text.replace(symbolsRegex, '$1'); - }, - htmlAttrs: false, -}); +export function addTypografRules(options: AddRuleOptions[]) { + options.forEach((option) => { + Typograf.addRule(option); + }); +} function enableRules(tp: typograf.Typograf) { const {disabled, enabled} = typografConfig;