Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 39551
1
###
2
An internal copy/paste buffer
3
4
MOTIVATION: There is no way to sync with the official operating system copy/paste buffer,
5
due to security restrictions. However, for some platforms (iPad, I'm looking at you!),
6
it's still very useful to have our own internal copy/paste buffer. This is it.
7
It stores a string right now. Who knows, maybe someboday it'll do interesting
8
richer content too.
9
###
10
11
buffer = ''
12
13
exports.get_buffer = ->
14
return buffer
15
16
exports.set_buffer = (s) ->
17
buffer = s ? ''
18
try
19
# https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand
20
# NOTE: there is probably no context in CoCalc where thi will actually work...
21
document.execCommand('copy')
22
return
23
24