Explorar o código

[cm6] rename to Code Editor | Visual Editor (#13513)

* [cm6] rename to Code Editor | Visual Editor

* showLegacySourceEditor change

* show info badge

* remove info badge

* display info badge

* use "Visual Editor" in example project

GitOrigin-RevId: 549e25aa4bcfe58522eadc70e35ca35f822317b1
Domagoj Kriskovic %!s(int64=3) %!d(string=hai) anos
pai
achega
2ab0779374

+ 1 - 69
services/web/app/src/Features/Project/ProjectController.js

@@ -38,8 +38,6 @@ const InstitutionsFeatures = require('../Institutions/InstitutionsFeatures')
 const ProjectAuditLogHandler = require('./ProjectAuditLogHandler')
 const ProjectAuditLogHandler = require('./ProjectAuditLogHandler')
 const PublicAccessLevels = require('../Authorization/PublicAccessLevels')
 const PublicAccessLevels = require('../Authorization/PublicAccessLevels')
 
 
-const VISUAL_EDITOR_NAMING_SPLIT_TEST_MIN_SIGNUP_DATE = new Date('2023-04-17')
-
 /**
 /**
  * @typedef {import("./types").GetProjectsRequest} GetProjectsRequest
  * @typedef {import("./types").GetProjectsRequest} GetProjectsRequest
  * @typedef {import("./types").GetProjectsResponse} GetProjectsResponse
  * @typedef {import("./types").GetProjectsResponse} GetProjectsResponse
@@ -558,60 +556,6 @@ const ProjectController = {
             }
             }
           )
           )
         },
         },
-        participatingInVisualEditorNamingTest: [
-          'user',
-          (results, cb) => {
-            const isNewUser =
-              results.user.signUpDate >=
-              VISUAL_EDITOR_NAMING_SPLIT_TEST_MIN_SIGNUP_DATE
-            cb(null, isNewUser)
-          },
-        ],
-        visualEditorNameAssignment: [
-          'participatingInVisualEditorNamingTest',
-          (results, cb) => {
-            if (!results.participatingInVisualEditorNamingTest) {
-              cb(null, { variant: 'default' })
-            } else {
-              SplitTestHandler.getAssignment(
-                req,
-                res,
-                'visual-editor-name',
-                (error, assignment) => {
-                  if (error) {
-                    cb(null, { variant: 'default' })
-                  } else {
-                    cb(null, assignment)
-                  }
-                }
-              )
-            }
-          },
-        ],
-        legacySourceEditorAssignment: [
-          'participatingInVisualEditorNamingTest',
-          'visualEditorNameAssignment',
-          (results, cb) => {
-            // Hide Ace for people in the Rich Text naming test
-            if (results.participatingInVisualEditorNamingTest) {
-              cb(null, { variant: 'true' })
-            } else {
-              SplitTestHandler.getAssignment(
-                req,
-                res,
-                'source-editor-legacy',
-                (error, assignment) => {
-                  // do not fail editor load if assignment fails
-                  if (error) {
-                    cb(null, { variant: 'default' })
-                  } else {
-                    cb(null, assignment)
-                  }
-                }
-              )
-            }
-          },
-        ],
         pdfjsAssignment(cb) {
         pdfjsAssignment(cb) {
           SplitTestHandler.getAssignment(
           SplitTestHandler.getAssignment(
             req,
             req,
@@ -848,9 +792,6 @@ const ProjectController = {
           isTokenMember,
           isTokenMember,
           isInvitedMember,
           isInvitedMember,
           brandVariation,
           brandVariation,
-          visualEditorNameAssignment,
-          participatingInVisualEditorNamingTest,
-          legacySourceEditorAssignment,
           pdfjsAssignment,
           pdfjsAssignment,
           editorLeftMenuAssignment,
           editorLeftMenuAssignment,
           richTextAssignment,
           richTextAssignment,
@@ -941,10 +882,7 @@ const ProjectController = {
             const showLegacySourceEditor =
             const showLegacySourceEditor =
               !Features.hasFeature('saas') ||
               !Features.hasFeature('saas') ||
               // Allow override via legacy_source_editor=true in query string
               // Allow override via legacy_source_editor=true in query string
-              shouldDisplayFeature('legacy_source_editor') ||
-              // Hide Ace for beta users
-              (!user.betaProgram &&
-                legacySourceEditorAssignment.variant === 'default')
+              shouldDisplayFeature('legacy_source_editor')
 
 
             const editorLeftMenuReact =
             const editorLeftMenuReact =
               editorLeftMenuAssignment?.variant === 'react'
               editorLeftMenuAssignment?.variant === 'react'
@@ -980,10 +918,6 @@ const ProjectController = {
                 ? 'project/editor_detached'
                 ? 'project/editor_detached'
                 : 'project/editor'
                 : 'project/editor'
 
 
-            const isParticipatingInVisualEditorNamingTest =
-              Features.hasFeature('saas') &&
-              participatingInVisualEditorNamingTest
-
             let richTextVariant
             let richTextVariant
             if (!Features.hasFeature('saas')) {
             if (!Features.hasFeature('saas')) {
               richTextVariant = 'cm6'
               richTextVariant = 'cm6'
@@ -1050,8 +984,6 @@ const ProjectController = {
               showTemplatesServerPro,
               showTemplatesServerPro,
               pdfjsVariant: pdfjsAssignment.variant,
               pdfjsVariant: pdfjsAssignment.variant,
               debugPdfDetach,
               debugPdfDetach,
-              isParticipatingInVisualEditorNamingTest,
-              visualEditorNameVariant: visualEditorNameAssignment.variant,
               showLegacySourceEditor,
               showLegacySourceEditor,
               showSymbolPalette,
               showSymbolPalette,
               galileoEnabled,
               galileoEnabled,

+ 1 - 1
services/web/app/templates/project_files/example-project/main.tex

@@ -33,7 +33,7 @@ Once you're familiar with the editor, you can find various project settings in t
 
 
 \subsection{How to create Sections and Subsections}
 \subsection{How to create Sections and Subsections}
 
 
-Simply use the section and subsection commands, as in this example document! With Overleaf, all the formatting and numbering is handled automatically according to the template you've chosen. If you're using Rich Text mode, you can also create new section and subsections via the buttons in the editor toolbar.
+Simply use the section and subsection commands, as in this example document! With Overleaf, all the formatting and numbering is handled automatically according to the template you've chosen. If you're using the Visual Editor, you can also create new section and subsections via the buttons in the editor toolbar.
 
 
 \subsection{How to include Figures}
 \subsection{How to include Figures}
 
 

+ 0 - 2
services/web/app/views/project/editor/meta.pug

@@ -22,8 +22,6 @@ meta(name="ol-wsRetryHandshake" data-type="json" content=settings.wsRetryHandsha
 meta(name="ol-pdfjsVariant" content=pdfjsVariant)
 meta(name="ol-pdfjsVariant" content=pdfjsVariant)
 meta(name="ol-debugPdfDetach" data-type="boolean" content=debugPdfDetach)
 meta(name="ol-debugPdfDetach" data-type="boolean" content=debugPdfDetach)
 meta(name="ol-showLegacySourceEditor", data-type="boolean" content=showLegacySourceEditor)
 meta(name="ol-showLegacySourceEditor", data-type="boolean" content=showLegacySourceEditor)
-meta(name="ol-visualEditorNameVariant", data-type="string" content=visualEditorNameVariant)
-meta(name="ol-isParticipatingInVisualEditorNamingTest", data-type="boolean" content=isParticipatingInVisualEditorNamingTest)
 meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
 meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
 meta(name="ol-galileoEnabled" data-type="string" content=galileoEnabled)
 meta(name="ol-galileoEnabled" data-type="string" content=galileoEnabled)
 meta(name="ol-galileoPromptWords" data-type="string" content=galileoPromptWords)
 meta(name="ol-galileoPromptWords" data-type="string" content=galileoPromptWords)

+ 2 - 0
services/web/frontend/extracted-translations.json

@@ -127,6 +127,7 @@
   "clsi_unavailable": "",
   "clsi_unavailable": "",
   "code_check_failed": "",
   "code_check_failed": "",
   "code_check_failed_explanation": "",
   "code_check_failed_explanation": "",
+  "code_editor": "",
   "collaborate_online_and_offline": "",
   "collaborate_online_and_offline": "",
   "collabs_per_proj": "",
   "collabs_per_proj": "",
   "collabs_per_proj_single": "",
   "collabs_per_proj_single": "",
@@ -1083,6 +1084,7 @@
   "view_pdf": "",
   "view_pdf": "",
   "view_your_invoices": "",
   "view_your_invoices": "",
   "viewing_x": "",
   "viewing_x": "",
+  "visual_editor": "",
   "want_change_to_apply_before_plan_end": "",
   "want_change_to_apply_before_plan_end": "",
   "we_cant_find_any_sections_or_subsections_in_this_file": "",
   "we_cant_find_any_sections_or_subsections_in_this_file": "",
   "we_logged_you_in": "",
   "we_logged_you_in": "",

+ 5 - 18
services/web/frontend/js/features/source-editor/components/editor-switch.tsx

@@ -3,9 +3,9 @@ import useScopeValue from '../../../shared/hooks/use-scope-value'
 import Tooltip from '../../../shared/components/tooltip'
 import Tooltip from '../../../shared/components/tooltip'
 import { sendMB } from '../../../infrastructure/event-tracking'
 import { sendMB } from '../../../infrastructure/event-tracking'
 import getMeta from '../../../utils/meta'
 import getMeta from '../../../utils/meta'
-import SplitTestBadge from '../../../shared/components/split-test-badge'
 import isValidTeXFile from '../../../main/is-valid-tex-file'
 import isValidTeXFile from '../../../main/is-valid-tex-file'
 import { useTranslation } from 'react-i18next'
 import { useTranslation } from 'react-i18next'
+import SplitTestBadge from '../../../shared/components/split-test-badge'
 
 
 function Badge() {
 function Badge() {
   const content = (
   const content = (
@@ -41,23 +41,13 @@ function Badge() {
 }
 }
 
 
 const showLegacySourceEditor: boolean = getMeta('ol-showLegacySourceEditor')
 const showLegacySourceEditor: boolean = getMeta('ol-showLegacySourceEditor')
-const visualEditorNameVariant: string = getMeta('ol-visualEditorNameVariant')
-const isParticipatingInVisualEditorNamingTest: boolean = getMeta(
-  'ol-isParticipatingInVisualEditorNamingTest'
-)
 
 
 function EditorSwitch() {
 function EditorSwitch() {
+  const { t } = useTranslation()
   const [newSourceEditor, setNewSourceEditor] = useScopeValue(
   const [newSourceEditor, setNewSourceEditor] = useScopeValue(
     'editor.newSourceEditor'
     'editor.newSourceEditor'
   )
   )
   const [richText, setRichText] = useScopeValue('editor.showRichText')
   const [richText, setRichText] = useScopeValue('editor.showRichText')
-  const sourceName =
-    visualEditorNameVariant === 'code-visual'
-      ? 'Code Editor'
-      : visualEditorNameVariant === 'source-visual'
-      ? 'Source Editor'
-      : 'Source'
-
   const [visual, setVisual] = useScopeValue('editor.showVisual')
   const [visual, setVisual] = useScopeValue('editor.showVisual')
 
 
   const [docName] = useScopeValue('editor.open_doc_name')
   const [docName] = useScopeValue('editor.open_doc_name')
@@ -116,7 +106,7 @@ function EditorSwitch() {
           onChange={handleChange}
           onChange={handleChange}
         />
         />
         <label htmlFor="editor-switch-cm6" className="toggle-switch-label">
         <label htmlFor="editor-switch-cm6" className="toggle-switch-label">
-          <span>{sourceName}</span>
+          <span>{t('code_editor')}</span>
         </label>
         </label>
 
 
         {showLegacySourceEditor ? (
         {showLegacySourceEditor ? (
@@ -143,7 +133,7 @@ function EditorSwitch() {
         />
         />
       </fieldset>
       </fieldset>
 
 
-      {!!richTextOrVisual && !isParticipatingInVisualEditorNamingTest && (
+      {!!richTextOrVisual && (
         <SplitTestBadge splitTestName="rich-text" displayOnVariants={['cm6']} />
         <SplitTestBadge splitTestName="rich-text" displayOnVariants={['cm6']} />
       )}
       )}
     </div>
     </div>
@@ -157,9 +147,6 @@ const RichTextToggle: FC<{
 }> = ({ checked, disabled, handleChange }) => {
 }> = ({ checked, disabled, handleChange }) => {
   const { t } = useTranslation()
   const { t } = useTranslation()
 
 
-  const richTextName =
-    visualEditorNameVariant === 'default' ? 'Rich Text' : 'Visual Editor'
-
   const toggle = (
   const toggle = (
     <span>
     <span>
       <input
       <input
@@ -173,7 +160,7 @@ const RichTextToggle: FC<{
         disabled={disabled}
         disabled={disabled}
       />
       />
       <label htmlFor="editor-switch-rich-text" className="toggle-switch-label">
       <label htmlFor="editor-switch-rich-text" className="toggle-switch-label">
-        <span>{richTextName}</span>
+        <span>{t('visual_editor')}</span>
       </label>
       </label>
     </span>
     </span>
   )
   )

+ 2 - 0
services/web/locales/en.json

@@ -231,6 +231,7 @@
   "cn": "Chinese (Simplified)",
   "cn": "Chinese (Simplified)",
   "code_check_failed": "Code check failed",
   "code_check_failed": "Code check failed",
   "code_check_failed_explanation": "Your code has errors that need to be fixed before the auto-compile can run",
   "code_check_failed_explanation": "Your code has errors that need to be fixed before the auto-compile can run",
+  "code_editor": "Code Editor",
   "collaborate_online_and_offline": "Collaborate online and offline, using your own workflow",
   "collaborate_online_and_offline": "Collaborate online and offline, using your own workflow",
   "collaboration": "Collaboration",
   "collaboration": "Collaboration",
   "collaborator": "Collaborator",
   "collaborator": "Collaborator",
@@ -1752,6 +1753,7 @@
   "view_which_changes": "View which changes have been",
   "view_which_changes": "View which changes have been",
   "view_your_invoices": "View Your Invoices",
   "view_your_invoices": "View Your Invoices",
   "viewing_x": "Viewing <0>__endTime__</0>",
   "viewing_x": "Viewing <0>__endTime__</0>",
+  "visual_editor": "Visual Editor",
   "want_change_to_apply_before_plan_end": "If you wish this change to apply before the end of your current billing period, please contact us.",
   "want_change_to_apply_before_plan_end": "If you wish this change to apply before the end of your current billing period, please contact us.",
   "we_cant_find_any_sections_or_subsections_in_this_file": "We can’t find any sections or subsections in this file",
   "we_cant_find_any_sections_or_subsections_in_this_file": "We can’t find any sections or subsections in this file",
   "we_logged_you_in": "We have logged you in.",
   "we_logged_you_in": "We have logged you in.",