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) {
|
export function useDetachContext(propTypes) {
|
||||||
const data = useContext(DetachContext)
|
const data = useContext(DetachContext)
|
||||||
|
if (!data) {
|
||||||
|
throw new Error('useDetachContext is only available inside DetachProvider')
|
||||||
|
}
|
||||||
PropTypes.checkPropTypes(propTypes, data, 'data', 'DetachContext.Provider')
|
PropTypes.checkPropTypes(propTypes, data, 'data', 'DetachContext.Provider')
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import useScopeValue from '../hooks/use-scope-value'
|
||||||
import useBrowserWindow from '../hooks/use-browser-window'
|
import useBrowserWindow from '../hooks/use-browser-window'
|
||||||
import { useIdeContext } from './ide-context'
|
import { useIdeContext } from './ide-context'
|
||||||
import { useProjectContext } from './project-context'
|
import { useProjectContext } from './project-context'
|
||||||
|
import { useDetachContext } from './detach-context'
|
||||||
|
|
||||||
export const EditorContext = createContext()
|
export const EditorContext = createContext()
|
||||||
|
|
||||||
|
@ -41,6 +42,8 @@ EditorContext.Provider.propTypes = {
|
||||||
export function EditorProvider({ children, settings }) {
|
export function EditorProvider({ children, settings }) {
|
||||||
const ide = useIdeContext()
|
const ide = useIdeContext()
|
||||||
|
|
||||||
|
const { role } = useDetachContext()
|
||||||
|
|
||||||
const { owner, features } = useProjectContext({
|
const { owner, features } = useProjectContext({
|
||||||
owner: PropTypes.shape({
|
owner: PropTypes.shape({
|
||||||
_id: PropTypes.string.isRequired,
|
_id: PropTypes.string.isRequired,
|
||||||
|
@ -107,12 +110,24 @@ export function EditorProvider({ children, settings }) {
|
||||||
|
|
||||||
const { setTitle } = useBrowserWindow()
|
const { setTitle } = useBrowserWindow()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTitle(
|
const parts = []
|
||||||
`${projectName ? projectName + ' - ' : ''}Online LaTeX Editor ${
|
|
||||||
window.ExposedSettings.appName
|
if (role === 'detached') {
|
||||||
}`
|
parts.push('[PDF]')
|
||||||
)
|
}
|
||||||
}, [projectName, setTitle])
|
|
||||||
|
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 => {
|
const insertSymbol = useCallback(symbol => {
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
|
|
|
@ -20,8 +20,8 @@ export function ContextRoot({ children, ide, settings }) {
|
||||||
<UserProvider>
|
<UserProvider>
|
||||||
<ProjectProvider>
|
<ProjectProvider>
|
||||||
<FileTreeDataProvider>
|
<FileTreeDataProvider>
|
||||||
<EditorProvider settings={settings}>
|
<DetachProvider>
|
||||||
<DetachProvider>
|
<EditorProvider settings={settings}>
|
||||||
<LayoutProvider>
|
<LayoutProvider>
|
||||||
<LocalCompileProvider>
|
<LocalCompileProvider>
|
||||||
<DetachCompileProvider>
|
<DetachCompileProvider>
|
||||||
|
@ -29,8 +29,8 @@ export function ContextRoot({ children, ide, settings }) {
|
||||||
</DetachCompileProvider>
|
</DetachCompileProvider>
|
||||||
</LocalCompileProvider>
|
</LocalCompileProvider>
|
||||||
</LayoutProvider>
|
</LayoutProvider>
|
||||||
</DetachProvider>
|
</EditorProvider>
|
||||||
</EditorProvider>
|
</DetachProvider>
|
||||||
</FileTreeDataProvider>
|
</FileTreeDataProvider>
|
||||||
</ProjectProvider>
|
</ProjectProvider>
|
||||||
</UserProvider>
|
</UserProvider>
|
||||||
|
|
|
@ -109,15 +109,15 @@ export function EditorProviders({
|
||||||
<UserProvider>
|
<UserProvider>
|
||||||
<ProjectProvider>
|
<ProjectProvider>
|
||||||
<FileTreeDataProvider>
|
<FileTreeDataProvider>
|
||||||
<EditorProvider settings={{}}>
|
<DetachProvider>
|
||||||
<DetachProvider>
|
<EditorProvider settings={{}}>
|
||||||
<LayoutProvider>
|
<LayoutProvider>
|
||||||
<LocalCompileProvider>
|
<LocalCompileProvider>
|
||||||
<DetachCompileProvider>{children}</DetachCompileProvider>
|
<DetachCompileProvider>{children}</DetachCompileProvider>
|
||||||
</LocalCompileProvider>
|
</LocalCompileProvider>
|
||||||
</LayoutProvider>
|
</LayoutProvider>
|
||||||
</DetachProvider>
|
</EditorProvider>
|
||||||
</EditorProvider>
|
</DetachProvider>
|
||||||
</FileTreeDataProvider>
|
</FileTreeDataProvider>
|
||||||
</ProjectProvider>
|
</ProjectProvider>
|
||||||
</UserProvider>
|
</UserProvider>
|
||||||
|
|
Loading…
Reference in a new issue