diff --git a/services/web/frontend/extracted-translations.json b/services/web/frontend/extracted-translations.json
index 7db0fc6d4f..91900cd22a 100644
--- a/services/web/frontend/extracted-translations.json
+++ b/services/web/frontend/extracted-translations.json
@@ -2058,6 +2058,7 @@
"will_lose_edit_access_on_date": "",
"with_premium_subscription_you_also_get": "",
"word_count": "",
+ "word_count_lower": "",
"work_in_vim_or_emacs_emulation_mode": "",
"work_offline": "",
"work_offline_pull_to_overleaf": "",
diff --git a/services/web/frontend/js/features/ide-redesign/components/toolbar/menu-bar.tsx b/services/web/frontend/js/features/ide-redesign/components/toolbar/menu-bar.tsx
index d75dfeb632..d0e3a8dbf5 100644
--- a/services/web/frontend/js/features/ide-redesign/components/toolbar/menu-bar.tsx
+++ b/services/web/frontend/js/features/ide-redesign/components/toolbar/menu-bar.tsx
@@ -7,7 +7,7 @@ import { MenuBarDropdown } from '@/shared/components/menu-bar/menu-bar-dropdown'
import { MenuBarOption } from '@/shared/components/menu-bar/menu-bar-option'
import { useTranslation } from 'react-i18next'
import ChangeLayoutOptions from './change-layout-options'
-import { MouseEventHandler, useCallback, useMemo } from 'react'
+import { MouseEventHandler, useCallback, useMemo, useState } from 'react'
import { useIdeRedesignSwitcherContext } from '@/features/ide-react/context/ide-redesign-switcher-context'
import { useSwitchEnableNewEditorState } from '../../hooks/use-switch-enable-new-editor-state'
import MaterialIcon from '@/shared/components/material-icon'
@@ -21,6 +21,9 @@ import CommandDropdown, {
} from './command-dropdown'
import { useUserSettingsContext } from '@/shared/context/user-settings-context'
import { useRailContext } from '../../contexts/rail-context'
+import WordCountModal from '@/features/word-count-modal/components/word-count-modal'
+import { isSplitTestEnabled } from '@/utils/splitTestUtils'
+import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
export const ToolbarMenuBar = () => {
const { t } = useTranslation()
@@ -29,6 +32,9 @@ export const ToolbarMenuBar = () => {
setShowSwitcherModal(true)
}, [setShowSwitcherModal])
const { setView, view } = useLayoutContext()
+ const { pdfUrl } = useCompileContext()
+ const wordCountEnabled = pdfUrl || isSplitTestEnabled('word-count-client')
+ const [showWordCountModal, setShowWordCountModal] = useState(false)
useCommandProvider(
() => [
@@ -40,8 +46,17 @@ export const ToolbarMenuBar = () => {
},
id: 'show_version_history',
},
+ {
+ type: 'command',
+ label: t('word_count_lower'),
+ disabled: !wordCountEnabled,
+ handler: () => {
+ setShowWordCountModal(true)
+ },
+ id: 'word_count',
+ },
],
- [t, setView, view]
+ [t, setView, view, wordCountEnabled]
)
const fileMenuStructure: MenuStructure = useMemo(
() => [
@@ -49,7 +64,7 @@ export const ToolbarMenuBar = () => {
id: 'file-file-tree',
children: ['new_file', 'new_folder', 'upload_file'],
},
- { id: 'file-history', children: ['show_version_history'] },
+ { id: 'file-tools', children: ['show_version_history', 'word_count'] },
{
id: 'file-download',
children: ['download-as-source-zip', 'download-pdf'],
@@ -175,67 +190,73 @@ export const ToolbarMenuBar = () => {
setActiveModal('contact-us')
}, [setActiveModal])
return (
-
+ setShowWordCountModal(false)}
/>
-
-
-
-
-
-
-
-
-
-
-
+ >
)
}
diff --git a/services/web/locales/en.json b/services/web/locales/en.json
index 1a610957e6..1a00873eda 100644
--- a/services/web/locales/en.json
+++ b/services/web/locales/en.json
@@ -2609,6 +2609,7 @@
"will_need_to_log_out_from_and_in_with": "You will need to log out from your __email1__ account and then log in with __email2__.",
"with_premium_subscription_you_also_get": "With an Overleaf Premium subscription you also get",
"word_count": "Word Count",
+ "word_count_lower": "Word count",
"work_in_vim_or_emacs_emulation_mode": "Work in Vim or Emacs emulation mode",
"work_offline": "Work offline",
"work_offline_pull_to_overleaf": "Work offline, then pull to __appName__",