Adding a core command already registered on another element?


#1

I’m looking to add a core command already in the Command Registry – in this case core:copy – on another element, and use that core command’s behavior instead of defining my own. (So using the system core:copy behavior instead.) How would I go about this? Thanks!


#2

From TextEditor API: editor.copySelectedText().

Also, you can usually find the right method by looking at src/text-editor-element.coffee.


#3

Ah sorry, I wasn’t clear – this isn’t going to be using the TextEditor (it’s a rendered markdown file), so I can’t use the TextEditor API unfortunately.


#4

I may be misunderstanding you, but it should be as easy as emitting the event. The big question is whether that command will work on whatever the other element is.


#5

But this doesn’t work when the command is bound to atom-text-editor, but dispatched from an element that is not (a child of) an atom-text-editor right?


#6

That is the issue – the event is emitting correctly but the element doesn’t know what to do with it.


#7

So … I’m not sure I understand. But if core:copy is designed to work on TextEditors, but you’re proposing to use it on something other than a TextEditor … how is it supposed to work?