@ckeditor/ckeditor5-media-embed 41.3.1 → 41.4.0
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/build/media-embed.js +1 -1
- package/dist/index-content.css +10 -0
- package/dist/index-editor.css +50 -0
- package/dist/index.css +148 -0
- package/dist/index.css.map +1 -0
- package/dist/index.js +1038 -0
- package/dist/index.js.map +1 -0
- package/dist/translations/ar.d.ts +8 -0
- package/dist/translations/ar.js +5 -0
- package/dist/translations/ar.umd.js +11 -0
- package/dist/translations/az.d.ts +8 -0
- package/dist/translations/az.js +5 -0
- package/dist/translations/az.umd.js +11 -0
- package/dist/translations/bg.d.ts +8 -0
- package/dist/translations/bg.js +5 -0
- package/dist/translations/bg.umd.js +11 -0
- package/dist/translations/bn.d.ts +8 -0
- package/dist/translations/bn.js +5 -0
- package/dist/translations/bn.umd.js +11 -0
- package/dist/translations/ca.d.ts +8 -0
- package/dist/translations/ca.js +5 -0
- package/dist/translations/ca.umd.js +11 -0
- package/dist/translations/cs.d.ts +8 -0
- package/dist/translations/cs.js +5 -0
- package/dist/translations/cs.umd.js +11 -0
- package/dist/translations/da.d.ts +8 -0
- package/dist/translations/da.js +5 -0
- package/dist/translations/da.umd.js +11 -0
- package/dist/translations/de-ch.d.ts +8 -0
- package/dist/translations/de-ch.js +5 -0
- package/dist/translations/de-ch.umd.js +11 -0
- package/dist/translations/de.d.ts +8 -0
- package/dist/translations/de.js +5 -0
- package/dist/translations/de.umd.js +11 -0
- package/dist/translations/el.d.ts +8 -0
- package/dist/translations/el.js +5 -0
- package/dist/translations/el.umd.js +11 -0
- package/dist/translations/en-au.d.ts +8 -0
- package/dist/translations/en-au.js +5 -0
- package/dist/translations/en-au.umd.js +11 -0
- package/dist/translations/en-gb.d.ts +8 -0
- package/dist/translations/en-gb.js +5 -0
- package/dist/translations/en-gb.umd.js +11 -0
- package/dist/translations/en.d.ts +8 -0
- package/dist/translations/en.js +5 -0
- package/dist/translations/en.umd.js +11 -0
- package/dist/translations/es.d.ts +8 -0
- package/dist/translations/es.js +5 -0
- package/dist/translations/es.umd.js +11 -0
- package/dist/translations/et.d.ts +8 -0
- package/dist/translations/et.js +5 -0
- package/dist/translations/et.umd.js +11 -0
- package/dist/translations/fa.d.ts +8 -0
- package/dist/translations/fa.js +5 -0
- package/dist/translations/fa.umd.js +11 -0
- package/dist/translations/fi.d.ts +8 -0
- package/dist/translations/fi.js +5 -0
- package/dist/translations/fi.umd.js +11 -0
- package/dist/translations/fr.d.ts +8 -0
- package/dist/translations/fr.js +5 -0
- package/dist/translations/fr.umd.js +11 -0
- package/dist/translations/gl.d.ts +8 -0
- package/dist/translations/gl.js +5 -0
- package/dist/translations/gl.umd.js +11 -0
- package/dist/translations/he.d.ts +8 -0
- package/dist/translations/he.js +5 -0
- package/dist/translations/he.umd.js +11 -0
- package/dist/translations/hi.d.ts +8 -0
- package/dist/translations/hi.js +5 -0
- package/dist/translations/hi.umd.js +11 -0
- package/dist/translations/hr.d.ts +8 -0
- package/dist/translations/hr.js +5 -0
- package/dist/translations/hr.umd.js +11 -0
- package/dist/translations/hu.d.ts +8 -0
- package/dist/translations/hu.js +5 -0
- package/dist/translations/hu.umd.js +11 -0
- package/dist/translations/id.d.ts +8 -0
- package/dist/translations/id.js +5 -0
- package/dist/translations/id.umd.js +11 -0
- package/dist/translations/it.d.ts +8 -0
- package/dist/translations/it.js +5 -0
- package/dist/translations/it.umd.js +11 -0
- package/dist/translations/ja.d.ts +8 -0
- package/dist/translations/ja.js +5 -0
- package/dist/translations/ja.umd.js +11 -0
- package/dist/translations/ko.d.ts +8 -0
- package/dist/translations/ko.js +5 -0
- package/dist/translations/ko.umd.js +11 -0
- package/dist/translations/ku.d.ts +8 -0
- package/dist/translations/ku.js +5 -0
- package/dist/translations/ku.umd.js +11 -0
- package/dist/translations/lt.d.ts +8 -0
- package/dist/translations/lt.js +5 -0
- package/dist/translations/lt.umd.js +11 -0
- package/dist/translations/lv.d.ts +8 -0
- package/dist/translations/lv.js +5 -0
- package/dist/translations/lv.umd.js +11 -0
- package/dist/translations/ms.d.ts +8 -0
- package/dist/translations/ms.js +5 -0
- package/dist/translations/ms.umd.js +11 -0
- package/dist/translations/ne.d.ts +8 -0
- package/dist/translations/ne.js +5 -0
- package/dist/translations/ne.umd.js +11 -0
- package/dist/translations/nl.d.ts +8 -0
- package/dist/translations/nl.js +5 -0
- package/dist/translations/nl.umd.js +11 -0
- package/dist/translations/no.d.ts +8 -0
- package/dist/translations/no.js +5 -0
- package/dist/translations/no.umd.js +11 -0
- package/dist/translations/pl.d.ts +8 -0
- package/dist/translations/pl.js +5 -0
- package/dist/translations/pl.umd.js +11 -0
- package/dist/translations/pt-br.d.ts +8 -0
- package/dist/translations/pt-br.js +5 -0
- package/dist/translations/pt-br.umd.js +11 -0
- package/dist/translations/pt.d.ts +8 -0
- package/dist/translations/pt.js +5 -0
- package/dist/translations/pt.umd.js +11 -0
- package/dist/translations/ro.d.ts +8 -0
- package/dist/translations/ro.js +5 -0
- package/dist/translations/ro.umd.js +11 -0
- package/dist/translations/ru.d.ts +8 -0
- package/dist/translations/ru.js +5 -0
- package/dist/translations/ru.umd.js +11 -0
- package/dist/translations/sk.d.ts +8 -0
- package/dist/translations/sk.js +5 -0
- package/dist/translations/sk.umd.js +11 -0
- package/dist/translations/sq.d.ts +8 -0
- package/dist/translations/sq.js +5 -0
- package/dist/translations/sq.umd.js +11 -0
- package/dist/translations/sr-latn.d.ts +8 -0
- package/dist/translations/sr-latn.js +5 -0
- package/dist/translations/sr-latn.umd.js +11 -0
- package/dist/translations/sr.d.ts +8 -0
- package/dist/translations/sr.js +5 -0
- package/dist/translations/sr.umd.js +11 -0
- package/dist/translations/sv.d.ts +8 -0
- package/dist/translations/sv.js +5 -0
- package/dist/translations/sv.umd.js +11 -0
- package/dist/translations/th.d.ts +8 -0
- package/dist/translations/th.js +5 -0
- package/dist/translations/th.umd.js +11 -0
- package/dist/translations/tk.d.ts +8 -0
- package/dist/translations/tk.js +5 -0
- package/dist/translations/tk.umd.js +11 -0
- package/dist/translations/tr.d.ts +8 -0
- package/dist/translations/tr.js +5 -0
- package/dist/translations/tr.umd.js +11 -0
- package/dist/translations/uk.d.ts +8 -0
- package/dist/translations/uk.js +5 -0
- package/dist/translations/uk.umd.js +11 -0
- package/dist/translations/ur.d.ts +8 -0
- package/dist/translations/ur.js +5 -0
- package/dist/translations/ur.umd.js +11 -0
- package/dist/translations/uz.d.ts +8 -0
- package/dist/translations/uz.js +5 -0
- package/dist/translations/uz.umd.js +11 -0
- package/dist/translations/vi.d.ts +8 -0
- package/dist/translations/vi.js +5 -0
- package/dist/translations/vi.umd.js +11 -0
- package/dist/translations/zh-cn.d.ts +8 -0
- package/dist/translations/zh-cn.js +5 -0
- package/dist/translations/zh-cn.umd.js +11 -0
- package/dist/translations/zh.d.ts +8 -0
- package/dist/translations/zh.js +5 -0
- package/dist/translations/zh.umd.js +11 -0
- package/dist/types/augmentation.d.ts +29 -0
- package/dist/types/automediaembed.d.ts +55 -0
- package/dist/types/converters.d.ts +42 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/mediaembed.d.ts +38 -0
- package/dist/types/mediaembedcommand.d.ts +40 -0
- package/dist/types/mediaembedconfig.d.ts +282 -0
- package/dist/types/mediaembedediting.d.ts +35 -0
- package/dist/types/mediaembedtoolbar.d.ts +34 -0
- package/dist/types/mediaembedui.d.ts +31 -0
- package/dist/types/mediaregistry.d.ts +70 -0
- package/dist/types/ui/mediaformview.d.ts +119 -0
- package/dist/types/utils.d.ts +71 -0
- package/package.json +4 -3
- package/src/mediaembedui.js +4 -0
- package/src/ui/mediaformview.js +0 -1
@@ -0,0 +1,38 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/mediaembed
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import { Widget } from 'ckeditor5/src/widget.js';
|
14
|
+
import MediaEmbedEditing from './mediaembedediting.js';
|
15
|
+
import AutoMediaEmbed from './automediaembed.js';
|
16
|
+
import MediaEmbedUI from './mediaembedui.js';
|
17
|
+
import '../theme/mediaembed.css';
|
18
|
+
/**
|
19
|
+
* The media embed plugin.
|
20
|
+
*
|
21
|
+
* For a detailed overview, check the {@glink features/media-embed Media Embed feature documentation}.
|
22
|
+
*
|
23
|
+
* This is a "glue" plugin which loads the following plugins:
|
24
|
+
*
|
25
|
+
* * The {@link module:media-embed/mediaembedediting~MediaEmbedEditing media embed editing feature},
|
26
|
+
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
27
|
+
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
28
|
+
*/
|
29
|
+
export default class MediaEmbed extends Plugin {
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
static get requires(): readonly [typeof MediaEmbedEditing, typeof MediaEmbedUI, typeof AutoMediaEmbed, typeof Widget];
|
34
|
+
/**
|
35
|
+
* @inheritDoc
|
36
|
+
*/
|
37
|
+
static get pluginName(): "MediaEmbed";
|
38
|
+
}
|
@@ -0,0 +1,40 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
import { Command } from 'ckeditor5/src/core.js';
|
10
|
+
/**
|
11
|
+
* The insert media command.
|
12
|
+
*
|
13
|
+
* The command is registered by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} as `'mediaEmbed'`.
|
14
|
+
*
|
15
|
+
* To insert media at the current selection, execute the command and specify the URL:
|
16
|
+
*
|
17
|
+
* ```ts
|
18
|
+
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
19
|
+
* ```
|
20
|
+
*/
|
21
|
+
export default class MediaEmbedCommand extends Command {
|
22
|
+
/**
|
23
|
+
* Media url.
|
24
|
+
*/
|
25
|
+
value: string | undefined;
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
refresh(): void;
|
30
|
+
/**
|
31
|
+
* Executes the command, which either:
|
32
|
+
*
|
33
|
+
* * updates the URL of the selected media,
|
34
|
+
* * inserts the new media into the editor and puts the selection around it.
|
35
|
+
*
|
36
|
+
* @fires execute
|
37
|
+
* @param url The URL of the media.
|
38
|
+
*/
|
39
|
+
execute(url: string): void;
|
40
|
+
}
|
@@ -0,0 +1,282 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
import type { ToolbarConfigItem } from 'ckeditor5/src/core.js';
|
10
|
+
import type { ArrayOrItem } from 'ckeditor5/src/utils.js';
|
11
|
+
/**
|
12
|
+
* @module media-embed/mediaembedconfig
|
13
|
+
*/
|
14
|
+
/**
|
15
|
+
* The configuration of the media embed features.
|
16
|
+
*
|
17
|
+
* Read more about {@glink features/media-embed#configuration configuring the media embed feature}.
|
18
|
+
*
|
19
|
+
* ```ts
|
20
|
+
* ClassicEditor
|
21
|
+
* .create( editorElement, {
|
22
|
+
* mediaEmbed: ... // Media embed feature options.
|
23
|
+
* } )
|
24
|
+
* .then( ... )
|
25
|
+
* .catch( ... );
|
26
|
+
* ```
|
27
|
+
*
|
28
|
+
* See {@link module:core/editor/editorconfig~EditorConfig all editor options}.
|
29
|
+
*/
|
30
|
+
export interface MediaEmbedConfig {
|
31
|
+
/**
|
32
|
+
* The default media providers supported by the editor.
|
33
|
+
*
|
34
|
+
* The names of providers with rendering functions (previews):
|
35
|
+
*
|
36
|
+
* * "dailymotion",
|
37
|
+
* * "spotify",
|
38
|
+
* * "youtube",
|
39
|
+
* * "vimeo"
|
40
|
+
*
|
41
|
+
* The names of providers without rendering functions:
|
42
|
+
*
|
43
|
+
* * "instagram",
|
44
|
+
* * "twitter",
|
45
|
+
* * "googleMaps",
|
46
|
+
* * "flickr",
|
47
|
+
* * "facebook"
|
48
|
+
*
|
49
|
+
* See the {@link module:media-embed/mediaembedconfig~MediaEmbedProvider provider syntax} to learn more about
|
50
|
+
* different kinds of media and media providers.
|
51
|
+
*
|
52
|
+
* **Note**: The default media provider configuration may not support all possible media URLs,
|
53
|
+
* only the most common are included.
|
54
|
+
*
|
55
|
+
* Media without rendering functions are always represented in the data using the "semantic" markup. See
|
56
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#previewsInData `config.mediaEmbed.previewsInData`} to
|
57
|
+
* learn more about possible data outputs.
|
58
|
+
*
|
59
|
+
* The priority of media providers corresponds to the order of configuration. The first provider
|
60
|
+
* to match the URL is always used, even if there are other providers that support a particular URL.
|
61
|
+
* The URL is never matched against the remaining providers.
|
62
|
+
*
|
63
|
+
* To discard **all** default media providers, simply override this configuration with your own
|
64
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedProvider definitions}:
|
65
|
+
*
|
66
|
+
* ```ts
|
67
|
+
* ClassicEditor
|
68
|
+
* .create( editorElement, {
|
69
|
+
* plugins: [ MediaEmbed, ... ],
|
70
|
+
* mediaEmbed: {
|
71
|
+
* providers: [
|
72
|
+
* {
|
73
|
+
* name: 'myProvider',
|
74
|
+
* url: /^example\.com\/media\/(\w+)/,
|
75
|
+
* html: match => '...'
|
76
|
+
* },
|
77
|
+
* ...
|
78
|
+
* ]
|
79
|
+
* }
|
80
|
+
* } )
|
81
|
+
* .then( ... )
|
82
|
+
* .catch( ... );
|
83
|
+
* ```
|
84
|
+
*
|
85
|
+
* You can take inspiration from the default configuration of this feature which you can find in:
|
86
|
+
* https://github.com/ckeditor/ckeditor5-media-embed/blob/master/src/mediaembedediting.js
|
87
|
+
*
|
88
|
+
* To **extend** the list of default providers, use
|
89
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#extraProviders `config.mediaEmbed.extraProviders`}.
|
90
|
+
*
|
91
|
+
* To **remove** certain providers, use
|
92
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#removeProviders `config.mediaEmbed.removeProviders`}.
|
93
|
+
*/
|
94
|
+
providers?: Array<MediaEmbedProvider>;
|
95
|
+
/**
|
96
|
+
* The additional media providers supported by the editor. This configuration helps extend the default
|
97
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#providers}.
|
98
|
+
*
|
99
|
+
* ```ts
|
100
|
+
* ClassicEditor
|
101
|
+
* .create( editorElement, {
|
102
|
+
* plugins: [ MediaEmbed, ... ],
|
103
|
+
* mediaEmbed: {
|
104
|
+
* extraProviders: [
|
105
|
+
* {
|
106
|
+
* name: 'extraProvider',
|
107
|
+
* url: /^example\.com\/media\/(\w+)/,
|
108
|
+
* html: match => '...'
|
109
|
+
* },
|
110
|
+
* ...
|
111
|
+
* ]
|
112
|
+
* }
|
113
|
+
* } )
|
114
|
+
* .then( ... )
|
115
|
+
* .catch( ... );
|
116
|
+
* ```
|
117
|
+
*
|
118
|
+
* See the {@link module:media-embed/mediaembedconfig~MediaEmbedProvider provider syntax} to learn more.
|
119
|
+
*/
|
120
|
+
extraProviders?: Array<MediaEmbedProvider>;
|
121
|
+
/**
|
122
|
+
* The list of media providers that should not be used despite being available in
|
123
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#providers `config.mediaEmbed.providers`} and
|
124
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#extraProviders `config.mediaEmbed.extraProviders`}
|
125
|
+
*
|
126
|
+
* ```ts
|
127
|
+
* mediaEmbed: {
|
128
|
+
* removeProviders: [ 'youtube', 'twitter' ]
|
129
|
+
* }
|
130
|
+
* ```
|
131
|
+
*/
|
132
|
+
removeProviders?: Array<string>;
|
133
|
+
/**
|
134
|
+
* Overrides the element name used for "semantic" data.
|
135
|
+
*
|
136
|
+
* This is not relevant if
|
137
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#previewsInData `config.mediaEmbed.previewsInData`} is set to `true`.
|
138
|
+
*
|
139
|
+
* When not set, the feature produces the `<oembed>` tag:
|
140
|
+
*
|
141
|
+
* ```html
|
142
|
+
* <figure class="media">
|
143
|
+
* <oembed url="https://url"></oembed>
|
144
|
+
* </figure>
|
145
|
+
* ```
|
146
|
+
*
|
147
|
+
* To override the element name with, for instance, the `o-embed` name:
|
148
|
+
*
|
149
|
+
* ```ts
|
150
|
+
* mediaEmbed: {
|
151
|
+
* elementName: 'o-embed'
|
152
|
+
* }
|
153
|
+
* ```
|
154
|
+
*
|
155
|
+
* This will produce semantic data with the `<o-embed>` tag:
|
156
|
+
*
|
157
|
+
* ```html
|
158
|
+
* <figure class="media">
|
159
|
+
* <o-embed url="https://url"></o-embed>
|
160
|
+
* </figure>
|
161
|
+
* ```
|
162
|
+
*
|
163
|
+
* @default 'oembed'
|
164
|
+
*/
|
165
|
+
elementName?: string;
|
166
|
+
/**
|
167
|
+
* Controls the data format produced by the feature.
|
168
|
+
*
|
169
|
+
* When `false` (default), the feature produces "semantic" data, i.e. it does not include the preview of
|
170
|
+
* the media, just the `<oembed>` tag with the `url` attribute:
|
171
|
+
*
|
172
|
+
* ```ts
|
173
|
+
* <figure class="media">
|
174
|
+
* <oembed url="https://url"></oembed>
|
175
|
+
* </figure>
|
176
|
+
* ```
|
177
|
+
*
|
178
|
+
* When `true`, the media is represented in the output in the same way it looks in the editor,
|
179
|
+
* i.e. the media preview is saved to the database:
|
180
|
+
*
|
181
|
+
* ```ts
|
182
|
+
* <figure class="media">
|
183
|
+
* <div data-oembed-url="https://url">
|
184
|
+
* <iframe src="https://preview"></iframe>
|
185
|
+
* </div>
|
186
|
+
* </figure>
|
187
|
+
* ```
|
188
|
+
*
|
189
|
+
* **Note:** Media without preview are always represented in the data using the "semantic" markup
|
190
|
+
* regardless of the value of the `previewsInData`. Learn more about different kinds of media
|
191
|
+
* in the {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#providers `config.mediaEmbed.providers`}
|
192
|
+
* configuration description.
|
193
|
+
*
|
194
|
+
* @defualt false
|
195
|
+
*/
|
196
|
+
previewsInData?: boolean;
|
197
|
+
/**
|
198
|
+
* Items to be placed in the media embed toolbar.
|
199
|
+
* This option requires adding {@link module:media-embed/mediaembedtoolbar~MediaEmbedToolbar} to the plugin list.
|
200
|
+
*
|
201
|
+
* Read more about configuring toolbar in {@link module:core/editor/editorconfig~EditorConfig#toolbar}.
|
202
|
+
*/
|
203
|
+
toolbar?: Array<ToolbarConfigItem>;
|
204
|
+
}
|
205
|
+
/**
|
206
|
+
* The media embed provider descriptor. Used in
|
207
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#providers `config.mediaEmbed.providers`} and
|
208
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#extraProviders `config.mediaEmbed.extraProviders`}.
|
209
|
+
*
|
210
|
+
* See {@link module:media-embed/mediaembedconfig~MediaEmbedConfig} to learn more.
|
211
|
+
*
|
212
|
+
* ```ts
|
213
|
+
* {
|
214
|
+
* name: 'example',
|
215
|
+
*
|
216
|
+
* // The following RegExp matches https://www.example.com/media/{media id},
|
217
|
+
* // (either with "http(s)://" and "www" or without), so the valid URLs are:
|
218
|
+
* //
|
219
|
+
* // * https://www.example.com/media/{media id},
|
220
|
+
* // * http://www.example.com/media/{media id},
|
221
|
+
* // * www.example.com/media/{media id},
|
222
|
+
* // * example.com/media/{media id}
|
223
|
+
* url: /^example\.com\/media\/(\w+)/,
|
224
|
+
*
|
225
|
+
* // The rendering function of the provider.
|
226
|
+
* // Used to represent the media when editing the content (i.e. in the view)
|
227
|
+
* // and also in the data output of the editor if semantic data output is disabled.
|
228
|
+
* html: match => `The HTML representing the media with ID=${ match[ 1 ] }.`
|
229
|
+
* }
|
230
|
+
* ```
|
231
|
+
*
|
232
|
+
* You can allow any sort of media in the editor using the "allow–all" `RegExp`.
|
233
|
+
* But mind that, since URLs are processed in the order of configuration, if one of the previous
|
234
|
+
* `RegExps` matches the URL, it will have a precedence over this one.
|
235
|
+
*
|
236
|
+
* ```ts
|
237
|
+
* {
|
238
|
+
* name: 'allow-all',
|
239
|
+
* url: /^.+/
|
240
|
+
* }
|
241
|
+
* ```
|
242
|
+
*
|
243
|
+
* To implement responsive media, you can use the following HTML structure:
|
244
|
+
*
|
245
|
+
* ```ts
|
246
|
+
* {
|
247
|
+
* ...
|
248
|
+
* html: match =>
|
249
|
+
* '<div style="position:relative; padding-bottom:100%; height:0">' +
|
250
|
+
* '<iframe src="..." frameborder="0" ' +
|
251
|
+
* 'style="position:absolute; width:100%; height:100%; top:0; left:0">' +
|
252
|
+
* '</iframe>' +
|
253
|
+
* '</div>'
|
254
|
+
* }
|
255
|
+
* ```
|
256
|
+
*/
|
257
|
+
export interface MediaEmbedProvider {
|
258
|
+
/**
|
259
|
+
* The name of the provider. Used e.g. when
|
260
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#removeProviders removing providers}.
|
261
|
+
*/
|
262
|
+
name: string;
|
263
|
+
/**
|
264
|
+
* The `RegExp` object (or array of objects) defining the URL of the media.
|
265
|
+
* If any URL matches the `RegExp`, it becomes the media in the editor model, as defined by the provider. The result
|
266
|
+
* of matching (output of `String.prototype.match()`) is passed to the `html` rendering function of the media.
|
267
|
+
*
|
268
|
+
* **Note:** You do not need to include the protocol (`http://`, `https://`) and `www` subdomain in your `RegExps`,
|
269
|
+
* they are stripped from the URLs before matching anyway.
|
270
|
+
*/
|
271
|
+
url: ArrayOrItem<RegExp>;
|
272
|
+
/**
|
273
|
+
* The rendering function of the media. The function receives the entire matching
|
274
|
+
* array from the corresponding `url` `RegExp` as an argument, allowing rendering a dedicated
|
275
|
+
* preview of the media identified by a certain ID or a hash. When not defined, the media embed feature
|
276
|
+
* will use a generic media representation in the view and output data.
|
277
|
+
* Note that when
|
278
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#previewsInData `config.mediaEmbed.previewsInData`}
|
279
|
+
* is `true`, the rendering function **will always** be used for the media in the editor data output.
|
280
|
+
*/
|
281
|
+
html?: (match: RegExpMatchArray) => string;
|
282
|
+
}
|
@@ -0,0 +1,35 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/mediaembedediting
|
11
|
+
*/
|
12
|
+
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
13
|
+
import MediaRegistry from './mediaregistry.js';
|
14
|
+
import '../theme/mediaembedediting.css';
|
15
|
+
/**
|
16
|
+
* The media embed editing feature.
|
17
|
+
*/
|
18
|
+
export default class MediaEmbedEditing extends Plugin {
|
19
|
+
/**
|
20
|
+
* @inheritDoc
|
21
|
+
*/
|
22
|
+
static get pluginName(): "MediaEmbedEditing";
|
23
|
+
/**
|
24
|
+
* The media registry managing the media providers in the editor.
|
25
|
+
*/
|
26
|
+
registry: MediaRegistry;
|
27
|
+
/**
|
28
|
+
* @inheritDoc
|
29
|
+
*/
|
30
|
+
constructor(editor: Editor);
|
31
|
+
/**
|
32
|
+
* @inheritDoc
|
33
|
+
*/
|
34
|
+
init(): void;
|
35
|
+
}
|
@@ -0,0 +1,34 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/mediaembedtoolbar
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import { WidgetToolbarRepository } from 'ckeditor5/src/widget.js';
|
14
|
+
import './mediaembedconfig.js';
|
15
|
+
/**
|
16
|
+
* The media embed toolbar plugin. It creates a toolbar for media embed that shows up when the media element is selected.
|
17
|
+
*
|
18
|
+
* Instances of toolbar components (e.g. buttons) are created based on the
|
19
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#toolbar `media.toolbar` configuration option}.
|
20
|
+
*/
|
21
|
+
export default class MediaEmbedToolbar extends Plugin {
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get requires(): readonly [typeof WidgetToolbarRepository];
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get pluginName(): "MediaEmbedToolbar";
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
afterInit(): void;
|
34
|
+
}
|
@@ -0,0 +1,31 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/mediaembedui
|
11
|
+
*/
|
12
|
+
import { Plugin } from 'ckeditor5/src/core.js';
|
13
|
+
import MediaEmbedEditing from './mediaembedediting.js';
|
14
|
+
/**
|
15
|
+
* The media embed UI plugin.
|
16
|
+
*/
|
17
|
+
export default class MediaEmbedUI extends Plugin {
|
18
|
+
/**
|
19
|
+
* @inheritDoc
|
20
|
+
*/
|
21
|
+
static get requires(): readonly [typeof MediaEmbedEditing];
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
static get pluginName(): "MediaEmbedUI";
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
init(): void;
|
30
|
+
private _setUpDropdown;
|
31
|
+
}
|
@@ -0,0 +1,70 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/mediaregistry
|
11
|
+
*/
|
12
|
+
import type { DowncastWriter, ViewElement } from 'ckeditor5/src/engine.js';
|
13
|
+
import { type Locale } from 'ckeditor5/src/utils.js';
|
14
|
+
import type { MediaEmbedConfig, MediaEmbedProvider } from './mediaembedconfig.js';
|
15
|
+
import type { MediaOptions } from './utils.js';
|
16
|
+
/**
|
17
|
+
* A bridge between the raw media content provider definitions and the editor view content.
|
18
|
+
*
|
19
|
+
* It helps translating media URLs to corresponding {@link module:engine/view/element~Element view elements}.
|
20
|
+
*
|
21
|
+
* Mostly used by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} plugin.
|
22
|
+
*/
|
23
|
+
export default class MediaRegistry {
|
24
|
+
/**
|
25
|
+
* The {@link module:utils/locale~Locale} instance.
|
26
|
+
*/
|
27
|
+
locale: Locale;
|
28
|
+
/**
|
29
|
+
* The media provider definitions available for the registry. Usually corresponding with the
|
30
|
+
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig media configuration}.
|
31
|
+
*/
|
32
|
+
providerDefinitions: Array<MediaEmbedProvider>;
|
33
|
+
/**
|
34
|
+
* Creates an instance of the {@link module:media-embed/mediaregistry~MediaRegistry} class.
|
35
|
+
*
|
36
|
+
* @param locale The localization services instance.
|
37
|
+
* @param config The configuration of the media embed feature.
|
38
|
+
*/
|
39
|
+
constructor(locale: Locale, config: MediaEmbedConfig);
|
40
|
+
/**
|
41
|
+
* Checks whether the passed URL is representing a certain media type allowed in the editor.
|
42
|
+
*
|
43
|
+
* @param url The URL to be checked
|
44
|
+
*/
|
45
|
+
hasMedia(url: string): boolean;
|
46
|
+
/**
|
47
|
+
* For the given media URL string and options, it returns the {@link module:engine/view/element~Element view element}
|
48
|
+
* representing that media.
|
49
|
+
*
|
50
|
+
* **Note:** If no URL is specified, an empty view element is returned.
|
51
|
+
*
|
52
|
+
* @param writer The view writer used to produce a view element.
|
53
|
+
* @param url The URL to be translated into a view element.
|
54
|
+
*/
|
55
|
+
getMediaViewElement(writer: DowncastWriter, url: string, options: MediaOptions): ViewElement;
|
56
|
+
/**
|
57
|
+
* Returns a `Media` instance for the given URL.
|
58
|
+
*
|
59
|
+
* @param url The URL of the media.
|
60
|
+
* @returns The `Media` instance or `null` when there is none.
|
61
|
+
*/
|
62
|
+
private _getMedia;
|
63
|
+
/**
|
64
|
+
* Tries to match `url` to `pattern`.
|
65
|
+
*
|
66
|
+
* @param url The URL of the media.
|
67
|
+
* @param pattern The pattern that should accept the media URL.
|
68
|
+
*/
|
69
|
+
private _getUrlMatches;
|
70
|
+
}
|
@@ -0,0 +1,119 @@
|
|
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
|
+
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved.
|
7
|
+
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
8
|
+
*/
|
9
|
+
/**
|
10
|
+
* @module media-embed/ui/mediaformview
|
11
|
+
*/
|
12
|
+
import { type InputTextView, ButtonView, LabeledFieldView, View } from 'ckeditor5/src/ui.js';
|
13
|
+
import { FocusTracker, KeystrokeHandler, type Locale } from 'ckeditor5/src/utils.js';
|
14
|
+
import '@ckeditor/ckeditor5-ui/theme/components/responsive-form/responsiveform.css';
|
15
|
+
import '../../theme/mediaform.css';
|
16
|
+
/**
|
17
|
+
* The media form view controller class.
|
18
|
+
*
|
19
|
+
* See {@link module:media-embed/ui/mediaformview~MediaFormView}.
|
20
|
+
*/
|
21
|
+
export default class MediaFormView extends View {
|
22
|
+
/**
|
23
|
+
* Tracks information about the DOM focus in the form.
|
24
|
+
*/
|
25
|
+
readonly focusTracker: FocusTracker;
|
26
|
+
/**
|
27
|
+
* An instance of the {@link module:utils/keystrokehandler~KeystrokeHandler}.
|
28
|
+
*/
|
29
|
+
readonly keystrokes: KeystrokeHandler;
|
30
|
+
/**
|
31
|
+
* The value of the URL input.
|
32
|
+
*/
|
33
|
+
mediaURLInputValue: string;
|
34
|
+
/**
|
35
|
+
* The URL input view.
|
36
|
+
*/
|
37
|
+
urlInputView: LabeledFieldView<InputTextView>;
|
38
|
+
/**
|
39
|
+
* The Save button view.
|
40
|
+
*/
|
41
|
+
saveButtonView: ButtonView;
|
42
|
+
/**
|
43
|
+
* The Cancel button view.
|
44
|
+
*/
|
45
|
+
cancelButtonView: ButtonView;
|
46
|
+
/**
|
47
|
+
* A collection of views that can be focused in the form.
|
48
|
+
*/
|
49
|
+
private readonly _focusables;
|
50
|
+
/**
|
51
|
+
* Helps cycling over {@link #_focusables} in the form.
|
52
|
+
*/
|
53
|
+
private readonly _focusCycler;
|
54
|
+
/**
|
55
|
+
* An array of form validators used by {@link #isValid}.
|
56
|
+
*/
|
57
|
+
private readonly _validators;
|
58
|
+
/**
|
59
|
+
* The default info text for the {@link #urlInputView}.
|
60
|
+
*/
|
61
|
+
private _urlInputViewInfoDefault?;
|
62
|
+
/**
|
63
|
+
* The info text with an additional tip for the {@link #urlInputView},
|
64
|
+
* displayed when the input has some value.
|
65
|
+
*/
|
66
|
+
private _urlInputViewInfoTip?;
|
67
|
+
/**
|
68
|
+
* @param validators Form validators used by {@link #isValid}.
|
69
|
+
* @param locale The localization services instance.
|
70
|
+
*/
|
71
|
+
constructor(validators: Array<(v: MediaFormView) => string | undefined>, locale: Locale);
|
72
|
+
/**
|
73
|
+
* @inheritDoc
|
74
|
+
*/
|
75
|
+
render(): void;
|
76
|
+
/**
|
77
|
+
* @inheritDoc
|
78
|
+
*/
|
79
|
+
destroy(): void;
|
80
|
+
/**
|
81
|
+
* Focuses the fist {@link #_focusables} in the form.
|
82
|
+
*/
|
83
|
+
focus(): void;
|
84
|
+
/**
|
85
|
+
* The native DOM `value` of the {@link #urlInputView} element.
|
86
|
+
*
|
87
|
+
* **Note**: Do not confuse it with the {@link module:ui/inputtext/inputtextview~InputTextView#value}
|
88
|
+
* which works one way only and may not represent the actual state of the component in the DOM.
|
89
|
+
*/
|
90
|
+
get url(): string;
|
91
|
+
set url(url: string);
|
92
|
+
/**
|
93
|
+
* Validates the form and returns `false` when some fields are invalid.
|
94
|
+
*/
|
95
|
+
isValid(): boolean;
|
96
|
+
/**
|
97
|
+
* Cleans up the supplementary error and information text of the {@link #urlInputView}
|
98
|
+
* bringing them back to the state when the form has been displayed for the first time.
|
99
|
+
*
|
100
|
+
* See {@link #isValid}.
|
101
|
+
*/
|
102
|
+
resetFormStatus(): void;
|
103
|
+
/**
|
104
|
+
* Creates a labeled input view.
|
105
|
+
*
|
106
|
+
* @returns Labeled input view instance.
|
107
|
+
*/
|
108
|
+
private _createUrlInput;
|
109
|
+
/**
|
110
|
+
* Creates a button view.
|
111
|
+
*
|
112
|
+
* @param label The button label.
|
113
|
+
* @param icon The button icon.
|
114
|
+
* @param className The additional button CSS class name.
|
115
|
+
* @param eventName An event name that the `ButtonView#execute` event will be delegated to.
|
116
|
+
* @returns The button view instance.
|
117
|
+
*/
|
118
|
+
private _createButton;
|
119
|
+
}
|