From aba4694377b2ce2b3305e1fa692477a5e8c1b310 Mon Sep 17 00:00:00 2001 From: Mathias Jakobsen Date: Wed, 2 Oct 2024 11:36:42 +0100 Subject: [PATCH] [web] Move ARS Write and Cite behind separate feature flag (#20631) * [web] Move ARS Write and Cite behind separate feature flag * [web] Use isSplitTestEnabled function * [web] Only load Write and Cite if project has ARS access * [web] Enable Write and Cite ARS by default * [web] Fix condition for loading write and cite ref sources * [web] Remove references settings button in free projects GitOrigin-RevId: c4f3b7c60da9864409c788dcf34bdc77347441a8 --- .../web/app/src/Features/Project/ProjectController.js | 1 + .../js/features/source-editor/extensions/index.ts | 9 +++++---- .../features/source-editor/hooks/use-codemirror-scope.ts | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index 5d149e9098..fd2477904b 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -339,6 +339,7 @@ const _ProjectController = { !anonymous && 'writefull-oauth-promotion', 'ieee-stylesheet', 'write-and-cite', + 'write-and-cite-ars', 'default-visual-for-beginners', 'spell-check-client', ].filter(Boolean) diff --git a/services/web/frontend/js/features/source-editor/extensions/index.ts b/services/web/frontend/js/features/source-editor/extensions/index.ts index 9e663d47b6..e0c724a54f 100644 --- a/services/web/frontend/js/features/source-editor/extensions/index.ts +++ b/services/web/frontend/js/features/source-editor/extensions/index.ts @@ -54,9 +54,10 @@ import { ranges } from './ranges' import { trackDetachedComments } from './track-detached-comments' import { addComment } from './add-comment' -const moduleExtensions: Array<() => Extension> = importOverleafModules( - 'sourceEditorExtensions' -).map((item: { import: { extension: Extension } }) => item.import.extension) +const moduleExtensions: Array<(options: Record) => Extension> = + importOverleafModules('sourceEditorExtensions').map( + (item: { import: { extension: Extension } }) => item.import.extension + ) export const createExtensions = (options: Record): Extension[] => [ lineNumbers(), @@ -145,7 +146,7 @@ export const createExtensions = (options: Record): Extension[] => [ // Send exceptions to Sentry EditorView.exceptionSink.of(options.handleException), // CodeMirror extensions provided by modules - moduleExtensions.map(extension => extension()), + moduleExtensions.map(extension => extension(options)), thirdPartyExtensions(), effectListeners(), geometryChangeEvent(), diff --git a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts index aafab8eb19..84b97c3769 100644 --- a/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts +++ b/services/web/frontend/js/features/source-editor/hooks/use-codemirror-scope.ts @@ -111,6 +111,7 @@ function useCodeMirrorScope(view: EditorView) { const [spellCheckLanguage] = useScopeValue( 'project.spellCheckLanguage' ) + const [projectFeatures] = useScopeValue('project.features') const hunspellManager = useHunspell(spellCheckLanguage) @@ -228,6 +229,8 @@ function useCodeMirrorScope(view: EditorView) { view.dispatch(setSpellCheckLanguage(spellingRef.current)) }, [view, spellCheckLanguage, hunspellManager]) + const projectFeaturesRef = useRef(projectFeatures) + // listen to doc:after-opened, and focus the editor if it's not a new doc useEffect(() => { const listener: EventListener = event => { @@ -326,6 +329,7 @@ function useCodeMirrorScope(view: EditorView) { phrases: phrasesRef.current, spelling: spellingRef.current, visual: visualRef.current, + projectFeatures: projectFeaturesRef.current, changeManager: createChangeManager(view, currentDoc), handleError, handleException,