mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #30495 from overleaf/mg-context-menu-paste
[web] Support paste with formatting in context menu GitOrigin-RevId: 551ed1d49ca423395bd9bfc756e10e8d59d71ecd
This commit is contained in:
@@ -20,7 +20,9 @@ import {
|
||||
cutSelection,
|
||||
copySelection,
|
||||
pasteWithoutFormatting,
|
||||
pasteWithFormatting,
|
||||
} from '../commands/clipboard'
|
||||
import { isVisual } from '../extensions/visual/visual'
|
||||
|
||||
export const useContextMenuItems = () => {
|
||||
const view = useCodeMirrorViewContext()
|
||||
@@ -68,9 +70,16 @@ export const useContextMenuItems = () => {
|
||||
[view, closeMenu]
|
||||
)
|
||||
|
||||
const inVisualMode = isVisual(view)
|
||||
|
||||
const handleCut = wrapForContextMenu(() => cutSelection(view))
|
||||
const handleCopy = wrapForContextMenu(() => copySelection(view))
|
||||
const handlePaste = wrapForContextMenu(() => pasteWithoutFormatting(view))
|
||||
const handlePaste = wrapForContextMenu(() =>
|
||||
inVisualMode ? pasteWithFormatting(view) : pasteWithoutFormatting(view)
|
||||
)
|
||||
const handlePasteSpecial = wrapForContextMenu(() =>
|
||||
inVisualMode ? pasteWithoutFormatting(view) : pasteWithFormatting(view)
|
||||
)
|
||||
const handleDelete = wrapForContextMenu(() => commands.deleteSelection(view))
|
||||
|
||||
const handleToggleTrackChanges = wrapForContextMenu(() => {
|
||||
@@ -120,6 +129,15 @@ export const useContextMenuItems = () => {
|
||||
show: canEdit,
|
||||
shortcut: getShortcut('paste'),
|
||||
},
|
||||
{
|
||||
label: inVisualMode
|
||||
? t('paste_without_formatting')
|
||||
: t('paste_with_formatting'),
|
||||
handler: handlePasteSpecial,
|
||||
disabled: false,
|
||||
show: canEdit,
|
||||
shortcut: inVisualMode ? getShortcut('paste-special') : undefined,
|
||||
},
|
||||
{
|
||||
label: t('delete'),
|
||||
handler: handleDelete,
|
||||
|
||||
Reference in New Issue
Block a user