Create Blank Pane


#1

Hello, there!

I am creating a package for specialized drawing inside the editor and need to create a Pane for the drawing to take place. I tried a Panel, but they don’t seem to support horizontal resizing.
So far I could only “create a Pane” by calling atom.workspace.open, what made me assume Panes are necessarily TextEditors.

Then my question: is there a way to create Blank Panes for me to insert any HTML and keep the ability to scroll horizontally?

Relevant code, so far:

atom.workspace.open(editor.getPath(), {
  split: 'right'
}).then(function(editor){
  // Destroy the editor stuff making the Pane empty.
  // Apply my view to the Pane.
  // Celebrate Victory!
});

Thanks in advance.


#2

If you take a look at the documentation for atom.workspace.open, it specifically states “or no registered opener can open the URI” then it resorts to opening a blank TextEditor. You can find out more about registering an opener for a URI under the documentation for atom.workspace.addOpener. This is also a technique employed by the markdown-preview package.


#3

Helped very much, thanks!

In a related matter, I couldn’t find a straightforward way for getting the Pane which contains a given TextEditor, any suggestions?


#4

If you look at the Extended methods in the Panes section of the Workspace class, you’ll find the paneForURI function.


#5

I did already try it but with no positive results. On the following block:

atom.workspace.open(p, {split: 'right'}).then(function(){
  console.log(p);
  console.log(atom.workspace.paneForURI(p));
});

The p contains a valid (now open) path. The third line logs undefined.


#6

I’m not sure that the promise returned by atom.workspace.open does everything you’re expecting it to by the code snippet you’re showing. The URI might be open … but that doesn’t mean that the pane is instantiated and everything is in place visually.