diff --git a/services/web/frontend/js/shared/context/detach-context.js b/services/web/frontend/js/shared/context/detach-context.js
index c6008d88db..e9b21c9d9d 100644
--- a/services/web/frontend/js/shared/context/detach-context.js
+++ b/services/web/frontend/js/shared/context/detach-context.js
@@ -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
}
diff --git a/services/web/frontend/js/shared/context/editor-context.js b/services/web/frontend/js/shared/context/editor-context.js
index 04533082d6..1fdda391c7 100644
--- a/services/web/frontend/js/shared/context/editor-context.js
+++ b/services/web/frontend/js/shared/context/editor-context.js
@@ -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(
diff --git a/services/web/frontend/js/shared/context/root-context.js b/services/web/frontend/js/shared/context/root-context.js
index eb425fa5ea..bdc1c6a681 100644
--- a/services/web/frontend/js/shared/context/root-context.js
+++ b/services/web/frontend/js/shared/context/root-context.js
@@ -20,8 +20,8 @@ export function ContextRoot({ children, ide, settings }) {
-
-
+
+
@@ -29,8 +29,8 @@ export function ContextRoot({ children, ide, settings }) {
-
-
+
+
diff --git a/services/web/test/frontend/helpers/editor-providers.js b/services/web/test/frontend/helpers/editor-providers.js
index 72dca645e1..c81c921d3b 100644
--- a/services/web/test/frontend/helpers/editor-providers.js
+++ b/services/web/test/frontend/helpers/editor-providers.js
@@ -109,15 +109,15 @@ export function EditorProviders({
-
-
+
+
{children}
-
-
+
+