@ckeditor/ckeditor5-ckbox 40.1.0 → 40.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/build/ckbox.js +2 -2
  2. package/build/translations/ar.js +1 -1
  3. package/build/translations/az.js +1 -1
  4. package/build/translations/bg.js +1 -1
  5. package/build/translations/bn.js +1 -1
  6. package/build/translations/ca.js +1 -1
  7. package/build/translations/cs.js +1 -1
  8. package/build/translations/da.js +1 -1
  9. package/build/translations/de.js +1 -1
  10. package/build/translations/el.js +1 -1
  11. package/build/translations/en-au.js +1 -1
  12. package/build/translations/es-co.js +1 -1
  13. package/build/translations/es.js +1 -1
  14. package/build/translations/et.js +1 -1
  15. package/build/translations/fa.js +1 -1
  16. package/build/translations/fi.js +1 -1
  17. package/build/translations/fr.js +1 -1
  18. package/build/translations/gl.js +1 -1
  19. package/build/translations/he.js +1 -1
  20. package/build/translations/hi.js +1 -1
  21. package/build/translations/hr.js +1 -1
  22. package/build/translations/hu.js +1 -1
  23. package/build/translations/id.js +1 -1
  24. package/build/translations/it.js +1 -1
  25. package/build/translations/ja.js +1 -1
  26. package/build/translations/ko.js +1 -1
  27. package/build/translations/lt.js +1 -1
  28. package/build/translations/lv.js +1 -1
  29. package/build/translations/ms.js +1 -1
  30. package/build/translations/nl.js +1 -1
  31. package/build/translations/no.js +1 -1
  32. package/build/translations/pl.js +1 -1
  33. package/build/translations/pt-br.js +1 -1
  34. package/build/translations/pt.js +1 -1
  35. package/build/translations/ro.js +1 -1
  36. package/build/translations/ru.js +1 -1
  37. package/build/translations/sk.js +1 -1
  38. package/build/translations/sq.js +1 -1
  39. package/build/translations/sr-latn.js +1 -1
  40. package/build/translations/sr.js +1 -1
  41. package/build/translations/sv.js +1 -1
  42. package/build/translations/th.js +1 -1
  43. package/build/translations/tr.js +1 -1
  44. package/build/translations/ug.js +1 -1
  45. package/build/translations/uk.js +1 -1
  46. package/build/translations/ur.js +1 -1
  47. package/build/translations/uz.js +1 -1
  48. package/build/translations/vi.js +1 -1
  49. package/build/translations/zh-cn.js +1 -1
  50. package/build/translations/zh.js +1 -1
  51. package/ckeditor5-metadata.json +17 -0
  52. package/lang/contexts.json +6 -2
  53. package/lang/translations/ar.po +18 -2
  54. package/lang/translations/az.po +18 -2
  55. package/lang/translations/bg.po +18 -2
  56. package/lang/translations/bn.po +18 -2
  57. package/lang/translations/ca.po +18 -2
  58. package/lang/translations/cs.po +18 -2
  59. package/lang/translations/da.po +18 -2
  60. package/lang/translations/de.po +18 -2
  61. package/lang/translations/el.po +18 -2
  62. package/lang/translations/en-au.po +18 -2
  63. package/lang/translations/en.po +18 -2
  64. package/lang/translations/es-co.po +18 -2
  65. package/lang/translations/es.po +18 -2
  66. package/lang/translations/et.po +18 -2
  67. package/lang/translations/fa.po +18 -2
  68. package/lang/translations/fi.po +18 -2
  69. package/lang/translations/fr.po +18 -2
  70. package/lang/translations/gl.po +18 -2
  71. package/lang/translations/he.po +18 -2
  72. package/lang/translations/hi.po +18 -2
  73. package/lang/translations/hr.po +18 -2
  74. package/lang/translations/hu.po +18 -2
  75. package/lang/translations/id.po +18 -2
  76. package/lang/translations/it.po +18 -2
  77. package/lang/translations/ja.po +18 -2
  78. package/lang/translations/ko.po +18 -2
  79. package/lang/translations/lt.po +18 -2
  80. package/lang/translations/lv.po +18 -2
  81. package/lang/translations/ms.po +18 -2
  82. package/lang/translations/nl.po +18 -2
  83. package/lang/translations/no.po +18 -2
  84. package/lang/translations/pl.po +18 -2
  85. package/lang/translations/pt-br.po +18 -2
  86. package/lang/translations/pt.po +18 -2
  87. package/lang/translations/ro.po +18 -2
  88. package/lang/translations/ru.po +18 -2
  89. package/lang/translations/sk.po +18 -2
  90. package/lang/translations/sq.po +18 -2
  91. package/lang/translations/sr-latn.po +18 -2
  92. package/lang/translations/sr.po +18 -2
  93. package/lang/translations/sv.po +18 -2
  94. package/lang/translations/th.po +18 -2
  95. package/lang/translations/tr.po +18 -2
  96. package/lang/translations/ug.po +18 -2
  97. package/lang/translations/uk.po +18 -2
  98. package/lang/translations/ur.po +18 -2
  99. package/lang/translations/uz.po +18 -2
  100. package/lang/translations/vi.po +18 -2
  101. package/lang/translations/zh-cn.po +18 -2
  102. package/lang/translations/zh.po +18 -2
  103. package/package.json +4 -3
  104. package/src/augmentation.d.ts +11 -1
  105. package/src/ckboxcommand.d.ts +8 -6
  106. package/src/ckboxcommand.js +5 -1
  107. package/src/ckboxconfig.d.ts +26 -0
  108. package/src/ckboxediting.d.ts +5 -12
  109. package/src/ckboxediting.js +7 -55
  110. package/src/ckboximageedit/ckboximageeditcommand.d.ts +97 -0
  111. package/src/ckboximageedit/ckboximageeditcommand.js +298 -0
  112. package/src/ckboximageedit/ckboximageeditediting.d.ts +28 -0
  113. package/src/ckboximageedit/ckboximageeditediting.js +36 -0
  114. package/src/ckboximageedit/ckboximageeditui.d.ts +24 -0
  115. package/src/ckboximageedit/ckboximageeditui.js +48 -0
  116. package/src/ckboximageedit/utils.d.ts +10 -0
  117. package/src/ckboximageedit/utils.js +48 -0
  118. package/src/ckboximageedit.d.ts +24 -0
  119. package/src/ckboximageedit.js +28 -0
  120. package/src/ckboxui.js +28 -1
  121. package/src/ckboxuploadadapter.d.ts +0 -5
  122. package/src/ckboxuploadadapter.js +15 -160
  123. package/src/ckboxutils.d.ts +50 -0
  124. package/src/ckboxutils.js +183 -0
  125. package/src/index.d.ts +4 -0
  126. package/src/index.js +3 -0
  127. package/src/utils.d.ts +31 -0
  128. package/src/utils.js +93 -0
  129. package/theme/ckboximageedit.css +53 -0
  130. package/theme/icons/ckbox-image-edit.svg +1 -0
