core/editor/utils/normalizerootsconfig
Functions
normalizeMultiRootEditorConstructorParams( sourceElementOrDataOrConfig, editorConfig ) → objectinternalmodule:core/editor/utils/normalizerootsconfig~normalizeMultiRootEditorConstructorParamsNormalizes the parameters passed to the editor constructor when a multi root is used. It supports both of the following signatures:
new Editor( editorConfig: EditorConfig ); new Editor( sourceElementsOrData: Record<string, string> | Record<string, HTMLElement>, editorConfig: EditorConfig );Copy codeParameters
sourceElementOrDataOrConfig : Record<string, string> | Record<string, HTMLElement>editorConfig : EditorConfig
Returns
object
normalizeRootsConfig( sourceElementsOrData, config, defaultRootName, separateAttachTo ) → voidinternalmodule:core/editor/utils/normalizerootsconfig~normalizeRootsConfigNormalizes the editor roots configuration. It ensures that all root configurations are defined in
config.rootsand that they haveinitialDatadefined.It normalizes a single-root configuration (where
config.rootis used) to a multi-root configuration (where all roots are defined inconfig.roots). This is considered a standard configuration format, so the editor features can always expect roots to be defined inconfig.roots.It also handles legacy configuration options, such as
config.initialData,config.placeholder, andconfig.label.Parameters
sourceElementsOrData : string | HTMLElement | Record<string, string> | Record<string, HTMLElement>config : Config<EditorConfig>defaultRootName : string | falseDefaults to
'main'separateAttachTo : booleanDefaults to
false
Returns
void
normalizeSingleRootEditorConstructorParams( sourceElementOrDataOrConfig, editorConfig ) → objectinternalmodule:core/editor/utils/normalizerootsconfig~normalizeSingleRootEditorConstructorParamsNormalizes the parameters passed to the editor constructor when a single root is used. It supports both of the following signatures:
new Editor( editorConfig: EditorConfig ); new Editor( sourceElementOrData: HTMLElement | string, editorConfig: EditorConfig );Copy codeParameters
sourceElementOrDataOrConfig : string | HTMLElement | EditorConfigeditorConfig : EditorConfig
Returns
object
normalizeViewRootElementDefinition( spec ) → HTMLElement | ViewRootElementDefinition | undefinedinternalmodule:core/editor/utils/normalizerootsconfig~normalizeViewRootElementDefinitionNormalizes the value passed in
config.root.elementinto a canonical form (HTMLElementorViewRootElementDefinition) that the UI layer can consume directly.Accepts:
- an existing
HTMLElement- returned as is, so the editor wraps it in place, - a tag name string (e.g.
'h1') - turned into{ name: 'h1' }, - a
ViewRootElementDefinitionobject - reshaped soclassesbecomes an array andattributes.classis lifted into it.
The
classattribute may be passed either as the dedicatedclassesfield (string or array of strings) or as aclasskey insideattributes. They are concatenated. Thestyleattribute may be passed either as thestylesobject or as astylestring insideattributes. When both are provided, the object form takes precedence and a warning is logged.The
<textarea>tag name is rejected as it cannot host a rich-text editable.Already used internally by
normalizeRootsConfig()forconfig.root.element/config.roots.*.element. Exported for callers that bypass the regular config-normalization pass, e.g.MultiRootEditor.addRoot()andMultiRootEditor.createEditable().Parameters
spec : string | HTMLElement | ViewRootElementDefinition | undefined
Returns
HTMLElement | ViewRootElementDefinition | undefined
- an existing