MCPcopy
hub / github.com/basecamp/trix / paste

Method paste

src/trix/controllers/level_2_input_controller.js:39–71  ·  view source on GitHub ↗
(event)

Source from the content-addressed store, hash-verified

37 // Handle paste event to work around beforeinput.insertFromPaste browser bugs.
38 // Safe to remove each condition once fixed upstream.
39 paste(event) {
40 // https://bugs.webkit.org/show_bug.cgi?id=194921
41 let paste
42 const href = event.clipboardData?.getData("URL")
43 if (pasteEventHasFilesOnly(event)) {
44 event.preventDefault()
45 return this.attachFiles(event.clipboardData.files)
46
47 // https://bugs.chromium.org/p/chromium/issues/detail?id=934448
48 } else if (pasteEventHasPlainTextOnly(event)) {
49 event.preventDefault()
50 paste = {
51 type: "text/plain",
52 string: event.clipboardData.getData("text/plain"),
53 }
54 this.delegate?.inputControllerWillPaste(paste)
55 this.responder?.insertString(paste.string)
56 this.render()
57 return this.delegate?.inputControllerDidPaste(paste)
58
59 // https://bugs.webkit.org/show_bug.cgi?id=196702
60 } else if (href) {
61 event.preventDefault()
62 paste = {
63 type: "text/html",
64 html: this.createLinkHTML(href),
65 }
66 this.delegate?.inputControllerWillPaste(paste)
67 this.responder?.insertHTML(paste.html)
68 this.render()
69 return this.delegate?.inputControllerDidPaste(paste)
70 }
71 },
72
73 beforeinput(event) {
74 const handler = this.constructor.inputTypes[event.inputType]

Callers

nothing calls this directly

Calls 10

renderMethod · 0.95
pasteEventHasFilesOnlyFunction · 0.85
getDataMethod · 0.45
attachFilesMethod · 0.45
insertStringMethod · 0.45
createLinkHTMLMethod · 0.45
insertHTMLMethod · 0.45

Tested by

no test coverage detected