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

Function pasteContent

src/test/test_helpers/input_helpers.js:40–67  ·  view source on GitHub ↗
(contentType, value)

Source from the content-addressed store, hash-verified

38}
39
40export const pasteContent = async (contentType, value) => {
41 let data
42
43 if (typeof contentType === "object") {
44 data = contentType
45 } else {
46 data = { [contentType]: value }
47 }
48
49 const testClipboardData = {
50 getData: (type) => data[type],
51 types: Object.keys(data),
52 items: Object.values(data),
53 }
54
55 if (testClipboardData.types.includes("Files")) {
56 testClipboardData.files = testClipboardData.items
57 }
58
59 triggerInputEvent(document.activeElement, "beforeinput", {
60 inputType: "insertFromPaste",
61 dataTransfer: testClipboardData,
62 })
63
64 triggerEvent(document.activeElement, "paste", { testClipboardData })
65
66 await nextFrame()
67}
68
69export const createFile = function (properties = {}) {
70 const file = {

Callers 2

pasting_test.jsFile · 0.90

Calls 3

triggerEventFunction · 0.90
nextFrameFunction · 0.90
triggerInputEventFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…