@khanacademy/perseus-editor 2.3.13 → 2.4.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.
- package/CHANGELOG.md +17 -0
- package/dist/es/index.js +23 -16
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +23 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/widgets/image-editor.tsx +40 -17
- package/tsconfig-build.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Perseus editors",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "2.
|
|
6
|
+
"version": "2.4.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kas": "^0.3.1",
|
|
25
25
|
"@khanacademy/kmath": "^0.1.1",
|
|
26
|
-
"@khanacademy/perseus": "^7.0.
|
|
26
|
+
"@khanacademy/perseus": "^7.0.2"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@khanacademy/wonder-blocks-button": "^4.0.8",
|
|
@@ -97,6 +97,27 @@ const ImageEditor: any = createReactClass({
|
|
|
97
97
|
|
|
98
98
|
const imageSettings = (
|
|
99
99
|
<div className="image-settings">
|
|
100
|
+
<div>
|
|
101
|
+
<label>
|
|
102
|
+
<div>Preview:</div>
|
|
103
|
+
<img
|
|
104
|
+
alt="Editor preview of image"
|
|
105
|
+
src={backgroundImage.url}
|
|
106
|
+
style={{
|
|
107
|
+
width: "100%",
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
</label>
|
|
111
|
+
</div>
|
|
112
|
+
<div>
|
|
113
|
+
<label>
|
|
114
|
+
<div>Dimensions:</div>
|
|
115
|
+
<p>
|
|
116
|
+
{backgroundImage.width}x{backgroundImage.height}
|
|
117
|
+
</p>
|
|
118
|
+
</label>
|
|
119
|
+
</div>
|
|
120
|
+
|
|
100
121
|
<div>
|
|
101
122
|
<label>
|
|
102
123
|
<div>
|
|
@@ -277,7 +298,16 @@ const ImageEditor: any = createReactClass({
|
|
|
277
298
|
// silently load the image when the component mounts
|
|
278
299
|
// silently update url and sizes when the image loads
|
|
279
300
|
// noisily load the image in response to the author changing it
|
|
280
|
-
onUrlChange: function (
|
|
301
|
+
onUrlChange: async function (
|
|
302
|
+
url: string | undefined | null,
|
|
303
|
+
silent: boolean,
|
|
304
|
+
) {
|
|
305
|
+
// Check if we've been passed something that looks like a URL
|
|
306
|
+
if (!url) {
|
|
307
|
+
this.setUrl(url, 0, 0, silent);
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
|
|
281
311
|
// All article content must be KA-owned!
|
|
282
312
|
if (!INTERNALLY_HOSTED_URL_RE.test(url)) {
|
|
283
313
|
this.setState({
|
|
@@ -288,25 +318,18 @@ const ImageEditor: any = createReactClass({
|
|
|
288
318
|
});
|
|
289
319
|
return;
|
|
290
320
|
}
|
|
291
|
-
this.setState({backgroundImageError: ""});
|
|
292
321
|
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
// faster URL, we keep track of the URL we're trying to change to.
|
|
296
|
-
this._leadingUrl = url;
|
|
322
|
+
// Clear previous errors
|
|
323
|
+
this.setState({backgroundImageError: ""});
|
|
297
324
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
325
|
+
try {
|
|
326
|
+
const size = await Util.getImageSizeModern(url);
|
|
327
|
+
this.setUrl(url, size[0], size[1], true);
|
|
328
|
+
} catch (error) {
|
|
329
|
+
this.setState({
|
|
330
|
+
backgroundImageError: `There was an error loading the image URL: ${error}`,
|
|
331
|
+
});
|
|
301
332
|
}
|
|
302
|
-
|
|
303
|
-
Util.getImageSize(url, (width, height) => {
|
|
304
|
-
if (this._leadingUrl !== url) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
this.setUrl(url, width, height, true);
|
|
309
|
-
});
|
|
310
333
|
},
|
|
311
334
|
|
|
312
335
|
onRangeChange: function (type, newRange) {
|