豆豆友情提示:这是一个非官方 GitHub 代理镜像,主要用于网络测试或访问加速。请勿在此进行登录、注册或处理任何敏感信息。进行这些操作请务必访问官方网站 github.com。 Raw 内容也通过此代理提供。
Skip to content

Add root/roots editor config option #19885

@niegowski

Description

@niegowski

To implement decisions from the RFC we need to:

  • Add root and roots editor config options to the EditorConfig interface.
    • The root key would be just an alias for roots.main and internally normalize it to such a structure for easier access later.
  • Prepare config normalization helper for root-related options (probably in the core package). Or should it be implemented in the Editor base class constructor?
    • It should check which options are set in the editor config (root.initialData, initialData, placeholder, root.placehoder, roots.XYZ.initialData, etc) and set the roots.XYZ structure (in the editor config) with root-related options (initialData, placeholder, label), the default root name is main. It should also take the sourceElementOrData editor constructor parameter in case the initialData is provided there, but it should (as currently) be used as the latest option. Note that it is a record (root name keyed) in the multi-root editor.
    • The lazyRoots, and rootsAttributes options should not use a legacy fallback. Those would be renamed in the new structure to lazyLoad and modelElement.attributes.
      • The old lazyRoots and rootsAttributes configuration keys should be removed.
      • The new modelElement.attributes key would replace the old rootsAttributes.
      • The new lazyLoad flag in the new per-root configuration should be marked as deprecated.
    • The old initialData, placeholder configuration keys should be marked as deprecated.
  • The above helper should be used in all editor constructors, and later root-related options should be retrieved from normalized config keys, for example, config.get( 'root.main.placeholder' ), config.get( 'root.main.initialData' ).
  • All editor.config.get() calls to altered config options should be modified to the normalized path (for example roots.XYZ.placeholder)

Example normalized config:

{
  roots: {
    main: {
      initialData: '...',	// Previously config.initialData or config.initialData.main in multi-root
      placeholder: '...',	// Previously config.placeholder or config.placeholder.main in multi-root
      label: '...', 		// Previously config.label or config.label.main in multi-root
      modelElement: {
        attributes: {} 		// Previously config.rootsAttributes.main
      },
      lazyLoad: false 		// Previously config.lazyRoots array
    }
  }
}
  • The multi-root addRoot() and createEditable() methods should get new declarations (the old ones should be marked as deprecated). New variants of those methods should accept structures similar to the above normalized config (only keys that are related to the specific method).
    • Note that addRoot() accepts elementName - the model root element name; this should be changed to modelElement.

Metadata

Metadata

Assignees

Labels

squad:coreIssue to be handled by the Core team.type:taskThis issue reports a chore (non-production change) and other types of "todos".

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions