3401const clips = lists['background-clip'];3402if (clips[clips.length - 1] === 'text') insertLayers(clips.length, ['none'], 'border-box');34033404const css = Object.keys(lists).reduce(3405(declarations, cssProp) => `${declarations}${cssProp}:${lists[cssProp].join(', ')} !important;`,3406''3407);3408// в Safari без clone градиент текста, перенесенного на несколько строк, рисуется одним куском на все строки3409const decorationBreak = textImages.length3410? '-webkit-box-decoration-break:clone !important;box-decoration-break:clone !important;'3411: '';
return css + decorationBreak;}/** * Слои цвета шага для вставки в список слоев фона, см. t_animationSBS__getColorLayersCss * * @param {sbsColorTarget} target * @param {{isBgColorHidden: boolean}} layersInfo - исходные слои фона узла, см. t_animationSBS__getBackgroundLayers * @returns {{bgImages: string[], textImages: string[]}} */function t_animationSBS__getStepLayerImages(target, layersInfo) { const paint = target.paint || {}; const solidLayerColor = `var(${window.t_animationSBS__BG_LAYER_PROP}, transparent)`; let bgImages = []; if (paint.bgColor) { bgImages = t_animationSBS__getPaintLayerImages(paint.bgColor); } else if (target.hasBgLayer && layersInfo.isBgColorHidden) { // сплошной слой нужен, только пока исходный фон закрывает background-color, см. t_animationSBS__getBgLayerInfo bgImages = [`linear-gradient(${solidLayerColor}, ${solidLayerColor})`]; } const textImages = paint.color ? t_animationSBS__getPaintLayerImages(paint.color) : []; return { bgImages, textImages };}/** * Исходные значения списочных свойств фона, развернутые до числа слоев: список короче списка слоев * повторяется по кругу, и без разворота значения сдвинулись бы относительно слоев после вставки слоев шага * * @param {CSSStyleDeclaration} computedStyles * @param {{images: string[], clips: string[]}} layersInfo - см. t_animationSBS__getBackgroundLayers * @param {string[]} cssProps * @returns {Object<string, string[]>} */function t_animationSBS__getBackgroundLists(computedStyles, layersInfo, cssProps) { const lists = {}; cssProps.forEach(cssProp => { if (cssProp === 'background-image') { lists[cssProp] = layersInfo.images.slice(); } else if (cssProp === 'background-clip' || cssProp === '-webkit-background-clip') { lists[cssProp] = layersInfo.clips.slice(); } else { const computedLayers = t_animationSBS__splitBackgroundLayers(computedStyles.getPropertyValue(cssProp)); if (!computedLayers.length) return; const count = layersInfo.images.length; lists[cssProp] = Array.from({ length: count }, (item, i) => computedLayers[i % computedLayers.length]); } }); return lists;}/** * Парсит цвет из колорпикера редактора (hex или rgba) или из вычисленных стилей * * @param {string | undefined} value * @returns {sbsRGBA | null} */function t_animationSBS__parseColor(value) { if (typeof value !== 'string') return null; const colorStr = value.trim().toLowerCase(); if (!colorStr) return null; if (colorStr === 'transparent') return [0, 0, 0, 0]; // цвет глобального стиля из пикера: var(--uc-color-color-<id>,<fallback>), берется fallback const globalColor = colorStr.match(/^var\(\s*--[\w-]+\s*,(.+)\)$/); if (globalColor) return t_animationSBS__parseColor(globalColor[1]); const hex = colorStr.match(/^#([0-9a-f]{3,8})$/); if (hex) { let digits = hex[1]; // короткая запись #rgb/#rgba разворачивается до #rrggbb/#rrggbbaa if (digits.length === 3 || digits.length === 4) digits = digits.replace(/./g, digit => digit + digit); if (digits.length !== 6 && digits.length !== 8) return null; const hexColor = [0, 2, 4, 6].map(pos => parseInt(digits.slice(pos, pos + 2), 16)); hexColor[3] = digits.length === 8 ? hexColor[3] / 255 : 1; return hexColor; } const rgb = colorStr.match(/^rgba?\(([^)]+)\)$/); if (!rgb) return null; // поддерживается и старый синтаксис rgba(r, g, b, a), и новый rgb(r g b / a), каналы могут быть в процентах const parts = rgb[1].split(/[\s,/]+/).filter(Boolean); if (parts.length < 3) return null; const rgbColor = parts.slice(0, 4).map((part, i) => { const number = parseFloat(part); if (!part.includes('%')) return number; return i === 3 ? number / 100 : (number * 255) / 100; }); if (rgbColor.length === 3) rgbColor.push(1); return rgbColor.every(number => !isNaN(number)) ? rgbColor : null;}