@ckeditor/ckeditor5-image 45.2.1 → 46.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.
Files changed (127) hide show
  1. package/build/image.js +1 -1
  2. package/dist/index-content.css +18 -17
  3. package/dist/index-editor.css +96 -96
  4. package/dist/index.css +164 -163
  5. package/dist/index.css.map +1 -1
  6. package/dist/index.js +93 -44
  7. package/dist/index.js.map +1 -1
  8. package/package.json +13 -13
  9. package/src/autoimage.d.ts +2 -2
  10. package/src/autoimage.js +8 -8
  11. package/src/image/converters.d.ts +1 -1
  12. package/src/image/imageblockediting.d.ts +5 -5
  13. package/src/image/imageblockediting.js +8 -8
  14. package/src/image/imageediting.d.ts +2 -2
  15. package/src/image/imageediting.js +5 -5
  16. package/src/image/imageinlineediting.d.ts +5 -5
  17. package/src/image/imageinlineediting.js +8 -8
  18. package/src/image/imageloadobserver.d.ts +7 -7
  19. package/src/image/imageloadobserver.js +6 -6
  20. package/src/image/imageplaceholder.d.ts +2 -2
  21. package/src/image/imageplaceholder.js +3 -3
  22. package/src/image/imagetypecommand.d.ts +4 -4
  23. package/src/image/imagetypecommand.js +1 -1
  24. package/src/image/insertimagecommand.d.ts +1 -1
  25. package/src/image/insertimagecommand.js +1 -1
  26. package/src/image/replaceimagesourcecommand.d.ts +3 -3
  27. package/src/image/replaceimagesourcecommand.js +1 -1
  28. package/src/image/ui/utils.d.ts +4 -2
  29. package/src/image/ui/utils.js +2 -0
  30. package/src/image/utils.d.ts +8 -4
  31. package/src/image/utils.js +4 -0
  32. package/src/image.d.ts +3 -3
  33. package/src/image.js +3 -3
  34. package/src/imageblock.d.ts +4 -4
  35. package/src/imageblock.js +4 -4
  36. package/src/imagecaption/imagecaptionediting.d.ts +8 -8
  37. package/src/imagecaption/imagecaptionediting.js +9 -9
  38. package/src/imagecaption/imagecaptionui.d.ts +2 -2
  39. package/src/imagecaption/imagecaptionui.js +2 -2
  40. package/src/imagecaption/imagecaptionutils.d.ts +5 -5
  41. package/src/imagecaption/imagecaptionutils.js +2 -2
  42. package/src/imagecaption/toggleimagecaptioncommand.d.ts +1 -1
  43. package/src/imagecaption/toggleimagecaptioncommand.js +2 -2
  44. package/src/imagecaption.d.ts +3 -3
  45. package/src/imagecaption.js +3 -3
  46. package/src/imageinline.d.ts +4 -4
  47. package/src/imageinline.js +4 -4
  48. package/src/imageinsert/imageinsertui.d.ts +2 -2
  49. package/src/imageinsert/imageinsertui.js +3 -3
  50. package/src/imageinsert/imageinsertviaurlui.d.ts +2 -2
  51. package/src/imageinsert/imageinsertviaurlui.js +3 -3
  52. package/src/imageinsert/ui/imageinsertformview.d.ts +3 -1
  53. package/src/imageinsert/ui/imageinsertformview.js +3 -1
  54. package/src/imageinsert/ui/imageinserturlview.d.ts +3 -1
  55. package/src/imageinsert/ui/imageinserturlview.js +3 -1
  56. package/src/imageinsert.d.ts +4 -4
  57. package/src/imageinsert.js +4 -4
  58. package/src/imageinsertviaurl.d.ts +3 -3
  59. package/src/imageinsertviaurl.js +3 -3
  60. package/src/imageresize/imagecustomresizeui.d.ts +1 -1
  61. package/src/imageresize/imagecustomresizeui.js +2 -2
  62. package/src/imageresize/imageresizebuttons.d.ts +2 -2
  63. package/src/imageresize/imageresizebuttons.js +5 -5
  64. package/src/imageresize/imageresizeediting.d.ts +2 -2
  65. package/src/imageresize/imageresizeediting.js +10 -5
  66. package/src/imageresize/imageresizehandles.d.ts +2 -2
  67. package/src/imageresize/imageresizehandles.js +3 -3
  68. package/src/imageresize/resizeimagecommand.d.ts +1 -1
  69. package/src/imageresize/resizeimagecommand.js +1 -1
  70. package/src/imageresize/ui/imagecustomresizeformview.d.ts +5 -1
  71. package/src/imageresize/ui/imagecustomresizeformview.js +3 -1
  72. package/src/imageresize/utils/getselectedimageeditornodes.d.ts +3 -2
  73. package/src/imageresize/utils/getselectedimageeditornodes.js +1 -0
  74. package/src/imageresize/utils/getselectedimagepossibleresizerange.d.ts +1 -0
  75. package/src/imageresize/utils/getselectedimagepossibleresizerange.js +1 -0
  76. package/src/imageresize/utils/getselectedimagewidthinunits.d.ts +1 -0
  77. package/src/imageresize/utils/getselectedimagewidthinunits.js +1 -0
  78. package/src/imageresize/utils/tryparsedimensionwithunit.d.ts +2 -0
  79. package/src/imageresize/utils/tryparsedimensionwithunit.js +2 -0
  80. package/src/imageresize.d.ts +5 -5
  81. package/src/imageresize.js +5 -5
  82. package/src/imagesizeattributes.d.ts +2 -2
  83. package/src/imagesizeattributes.js +5 -4
  84. package/src/imagestyle/converters.d.ts +2 -0
  85. package/src/imagestyle/converters.js +2 -0
  86. package/src/imagestyle/imagestylecommand.d.ts +3 -3
  87. package/src/imagestyle/imagestylecommand.js +1 -1
  88. package/src/imagestyle/imagestyleediting.d.ts +2 -2
  89. package/src/imagestyle/imagestyleediting.js +8 -7
  90. package/src/imagestyle/imagestyleui.d.ts +2 -2
  91. package/src/imagestyle/imagestyleui.js +3 -3
  92. package/src/imagestyle/utils.d.ts +11 -5
  93. package/src/imagestyle/utils.js +11 -5
  94. package/src/imagestyle.d.ts +3 -3
  95. package/src/imagestyle.js +3 -3
  96. package/src/imagetextalternative/imagetextalternativecommand.d.ts +1 -1
  97. package/src/imagetextalternative/imagetextalternativecommand.js +1 -1
  98. package/src/imagetextalternative/imagetextalternativeediting.d.ts +2 -2
  99. package/src/imagetextalternative/imagetextalternativeediting.js +3 -3
  100. package/src/imagetextalternative/imagetextalternativeui.d.ts +1 -1
  101. package/src/imagetextalternative/imagetextalternativeui.js +2 -2
  102. package/src/imagetextalternative/ui/textalternativeformview.d.ts +5 -1
  103. package/src/imagetextalternative/ui/textalternativeformview.js +3 -1
  104. package/src/imagetextalternative.d.ts +3 -3
  105. package/src/imagetextalternative.js +3 -3
  106. package/src/imagetoolbar.d.ts +2 -2
  107. package/src/imagetoolbar.js +2 -2
  108. package/src/imageupload/imageuploadediting.d.ts +11 -9
  109. package/src/imageupload/imageuploadediting.js +10 -8
  110. package/src/imageupload/imageuploadprogress.d.ts +1 -1
  111. package/src/imageupload/imageuploadprogress.js +5 -5
  112. package/src/imageupload/imageuploadui.d.ts +1 -1
  113. package/src/imageupload/imageuploadui.js +1 -1
  114. package/src/imageupload/uploadimagecommand.d.ts +1 -1
  115. package/src/imageupload/uploadimagecommand.js +1 -1
  116. package/src/imageupload/utils.d.ts +3 -1
  117. package/src/imageupload/utils.js +2 -0
  118. package/src/imageupload.d.ts +4 -4
  119. package/src/imageupload.js +4 -4
  120. package/src/imageutils.d.ts +13 -13
  121. package/src/imageutils.js +4 -4
  122. package/src/index.d.ts +63 -42
  123. package/src/index.js +58 -32
  124. package/src/pictureediting.d.ts +3 -3
  125. package/src/pictureediting.js +3 -3
  126. package/theme/imagecaption.css +7 -6
  127. package/theme/imagestyle.css +12 -12
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@
4
4
  */
5
5
  import { Plugin, Command } from '@ckeditor/ckeditor5-core/dist/index.js';
6
6
  import { Clipboard, ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/dist/index.js';
7
- import { LivePosition, LiveRange, Observer, UpcastWriter, enablePlaceholder, Element } from '@ckeditor/ckeditor5-engine/dist/index.js';
7
+ import { ModelLivePosition, ModelLiveRange, Observer, ViewUpcastWriter, enableViewPlaceholder, ModelElement } from '@ckeditor/ckeditor5-engine/dist/index.js';
8
8
  import { Undo } from '@ckeditor/ckeditor5-undo/dist/index.js';
9
9
  import { Delete } from '@ckeditor/ckeditor5-typing/dist/index.js';
10
10
  import { first, DomEmitterMixin, global, FocusTracker, KeystrokeHandler, logWarning, toArray, env, CKEditorError, Collection, Rect } from '@ckeditor/ckeditor5-utils/dist/index.js';
11
11
  import { toWidget, isWidget, findOptimalInsertionRange, Widget, toWidgetEditable, WidgetResize, calculateResizeHostAncestorWidth, WidgetToolbarRepository } from '@ckeditor/ckeditor5-widget/dist/index.js';
12
- import { View, FormRowView, ViewCollection, FocusCycler, submitHandler, ButtonView, FormHeaderView, LabeledFieldView, createLabeledInputText, BalloonPanelView, ContextualBalloon, CssTransitionDisablerMixin, clickOutsideHandler, CollapsibleView, SplitButtonView, createDropdown, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, FileDialogButtonView, MenuBarMenuListItemFileDialogButtonView, Notification, Dialog, MenuBarMenuListItemButtonView, ViewModel, DropdownButtonView, addListToDropdown, createLabeledInputNumber, addToolbarToDropdown } from '@ckeditor/ckeditor5-ui/dist/index.js';
12
+ import { View, FormRowView, ViewCollection, FocusCycler, submitHandler, ButtonView, FormHeaderView, LabeledFieldView, createLabeledInputText, BalloonPanelView, ContextualBalloon, CssTransitionDisablerMixin, clickOutsideHandler, CollapsibleView, SplitButtonView, createDropdown, MenuBarMenuView, MenuBarMenuListView, MenuBarMenuListItemView, FileDialogButtonView, MenuBarMenuListItemFileDialogButtonView, Notification, Dialog, MenuBarMenuListItemButtonView, UIModel, DropdownButtonView, addListToDropdown, createLabeledInputNumber, addToolbarToDropdown } from '@ckeditor/ckeditor5-ui/dist/index.js';
13
13
  import { IconPreviousArrow, IconTextAlternative, IconImage, IconCaption, IconImageUpload, IconImageUrl, IconObjectSizeFull, IconObjectSizeCustom, IconObjectSizeLarge, IconObjectSizeMedium, IconObjectSizeSmall, IconObjectInline, IconObjectInlineRight, IconObjectInlineLeft, IconObjectCenter, IconObjectRight, IconObjectLeft, IconObjectFullWidth } from '@ckeditor/ckeditor5-icons/dist/index.js';
14
14
  import { FileRepository } from '@ckeditor/ckeditor5-upload/dist/index.js';
15
15
  import { isObject, identity } from 'es-toolkit/compat';
@@ -111,6 +111,8 @@ import { isObject, identity } from 'es-toolkit/compat';
111
111
  }
