@khanacademy/perseus 12.0.1 → 12.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 +21 -0
- package/dist/article-renderer.d.ts +2 -0
- package/dist/es/index.css +5 -2
- package/dist/es/index.js +36 -25
- package/dist/es/index.js.map +1 -1
- package/dist/index.css +5 -2
- package/dist/index.js +36 -25
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/__stories__/article-renderer.stories.tsx +28 -2
- package/src/__testdata__/article-renderer.testdata.ts +85 -0
- package/src/__tests__/article-renderer.test.tsx +131 -0
- package/src/__tests__/item-renderer.test.tsx +1 -19
- package/src/article-renderer.tsx +58 -45
- package/src/styles/perseus-renderer.less +1 -0
- package/src/styles/widgets/image.less +2 -6
- package/src/widgets/__stories__/image.stories.tsx +1 -0
- package/src/widgets/__tests__/__snapshots__/group.test.tsx.snap +1 -0
- package/src/widgets/__tests__/__snapshots__/image.test.ts.snap +2 -0
- package/src/widgets/image.tsx +12 -2
- package/tsconfig-build.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @khanacademy/perseus
|
|
2
2
|
|
|
3
|
+
## 12.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#773](https://github.com/Khan/perseus/pull/773) [`809823e4`](https://github.com/Khan/perseus/commit/809823e490f65cbcbaa05b548de985035810ba8d) Thanks [@nixterrimus](https://github.com/nixterrimus)! - Fix text overlap in interactive graph widget
|
|
8
|
+
|
|
9
|
+
* [#755](https://github.com/Khan/perseus/pull/755) [`6d9e31a4`](https://github.com/Khan/perseus/commit/6d9e31a4ea4a1ed29bef2d9812d21e5b2fd41af6) Thanks [@SonicScrewdriver](https://github.com/SonicScrewdriver)! - Adding logic to ArticleRenderer so that it can return our currently focused element.
|
|
10
|
+
|
|
11
|
+
## 12.1.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- 6dbc58c6: Fix image centering for widget
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- c4ae088f: Upgrades MathQuill to fix Android keyboard error
|
|
20
|
+
- Updated dependencies [c4ae088f]
|
|
21
|
+
- Updated dependencies [aea0387f]
|
|
22
|
+
- @khanacademy/math-input@14.2.0
|
|
23
|
+
|
|
3
24
|
## 12.0.1
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* composed of multiple (Renderer) sections concatenated together.
|
|
4
4
|
*/
|
|
5
5
|
import * as React from "react";
|
|
6
|
+
import Renderer from "./renderer";
|
|
6
7
|
import type { KeypadProps } from "./mixins/provide-keypad";
|
|
7
8
|
import type { PerseusRenderer } from "./perseus-types";
|
|
8
9
|
import type { APIOptions, PerseusDependenciesV2 } from "./types";
|
|
@@ -28,6 +29,7 @@ type DefaultProps = {
|
|
|
28
29
|
};
|
|
29
30
|
declare class ArticleRenderer extends React.Component<Props> implements KeypadContextRendererInterface {
|
|
30
31
|
_currentFocus: any;
|
|
32
|
+
sectionRenderers: Array<Renderer>;
|
|
31
33
|
static defaultProps: DefaultProps;
|
|
32
34
|
constructor(props: Props);
|
|
33
35
|
componentDidMount(): void;
|
package/dist/es/index.css
CHANGED
|
@@ -2613,6 +2613,7 @@ img.zoom-img {
|
|
|
2613
2613
|
}
|
|
2614
2614
|
/* Widget CSS */
|
|
2615
2615
|
.perseus-graph-padding {
|
|
2616
|
+
box-sizing: content-box;
|
|
2616
2617
|
padding: 25px 25px 0 0;
|
|
2617
2618
|
}
|
|
2618
2619
|
.categorizer-container {
|
|
@@ -2749,6 +2750,7 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2749
2750
|
margin: 0px 4px;
|
|
2750
2751
|
}
|
|
2751
2752
|
.perseus-widget-grapher {
|
|
2753
|
+
box-sizing: content-box;
|
|
2752
2754
|
padding: 25px 25px 0 0;
|
|
2753
2755
|
}
|
|
2754
2756
|
.perseus-widget-grapher > .graphie-container {
|
|
@@ -2793,7 +2795,8 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2793
2795
|
margin-left: -20px;
|
|
2794
2796
|
}
|
|
2795
2797
|
.perseus-image-widget {
|
|
2796
|
-
margin:
|
|
2798
|
+
margin-left: auto;
|
|
2799
|
+
margin-right: auto;
|
|
2797
2800
|
}
|
|
2798
2801
|
.perseus-image-widget .perseus-image-title {
|
|
2799
2802
|
text-align: center;
|
|
@@ -2802,7 +2805,6 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2802
2805
|
color: rgba(33, 36, 44, 0.7);
|
|
2803
2806
|
padding-left: 16px;
|
|
2804
2807
|
position: relative;
|
|
2805
|
-
top: -12px;
|
|
2806
2808
|
}
|
|
2807
2809
|
.perseus-image-widget .perseus-image-caption::before {
|
|
2808
2810
|
content: "";
|
|
@@ -2836,6 +2838,7 @@ body.mobile .categorizer-container td.category input[type="radio"] + span:active
|
|
|
2836
2838
|
margin-top: 5px;
|
|
2837
2839
|
}
|
|
2838
2840
|
.perseus-widget-interactive-graph {
|
|
2841
|
+
box-sizing: content-box;
|
|
2839
2842
|
padding: 25px 25px 0 0;
|
|
2840
2843
|
}
|
|
2841
2844
|
.perseus-widget-interactive-graph > .graphie-container {
|
package/dist/es/index.js
CHANGED
|
@@ -26579,7 +26579,10 @@ class ImageWidget extends React.Component {
|
|
|
26579
26579
|
})));
|
|
26580
26580
|
}
|
|
26581
26581
|
return /*#__PURE__*/React.createElement("figure", {
|
|
26582
|
-
className: "perseus-image-widget"
|
|
26582
|
+
className: "perseus-image-widget",
|
|
26583
|
+
style: {
|
|
26584
|
+
maxWidth: backgroundImage.width
|
|
26585
|
+
}
|
|
26583
26586
|
}, image, alt, titleAndCaption);
|
|
26584
26587
|
}
|
|
26585
26588
|
let title;
|
|
@@ -26606,7 +26609,10 @@ class ImageWidget extends React.Component {
|
|
|
26606
26609
|
}));
|
|
26607
26610
|
}
|
|
26608
26611
|
return /*#__PURE__*/React.createElement("figure", {
|
|
26609
|
-
className: "perseus-image-widget"
|
|
26612
|
+
className: "perseus-image-widget",
|
|
26613
|
+
style: {
|
|
26614
|
+
maxWidth: backgroundImage.width
|
|
26615
|
+
}
|
|
26610
26616
|
}, title, image, alt, caption);
|
|
26611
26617
|
}
|
|
26612
26618
|
static validate(userInput, rubric) {
|
|
@@ -43742,7 +43748,7 @@ const init = function init(options) {
|
|
|
43742
43748
|
|
|
43743
43749
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
43744
43750
|
const libName = "@khanacademy/perseus";
|
|
43745
|
-
const libVersion = "12.0
|
|
43751
|
+
const libVersion = "12.2.0";
|
|
43746
43752
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
43747
43753
|
|
|
43748
43754
|
const apiVersion = {
|
|
@@ -43764,6 +43770,7 @@ class ArticleRenderer extends React.Component {
|
|
|
43764
43770
|
constructor(props) {
|
|
43765
43771
|
super(props);
|
|
43766
43772
|
this._currentFocus = void 0;
|
|
43773
|
+
this.sectionRenderers = [];
|
|
43767
43774
|
this._handleFocusChange = (newFocusPath, oldFocusPath) => {
|
|
43768
43775
|
// TODO(charlie): DRY this up--some of this logic is repeated in
|
|
43769
43776
|
// ItemRenderer.
|
|
@@ -43788,17 +43795,17 @@ class ArticleRenderer extends React.Component {
|
|
|
43788
43795
|
// paths, so as to check whether the focused path represents an
|
|
43789
43796
|
// input.
|
|
43790
43797
|
let didFocusInput = false;
|
|
43798
|
+
let focusedInput;
|
|
43791
43799
|
if (this._currentFocus) {
|
|
43792
|
-
const [
|
|
43793
|
-
|
|
43794
|
-
// @ts-expect-error - TS2339 - Property 'getInputPaths' does not exist on type 'ReactInstance'.
|
|
43795
|
-
const inputPaths = this.refs[sectionRef].getInputPaths();
|
|
43800
|
+
const [sectionIndex, ...focusPath] = this._currentFocus;
|
|
43801
|
+
const inputPaths = this.sectionRenderers[sectionIndex].getInputPaths();
|
|
43796
43802
|
didFocusInput = inputPaths.some(inputPath => {
|
|
43797
43803
|
return Util.inputPathsEqual(inputPath, focusPath);
|
|
43798
43804
|
});
|
|
43805
|
+
focusedInput = this.sectionRenderers[sectionIndex].getDOMNodeForPath(focusPath);
|
|
43799
43806
|
}
|
|
43800
43807
|
if (this.props.apiOptions.onFocusChange != null) {
|
|
43801
|
-
this.props.apiOptions.onFocusChange(this._currentFocus, prevFocusPath, didFocusInput ? keypadElement == null ? void 0 : keypadElement.getDOMNode() : null);
|
|
43808
|
+
this.props.apiOptions.onFocusChange(this._currentFocus, prevFocusPath, didFocusInput ? keypadElement == null ? void 0 : keypadElement.getDOMNode() : null, didFocusInput ? focusedInput : null);
|
|
43802
43809
|
}
|
|
43803
43810
|
if (keypadElement && isMobile) {
|
|
43804
43811
|
if (didFocusInput) {
|
|
@@ -43830,10 +43837,8 @@ class ArticleRenderer extends React.Component {
|
|
|
43830
43837
|
};
|
|
43831
43838
|
this.blur = () => {
|
|
43832
43839
|
if (this._currentFocus) {
|
|
43833
|
-
const [
|
|
43834
|
-
|
|
43835
|
-
// @ts-expect-error - TS2339 - Property 'blurPath' does not exist on type 'ReactInstance'.
|
|
43836
|
-
this.refs[sectionRef].blurPath(inputPath);
|
|
43840
|
+
const [sectionIndex, ...inputPath] = this._currentFocus;
|
|
43841
|
+
this.sectionRenderers[sectionIndex].blurPath(inputPath);
|
|
43837
43842
|
}
|
|
43838
43843
|
};
|
|
43839
43844
|
this._sections = () => {
|
|
@@ -43859,33 +43864,39 @@ class ArticleRenderer extends React.Component {
|
|
|
43859
43864
|
});
|
|
43860
43865
|
|
|
43861
43866
|
// TODO(alex): Add mobile api functions and pass them down here
|
|
43862
|
-
|
|
43863
|
-
|
|
43864
|
-
|
|
43865
|
-
|
|
43866
|
-
|
|
43867
|
-
key:
|
|
43867
|
+
// We're using the index as the key here because we don't have a unique
|
|
43868
|
+
// identifier for each section. This should be fine as we never remove
|
|
43869
|
+
// or reorder sections.
|
|
43870
|
+
const sections = this._sections().map((section, sectionIndex) => {
|
|
43871
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
43872
|
+
key: sectionIndex,
|
|
43868
43873
|
className: "clearfix"
|
|
43869
43874
|
}, /*#__PURE__*/React.createElement(Renderer, _extends({}, section, {
|
|
43870
|
-
ref:
|
|
43871
|
-
|
|
43872
|
-
|
|
43875
|
+
ref: elem => {
|
|
43876
|
+
if (elem) {
|
|
43877
|
+
this.sectionRenderers[sectionIndex] = elem;
|
|
43878
|
+
}
|
|
43879
|
+
},
|
|
43880
|
+
key: sectionIndex,
|
|
43881
|
+
key_: sectionIndex,
|
|
43873
43882
|
keypadElement: this.props.keypadElement,
|
|
43874
43883
|
apiOptions: _extends({}, apiOptions, {
|
|
43875
43884
|
onFocusChange: (newFocusPath, oldFocusPath) => {
|
|
43876
|
-
// Prefix the paths with the relevant section,
|
|
43885
|
+
// Prefix the paths with the relevant section index,
|
|
43877
43886
|
// so as to allow us to distinguish between
|
|
43878
43887
|
// equivalently-named inputs across Renderers.
|
|
43879
|
-
this._handleFocusChange(newFocusPath && [
|
|
43888
|
+
this._handleFocusChange(newFocusPath && [sectionIndex].concat(newFocusPath), oldFocusPath && [sectionIndex].concat(oldFocusPath));
|
|
43880
43889
|
}
|
|
43881
43890
|
}),
|
|
43882
43891
|
linterContext: PerseusLinter.pushContextStack(this.props.linterContext, "article"),
|
|
43883
43892
|
legacyPerseusLint: this.props.legacyPerseusLint
|
|
43884
|
-
})))
|
|
43893
|
+
})));
|
|
43885
43894
|
});
|
|
43886
43895
|
return /*#__PURE__*/React.createElement("div", {
|
|
43887
43896
|
className: classes
|
|
43888
|
-
},
|
|
43897
|
+
}, /*#__PURE__*/React.createElement(DependenciesContext.Provider, {
|
|
43898
|
+
value: this.props.dependencies
|
|
43899
|
+
}, sections));
|
|
43889
43900
|
}
|
|
43890
43901
|
}
|
|
43891
43902
|
ArticleRenderer.defaultProps = {
|