clipboard.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. if (process.platform === 'linux' && process.type === 'renderer') {
  2. // On Linux we could not access clipboard in renderer process.
  3. module.exports = require('electron').remote.clipboard
  4. } else {
  5. const {deprecate} = require('electron')
  6. const clipboard = process.atomBinding('clipboard')
  7. // TODO(codebytere): remove in 3.0
  8. clipboard.readHtml = function () {
  9. if (!process.noDeprecations) {
  10. deprecate.warn('clipboard.readHtml', 'clipboard.readHTML')
  11. }
  12. return clipboard.readHTML()
  13. }
  14. // TODO(codebytere): remove in 3.0
  15. clipboard.writeHtml = function () {
  16. if (!process.noDeprecations) {
  17. deprecate.warn('clipboard.writeHtml', 'clipboard.writeHTML')
  18. }
  19. return clipboard.writeHTML()
  20. }
  21. // TODO(codebytere): remove in 3.0
  22. clipboard.readRtf = function () {
  23. if (!process.noDeprecations) {
  24. deprecate.warn('clipboard.readRtf', 'clipboard.writeRTF')
  25. }
  26. return clipboard.readRTF()
  27. }
  28. // TODO(codebytere): remove in 3.0
  29. clipboard.writeRtf = function () {
  30. if (!process.noDeprecations) {
  31. deprecate.warn('clipboard.writeRtf', 'clipboard.writeRTF')
  32. }
  33. return clipboard.writeRTF()
  34. }
  35. // Read/write to find pasteboard over IPC since only main process is notified
  36. // of changes
  37. if (process.platform === 'darwin' && process.type === 'renderer') {
  38. clipboard.readFindText = require('electron').remote.clipboard.readFindText
  39. clipboard.writeFindText = require('electron').remote.clipboard.writeFindText
  40. }
  41. module.exports = clipboard
  42. }