@ckeditor/ckeditor5-media-embed 40.0.0 → 40.1.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/LICENSE.md +2 -2
- package/package.json +3 -3
- package/src/augmentation.d.ts +25 -25
- package/src/augmentation.js +5 -5
- package/src/automediaembed.d.ts +51 -51
- package/src/automediaembed.js +131 -131
- package/src/converters.d.ts +38 -38
- package/src/converters.js +53 -53
- package/src/index.d.ts +15 -15
- package/src/index.js +13 -13
- package/src/mediaembed.d.ts +34 -34
- package/src/mediaembed.js +38 -38
- package/src/mediaembedcommand.d.ts +36 -36
- package/src/mediaembedcommand.js +71 -71
- package/src/mediaembedconfig.d.ts +278 -278
- package/src/mediaembedconfig.js +5 -5
- package/src/mediaembedediting.d.ts +31 -31
- package/src/mediaembedediting.js +231 -231
- package/src/mediaembedtoolbar.d.ts +30 -30
- package/src/mediaembedtoolbar.js +44 -44
- package/src/mediaembedui.d.ts +27 -27
- package/src/mediaembedui.js +99 -99
- package/src/mediaregistry.d.ts +66 -66
- package/src/mediaregistry.js +232 -232
- package/src/ui/mediaformview.d.ts +115 -115
- package/src/ui/mediaformview.js +194 -194
- package/src/utils.d.ts +67 -67
- package/src/utils.js +85 -85
- package/theme/icons/media/twitter.svg +0 -0
- package/build/media-embed.js.map +0 -1
package/src/index.d.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
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
|
7
|
-
*/
|
8
|
-
export { default as MediaEmbed } from './mediaembed';
|
9
|
-
export { default as MediaEmbedEditing } from './mediaembedediting';
|
10
|
-
export { default as MediaEmbedUI } from './mediaembedui';
|
11
|
-
export { default as AutoMediaEmbed } from './automediaembed';
|
12
|
-
export { default as MediaEmbedToolbar } from './mediaembedtoolbar';
|
13
|
-
export type { MediaEmbedConfig } from './mediaembedconfig';
|
14
|
-
export type { default as MediaEmbedCommand } from './mediaembedcommand';
|
15
|
-
import './augmentation';
|
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
|
7
|
+
*/
|
8
|
+
export { default as MediaEmbed } from './mediaembed';
|
9
|
+
export { default as MediaEmbedEditing } from './mediaembedediting';
|
10
|
+
export { default as MediaEmbedUI } from './mediaembedui';
|
11
|
+
export { default as AutoMediaEmbed } from './automediaembed';
|
12
|
+
export { default as MediaEmbedToolbar } from './mediaembedtoolbar';
|
13
|
+
export type { MediaEmbedConfig } from './mediaembedconfig';
|
14
|
+
export type { default as MediaEmbedCommand } from './mediaembedcommand';
|
15
|
+
import './augmentation';
|
package/src/index.js
CHANGED
@@ -1,13 +1,13 @@
|
|
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
|
7
|
-
*/
|
8
|
-
export { default as MediaEmbed } from './mediaembed';
|
9
|
-
export { default as MediaEmbedEditing } from './mediaembedediting';
|
10
|
-
export { default as MediaEmbedUI } from './mediaembedui';
|
11
|
-
export { default as AutoMediaEmbed } from './automediaembed';
|
12
|
-
export { default as MediaEmbedToolbar } from './mediaembedtoolbar';
|
13
|
-
import './augmentation';
|
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
|
7
|
+
*/
|
8
|
+
export { default as MediaEmbed } from './mediaembed';
|
9
|
+
export { default as MediaEmbedEditing } from './mediaembedediting';
|
10
|
+
export { default as MediaEmbedUI } from './mediaembedui';
|
11
|
+
export { default as AutoMediaEmbed } from './automediaembed';
|
12
|
+
export { default as MediaEmbedToolbar } from './mediaembedtoolbar';
|
13
|
+
import './augmentation';
|
package/src/mediaembed.d.ts
CHANGED
@@ -1,34 +1,34 @@
|
|
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/mediaembed
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import { Widget } from 'ckeditor5/src/widget';
|
10
|
-
import MediaEmbedEditing from './mediaembedediting';
|
11
|
-
import AutoMediaEmbed from './automediaembed';
|
12
|
-
import MediaEmbedUI from './mediaembedui';
|
13
|
-
import '../theme/mediaembed.css';
|
14
|
-
/**
|
15
|
-
* The media embed plugin.
|
16
|
-
*
|
17
|
-
* For a detailed overview, check the {@glink features/media-embed Media Embed feature documentation}.
|
18
|
-
*
|
19
|
-
* This is a "glue" plugin which loads the following plugins:
|
20
|
-
*
|
21
|
-
* * The {@link module:media-embed/mediaembedediting~MediaEmbedEditing media embed editing feature},
|
22
|
-
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
|
-
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
|
-
*/
|
25
|
-
export default class MediaEmbed extends Plugin {
|
26
|
-
/**
|
27
|
-
* @inheritDoc
|
28
|
-
*/
|
29
|
-
static get requires(): readonly [typeof MediaEmbedEditing, typeof MediaEmbedUI, typeof AutoMediaEmbed, typeof Widget];
|
30
|
-
/**
|
31
|
-
* @inheritDoc
|
32
|
-
*/
|
33
|
-
static get pluginName(): "MediaEmbed";
|
34
|
-
}
|
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/mediaembed
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import { Widget } from 'ckeditor5/src/widget';
|
10
|
+
import MediaEmbedEditing from './mediaembedediting';
|
11
|
+
import AutoMediaEmbed from './automediaembed';
|
12
|
+
import MediaEmbedUI from './mediaembedui';
|
13
|
+
import '../theme/mediaembed.css';
|
14
|
+
/**
|
15
|
+
* The media embed plugin.
|
16
|
+
*
|
17
|
+
* For a detailed overview, check the {@glink features/media-embed Media Embed feature documentation}.
|
18
|
+
*
|
19
|
+
* This is a "glue" plugin which loads the following plugins:
|
20
|
+
*
|
21
|
+
* * The {@link module:media-embed/mediaembedediting~MediaEmbedEditing media embed editing feature},
|
22
|
+
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
|
+
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
|
+
*/
|
25
|
+
export default class MediaEmbed extends Plugin {
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get requires(): readonly [typeof MediaEmbedEditing, typeof MediaEmbedUI, typeof AutoMediaEmbed, typeof Widget];
|
30
|
+
/**
|
31
|
+
* @inheritDoc
|
32
|
+
*/
|
33
|
+
static get pluginName(): "MediaEmbed";
|
34
|
+
}
|
package/src/mediaembed.js
CHANGED
@@ -1,38 +1,38 @@
|
|
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/mediaembed
|
7
|
-
*/
|
8
|
-
import { Plugin } from 'ckeditor5/src/core';
|
9
|
-
import { Widget } from 'ckeditor5/src/widget';
|
10
|
-
import MediaEmbedEditing from './mediaembedediting';
|
11
|
-
import AutoMediaEmbed from './automediaembed';
|
12
|
-
import MediaEmbedUI from './mediaembedui';
|
13
|
-
import '../theme/mediaembed.css';
|
14
|
-
/**
|
15
|
-
* The media embed plugin.
|
16
|
-
*
|
17
|
-
* For a detailed overview, check the {@glink features/media-embed Media Embed feature documentation}.
|
18
|
-
*
|
19
|
-
* This is a "glue" plugin which loads the following plugins:
|
20
|
-
*
|
21
|
-
* * The {@link module:media-embed/mediaembedediting~MediaEmbedEditing media embed editing feature},
|
22
|
-
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
|
-
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
|
-
*/
|
25
|
-
export default class MediaEmbed extends Plugin {
|
26
|
-
/**
|
27
|
-
* @inheritDoc
|
28
|
-
*/
|
29
|
-
static get requires() {
|
30
|
-
return [MediaEmbedEditing, MediaEmbedUI, AutoMediaEmbed, Widget];
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* @inheritDoc
|
34
|
-
*/
|
35
|
-
static get pluginName() {
|
36
|
-
return 'MediaEmbed';
|
37
|
-
}
|
38
|
-
}
|
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/mediaembed
|
7
|
+
*/
|
8
|
+
import { Plugin } from 'ckeditor5/src/core';
|
9
|
+
import { Widget } from 'ckeditor5/src/widget';
|
10
|
+
import MediaEmbedEditing from './mediaembedediting';
|
11
|
+
import AutoMediaEmbed from './automediaembed';
|
12
|
+
import MediaEmbedUI from './mediaembedui';
|
13
|
+
import '../theme/mediaembed.css';
|
14
|
+
/**
|
15
|
+
* The media embed plugin.
|
16
|
+
*
|
17
|
+
* For a detailed overview, check the {@glink features/media-embed Media Embed feature documentation}.
|
18
|
+
*
|
19
|
+
* This is a "glue" plugin which loads the following plugins:
|
20
|
+
*
|
21
|
+
* * The {@link module:media-embed/mediaembedediting~MediaEmbedEditing media embed editing feature},
|
22
|
+
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
|
+
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
|
+
*/
|
25
|
+
export default class MediaEmbed extends Plugin {
|
26
|
+
/**
|
27
|
+
* @inheritDoc
|
28
|
+
*/
|
29
|
+
static get requires() {
|
30
|
+
return [MediaEmbedEditing, MediaEmbedUI, AutoMediaEmbed, Widget];
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* @inheritDoc
|
34
|
+
*/
|
35
|
+
static get pluginName() {
|
36
|
+
return 'MediaEmbed';
|
37
|
+
}
|
38
|
+
}
|
@@ -1,36 +1,36 @@
|
|
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
|
-
import { Command } from 'ckeditor5/src/core';
|
6
|
-
/**
|
7
|
-
* The insert media command.
|
8
|
-
*
|
9
|
-
* The command is registered by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} as `'mediaEmbed'`.
|
10
|
-
*
|
11
|
-
* To insert media at the current selection, execute the command and specify the URL:
|
12
|
-
*
|
13
|
-
* ```ts
|
14
|
-
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
15
|
-
* ```
|
16
|
-
*/
|
17
|
-
export default class MediaEmbedCommand extends Command {
|
18
|
-
/**
|
19
|
-
* Media url.
|
20
|
-
*/
|
21
|
-
value: string | undefined;
|
22
|
-
/**
|
23
|
-
* @inheritDoc
|
24
|
-
*/
|
25
|
-
refresh(): void;
|
26
|
-
/**
|
27
|
-
* Executes the command, which either:
|
28
|
-
*
|
29
|
-
* * updates the URL of the selected media,
|
30
|
-
* * inserts the new media into the editor and puts the selection around it.
|
31
|
-
*
|
32
|
-
* @fires execute
|
33
|
-
* @param url The URL of the media.
|
34
|
-
*/
|
35
|
-
execute(url: string): void;
|
36
|
-
}
|
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
|
+
import { Command } from 'ckeditor5/src/core';
|
6
|
+
/**
|
7
|
+
* The insert media command.
|
8
|
+
*
|
9
|
+
* The command is registered by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} as `'mediaEmbed'`.
|
10
|
+
*
|
11
|
+
* To insert media at the current selection, execute the command and specify the URL:
|
12
|
+
*
|
13
|
+
* ```ts
|
14
|
+
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
15
|
+
* ```
|
16
|
+
*/
|
17
|
+
export default class MediaEmbedCommand extends Command {
|
18
|
+
/**
|
19
|
+
* Media url.
|
20
|
+
*/
|
21
|
+
value: string | undefined;
|
22
|
+
/**
|
23
|
+
* @inheritDoc
|
24
|
+
*/
|
25
|
+
refresh(): void;
|
26
|
+
/**
|
27
|
+
* Executes the command, which either:
|
28
|
+
*
|
29
|
+
* * updates the URL of the selected media,
|
30
|
+
* * inserts the new media into the editor and puts the selection around it.
|
31
|
+
*
|
32
|
+
* @fires execute
|
33
|
+
* @param url The URL of the media.
|
34
|
+
*/
|
35
|
+
execute(url: string): void;
|
36
|
+
}
|
package/src/mediaembedcommand.js
CHANGED
@@ -1,71 +1,71 @@
|
|
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
|
-
import { Command } from 'ckeditor5/src/core';
|
6
|
-
import { findOptimalInsertionRange } from 'ckeditor5/src/widget';
|
7
|
-
import { getSelectedMediaModelWidget, insertMedia } from './utils';
|
8
|
-
/**
|
9
|
-
* The insert media command.
|
10
|
-
*
|
11
|
-
* The command is registered by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} as `'mediaEmbed'`.
|
12
|
-
*
|
13
|
-
* To insert media at the current selection, execute the command and specify the URL:
|
14
|
-
*
|
15
|
-
* ```ts
|
16
|
-
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
17
|
-
* ```
|
18
|
-
*/
|
19
|
-
export default class MediaEmbedCommand extends Command {
|
20
|
-
/**
|
21
|
-
* @inheritDoc
|
22
|
-
*/
|
23
|
-
refresh() {
|
24
|
-
const model = this.editor.model;
|
25
|
-
const selection = model.document.selection;
|
26
|
-
const selectedMedia = getSelectedMediaModelWidget(selection);
|
27
|
-
this.value = selectedMedia ? selectedMedia.getAttribute('url') : undefined;
|
28
|
-
this.isEnabled = isMediaSelected(selection) || isAllowedInParent(selection, model);
|
29
|
-
}
|
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) {
|
40
|
-
const model = this.editor.model;
|
41
|
-
const selection = model.document.selection;
|
42
|
-
const selectedMedia = getSelectedMediaModelWidget(selection);
|
43
|
-
if (selectedMedia) {
|
44
|
-
model.change(writer => {
|
45
|
-
writer.setAttribute('url', url, selectedMedia);
|
46
|
-
});
|
47
|
-
}
|
48
|
-
else {
|
49
|
-
insertMedia(model, url, selection, true);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
/**
|
54
|
-
* Checks if the media embed is allowed in the parent.
|
55
|
-
*/
|
56
|
-
function isAllowedInParent(selection, model) {
|
57
|
-
const insertionRange = findOptimalInsertionRange(selection, model);
|
58
|
-
let parent = insertionRange.start.parent;
|
59
|
-
// The model.insertContent() will remove empty parent (unless it is a $root or a limit).
|
60
|
-
if (parent.isEmpty && !model.schema.isLimit(parent)) {
|
61
|
-
parent = parent.parent;
|
62
|
-
}
|
63
|
-
return model.schema.checkChild(parent, 'media');
|
64
|
-
}
|
65
|
-
/**
|
66
|
-
* Checks if the media object is selected.
|
67
|
-
*/
|
68
|
-
function isMediaSelected(selection) {
|
69
|
-
const element = selection.getSelectedElement();
|
70
|
-
return !!element && element.name === 'media';
|
71
|
-
}
|
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
|
+
import { Command } from 'ckeditor5/src/core';
|
6
|
+
import { findOptimalInsertionRange } from 'ckeditor5/src/widget';
|
7
|
+
import { getSelectedMediaModelWidget, insertMedia } from './utils';
|
8
|
+
/**
|
9
|
+
* The insert media command.
|
10
|
+
*
|
11
|
+
* The command is registered by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} as `'mediaEmbed'`.
|
12
|
+
*
|
13
|
+
* To insert media at the current selection, execute the command and specify the URL:
|
14
|
+
*
|
15
|
+
* ```ts
|
16
|
+
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
17
|
+
* ```
|
18
|
+
*/
|
19
|
+
export default class MediaEmbedCommand extends Command {
|
20
|
+
/**
|
21
|
+
* @inheritDoc
|
22
|
+
*/
|
23
|
+
refresh() {
|
24
|
+
const model = this.editor.model;
|
25
|
+
const selection = model.document.selection;
|
26
|
+
const selectedMedia = getSelectedMediaModelWidget(selection);
|
27
|
+
this.value = selectedMedia ? selectedMedia.getAttribute('url') : undefined;
|
28
|
+
this.isEnabled = isMediaSelected(selection) || isAllowedInParent(selection, model);
|
29
|
+
}
|
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) {
|
40
|
+
const model = this.editor.model;
|
41
|
+
const selection = model.document.selection;
|
42
|
+
const selectedMedia = getSelectedMediaModelWidget(selection);
|
43
|
+
if (selectedMedia) {
|
44
|
+
model.change(writer => {
|
45
|
+
writer.setAttribute('url', url, selectedMedia);
|
46
|
+
});
|
47
|
+
}
|
48
|
+
else {
|
49
|
+
insertMedia(model, url, selection, true);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
/**
|
54
|
+
* Checks if the media embed is allowed in the parent.
|
55
|
+
*/
|
56
|
+
function isAllowedInParent(selection, model) {
|
57
|
+
const insertionRange = findOptimalInsertionRange(selection, model);
|
58
|
+
let parent = insertionRange.start.parent;
|
59
|
+
// The model.insertContent() will remove empty parent (unless it is a $root or a limit).
|
60
|
+
if (parent.isEmpty && !model.schema.isLimit(parent)) {
|
61
|
+
parent = parent.parent;
|
62
|
+
}
|
63
|
+
return model.schema.checkChild(parent, 'media');
|
64
|
+
}
|
65
|
+
/**
|
66
|
+
* Checks if the media object is selected.
|
67
|
+
*/
|
68
|
+
function isMediaSelected(selection) {
|
69
|
+
const element = selection.getSelectedElement();
|
70
|
+
return !!element && element.name === 'media';
|
71
|
+
}
|