@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.
- package/build/ckbox.js +2 -2
- package/build/translations/ar.js +1 -1
- package/build/translations/az.js +1 -1
- package/build/translations/bg.js +1 -1
- package/build/translations/bn.js +1 -1
- package/build/translations/ca.js +1 -1
- package/build/translations/cs.js +1 -1
- package/build/translations/da.js +1 -1
- package/build/translations/de.js +1 -1
- package/build/translations/el.js +1 -1
- package/build/translations/en-au.js +1 -1
- package/build/translations/es-co.js +1 -1
- package/build/translations/es.js +1 -1
- package/build/translations/et.js +1 -1
- package/build/translations/fa.js +1 -1
- package/build/translations/fi.js +1 -1
- package/build/translations/fr.js +1 -1
- package/build/translations/gl.js +1 -1
- package/build/translations/he.js +1 -1
- package/build/translations/hi.js +1 -1
- package/build/translations/hr.js +1 -1
- package/build/translations/hu.js +1 -1
- package/build/translations/id.js +1 -1
- package/build/translations/it.js +1 -1
- package/build/translations/ja.js +1 -1
- package/build/translations/ko.js +1 -1
- package/build/translations/lt.js +1 -1
- package/build/translations/lv.js +1 -1
- package/build/translations/ms.js +1 -1
- package/build/translations/nl.js +1 -1
- package/build/translations/no.js +1 -1
- package/build/translations/pl.js +1 -1
- package/build/translations/pt-br.js +1 -1
- package/build/translations/pt.js +1 -1
- package/build/translations/ro.js +1 -1
- package/build/translations/ru.js +1 -1
- package/build/translations/sk.js +1 -1
- package/build/translations/sq.js +1 -1
- package/build/translations/sr-latn.js +1 -1
- package/build/translations/sr.js +1 -1
- package/build/translations/sv.js +1 -1
- package/build/translations/th.js +1 -1
- package/build/translations/tr.js +1 -1
- package/build/translations/ug.js +1 -1
- package/build/translations/uk.js +1 -1
- package/build/translations/ur.js +1 -1
- package/build/translations/uz.js +1 -1
- package/build/translations/vi.js +1 -1
- package/build/translations/zh-cn.js +1 -1
- package/build/translations/zh.js +1 -1
- package/ckeditor5-metadata.json +17 -0
- package/lang/contexts.json +6 -2
- package/lang/translations/ar.po +18 -2
- package/lang/translations/az.po +18 -2
- package/lang/translations/bg.po +18 -2
- package/lang/translations/bn.po +18 -2
- package/lang/translations/ca.po +18 -2
- package/lang/translations/cs.po +18 -2
- package/lang/translations/da.po +18 -2
- package/lang/translations/de.po +18 -2
- package/lang/translations/el.po +18 -2
- package/lang/translations/en-au.po +18 -2
- package/lang/translations/en.po +18 -2
- package/lang/translations/es-co.po +18 -2
- package/lang/translations/es.po +18 -2
- package/lang/translations/et.po +18 -2
- package/lang/translations/fa.po +18 -2
- package/lang/translations/fi.po +18 -2
- package/lang/translations/fr.po +18 -2
- package/lang/translations/gl.po +18 -2
- package/lang/translations/he.po +18 -2
- package/lang/translations/hi.po +18 -2
- package/lang/translations/hr.po +18 -2
- package/lang/translations/hu.po +18 -2
- package/lang/translations/id.po +18 -2
- package/lang/translations/it.po +18 -2
- package/lang/translations/ja.po +18 -2
- package/lang/translations/ko.po +18 -2
- package/lang/translations/lt.po +18 -2
- package/lang/translations/lv.po +18 -2
- package/lang/translations/ms.po +18 -2
- package/lang/translations/nl.po +18 -2
- package/lang/translations/no.po +18 -2
- package/lang/translations/pl.po +18 -2
- package/lang/translations/pt-br.po +18 -2
- package/lang/translations/pt.po +18 -2
- package/lang/translations/ro.po +18 -2
- package/lang/translations/ru.po +18 -2
- package/lang/translations/sk.po +18 -2
- package/lang/translations/sq.po +18 -2
- package/lang/translations/sr-latn.po +18 -2
- package/lang/translations/sr.po +18 -2
- package/lang/translations/sv.po +18 -2
- package/lang/translations/th.po +18 -2
- package/lang/translations/tr.po +18 -2
- package/lang/translations/ug.po +18 -2
- package/lang/translations/uk.po +18 -2
- package/lang/translations/ur.po +18 -2
- package/lang/translations/uz.po +18 -2
- package/lang/translations/vi.po +18 -2
- package/lang/translations/zh-cn.po +18 -2
- package/lang/translations/zh.po +18 -2
- package/package.json +4 -3
- package/src/augmentation.d.ts +11 -1
- package/src/ckboxcommand.d.ts +8 -6
- package/src/ckboxcommand.js +5 -1
- package/src/ckboxconfig.d.ts +26 -0
- package/src/ckboxediting.d.ts +5 -12
- package/src/ckboxediting.js +7 -55
- package/src/ckboximageedit/ckboximageeditcommand.d.ts +97 -0
- package/src/ckboximageedit/ckboximageeditcommand.js +298 -0
- package/src/ckboximageedit/ckboximageeditediting.d.ts +28 -0
- package/src/ckboximageedit/ckboximageeditediting.js +36 -0
- package/src/ckboximageedit/ckboximageeditui.d.ts +24 -0
- package/src/ckboximageedit/ckboximageeditui.js +48 -0
- package/src/ckboximageedit/utils.d.ts +10 -0
- package/src/ckboximageedit/utils.js +48 -0
- package/src/ckboximageedit.d.ts +24 -0
- package/src/ckboximageedit.js +28 -0
- package/src/ckboxui.js +28 -1
- package/src/ckboxuploadadapter.d.ts +0 -5
- package/src/ckboxuploadadapter.js +15 -160
- package/src/ckboxutils.d.ts +50 -0
- package/src/ckboxutils.js +183 -0
- package/src/index.d.ts +4 -0
- package/src/index.js +3 -0
- package/src/utils.d.ts +31 -0
- package/src/utils.js +93 -0
- package/theme/ckboximageedit.css +53 -0
- 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>
|