Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Mathjax for formules formatting #339

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ const config = createConfig('eslint', {
'import/no-named-as-default-member': 'off',
'import/no-import-module-exports': 'off',
'import/no-self-import': 'off',
'spaced-comment': ['error', 'always', { 'block': { 'exceptions': ['*'] } }],
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
'react-hooks/rules-of-hooks': 'off',
"react/forbid-prop-types": ["error", { "forbid": ["any", "array"] }], // arguable object proptype is use when I do not care about the shape of the object
'react/forbid-prop-types': ['error', { forbid: ['any', 'array'] }], // arguable object proptype is use when I do not care about the shape of the object
'no-import-assign': 'off',
'no-promise-executor-return': 'off',
'import/no-cycle': 'off',
},
});

config.settings = {
"import/resolver": {
'import/resolver': {
node: {
paths: ["src", "node_modules"],
extensions: [".js", ".jsx"],
paths: ['src', 'node_modules'],
extensions: ['.js', '.jsx'],
},
},
};
Expand Down
8,395 changes: 5,620 additions & 2,775 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"@testing-library/user-event": "^14.0.0",
"@zip.js/zip.js": "^2.4.6",
"axios": "^0.28.0",
"better-react-mathjax": "^2.0.3",
"classnames": "^2.3.1",
"core-js": "3.35.1",
"dompurify": "^2.3.1",
Expand Down
5 changes: 4 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import DemoWarning from 'containers/DemoWarning';
import CTA from 'containers/CTA';
import NotificationsBanner from 'containers/NotificationsBanner';
import ListView from 'containers/ListView';
import { MathJaxContext } from 'better-react-mathjax';

import './App.scss';
import Head from './components/Head';
Expand All @@ -30,7 +31,9 @@ export const App = ({ courseMetadata, isEnabled }) => (
<CTA />
<NotificationsBanner />
<main data-testid="main">
<ListView />
<MathJaxContext>
<ListView />
</MathJaxContext>
</main>
<FooterSlot />
</div>
Expand Down
82 changes: 43 additions & 39 deletions src/__snapshots__/App.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App router component snapshot: disabled (show demo warning) 1`] = `
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<DemoWarning />
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
<MathJaxContext>
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<DemoWarning />
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
</MathJaxContext>
`;

exports[`App router component snapshot: enabled 1`] = `
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
<MathJaxContext>
<BrowserRouter>
<div>
<Head />
<Header
courseNumber="course-number"
courseOrg="course-org"
courseTitle="course-title"
data-testid="header"
/>
<CTA />
<NotificationsBanner />
<main
data-testid="main"
>
<ListView />
</main>
<FooterSlot />
</div>
</BrowserRouter>
</MathJaxContext>
`;
40 changes: 22 additions & 18 deletions src/containers/ResponseDisplay/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ exports[`ResponseDisplay component snapshot file upload disable with valid respo
<div
className="response-display"
>
<Card
key="0"
>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
<MathJax>
<Card
key="0"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
</MathJax>
</div>
`;

Expand Down Expand Up @@ -70,16 +72,18 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
]
}
/>
<Card
key="0"
>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
<MathJax>
<Card
key="0"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
<Card.Section
className="response-display-text-content"
data-testid="response-display-text-content"
>
parsed html (sanitized (some text response here))
</Card.Section>
</Card>
</MathJax>
</div>
`;

Expand Down
11 changes: 8 additions & 3 deletions src/containers/ResponseDisplay/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { MathJax } from 'better-react-mathjax';

import { Card } from '@openedx/paragon';

Expand Down Expand Up @@ -47,9 +48,13 @@ export class ResponseDisplay extends React.Component {
{
/* eslint-disable react/no-array-index-key */
this.textContents.map((textContent, index) => (
<Card key={index}>
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">{textContent}</Card.Section>
</Card>
<MathJax>
<Card key={index}>
<Card.Section className="response-display-text-content" data-testid="response-display-text-content">
{textContent}
</Card.Section>
</Card>
</MathJax>
))
}
</div>
Expand Down
Loading