|
| 1 | +import React, {useRef} from 'react'; |
| 2 | +import { EditorComponent } from '@src/editors/EditorComponent'; |
| 3 | +import { useIntl } from '@edx/frontend-platform/i18n'; |
| 4 | +import { useDispatch, useSelector } from 'react-redux'; |
| 5 | +import { EditorState, selectors } from '@src/editors/data/redux'; |
| 6 | +import { RequestKeys } from '@src/editors/data/constants/requests'; |
| 7 | +import {Spinner} from "@openedx/paragon"; |
| 8 | +import EditorContainer from "@src/editors/containers/EditorContainer"; |
| 9 | +import { ProblemEditorContextProvider } from "../ProblemEditor/components/EditProblemView/ProblemEditorContext"; |
| 10 | + |
| 11 | +export interface Props extends EditorComponent {} |
| 12 | + |
| 13 | +/** |
| 14 | + * Renders the form with all fields to embed a PDF. |
| 15 | + */ |
| 16 | +const PdfEditor: React.FC<Props> = (props) => { |
| 17 | + const intl = useIntl(); |
| 18 | + const dispatch = useDispatch(); |
| 19 | + const blockFinished = useSelector((state: EditorState) => selectors.app.shouldCreateBlock(state) |
| 20 | + || selectors.requests.isFinished(state, { requestKey: RequestKeys.fetchBlock })); |
| 21 | + |
| 22 | + const blockFailed = useSelector( |
| 23 | + (state: EditorState) => selectors.requests.isFailed(state, { requestKey: RequestKeys.fetchBlock }), |
| 24 | + ); |
| 25 | + // TODO: Is this necessary? |
| 26 | + const editorRef = useRef(null); |
| 27 | + if (!blockFinished) { |
| 28 | + return ( |
| 29 | + <div className="text-center p-6"> |
| 30 | + <Spinner |
| 31 | + animation="border" |
| 32 | + className="m-3" |
| 33 | + screenReaderText="Loading Problem Editor" |
| 34 | + /> |
| 35 | + </div> |
| 36 | + ); |
| 37 | + } |
| 38 | + return ( |
| 39 | + <ProblemEditorContextProvider editorRef={editorRef}> |
| 40 | + <EditorContainer {...props} isDirty={() => true} getContent={() => console.log("Content get!")}> |
| 41 | + <h1>I am the PDF Editor</h1> |
| 42 | + </EditorContainer> |
| 43 | + </ProblemEditorContextProvider> |
| 44 | + ) |
| 45 | +}; |
| 46 | + |
| 47 | +export default PdfEditor; |
0 commit comments