MCPcopy
hub / github.com/antonmedv/codejar / handlePaste

Function handlePaste

codejar.ts:449–462  ·  view source on GitHub ↗
(event: ClipboardEvent)

Source from the content-addressed store, hash-verified

447 }
448
449 function handlePaste(event: ClipboardEvent) {
450 if (event.defaultPrevented) return
451 preventDefault(event)
452 const originalEvent = (event as any).originalEvent ?? event
453 const text = originalEvent.clipboardData.getData('text/plain').replace(/\r\n?/g, '\n')
454 const pos = save()
455 insert(text)
456 doHighlight(editor)
457 restore({
458 start: Math.min(pos.start, pos.end) + text.length,
459 end: Math.min(pos.start, pos.end) + text.length,
460 dir: '<-',
461 })
462 }
463
464 function handleCut(event: ClipboardEvent) {
465 const pos = save()

Callers 1

CodeJarFunction · 0.85

Calls 5

preventDefaultFunction · 0.85
saveFunction · 0.85
insertFunction · 0.85
doHighlightFunction · 0.85
restoreFunction · 0.85

Tested by

no test coverage detected