@ckeditor/ckeditor5-editor-multi-root 43.0.0 → 43.1.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -219,9 +219,10 @@ export default class MultiRootEditor extends Editor {
219
219
  * @param root Root for which the editable element should be created.
220
220
  * @param placeholder Placeholder for the editable element. If not set, placeholder value from the
221
221
  * {@link module:core/editor/editorconfig~EditorConfig#placeholder editor configuration} will be used (if it was provided).
222
+ * @param label The accessible label text describing the editable to the assistive technologies.
222
223
  * @returns The created DOM element. Append it in a desired place in your application.
223
224
  */
224
- createEditable(root: RootElement, placeholder?: string): HTMLElement;
225
+ createEditable(root: RootElement, placeholder?: string, label?: string): HTMLElement;
225
226
  /**
226
227
  * Detaches the DOM editable element that was attached to the given root.
227
228
  *
@@ -53,10 +53,13 @@ export default class MultiRootEditorUIView extends EditorUIView {
53
53
  * @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
54
54
  * in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
55
55
  * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
56
+ * @param options.label When set, this value will be used as an accessible `aria-label` of the
57
+ * {@link module:ui/editableui/editableuiview~EditableUIView editable view} elements.
56
58
  */
57
59
  constructor(locale: Locale, editingView: EditingView, editableNames: Array<string>, options?: {
58
60
  editableElements?: Record<string, HTMLElement>;
59
61
  shouldToolbarGroupWhenFull?: boolean;
62
+ label?: string | Record<string, string>;
60
63
  });
61
64
  /**
62
65
  * Creates an editable instance with given name and registers it in the editor UI view.
@@ -66,9 +69,10 @@ export default class MultiRootEditorUIView extends EditorUIView {
66
69
  *
67
70
  * @param editableName The name for the editable.
68
71
  * @param editableElement DOM element for which the editable should be created.
72
+ * @param label The accessible editable label used by assistive technologies.
69
73
  * @returns The created editable instance.
70
74
  */
71
- createEditable(editableName: string, editableElement?: HTMLElement): InlineEditableUIView;
75
+ createEditable(editableName: string, editableElement?: HTMLElement, label?: string): InlineEditableUIView;
72
76
  /**
73
77
  * Destroys and removes the editable from the editor UI view.
74
78
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ckeditor/ckeditor5-editor-multi-root",
3
- "version": "43.0.0",
3
+ "version": "43.1.0-alpha.1",
4
4
  "description": "Multi-root editor implementation for CKEditor 5.",
5
5
  "keywords": [
6
6
  "ckeditor",
@@ -12,11 +12,11 @@
12
12
  "type": "module",
13
13
  "main": "src/index.js",
14
14
  "dependencies": {
15
- "@ckeditor/ckeditor5-core": "43.0.0",
16
- "@ckeditor/ckeditor5-engine": "43.0.0",
17
- "@ckeditor/ckeditor5-ui": "43.0.0",
18
- "@ckeditor/ckeditor5-utils": "43.0.0",
19
- "ckeditor5": "43.0.0",
15
+ "@ckeditor/ckeditor5-core": "43.1.0-alpha.1",
16
+ "@ckeditor/ckeditor5-engine": "43.1.0-alpha.1",
17
+ "@ckeditor/ckeditor5-ui": "43.1.0-alpha.1",
18
+ "@ckeditor/ckeditor5-utils": "43.1.0-alpha.1",
19
+ "ckeditor5": "43.1.0-alpha.1",
20
20
  "lodash-es": "4.17.21"
21
21
  },
22
22
  "author": "CKSource (http://cksource.com/)",
@@ -215,9 +215,10 @@ export default class MultiRootEditor extends Editor {
215
215
  * @param root Root for which the editable element should be created.
216
216
  * @param placeholder Placeholder for the editable element. If not set, placeholder value from the
217
217
  * {@link module:core/editor/editorconfig~EditorConfig#placeholder editor configuration} will be used (if it was provided).
218
+ * @param label The accessible label text describing the editable to the assistive technologies.
218
219
  * @returns The created DOM element. Append it in a desired place in your application.
219
220
  */
220
- createEditable(root: RootElement, placeholder?: string): HTMLElement;
221
+ createEditable(root: RootElement, placeholder?: string, label?: string): HTMLElement;
221
222
  /**
222
223
  * Detaches the DOM editable element that was attached to the given root.
223
224
  *
@@ -135,7 +135,8 @@ export default class MultiRootEditor extends Editor {
135
135
  }
136
136
  const options = {
137
137
  shouldToolbarGroupWhenFull: !this.config.get('toolbar.shouldNotGroupWhenFull'),
138
- editableElements: sourceIsData ? undefined : sourceElementsOrData
138
+ editableElements: sourceIsData ? undefined : sourceElementsOrData,
139
+ label: this.config.get('label')
139
140
  };
140
141
  const view = new MultiRootEditorUIView(this.locale, this.editing.view, rootNames, options);
141
142
  this.ui = new MultiRootEditorUI(this, view);
@@ -403,10 +404,11 @@ export default class MultiRootEditor extends Editor {
403
404
  * @param root Root for which the editable element should be created.
404
405
  * @param placeholder Placeholder for the editable element. If not set, placeholder value from the
405
406
  * {@link module:core/editor/editorconfig~EditorConfig#placeholder editor configuration} will be used (if it was provided).
407
+ * @param label The accessible label text describing the editable to the assistive technologies.
406
408
  * @returns The created DOM element. Append it in a desired place in your application.
407
409
  */
408
- createEditable(root, placeholder) {
409
- const editable = this.ui.view.createEditable(root.rootName);
410
+ createEditable(root, placeholder, label) {
411
+ const editable = this.ui.view.createEditable(root.rootName, undefined, label);
410
412
  this.ui.addEditable(editable, placeholder);
411
413
  this.editing.view.forceRender();
412
414
  return editable.element;
@@ -49,10 +49,13 @@ export default class MultiRootEditorUIView extends EditorUIView {
49
49
  * @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
50
50
  * in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
51
51
  * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
52
+ * @param options.label When set, this value will be used as an accessible `aria-label` of the
53
+ * {@link module:ui/editableui/editableuiview~EditableUIView editable view} elements.
52
54
  */
53
55
  constructor(locale: Locale, editingView: EditingView, editableNames: Array<string>, options?: {
54
56
  editableElements?: Record<string, HTMLElement>;
55
57
  shouldToolbarGroupWhenFull?: boolean;
58
+ label?: string | Record<string, string>;
56
59
  });
57
60
  /**
58
61
  * Creates an editable instance with given name and registers it in the editor UI view.
@@ -62,9 +65,10 @@ export default class MultiRootEditorUIView extends EditorUIView {
62
65
  *
63
66
  * @param editableName The name for the editable.
64
67
  * @param editableElement DOM element for which the editable should be created.
68
+ * @param label The accessible editable label used by assistive technologies.
65
69
  * @returns The created editable instance.
66
70
  */
67
- createEditable(editableName: string, editableElement?: HTMLElement): InlineEditableUIView;
71
+ createEditable(editableName: string, editableElement?: HTMLElement, label?: string): InlineEditableUIView;
68
72
  /**
69
73
  * Destroys and removes the editable from the editor UI view.
70
74
  *
@@ -30,6 +30,8 @@ export default class MultiRootEditorUIView extends EditorUIView {
30
30
  * @param options.shouldToolbarGroupWhenFull When set to `true` enables automatic items grouping
31
31
  * in the main {@link module:editor-multi-root/multirooteditoruiview~MultiRootEditorUIView#toolbar toolbar}.
32
32
  * See {@link module:ui/toolbar/toolbarview~ToolbarOptions#shouldGroupWhenFull} to learn more.
33
+ * @param options.label When set, this value will be used as an accessible `aria-label` of the
34
+ * {@link module:ui/editableui/editableuiview~EditableUIView editable view} elements.
33
35
  */
34
36
  constructor(locale, editingView, editableNames, options = {}) {
35
37
  super(locale);
@@ -42,7 +44,11 @@ export default class MultiRootEditorUIView extends EditorUIView {
42
44
  // Create `InlineEditableUIView` instance for each editable.
43
45
  for (const editableName of editableNames) {
44
46
  const editableElement = options.editableElements ? options.editableElements[editableName] : undefined;
45
- this.createEditable(editableName, editableElement);
47
+ let { label } = options;
48
+ if (typeof label === 'object') {
49
+ label = label[editableName];
50
+ }
51
+ this.createEditable(editableName, editableElement, label);
46
52
  }
47
53
  this.editable = Object.values(this.editables)[0];
48
54
  // This toolbar may be placed anywhere in the page so things like font size need to be reset in it.
@@ -76,14 +82,12 @@ export default class MultiRootEditorUIView extends EditorUIView {
76
82
  *
77
83
  * @param editableName The name for the editable.
78
84
  * @param editableElement DOM element for which the editable should be created.
85
+ * @param label The accessible editable label used by assistive technologies.
79
86
  * @returns The created editable instance.
80
87
  */
81
- createEditable(editableName, editableElement) {
82
- const t = this.locale.t;
88
+ createEditable(editableName, editableElement, label) {
83
89
  const editable = new InlineEditableUIView(this.locale, this._editingView, editableElement, {
84
- label: editable => {
85
- return t('Rich Text Editor. Editing area: %0', editable.name);
86
- }
90
+ label
87
91
  });
88
92
  this.editables[editableName] = editable;
89
93
  editable.name = editableName;