@ckeditor/ckeditor5-image 27.1.0 → 29.2.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 (167) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +3 -3
  3. package/build/image.js +1 -1
  4. package/build/translations/ar.js +1 -0
  5. package/build/translations/ast.js +1 -0
  6. package/build/translations/az.js +1 -0
  7. package/build/translations/bg.js +1 -0
  8. package/build/translations/cs.js +1 -0
  9. package/build/translations/da.js +1 -0
  10. package/build/translations/de-ch.js +1 -0
  11. package/build/translations/de.js +1 -0
  12. package/build/translations/el.js +1 -0
  13. package/build/translations/en-au.js +1 -0
  14. package/build/translations/en-gb.js +1 -0
  15. package/build/translations/eo.js +1 -0
  16. package/build/translations/es.js +1 -0
  17. package/build/translations/et.js +1 -0
  18. package/build/translations/eu.js +1 -0
  19. package/build/translations/fa.js +1 -0
  20. package/build/translations/fi.js +1 -0
  21. package/build/translations/fr.js +1 -0
  22. package/build/translations/gl.js +1 -0
  23. package/build/translations/he.js +1 -0
  24. package/build/translations/hi.js +1 -0
  25. package/build/translations/hr.js +1 -0
  26. package/build/translations/hu.js +1 -0
  27. package/build/translations/id.js +1 -0
  28. package/build/translations/it.js +1 -0
  29. package/build/translations/ja.js +1 -0
  30. package/build/translations/km.js +1 -0
  31. package/build/translations/kn.js +1 -0
  32. package/build/translations/ko.js +1 -0
  33. package/build/translations/ku.js +1 -0
  34. package/build/translations/lt.js +1 -0
  35. package/build/translations/lv.js +1 -0
  36. package/build/translations/nb.js +1 -0
  37. package/build/translations/ne.js +1 -0
  38. package/build/translations/nl.js +1 -0
  39. package/build/translations/no.js +1 -0
  40. package/build/translations/pl.js +1 -0
  41. package/build/translations/pt-br.js +1 -0
  42. package/build/translations/pt.js +1 -0
  43. package/build/translations/ro.js +1 -0
  44. package/build/translations/ru.js +1 -0
  45. package/build/translations/si.js +1 -0
  46. package/build/translations/sk.js +1 -0
  47. package/build/translations/sq.js +1 -0
  48. package/build/translations/sr-latn.js +1 -0
  49. package/build/translations/sr.js +1 -0
  50. package/build/translations/sv.js +1 -0
  51. package/build/translations/th.js +1 -0
  52. package/build/translations/tk.js +1 -0
  53. package/build/translations/tr.js +1 -0
  54. package/build/translations/ug.js +1 -0
  55. package/build/translations/uk.js +1 -0
  56. package/build/translations/vi.js +1 -0
  57. package/build/translations/zh-cn.js +1 -0
  58. package/build/translations/zh.js +1 -0
  59. package/ckeditor5-metadata.json +233 -0
  60. package/lang/contexts.json +3 -0
  61. package/lang/translations/ar.po +12 -0
  62. package/lang/translations/ast.po +12 -0
  63. package/lang/translations/az.po +12 -0
  64. package/lang/translations/bg.po +12 -0
  65. package/lang/translations/cs.po +12 -0
  66. package/lang/translations/da.po +12 -0
  67. package/lang/translations/de-ch.po +113 -0
  68. package/lang/translations/de.po +15 -3
  69. package/lang/translations/el.po +12 -0
  70. package/lang/translations/en-au.po +12 -0
  71. package/lang/translations/en-gb.po +12 -0
  72. package/lang/translations/en.po +12 -0
  73. package/lang/translations/eo.po +12 -0
  74. package/lang/translations/es.po +12 -0
  75. package/lang/translations/et.po +12 -0
  76. package/lang/translations/eu.po +12 -0
  77. package/lang/translations/fa.po +12 -0
  78. package/lang/translations/fi.po +12 -0
  79. package/lang/translations/fr.po +12 -0
  80. package/lang/translations/gl.po +12 -0
  81. package/lang/translations/he.po +12 -0
  82. package/lang/translations/hi.po +12 -0
  83. package/lang/translations/hr.po +12 -0
  84. package/lang/translations/hu.po +13 -1
  85. package/lang/translations/id.po +21 -9
  86. package/lang/translations/it.po +12 -0
  87. package/lang/translations/ja.po +12 -0
  88. package/lang/translations/km.po +12 -0
  89. package/lang/translations/kn.po +12 -0
  90. package/lang/translations/ko.po +12 -0
  91. package/lang/translations/ku.po +12 -0
  92. package/lang/translations/lt.po +12 -0
  93. package/lang/translations/lv.po +12 -0
  94. package/lang/translations/nb.po +12 -0
  95. package/lang/translations/ne.po +12 -0
  96. package/lang/translations/nl.po +12 -0
  97. package/lang/translations/no.po +12 -0
  98. package/lang/translations/pl.po +20 -8
  99. package/lang/translations/pt-br.po +12 -0
  100. package/lang/translations/pt.po +12 -0
  101. package/lang/translations/ro.po +21 -9
  102. package/lang/translations/ru.po +12 -0
  103. package/lang/translations/si.po +12 -0
  104. package/lang/translations/sk.po +12 -0
  105. package/lang/translations/sq.po +12 -0
  106. package/lang/translations/sr-latn.po +12 -0
  107. package/lang/translations/sr.po +12 -0
  108. package/lang/translations/sv.po +12 -0
  109. package/lang/translations/th.po +12 -0
  110. package/lang/translations/tk.po +12 -0
  111. package/lang/translations/tr.po +12 -0
  112. package/lang/translations/ug.po +12 -0
  113. package/lang/translations/uk.po +12 -0
  114. package/lang/translations/vi.po +12 -0
  115. package/lang/translations/zh-cn.po +12 -0
  116. package/lang/translations/zh.po +12 -0
  117. package/package.json +36 -29
  118. package/src/autoimage.js +6 -4
  119. package/src/image/converters.js +192 -13
  120. package/src/image/imageblockediting.js +179 -0
  121. package/src/image/imageediting.js +13 -70
  122. package/src/image/imageinlineediting.js +204 -0
  123. package/src/image/imagetypecommand.js +105 -0
  124. package/src/image/insertimagecommand.js +77 -10
  125. package/src/image/ui/utils.js +3 -3
  126. package/src/image/utils.js +70 -121
  127. package/src/image.js +7 -19
  128. package/src/imageblock.js +46 -0
  129. package/src/imagecaption/imagecaptionediting.js +202 -230
  130. package/src/imagecaption/imagecaptionui.js +78 -0
  131. package/src/imagecaption/toggleimagecaptioncommand.js +165 -0
  132. package/src/imagecaption/utils.js +25 -40
  133. package/src/imagecaption.js +3 -2
  134. package/src/imageinline.js +46 -0
  135. package/src/imageinsert/imageinsertui.js +5 -6
  136. package/src/imageinsert.js +16 -4
  137. package/src/imageresize/imageresizebuttons.js +1 -1
  138. package/src/imageresize/imageresizeediting.js +21 -8
  139. package/src/imageresize/imageresizehandles.js +30 -8
  140. package/src/imageresize/resizeimagecommand.js +8 -5
  141. package/src/imagestyle/converters.js +25 -17
  142. package/src/imagestyle/imagestylecommand.js +73 -33
  143. package/src/imagestyle/imagestyleediting.js +113 -52
  144. package/src/imagestyle/imagestyleui.js +197 -31
  145. package/src/imagestyle/utils.js +300 -85
  146. package/src/imagestyle.js +218 -47
  147. package/src/imagetextalternative/imagetextalternativecommand.js +10 -7
  148. package/src/imagetextalternative/imagetextalternativeediting.js +9 -1
  149. package/src/imagetextalternative/imagetextalternativeui.js +2 -2
  150. package/src/imagetextalternative.js +1 -1
  151. package/src/imagetoolbar.js +33 -11
  152. package/src/imageupload/imageuploadediting.js +91 -31
  153. package/src/imageupload/imageuploadprogress.js +17 -9
  154. package/src/imageupload/imageuploadui.js +1 -1
  155. package/src/imageupload/uploadimagecommand.js +50 -24
  156. package/src/imageupload/utils.js +3 -2
  157. package/src/imageupload.js +1 -1
  158. package/src/imageutils.js +342 -0
  159. package/src/index.js +22 -47
  160. package/src/pictureediting.js +149 -0
  161. package/theme/image.css +101 -21
  162. package/theme/imagecaption.css +24 -2
  163. package/theme/imageresize.css +11 -0
  164. package/theme/imagestyle.css +76 -0
  165. package/theme/imageuploadicon.css +8 -2
  166. package/theme/imageuploadprogress.css +12 -8
  167. package/build/image.js.map +0 -1
