@khanacademy/perseus 7.1.0 → 7.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.
- package/CHANGELOG.md +12 -0
- package/dist/es/index.css +2 -1
- package/dist/es/index.js +50 -49
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +2 -1
- package/dist/index.js +50 -49
- package/dist/index.js.map +1 -1
- package/dist/util.d.ts +7 -12
- package/dist/util.graphie.d.ts +6 -0
- package/dist/util.graphie.js.flow +14 -0
- package/dist/util.js.flow +7 -12
- package/package.json +1 -1
- package/src/styles/articles.less +1 -1
- package/src/util.graphie.test.ts +45 -0
- package/src/util.graphie.ts +59 -0
- package/src/util.ts +8 -63
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.css
CHANGED
|
@@ -1550,7 +1550,8 @@ body.mobile ul.inequalities-one-line-radios > li {
|
|
|
1550
1550
|
margin-bottom: 32px;
|
|
1551
1551
|
margin-top: 0;
|
|
1552
1552
|
}
|
|
1553
|
-
.framework-perseus.perseus-article:not(.perseus-mobile) .perseus-renderer > .paragraph .katex
|
|
1553
|
+
.framework-perseus.perseus-article:not(.perseus-mobile) .perseus-renderer > .paragraph .katex,
|
|
1554
|
+
.framework-perseus.perseus-article:not(.perseus-mobile) .perseus-renderer > .paragraph mjx-container {
|
|
1554
1555
|
font-size: 100%;
|
|
1555
1556
|
}
|
|
1556
1557
|
.framework-perseus.perseus-article:not(.perseus-mobile) .perseus-renderer > .paragraph ul:not(.perseus-widget-radio) {
|
package/dist/index.js
CHANGED
|
@@ -3009,8 +3009,6 @@ const defaultContext$2 = {
|
|
|
3009
3009
|
};
|
|
3010
3010
|
const context$1 = /*#__PURE__*/React__namespace.createContext(defaultContext$2);
|
|
3011
3011
|
|
|
3012
|
-
/* eslint-disable @babel/no-invalid-this, getter-return, one-var */
|
|
3013
|
-
let supportsPassive = false;
|
|
3014
3012
|
const svgLabelsRegex = /^web\+graphie:/;
|
|
3015
3013
|
// For offline exercises in the mobile app, we download the graphie data
|
|
3016
3014
|
// (svgs and localized data files) and serve them from the local file
|
|
@@ -3018,6 +3016,50 @@ const svgLabelsRegex = /^web\+graphie:/;
|
|
|
3018
3016
|
// in the perseus json with this `file+graphie` prefix to indicate that
|
|
3019
3017
|
// they should have the `file://` protocol instead of `https://`.
|
|
3020
3018
|
const svgLocalLabelsRegex$1 = /^file\+graphie:/;
|
|
3019
|
+
|
|
3020
|
+
// Sometimes other components want to download the actual image e.g. to
|
|
3021
|
+
// determine its size. Here, we transform an .svg-labels url into the
|
|
3022
|
+
// correct image url, and leave normal image urls alone
|
|
3023
|
+
function getRealImageUrl(graphieUrl) {
|
|
3024
|
+
if (isLabeledSVG(graphieUrl)) {
|
|
3025
|
+
return getSvgUrl(graphieUrl);
|
|
3026
|
+
}
|
|
3027
|
+
return graphieUrl;
|
|
3028
|
+
}
|
|
3029
|
+
function isLabeledSVG(graphieUrl) {
|
|
3030
|
+
return svgLabelsRegex.test(graphieUrl) || svgLocalLabelsRegex$1.test(graphieUrl);
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
// For each graphie, there are two urls we need to download from. This gets
|
|
3034
|
+
// the base url without the suffix, and `getSvgUrl` and `getDataUrl` apply
|
|
3035
|
+
// appropriate suffixes to get the image and other data
|
|
3036
|
+
function getBaseUrl(graphieUrl) {
|
|
3037
|
+
return graphieUrl.replace(svgLabelsRegex, "https:").replace(svgLocalLabelsRegex$1, "file:");
|
|
3038
|
+
}
|
|
3039
|
+
function getSvgUrl(graphieUrl) {
|
|
3040
|
+
return getBaseUrl(graphieUrl) + ".svg";
|
|
3041
|
+
}
|
|
3042
|
+
function getDataUrl(graphieUrl) {
|
|
3043
|
+
return getBaseUrl(graphieUrl) + "-data.json";
|
|
3044
|
+
}
|
|
3045
|
+
async function getImageSizeModern(url) {
|
|
3046
|
+
const image = new Image();
|
|
3047
|
+
return new Promise((resolve, reject) => {
|
|
3048
|
+
// Handle the success case
|
|
3049
|
+
image.onload = () => {
|
|
3050
|
+
resolve([image.naturalWidth, image.naturalHeight]);
|
|
3051
|
+
};
|
|
3052
|
+
|
|
3053
|
+
// Handle the error case
|
|
3054
|
+
image.onerror = reject;
|
|
3055
|
+
|
|
3056
|
+
// Kick off the loading
|
|
3057
|
+
image.src = getRealImageUrl(url);
|
|
3058
|
+
});
|
|
3059
|
+
}
|
|
3060
|
+
|
|
3061
|
+
/* eslint-disable @babel/no-invalid-this, getter-return, one-var */
|
|
3062
|
+
let supportsPassive = false;
|
|
3021
3063
|
const nestedMap$2 = function (children, func, context) {
|
|
3022
3064
|
if (Array.isArray(children)) {
|
|
3023
3065
|
// @ts-expect-error [FEI-5003] - TS2322 - Type '(M | readonly M[])[]' is not assignable to type 'M | readonly M[]'.
|
|
@@ -3683,21 +3725,6 @@ const supportsPassiveEvents = () => {
|
|
|
3683
3725
|
function captureScratchpadTouchStart$4(e) {
|
|
3684
3726
|
e.stopPropagation();
|
|
3685
3727
|
}
|
|
3686
|
-
async function getImageSizeModern(url) {
|
|
3687
|
-
const image = new Image();
|
|
3688
|
-
return new Promise((resolve, reject) => {
|
|
3689
|
-
// Handle the success case
|
|
3690
|
-
image.onload = () => {
|
|
3691
|
-
resolve([image.naturalWidth, image.naturalHeight]);
|
|
3692
|
-
};
|
|
3693
|
-
|
|
3694
|
-
// Handle the error case
|
|
3695
|
-
image.onerror = reject;
|
|
3696
|
-
|
|
3697
|
-
// Kick off the loading
|
|
3698
|
-
image.src = url;
|
|
3699
|
-
});
|
|
3700
|
-
}
|
|
3701
3728
|
function getImageSize(url, callback) {
|
|
3702
3729
|
const img = new Image();
|
|
3703
3730
|
img.onload = function () {
|
|
@@ -3727,32 +3754,6 @@ function getImageSize(url, callback) {
|
|
|
3727
3754
|
img.src = getRealImageUrl(url);
|
|
3728
3755
|
}
|
|
3729
3756
|
|
|
3730
|
-
// Sometimes other components want to download the actual image e.g. to
|
|
3731
|
-
// determine its size. Here, we transform an .svg-labels url into the
|
|
3732
|
-
// correct image url, and leave normal image urls alone
|
|
3733
|
-
function getRealImageUrl(url) {
|
|
3734
|
-
if (isLabeledSVG(url)) {
|
|
3735
|
-
return getSvgUrl(url);
|
|
3736
|
-
}
|
|
3737
|
-
return url;
|
|
3738
|
-
}
|
|
3739
|
-
function isLabeledSVG(url) {
|
|
3740
|
-
return svgLabelsRegex.test(url) || svgLocalLabelsRegex$1.test(url);
|
|
3741
|
-
}
|
|
3742
|
-
|
|
3743
|
-
// For each svg+labels, there are two urls we need to download from. This gets
|
|
3744
|
-
// the base url without the suffix, and `getSvgUrl` and `getDataUrl` apply
|
|
3745
|
-
// appropriate suffixes to get the image and other data
|
|
3746
|
-
function getBaseUrl(url) {
|
|
3747
|
-
return url.replace(svgLabelsRegex, "https:").replace(svgLocalLabelsRegex$1, "file:");
|
|
3748
|
-
}
|
|
3749
|
-
function getSvgUrl(url) {
|
|
3750
|
-
return getBaseUrl(url) + ".svg";
|
|
3751
|
-
}
|
|
3752
|
-
function getDataUrl(url) {
|
|
3753
|
-
return getBaseUrl(url) + "-data.json";
|
|
3754
|
-
}
|
|
3755
|
-
|
|
3756
3757
|
/**
|
|
3757
3758
|
* Gets the word right before where the textarea cursor is
|
|
3758
3759
|
*
|
|
@@ -3832,12 +3833,12 @@ const Util = {
|
|
|
3832
3833
|
supportsPassiveEvents,
|
|
3833
3834
|
captureScratchpadTouchStart: captureScratchpadTouchStart$4,
|
|
3834
3835
|
getImageSize,
|
|
3835
|
-
getImageSizeModern,
|
|
3836
|
-
getRealImageUrl,
|
|
3837
|
-
isLabeledSVG,
|
|
3838
|
-
getBaseUrl,
|
|
3839
|
-
getSvgUrl,
|
|
3840
|
-
getDataUrl,
|
|
3836
|
+
getImageSizeModern: getImageSizeModern,
|
|
3837
|
+
getRealImageUrl: getRealImageUrl,
|
|
3838
|
+
isLabeledSVG: isLabeledSVG,
|
|
3839
|
+
getBaseUrl: getBaseUrl,
|
|
3840
|
+
getSvgUrl: getSvgUrl,
|
|
3841
|
+
getDataUrl: getDataUrl,
|
|
3841
3842
|
textarea,
|
|
3842
3843
|
unescapeMathMode: unescapeMathMode$1,
|
|
3843
3844
|
random: random$1
|