UNPKG

1.89 kBJavaScriptView Raw
1/**
2 * @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3 * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4 */
5import { View } from 'ckeditor5/src/ui';
6import '../../../theme/imageinsertformrowview.css';
7/**
8 * The class representing a single row in a complex form,
9 * used by {@link module:image/imageinsert/ui/imageinsertpanelview~ImageInsertPanelView}.
10 *
11 * **Note**: For now this class is private. When more use cases appear (beyond `ckeditor5-table` and `ckeditor5-image`),
12 * it will become a component in `ckeditor5-ui`.
13 *
14 * @private
15 */
16export default class ImageUploadFormRowView extends View {
17 /**
18 * Creates an instance of the form row class.
19 *
20 * @param locale The locale instance.
21 * @param options.labelView When passed, the row gets the `group` and `aria-labelledby`
22 * DOM attributes and gets described by the label.
23 */
24 constructor(locale, options = {}) {
25 super(locale);
26 const bind = this.bindTemplate;
27 this.set('class', options.class || null);
28 this.children = this.createCollection();
29 if (options.children) {
30 options.children.forEach(child => this.children.add(child));
31 }
32 this.set('_role', null);
33 this.set('_ariaLabelledBy', null);
34 if (options.labelView) {
35 this.set({
36 _role: 'group',
37 _ariaLabelledBy: options.labelView.id
38 });
39 }
40 this.setTemplate({
41 tag: 'div',
42 attributes: {
43 class: [
44 'ck',
45 'ck-form__row',
46 bind.to('class')
47 ],
48 role: bind.to('_role'),
49 'aria-labelledby': bind.to('_ariaLabelledBy')
50 },
51 children: this.children
52 });
53 }
54}