@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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @khanacademy/perseus
2
2
 
3
+ ## 7.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e08f85ee: Add testing and improve error logging in the image editor
8
+
9
+ ## 7.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - fc70e558: Fix the font size of inline MathJax 3 math in paragraphs, making it the same as KaTeX math.
14
+
3
15
  ## 7.1.0
4
16
 
5
17
  ### Minor Changes
package/dist/es/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/es/index.js CHANGED
@@ -2945,8 +2945,6 @@ const defaultContext$2 = {
2945
2945
  };
2946
2946
  const context$1 = /*#__PURE__*/React.createContext(defaultContext$2);
2947
2947
 
2948
- /* eslint-disable @babel/no-invalid-this, getter-return, one-var */
2949
- let supportsPassive = false;
2950
2948
  const svgLabelsRegex = /^web\+graphie:/;
2951
2949
  // For offline exercises in the mobile app, we download the graphie data
2952
2950
  // (svgs and localized data files) and serve them from the local file
@@ -2954,6 +2952,50 @@ const svgLabelsRegex = /^web\+graphie:/;
2954
2952
  // in the perseus json with this `file+graphie` prefix to indicate that
2955
2953
  // they should have the `file://` protocol instead of `https://`.
2956
2954
  const svgLocalLabelsRegex$1 = /^file\+graphie:/;
2955
+
2956
+ // Sometimes other components want to download the actual image e.g. to
2957
+ // determine its size. Here, we transform an .svg-labels url into the
2958
+ // correct image url, and leave normal image urls alone
2959
+ function getRealImageUrl(graphieUrl) {
2960
+ if (isLabeledSVG(graphieUrl)) {
2961
+ return getSvgUrl(graphieUrl);
2962
+ }
2963
+ return graphieUrl;
2964
+ }
2965
+ function isLabeledSVG(graphieUrl) {
2966
+ return svgLabelsRegex.test(graphieUrl) || svgLocalLabelsRegex$1.test(graphieUrl);
2967
+ }
2968
+
2969
+ // For each graphie, there are two urls we need to download from. This gets
2970
+ // the base url without the suffix, and `getSvgUrl` and `getDataUrl` apply
2971
+ // appropriate suffixes to get the image and other data
2972
+ function getBaseUrl(graphieUrl) {
2973
+ return graphieUrl.replace(svgLabelsRegex, "https:").replace(svgLocalLabelsRegex$1, "file:");
2974
+ }
2975
+ function getSvgUrl(graphieUrl) {
2976
+ return getBaseUrl(graphieUrl) + ".svg";
2977
+ }
2978
+ function getDataUrl(graphieUrl) {
2979
+ return getBaseUrl(graphieUrl) + "-data.json";
2980
+ }
2981
+ async function getImageSizeModern(url) {
2982
+ const image = new Image();
2983
+ return new Promise((resolve, reject) => {
2984
+ // Handle the success case
2985
+ image.onload = () => {
2986
+ resolve([image.naturalWidth, image.naturalHeight]);
2987
+ };
2988
+
2989
+ // Handle the error case
2990
+ image.onerror = reject;
2991
+
2992
+ // Kick off the loading
2993
+ image.src = getRealImageUrl(url);
2994
+ });
2995
+ }
2996
+
2997
+ /* eslint-disable @babel/no-invalid-this, getter-return, one-var */
2998
+ let supportsPassive = false;
2957
2999
  const nestedMap$2 = function nestedMap(children, func, context) {
2958
3000
  if (Array.isArray(children)) {
2959
3001
  // @ts-expect-error [FEI-5003] - TS2322 - Type '(M | readonly M[])[]' is not assignable to type 'M | readonly M[]'.
@@ -3618,21 +3660,6 @@ const supportsPassiveEvents = () => {
3618
3660
  function captureScratchpadTouchStart$4(e) {
3619
3661
  e.stopPropagation();
3620
3662
  }
3621
- async function getImageSizeModern(url) {
3622
- const image = new Image();
3623
- return new Promise((resolve, reject) => {
3624
- // Handle the success case
3625
- image.onload = () => {
3626
- resolve([image.naturalWidth, image.naturalHeight]);
3627
- };
3628
-
3629
- // Handle the error case
3630
- image.onerror = reject;
3631
-
3632
- // Kick off the loading
3633
- image.src = url;
3634
- });
3635
- }
3636
3663
  function getImageSize(url, callback) {
3637
3664
  const img = new Image();
3638
3665
  img.onload = function () {
@@ -3662,32 +3689,6 @@ function getImageSize(url, callback) {
3662
3689
  img.src = getRealImageUrl(url);
3663
3690
  }
3664
3691
 
3665
- // Sometimes other components want to download the actual image e.g. to
3666
- // determine its size. Here, we transform an .svg-labels url into the
3667
- // correct image url, and leave normal image urls alone
3668
- function getRealImageUrl(url) {
3669
- if (isLabeledSVG(url)) {
3670
- return getSvgUrl(url);
3671
- }
3672
- return url;
3673
- }
3674
- function isLabeledSVG(url) {
3675
- return svgLabelsRegex.test(url) || svgLocalLabelsRegex$1.test(url);
3676
- }
3677
-
3678
- // For each svg+labels, there are two urls we need to download from. This gets
3679
- // the base url without the suffix, and `getSvgUrl` and `getDataUrl` apply
3680
- // appropriate suffixes to get the image and other data
3681
- function getBaseUrl(url) {
3682
- return url.replace(svgLabelsRegex, "https:").replace(svgLocalLabelsRegex$1, "file:");
3683
- }
3684
- function getSvgUrl(url) {
3685
- return getBaseUrl(url) + ".svg";
3686
- }
3687
- function getDataUrl(url) {
3688
- return getBaseUrl(url) + "-data.json";
3689
- }
3690
-
3691
3692
  /**
3692
3693
  * Gets the word right before where the textarea cursor is
3693
3694
  *
@@ -3767,12 +3768,12 @@ const Util = {
3767
3768
  supportsPassiveEvents,
3768
3769
  captureScratchpadTouchStart: captureScratchpadTouchStart$4,
3769
3770
  getImageSize,
3770
- getImageSizeModern,
3771
- getRealImageUrl,
3772
- isLabeledSVG,
3773
- getBaseUrl,
3774
- getSvgUrl,
3775
- getDataUrl,
3771
+ getImageSizeModern: getImageSizeModern,
3772
+ getRealImageUrl: getRealImageUrl,
3773
+ isLabeledSVG: isLabeledSVG,
3774
+ getBaseUrl: getBaseUrl,
3775
+ getSvgUrl: getSvgUrl,
3776
+ getDataUrl: getDataUrl,
3776
3777
  textarea,
3777
3778
  unescapeMathMode: unescapeMathMode$1,
3778
3779
  random: random$1