package/src/utils.js CHANGED
@@ -80,3 +80,96 @@ export function blurHashToDataUrl(hash) {
80
80
  return undefined;
81
81
  }
82
82
  }
83
+ /**
84
+ * Sends the HTTP request.
85
+ *
86
+ * @internal
87
+ * @param config.url the URL where the request will be sent.
88
+ * @param config.method The HTTP method.
89
+ * @param config.data Additional data to send.
90
+ * @param config.onUploadProgress A callback informing about the upload progress.
91
+ */
92
+ export function sendHttpRequest({ url, method = 'GET', data, onUploadProgress, signal, authorization }) {
93
+ const xhr = new XMLHttpRequest();
94
+ xhr.open(method, url.toString());
95
+ xhr.setRequestHeader('Authorization', authorization);
96
+ xhr.setRequestHeader('CKBox-Version', 'CKEditor 5');
97
+ xhr.responseType = 'json';
98
+ // The callback is attached to the `signal#abort` event.
99
+ const abortCallback = () => {
100
+ xhr.abort();
101
+ };
102
+ return new Promise((resolve, reject) => {
103
+ signal.throwIfAborted();
104
+ signal.addEventListener('abort', abortCallback);
105
+ xhr.addEventListener('loadstart', () => {
106
+ signal.addEventListener('abort', abortCallback);
107
+ });
108
+ xhr.addEventListener('loadend', () => {
109
+ signal.removeEventListener('abort', abortCallback);
110
+ });
111
+ xhr.addEventListener('error', () => {
112
+ reject();
113
+ });
114
+ xhr.addEventListener('abort', () => {
115
+ reject();
116
+ });
117
+ xhr.addEventListener('load', () => {
118
+ const response = xhr.response;
119
+ if (!response || response.statusCode >= 400) {
120
+ return reject(response && response.message);
121
+ }
122
+ resolve(response);
123
+ });
124
+ /* istanbul ignore else -- @preserve */
125
+ if (onUploadProgress) {
126
+ xhr.upload.addEventListener('progress', evt => {
127
+ onUploadProgress(evt);
128
+ });
129
+ }
130
+ // Send the request.
131
+ xhr.send(data);
132
+ });
133
+ }
134
+ const MIME_TO_EXTENSION = {
135
+ 'image/gif': 'gif',
136
+ 'image/jpeg': 'jpg',
137
+ 'image/png': 'png',
138
+ 'image/webp': 'webp',
139
+ 'image/bmp': 'bmp',
140
+ 'image/tiff': 'tiff'
141
+ };
142
+ /**
143
+ * Returns an extension a typical file in the specified `mimeType` format would have.
144
+ */
145
+ export function convertMimeTypeToExtension(mimeType) {
146
+ return MIME_TO_EXTENSION[mimeType];
147
+ }
148
+ /**
149
+ * Tries to fetch the given `url` and returns 'content-type' of the response.
150
+ */
151
+ export async function getContentTypeOfUrl(url, options) {
152
+ try {
153
+ const response = await fetch(url, {
154
+ method: 'HEAD',
155
+ cache: 'force-cache',
156
+ ...options
157
+ });
158
+ if (!response.ok) {
159
+ return '';
160
+ }
161
+ return response.headers.get('content-type') || '';
162
+ }
163
+ catch {
164
+ return '';
165
+ }
166
+ }
167
+ /**
168
+ * Returns an extension from the given value.
169
+ */
170
+ export function getFileExtension(file) {
171
+ const fileName = file.name;
172
+ const extensionRegExp = /\.(?<ext>[^.]+)$/;
173
+ const match = fileName.match(extensionRegExp);
174
+ return match.groups.ext.toLowerCase();
175
+ }
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
3
+ * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
4
+ */
5
+
6
+ :root {
7
+ /* Based on default CKBox theme colors */
8
+ --ck-image-processing-highlight-color: hsl(220, 10%, 98%);
9
+ --ck-image-processing-background-color: hsl(220, 10%, 90%);
10
+ }
11
+
12
+ .ck.ck-editor__editable {
13
+ & .image {
14
+ &.image-processing {
15
+ position: relative;
16
+
17
+ &:before {
18
+ content: '';
19
+
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ z-index: 1;
24
+
25
+ height: 100%;
26
+ width: 100%;
27
+
28
+ background: linear-gradient(
29
+ 90deg,
30
+ var(--ck-image-processing-background-color),
31
+ var(--ck-image-processing-highlight-color),
32
+ var(--ck-image-processing-background-color)
33
+ );
34
+ background-size: 200% 100%;
35
+
36
+ animation: ck-image-processing-animation 2s linear infinite;
37
+ }
38
+
39
+ & img {
40
+ height: 100%;
41
+ }
42
+ }
43
+ }
44
+ }
45
+
46
+ @keyframes ck-image-processing-animation {
47
+ 0% {
48
+ background-position: 200% 0;
49
+ }
50
+ 100% {
51
+ background-position: -200% 0;
52
+ }
53
+ }
@@ -0,0 +1 @@
1
+ <svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path d="M1.201 1C.538 1 0 1.47 0 2.1v12.86C0 15.603.534 16 1.186 16H6.45l3.647-3.596-3.48-3.254a.694.694 0 0 0-.958-.033L1.5 13.6V2.5h15v4.59a3.477 3.477 0 0 1 1.5.15V2.1c0-.63-.547-1.1-1.2-1.1H1.202Zm11.723 2.805a2.137 2.137 0 0 0-2.045 2.406 2.13 2.13 0 0 0 4.172.277 2.134 2.134 0 0 0-.76-2.244 2.13 2.13 0 0 0-1.367-.44Z"/><path d="M8.1 17.612V20h2.39l7.046-7.046-2.39-2.39L8.1 17.612Zm11.283-6.506a.638.638 0 0 0 .139-.692.603.603 0 0 0-.139-.206L17.892 8.72a.63.63 0 0 0-.898 0l-1.167 1.163 2.391 2.39 1.165-1.167Z"/></svg>