MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / init

Method init

lib/web/CodeMirror/src/input/TextareaInput.js:33–111  ·  view source on GitHub ↗
(display)

Source from the content-addressed store, hash-verified

31 }
32
33 init(display) {
34 let input = this, cm = this.cm
35 this.createField(display)
36 const te = this.textarea
37
38 display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild)
39
40 // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
41 if (ios) te.style.width = "0px"
42
43 on(te, "input", () => {
44 if (ie && ie_version >= 9 && this.hasSelection) this.hasSelection = null
45 input.poll()
46 })
47
48 on(te, "paste", e => {
49 if (signalDOMEvent(cm, e) || handlePaste(e, cm)) return
50
51 cm.state.pasteIncoming = +new Date
52 input.fastPoll()
53 })
54
55 function prepareCopyCut(e) {
56 if (signalDOMEvent(cm, e)) return
57 if (cm.somethingSelected()) {
58 setLastCopied({lineWise: false, text: cm.getSelections()})
59 } else if (!cm.options.lineWiseCopyCut) {
60 return
61 } else {
62 let ranges = copyableRanges(cm)
63 setLastCopied({lineWise: true, text: ranges.text})
64 if (e.type == "cut") {
65 cm.setSelections(ranges.ranges, null, sel_dontScroll)
66 } else {
67 input.prevInput = ""
68 te.value = ranges.text.join("\n")
69 selectInput(te)
70 }
71 }
72 if (e.type == "cut") cm.state.cutIncoming = +new Date
73 }
74 on(te, "cut", prepareCopyCut)
75 on(te, "copy", prepareCopyCut)
76
77 on(display.scroller, "paste", e => {
78 if (eventInWidget(display, e) || signalDOMEvent(cm, e)) return
79 if (!te.dispatchEvent) {
80 cm.state.pasteIncoming = +new Date
81 input.focus()
82 return
83 }
84
85 // Pass the `paste` event to the textarea so it's handled by its event listener.
86 const event = new Event("paste")
87 event.clipboardData = e.clipboardData
88 te.dispatchEvent(event)
89 })
90

Callers 4

infer.jsFile · 0.45
DisplayFunction · 0.45
merge.jsFile · 0.45
DisplayFunction · 0.45

Calls 10

createFieldMethod · 0.95
onFunction · 0.90
signalDOMEventFunction · 0.90
handlePasteFunction · 0.90
eventInWidgetFunction · 0.90
e_preventDefaultFunction · 0.90
fastPollMethod · 0.80
pollMethod · 0.45
focusMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected