Merge pull request #34152 from overleaf/mj-select-all
[web] Add select all to context menu GitOrigin-RevId: ff5fb828db8e1cd57d1361a2e572918339e5e18b
This commit is contained in:
committed by
Copybot
parent
fda0283490
commit
24dba36060
@@ -32,6 +32,7 @@ import {
|
||||
ContextMenuItemSegmentation,
|
||||
} from '../utils/context-menu-analytics'
|
||||
import { isCursorOnEmptyLine } from '../utils/is-cursor-on-empty-line'
|
||||
import { selectAll } from '@codemirror/commands'
|
||||
|
||||
export const useContextMenuItems = () => {
|
||||
const view = useCodeMirrorViewContext()
|
||||
@@ -144,6 +145,9 @@ export const useContextMenuItems = () => {
|
||||
return result
|
||||
}
|
||||
)
|
||||
const handleSelectAll = wrapForContextMenu('select-all', () =>
|
||||
selectAll(view)
|
||||
)
|
||||
const handleDelete = wrapForContextMenu('delete', () =>
|
||||
commands.deleteSelection(view)
|
||||
)
|
||||
@@ -223,6 +227,13 @@ export const useContextMenuItems = () => {
|
||||
show: canEdit,
|
||||
shortcut: inVisualMode ? getShortcut('paste-special') : undefined,
|
||||
},
|
||||
{
|
||||
label: t('select_all'),
|
||||
handler: handleSelectAll,
|
||||
disabled: false,
|
||||
show: true,
|
||||
shortcut: getShortcut('select-all'),
|
||||
},
|
||||
{
|
||||
label: t('delete'),
|
||||
handler: handleDelete,
|
||||
|
||||
@@ -6,6 +6,7 @@ export type ContextMenuItemSegmentation =
|
||||
| 'paste'
|
||||
| 'paste-without-formatting'
|
||||
| 'paste-with-formatting'
|
||||
| 'select-all'
|
||||
| 'give-feedback'
|
||||
| 'delete'
|
||||
| 'jump-to-location-in-pdf'
|
||||
|
||||
+2
-1
@@ -663,7 +663,7 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
})
|
||||
|
||||
describe('when a user does not have edit permissions', function () {
|
||||
it('should only show Copy and Comment (hidden Cut, Paste, Delete, Suggest edits)', function () {
|
||||
it('should only show Copy, Select all, Comment (hidden Cut, Paste, Delete, Suggest edits)', function () {
|
||||
const scope = mockScope()
|
||||
scope.permissions.write = false
|
||||
scope.permissions.trackedWrite = false
|
||||
@@ -701,6 +701,7 @@ describe('editor context menu', { scrollBehavior: false }, function () {
|
||||
cy.findByRole('menu').within(() => {
|
||||
cy.findByRole('menuitem', { name: /cut/i }).should('not.exist')
|
||||
cy.findByRole('menuitem', { name: /copy/i }).should('be.enabled')
|
||||
cy.findByRole('menuitem', { name: /select all/i }).should('be.enabled')
|
||||
cy.findByRole('menuitem', { name: pasteLabelMatcher }).should(
|
||||
'not.exist'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user