@ckeditor/ckeditor5-media-embed 41.2.0 → 41.3.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.
- package/dist/content-index.css +10 -0
- package/dist/editor-index.css +38 -0
- package/dist/index.css +108 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1167 -0
- package/dist/index.js.map +1 -0
- package/dist/types/augmentation.d.ts +25 -0
- package/dist/types/automediaembed.d.ts +51 -0
- package/dist/types/converters.d.ts +38 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/mediaembed.d.ts +34 -0
- package/dist/types/mediaembedcommand.d.ts +36 -0
- package/dist/types/mediaembedconfig.d.ts +278 -0
- package/dist/types/mediaembedediting.d.ts +31 -0
- package/dist/types/mediaembedtoolbar.d.ts +30 -0
- package/dist/types/mediaembedui.d.ts +27 -0
- package/dist/types/mediaregistry.d.ts +66 -0
- package/dist/types/ui/mediaformview.d.ts +115 -0
- package/dist/types/utils.d.ts +67 -0
- package/package.json +4 -3
@@ -0,0 +1,115 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, 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.js';
|
9
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
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 {@link #_focusables} in the form.
|
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
|
+
}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
/**
|
2
|
+
* @license Copyright (c) 2003-2024, 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/utils
|
7
|
+
*/
|
8
|
+
import type { ViewContainerElement, Element, Model, Selectable, Selection, DowncastWriter, ViewDocumentSelection, ViewElement, DocumentSelection } from 'ckeditor5/src/engine.js';
|
9
|
+
import type MediaRegistry from './mediaregistry.js';
|
10
|
+
/**
|
11
|
+
* Converts a given {@link module:engine/view/element~Element} to a media embed widget:
|
12
|
+
* * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the media widget element.
|
13
|
+
* * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
|
14
|
+
*
|
15
|
+
* @param writer An instance of the view writer.
|
16
|
+
* @param label The element's label.
|
17
|
+
*/
|
18
|
+
export declare function toMediaWidget(viewElement: ViewElement, writer: DowncastWriter, label: string): ViewElement;
|
19
|
+
/**
|
20
|
+
* Returns a media widget editing view element if one is selected.
|
21
|
+
*/
|
22
|
+
export declare function getSelectedMediaViewWidget(selection: ViewDocumentSelection): ViewElement | null;
|
23
|
+
/**
|
24
|
+
* Checks if a given view element is a media widget.
|
25
|
+
*/
|
26
|
+
export declare function isMediaWidget(viewElement: ViewElement): boolean;
|
27
|
+
/**
|
28
|
+
* Creates a view element representing the media. Either a "semantic" one for the data pipeline:
|
29
|
+
*
|
30
|
+
* ```html
|
31
|
+
* <figure class="media">
|
32
|
+
* <oembed url="foo"></oembed>
|
33
|
+
* </figure>
|
34
|
+
* ```
|
35
|
+
*
|
36
|
+
* or a "non-semantic" (for the editing view pipeline):
|
37
|
+
*
|
38
|
+
* ```html
|
39
|
+
* <figure class="media">
|
40
|
+
* <div data-oembed-url="foo">[ non-semantic media preview for "foo" ]</div>
|
41
|
+
* </figure>
|
42
|
+
* ```
|
43
|
+
*/
|
44
|
+
export declare function createMediaFigureElement(writer: DowncastWriter, registry: MediaRegistry, url: string, options: MediaOptions): ViewContainerElement;
|
45
|
+
/**
|
46
|
+
* Returns a selected media element in the model, if any.
|
47
|
+
*/
|
48
|
+
export declare function getSelectedMediaModelWidget(selection: Selection | DocumentSelection): Element | null;
|
49
|
+
/**
|
50
|
+
* Creates a media element and inserts it into the model.
|
51
|
+
*
|
52
|
+
* **Note**: This method will use {@link module:engine/model/model~Model#insertContent `model.insertContent()`} logic of inserting content
|
53
|
+
* if no `insertPosition` is passed.
|
54
|
+
*
|
55
|
+
* @param url An URL of an embeddable media.
|
56
|
+
* @param findOptimalPosition If true it will try to find optimal position to insert media without breaking content
|
57
|
+
* in which a selection is.
|
58
|
+
*/
|
59
|
+
export declare function insertMedia(model: Model, url: string, selectable: Selectable, findOptimalPosition: boolean): void;
|
60
|
+
/**
|
61
|
+
* Type for commonly grouped function parameters across this package.
|
62
|
+
*/
|
63
|
+
export type MediaOptions = {
|
64
|
+
elementName: string;
|
65
|
+
renderMediaPreview?: boolean;
|
66
|
+
renderForEditingView?: boolean;
|
67
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-media-embed",
|
3
|
-
"version": "41.
|
3
|
+
"version": "41.3.0-alpha.1",
|
4
4
|
"description": "Media embed feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,8 +13,8 @@
|
|
13
13
|
"type": "module",
|
14
14
|
"main": "src/index.js",
|
15
15
|
"dependencies": {
|
16
|
-
"@ckeditor/ckeditor5-ui": "41.
|
17
|
-
"ckeditor5": "41.
|
16
|
+
"@ckeditor/ckeditor5-ui": "41.3.0-alpha.1",
|
17
|
+
"ckeditor5": "41.3.0-alpha.1"
|
18
18
|
},
|
19
19
|
"author": "CKSource (http://cksource.com/)",
|
20
20
|
"license": "GPL-2.0-or-later",
|
@@ -26,6 +26,7 @@
|
|
26
26
|
"directory": "packages/ckeditor5-media-embed"
|
27
27
|
},
|
28
28
|
"files": [
|
29
|
+
"dist",
|
29
30
|
"lang",
|
30
31
|
"src/**/*.js",
|
31
32
|
"src/**/*.d.ts",
|