@khanacademy/perseus 7.0.0 → 7.0.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 +11 -0
- package/dist/es/index.js +18 -2
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +17 -1
- package/dist/index.js.map +1 -1
- package/dist/util.d.ts +3 -1
- package/dist/util.js.flow +3 -1
- package/package.json +3 -3
- package/src/mixins/provide-keypad.tsx +2 -2
- package/src/util.ts +19 -1
- package/src/widgets/__stories__/test-keypad-context-wrapper.tsx +2 -2
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/util.d.ts
CHANGED
|
@@ -171,7 +171,8 @@ declare function extractPointerLocation(event: any): Position | null | undefined
|
|
|
171
171
|
* avoid sending the touch to the mobile scratchpad
|
|
172
172
|
*/
|
|
173
173
|
declare function captureScratchpadTouchStart(e: TouchEvent): void;
|
|
174
|
-
declare function
|
|
174
|
+
declare function getImageSizeModern(url: string): Promise<[number, number]>;
|
|
175
|
+
declare function getImageSize(url: string, callback: (width: number, height: number) => void): void;
|
|
175
176
|
declare function getRealImageUrl(url: string): string;
|
|
176
177
|
declare function isLabeledSVG(url: string): boolean;
|
|
177
178
|
declare function getBaseUrl(url: string): string;
|
|
@@ -233,6 +234,7 @@ declare const Util: {
|
|
|
233
234
|
readonly supportsPassiveEvents: () => boolean;
|
|
234
235
|
readonly captureScratchpadTouchStart: typeof captureScratchpadTouchStart;
|
|
235
236
|
readonly getImageSize: typeof getImageSize;
|
|
237
|
+
readonly getImageSizeModern: typeof getImageSizeModern;
|
|
236
238
|
readonly getRealImageUrl: typeof getRealImageUrl;
|
|
237
239
|
readonly isLabeledSVG: typeof isLabeledSVG;
|
|
238
240
|
readonly getBaseUrl: typeof getBaseUrl;
|
package/dist/util.js.flow
CHANGED
|
@@ -236,9 +236,10 @@ declare function extractPointerLocation(event: any): Position | null | void;
|
|
|
236
236
|
* avoid sending the touch to the mobile scratchpad
|
|
237
237
|
*/
|
|
238
238
|
declare function captureScratchpadTouchStart(e: TouchEvent): void;
|
|
239
|
+
declare function getImageSizeModern(url: string): Promise<[number, number]>;
|
|
239
240
|
declare function getImageSize(
|
|
240
241
|
url: string,
|
|
241
|
-
callback: (
|
|
242
|
+
callback: (width: number, height: number) => void
|
|
242
243
|
): void;
|
|
243
244
|
declare function getRealImageUrl(url: string): string;
|
|
244
245
|
declare function isLabeledSVG(url: string): boolean;
|
|
@@ -307,6 +308,7 @@ declare var Util: {|
|
|
|
307
308
|
+supportsPassiveEvents: () => boolean,
|
|
308
309
|
+captureScratchpadTouchStart: typeof captureScratchpadTouchStart,
|
|
309
310
|
+getImageSize: typeof getImageSize,
|
|
311
|
+
+getImageSizeModern: typeof getImageSizeModern,
|
|
310
312
|
+getRealImageUrl: typeof getRealImageUrl,
|
|
311
313
|
+isLabeledSVG: typeof isLabeledSVG,
|
|
312
314
|
+getBaseUrl: typeof getBaseUrl,
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Core Perseus API (includes renderers and widgets)",
|
|
4
4
|
"author": "Khan Academy",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "7.0.
|
|
6
|
+
"version": "7.0.1",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@khanacademy/kas": "^0.3.1",
|
|
25
25
|
"@khanacademy/kmath": "^0.1.1",
|
|
26
|
-
"@khanacademy/math-input": "^8.
|
|
27
|
-
"@khanacademy/perseus-core": "0.0
|
|
26
|
+
"@khanacademy/math-input": "^8.1.0",
|
|
27
|
+
"@khanacademy/perseus-core": "0.1.0",
|
|
28
28
|
"@khanacademy/perseus-linter": "^0.3.1",
|
|
29
29
|
"@khanacademy/pure-markdown": "^0.2.3",
|
|
30
30
|
"@khanacademy/simple-markdown": "^0.9.3"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* extend a `ProvideKeypad` component instead of using this mixin.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {MobileKeypad} from "@khanacademy/math-input";
|
|
14
14
|
import PropTypes from "prop-types";
|
|
15
15
|
import * as React from "react";
|
|
16
16
|
import ReactDOM from "react-dom";
|
|
@@ -91,7 +91,7 @@ const ProvideKeypad = {
|
|
|
91
91
|
document.body?.appendChild(_this._keypadContainer);
|
|
92
92
|
|
|
93
93
|
reactRender(
|
|
94
|
-
<
|
|
94
|
+
<MobileKeypad
|
|
95
95
|
onElementMounted={(element) => {
|
|
96
96
|
// NOTE(kevinb): The reason why this setState works is
|
|
97
97
|
// b/c we're calling it manually from item-renderer.jsx
|
package/src/util.ts
CHANGED
|
@@ -839,9 +839,26 @@ function captureScratchpadTouchStart(e: TouchEvent) {
|
|
|
839
839
|
e.stopPropagation();
|
|
840
840
|
}
|
|
841
841
|
|
|
842
|
+
async function getImageSizeModern(url: string): Promise<[number, number]> {
|
|
843
|
+
const image = new Image();
|
|
844
|
+
|
|
845
|
+
return new Promise((resolve, reject) => {
|
|
846
|
+
// Handle the success case
|
|
847
|
+
image.onload = () => {
|
|
848
|
+
resolve([image.naturalWidth, image.naturalHeight]);
|
|
849
|
+
};
|
|
850
|
+
|
|
851
|
+
// Handle the error case
|
|
852
|
+
image.onerror = reject;
|
|
853
|
+
|
|
854
|
+
// Kick off the loading
|
|
855
|
+
image.src = url;
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
842
859
|
function getImageSize(
|
|
843
860
|
url: string,
|
|
844
|
-
callback: (
|
|
861
|
+
callback: (width: number, height: number) => void,
|
|
845
862
|
): void {
|
|
846
863
|
const img = new Image();
|
|
847
864
|
img.onload = function () {
|
|
@@ -990,6 +1007,7 @@ const Util = {
|
|
|
990
1007
|
supportsPassiveEvents,
|
|
991
1008
|
captureScratchpadTouchStart,
|
|
992
1009
|
getImageSize,
|
|
1010
|
+
getImageSizeModern,
|
|
993
1011
|
getRealImageUrl,
|
|
994
1012
|
isLabeledSVG,
|
|
995
1013
|
getBaseUrl,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {KeypadContext,
|
|
1
|
+
import {KeypadContext, MobileKeypad} from "@khanacademy/math-input";
|
|
2
2
|
import {View} from "@khanacademy/wonder-blocks-core";
|
|
3
3
|
import {StyleSheet} from "aphrodite";
|
|
4
4
|
import * as React from "react";
|
|
@@ -8,7 +8,7 @@ const Footer = (): React.ReactElement => {
|
|
|
8
8
|
<View style={styles.keypadContainer}>
|
|
9
9
|
<KeypadContext.Consumer>
|
|
10
10
|
{({setKeypadElement, renderer}) => (
|
|
11
|
-
<
|
|
11
|
+
<MobileKeypad
|
|
12
12
|
onElementMounted={setKeypadElement}
|
|
13
13
|
onDismiss={() => renderer && renderer.blur()}
|
|
14
14
|
style={styles.keypad}
|