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 | */
|
5 | /**
|
6 | * @module media-embed/ui/mediaformview
|
7 | */
|
8 | import { type InputTextView, ButtonView, LabeledFieldView, View } from 'ckeditor5/src/ui';
|
9 | import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils';
|
10 | import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
11 | import '../../theme/mediaform.css';
|
12 | /**
|
13 | * The media form view controller class.
|
14 | *
|
15 | * See {@link module:media-embed/ui/mediaformview~MediaFormView}.
|
16 | */
|
17 | export default class MediaFormView extends View {
|
18 | /**
|
19 | * Tracks information about the DOM focus in the form.
|
20 | */
|
21 | readonly focusTracker: FocusTracker;
|
22 | /**
|
23 | * An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
24 | */
|
25 | readonly keystrokes: KeystrokeHandler;
|
26 | /**
|
27 | * The value of the URL input.
|
28 | */
|
29 | mediaURLInputValue: string;
|
30 | /**
|
31 | * The URL input view.
|
32 | */
|
33 | urlInputView: LabeledFieldView<InputTextView>;
|
34 | /**
|
35 | * The Save button view.
|
36 | */
|
37 | saveButtonView: ButtonView;
|
38 | /**
|
39 | * The Cancel button view.
|
40 | */
|
41 | cancelButtonView: ButtonView;
|
42 | /**
|
43 | * A collection of views that can be focused in the form.
|
44 | */
|
45 | private readonly _focusables;
|
46 | /**
|
47 | * Helps cycling over {@link #_focusables} in the form.
|
48 | */
|
49 | private readonly _focusCycler;
|
50 | /**
|
51 | * An array of form validators used by {@link #isValid}.
|
52 | */
|
53 | private readonly _validators;
|
54 | /**
|
55 | * The default info text for the {@link #urlInputView}.
|
56 | */
|
57 | private _urlInputViewInfoDefault?;
|
58 | /**
|
59 | * The info text with an additional tip for the {@link #urlInputView},
|
60 | * displayed when the input has some value.
|
61 | */
|
62 | private _urlInputViewInfoTip?;
|
63 | /**
|
64 | * @param validators Form validators used by {@link #isValid}.
|
65 | * @param locale The localization services instance.
|
66 | */
|
67 | constructor(validators: Array<(v: MediaFormView) => string | undefined>, locale: Locale);
|
68 | /**
|
69 | * @inheritDoc
|
70 | */
|
71 | render(): void;
|
72 | /**
|
73 | * @inheritDoc
|
74 | */
|
75 | destroy(): void;
|
76 | /**
|
77 | * Focuses the fist {in the form.
#_focusables} |
78 | */
|
79 | focus(): void;
|
80 | /**
|
81 | * The native DOM `value` of the {@link #urlInputView} element.
|
82 | *
|
83 | * **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
|
84 | * which works one way only and may not represent the actual state of the component in the DOM.
|
85 | */
|
86 | get url(): string;
|
87 | set url(url: string);
|
88 | /**
|
89 | * Validates the form and returns `false` when some fields are invalid.
|
90 | */
|
91 | isValid(): boolean;
|
92 | /**
|
93 | * Cleans up the supplementary error and information text of the {@link #urlInputView}
|
94 | * bringing them back to the state when the form has been displayed for the first time.
|
95 | *
|
96 | * See {@link #isValid}.
|
97 | */
|
98 | resetFormStatus(): void;
|
99 | /**
|
100 | * Creates a labeled input view.
|
101 | *
|
102 | * @returns Labeled input view instance.
|
103 | */
|
104 | private _createUrlInput;
|
105 | /**
|
106 | * Creates a button view.
|
107 | *
|
108 | * @param label The button label.
|
109 | * @param icon The button icon.
|
110 | * @param className The additional button CSS class name.
|
111 | * @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
112 | * @returns The button view instance.
|
113 | */
|
114 | private _createButton;
|
115 | }
|