Skip to content

Commit

Permalink
fixup! fixup! feat: Compare files side by side
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusknorr committed Aug 3, 2023
1 parent 220e73d commit 09745a2
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion src/services/Viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ import Images from '../models/images.js'
import Videos from '../models/videos.js'
import Audios from '../models/audios.js'

/**
* Handler type definition
*
* @typedef {object} Handler
* @property {string} id unique identifier for the handler
* @property {string[]} mimes list of mime types that are supported for opening
* @property {object} component Vue component to render the file
* @property {string} group group identifier to combine for navigating to the next/previous files
* @property {?string} theme viewer modal theme (one of 'dark', 'light', 'default')
* @property {boolean} sourceSupport Indicate support for opening a source URL,
* used for version preview and opening files from other sources (e.g. mail attachments)
*/

/**
* File info type definition
*
Expand All @@ -41,9 +54,11 @@ export default class Viewer {

_state
_mimetypes
_mimetypesSource

constructor() {
this._mimetypes = []
this._mimetypesSource = []
this._state = {}
this._state.file = ''
this._state.fileInfo = null
Expand Down Expand Up @@ -72,6 +87,7 @@ export default class Viewer {
*
* @readonly
* @memberof Viewer
* @return {Handler[]}
*/
get availableHandlers() {
return this._state.handlers
Expand All @@ -81,11 +97,14 @@ export default class Viewer {
* Register a new handler
*
* @memberof Viewer
* @param {object} handler a new unregistered handler
* @param {Handler} handler a new unregistered handler
*/
registerHandler(handler) {
this._state.handlers.push(handler)
this._mimetypes.push.apply(this._mimetypes, handler.mimes)
if (handler?.sourceSupport === true) {
this._mimetypesSource.push.apply(this._mimetypesSource, handler.mimes)
}
}

/**
Expand Down Expand Up @@ -158,6 +177,16 @@ export default class Viewer {
return this._mimetypes
}

/**
* Get the supported mimetypes that can be opened with the viewer from a source URL
*
* @memberof Viewer
* @return {Array} list of mimetype strings that the viewer can open from a source URL
*/
get mimetypesSource() {
return this._mimetypesSource
}

/**
* Return the method provided to fetch more results
*
Expand Down Expand Up @@ -302,6 +331,13 @@ export default class Viewer {
this.open(options)
}

/**
* Open the viewer with two files side by side
*
* @memberof Viewer
* @param {Fileinfo} fileInfo current file
* @param {Fileinfo} compareFileInfo older file to compare
*/
compare(fileInfo, compareFileInfo) {
this.open({
fileInfo,
Expand Down

0 comments on commit 09745a2

Please sign in to comment.