mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 21:23:45 +01:00
Merge pull request #36408 from overleaf/mj-context-menu-flag-teardown
[web] Tear down editor-context-menu flag GitOrigin-RevId: 80cc2ebaf62ec1bd6064b0f96b884d159a9d4b5f
This commit is contained in:
committed by
Copybot
parent
38eb3ddfa6
commit
e8ee19d17d
@@ -497,7 +497,6 @@ const _ProjectController = {
|
||||
'wf-citations-checker',
|
||||
'wf-citations-checker-on-selection',
|
||||
'writefull-asymetric-queue-size-per-model',
|
||||
'editor-context-menu',
|
||||
'email-notifications',
|
||||
'wf-enable-freemium-super-complete',
|
||||
'wf-enable-super-complete-promotion',
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
useCodeMirrorViewContext,
|
||||
} from './codemirror-context'
|
||||
import { contextMenuStateField } from '../extensions/context-menu'
|
||||
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
||||
import { useContextMenuItems } from '../hooks/use-context-menu-items'
|
||||
import DropdownListItem from '@/shared/components/dropdown/dropdown-list-item'
|
||||
import { sendContextMenuEvent } from '../utils/context-menu-analytics'
|
||||
@@ -20,10 +19,9 @@ import { sendContextMenuEvent } from '../utils/context-menu-analytics'
|
||||
const EditorContextMenu: FC = () => {
|
||||
const state = useCodeMirrorStateContext()
|
||||
const view = useCodeMirrorViewContext()
|
||||
const editorContextMenuEnabled = useFeatureFlag('editor-context-menu')
|
||||
|
||||
const menuState = state.field(contextMenuStateField, false)
|
||||
if (!editorContextMenuEnabled || !menuState?.tooltip) {
|
||||
if (!menuState?.tooltip) {
|
||||
return null
|
||||
}
|
||||
|
||||
|
||||
@@ -396,8 +396,8 @@ const contextMenuKeymap = (): Extension =>
|
||||
])
|
||||
)
|
||||
|
||||
export const contextMenu = (enabled: boolean): Extension =>
|
||||
enabled && !isMobile
|
||||
export const contextMenu = (): Extension =>
|
||||
!isMobile
|
||||
? [
|
||||
contextMenuContainerTheme,
|
||||
contextMenuStateField,
|
||||
|
||||
@@ -159,11 +159,8 @@ export const createExtensions = (options: Record<string, any>): Extension[] => [
|
||||
trackDetachedComments(options.currentDoc),
|
||||
visual(options.docName, options.visual),
|
||||
mathPreview(options.settings.mathPreview),
|
||||
reviewTooltip(
|
||||
options.settings.floatingMenu,
|
||||
options.editorContextMenuEnabled
|
||||
),
|
||||
contextMenu(options.editorContextMenuEnabled),
|
||||
reviewTooltip(options.settings.floatingMenu),
|
||||
contextMenu(),
|
||||
toolbarPanel(),
|
||||
breadcrumbPanel(),
|
||||
verticalOverflow(),
|
||||
|
||||
@@ -32,28 +32,20 @@ const mouseDownStateField = StateField.define<boolean>({
|
||||
|
||||
const reviewTooltipCompartment = new Compartment()
|
||||
|
||||
export const reviewTooltip = (
|
||||
enabled: boolean,
|
||||
editorContextMenuEnabled: boolean = false
|
||||
): Extension => {
|
||||
export const reviewTooltip = (enabled: boolean): Extension => {
|
||||
return [
|
||||
addCommentRangesField,
|
||||
reviewTooltipCompartment.of(
|
||||
enabled ? reviewTooltipMenu(editorContextMenuEnabled) : []
|
||||
),
|
||||
reviewTooltipCompartment.of(enabled ? reviewTooltipMenu() : []),
|
||||
]
|
||||
}
|
||||
|
||||
export const setReviewTooltip = (
|
||||
enabled: boolean,
|
||||
editorContextMenuEnabled: boolean
|
||||
): TransactionSpec => ({
|
||||
export const setReviewTooltip = (enabled: boolean): TransactionSpec => ({
|
||||
effects: reviewTooltipCompartment.reconfigure(
|
||||
enabled ? reviewTooltipMenu(editorContextMenuEnabled) : []
|
||||
enabled ? reviewTooltipMenu() : []
|
||||
),
|
||||
})
|
||||
|
||||
const reviewTooltipMenu = (editorContextMenuEnabled: boolean): Extension => {
|
||||
const reviewTooltipMenu = (): Extension => {
|
||||
let mouseUpListener: null | (() => void) = null
|
||||
const disableMouseUpListener = () => {
|
||||
if (mouseUpListener) {
|
||||
@@ -68,7 +60,7 @@ const reviewTooltipMenu = (editorContextMenuEnabled: boolean): Extension => {
|
||||
EditorView.domEventHandlers({
|
||||
mousedown: (event, view) => {
|
||||
// Hide tooltip when opening the context menu
|
||||
if (editorContextMenuEnabled && isContextMenuMouseEvent(event)) {
|
||||
if (isContextMenuMouseEvent(event)) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ import { beforeChangeDocEffect } from '@/features/source-editor/extensions/befor
|
||||
import { useActiveOverallTheme } from '@/shared/hooks/use-active-overall-theme'
|
||||
import { useEditorSelectionContext } from '@/shared/context/editor-selection-context'
|
||||
import { useActiveEditorTheme } from '@/shared/hooks/use-active-editor-theme'
|
||||
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
||||
import { isCmVisualEditorAvailable } from '../utils/visual-editor'
|
||||
import { setEditorTabs } from '../extensions/tabs-listener'
|
||||
import { setReviewTooltip } from '../extensions/review-tooltip'
|
||||
@@ -100,7 +99,6 @@ function useCodeMirrorScope(view: EditorView) {
|
||||
const { onlineUserCursorHighlights } = useOnlineUsersContext()
|
||||
|
||||
const { project, features: projectFeatures } = useProjectContext()
|
||||
const editorContextMenuEnabled = useFeatureFlag('editor-context-menu')
|
||||
let spellCheckLanguage = project?.spellCheckLanguage || ''
|
||||
// spell check is off when read-only
|
||||
if (!permissions.write && !permissions.trackedWrite) {
|
||||
@@ -227,7 +225,6 @@ function useCodeMirrorScope(view: EditorView) {
|
||||
}, [view, spellCheckLanguage, hunspellManager])
|
||||
|
||||
const projectFeaturesRef = useRef(projectFeatures)
|
||||
const editorContextMenuEnabledRef = useRef(editorContextMenuEnabled)
|
||||
|
||||
// listen to doc:after-opened, and focus the editor if it's not a new doc
|
||||
useEffect(() => {
|
||||
@@ -355,7 +352,6 @@ function useCodeMirrorScope(view: EditorView) {
|
||||
spelling: spellingRef.current,
|
||||
visual: visualRef.current,
|
||||
projectFeatures: projectFeaturesRef.current,
|
||||
editorContextMenuEnabled: editorContextMenuEnabledRef.current,
|
||||
initialSearchQuery: searchQueryRef.current,
|
||||
showBoundary,
|
||||
handleException,
|
||||
@@ -495,9 +491,7 @@ function useCodeMirrorScope(view: EditorView) {
|
||||
useEffect(() => {
|
||||
settingsRef.current.floatingMenu = floatingMenu
|
||||
window.setTimeout(() => {
|
||||
view.dispatch(
|
||||
setReviewTooltip(floatingMenu, editorContextMenuEnabledRef.current)
|
||||
)
|
||||
view.dispatch(setReviewTooltip(floatingMenu))
|
||||
})
|
||||
}, [view, floatingMenu])
|
||||
|
||||
|
||||
-44
@@ -127,9 +127,6 @@ const grantClipboardPermissions = () => {
|
||||
describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache.set('ol-preventCompileOnLoad', true)
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-context-menu': 'enabled',
|
||||
})
|
||||
cy.intercept('POST', '/project/*/track_changes', {
|
||||
statusCode: 200,
|
||||
body: {},
|
||||
@@ -709,27 +706,6 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('when feature flag is disabled', function () {
|
||||
it('should not show the context menu', function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-context-menu': 'default',
|
||||
})
|
||||
|
||||
const scope = mockScope()
|
||||
|
||||
cy.mount(
|
||||
<TestContainer>
|
||||
<EditorProviders scope={scope}>
|
||||
<CodeMirrorEditor />
|
||||
</EditorProviders>
|
||||
</TestContainer>
|
||||
)
|
||||
|
||||
cy.get('.cm-line').eq(10).rightclick()
|
||||
cy.findByRole('menu').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
describe('when a user does not have edit permissions', function () {
|
||||
it('should only show Copy, Select all, Comment (hidden Cut, Paste, Delete, Suggest edits)', function () {
|
||||
const scope = mockScope()
|
||||
@@ -1107,7 +1083,6 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
|
||||
it('should hide button when visual preview is enabled', function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-context-menu': 'enabled',
|
||||
'visual-preview': 'enabled',
|
||||
})
|
||||
|
||||
@@ -1367,25 +1342,6 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
cy.get('body').type('{esc}')
|
||||
cy.findByRole('menu').should('not.exist')
|
||||
})
|
||||
|
||||
it('should not show context menu on gutter when feature flag is disabled', function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'editor-context-menu': 'default',
|
||||
})
|
||||
|
||||
const scope = mockScope()
|
||||
|
||||
cy.mount(
|
||||
<TestContainer>
|
||||
<EditorProviders scope={scope}>
|
||||
<CodeMirrorEditor />
|
||||
</EditorProviders>
|
||||
</TestContainer>
|
||||
)
|
||||
|
||||
cy.get('.cm-gutterElement').eq(5).rightclick()
|
||||
cy.findByRole('menu').should('not.exist')
|
||||
})
|
||||
})
|
||||
|
||||
describe('when right-clicking inside the open menu', function () {
|
||||
|
||||
Reference in New Issue
Block a user