-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Adding aggregated roots config. #19937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 20 commits
bb269f7
68561aa
50d9a1a
c938e54
7e5a6f9
6b2965b
ea2be4f
2835050
3124bcd
0b0781a
0369567
d0229cc
d9a53ed
9e6d966
eb4cb4d
07cad2b
0f57ed9
b5faac5
1b2c96d
8296538
46b13f9
d031651
bf993b8
631c6f4
616087f
5610b03
a05fb7e
ef1dcdf
fadcb04
4439ee3
402d913
3b1880a
02b7720
a65ae75
3ed3b7f
8528fc3
b7357d8
d5d4aa3
978692a
4777f9b
8190f4c
b891e6d
5a7983e
b4f0204
237720d
c0d210d
a985826
7fd5d42
ea7d252
f82c56f
f198439
cf2fb29
c8fa891
4c49bca
048442f
4effe13
49c9427
b686937
1cc1c3a
68bbfb2
338e10f
9260a95
56768c3
d696cf7
b618883
eb38b5b
3849c94
2509278
3f5fee1
0ee70a4
d72e58d
1010096
ee09a8b
07b8053
adda4e4
ee8bc9d
18ac0bc
1d6c694
fba83db
b51b3ce
0526aef
7c2cd08
522de92
8447ef7
09dafa3
72f8994
7ba9c8e
d179646
a85d24f
e47ac69
0f066bf
e50d77b
aa135f7
23eda2f
237d3d4
c629429
e945b5c
764d29a
f302a91
bda5e06
34f0085
98306b2
3df9229
4835dd8
ad79d22
14cb397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,12 @@ export interface EditorConfig extends EngineConfig { | |
| * If `config.initialData` is not set when the editor is initialized, the data received in `Editor.create()` call | ||
| * will be used to set `config.initialData`. As a result, `initialData` is always set in the editor's config and | ||
| * plugins can read and/or modify it during initialization. | ||
| * | ||
| * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use | ||
| * {@link module:core/editor/editorconfig~EditorConfig#root `root.initialData`} or | ||
| * {@link module:core/editor/editorconfig~EditorConfig#roots `roots.<rootName>.initialData`} instead.** | ||
| * | ||
| * @deprecated | ||
| */ | ||
| initialData?: string | Record<string, string>; | ||
|
|
||
|
|
@@ -537,6 +543,12 @@ export interface EditorConfig extends EngineConfig { | |
| * element passed to the `create()` method. | ||
| * | ||
| * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples. | ||
| * | ||
| * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use | ||
| * {@link module:core/editor/editorconfig~EditorConfig#root `root.placeholder`} or | ||
| * {@link module:core/editor/editorconfig~EditorConfig#roots `roots.<rootName>.placeholder`} instead.** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When to use the latter? It sounds like we're giving the user an option, while we don't. |
||
| * | ||
| * @deprecated | ||
| */ | ||
| placeholder?: string | Record<string, string>; | ||
|
|
||
|
|
@@ -864,8 +876,243 @@ export interface EditorConfig extends EngineConfig { | |
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| * | ||
| * **This property has been deprecated and will be removed in the future versions of CKEditor. Please use | ||
| * {@link module:core/editor/editorconfig~EditorConfig#root `root.label`} or | ||
| * {@link module:core/editor/editorconfig~EditorConfig#roots `roots.<rootName>.label`} instead.** | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When to use the latter? It sounds like we're giving the user an option, while we don't. |
||
| * | ||
| * @deprecated | ||
| */ | ||
| label?: string | Record<string, string>; | ||
|
|
||
| /** | ||
| * The root configuration options for the default `main` root. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't a sufficient documentation in this place. When you visit the API docs and land on https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editorconfig.html#interface-EditorConfig you will only see these two paragraphs. But this is by far one of the most important configuration options. Thus, it must contain proper examples of a simple (typical) use and fuller case. |
||
| * | ||
| * This option is an alias for `config.roots.main`. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What happens if both are configured? Maybe add something like "...and will be ignored if
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I see you throw error. Document that. |
||
| */ | ||
| root?: RootConfig; | ||
|
|
||
| /** | ||
| * The root configuration options grouped by the root name. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Be more thorough. In the case of which editor type does this option make sense? Which option to use when using a typical editor (link to |
||
| * | ||
| * ```ts | ||
| * ClassicEditor | ||
| * .create( document.querySelector( '#editor' ), { | ||
| * roots: { | ||
| * main: { | ||
| * initialData: '<p>Hello world!</p>', | ||
| * placeholder: 'Type some text...', | ||
| * label: 'Main content' | ||
| * } | ||
| * } | ||
| * } ); | ||
| * ``` | ||
| */ | ||
| roots?: Record<string, RootConfig>; | ||
| } | ||
|
|
||
| /** | ||
| * Configuration for a single editor root. It is used in {@link module:core/editor/editorconfig~EditorConfig#root `EditorConfig#root`} and | ||
niegowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * {@link module:core/editor/editorconfig~EditorConfig#roots `EditorConfig#roots.<rootName>`}. | ||
| * | ||
| * **Note**: If your editor implementation uses only a single root, you can use `config.root` to set the root configuration instead of | ||
| * `config.roots.main`. | ||
| */ | ||
| export interface RootConfig { | ||
|
|
||
| /** | ||
| * The initial editor data to be used instead of the provided element's HTML content. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What element? It's explained later, but let's limit the cognitive load at this point. |
||
| * | ||
| * ```ts | ||
| * ClassicEditor | ||
| * .create( document.querySelector( '#editor' ), { | ||
| * root: { | ||
| * initialData: '<h2>Initial data</h2><p>Foo bar.</p>' | ||
| * } | ||
| * } ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| * | ||
| * By default, the editor is initialized with the content of the element on which this editor is initialized. | ||
| * This configuration option lets you override this behavior and pass different initial data. | ||
| * It is especially useful if it is difficult for your integration to put the data inside the HTML element. | ||
| * | ||
| * If your editor implementation uses multiple roots, you should provide config for roots individually: | ||
| * | ||
| * ```ts | ||
| * MultiRootEditor.create( | ||
| * // Roots for the editor: | ||
| * { | ||
| * header: document.querySelector( '#header' ), | ||
| * content: document.querySelector( '#content' ), | ||
| * leftSide: document.querySelector( '#left-side' ), | ||
| * rightSide: document.querySelector( '#right-side' ) | ||
| * }, | ||
| * // Config: | ||
| * { | ||
| * roots: { | ||
| * header: { | ||
| * initialData: '<p>Content for header part.</p>' | ||
| * }, | ||
| * content: { | ||
| * initialData: '<p>Content for main part.</p>' | ||
| * }, | ||
| * leftSide: { | ||
| * initialData: '<p>Content for left-side box.</p>' | ||
| * }, | ||
| * rightSide: { | ||
| * initialData: '<p>Content for right-side box.</p>' | ||
| * } | ||
| * } | ||
| * } | ||
| * ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
niegowski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| * See also {@link module:core/editor/editor~Editor.create Editor.create()} documentation for the editor implementation which you use. | ||
| * | ||
| * **Note:** If initial data is passed to `Editor.create()` in the first parameter (instead of a DOM element), and, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it necessary to mention this? |
||
| * at the same time, `config.initialData` is set, an error will be thrown as those two options exclude themselves. | ||
niegowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * If `config.root.initialData` is not set when the editor is initialized, the data received in `Editor.create()` call | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I understand that you mean the data from the first parameter? It is not clear. |
||
| * will be used to set `config.roots.main.initialData`. As a result, `initialData` is always set in the editor's config and | ||
| * plugins can read and/or modify it during initialization. TODO breaking change - the updated initialData changes location | ||
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
cursor[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| initialData?: string; | ||
|
|
||
| /** | ||
| * Specifies the text displayed in the editor when there is no content (editor is empty). It is intended to | ||
| * help users locate the editor in the application (form) and prompt them to input the content. Work similarly | ||
niegowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * as to the native DOM | ||
niegowski marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * [`placeholder` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#The_placeholder_attribute) | ||
| * used by inputs. | ||
| * | ||
| * ```ts | ||
| * ClassicEditor | ||
| * .create( document.querySelector( '#editor' ), { | ||
| * root: { | ||
| * placeholder: 'Type some text...' | ||
| * } | ||
| * } ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| * | ||
| * If your editor implementation uses multiple roots, you should provide config for roots individually: | ||
| * | ||
| * ```ts | ||
| * MultiRootEditor.create( | ||
| * // Roots for the editor: | ||
| * { | ||
| * header: document.querySelector( '#header' ), | ||
| * content: document.querySelector( '#content' ), | ||
| * leftSide: document.querySelector( '#left-side' ), | ||
| * rightSide: document.querySelector( '#right-side' ) | ||
| * }, | ||
| * // Config: | ||
| * { | ||
| * roots: { | ||
| * header: { | ||
| * placeholder: 'Type header...' | ||
| * }, | ||
| * content: { | ||
| * placeholder: 'Type content...' | ||
| * }, | ||
| * leftSide: { | ||
| * placeholder: 'Type left-side...' | ||
| * }, | ||
| * rightSide: { | ||
| * placeholder: 'Type right-side...' | ||
| * } | ||
| * } | ||
| * } | ||
| * ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| * | ||
| * The placeholder text is displayed as a pseudo–element of an empty paragraph in the editor content. | ||
| * The paragraph has the `.ck-placeholder` CSS class and the `data-placeholder` attribute. | ||
| * | ||
| * ```html | ||
| * <p data-placeholder="Type some text..." class="ck-placeholder"> | ||
| * ::before | ||
| * </p> | ||
| * ``` | ||
| * | ||
| * **Note**: Placeholder text can also be set using the `placeholder` attribute if a `<textarea>` is passed to | ||
| * the `create()` method, e.g. {@link module:editor-classic/classiceditor~ClassicEditor.create `ClassicEditor.create()`}. | ||
| * | ||
| * **Note**: This configuration has precedence over the value of the `placeholder` attribute of a `<textarea>` | ||
| * element passed to the `create()` method. | ||
| * | ||
| * See the {@glink features/editor-placeholder "Editor placeholder"} guide for more information and live examples. | ||
| */ | ||
| placeholder?: string; | ||
|
|
||
| /** | ||
| * Label text for the `aria-label` attribute set on editor editing area. Used by assistive technologies | ||
| * to tell apart multiple editor instances (editing areas) on the page. If not set, a default | ||
| * "Rich Text Editor. Editing area [name of the area]" is used instead. | ||
|
Comment on lines
+1098
to
+1100
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In AI we are looking forward to use this Hence, I propose to change description for this property. It should be more general, like, "Label which briefly describes this editing area. It is used to for It can be also used by other features when referring to this area." You can consult with @oleq this API doc. |
||
| * | ||
| * ```ts | ||
| * ClassicEditor | ||
| * .create( document.querySelector( '#editor' ), { | ||
| * root: { | ||
| * label: 'My editor' | ||
| * } | ||
| * } ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| * | ||
| * If your editor implementation uses multiple roots, you should provide config for roots individually: | ||
| * | ||
| * ```ts | ||
| * MultiRootEditor.create( | ||
| * // Roots for the editor: | ||
| * { | ||
| * header: document.querySelector( '#header' ), | ||
| * content: document.querySelector( '#content' ), | ||
| * leftSide: document.querySelector( '#left-side' ), | ||
| * rightSide: document.querySelector( '#right-side' ) | ||
| * }, | ||
| * // Config: | ||
| * { | ||
| * roots: { | ||
| * header: { | ||
| * label: 'Header label' | ||
| * }, | ||
| * content: { | ||
| * label: 'Content label' | ||
| * }, | ||
| * leftSide: { | ||
| * label: 'Left side label' | ||
| * }, | ||
| * rightSide: { | ||
| * label: 'Right side label' | ||
| * } | ||
|
||
| * } | ||
| * } | ||
| * ) | ||
| * .then( ... ) | ||
| * .catch( ... ); | ||
| * ``` | ||
| */ | ||
| label?: string; | ||
| } | ||
|
|
||
| /** | ||
| * Configuration of a root element of the editor. It is used in {@link module:core/editor/editorconfig~EditorConfig#root `config.root`} and | ||
| * {@link module:core/editor/editorconfig~EditorConfig#roots `config.roots.<rootName>`} to specify details of the model root element. | ||
| */ | ||
| export interface RootModelElementConfig { | ||
|
|
||
| /** | ||
| * TODO This will be used later to specify the name of the model element which will be used as a root. For now, it is always `'$root'`. | ||
| */ | ||
| name?: string; | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -875,6 +1122,12 @@ export interface EditorConfig extends EngineConfig { | |
| * @error editor-create-initial-data | ||
| */ | ||
|
|
||
| /** | ||
| * The `config.initialData` option cannot be used together with the `config.root.initialData` or `config.roots.main.initialData`. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More context needed. Which option to use?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, you can make these links to the API docs. |
||
| * | ||
| * @error editor-create-roots-initial-data | ||
| */ | ||
|
|
||
| /** | ||
| * The configuration of the editor language. | ||
| * | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When to use the latter? It sounds like we're giving the user an option, while we don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS. I know that
rootis an alias forroots.mainbut please do not overcomplicate it for people. Therootsoption should in practice be used only by the users of the multiroot editor.