@ckeditor/ckeditor5-media-embed 47.6.1 → 48.0.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/ckeditor5-metadata.json +3 -3
- package/{src → dist}/automediaembed.d.ts +4 -4
- package/{src → dist}/converters.d.ts +1 -1
- package/dist/index-content.css +4 -4
- package/dist/index-editor.css +136 -75
- package/dist/index.css +128 -116
- package/dist/index.css.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/{src → dist}/mediaembed.d.ts +2 -2
- package/{src → dist}/mediaembedcommand.d.ts +1 -1
- package/{src → dist}/mediaembedconfig.d.ts +2 -2
- package/{src → dist}/mediaembedediting.d.ts +1 -1
- package/{src → dist}/mediaembedtoolbar.d.ts +2 -2
- package/{src → dist}/mediaembedui.d.ts +2 -2
- package/{src → dist}/mediaregistry.d.ts +2 -2
- package/{src → dist}/ui/mediaformview.d.ts +2 -3
- package/{src → dist}/utils.d.ts +1 -1
- package/package.json +27 -51
- package/build/media-embed.js +0 -5
- package/build/translations/af.js +0 -1
- package/build/translations/ar.js +0 -1
- package/build/translations/ast.js +0 -1
- package/build/translations/az.js +0 -1
- package/build/translations/be.js +0 -1
- package/build/translations/bg.js +0 -1
- package/build/translations/bn.js +0 -1
- package/build/translations/bs.js +0 -1
- package/build/translations/ca.js +0 -1
- package/build/translations/cs.js +0 -1
- package/build/translations/da.js +0 -1
- package/build/translations/de-ch.js +0 -1
- package/build/translations/de.js +0 -1
- package/build/translations/el.js +0 -1
- package/build/translations/en-au.js +0 -1
- package/build/translations/en-gb.js +0 -1
- package/build/translations/eo.js +0 -1
- package/build/translations/es-co.js +0 -1
- package/build/translations/es.js +0 -1
- package/build/translations/et.js +0 -1
- package/build/translations/eu.js +0 -1
- package/build/translations/fa.js +0 -1
- package/build/translations/fi.js +0 -1
- package/build/translations/fr.js +0 -1
- package/build/translations/gl.js +0 -1
- package/build/translations/gu.js +0 -1
- package/build/translations/he.js +0 -1
- package/build/translations/hi.js +0 -1
- package/build/translations/hr.js +0 -1
- package/build/translations/hu.js +0 -1
- package/build/translations/hy.js +0 -1
- package/build/translations/id.js +0 -1
- package/build/translations/it.js +0 -1
- package/build/translations/ja.js +0 -1
- package/build/translations/jv.js +0 -1
- package/build/translations/kk.js +0 -1
- package/build/translations/km.js +0 -1
- package/build/translations/kn.js +0 -1
- package/build/translations/ko.js +0 -1
- package/build/translations/ku.js +0 -1
- package/build/translations/lt.js +0 -1
- package/build/translations/lv.js +0 -1
- package/build/translations/ms.js +0 -1
- package/build/translations/nb.js +0 -1
- package/build/translations/ne.js +0 -1
- package/build/translations/nl.js +0 -1
- package/build/translations/no.js +0 -1
- package/build/translations/oc.js +0 -1
- package/build/translations/pl.js +0 -1
- package/build/translations/pt-br.js +0 -1
- package/build/translations/pt.js +0 -1
- package/build/translations/ro.js +0 -1
- package/build/translations/ru.js +0 -1
- package/build/translations/si.js +0 -1
- package/build/translations/sk.js +0 -1
- package/build/translations/sl.js +0 -1
- package/build/translations/sq.js +0 -1
- package/build/translations/sr-latn.js +0 -1
- package/build/translations/sr.js +0 -1
- package/build/translations/sv.js +0 -1
- package/build/translations/th.js +0 -1
- package/build/translations/ti.js +0 -1
- package/build/translations/tk.js +0 -1
- package/build/translations/tr.js +0 -1
- package/build/translations/tt.js +0 -1
- package/build/translations/ug.js +0 -1
- package/build/translations/uk.js +0 -1
- package/build/translations/ur.js +0 -1
- package/build/translations/uz.js +0 -1
- package/build/translations/vi.js +0 -1
- package/build/translations/zh-cn.js +0 -1
- package/build/translations/zh.js +0 -1
- package/lang/contexts.json +0 -13
- package/lang/translations/af.po +0 -56
- package/lang/translations/ar.po +0 -56
- package/lang/translations/ast.po +0 -56
- package/lang/translations/az.po +0 -56
- package/lang/translations/be.po +0 -56
- package/lang/translations/bg.po +0 -56
- package/lang/translations/bn.po +0 -56
- package/lang/translations/bs.po +0 -56
- package/lang/translations/ca.po +0 -56
- package/lang/translations/cs.po +0 -56
- package/lang/translations/da.po +0 -56
- package/lang/translations/de-ch.po +0 -56
- package/lang/translations/de.po +0 -56
- package/lang/translations/el.po +0 -56
- package/lang/translations/en-au.po +0 -56
- package/lang/translations/en-gb.po +0 -56
- package/lang/translations/en.po +0 -56
- package/lang/translations/eo.po +0 -56
- package/lang/translations/es-co.po +0 -56
- package/lang/translations/es.po +0 -56
- package/lang/translations/et.po +0 -56
- package/lang/translations/eu.po +0 -56
- package/lang/translations/fa.po +0 -56
- package/lang/translations/fi.po +0 -56
- package/lang/translations/fr.po +0 -56
- package/lang/translations/gl.po +0 -56
- package/lang/translations/gu.po +0 -56
- package/lang/translations/he.po +0 -56
- package/lang/translations/hi.po +0 -56
- package/lang/translations/hr.po +0 -56
- package/lang/translations/hu.po +0 -56
- package/lang/translations/hy.po +0 -56
- package/lang/translations/id.po +0 -56
- package/lang/translations/it.po +0 -56
- package/lang/translations/ja.po +0 -56
- package/lang/translations/jv.po +0 -56
- package/lang/translations/kk.po +0 -56
- package/lang/translations/km.po +0 -56
- package/lang/translations/kn.po +0 -56
- package/lang/translations/ko.po +0 -56
- package/lang/translations/ku.po +0 -56
- package/lang/translations/lt.po +0 -56
- package/lang/translations/lv.po +0 -56
- package/lang/translations/ms.po +0 -56
- package/lang/translations/nb.po +0 -56
- package/lang/translations/ne.po +0 -56
- package/lang/translations/nl.po +0 -56
- package/lang/translations/no.po +0 -56
- package/lang/translations/oc.po +0 -56
- package/lang/translations/pl.po +0 -56
- package/lang/translations/pt-br.po +0 -56
- package/lang/translations/pt.po +0 -56
- package/lang/translations/ro.po +0 -56
- package/lang/translations/ru.po +0 -56
- package/lang/translations/si.po +0 -56
- package/lang/translations/sk.po +0 -56
- package/lang/translations/sl.po +0 -56
- package/lang/translations/sq.po +0 -56
- package/lang/translations/sr-latn.po +0 -56
- package/lang/translations/sr.po +0 -56
- package/lang/translations/sv.po +0 -56
- package/lang/translations/th.po +0 -56
- package/lang/translations/ti.po +0 -56
- package/lang/translations/tk.po +0 -56
- package/lang/translations/tr.po +0 -56
- package/lang/translations/tt.po +0 -56
- package/lang/translations/ug.po +0 -56
- package/lang/translations/uk.po +0 -56
- package/lang/translations/ur.po +0 -56
- package/lang/translations/uz.po +0 -56
- package/lang/translations/vi.po +0 -56
- package/lang/translations/zh-cn.po +0 -56
- package/lang/translations/zh.po +0 -56
- package/src/augmentation.js +0 -5
- package/src/automediaembed.js +0 -147
- package/src/converters.js +0 -55
- package/src/index.js +0 -18
- package/src/mediaembed.js +0 -44
- package/src/mediaembedcommand.js +0 -71
- package/src/mediaembedconfig.js +0 -5
- package/src/mediaembedediting.js +0 -252
- package/src/mediaembedtoolbar.js +0 -50
- package/src/mediaembedui.js +0 -134
- package/src/mediaregistry.js +0 -262
- package/src/ui/mediaformview.js +0 -157
- package/src/utils.js +0 -96
- package/theme/mediaembed.css +0 -23
- package/theme/mediaembedediting.css +0 -48
- package/theme/mediaform.css +0 -39
- /package/{src → dist}/augmentation.d.ts +0 -0
- /package/{src → dist}/index.d.ts +0 -0
package/src/mediaregistry.js
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module media-embed/mediaregistry
|
|
7
|
-
*/
|
|
8
|
-
import { IconView, Template } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { IconMediaPlaceholder } from 'ckeditor5/src/icons.js';
|
|
10
|
-
import { logWarning, toArray } from 'ckeditor5/src/utils.js';
|
|
11
|
-
const mediaPlaceholderIconViewBox = '0 0 64 42';
|
|
12
|
-
/**
|
|
13
|
-
* A bridge between the raw media content provider definitions and the editor view content.
|
|
14
|
-
*
|
|
15
|
-
* It helps translating media URLs to corresponding {@link module:engine/view/element~ViewElement view elements}.
|
|
16
|
-
*
|
|
17
|
-
* Mostly used by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} plugin.
|
|
18
|
-
*/
|
|
19
|
-
export class MediaRegistry {
|
|
20
|
-
/**
|
|
21
|
-
* The {@link module:utils/locale~Locale} instance.
|
|
22
|
-
*/
|
|
23
|
-
locale;
|
|
24
|
-
/**
|
|
25
|
-
* The media provider definitions available for the registry. Usually corresponding with the
|
|
26
|
-
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig media configuration}.
|
|
27
|
-
*/
|
|
28
|
-
providerDefinitions;
|
|
29
|
-
/**
|
|
30
|
-
* Creates an instance of the {@link module:media-embed/mediaregistry~MediaRegistry} class.
|
|
31
|
-
*
|
|
32
|
-
* @param locale The localization services instance.
|
|
33
|
-
* @param config The configuration of the media embed feature.
|
|
34
|
-
*/
|
|
35
|
-
constructor(locale, config) {
|
|
36
|
-
const providers = config.providers;
|
|
37
|
-
const extraProviders = config.extraProviders || [];
|
|
38
|
-
const removedProviders = new Set(config.removeProviders);
|
|
39
|
-
const providerDefinitions = providers
|
|
40
|
-
.concat(extraProviders)
|
|
41
|
-
.filter(provider => {
|
|
42
|
-
const name = provider.name;
|
|
43
|
-
if (!name) {
|
|
44
|
-
/**
|
|
45
|
-
* One of the providers (or extra providers) specified in the media embed configuration
|
|
46
|
-
* has no name and will not be used by the editor. In order to get this media
|
|
47
|
-
* provider working, double check your editor configuration.
|
|
48
|
-
*
|
|
49
|
-
* @error media-embed-no-provider-name
|
|
50
|
-
*/
|
|
51
|
-
logWarning('media-embed-no-provider-name', { provider });
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
return !removedProviders.has(name);
|
|
55
|
-
});
|
|
56
|
-
this.locale = locale;
|
|
57
|
-
this.providerDefinitions = providerDefinitions;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Checks whether the passed URL is representing a certain media type allowed in the editor.
|
|
61
|
-
*
|
|
62
|
-
* @param url The URL to be checked
|
|
63
|
-
*/
|
|
64
|
-
hasMedia(url) {
|
|
65
|
-
return !!this._getMedia(url);
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* For the given media URL string and options, it returns the {@link module:engine/view/element~ViewElement view element}
|
|
69
|
-
* representing that media.
|
|
70
|
-
*
|
|
71
|
-
* **Note:** If no URL is specified, an empty view element is returned.
|
|
72
|
-
*
|
|
73
|
-
* @param writer The view writer used to produce a view element.
|
|
74
|
-
* @param url The URL to be translated into a view element.
|
|
75
|
-
*/
|
|
76
|
-
getMediaViewElement(writer, url, options) {
|
|
77
|
-
return this._getMedia(url).getViewElement(writer, options);
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Returns a `Media` instance for the given URL.
|
|
81
|
-
*
|
|
82
|
-
* @param url The URL of the media.
|
|
83
|
-
* @returns The `Media` instance or `null` when there is none.
|
|
84
|
-
*/
|
|
85
|
-
_getMedia(url) {
|
|
86
|
-
if (!url) {
|
|
87
|
-
return new Media(this.locale);
|
|
88
|
-
}
|
|
89
|
-
url = url.trim();
|
|
90
|
-
for (const definition of this.providerDefinitions) {
|
|
91
|
-
const previewRenderer = definition.html;
|
|
92
|
-
const pattern = toArray(definition.url);
|
|
93
|
-
for (const subPattern of pattern) {
|
|
94
|
-
const match = this._getUrlMatches(url, subPattern);
|
|
95
|
-
if (match) {
|
|
96
|
-
return new Media(this.locale, url, match, previewRenderer);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Tries to match `url` to `pattern`.
|
|
104
|
-
*
|
|
105
|
-
* @param url The URL of the media.
|
|
106
|
-
* @param pattern The pattern that should accept the media URL.
|
|
107
|
-
*/
|
|
108
|
-
_getUrlMatches(url, pattern) {
|
|
109
|
-
// 1. Try to match without stripping the protocol and "www" subdomain.
|
|
110
|
-
let match = url.match(pattern);
|
|
111
|
-
if (match) {
|
|
112
|
-
return match;
|
|
113
|
-
}
|
|
114
|
-
// 2. Try to match after stripping the protocol.
|
|
115
|
-
let rawUrl = url.replace(/^https?:\/\//, '');
|
|
116
|
-
match = rawUrl.match(pattern);
|
|
117
|
-
if (match) {
|
|
118
|
-
return match;
|
|
119
|
-
}
|
|
120
|
-
// 3. Try to match after stripping the "www" subdomain.
|
|
121
|
-
rawUrl = rawUrl.replace(/^www\./, '');
|
|
122
|
-
match = rawUrl.match(pattern);
|
|
123
|
-
if (match) {
|
|
124
|
-
return match;
|
|
125
|
-
}
|
|
126
|
-
return null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Represents media defined by the provider configuration.
|
|
131
|
-
*
|
|
132
|
-
* It can be rendered to the {@link module:engine/view/element~ViewElement view element} and used in the editing or data pipeline.
|
|
133
|
-
*/
|
|
134
|
-
class Media {
|
|
135
|
-
/**
|
|
136
|
-
* The URL this Media instance represents.
|
|
137
|
-
*/
|
|
138
|
-
url;
|
|
139
|
-
/**
|
|
140
|
-
* Shorthand for {@link module:utils/locale~Locale#t}.
|
|
141
|
-
*
|
|
142
|
-
* @see module:utils/locale~Locale#t
|
|
143
|
-
*/
|
|
144
|
-
_locale;
|
|
145
|
-
/**
|
|
146
|
-
* The output of the `RegExp.match` which validated the {@link #url} of this media.
|
|
147
|
-
*/
|
|
148
|
-
_match;
|
|
149
|
-
/**
|
|
150
|
-
* The function returning the HTML string preview of this media.
|
|
151
|
-
*/
|
|
152
|
-
_previewRenderer;
|
|
153
|
-
constructor(locale, url, match, previewRenderer) {
|
|
154
|
-
this.url = this._getValidUrl(url);
|
|
155
|
-
this._locale = locale;
|
|
156
|
-
this._match = match;
|
|
157
|
-
this._previewRenderer = previewRenderer;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Returns the view element representation of the media.
|
|
161
|
-
*
|
|
162
|
-
* @param writer The view writer used to produce a view element.
|
|
163
|
-
*/
|
|
164
|
-
getViewElement(writer, options) {
|
|
165
|
-
const attributes = {};
|
|
166
|
-
let viewElement;
|
|
167
|
-
if (options.renderForEditingView || (options.renderMediaPreview && this.url && this._previewRenderer)) {
|
|
168
|
-
if (this.url) {
|
|
169
|
-
attributes['data-oembed-url'] = this.url;
|
|
170
|
-
}
|
|
171
|
-
if (options.renderForEditingView) {
|
|
172
|
-
attributes.class = 'ck-media__wrapper';
|
|
173
|
-
}
|
|
174
|
-
const mediaHtml = this._getPreviewHtml(options);
|
|
175
|
-
viewElement = writer.createRawElement('div', attributes, (domElement, domConverter) => {
|
|
176
|
-
domConverter.setContentOf(domElement, mediaHtml);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
if (this.url) {
|
|
181
|
-
attributes.url = this.url;
|
|
182
|
-
}
|
|
183
|
-
viewElement = writer.createEmptyElement(options.elementName, attributes);
|
|
184
|
-
}
|
|
185
|
-
writer.setCustomProperty('media-content', true, viewElement);
|
|
186
|
-
return viewElement;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Returns the HTML string of the media content preview.
|
|
190
|
-
*/
|
|
191
|
-
_getPreviewHtml(options) {
|
|
192
|
-
if (this._previewRenderer) {
|
|
193
|
-
return this._previewRenderer(this._match);
|
|
194
|
-
}
|
|
195
|
-
else {
|
|
196
|
-
// The placeholder only makes sense for editing view and media which have URLs.
|
|
197
|
-
// Placeholder is never displayed in data and URL-less media have no content.
|
|
198
|
-
if (this.url && options.renderForEditingView) {
|
|
199
|
-
return this._getPlaceholderHtml();
|
|
200
|
-
}
|
|
201
|
-
return '';
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Returns the placeholder HTML when the media has no content preview.
|
|
206
|
-
*/
|
|
207
|
-
_getPlaceholderHtml() {
|
|
208
|
-
const icon = new IconView();
|
|
209
|
-
const t = this._locale.t;
|
|
210
|
-
icon.content = IconMediaPlaceholder;
|
|
211
|
-
icon.viewBox = mediaPlaceholderIconViewBox;
|
|
212
|
-
const placeholder = new Template({
|
|
213
|
-
tag: 'div',
|
|
214
|
-
attributes: {
|
|
215
|
-
class: 'ck ck-reset_all ck-media__placeholder'
|
|
216
|
-
},
|
|
217
|
-
children: [
|
|
218
|
-
{
|
|
219
|
-
tag: 'div',
|
|
220
|
-
attributes: {
|
|
221
|
-
class: 'ck-media__placeholder__icon'
|
|
222
|
-
},
|
|
223
|
-
children: [icon]
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
tag: 'a',
|
|
227
|
-
attributes: {
|
|
228
|
-
class: 'ck-media__placeholder__url',
|
|
229
|
-
target: '_blank',
|
|
230
|
-
rel: 'noopener noreferrer',
|
|
231
|
-
href: this.url,
|
|
232
|
-
'data-cke-tooltip-text': t('Open media in new tab')
|
|
233
|
-
},
|
|
234
|
-
children: [
|
|
235
|
-
{
|
|
236
|
-
tag: 'span',
|
|
237
|
-
attributes: {
|
|
238
|
-
class: 'ck-media__placeholder__url__text'
|
|
239
|
-
},
|
|
240
|
-
children: [this.url]
|
|
241
|
-
}
|
|
242
|
-
]
|
|
243
|
-
}
|
|
244
|
-
]
|
|
245
|
-
}).render();
|
|
246
|
-
return placeholder.outerHTML;
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Returns the full URL to the specified media.
|
|
250
|
-
*
|
|
251
|
-
* @param url The URL of the media.
|
|
252
|
-
*/
|
|
253
|
-
_getValidUrl(url) {
|
|
254
|
-
if (!url) {
|
|
255
|
-
return null;
|
|
256
|
-
}
|
|
257
|
-
if (url.match(/^https?/)) {
|
|
258
|
-
return url;
|
|
259
|
-
}
|
|
260
|
-
return 'https://' + url;
|
|
261
|
-
}
|
|
262
|
-
}
|
package/src/ui/mediaformview.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* @module media-embed/ui/mediaformview
|
|
7
|
-
*/
|
|
8
|
-
import { LabeledFieldView, View, createLabeledInputText, submitHandler } from 'ckeditor5/src/ui.js';
|
|
9
|
-
import { FocusTracker, KeystrokeHandler } from 'ckeditor5/src/utils.js';
|
|
10
|
-
// See: #8833.
|
|
11
|
-
// eslint-disable-next-line ckeditor5-rules/ckeditor-imports
|
|
12
|
-
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
|
13
|
-
import '../../theme/mediaform.css';
|
|
14
|
-
/**
|
|
15
|
-
* The media form view controller class.
|
|
16
|
-
*
|
|
17
|
-
* See {@link module:media-embed/ui/mediaformview~MediaFormView}.
|
|
18
|
-
*/
|
|
19
|
-
export class MediaFormView extends View {
|
|
20
|
-
/**
|
|
21
|
-
* Tracks information about the DOM focus in the form.
|
|
22
|
-
*/
|
|
23
|
-
focusTracker;
|
|
24
|
-
/**
|
|
25
|
-
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
|
26
|
-
*/
|
|
27
|
-
keystrokes;
|
|
28
|
-
/**
|
|
29
|
-
* The URL input view.
|
|
30
|
-
*/
|
|
31
|
-
urlInputView;
|
|
32
|
-
/**
|
|
33
|
-
* An array of form validators used by {@link #isValid}.
|
|
34
|
-
*/
|
|
35
|
-
_validators;
|
|
36
|
-
/**
|
|
37
|
-
* The default info text for the {@link #urlInputView}.
|
|
38
|
-
*/
|
|
39
|
-
_urlInputViewInfoDefault;
|
|
40
|
-
/**
|
|
41
|
-
* The info text with an additional tip for the {@link #urlInputView},
|
|
42
|
-
* displayed when the input has some value.
|
|
43
|
-
*/
|
|
44
|
-
_urlInputViewInfoTip;
|
|
45
|
-
/**
|
|
46
|
-
* @param validators Form validators used by {@link #isValid}.
|
|
47
|
-
* @param locale The localization services instance.
|
|
48
|
-
*/
|
|
49
|
-
constructor(validators, locale) {
|
|
50
|
-
super(locale);
|
|
51
|
-
this.focusTracker = new FocusTracker();
|
|
52
|
-
this.keystrokes = new KeystrokeHandler();
|
|
53
|
-
this.set('mediaURLInputValue', '');
|
|
54
|
-
this.urlInputView = this._createUrlInput();
|
|
55
|
-
this._validators = validators;
|
|
56
|
-
this.setTemplate({
|
|
57
|
-
tag: 'form',
|
|
58
|
-
attributes: {
|
|
59
|
-
class: [
|
|
60
|
-
'ck',
|
|
61
|
-
'ck-media-form',
|
|
62
|
-
'ck-responsive-form'
|
|
63
|
-
],
|
|
64
|
-
tabindex: '-1'
|
|
65
|
-
},
|
|
66
|
-
children: [
|
|
67
|
-
this.urlInputView
|
|
68
|
-
]
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* @inheritDoc
|
|
73
|
-
*/
|
|
74
|
-
render() {
|
|
75
|
-
super.render();
|
|
76
|
-
submitHandler({
|
|
77
|
-
view: this
|
|
78
|
-
});
|
|
79
|
-
// Register the view in the focus tracker.
|
|
80
|
-
this.focusTracker.add(this.urlInputView.element);
|
|
81
|
-
// Start listening for the keystrokes coming from #element.
|
|
82
|
-
this.keystrokes.listenTo(this.element);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* @inheritDoc
|
|
86
|
-
*/
|
|
87
|
-
destroy() {
|
|
88
|
-
super.destroy();
|
|
89
|
-
this.focusTracker.destroy();
|
|
90
|
-
this.keystrokes.destroy();
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Focuses the {@link #urlInputView}.
|
|
94
|
-
*/
|
|
95
|
-
focus() {
|
|
96
|
-
this.urlInputView.focus();
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* The native DOM `value` of the {@link #urlInputView} element.
|
|
100
|
-
*
|
|
101
|
-
* **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
|
|
102
|
-
* which works one way only and may not represent the actual state of the component in the DOM.
|
|
103
|
-
*/
|
|
104
|
-
get url() {
|
|
105
|
-
return this.urlInputView.fieldView.element.value.trim();
|
|
106
|
-
}
|
|
107
|
-
set url(url) {
|
|
108
|
-
this.urlInputView.fieldView.value = url.trim();
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Validates the form and returns `false` when some fields are invalid.
|
|
112
|
-
*/
|
|
113
|
-
isValid() {
|
|
114
|
-
this.resetFormStatus();
|
|
115
|
-
for (const validator of this._validators) {
|
|
116
|
-
const errorText = validator(this);
|
|
117
|
-
// One error per field is enough.
|
|
118
|
-
if (errorText) {
|
|
119
|
-
// Apply updated error.
|
|
120
|
-
this.urlInputView.errorText = errorText;
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
return true;
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Cleans up the supplementary error and information text of the {@link #urlInputView}
|
|
128
|
-
* bringing them back to the state when the form has been displayed for the first time.
|
|
129
|
-
*
|
|
130
|
-
* See {@link #isValid}.
|
|
131
|
-
*/
|
|
132
|
-
resetFormStatus() {
|
|
133
|
-
this.urlInputView.errorText = null;
|
|
134
|
-
this.urlInputView.infoText = this._urlInputViewInfoDefault;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Creates a labeled input view.
|
|
138
|
-
*
|
|
139
|
-
* @returns Labeled input view instance.
|
|
140
|
-
*/
|
|
141
|
-
_createUrlInput() {
|
|
142
|
-
const t = this.locale.t;
|
|
143
|
-
const labeledInput = new LabeledFieldView(this.locale, createLabeledInputText);
|
|
144
|
-
const inputField = labeledInput.fieldView;
|
|
145
|
-
this._urlInputViewInfoDefault = t('Paste the media URL in the input.');
|
|
146
|
-
this._urlInputViewInfoTip = t('Tip: Paste the URL into the content to embed faster.');
|
|
147
|
-
labeledInput.label = t('Media URL');
|
|
148
|
-
labeledInput.infoText = this._urlInputViewInfoDefault;
|
|
149
|
-
inputField.inputMode = 'url';
|
|
150
|
-
inputField.on('input', () => {
|
|
151
|
-
// Display the tip text only when there is some value. Otherwise fall back to the default info text.
|
|
152
|
-
labeledInput.infoText = inputField.element.value ? this._urlInputViewInfoTip : this._urlInputViewInfoDefault;
|
|
153
|
-
this.mediaURLInputValue = inputField.element.value.trim();
|
|
154
|
-
});
|
|
155
|
-
return labeledInput;
|
|
156
|
-
}
|
|
157
|
-
}
|
package/src/utils.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
import { isWidget, toWidget } from 'ckeditor5/src/widget.js';
|
|
6
|
-
/**
|
|
7
|
-
* Converts a given {@link module:engine/view/element~ViewElement} to a media embed widget:
|
|
8
|
-
* * Adds a {@link module:engine/view/element~ViewElement#_setCustomProperty custom property}
|
|
9
|
-
* allowing to recognize the media widget element.
|
|
10
|
-
* * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
|
|
11
|
-
*
|
|
12
|
-
* @param writer An instance of the view writer.
|
|
13
|
-
* @param label The element's label.
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
export function toMediaWidget(viewElement, writer, label) {
|
|
17
|
-
writer.setCustomProperty('media', true, viewElement);
|
|
18
|
-
return toWidget(viewElement, writer, { label });
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Returns a media widget editing view element if one is selected.
|
|
22
|
-
*
|
|
23
|
-
* @internal
|
|
24
|
-
*/
|
|
25
|
-
export function getSelectedMediaViewWidget(selection) {
|
|
26
|
-
const viewElement = selection.getSelectedElement();
|
|
27
|
-
if (viewElement && isMediaWidget(viewElement)) {
|
|
28
|
-
return viewElement;
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Checks if a given view element is a media widget.
|
|
34
|
-
*
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
export function isMediaWidget(viewElement) {
|
|
38
|
-
return !!viewElement.getCustomProperty('media') && isWidget(viewElement);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Creates a view element representing the media. Either a "semantic" one for the data pipeline:
|
|
42
|
-
*
|
|
43
|
-
* ```html
|
|
44
|
-
* <figure class="media">
|
|
45
|
-
* <oembed url="foo"></oembed>
|
|
46
|
-
* </figure>
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* or a "non-semantic" (for the editing view pipeline):
|
|
50
|
-
*
|
|
51
|
-
* ```html
|
|
52
|
-
* <figure class="media">
|
|
53
|
-
* <div data-oembed-url="foo">[ non-semantic media preview for "foo" ]</div>
|
|
54
|
-
* </figure>
|
|
55
|
-
* ```
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
59
|
-
export function createMediaFigureElement(writer, registry, url, options) {
|
|
60
|
-
return writer.createContainerElement('figure', { class: 'media' }, [
|
|
61
|
-
registry.getMediaViewElement(writer, url, options),
|
|
62
|
-
writer.createSlot()
|
|
63
|
-
]);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Returns a selected media element in the model, if any.
|
|
67
|
-
*
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
export function getSelectedMediaModelWidget(selection) {
|
|
71
|
-
const selectedElement = selection.getSelectedElement();
|
|
72
|
-
if (selectedElement && selectedElement.is('element', 'media')) {
|
|
73
|
-
return selectedElement;
|
|
74
|
-
}
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Creates a media element and inserts it into the model.
|
|
79
|
-
*
|
|
80
|
-
* **Note**: This method will use {@link module:engine/model/model~Model#insertContent `model.insertContent()`} logic of inserting content
|
|
81
|
-
* if no `insertPosition` is passed.
|
|
82
|
-
*
|
|
83
|
-
* @param url An URL of an embeddable media.
|
|
84
|
-
* @param findOptimalPosition If true it will try to find optimal position to insert media without breaking content
|
|
85
|
-
* in which a selection is.
|
|
86
|
-
* @internal
|
|
87
|
-
*/
|
|
88
|
-
export function insertMedia(model, url, selectable, findOptimalPosition) {
|
|
89
|
-
model.change(writer => {
|
|
90
|
-
const mediaElement = writer.createElement('media', { url });
|
|
91
|
-
model.insertObject(mediaElement, selectable, null, {
|
|
92
|
-
setSelection: 'on',
|
|
93
|
-
findOptimalPosition: findOptimalPosition ? 'auto' : undefined
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
package/theme/mediaembed.css
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
.ck-content .media {
|
|
7
|
-
/* Don't allow floated content overlap the media.
|
|
8
|
-
https://github.com/ckeditor/ckeditor5-media-embed/issues/53 */
|
|
9
|
-
clear: both;
|
|
10
|
-
|
|
11
|
-
/* Make sure there is some space between the content and the media. */
|
|
12
|
-
/* The first value should be equal to --ck-spacing-large variable if used in the editor context
|
|
13
|
-
to avoid the content jumping (See https://github.com/ckeditor/ckeditor5/issues/9825). */
|
|
14
|
-
margin: 0.9em 0;
|
|
15
|
-
|
|
16
|
-
/* Make sure media is not overriden with Bootstrap default `flex` value.
|
|
17
|
-
See: https://github.com/ckeditor/ckeditor5/issues/1373. */
|
|
18
|
-
display: block;
|
|
19
|
-
|
|
20
|
-
/* Give the media some minimal width in the content to prevent them
|
|
21
|
-
from being "squashed" in tight spaces, e.g. in table cells (#44) */
|
|
22
|
-
min-width: 15em;
|
|
23
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
.ck-media__wrapper {
|
|
7
|
-
& .ck-media__placeholder {
|
|
8
|
-
display: flex;
|
|
9
|
-
flex-direction: column;
|
|
10
|
-
align-items: center;
|
|
11
|
-
|
|
12
|
-
& .ck-media__placeholder__url {
|
|
13
|
-
/* Otherwise the URL will overflow when the content is very narrow. */
|
|
14
|
-
max-width: 100%;
|
|
15
|
-
|
|
16
|
-
position: relative;
|
|
17
|
-
|
|
18
|
-
& .ck-media__placeholder__url__text {
|
|
19
|
-
overflow: hidden;
|
|
20
|
-
display: block;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&[data-oembed-url*="twitter.com"],
|
|
26
|
-
&[data-oembed-url*="google.com/maps"],
|
|
27
|
-
&[data-oembed-url*="goo.gl/maps"],
|
|
28
|
-
&[data-oembed-url*="maps.google.com"],
|
|
29
|
-
&[data-oembed-url*="maps.app.goo.gl"],
|
|
30
|
-
&[data-oembed-url*="facebook.com"],
|
|
31
|
-
&[data-oembed-url*="instagram.com"] {
|
|
32
|
-
& .ck-media__placeholder__icon * {
|
|
33
|
-
display: none;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* Disable all mouse interaction as long as the editor is not read–only.
|
|
39
|
-
https://github.com/ckeditor/ckeditor5-media-embed/issues/58 */
|
|
40
|
-
.ck-editor__editable:not(.ck-read-only) .ck-media__wrapper > *:not(.ck-media__placeholder) {
|
|
41
|
-
pointer-events: none;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/* Disable all mouse interaction when the widget is not selected (e.g. to avoid opening links by accident).
|
|
45
|
-
https://github.com/ckeditor/ckeditor5-media-embed/issues/18 */
|
|
46
|
-
.ck-editor__editable:not(.ck-read-only) .ck-widget:not(.ck-widget_selected) .ck-media__placeholder {
|
|
47
|
-
pointer-events: none;
|
|
48
|
-
}
|
package/theme/mediaform.css
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2003-2026, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
@import "@ckeditor/ckeditor5-ui/theme/mixins/_rwd.css";
|
|
7
|
-
|
|
8
|
-
.ck.ck-media-form {
|
|
9
|
-
display: flex;
|
|
10
|
-
align-items: flex-start;
|
|
11
|
-
flex-direction: row;
|
|
12
|
-
flex-wrap: nowrap;
|
|
13
|
-
width: 400px;
|
|
14
|
-
|
|
15
|
-
& .ck-labeled-field-view {
|
|
16
|
-
display: inline-block;
|
|
17
|
-
width: 100%;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
& .ck-label {
|
|
21
|
-
display: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
& .ck-input {
|
|
25
|
-
width: 100%;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@mixin ck-media-phone {
|
|
29
|
-
flex-wrap: wrap;
|
|
30
|
-
|
|
31
|
-
& .ck-labeled-field-view {
|
|
32
|
-
flex-basis: 100%;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
& .ck-button {
|
|
36
|
-
flex-basis: 50%;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
File without changes
|
/package/{src → dist}/index.d.ts
RENAMED
|
File without changes
|