package/theme/image.css CHANGED
@@ -3,34 +3,114 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
6
- .ck-content .image {
7
- display: table;
8
- clear: both;
9
- text-align: center;
6
+ .ck-content {
7
+ & .image {
8
+ display: table;
9
+ clear: both;
10
+ text-align: center;
10
11
 
11
- /* Make sure there is some space between the content and the image. Center image by default. */
12
- margin: 1em auto;
12
+ /* Make sure there is some space between the content and the image. Center image by default. */
13
+ /* The first value should be equal to --ck-spacing-large variable if used in the editor context
14
+ to avoid the content jumping (See https://github.com/ckeditor/ckeditor5/issues/9825). */
15
+ margin: 0.9em auto;
13
16
 
14
- & img {
15
- /* Prevent unnecessary margins caused by line-height (see #44). */
16
- display: block;
17
+ /* Make sure the caption will be displayed properly (See: https://github.com/ckeditor/ckeditor5/issues/1870). */
18
+ min-width: 50px;
19
+
20
+ & img {
21
+ /* Prevent unnecessary margins caused by line-height (see #44). */
22
+ display: block;
23
+
24
+ /* Center the image if its width is smaller than the content's width. */
25
+ margin: 0 auto;
26
+
27
+ /* Make sure the image never exceeds the size of the parent container (ckeditor/ckeditor5-ui#67). */
28
+ max-width: 100%;
29
+
30
+ /* Make sure the image is never smaller than the parent container (See: https://github.com/ckeditor/ckeditor5/issues/9300). */
31
+ min-width: 100%
32
+ }
33
+ }
17
34
 
18
- /* Center the image if its width is smaller than the content's width. */
19
- margin: 0 auto;
35
+ & .image-inline {
36
+ /*
37
+ * Normally, the .image-inline would have "display: inline-block" and "img { width: 100% }" (to follow the wrapper while resizing).
38
+ * Unfortunately, together with "srcset", it gets automatically stretched up to the width of the editing root.
39
+ * This strange behavior does not happen with inline-flex.
40
+ */
41
+ display: inline-flex;
20
42
 
21
- /* Make sure the image never exceeds the size of the parent container (ckeditor/ckeditor5-ui#67). */
43
+ /* While being resized, don't allow the image to exceed the width of the editing root. */
22
44
  max-width: 100%;
23
45
 
24
- /* Make sure the caption will be displayed properly (See: https://github.com/ckeditor/ckeditor5/issues/1870). */
25
- min-width: 50px;
46
+ /* This is required by Safari to resize images in a sensible way. Without this, the browser breaks the ratio. */
47
+ align-items: flex-start;
48
+
49
+ /* When the picture is present it must act as a flex container to let the img resize properly */
50
+ & picture {
51
+ display: flex;
52
+ }
53
+
54
+ /* When the picture is present, it must act like a resizable img. */
55
+ & picture,
56
+ & img {
57
+ /* This is necessary for the img to span the entire .image-inline wrapper and to resize properly. */
58
+ flex-grow: 1;
59
+ flex-shrink: 1;
60
+
61
+ /* Prevents overflowing the editing root boundaries when an inline image is very wide. */
62
+ max-width: 100%;
63
+ }
26
64
  }
27
65
  }
28
66
 
29
- /*
30
- * Since the caption placeholder for images disappears when focused, it does not require special treatment
31
- * and can go with a position that follows text alignment of an .image out-of-the-box (center by default).
32
- * See https://github.com/ckeditor/ckeditor5/issues/8689.
33
- */
34
- .ck.ck-editor__editable .image > figcaption.ck-placeholder::before {
35
- position: static;
67
+ .ck.ck-editor__editable {
68
+ /*
69
+ * Inhertit the content styles padding of the <figcaption> in case the integration overrides `text-align: center`
70
+ * of `.image` (e.g. to the left/right). This ensures the placeholder stays at the padding just like the native
71
+ * caret does, and not at the edge of <figcaption>.
72
+ */
73
+ & .image > figcaption.ck-placeholder::before {
74
+ padding-left: inherit;
75
+ padding-right: inherit;
76
+
77
+ /*
78
+ * Make sure the image caption placeholder doesn't overflow the placeholder area.
79
+ * See https://github.com/ckeditor/ckeditor5/issues/9162.
80
+ */
81
+ white-space: nowrap;
82
+ overflow: hidden;
83
+ text-overflow: ellipsis;
84
+ }
85
+
86
+
87
+ /*
88
+ * Make sure the selected inline image always stays on top of its siblings.
89
+ * See https://github.com/ckeditor/ckeditor5/issues/9108.
90
+ */
91
+ & .image.ck-widget_selected {
92
+ z-index: 1;
93
+ }
94
+
95
+ & .image-inline.ck-widget_selected {
96
+ z-index: 1;
97
+
98
+ /*
99
+ * Make sure the native browser selection style is not displayed.
100
+ * Inline image widgets have their own styles for the selected state and
101
+ * leaving this up to the browser is asking for a visual collision.
102
+ */
103
+ & ::selection {
104
+ display: none;
105
+ }
106
+ }
107
+
108
+ /* The inline image nested in the table should have its original size if not resized.
109
+ See https://github.com/ckeditor/ckeditor5/issues/9117. */
110
+ & td,
111
+ & th {
112
+ & .image-inline img {
113
+ max-width: none;
114
+ }
115
+ }
36
116
  }
@@ -3,13 +3,35 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
6
+ :root {
7
+ --ck-color-image-caption-background: hsl(0, 0%, 97%);
8
+ --ck-color-image-caption-text: hsl(0, 0%, 20%);
9
+ --ck-color-image-caption-highligted-background: hsl(52deg 100% 50%);
10
+ }
11
+
12
+ /* Content styles */
6
13
  .ck-content .image > figcaption {
7
14
  display: table-caption;
8
15
  caption-side: bottom;
9
16
  word-break: break-word;
10
- color: hsl(0, 0%, 20%);
11
- background-color: hsl(0, 0%, 97%);
17
+ color: var(--ck-color-image-caption-text);
18
+ background-color: var(--ck-color-image-caption-background);
12
19
  padding: .6em;
13
20
  font-size: .75em;
14
21
  outline-offset: -1px;
15
22
  }
23
+
24
+ /* Editing styles */
25
+ .ck.ck-editor__editable .image > figcaption.image__caption_highlighted {
26
+ animation: ck-image-caption-highlight .6s ease-out;
27
+ }
28
+
29
+ @keyframes ck-image-caption-highlight {
30
+ 0% {
31
+ background-color: var(--ck-color-image-caption-highligted-background);
32
+ }
33
+
34
+ 100% {
35
+ background-color: var(--ck-color-image-caption-background);
36
+ }
37
+ }
@@ -24,6 +24,17 @@
24
24
  }
25
25
  }
26
26
 
27
+ .ck.ck-editor__editable {
28
+ /* The resized inline image nested in the table should respect its parent size.
29
+ See https://github.com/ckeditor/ckeditor5/issues/9117. */
30
+ & td,
31
+ & th {
32
+ & .image-inline.image_resized img {
33
+ max-width: 100%;
34
+ }
35
+ }
36
+ }
37
+
27
38
  [dir="ltr"] .ck.ck-button.ck-button_with-text.ck-resize-image-button .ck-button__icon {
28
39
  margin-right: var(--ck-spacing-standard);
29
40
  }
@@ -5,9 +5,25 @@
5
5
 
6
6
  :root {
7
7
  --ck-image-style-spacing: 1.5em;
8
+ --ck-inline-image-style-spacing: calc(var(--ck-image-style-spacing) / 2);
8
9
  }
9
10
 
10
11
  .ck-content {
12
+ /* Provides a minimal side margin for the left and right aligned images, so that the user has a visual feedback
13
+ confirming successful application of the style if image width exceeds the editor's size.
14
+ See https://github.com/ckeditor/ckeditor5/issues/9342 */
15
+ & .image-style-block-align-left,
16
+ & .image-style-block-align-right {
17
+ max-width: calc(100% - var(--ck-image-style-spacing));
18
+ }
19
+
20
+ /* Allows displaying multiple floating images in the same line.
21
+ See https://github.com/ckeditor/ckeditor5/issues/9183#issuecomment-804988132 */
22
+ & .image-style-align-left,
23
+ & .image-style-align-right {
24
+ clear: none;
25
+ }
26
+
11
27
  & .image-style-side {
12
28
  float: right;
13
29
  margin-left: var(--ck-image-style-spacing);
@@ -28,4 +44,64 @@
28
44
  float: right;
29
45
  margin-left: var(--ck-image-style-spacing);
30
46
  }
47
+
48
+ & .image-style-block-align-right {
49
+ margin-right: 0;
50
+ margin-left: auto;
51
+ }
52
+
53
+ & .image-style-block-align-left {
54
+ margin-left: 0;
55
+ margin-right: auto;
56
+ }
57
+
58
+ /* Simulates margin collapsing with the preceding paragraph, which does not work for the floating elements. */
59
+ & p + .image-style-align-left,
60
+ & p + .image-style-align-right,
61
+ & p + .image-style-side {
62
+ margin-top: 0;
63
+ }
64
+
65
+ & .image-inline {
66
+ &.image-style-align-left,
67
+ &.image-style-align-right {
68
+ margin-top: var(--ck-inline-image-style-spacing);
69
+ margin-bottom: var(--ck-inline-image-style-spacing);
70
+ }
71
+
72
+ &.image-style-align-left {
73
+ margin-right: var(--ck-inline-image-style-spacing);
74
+ }
75
+
76
+ &.image-style-align-right {
77
+ margin-left: var(--ck-inline-image-style-spacing);
78
+ }
79
+ }
80
+ }
81
+
82
+ .ck.ck-splitbutton {
83
+ /* The button should display as a regular drop-down if the action button
84
+ is forced to fire the same action as the arrow button. */
85
+ &.ck-splitbutton_flatten {
86
+ &:hover,
87
+ &.ck-splitbutton_open {
88
+ & > .ck-splitbutton__action:not(.ck-disabled),
89
+ & > .ck-splitbutton__arrow:not(.ck-disabled),
90
+ & > .ck-splitbutton__arrow:not(.ck-disabled):not(:hover) {
91
+ background-color: var(--ck-color-button-on-background);
92
+
93
+ &::after {
94
+ display: none;
95
+ }
96
+ }
97
+ }
98
+
99
+ &.ck-splitbutton_open:hover {
100
+ & > .ck-splitbutton__action:not(.ck-disabled),
101
+ & > .ck-splitbutton__arrow:not(.ck-disabled),
102
+ & > .ck-splitbutton__arrow:not(.ck-disabled):not(:hover) {
103
+ background-color: var(--ck-color-button-on-hover-background);
104
+ }
105
+ }
106
+ }
31
107
  }
@@ -6,9 +6,15 @@
6
6
  .ck-image-upload-complete-icon {
7
7
  display: block;
8
8
  position: absolute;
9
- top: 10px;
10
- right: 10px;
9
+
10
+ /*
11
+ * Smaller images should have the icon closer to the border.
12
+ * Match the icon position with the linked image indicator brought by the link image feature.
13
+ */
14
+ top: min(var(--ck-spacing-medium), 6%);
15
+ right: min(var(--ck-spacing-medium), 6%);
11
16
  border-radius: 50%;
17
+ z-index: 1;
12
18
 
13
19
  &::after {
14
20
  content: "";
@@ -3,13 +3,17 @@
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
4
  */
5
5
 
6
- .ck.ck-editor__editable .image {
7
- position: relative;
8
- }
6
+ .ck.ck-editor__editable {
7
+ & .image,
8
+ & .image-inline {
9
+ position: relative;
10
+ }
9
11
 
10
- /* Upload progress bar. */
11
- .ck.ck-editor__editable .image .ck-progress-bar {
12
- position: absolute;
13
- top: 0;
14
- left: 0;
12
+ /* Upload progress bar. */
13
+ & .image .ck-progress-bar,
14
+ & .image-inline .ck-progress-bar {
15
+ position: absolute;
16
+ top: 0;
17
+ left: 0;
18
+ }
15
19
  }