@ckeditor/ckeditor5-media-embed 39.0.1 → 40.0.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.
Files changed (85) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/media-embed.js.map +1 -0
  4. package/build/translations/pt-br.js +1 -1
  5. package/lang/translations/ar.po +1 -0
  6. package/lang/translations/az.po +1 -0
  7. package/lang/translations/bg.po +1 -0
  8. package/lang/translations/bn.po +1 -0
  9. package/lang/translations/ca.po +1 -0
  10. package/lang/translations/cs.po +1 -0
  11. package/lang/translations/da.po +1 -0
  12. package/lang/translations/de-ch.po +1 -0
  13. package/lang/translations/de.po +1 -0
  14. package/lang/translations/el.po +1 -0
  15. package/lang/translations/en-au.po +1 -0
  16. package/lang/translations/en-gb.po +1 -0
  17. package/lang/translations/en.po +1 -0
  18. package/lang/translations/es.po +1 -0
  19. package/lang/translations/et.po +1 -0
  20. package/lang/translations/fa.po +1 -0
  21. package/lang/translations/fi.po +1 -0
  22. package/lang/translations/fr.po +1 -0
  23. package/lang/translations/gl.po +1 -0
  24. package/lang/translations/he.po +1 -0
  25. package/lang/translations/hi.po +1 -0
  26. package/lang/translations/hr.po +1 -0
  27. package/lang/translations/hu.po +1 -0
  28. package/lang/translations/id.po +1 -0
  29. package/lang/translations/it.po +1 -0
  30. package/lang/translations/ja.po +1 -0
  31. package/lang/translations/ko.po +1 -0
  32. package/lang/translations/ku.po +1 -0
  33. package/lang/translations/lt.po +1 -0
  34. package/lang/translations/lv.po +1 -0
  35. package/lang/translations/ms.po +1 -0
  36. package/lang/translations/ne.po +1 -0
  37. package/lang/translations/nl.po +1 -0
  38. package/lang/translations/no.po +1 -0
  39. package/lang/translations/pl.po +1 -0
  40. package/lang/translations/pt-br.po +2 -1
  41. package/lang/translations/pt.po +1 -0
  42. package/lang/translations/ro.po +1 -0
  43. package/lang/translations/ru.po +1 -0
  44. package/lang/translations/sk.po +1 -0
  45. package/lang/translations/sq.po +1 -0
  46. package/lang/translations/sr-latn.po +1 -0
  47. package/lang/translations/sr.po +1 -0
  48. package/lang/translations/sv.po +1 -0
  49. package/lang/translations/th.po +1 -0
  50. package/lang/translations/tk.po +1 -0
  51. package/lang/translations/tr.po +1 -0
  52. package/lang/translations/uk.po +1 -0
  53. package/lang/translations/ur.po +1 -0
  54. package/lang/translations/uz.po +1 -0
  55. package/lang/translations/vi.po +1 -0
  56. package/lang/translations/zh-cn.po +1 -0
  57. package/lang/translations/zh.po +1 -0
  58. package/package.json +3 -7
  59. package/src/augmentation.d.ts +25 -25
  60. package/src/augmentation.js +5 -5
  61. package/src/automediaembed.d.ts +51 -51
  62. package/src/automediaembed.js +131 -131
  63. package/src/converters.d.ts +38 -38
  64. package/src/converters.js +53 -53
  65. package/src/index.d.ts +15 -15
  66. package/src/index.js +13 -13
  67. package/src/mediaembed.d.ts +34 -34
  68. package/src/mediaembed.js +38 -38
  69. package/src/mediaembedcommand.d.ts +36 -36
  70. package/src/mediaembedcommand.js +71 -71
  71. package/src/mediaembedconfig.d.ts +278 -278
  72. package/src/mediaembedconfig.js +5 -5
  73. package/src/mediaembedediting.d.ts +31 -31
  74. package/src/mediaembedediting.js +231 -231
  75. package/src/mediaembedtoolbar.d.ts +30 -30
  76. package/src/mediaembedtoolbar.js +44 -44
  77. package/src/mediaembedui.d.ts +27 -27
  78. package/src/mediaembedui.js +99 -99
  79. package/src/mediaregistry.d.ts +66 -66
  80. package/src/mediaregistry.js +232 -232
  81. package/src/ui/mediaformview.d.ts +115 -115
  82. package/src/ui/mediaformview.js +194 -194
  83. package/src/utils.d.ts +67 -67
  84. package/src/utils.js +85 -85
  85. package/theme/icons/media/twitter.svg +0 -0
@@ -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
+ }
@@ -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
+ }