orderthings.js 736 B

12345678910111213141516171819202122232425262728293031
  1. 'use babel';
  2. import { CompositeDisposable } from 'atom';
  3. export default {
  4. subscriptions: null,
  5. activate() {
  6. // Events subscribed to in atom's system can be easily cleaned up with a CompositeDisposable
  7. this.subscriptions = new CompositeDisposable();
  8. // Register command that toggles this view
  9. this.subscriptions.add(atom.commands.add('atom-workspace', {
  10. 'orderthings:fetch': () => this.fetch()
  11. }));
  12. },
  13. deactivate() {
  14. this.subscriptions.dispose();
  15. },
  16. fetch() {
  17. let editor;
  18. if (editor = atom.workspace.getActiveTextEditor()) {
  19. let selection = editor.getSelectedText();
  20. selection = selection.split('').reverse().join('');
  21. editor.insertText(selection);
  22. }
  23. }
  24. };