diff --git a/src/app/image-edit-session.coffee b/src/app/image-edit-session.coffee index a38b7294b..dd470fd85 100644 --- a/src/app/image-edit-session.coffee +++ b/src/app/image-edit-session.coffee @@ -8,8 +8,16 @@ module.exports= class ImageEditSession registerDeserializer(this) + # Files with these extensions will be opened as images + @imageExtensions: ['.gif', '.jpeg', '.jpg', '.png'] + ### Internal ### + Project = require 'project' + Project.registerOpener (path) => + new ImageEditSession(path) if _.include(@imageExtensions, fsUtils.extension(path)) + + @deserialize: (state) -> if fsUtils.exists(state.path) project.open(state.path) @@ -27,19 +35,6 @@ class ImageEditSession ### Public ### - # Identifies if a path can be opened by the image viewer. - # - # path - The {String} name of the path to check - # - # Returns a {Boolean}. - @canOpen: (path) -> - _.indexOf([ - '.gif' - '.jpeg' - '.jpg' - '.png' - ], fsUtils.extension(path), true) >= 0 - # Retrieves the filename of the open file. # # This is `'untitled'` if the file is new and not saved to the disk. diff --git a/src/app/project.coffee b/src/app/project.coffee index 0fb7a9203..5dd65681a 100644 --- a/src/app/project.coffee +++ b/src/app/project.coffee @@ -4,7 +4,6 @@ $ = require 'jquery' Range = require 'range' Buffer = require 'text-buffer' EditSession = require 'edit-session' -ImageEditSession = require 'image-edit-session' EventEmitter = require 'event-emitter' Directory = require 'directory' BufferedProcess = require 'buffered-process' @@ -160,10 +159,7 @@ class Project for opener in @constructor.openers return resource if resource = opener(filePath, options) - if ImageEditSession.canOpen(filePath) - new ImageEditSession(filePath) - else - @buildEditSessionForBuffer(@bufferForPath(filePath), options) + @buildEditSessionForBuffer(@bufferForPath(filePath), options) # Retrieves all the {EditSession}s in the project; that is, the `EditSession`s for all open files. # @@ -311,3 +307,5 @@ class Project @on 'buffer-created', (buffer) -> callback(buffer) _.extend Project.prototype, EventEmitter + +require 'image-edit-session'