@khanacademy/perseus 19.5.1 → 19.6.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/dist/es/index.js CHANGED
@@ -24844,22 +24844,19 @@ class Explanation extends React.Component {
24844
24844
  };
24845
24845
  }
24846
24846
  render() {
24847
- const {
24848
- Link
24849
- } = this.props.apiOptions.baseElements;
24850
24847
  const {
24851
24848
  isArticle,
24852
24849
  isMobile
24853
24850
  } = this.props.apiOptions;
24854
- const linkAnchor = this.state.expanded ? this.props.hidePrompt : this.props.showPrompt;
24855
- let linkContainer;
24851
+ const promptText = this.state.expanded ? this.props.hidePrompt : this.props.showPrompt;
24852
+ let promptContainer;
24856
24853
 
24857
24854
  // TODO(diedra): This isn't a valid href;
24858
24855
  // change this to a button that looks like a link.
24859
24856
  const href = "javascript:void(0)";
24860
24857
  const onClick = this._onClick;
24861
24858
  if (isMobile) {
24862
- linkContainer = /*#__PURE__*/React.createElement("div", {
24859
+ promptContainer = /*#__PURE__*/React.createElement("div", {
24863
24860
  className: css(styles$o.linkContainer)
24864
24861
  }, /*#__PURE__*/React.createElement("a", {
24865
24862
  className: css(styles$o.mobileExplanationLink),
@@ -24867,7 +24864,7 @@ class Explanation extends React.Component {
24867
24864
  onClick: onClick,
24868
24865
  role: "button",
24869
24866
  "aria-expanded": this.state.expanded
24870
- }, linkAnchor), this.state.expanded && /*#__PURE__*/React.createElement("svg", {
24867
+ }, promptText), this.state.expanded && /*#__PURE__*/React.createElement("svg", {
24871
24868
  className: css(styles$o.disclosureArrow)
24872
24869
  }, /*#__PURE__*/React.createElement("polygon", {
24873
24870
  style: {
@@ -24876,41 +24873,18 @@ class Explanation extends React.Component {
24876
24873
  points: `0,${arrowHeight} ` + `${arrowWidth},${arrowHeight} ` + `${arrowWidth / 2},0`
24877
24874
  })));
24878
24875
  } else {
24879
- if (isArticle) {
24880
- // NOTE: For articles, the baseElements `Link` may is either be
24881
- // an anchor tag (if rendered in a modal) or a Wonder Blocks
24882
- // link component in lesson page, see: `article-page.jsx`.
24883
- linkContainer = /*#__PURE__*/React.createElement("div", {
24884
- className: css(styles$o.linkContainer, styles$o.articleLink)
24885
- }, /*#__PURE__*/React.createElement(Link, {
24886
- className: css(styles$o.explanationLink)
24887
- // HACK(michaelpolyak): WB Link doesn't passthrough
24888
- // class name.
24889
- ,
24890
- style: styles$o.explanationLink,
24891
- href: href,
24892
- onClick: onClick,
24893
- role: "button",
24894
- "aria-expanded": this.state.expanded
24895
- }, `[${linkAnchor}]`));
24896
- } else {
24897
- // NOTE: For exercises, the baseElements `Link` is an
24898
- // anchor tag, see: `perseus-api.jsx`.
24899
- linkContainer = /*#__PURE__*/React.createElement("div", {
24900
- className: css(styles$o.linkContainer, styles$o.exerciseLink)
24901
- }, /*#__PURE__*/React.createElement(Link, {
24902
- className: css(styles$o.explanationLink),
24903
- href: href,
24904
- onClick: onClick,
24905
- role: "button",
24906
- "aria-expanded": this.state.expanded
24907
- }, `[${linkAnchor}]`));
24908
- }
24876
+ const viewStyling = isArticle ? [styles$o.explanationLink, styles$o.articleLink] : [styles$o.explanationLink, styles$o.exerciseLink];
24877
+ promptContainer = /*#__PURE__*/React.createElement(Clickable, {
24878
+ onClick: onClick,
24879
+ "aria-expanded": this.state.expanded
24880
+ }, () => /*#__PURE__*/React.createElement(View, {
24881
+ style: viewStyling
24882
+ }, `[${promptText}]`));
24909
24883
  }
24910
24884
  const expandedStyle = isMobile ? styles$o.contentExpandedMobile : styles$o.contentExpanded;
24911
24885
  return /*#__PURE__*/React.createElement("div", {
24912
24886
  className: css(styles$o.container)
24913
- }, linkContainer, this.state.expanded && /*#__PURE__*/React.createElement("div", {
24887
+ }, promptContainer, this.state.expanded && /*#__PURE__*/React.createElement("div", {
24914
24888
  className: css(styles$o.content, isMobile && styles$o.contentMobile, this.state.expanded && expandedStyle)
24915
24889
  // eslint-disable-next-line react/no-string-refs
24916
24890
  ,
@@ -41580,7 +41554,7 @@ const init = function init(options) {
41580
41554
 
41581
41555
  // This file is processed by a Rollup plugin (replace) to inject the production
41582
41556
  const libName = "@khanacademy/perseus";
41583
- const libVersion = "19.5.1";
41557
+ const libVersion = "19.6.1";
41584
41558
  addLibraryVersionToPerseusDebug(libName, libVersion);
41585
41559
 
41586
41560
  const apiVersion = {
@@ -41682,7 +41656,24 @@ class ArticleRenderer extends React.Component {
41682
41656
  }
41683
41657
  };
41684
41658
  this._sections = () => {
41685
- return Array.isArray(this.props.json) ? this.props.json : [this.props.json];
41659
+ const sections = Array.isArray(this.props.json) ? this.props.json : [this.props.json];
41660
+
41661
+ // In JIPT context we split sections to paragraphs in order match the
41662
+ // translatable strings found on Crowdin when rendering articles in
41663
+ // the WYSIWYG mode for translation. This is needed for the jipt.js
41664
+ // integration in order to attribute the rendered strings on Crowdin.
41665
+ if (getDependencies().JIPT.useJIPT) {
41666
+ const paragraphs = [];
41667
+ for (const section of sections) {
41668
+ JiptParagraphs.parseToArray(section.content).forEach(paragraph => {
41669
+ paragraphs.push(_extends({}, section, {
41670
+ content: paragraph
41671
+ }));
41672
+ });
41673
+ }
41674
+ return paragraphs;
41675
+ }
41676
+ return sections;
41686
41677
  };
41687
41678
  }
41688
41679
  componentDidMount() {