Skip to main content

Import CSS

Plugin alias: importcss

editor42.init({
plugins: 'importcss'
});

Scans CSS stylesheets loaded in the editor content area and automatically converts their CSS selectors into editor format/style definitions. These are surfaced in the Formats/Styles dropdown, allowing users to apply CSS classes without manual format configuration.

Options

OptionTypeDefaultDescription
importcss_merge_classesbooleantrueMerge CSS classes onto existing elements.
importcss_exclusivebooleantrueEach selector appears only once.
importcss_selector_converterfunctionCustom converter from CSS selector to format definition.
importcss_selector_filterstring/RegExp/functionInclude/exclude selectors.
importcss_file_filterstring/RegExp/functionInclude/exclude stylesheets by URL.
importcss_groupsobject[]Organize imported styles into named groups.
importcss_appendbooleanfalseAppend to existing formats instead of replacing.

Events

EventDescription
addStyleModificationsDispatched with { items, replace } after processing.

API

MethodDescription
convertSelectorToFormat(selectorText)Converts a CSS selector to a format object.