Files
frontend-app-authoring/src/editors/sharedComponents/SourceCodeModal/index.jsx
Kristin Aoki 6c743f858d fix: video selection gallery scroll (#477)
* fix: video selection gallery scroll

* fix: lint errors
2024-05-22 12:02:25 -04:00

63 lines
1.4 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import {
FormattedMessage,
injectIntl,
intlShape,
} from '@edx/frontend-platform/i18n';
import { Button, useWindowSize } from '@openedx/paragon';
import messages from './messages';
import hooks from './hooks';
import BaseModal from '../BaseModal';
import CodeEditor from '../CodeEditor';
export const SourceCodeModal = ({
isOpen,
close,
editorRef,
// injected
intl,
}) => {
const { saveBtnProps, value, ref } = hooks.prepareSourceCodeModal({ editorRef, close });
const { height } = useWindowSize();
return (
<BaseModal
close={close}
size="xl"
confirmAction={(
<Button {...saveBtnProps} variant="primary">
<FormattedMessage {...messages.saveButtonLabel} />
</Button>
)}
isOpen={isOpen}
title={intl.formatMessage(messages.titleLabel)}
bodyStyle={{ maxHeight: (height - 180) }}
>
<div className="px-4.5 pt-2.5">
<CodeEditor
innerRef={ref}
value={value}
/>
</div>
</BaseModal>
);
};
SourceCodeModal.propTypes = {
isOpen: PropTypes.bool.isRequired,
close: PropTypes.func.isRequired,
editorRef: PropTypes.oneOfType([
PropTypes.func,
// eslint-disable-next-line react/forbid-prop-types
PropTypes.shape({ current: PropTypes.any }),
]).isRequired,
// injected
intl: intlShape.isRequired,
};
export default injectIntl(SourceCodeModal);