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 (quince.master) #341

Open
wants to merge 1 commit into
base: open-release/quince.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 @@ -6,20 +6,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
10,308 changes: 6,902 additions & 3,406 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 @@ -38,6 +38,7 @@
"@testing-library/user-event": "^14.0.0",
"@zip.js/zip.js": "^2.4.6",
"axios": "^0.27.0",
"better-react-mathjax": "^2.0.3",
"classnames": "^2.3.1",
"core-js": "3.32.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 @@ -11,6 +11,7 @@ import { selectors } from 'data/redux';
import DemoWarning from 'containers/DemoWarning';
import CTA from 'containers/CTA';
import ListView from 'containers/ListView';
import { MathJaxContext } from 'better-react-mathjax';

import './App.scss';
import Head from './components/Head';
Expand All @@ -27,7 +28,9 @@ export const App = ({ courseMetadata, isEnabled }) => (
{!isEnabled && <DemoWarning />}
<CTA />
<main>
<ListView />
<MathJaxContext>
<ListView />
</MathJaxContext>
</main>
<Footer logo={process.env.LOGO_POWERED_BY_OPEN_EDX_URL_SVG} />
</div>
Expand Down
78 changes: 43 additions & 35 deletions src/__snapshots__/App.test.jsx.snap
Original file line number Diff line number Diff line change
@@ -1,42 +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"
/>
<DemoWarning />
<CTA />
<main>
<ListView />
</main>
<Footer
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
</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"
/>
<CTA />
<main>
<ListView />
</main>
<Footer
logo="https://edx-cdn.org/v3/stage/open-edx-tag.svg"
/>
</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: 28 additions & 12 deletions src/containers/ResponseDisplay/__snapshots__/index.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ exports[`ResponseDisplay component snapshot file upload disable with valid respo
<div
className="response-display"
>
<Card>
<Card.Section
className="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 All @@ -19,9 +24,11 @@ exports[`ResponseDisplay component snapshot file upload disabled without respons
className="response-display"
>
<SubmissionFiles
data-testid="submission-files"
files={Array []}
/>
<PreviewDisplay
data-testid="allow-file-upload"
files={Array []}
/>
</div>
Expand All @@ -32,6 +39,7 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
className="response-display"
>
<SubmissionFiles
data-testid="submission-files"
files={
Array [
Object {
Expand All @@ -48,6 +56,7 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
}
/>
<PreviewDisplay
data-testid="allow-file-upload"
files={
Array [
Object {
Expand All @@ -63,13 +72,18 @@ exports[`ResponseDisplay component snapshot file upload enable with valid respon
]
}
/>
<Card>
<Card.Section
className="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 All @@ -78,9 +92,11 @@ exports[`ResponseDisplay component snapshot file upload enable without response
className="response-display"
>
<SubmissionFiles
data-testid="submission-files"
files={Array []}
/>
<PreviewDisplay
data-testid="allow-file-upload"
files={Array []}
/>
</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 '@edx/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">{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