mirror of
https://github.com/atom/atom.git
synced 2026-01-26 15:28:27 -05:00
Merge pull request #16526 from atom/wl-rm-safe-clipboard
Directly require clipboard from Electron
This commit is contained in:
@@ -38,7 +38,6 @@ module.exports = function (packagedAppPath) {
|
||||
requiredModuleRelativePath.endsWith(path.join('node_modules', 'request', 'request.js')) ||
|
||||
requiredModuleRelativePath === path.join('..', 'exports', 'atom.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'src', 'electron-shims.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'src', 'safe-clipboard.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'atom-keymap', 'lib', 'command-event.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'babel-core', 'index.js') ||
|
||||
requiredModuleRelativePath === path.join('..', 'node_modules', 'cached-run-in-this-context', 'lib', 'main.js') ||
|
||||
|
||||
@@ -12,7 +12,7 @@ FindParentDir = require 'find-parent-dir'
|
||||
TextEditor = require '../src/text-editor'
|
||||
TextEditorElement = require '../src/text-editor-element'
|
||||
TextMateLanguageMode = require '../src/text-mate-language-mode'
|
||||
clipboard = require '../src/safe-clipboard'
|
||||
{clipboard} = require 'electron'
|
||||
|
||||
jasmineStyle = document.createElement('style')
|
||||
jasmineStyle.textContent = atom.themes.loadStylesheet(atom.themes.resolveStylesheet('../static/jasmine'))
|
||||
|
||||
@@ -11,7 +11,7 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const Grim = require('grim')
|
||||
const electron = require('electron')
|
||||
const clipboard = require('../src/safe-clipboard')
|
||||
const clipboard = electron.clipboard
|
||||
|
||||
const SAMPLE_TEXT = fs.readFileSync(path.join(__dirname, 'fixtures', 'sample.js'), 'utf8')
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ const fs = require('fs')
|
||||
const path = require('path')
|
||||
const temp = require('temp').track()
|
||||
const dedent = require('dedent')
|
||||
const clipboard = require('../src/safe-clipboard')
|
||||
const {clipboard} = require('electron')
|
||||
const TextEditor = require('../src/text-editor')
|
||||
const TextBuffer = require('text-buffer')
|
||||
const TextMateLanguageMode = require('../src/text-mate-language-mode')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const crypto = require('crypto')
|
||||
const clipboard = require('./safe-clipboard')
|
||||
const {clipboard} = require('electron')
|
||||
|
||||
// Extended: Represents the clipboard used for copying and pasting in Atom.
|
||||
//
|
||||
@@ -7,10 +7,10 @@ const clipboard = require('./safe-clipboard')
|
||||
//
|
||||
// ## Examples
|
||||
//
|
||||
// ```coffee
|
||||
// ```js
|
||||
// atom.clipboard.write('hello')
|
||||
//
|
||||
// console.log(atom.clipboard.read()) # 'hello'
|
||||
// console.log(atom.clipboard.read()) // 'hello'
|
||||
// ```
|
||||
module.exports =
|
||||
class Clipboard {
|
||||
@@ -59,7 +59,7 @@ class Clipboard {
|
||||
// * `text` The {String} clipboard text.
|
||||
// * `metadata` The metadata stored by an earlier call to {::write}.
|
||||
readWithMetadata () {
|
||||
let text = this.read()
|
||||
const text = this.read()
|
||||
if (this.signatureForMetadata === this.md5(text)) {
|
||||
return {text, metadata: this.metadata}
|
||||
} else {
|
||||
|
||||
@@ -7,7 +7,7 @@ const Config = require('../config')
|
||||
const ConfigFile = require('../config-file')
|
||||
const FileRecoveryService = require('./file-recovery-service')
|
||||
const ipcHelpers = require('../ipc-helpers')
|
||||
const {BrowserWindow, Menu, app, dialog, ipcMain, shell, screen} = require('electron')
|
||||
const {BrowserWindow, Menu, app, clipboard, dialog, ipcMain, shell, screen} = require('electron')
|
||||
const {CompositeDisposable, Disposable} = require('event-kit')
|
||||
const crypto = require('crypto')
|
||||
const fs = require('fs-plus')
|
||||
@@ -583,7 +583,6 @@ class AtomApplication extends EventEmitter {
|
||||
win.temporaryState = state
|
||||
}))
|
||||
|
||||
const clipboard = require('../safe-clipboard')
|
||||
this.disposable.add(ipcHelpers.on(ipcMain, 'write-text-to-selection-clipboard', (event, text) =>
|
||||
clipboard.writeText(text, 'selection')
|
||||
))
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# Using clipboard in renderer process is not safe on Linux.
|
||||
module.exports =
|
||||
if process.platform is 'linux' and process.type is 'renderer'
|
||||
require('electron').remote.clipboard
|
||||
else
|
||||
require('electron').clipboard
|
||||
@@ -5,8 +5,8 @@ const {Point, Range} = require('text-buffer')
|
||||
const LineTopIndex = require('line-top-index')
|
||||
const TextEditor = require('./text-editor')
|
||||
const {isPairedCharacter} = require('./text-utils')
|
||||
const clipboard = require('./safe-clipboard')
|
||||
const electron = require('electron')
|
||||
const clipboard = electron.clipboard
|
||||
const $ = etch.dom
|
||||
|
||||
let TextEditorElement
|
||||
|
||||
Reference in New Issue
Block a user