mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 04:58:46 -05:00
7c97f8ab6e
* Use new JSX runtime and update Babel Node target * Update .eslintrc * Remove React imports GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
import { createContext, useContext } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import useScopeValue from './util/scope-value-hook'
|
|
|
|
export const CompileContext = createContext()
|
|
|
|
CompileContext.Provider.propTypes = {
|
|
value: PropTypes.shape({
|
|
pdfUrl: PropTypes.string,
|
|
pdfDownloadUrl: PropTypes.string,
|
|
logEntries: PropTypes.object,
|
|
uncompiled: PropTypes.bool,
|
|
}),
|
|
}
|
|
|
|
export function CompileProvider({ children }) {
|
|
const [pdfUrl] = useScopeValue('pdf.url')
|
|
const [pdfDownloadUrl] = useScopeValue('pdf.downloadUrl')
|
|
const [logEntries] = useScopeValue('pdf.logEntries')
|
|
const [uncompiled] = useScopeValue('pdf.uncompiled')
|
|
|
|
const value = {
|
|
pdfUrl,
|
|
pdfDownloadUrl,
|
|
logEntries,
|
|
uncompiled,
|
|
}
|
|
|
|
return (
|
|
<CompileContext.Provider value={value}>{children}</CompileContext.Provider>
|
|
)
|
|
}
|
|
|
|
CompileProvider.propTypes = {
|
|
children: PropTypes.any,
|
|
}
|
|
|
|
export function useCompileContext(propTypes) {
|
|
const data = useContext(CompileContext)
|
|
PropTypes.checkPropTypes(propTypes, data, 'data', 'CompileContext.Provider')
|
|
return data
|
|
}
|