mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add "[PDF]" prefix to detached window title (#8039)
* Move DetachProvider outside EditorProvider * Add "[PDF]" prefix to detached window title GitOrigin-RevId: 7d09f4053069b20d55a2a04a8f29f90b973e50b9
This commit is contained in:
parent
1f24160005
commit
2340b1b25e
4 changed files with 32 additions and 14 deletions
|
@ -135,6 +135,9 @@ DetachProvider.propTypes = {
|
|||
|
||||
export function useDetachContext(propTypes) {
|
||||
const data = useContext(DetachContext)
|
||||
if (!data) {
|
||||
throw new Error('useDetachContext is only available inside DetachProvider')
|
||||
}
|
||||
PropTypes.checkPropTypes(propTypes, data, 'data', 'DetachContext.Provider')
|
||||
return data
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import useScopeValue from '../hooks/use-scope-value'
|
|||
import useBrowserWindow from '../hooks/use-browser-window'
|
||||
import { useIdeContext } from './ide-context'
|
||||
import { useProjectContext } from './project-context'
|
||||
import { useDetachContext } from './detach-context'
|
||||
|
||||
export const EditorContext = createContext()
|
||||
|
||||
|
@ -41,6 +42,8 @@ EditorContext.Provider.propTypes = {
|
|||
export function EditorProvider({ children, settings }) {
|
||||
const ide = useIdeContext()
|
||||
|
||||
const { role } = useDetachContext()
|
||||
|
||||
const { owner, features } = useProjectContext({
|
||||
owner: PropTypes.shape({
|
||||
_id: PropTypes.string.isRequired,
|
||||
|
@ -107,12 +110,24 @@ export function EditorProvider({ children, settings }) {
|
|||
|
||||
const { setTitle } = useBrowserWindow()
|
||||
useEffect(() => {
|
||||
setTitle(
|
||||
`${projectName ? projectName + ' - ' : ''}Online LaTeX Editor ${
|
||||
window.ExposedSettings.appName
|
||||
}`
|
||||
)
|
||||
}, [projectName, setTitle])
|
||||
const parts = []
|
||||
|
||||
if (role === 'detached') {
|
||||
parts.push('[PDF]')
|
||||
}
|
||||
|
||||
if (projectName) {
|
||||
parts.push(projectName)
|
||||
parts.push('-')
|
||||
}
|
||||
|
||||
parts.push('Online LaTeX Editor')
|
||||
parts.push(window.ExposedSettings.appName)
|
||||
|
||||
const title = parts.join(' ')
|
||||
|
||||
setTitle(title)
|
||||
}, [projectName, setTitle, role])
|
||||
|
||||
const insertSymbol = useCallback(symbol => {
|
||||
window.dispatchEvent(
|
||||
|
|
|
@ -20,8 +20,8 @@ export function ContextRoot({ children, ide, settings }) {
|
|||
<UserProvider>
|
||||
<ProjectProvider>
|
||||
<FileTreeDataProvider>
|
||||
<EditorProvider settings={settings}>
|
||||
<DetachProvider>
|
||||
<DetachProvider>
|
||||
<EditorProvider settings={settings}>
|
||||
<LayoutProvider>
|
||||
<LocalCompileProvider>
|
||||
<DetachCompileProvider>
|
||||
|
@ -29,8 +29,8 @@ export function ContextRoot({ children, ide, settings }) {
|
|||
</DetachCompileProvider>
|
||||
</LocalCompileProvider>
|
||||
</LayoutProvider>
|
||||
</DetachProvider>
|
||||
</EditorProvider>
|
||||
</EditorProvider>
|
||||
</DetachProvider>
|
||||
</FileTreeDataProvider>
|
||||
</ProjectProvider>
|
||||
</UserProvider>
|
||||
|
|
|
@ -109,15 +109,15 @@ export function EditorProviders({
|
|||
<UserProvider>
|
||||
<ProjectProvider>
|
||||
<FileTreeDataProvider>
|
||||
<EditorProvider settings={{}}>
|
||||
<DetachProvider>
|
||||
<DetachProvider>
|
||||
<EditorProvider settings={{}}>
|
||||
<LayoutProvider>
|
||||
<LocalCompileProvider>
|
||||
<DetachCompileProvider>{children}</DetachCompileProvider>
|
||||
</LocalCompileProvider>
|
||||
</LayoutProvider>
|
||||
</DetachProvider>
|
||||
</EditorProvider>
|
||||
</EditorProvider>
|
||||
</DetachProvider>
|
||||
</FileTreeDataProvider>
|
||||
</ProjectProvider>
|
||||
</UserProvider>
|
||||
|
|
Loading…
Reference in a new issue