   destroy: ->
     @detach()
 
+  resolveEditor: (editorId) ->
+    resolve = =>
+      @editor = @editorForId(editorId)
+
+    if atom.workspace?
+      resolve()
+
+  editorForId: (editorId) ->
+    for editor in atom.workspace.getEditors()
+      return editor if editor.id?.toString() is editorId.toString()
+    null
+
   getTitle: ->
     return 'impressjs-preview'
 

{View} = require 'atom'

module.exports =
class ImpressjsPreviewView extends View
  @content: ->
    @div 'This is a test.'

  @editorId: null

  initialize: (arg) ->
    @editorId = arg.editorId

  # Returns an object that can be retrieved when package is activated
  serialize: ->

    return 'impressjs-preview://editor/' + @editorId

  render: ->
    content = @editor.getText()
    @html(content)

    impress().init()
