@ckeditor/ckeditor5-media-embed 45.2.1 → 46.0.0-alpha.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.js +23 -12
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
- package/src/automediaembed.d.ts +1 -1
- package/src/automediaembed.js +8 -8
- package/src/converters.d.ts +1 -1
- package/src/index.d.ts +11 -6
- package/src/index.js +10 -5
- package/src/mediaembed.d.ts +4 -4
- package/src/mediaembed.js +4 -4
- package/src/mediaembedcommand.d.ts +1 -1
- package/src/mediaembedcommand.js +1 -1
- package/src/mediaembedediting.d.ts +2 -2
- package/src/mediaembedediting.js +3 -3
- package/src/mediaembedtoolbar.d.ts +1 -1
- package/src/mediaembedtoolbar.js +1 -1
- package/src/mediaembedui.d.ts +2 -2
- package/src/mediaembedui.js +3 -3
- package/src/mediaregistry.d.ts +5 -5
- package/src/mediaregistry.js +4 -4
- package/src/ui/mediaformview.d.ts +1 -1
- package/src/ui/mediaformview.js +1 -1
- package/src/utils.d.ts +19 -8
- package/src/utils.js +13 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ckeditor/ckeditor5-media-embed",
|
3
|
-
"version": "
|
3
|
+
"version": "46.0.0-alpha.0",
|
4
4
|
"description": "Media embed feature for CKEditor 5.",
|
5
5
|
"keywords": [
|
6
6
|
"ckeditor",
|
@@ -13,16 +13,16 @@
|
|
13
13
|
"type": "module",
|
14
14
|
"main": "src/index.js",
|
15
15
|
"dependencies": {
|
16
|
-
"@ckeditor/ckeditor5-clipboard": "
|
17
|
-
"@ckeditor/ckeditor5-core": "
|
18
|
-
"@ckeditor/ckeditor5-engine": "
|
19
|
-
"@ckeditor/ckeditor5-icons": "
|
20
|
-
"@ckeditor/ckeditor5-typing": "
|
21
|
-
"@ckeditor/ckeditor5-ui": "
|
22
|
-
"@ckeditor/ckeditor5-undo": "
|
23
|
-
"@ckeditor/ckeditor5-utils": "
|
24
|
-
"@ckeditor/ckeditor5-widget": "
|
25
|
-
"ckeditor5": "
|
16
|
+
"@ckeditor/ckeditor5-clipboard": "46.0.0-alpha.0",
|
17
|
+
"@ckeditor/ckeditor5-core": "46.0.0-alpha.0",
|
18
|
+
"@ckeditor/ckeditor5-engine": "46.0.0-alpha.0",
|
19
|
+
"@ckeditor/ckeditor5-icons": "46.0.0-alpha.0",
|
20
|
+
"@ckeditor/ckeditor5-typing": "46.0.0-alpha.0",
|
21
|
+
"@ckeditor/ckeditor5-ui": "46.0.0-alpha.0",
|
22
|
+
"@ckeditor/ckeditor5-undo": "46.0.0-alpha.0",
|
23
|
+
"@ckeditor/ckeditor5-utils": "46.0.0-alpha.0",
|
24
|
+
"@ckeditor/ckeditor5-widget": "46.0.0-alpha.0",
|
25
|
+
"ckeditor5": "46.0.0-alpha.0"
|
26
26
|
},
|
27
27
|
"author": "CKSource (http://cksource.com/)",
|
28
28
|
"license": "SEE LICENSE IN LICENSE.md",
|
package/src/automediaembed.d.ts
CHANGED
@@ -13,7 +13,7 @@ import { Undo } from 'ckeditor5/src/undo.js';
|
|
13
13
|
* The auto-media embed plugin. It recognizes media links in the pasted content and embeds
|
14
14
|
* them shortly after they are injected into the document.
|
15
15
|
*/
|
16
|
-
export
|
16
|
+
export declare class AutoMediaEmbed extends Plugin {
|
17
17
|
/**
|
18
18
|
* @inheritDoc
|
19
19
|
*/
|
package/src/automediaembed.js
CHANGED
@@ -6,19 +6,19 @@
|
|
6
6
|
* @module media-embed/automediaembed
|
7
7
|
*/
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
|
-
import {
|
9
|
+
import { ModelLiveRange, ModelLivePosition } from 'ckeditor5/src/engine.js';
|
10
10
|
import { Clipboard } from 'ckeditor5/src/clipboard.js';
|
11
11
|
import { Delete } from 'ckeditor5/src/typing.js';
|
12
12
|
import { Undo } from 'ckeditor5/src/undo.js';
|
13
13
|
import { global } from 'ckeditor5/src/utils.js';
|
14
|
-
import MediaEmbedEditing from './mediaembedediting.js';
|
14
|
+
import { MediaEmbedEditing } from './mediaembedediting.js';
|
15
15
|
import { insertMedia } from './utils.js';
|
16
16
|
const URL_REGEXP = /^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;
|
17
17
|
/**
|
18
18
|
* The auto-media embed plugin. It recognizes media links in the pasted content and embeds
|
19
19
|
* them shortly after they are injected into the document.
|
20
20
|
*/
|
21
|
-
export
|
21
|
+
export class AutoMediaEmbed extends Plugin {
|
22
22
|
/**
|
23
23
|
* @inheritDoc
|
24
24
|
*/
|
@@ -67,9 +67,9 @@ export default class AutoMediaEmbed extends Plugin {
|
|
67
67
|
const clipboardPipeline = editor.plugins.get('ClipboardPipeline');
|
68
68
|
this.listenTo(clipboardPipeline, 'inputTransformation', () => {
|
69
69
|
const firstRange = modelDocument.selection.getFirstRange();
|
70
|
-
const leftLivePosition =
|
70
|
+
const leftLivePosition = ModelLivePosition.fromPosition(firstRange.start);
|
71
71
|
leftLivePosition.stickiness = 'toPrevious';
|
72
|
-
const rightLivePosition =
|
72
|
+
const rightLivePosition = ModelLivePosition.fromPosition(firstRange.end);
|
73
73
|
rightLivePosition.stickiness = 'toNext';
|
74
74
|
modelDocument.once('change:data', () => {
|
75
75
|
this._embedMediaBetweenPositions(leftLivePosition, rightLivePosition);
|
@@ -97,8 +97,8 @@ export default class AutoMediaEmbed extends Plugin {
|
|
97
97
|
_embedMediaBetweenPositions(leftPosition, rightPosition) {
|
98
98
|
const editor = this.editor;
|
99
99
|
const mediaRegistry = editor.plugins.get(MediaEmbedEditing).registry;
|
100
|
-
// TODO: Use marker instead of
|
101
|
-
const urlRange = new
|
100
|
+
// TODO: Use marker instead of ModelLiveRange & LivePositions.
|
101
|
+
const urlRange = new ModelLiveRange(leftPosition, rightPosition);
|
102
102
|
const walker = urlRange.getWalker({ ignoreElementEnd: true });
|
103
103
|
let url = '';
|
104
104
|
for (const node of walker) {
|
@@ -124,7 +124,7 @@ export default class AutoMediaEmbed extends Plugin {
|
|
124
124
|
return;
|
125
125
|
}
|
126
126
|
// Position won't be available in the `setTimeout` function so let's clone it.
|
127
|
-
this._positionToInsert =
|
127
|
+
this._positionToInsert = ModelLivePosition.fromPosition(leftPosition);
|
128
128
|
// This action mustn't be executed if undo was called between pasting and auto-embedding.
|
129
129
|
this._timeoutId = global.window.setTimeout(() => {
|
130
130
|
editor.model.change(writer => {
|
package/src/converters.d.ts
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
4
4
|
*/
|
5
5
|
import type { DowncastDispatcher } from 'ckeditor5/src/engine.js';
|
6
|
-
import type MediaRegistry from './mediaregistry.js';
|
6
|
+
import { type MediaRegistry } from './mediaregistry.js';
|
7
7
|
import type { MediaOptions } from './utils.js';
|
8
8
|
/**
|
9
9
|
* Returns a function that converts the model "url" attribute to the view representation.
|
package/src/index.d.ts
CHANGED
@@ -5,11 +5,16 @@
|
|
5
5
|
/**
|
6
6
|
* @module media-embed
|
7
7
|
*/
|
8
|
-
export {
|
9
|
-
export {
|
10
|
-
export {
|
11
|
-
export {
|
12
|
-
export {
|
8
|
+
export { MediaEmbed } from './mediaembed.js';
|
9
|
+
export { MediaEmbedEditing } from './mediaembedediting.js';
|
10
|
+
export { MediaEmbedUI } from './mediaembedui.js';
|
11
|
+
export { AutoMediaEmbed } from './automediaembed.js';
|
12
|
+
export { MediaEmbedToolbar } from './mediaembedtoolbar.js';
|
13
|
+
export { MediaEmbedCommand } from './mediaembedcommand.js';
|
13
14
|
export type { MediaEmbedConfig } from './mediaembedconfig.js';
|
14
|
-
export
|
15
|
+
export { modelToViewUrlAttributeConverter as _modelToViewUrlAttributeMediaConverter } from './converters.js';
|
16
|
+
export { MediaFormView as _MediaFormView } from './ui/mediaformview.js';
|
17
|
+
export { toMediaWidget as _toMediaWidget, getSelectedMediaViewWidget as _getSelectedMediaViewWidget, isMediaWidget as _isMediaWidget, createMediaFigureElement as _createMediaFigureElement, getSelectedMediaModelWidget as _getSelectedMediaModelWidget, insertMedia as _insertMedia, type MediaOptions } from './utils.js';
|
18
|
+
export type { MediaEmbedProvider } from './mediaembedconfig.js';
|
19
|
+
export { MediaRegistry } from './mediaregistry.js';
|
15
20
|
import './augmentation.js';
|
package/src/index.js
CHANGED
@@ -5,9 +5,14 @@
|
|
5
5
|
/**
|
6
6
|
* @module media-embed
|
7
7
|
*/
|
8
|
-
export {
|
9
|
-
export {
|
10
|
-
export {
|
11
|
-
export {
|
12
|
-
export {
|
8
|
+
export { MediaEmbed } from './mediaembed.js';
|
9
|
+
export { MediaEmbedEditing } from './mediaembedediting.js';
|
10
|
+
export { MediaEmbedUI } from './mediaembedui.js';
|
11
|
+
export { AutoMediaEmbed } from './automediaembed.js';
|
12
|
+
export { MediaEmbedToolbar } from './mediaembedtoolbar.js';
|
13
|
+
export { MediaEmbedCommand } from './mediaembedcommand.js';
|
14
|
+
export { modelToViewUrlAttributeConverter as _modelToViewUrlAttributeMediaConverter } from './converters.js';
|
15
|
+
export { MediaFormView as _MediaFormView } from './ui/mediaformview.js';
|
16
|
+
export { toMediaWidget as _toMediaWidget, getSelectedMediaViewWidget as _getSelectedMediaViewWidget, isMediaWidget as _isMediaWidget, createMediaFigureElement as _createMediaFigureElement, getSelectedMediaModelWidget as _getSelectedMediaModelWidget, insertMedia as _insertMedia } from './utils.js';
|
17
|
+
export { MediaRegistry } from './mediaregistry.js';
|
13
18
|
import './augmentation.js';
|
package/src/mediaembed.d.ts
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
*/
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { Widget } from 'ckeditor5/src/widget.js';
|
10
|
-
import MediaEmbedEditing from './mediaembedediting.js';
|
11
|
-
import AutoMediaEmbed from './automediaembed.js';
|
12
|
-
import MediaEmbedUI from './mediaembedui.js';
|
10
|
+
import { MediaEmbedEditing } from './mediaembedediting.js';
|
11
|
+
import { AutoMediaEmbed } from './automediaembed.js';
|
12
|
+
import { MediaEmbedUI } from './mediaembedui.js';
|
13
13
|
import '../theme/mediaembed.css';
|
14
14
|
/**
|
15
15
|
* The media embed plugin.
|
@@ -22,7 +22,7 @@ import '../theme/mediaembed.css';
|
|
22
22
|
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
23
|
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
24
|
*/
|
25
|
-
export
|
25
|
+
export declare class MediaEmbed extends Plugin {
|
26
26
|
/**
|
27
27
|
* @inheritDoc
|
28
28
|
*/
|
package/src/mediaembed.js
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
*/
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { Widget } from 'ckeditor5/src/widget.js';
|
10
|
-
import MediaEmbedEditing from './mediaembedediting.js';
|
11
|
-
import AutoMediaEmbed from './automediaembed.js';
|
12
|
-
import MediaEmbedUI from './mediaembedui.js';
|
10
|
+
import { MediaEmbedEditing } from './mediaembedediting.js';
|
11
|
+
import { AutoMediaEmbed } from './automediaembed.js';
|
12
|
+
import { MediaEmbedUI } from './mediaembedui.js';
|
13
13
|
import '../theme/mediaembed.css';
|
14
14
|
/**
|
15
15
|
* The media embed plugin.
|
@@ -22,7 +22,7 @@ import '../theme/mediaembed.css';
|
|
22
22
|
* * The {@link module:media-embed/mediaembedui~MediaEmbedUI media embed UI feature} and
|
23
23
|
* * The {@link module:media-embed/automediaembed~AutoMediaEmbed auto-media embed feature}.
|
24
24
|
*/
|
25
|
-
export
|
25
|
+
export class MediaEmbed extends Plugin {
|
26
26
|
/**
|
27
27
|
* @inheritDoc
|
28
28
|
*/
|
@@ -14,7 +14,7 @@ import { Command } from 'ckeditor5/src/core.js';
|
|
14
14
|
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
15
15
|
* ```
|
16
16
|
*/
|
17
|
-
export
|
17
|
+
export declare class MediaEmbedCommand extends Command {
|
18
18
|
/**
|
19
19
|
* Media url.
|
20
20
|
*/
|
package/src/mediaembedcommand.js
CHANGED
@@ -16,7 +16,7 @@ import { getSelectedMediaModelWidget, insertMedia } from './utils.js';
|
|
16
16
|
* editor.execute( 'mediaEmbed', 'http://url.to.the/media' );
|
17
17
|
* ```
|
18
18
|
*/
|
19
|
-
export
|
19
|
+
export class MediaEmbedCommand extends Command {
|
20
20
|
/**
|
21
21
|
* @inheritDoc
|
22
22
|
*/
|
@@ -6,12 +6,12 @@
|
|
6
6
|
* @module media-embed/mediaembedediting
|
7
7
|
*/
|
8
8
|
import { Plugin, type Editor } from 'ckeditor5/src/core.js';
|
9
|
-
import MediaRegistry from './mediaregistry.js';
|
9
|
+
import { MediaRegistry } from './mediaregistry.js';
|
10
10
|
import '../theme/mediaembedediting.css';
|
11
11
|
/**
|
12
12
|
* The media embed editing feature.
|
13
13
|
*/
|
14
|
-
export
|
14
|
+
export declare class MediaEmbedEditing extends Plugin {
|
15
15
|
/**
|
16
16
|
* @inheritDoc
|
17
17
|
*/
|
package/src/mediaembedediting.js
CHANGED
@@ -8,14 +8,14 @@
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { first } from 'ckeditor5/src/utils.js';
|
10
10
|
import { modelToViewUrlAttributeConverter } from './converters.js';
|
11
|
-
import MediaEmbedCommand from './mediaembedcommand.js';
|
12
|
-
import MediaRegistry from './mediaregistry.js';
|
11
|
+
import { MediaEmbedCommand } from './mediaembedcommand.js';
|
12
|
+
import { MediaRegistry } from './mediaregistry.js';
|
13
13
|
import { toMediaWidget, createMediaFigureElement } from './utils.js';
|
14
14
|
import '../theme/mediaembedediting.css';
|
15
15
|
/**
|
16
16
|
* The media embed editing feature.
|
17
17
|
*/
|
18
|
-
export
|
18
|
+
export class MediaEmbedEditing extends Plugin {
|
19
19
|
/**
|
20
20
|
* @inheritDoc
|
21
21
|
*/
|
@@ -14,7 +14,7 @@ import './mediaembedconfig.js';
|
|
14
14
|
* Instances of toolbar components (e.g. buttons) are created based on the
|
15
15
|
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#toolbar `media.toolbar` configuration option}.
|
16
16
|
*/
|
17
|
-
export
|
17
|
+
export declare class MediaEmbedToolbar extends Plugin {
|
18
18
|
/**
|
19
19
|
* @inheritDoc
|
20
20
|
*/
|
package/src/mediaembedtoolbar.js
CHANGED
@@ -15,7 +15,7 @@ import './mediaembedconfig.js';
|
|
15
15
|
* Instances of toolbar components (e.g. buttons) are created based on the
|
16
16
|
* {@link module:media-embed/mediaembedconfig~MediaEmbedConfig#toolbar `media.toolbar` configuration option}.
|
17
17
|
*/
|
18
|
-
export
|
18
|
+
export class MediaEmbedToolbar extends Plugin {
|
19
19
|
/**
|
20
20
|
* @inheritDoc
|
21
21
|
*/
|
package/src/mediaembedui.d.ts
CHANGED
@@ -7,11 +7,11 @@
|
|
7
7
|
*/
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { Dialog } from 'ckeditor5/src/ui.js';
|
10
|
-
import MediaEmbedEditing from './mediaembedediting.js';
|
10
|
+
import { MediaEmbedEditing } from './mediaembedediting.js';
|
11
11
|
/**
|
12
12
|
* The media embed UI plugin.
|
13
13
|
*/
|
14
|
-
export
|
14
|
+
export declare class MediaEmbedUI extends Plugin {
|
15
15
|
/**
|
16
16
|
* @inheritDoc
|
17
17
|
*/
|
package/src/mediaembedui.js
CHANGED
@@ -8,12 +8,12 @@
|
|
8
8
|
import { Plugin } from 'ckeditor5/src/core.js';
|
9
9
|
import { IconMedia } from 'ckeditor5/src/icons.js';
|
10
10
|
import { ButtonView, CssTransitionDisablerMixin, MenuBarMenuListItemButtonView, Dialog } from 'ckeditor5/src/ui.js';
|
11
|
-
import MediaFormView from './ui/mediaformview.js';
|
12
|
-
import MediaEmbedEditing from './mediaembedediting.js';
|
11
|
+
import { MediaFormView } from './ui/mediaformview.js';
|
12
|
+
import { MediaEmbedEditing } from './mediaembedediting.js';
|
13
13
|
/**
|
14
14
|
* The media embed UI plugin.
|
15
15
|
*/
|
16
|
-
export
|
16
|
+
export class MediaEmbedUI extends Plugin {
|
17
17
|
/**
|
18
18
|
* @inheritDoc
|
19
19
|
*/
|
package/src/mediaregistry.d.ts
CHANGED
@@ -3,17 +3,17 @@
|
|
3
3
|
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
|
4
4
|
*/
|
5
5
|
import { type Locale } from 'ckeditor5/src/utils.js';
|
6
|
-
import type {
|
6
|
+
import type { ViewDowncastWriter, ViewElement } from 'ckeditor5/src/engine.js';
|
7
7
|
import type { MediaEmbedConfig, MediaEmbedProvider } from './mediaembedconfig.js';
|
8
8
|
import type { MediaOptions } from './utils.js';
|
9
9
|
/**
|
10
10
|
* A bridge between the raw media content provider definitions and the editor view content.
|
11
11
|
*
|
12
|
-
* It helps translating media URLs to corresponding {@link module:engine/view/element~
|
12
|
+
* It helps translating media URLs to corresponding {@link module:engine/view/element~ViewElement view elements}.
|
13
13
|
*
|
14
14
|
* Mostly used by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} plugin.
|
15
15
|
*/
|
16
|
-
export
|
16
|
+
export declare class MediaRegistry {
|
17
17
|
/**
|
18
18
|
* The {@link module:utils/locale~Locale} instance.
|
19
19
|
*/
|
@@ -37,7 +37,7 @@ export default class MediaRegistry {
|
|
37
37
|
*/
|
38
38
|
hasMedia(url: string): boolean;
|
39
39
|
/**
|
40
|
-
* For the given media URL string and options, it returns the {@link module:engine/view/element~
|
40
|
+
* For the given media URL string and options, it returns the {@link module:engine/view/element~ViewElement view element}
|
41
41
|
* representing that media.
|
42
42
|
*
|
43
43
|
* **Note:** If no URL is specified, an empty view element is returned.
|
@@ -45,7 +45,7 @@ export default class MediaRegistry {
|
|
45
45
|
* @param writer The view writer used to produce a view element.
|
46
46
|
* @param url The URL to be translated into a view element.
|
47
47
|
*/
|
48
|
-
getMediaViewElement(writer:
|
48
|
+
getMediaViewElement(writer: ViewDowncastWriter, url: string, options: MediaOptions): ViewElement;
|
49
49
|
/**
|
50
50
|
* Returns a `Media` instance for the given URL.
|
51
51
|
*
|
package/src/mediaregistry.js
CHANGED
@@ -12,11 +12,11 @@ const mediaPlaceholderIconViewBox = '0 0 64 42';
|
|
12
12
|
/**
|
13
13
|
* A bridge between the raw media content provider definitions and the editor view content.
|
14
14
|
*
|
15
|
-
* It helps translating media URLs to corresponding {@link module:engine/view/element~
|
15
|
+
* It helps translating media URLs to corresponding {@link module:engine/view/element~ViewElement view elements}.
|
16
16
|
*
|
17
17
|
* Mostly used by the {@link module:media-embed/mediaembedediting~MediaEmbedEditing} plugin.
|
18
18
|
*/
|
19
|
-
export
|
19
|
+
export class MediaRegistry {
|
20
20
|
/**
|
21
21
|
* The {@link module:utils/locale~Locale} instance.
|
22
22
|
*/
|
@@ -65,7 +65,7 @@ export default class MediaRegistry {
|
|
65
65
|
return !!this._getMedia(url);
|
66
66
|
}
|
67
67
|
/**
|
68
|
-
* For the given media URL string and options, it returns the {@link module:engine/view/element~
|
68
|
+
* For the given media URL string and options, it returns the {@link module:engine/view/element~ViewElement view element}
|
69
69
|
* representing that media.
|
70
70
|
*
|
71
71
|
* **Note:** If no URL is specified, an empty view element is returned.
|
@@ -129,7 +129,7 @@ export default class MediaRegistry {
|
|
129
129
|
/**
|
130
130
|
* Represents media defined by the provider configuration.
|
131
131
|
*
|
132
|
-
* It can be rendered to the {@link module:engine/view/element~
|
132
|
+
* It can be rendered to the {@link module:engine/view/element~ViewElement view element} and used in the editing or data pipeline.
|
133
133
|
*/
|
134
134
|
class Media {
|
135
135
|
/**
|
@@ -14,7 +14,7 @@ import '../../theme/mediaform.css';
|
|
14
14
|
*
|
15
15
|
* See {@link module:media-embed/ui/mediaformview~MediaFormView}.
|
16
16
|
*/
|
17
|
-
export
|
17
|
+
export declare class MediaFormView extends View {
|
18
18
|
/**
|
19
19
|
* Tracks information about the DOM focus in the form.
|
20
20
|
*/
|
package/src/ui/mediaformview.js
CHANGED
@@ -16,7 +16,7 @@ import '../../theme/mediaform.css';
|
|
16
16
|
*
|
17
17
|
* See {@link module:media-embed/ui/mediaformview~MediaFormView}.
|
18
18
|
*/
|
19
|
-
export
|
19
|
+
export class MediaFormView extends View {
|
20
20
|
/**
|
21
21
|
* Tracks information about the DOM focus in the form.
|
22
22
|
*/
|
package/src/utils.d.ts
CHANGED
@@ -5,23 +5,29 @@
|
|
5
5
|
/**
|
6
6
|
* @module media-embed/utils
|
7
7
|
*/
|
8
|
-
import type { ViewContainerElement,
|
9
|
-
import type MediaRegistry from './mediaregistry.js';
|
8
|
+
import type { ViewContainerElement, ModelElement, Model, ModelSelectable, ModelSelection, ViewDowncastWriter, ViewDocumentSelection, ViewElement, ModelDocumentSelection } from 'ckeditor5/src/engine.js';
|
9
|
+
import { type MediaRegistry } from './mediaregistry.js';
|
10
10
|
/**
|
11
|
-
* Converts a given {@link module:engine/view/element~
|
12
|
-
* * Adds a {@link module:engine/view/element~
|
11
|
+
* Converts a given {@link module:engine/view/element~ViewElement} to a media embed widget:
|
12
|
+
* * Adds a {@link module:engine/view/element~ViewElement#_setCustomProperty custom property}
|
13
|
+
* allowing to recognize the media widget element.
|
13
14
|
* * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
|
14
15
|
*
|
15
16
|
* @param writer An instance of the view writer.
|
16
17
|
* @param label The element's label.
|
18
|
+
* @internal
|
17
19
|
*/
|
18
|
-
export declare function toMediaWidget(viewElement: ViewElement, writer:
|
20
|
+
export declare function toMediaWidget(viewElement: ViewElement, writer: ViewDowncastWriter, label: string): ViewElement;
|
19
21
|
/**
|
20
22
|
* Returns a media widget editing view element if one is selected.
|
23
|
+
*
|
24
|
+
* @internal
|
21
25
|
*/
|
22
26
|
export declare function getSelectedMediaViewWidget(selection: ViewDocumentSelection): ViewElement | null;
|
23
27
|
/**
|
24
28
|
* Checks if a given view element is a media widget.
|
29
|
+
*
|
30
|
+
* @internal
|
25
31
|
*/
|
26
32
|
export declare function isMediaWidget(viewElement: ViewElement): boolean;
|
27
33
|
/**
|
@@ -40,12 +46,16 @@ export declare function isMediaWidget(viewElement: ViewElement): boolean;
|
|
40
46
|
* <div data-oembed-url="foo">[ non-semantic media preview for "foo" ]</div>
|
41
47
|
* </figure>
|
42
48
|
* ```
|
49
|
+
*
|
50
|
+
* @internal
|
43
51
|
*/
|
44
|
-
export declare function createMediaFigureElement(writer:
|
52
|
+
export declare function createMediaFigureElement(writer: ViewDowncastWriter, registry: MediaRegistry, url: string, options: MediaOptions): ViewContainerElement;
|
45
53
|
/**
|
46
54
|
* Returns a selected media element in the model, if any.
|
55
|
+
*
|
56
|
+
* @internal
|
47
57
|
*/
|
48
|
-
export declare function getSelectedMediaModelWidget(selection:
|
58
|
+
export declare function getSelectedMediaModelWidget(selection: ModelSelection | ModelDocumentSelection): ModelElement | null;
|
49
59
|
/**
|
50
60
|
* Creates a media element and inserts it into the model.
|
51
61
|
*
|
@@ -55,8 +65,9 @@ export declare function getSelectedMediaModelWidget(selection: Selection | Docum
|
|
55
65
|
* @param url An URL of an embeddable media.
|
56
66
|
* @param findOptimalPosition If true it will try to find optimal position to insert media without breaking content
|
57
67
|
* in which a selection is.
|
68
|
+
* @internal
|
58
69
|
*/
|
59
|
-
export declare function insertMedia(model: Model, url: string, selectable:
|
70
|
+
export declare function insertMedia(model: Model, url: string, selectable: ModelSelectable, findOptimalPosition: boolean): void;
|
60
71
|
/**
|
61
72
|
* Type for commonly grouped function parameters across this package.
|
62
73
|
*/
|
package/src/utils.js
CHANGED
@@ -4,12 +4,14 @@
|
|
4
4
|
*/
|
5
5
|
import { isWidget, toWidget } from 'ckeditor5/src/widget.js';
|
6
6
|
/**
|
7
|
-
* Converts a given {@link module:engine/view/element~
|
8
|
-
* * Adds a {@link module:engine/view/element~
|
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.
|
9
10
|
* * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
|
10
11
|
*
|
11
12
|
* @param writer An instance of the view writer.
|
12
13
|
* @param label The element's label.
|
14
|
+
* @internal
|
13
15
|
*/
|
14
16
|
export function toMediaWidget(viewElement, writer, label) {
|
15
17
|
writer.setCustomProperty('media', true, viewElement);
|
@@ -17,6 +19,8 @@ export function toMediaWidget(viewElement, writer, label) {
|
|
17
19
|
}
|
18
20
|
/**
|
19
21
|
* Returns a media widget editing view element if one is selected.
|
22
|
+
*
|
23
|
+
* @internal
|
20
24
|
*/
|
21
25
|
export function getSelectedMediaViewWidget(selection) {
|
22
26
|
const viewElement = selection.getSelectedElement();
|
@@ -27,6 +31,8 @@ export function getSelectedMediaViewWidget(selection) {
|
|
27
31
|
}
|
28
32
|
/**
|
29
33
|
* Checks if a given view element is a media widget.
|
34
|
+
*
|
35
|
+
* @internal
|
30
36
|
*/
|
31
37
|
export function isMediaWidget(viewElement) {
|
32
38
|
return !!viewElement.getCustomProperty('media') && isWidget(viewElement);
|
@@ -47,6 +53,8 @@ export function isMediaWidget(viewElement) {
|
|
47
53
|
* <div data-oembed-url="foo">[ non-semantic media preview for "foo" ]</div>
|
48
54
|
* </figure>
|
49
55
|
* ```
|
56
|
+
*
|
57
|
+
* @internal
|
50
58
|
*/
|
51
59
|
export function createMediaFigureElement(writer, registry, url, options) {
|
52
60
|
return writer.createContainerElement('figure', { class: 'media' }, [
|
@@ -56,6 +64,8 @@ export function createMediaFigureElement(writer, registry, url, options) {
|
|
56
64
|
}
|
57
65
|
/**
|
58
66
|
* Returns a selected media element in the model, if any.
|
67
|
+
*
|
68
|
+
* @internal
|
59
69
|
*/
|
60
70
|
export function getSelectedMediaModelWidget(selection) {
|
61
71
|
const selectedElement = selection.getSelectedElement();
|
@@ -73,6 +83,7 @@ export function getSelectedMediaModelWidget(selection) {
|
|
73
83
|
* @param url An URL of an embeddable media.
|
74
84
|
* @param findOptimalPosition If true it will try to find optimal position to insert media without breaking content
|
75
85
|
* in which a selection is.
|
86
|
+
* @internal
|
76
87
|
*/
|
77
88
|
export function insertMedia(model, url, selectable, findOptimalPosition) {
|
78
89
|
model.change(writer => {
|