/** * @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options */ /** * @module paste-from-office-enhanced/normalizers/inliner/utils */ import { type ViewElement } from '@ckeditor/ckeditor5-engine'; type StyleSelector = string; type CSSStyleDefinitions = Record; type ExtractedStyles = Record; type ExpandedStyles = Map; type ParsedCSSSelector = { tagName?: StyleSelector; className?: StyleSelector; }; /** * Returns style definitions that match given element. * * @param element * @param expandedStyles * @returns */ export declare function getMatchingStyles(element: ViewElement, expandedStyles: ExpandedStyles): ExpandedStyles; /** * Converts CSSStyleSheets into a simple object format: * * ```js * { * 'p, p.foo': { * 'font-family': 'Arial' * }, * 'td': { * 'background': 'red' * }, * // ... * } * ``` * @param styles * @returns */ export declare function extractStyles(styles: Array): ExtractedStyles; /** * Expands styles object with complex selector into a map of unique parsed selectors and style definitions. * * ```ts * const styles = { * 'p, p.foo': { * 'font-family': 'Arial' * }, * 'td': { * 'background': 'red' * }, * // ... * } * * expandStyles( styles ); * * { * { tagName: 'p' }: { * 'font-family': 'Arial' * }, * { tagName: 'p', className: 'foo }: { * 'font-family': 'Arial' * }, * { tagName: 'td' }: { * 'background': 'red' * }, * // ... * } * ``` * @param styles * @returns */ export declare function expandStyles(styles: ExtractedStyles): ExpandedStyles; /** * Converts a native CSSStyleDeclaration into a simple object. * * ```ts * { * 'font-family': 'Arial' * 'background': 'red', * // ... * } * ``` * @param declaration * @returns */ export declare function parseCSSStyleDeclaration(declaration: CSSStyleDeclaration): CSSStyleDefinitions; /** * Parses CSS selector into an array of objects with tagName and className properties. * * ```ts * parseCSSSelector( 'p, p.foo' ); * ``` * * returns: * * ```ts * [ * { tagName: 'p' }, * { tagName: 'p', className: 'foo' } * ] * ``` * @param selector * @returns */ export declare function parseCSSSelector(selector: string): Array; /** * Extracts `mso-pattern` background colors from raw CSS text (`stylesString`). * * Browsers silently discard `mso-*` vendor properties during CSS parsing, so the browser-parsed * `CSSStyleSheet` objects never contain `mso-pattern` values. This function parses the raw CSS text * to extract pattern colors from class-scoped rules. * * Returns a mapping of class names to their pattern colors (e.g., `{ xl65: '#4EA72E' }`). * * Conditions for synthesizing a background-color: * - `mso-pattern: auto` (no pattern set) — skipped (single value doesn't match the regex). * - `mso-pattern: none` — skipped (pattern explicitly off). * - `mso-pattern: auto` — skipped (no pattern). * - `mso-pattern: auto none` — skipped (color is `auto`). * - `mso-pattern: ` where pattern type is not `none`/`auto` — extracted. * * @param stylesString Raw CSS text from `data._parsedData.stylesString`. * @returns A record mapping class names to their `mso-pattern` color values. */ export declare function extractMsoPatternBackgroundColors(stylesString: string): Record; /** * Flattens multiple style definitions considering their order to simulate a CSS cascade. * * ```ts * flattenStyleDefinitions( [ * { 'font-family': 'Arial', 'margin-top': '1px', 'font-size': '10px' }, * { 'font-family': 'monospace', 'margin-top': '3px' } * ] ); * ``` * * returns: * * ```ts * { 'font-family': 'monospace', 'margin-top': '3px', 'font-size': '10px' } * ``` * @param definitions * @returns */ export declare function flattenStyleDefinitions(definitions: Array): CSSStyleDefinitions; export {};