ExportInlineStylesConfig
The configuration of the export inline styles feature. It is used by the @ckeditor/ckeditor5-export-inline-styles package.
ClassicEditor
.create( editorElement, {
exportInlineStyles: ... // Export inline styles feature options.
} )
.then( ... )
.catch( ... );Properties
inlineCss : string | undefinedmodule:export-inline-styles/exportinlinestyles~ExportInlineStylesConfig#inlineCssInternal CSS styles that will be processed after the external stylesheets. The styles should be provided as a regular CSS string.
const exportInlineStylesConfig = { inlineCss: ` .my-class { color: red; font-weight: bold; } .other-class { margin: 10px; padding: 5px; } ` }Copy codeNOTE: These styles are processed after the external stylesheets, so they can override styles from external files.
Defaults to
''stripCssClasses : boolean | undefinedmodule:export-inline-styles/exportinlinestyles~ExportInlineStylesConfig#stripCssClassesWhen enabled, CSS classes will be removed from DOM elements after the inline styles have been applied. This ensures that the exported content does not depend on external CSS classes while preserving the visual styling through inline styles.
const exportInlineStylesConfig = { stripCssClasses: true }Copy codeDefaults to
falsestylesheets : Array<string> | undefinedmodule:export-inline-styles/exportinlinestyles~ExportInlineStylesConfig#stylesheetsPaths to the
.cssfiles containing styling that should be converted to inline styles (the order of provided items matters).const exportInlineStylesConfig = { stylesheets: [ './path/to/custom-style.css' ] }Copy codeNOTE: If
stylesheetsare not provided, the plugin will process only the default editor content styles.Default editor's content styles: The default editor content styles are processed thanks to the
'EDITOR_STYLES'token, which is provided to thestylesheetsby default. If you don't want them to be processed, you have to omit the token:NOTE: The
'EDITOR_STYLES'string is only supported in legacy custom builds with webpack or DLLs. In other setups you always need to pass the stylesheets.const exportInlineStylesConfig = { stylesheets: [ './path/to/custom-editor-styles.css' ] }Copy codeMultiple stylesheets: You can provide multiple stylesheets that will be processed in order:
const exportInlineStylesConfig = { stylesheets: [ './path/to/base-styles.css', './path/to/theme-styles.css', './path/to/custom-styles.css' ] ] }Copy codeDefaults to
[ 'EDITOR_STYLES' ]transformations : Array<ExportInlineStylesTransformation> | undefinedmodule:export-inline-styles/exportinlinestyles~ExportInlineStylesConfig#transformationsA list of transformation callbacks applied to HTML elements before assigning inlined styles to them and processing the children. It allows you to modify the elements based on the applied styles.
Note that the wrapping element with class
ck-contentis transformed first. Setting inline styles on this element will cause those styles to be inherited by all its child elements.const exportInlineStylesConfig = { transformations: [ ( element, stylesMap ) => { if ( element.tagName.toLowerCase() === 'p' && stylesMap.get( 'text-align' ) === 'center' ) { element.setAttribute( 'data-aligned', 'center' ); stylesMap.remove( 'text-align' ); } // Example of setting a font on the root `ck-content` element. // This will cause all child elements to inherit the font and color. if ( element.classList.contains( 'ck-content' ) ) { stylesMap.set( 'font-family', 'Arial, sans-serif' ); stylesMap.set( 'color', '#333' ); } }, // ... ] }Copy codeDefaults to
[]