112
112
  /**
113
113
  * Returns parsed value of the size, but only if it contains unit: px.
114
+ *
115
+ * @internal
114
116
  */ function getSizeValueIfInPx(size) {
115
117
  if (size && size.endsWith('px')) {
116
118
  return parseInt(size);
@@ -123,6 +125,8 @@ import { isObject, identity } from 'es-toolkit/compat';
123
125
  * If both image styles: width & height are set, they will override the image width & height attributes in the
124
126
  * browser. In this case, the image looks the same as if these styles were applied to attributes instead of styles.
125
127
  * That's why we can upcast these styles to width & height attributes instead of resizedWidth and resizedHeight.
128
+ *
129
+ * @internal
126
130
  */ function widthAndHeightStylesAreBothSet(viewElement) {
127
131
  const widthStyle = getSizeValueIfInPx(viewElement.getStyle('width'));
128
132
  const heightStyle = getSizeValueIfInPx(viewElement.getStyle('height'));
@@ -176,7 +180,7 @@ const IMAGE_WIDGETS_CLASSES_MATCH_REGEXP = /^(image|image-inline)$/;
176
180
  * ```
177
181
  *
178
182
  * @param attributes Attributes of the inserted image.
179
- * This method filters out the attributes which are disallowed by the {@link module:engine/model/schema~Schema}.
183
+ * This method filters out the attributes which are disallowed by the {@link module:engine/model/schema~ModelSchema}.
180
184
  * @param selectable Place to insert the image. If not specified,
181
185
  * the {@link module:widget/utils~findOptimalInsertionRange} logic will be applied for the block images
182
186
  * and `model.document.selection` for the inline images.
@@ -297,8 +301,8 @@ const IMAGE_WIDGETS_CLASSES_MATCH_REGEXP = /^(image|image-inline)$/;
297
301
  return isImageAllowedInParent(this.editor, selection) && isNotInsideImage(selection);
298
302
  }
299
303
  /**
300
- * Converts a given {@link module:engine/view/element~Element} to an image widget:
301
- * * Adds a {@link module:engine/view/element~Element#_setCustomProperty custom property} allowing to recognize the image widget
304
+ * Converts a given {@link module:engine/view/element~ViewElement} to an image widget:
305
+ * * Adds a {@link module:engine/view/element~ViewElement#_setCustomProperty custom property} allowing to recognize the image widget
302
306
  * element.
303
307
  * * Calls the {@link module:widget/utils~toWidget} function with the proper element's label creator.
304
308
  *
@@ -465,9 +469,9 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
465
469
  // into an image.
466
470
  this.listenTo(clipboardPipeline, 'inputTransformation', ()=>{
467
471
  const firstRange = modelDocument.selection.getFirstRange();
468
- const leftLivePosition = LivePosition.fromPosition(firstRange.start);
472
+ const leftLivePosition = ModelLivePosition.fromPosition(firstRange.start);
469
473
  leftLivePosition.stickiness = 'toPrevious';
470
- const rightLivePosition = LivePosition.fromPosition(firstRange.end);
474
+ const rightLivePosition = ModelLivePosition.fromPosition(firstRange.end);
471
475
  rightLivePosition.stickiness = 'toNext';
472
476
  modelDocument.once('change:data', ()=>{
473
477
  this._embedImageBetweenPositions(leftLivePosition, rightLivePosition);
@@ -496,8 +500,8 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
496
500
  * @param rightPosition Right position of the selection.
497
501
  */ _embedImageBetweenPositions(leftPosition, rightPosition) {
498
502
  const editor = this.editor;
499
- // TODO: Use a marker instead of LiveRange & LivePositions.
500
- const urlRange = new LiveRange(leftPosition, rightPosition);
503
+ // TODO: Use a marker instead of ModelLiveRange & LivePositions.
504
+ const urlRange = new ModelLiveRange(leftPosition, rightPosition);
501
505
  const walker = urlRange.getWalker({
502
506
  ignoreElementEnd: true
503
507
  });
@@ -516,7 +520,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
516
520
  return;
517
521
  }
518
522
  // Position will not be available in the `setTimeout` function so let's clone it.
519
- this._positionToInsert = LivePosition.fromPosition(leftPosition);
523
+ this._positionToInsert = ModelLivePosition.fromPosition(leftPosition);
520
524
  // This action mustn't be executed if undo was called between pasting and auto-embedding.
521
525
  this._timeoutId = setTimeout(()=>{
522
526
  // Do nothing if image element cannot be inserted at the current position.
@@ -614,6 +618,8 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
614
618
 
615
619
  /**
616
620
  * The TextAlternativeFormView class.
621
+ *
622
+ * @internal
617
623
  */ class TextAlternativeFormView extends View {
618
624
  /**
619
625
  * Tracks information about the DOM focus in the form.
@@ -778,6 +784,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
778
784
  * with respect to the image in the editor content, if one is selected.
779
785
  *
780
786
  * @param editor The editor instance.
787
+ * @internal
781
788
  */ function repositionContextualBalloon(editor) {
782
789
  const balloon = editor.plugins.get('ContextualBalloon');
783
790
  const imageUtils = editor.plugins.get('ImageUtils');
@@ -792,6 +799,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
792
799
  * to the selected element in the editor content.
793
800
  *
794
801
  * @param editor The editor instance.
802
+ * @internal
795
803
  */ function getBalloonPositionData(editor) {
796
804
  const editingView = editor.editing.view;
797
805
  const defaultPositions = BalloonPanelView.defaultPositions;
@@ -1248,9 +1256,9 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1248
1256
  }
1249
1257
 
1250
1258
  /**
1251
- * Observes all new images added to the {@link module:engine/view/document~Document},
1252
- * fires {@link module:engine/view/document~Document#event:imageLoaded} and
1253
- * {@link module:engine/view/document~Document#event:layoutChanged} event every time when the new image
1259
+ * Observes all new images added to the {@link module:engine/view/document~ViewDocument},
1260
+ * fires {@link module:engine/view/document~ViewDocument#event:imageLoaded} and
1261
+ * {@link module:engine/view/document~ViewDocument#event:layoutChanged} event every time when the new image
1254
1262
  * has been loaded.
1255
1263
  *
1256
1264
  * **Note:** This event is not fired for images that has been added to the document and rendered as `complete` (already loaded).
@@ -1277,8 +1285,8 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1277
1285
  this.stopListening(domRoot);
1278
1286
  }
1279
1287
  /**
1280
- * Fires {@link module:engine/view/document~Document#event:layoutChanged} and
1281
- * {@link module:engine/view/document~Document#event:imageLoaded}
1288
+ * Fires {@link module:engine/view/document~ViewDocument#event:layoutChanged} and
1289
+ * {@link module:engine/view/document~ViewDocument#event:imageLoaded}
1282
1290
  * if observer {@link #isEnabled is enabled}.
1283
1291
  *
1284
1292
  * @param domEvent The DOM event.
@@ -1558,8 +1566,9 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1558
1566
  /**
1559
1567
  * Registers the `width` and `height` attributes for inline and block images.
1560
1568
  */ _registerSchema() {
1569
+ const schema = this.editor.model.schema;
1561
1570
  if (this.editor.plugins.has('ImageBlockEditing')) {
1562
- this.editor.model.schema.extend('imageBlock', {
1571
+ schema.extend('imageBlock', {
1563
1572
  allowAttributes: [
1564
1573
  'width',
1565
1574
  'height'
@@ -1567,7 +1576,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1567
1576
  });
1568
1577
  }
1569
1578
  if (this.editor.plugins.has('ImageInlineEditing')) {
1570
- this.editor.model.schema.extend('imageInline', {
1579
+ schema.extend('imageInline', {
1571
1580
  allowAttributes: [
1572
1581
  'width',
1573
1582
  'height'
@@ -1986,7 +1995,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
1986
1995
  // Convert inline images into block images only when the currently selected block is empty
1987
1996
  // (e.g. an empty paragraph) or some object is selected (to replace it).
1988
1997
  if (determineImageTypeForInsertionAtSelection(model.schema, selection) === 'imageBlock') {
1989
- const writer = new UpcastWriter(editingView.document);
1998
+ const writer = new ViewUpcastWriter(editingView.document);
1990
1999
  // Wrap <img ... /> -> <figure class="image"><img .../></figure>
1991
2000
  const blockViewImages = docFragmentChildren.map((inlineViewImage)=>writer.createElement('figure', {
1992
2001
  class: 'image'
@@ -2014,6 +2023,8 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2014
2023
  * The view displayed in the insert image dropdown.
2015
2024
  *
2016
2025
  * See {@link module:image/imageinsert/imageinsertui~ImageInsertUI}.
2026
+ *
2027
+ * @internal
2017
2028
  */ class ImageInsertFormView extends View {
2018
2029
  /**
2019
2030
  * Tracks information about DOM focus in the form.
@@ -2457,7 +2468,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2457
2468
  // Convert block images into inline images only when pasting or dropping into non-empty blocks
2458
2469
  // and when the block is not an object (e.g. pasting to replace another widget).
2459
2470
  if (determineImageTypeForInsertionAtSelection(model.schema, selection) === 'imageInline') {
2460
- const writer = new UpcastWriter(editingView.document);
2471
+ const writer = new ViewUpcastWriter(editingView.document);
2461
2472
  // Unwrap <figure class="image"><img .../></figure> -> <img ... />
2462
2473
  // but <figure class="image"><img .../><figcaption>...</figcaption></figure> -> stays the same
2463
2474
  const inlineViewImages = docFragmentChildren.map((blockViewImage)=>{
@@ -2837,7 +2848,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2837
2848
  const figcaptionElement = writer.createEditableElement('figcaption');
2838
2849
  writer.setCustomProperty('imageCaption', true, figcaptionElement);
2839
2850
  figcaptionElement.placeholder = t('Enter image caption');
2840
- enablePlaceholder({
2851
+ enableViewPlaceholder({
2841
2852
  view,
2842
2853
  element: figcaptionElement,
2843
2854
  keepOnFocus: true
@@ -2908,7 +2919,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2908
2919
  }
2909
2920
  }
2910
2921
  /**
2911
- * Returns the saved {@link module:engine/model/element~Element#toJSON JSONified} caption
2922
+ * Returns the saved {@link module:engine/model/element~ModelElement#toJSON JSONified} caption
2912
2923
  * of an image model element.
2913
2924
  *
2914
2925
  * See {@link #_saveCaption}.
@@ -2918,10 +2929,10 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
2918
2929
  * @returns The model caption element or `null` if there is none.
2919
2930
  */ _getSavedCaption(imageModelElement) {
2920
2931
  const jsonObject = this._savedCaptionsMap.get(imageModelElement);
2921
- return jsonObject ? Element.fromJSON(jsonObject) : null;
2932
+ return jsonObject ? ModelElement.fromJSON(jsonObject) : null;
2922
2933
  }
2923
2934
  /**
2924
- * Saves a {@link module:engine/model/element~Element#toJSON JSONified} caption for
2935
+ * Saves a {@link module:engine/model/element~ModelElement#toJSON JSONified} caption for
2925
2936
  * an image element to allow restoring it in the future.
2926
2937
  *
2927
2938
  * A caption is saved every time it gets hidden and/or the type of an image changes. The
@@ -3065,6 +3076,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3065
3076
  /**
3066
3077
  * Creates a promise that fetches the image local source (Base64 or blob) and resolves with a `File` object.
3067
3078
  *
3079
+ * @internal
3068
3080
  * @param image Image whose source to fetch.
3069
3081
  * @returns A promise which resolves when an image source is fetched and converted to a `File` instance.
3070
3082
  * It resolves with a `File` object. If there were any errors during file processing, the promise will be rejected.
@@ -3094,6 +3106,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3094
3106
  * Checks whether a given node is an image element with a local source (Base64 or blob).
3095
3107
  *
3096
3108
  * @param node The node to check.
3109
+ * @internal
3097
3110
  */ function isLocalImage(imageUtils, node) {
3098
3111
  if (!imageUtils.isInlineImageView(node) || !node.getAttribute('src')) {
3099
3112
  return false;
@@ -3423,7 +3436,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3423
3436
  }, 3000);
3424
3437
  }
3425
3438
  /**
3426
- * Create progress bar element using {@link module:engine/view/uielement~UIElement}.
3439
+ * Create progress bar element using {@link module:engine/view/uielement~ViewUIElement}.
3427
3440
  */ function _createProgressBar(writer) {
3428
3441
  const progressBar = writer.createUIElement('div', {
3429
3442
  class: 'ck-progress-bar'
@@ -3432,7 +3445,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3432
3445
  return progressBar;
3433
3446
  }
3434
3447
  /**
3435
- * Create placeholder element using {@link module:engine/view/uielement~UIElement}.
3448
+ * Create placeholder element using {@link module:engine/view/uielement~ViewUIElement}.
3436
3449
  */ function _createPlaceholder(writer) {
3437
3450
  const placeholder = writer.createUIElement('div', {
3438
3451
  class: 'ck-upload-placeholder-loader'
@@ -3441,7 +3454,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3441
3454
  return placeholder;
3442
3455
  }
3443
3456
  /**
3444
- * Returns {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
3457
+ * Returns {@link module:engine/view/uielement~ViewUIElement} of given unique property from image figure element.
3445
3458
  * Returns `undefined` if element is not found.
3446
3459
  */ function _getUIElement(imageFigure, uniqueProperty) {
3447
3460
  for (const child of imageFigure.getChildren()){
@@ -3451,7 +3464,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3451
3464
  }
3452
3465
  }
3453
3466
  /**
3454
- * Removes {@link module:engine/view/uielement~UIElement} of given unique property from image figure element.
3467
+ * Removes {@link module:engine/view/uielement~ViewUIElement} of given unique property from image figure element.
3455
3468
  */ function _removeUIElement(viewFigure, writer, uniqueProperty) {
3456
3469
  const element = _getUIElement(viewFigure, uniqueProperty);
3457
3470
  if (element) {
@@ -3572,7 +3585,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3572
3585
  * and the `imageUpload` command as an aliased name.
3573
3586
  *
3574
3587
  * When an image is uploaded, it fires the {@link ~ImageUploadEditing#event:uploadComplete `uploadComplete`} event
3575
- * that allows adding custom attributes to the {@link module:engine/model/element~Element image element}.
3588
+ * that allows adding custom attributes to the {@link module:engine/model/element~ModelElement image element}.
3576
3589
  */ class ImageUploadEditing extends Plugin {
3577
3590
  /**
3578
3591
  * @inheritDoc
@@ -3688,7 +3701,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3688
3701
  this.listenTo(editor.editing.view.document, 'clipboardInput', (evt, data)=>{
3689
3702
  // Skip if non empty HTML data is included.
3690
3703
  // https://github.com/ckeditor/ckeditor5-upload/issues/68
3691
- if (isHtmlIncluded(data.dataTransfer)) {
3704
+ if (isHtmlInDataTransfer(data.dataTransfer)) {
3692
3705
  return;
3693
3706
  }
3694
3707
  const images = Array.from(data.dataTransfer.files).filter((file)=>{
@@ -3734,7 +3747,7 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
3734
3747
  if (!fetchableImages.length) {
3735
3748
  return;
3736
3749
  }
3737
- const writer = new UpcastWriter(editor.editing.view.document);
3750
+ const writer = new ViewUpcastWriter(editor.editing.view.document);
3738
3751
  for (const fetchableImage of fetchableImages){
3739
3752
  // Set attribute marking that the image was processed already.
3740
3753
  writer.setAttribute('uploadProcessed', true, fetchableImage.imageElement);
@@ -4044,8 +4057,10 @@ const IMAGE_URL_REGEXP = new RegExp(String(/^(http(s)?:\/\/)?[\w-]+\.[\w.~:/[\]@
4044
4057
  }
4045
4058
  }
4046
4059
  /**
4060
+ * TODO move this to the clipboard package.
4061
+ *
4047
4062
  * Returns `true` if non-empty `text/html` is included in the data transfer.
4048
- */ function isHtmlIncluded(dataTransfer) {
4063
+ */ function isHtmlInDataTransfer(dataTransfer) {
4049
4064
  return Array.from(dataTransfer.types).includes('text/html') && dataTransfer.getData('text/html') !== '';
4050
4065
  }
4051
4066
  function getImagesFromChangeItem(editor, item) {
@@ -4089,6 +4104,8 @@ function getImagesFromChangeItem(editor, item) {
4089
4104
  * The insert an image via URL view.
4090
4105
  *
4091
4106
  * See {@link module:image/imageinsert/imageinsertviaurlui~ImageInsertViaUrlUI}.
4107
+ *
4108
+ * @internal
4092
4109
  */ class ImageInsertUrlView extends View {
4093
4110
  /**
4094
4111
  * The URL input field view.
@@ -4521,21 +4538,34 @@ function getImagesFromChangeItem(editor, item) {
4521
4538
  this._registerSchema();
4522
4539
  }
4523
4540
  _registerSchema() {
4541
+ const schema = this.editor.model.schema;
4524
4542
  if (this.editor.plugins.has('ImageBlockEditing')) {
4525
- this.editor.model.schema.extend('imageBlock', {
4543
+ schema.extend('imageBlock', {
4526
4544
  allowAttributes: [
4527
4545
  'resizedWidth',
4528
4546
  'resizedHeight'
4529
4547
  ]
4530
4548
  });
4549
+ schema.setAttributeProperties('resizedWidth', {
4550
+ isFormatting: true
4551
+ });
4552
+ schema.setAttributeProperties('resizedHeight', {
4553
+ isFormatting: true
4554
+ });
4531
4555
  }
4532
4556
  if (this.editor.plugins.has('ImageInlineEditing')) {
4533
- this.editor.model.schema.extend('imageInline', {
4557
+ schema.extend('imageInline', {
4534
4558
  allowAttributes: [
4535
4559
  'resizedWidth',
4536
4560
  'resizedHeight'
4537
4561
  ]
4538
4562
  });
4563
+ schema.setAttributeProperties('resizedWidth', {
4564
+ isFormatting: true
4565
+ });
4566
+ schema.setAttributeProperties('resizedHeight', {
4567
+ isFormatting: true
4568
+ });
4539
4569
  }
4540
4570
  }
4541
4571
  /**
@@ -4847,7 +4877,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4847
4877
  const customResizeUI = editor.plugins.get('ImageCustomResizeUI');
4848
4878
  definition = {
4849
4879
  type: 'button',
4850
- model: new ViewModel({
4880
+ model: new UIModel({
4851
4881
  label: this._getOptionLabelValue(option),
4852
4882
  role: 'menuitemradio',
4853
4883
  withText: true,
@@ -4862,7 +4892,7 @@ const RESIZE_ICONS = /* #__PURE__ */ (()=>({
4862
4892
  } else {
4863
4893
  definition = {
4864
4894
  type: 'button',
4865
- model: new ViewModel({
4895
+ model: new UIModel({
4866
4896
  commandName: 'resizeImage',
4867
4897
  commandValue: option.valueWithUnits,
4868
4898
  label: this._getOptionLabelValue(option),
@@ -5025,6 +5055,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5025
5055
 
5026
5056
  * @param dimension Unsafe string with dimension.
5027
5057
  * @returns Parsed dimension with extracted numeric value and units.
5058
+ * @internal
5028
5059
  */ function tryParseDimensionWithUnit(dimension) {
5029
5060
  if (!dimension) {
5030
5061
  return null;
@@ -5045,6 +5076,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5045
5076
  * @param parentDimensionPx Dimension of parent element that contains measured element.
5046
5077
  * @param dimension Measured element dimension.
5047
5078
  * @returns Casted dimension.
5079
+ * @internal
5048
5080
  */ function tryCastDimensionsToUnit(parentDimensionPx, dimension, targetUnit) {
5049
5081
  // "%" -> "px" conversion
5050
5082
  if (targetUnit === 'px') {
@@ -5069,6 +5101,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5069
5101
  * Finds model, view and DOM element for selected image element. Returns `null` if there is no image selected.
5070
5102
  *
5071
5103
  * @param editor Editor instance.
5104
+ * @internal
5072
5105
  */ function getSelectedImageEditorNodes(editor) {
5073
5106
  const { editing } = editor;
5074
5107
  const imageUtils = editor.plugins.get('ImageUtils');
@@ -5095,6 +5128,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5095
5128
  * @param editor Editor instance.
5096
5129
  * @param targetUnit Unit in which dimension will be returned.
5097
5130
  * @returns Parsed image width after resize (with unit).
5131
+ * @internal
5098
5132
  */ function getSelectedImageWidthInUnits(editor, targetUnit) {
5099
5133
  const imageNodes = getSelectedImageEditorNodes(editor);
5100
5134
  if (!imageNodes) {
@@ -5116,6 +5150,8 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5116
5150
 
5117
5151
  /**
5118
5152
  * The ImageCustomResizeFormView class.
5153
+ *
5154
+ * @internal
5119
5155
  */ class ImageCustomResizeFormView extends View {
5120
5156
  /**
5121
5157
  * Tracks information about the DOM focus in the form.
@@ -5346,6 +5382,7 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5346
5382
  * @param editor Editor instance.
5347
5383
  * @param targetUnit Unit in which dimension will be returned.
5348
5384
  * @returns Possible resize range in numeric form.
5385
+ * @internal
5349
5386
  */ function getSelectedImagePossibleResizeRange(editor, targetUnit) {
5350
5387
  const imageNodes = getSelectedImageEditorNodes(editor);
5351
5388
  if (!imageNodes) {
@@ -5671,6 +5708,8 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5671
5708
  * * **`'inline'`** is an inline image without any CSS class,
5672
5709
  * * **`'block'`** is a block image without any CSS class,
5673
5710
  * * **`'side'`** is a block image styled with the `image-style-side` CSS class.
5711
+ *
5712
+ * @internal
5674
5713
  */ const DEFAULT_OPTIONS = {
5675
5714
  // This style represents an image placed in the line of text.
5676
5715
  get inline () {
@@ -5778,6 +5817,8 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5778
5817
  * See {@link module:image/imageconfig~ImageStyleOptionDefinition#icon} to learn more.
5779
5818
  *
5780
5819
  * There are 7 default icons available: `'full'`, `'left'`, `'inlineLeft'`, `'center'`, `'right'`, `'inlineRight'`, and `'inline'`.
5820
+ *
5821
+ * @internal
5781
5822
  */ const DEFAULT_ICONS = /* #__PURE__ */ (()=>({
5782
5823
  full: IconObjectFullWidth,
5783
5824
  left: IconObjectLeft,
@@ -5797,6 +5838,8 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5797
5838
  * those that wraps the text around the image,
5798
5839
  * * **`'imageStyle:breakText'`**, which contains the `alignBlockLeft`, `alignCenter` and `alignBlockRight` options, that is,
5799
5840
  * those that breaks the text around the image.
5841
+ *
5842
+ * @internal
5800
5843
  */ const DEFAULT_DROPDOWN_DEFINITIONS = [
5801
5844
  {
5802
5845
  name: 'imageStyle:wrapText',
@@ -5994,14 +6037,13 @@ const RESIZED_IMAGE_CLASS = 'image_resized';
5994
6037
  * @param {object} info The information about the invalid definition.
5995
6038
  */ logWarning('image-style-configuration-definition-invalid', info);
5996
6039
  }
5997
- var utils = {
6040
+ /**
6041
+ * @internal
6042
+ */ const utils = {
5998
6043
  normalizeStyles,
5999
6044
  getDefaultStylesConfiguration,
6000
6045
  getDefaultDropdownDefinitions,
6001
- warnInvalidStyle,
6002
- DEFAULT_OPTIONS,
6003
- DEFAULT_ICONS,
6004
- DEFAULT_DROPDOWN_DEFINITIONS
6046
+ warnInvalidStyle
6005
6047
  };
6006
6048
 
6007
6049
  /**
@@ -6011,6 +6053,7 @@ var utils = {
6011
6053
  *
6012
6054
  * @param styles An array containing available image style options.
6013
6055
  * @returns A model-to-view attribute converter.
6056
+ * @internal
6014
6057
  */ function modelToViewStyleAttribute(styles) {
6015
6058
  return (evt, data, conversionApi)=>{
6016
6059
  if (!conversionApi.consumable.consume(data.item, evt.name)) {
@@ -6034,6 +6077,7 @@ var utils = {
6034
6077
  *
6035
6078
  * @param styles Image style options for which the converter is created.
6036
6079
  * @returns A view-to-model converter.
6080
+ * @internal
6037
6081
  */ function viewToModelStyleAttribute(styles) {
6038
6082
  // Convert only non–default styles.
6039
6083
  const nonDefaultStyles = {
@@ -6112,12 +6156,11 @@ var utils = {
6112
6156
  /**
6113
6157
  * @inheritDoc
6114
6158
  */ init() {
6115
- const { normalizeStyles, getDefaultStylesConfiguration } = utils;
6116
6159
  const editor = this.editor;
6117
6160
  const isBlockPluginLoaded = editor.plugins.has('ImageBlockEditing');
6118
6161
  const isInlinePluginLoaded = editor.plugins.has('ImageInlineEditing');
6119
- editor.config.define('image.styles', getDefaultStylesConfiguration(isBlockPluginLoaded, isInlinePluginLoaded));
6120
- this.normalizedStyles = normalizeStyles({
6162
+ editor.config.define('image.styles', utils.getDefaultStylesConfiguration(isBlockPluginLoaded, isInlinePluginLoaded));
6163
+ this.normalizedStyles = utils.normalizeStyles({
6121
6164
  configuredStyles: editor.config.get('image.styles'),
6122
6165
  isBlockPluginLoaded,
6123
6166
  isInlinePluginLoaded
@@ -6144,6 +6187,9 @@ var utils = {
6144
6187
  schema.extend('imageBlock', {
6145
6188
  allowAttributes: 'imageStyle'
6146
6189
  });
6190
+ schema.setAttributeProperties('imageStyle', {
6191
+ isFormatting: true
6192
+ });
6147
6193
  // Converter for figure element from view to model.
6148
6194
  editor.data.upcastDispatcher.on('element:figure', viewToModelConverter, {
6149
6195
  priority: 'low'
@@ -6153,6 +6199,9 @@ var utils = {
6153
6199
  schema.extend('imageInline', {
6154
6200
  allowAttributes: 'imageStyle'
6155
6201
  });
6202
+ schema.setAttributeProperties('imageStyle', {
6203
+ isFormatting: true
6204
+ });
6156
6205
  // Converter for the img element from view to model.
6157
6206
  editor.data.upcastDispatcher.on('element:img', viewToModelConverter, {
6158
6207
  priority: 'low'
@@ -6583,5 +6632,5 @@ var utils = {
6583
6632
  }
6584
6633
  }
6585
6634
 
6586
- export { AutoImage, Image, ImageBlock, ImageBlockEditing, ImageCaption, ImageCaptionEditing, ImageCaptionUI, ImageCaptionUtils, ImageCustomResizeUI, ImageEditing, ImageInline, ImageInsert, ImageInsertUI, ImageInsertViaUrl, ImageResize, ImageResizeButtons, ImageResizeEditing, ImageResizeHandles, ImageSizeAttributes, ImageStyle, ImageStyleEditing, ImageStyleUI, ImageTextAlternative, ImageTextAlternativeEditing, ImageTextAlternativeUI, ImageToolbar, ImageUpload, ImageUploadEditing, ImageUploadProgress, ImageUploadUI, ImageUtils, PictureEditing, createImageTypeRegExp };
6635
+ export { AutoImage, Image, ImageBlock, ImageBlockEditing, ImageCaption, ImageCaptionEditing, ImageCaptionUI, ImageCaptionUtils, ImageCustomResizeUI, ImageEditing, ImageInline, ImageInlineEditing, ImageInsert, ImageInsertUI, ImageInsertViaUrl, ImageInsertViaUrlUI, ImageLoadObserver, ImagePlaceholder, ImageResize, ImageResizeButtons, ImageResizeEditing, ImageResizeHandles, ImageSizeAttributes, ImageStyle, ImageStyleCommand, ImageStyleEditing, ImageStyleUI, ImageTextAlternative, ImageTextAlternativeCommand, ImageTextAlternativeEditing, ImageTextAlternativeUI, ImageToolbar, ImageTypeCommand, ImageUpload, ImageUploadEditing, ImageUploadProgress, ImageUploadUI, ImageUtils, InsertImageCommand, PictureEditing, ReplaceImageSourceCommand, ResizeImageCommand, ToggleImageCaptionCommand, UploadImageCommand, DEFAULT_DROPDOWN_DEFINITIONS as _IMAGE_DEFAULT_DROPDOWN_DEFINITIONS, DEFAULT_ICONS as _IMAGE_DEFAULT_ICONS, DEFAULT_OPTIONS as _IMAGE_DEFAULT_OPTIONS, ImageCustomResizeFormView as _ImageCustomResizeFormView, ImageInsertFormView as _ImageInsertFormView, ImageInsertUrlView as _ImageInsertUrlView, utils as _ImageStyleUtils, TextAlternativeFormView as _ImageTextAlternativeFormView, widthAndHeightStylesAreBothSet as _checkIfImageWidthAndHeightStylesAreBothSet, createBlockImageViewElement as _createBlockImageViewElement, createInlineImageViewElement as _createInlineImageViewElement, determineImageTypeForInsertionAtSelection as _determineImageTypeForInsertionAtSelection, downcastImageAttribute as _downcastImageAttribute, downcastSourcesAttribute as _downcastImageSourcesAttribute, downcastSrcsetAttribute as _downcastImageSrcsetAttribute, fetchLocalImage as _fetchLocalImage, getBalloonPositionData as _getImageBalloonPositionData, getSizeValueIfInPx as _getImageSizeValueIfInPx, getImgViewElementMatcher as _getImageViewElementMatcher, getSelectedImageEditorNodes as _getSelectedImageEditorNodes, getSelectedImagePossibleResizeRange as _getSelectedImagePossibleResizeRange, getSelectedImageWidthInUnits as _getSelectedImageWidthInUnits, isLocalImage as _isLocalImage, modelToViewStyleAttribute as _modelToViewImageStyleAttribute, repositionContextualBalloon as _repositionImageContextualBalloon, tryCastDimensionsToUnit as _tryCastImageDimensionsToUnit, tryParseDimensionWithUnit as _tryParseImageDimensionWithUnit, upcastImageFigure as _upcastImageFigure, upcastPicture as _upcastImagePicture, viewToModelStyleAttribute as _viewToModelImageStyleAttribute, createImageTypeRegExp, isHtmlInDataTransfer };
6587
6636
  //# sourceMappingURL=index.js.map