diff --git a/services/web/app/src/Features/Project/ProjectController.js b/services/web/app/src/Features/Project/ProjectController.js index c69fe7cbd4..bb78e40868 100644 --- a/services/web/app/src/Features/Project/ProjectController.js +++ b/services/web/app/src/Features/Project/ProjectController.js @@ -1067,6 +1067,21 @@ const ProjectController = { } ) }, + richTextAssignment(cb) { + SplitTestHandler.getAssignment( + req, + res, + 'rich-text', + (error, assignment) => { + // do not fail editor load if assignment fails + if (error) { + cb(null, { variant: 'default' }) + } else { + cb(null, assignment) + } + } + ) + }, }, ( err, @@ -1083,6 +1098,7 @@ const ProjectController = { newSourceEditorAssignment, pdfjsAssignment, editorLeftMenuAssignment, + richTextAssignment, } ) => { if (err != null) { @@ -1266,6 +1282,7 @@ const ProjectController = { fixedSizeDocument: true, useOpenTelemetry: Settings.useOpenTelemetryClient, showCM6SwitchAwaySurvey: Settings.showCM6SwitchAwaySurvey, + richTextVariant: richTextAssignment.variant, }) timer.done() } diff --git a/services/web/app/views/project/editor/meta.pug b/services/web/app/views/project/editor/meta.pug index bf86b78d96..3213082069 100644 --- a/services/web/app/views/project/editor/meta.pug +++ b/services/web/app/views/project/editor/meta.pug @@ -34,6 +34,7 @@ meta(name="ol-showUpgradePrompt" data-type="boolean" content=showUpgradePrompt) meta(name="ol-useOpenTelemetry" data-type="boolean" content=useOpenTelemetry) meta(name="ol-showSupport", data-type="boolean" content=showSupport) meta(name="ol-showCM6SwitchAwaySurvey", data-type="boolean" content=showCM6SwitchAwaySurvey) +meta(name="ol-richTextVariant" content=richTextVariant) - var fileActionI18n = ['edited', 'renamed', 'created', 'deleted'].reduce((acc, i) => {acc[i] = translate('file_action_' + i); return acc}, {}) meta(name="ol-fileActionI18n" data-type="json" content=fileActionI18n) diff --git a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx index 6fbfa27c54..dadd34da6c 100644 --- a/services/web/frontend/js/features/source-editor/components/editor-switch.tsx +++ b/services/web/frontend/js/features/source-editor/components/editor-switch.tsx @@ -2,8 +2,8 @@ import { memo, useCallback } from 'react' import useScopeValue from '../../../shared/hooks/use-scope-value' import Tooltip from '../../../shared/components/tooltip' import { sendMB } from '../../../infrastructure/event-tracking' - -const params = new URLSearchParams(window.location.search) +import getMeta from '../../../utils/meta' +import SplitTestBadge from '../../../shared/components/split-test-badge' function Badge() { const content = ( @@ -66,7 +66,7 @@ function EditorSwitch() { break case 'rich-text': - if (params.has('cm_visual')) { + if (getMeta('ol-richTextVariant') === 'cm6') { setRichText(false) setVisual(true) setNewSourceEditor(true) @@ -74,6 +74,7 @@ function EditorSwitch() { setRichText(true) setVisual(false) } + break } @@ -131,6 +132,10 @@ function EditorSwitch() { Rich Text + + {!!richTextOrVisual && ( + + )} ) } diff --git a/services/web/frontend/js/ide/editor/EditorManager.js b/services/web/frontend/js/ide/editor/EditorManager.js index 696b4db85e..68fa6322b4 100644 --- a/services/web/frontend/js/ide/editor/EditorManager.js +++ b/services/web/frontend/js/ide/editor/EditorManager.js @@ -24,8 +24,6 @@ import './controllers/SwitchToPDFButton' import getMeta from '../../utils/meta' import { hasSeenCM6SwitchAwaySurvey } from '../../features/source-editor/utils/switch-away-survey' -const params = new URLSearchParams(window.location.search) - let EditorManager export default EditorManager = (function () { @@ -168,7 +166,7 @@ export default EditorManager = (function () { } showRichText() { - if (params.has('cm_visual')) { + if (getMeta('ol-richTextVariant') === 'cm6') { return false } @@ -179,13 +177,13 @@ export default EditorManager = (function () { } showVisual() { - if (!params.has('cm_visual')) { + if (getMeta('ol-richTextVariant') !== 'cm6') { return false } return ( - this.localStorage(`editor.visual-mode.${this.$scope.project_id}`) === - 'visual' + this.localStorage(`editor.mode.${this.$scope.project_id}`) === + 'rich-text' ) }