mirror of
https://github.com/ONLYOFFICE/document-server-integration.git
synced 2026-02-10 18:05:10 +08:00
refactor: create and use new method for finding formats by extension
This commit is contained in:
@ -20,27 +20,25 @@ class FormatManager {
|
||||
formats = [];
|
||||
|
||||
constructor(formats) {
|
||||
if (Array.isArray(formats)) this.formats = formats;
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -20,27 +20,25 @@ class FormatManager {
|
||||
formats = [];
|
||||
|
||||
constructor(formats) {
|
||||
if (Array.isArray(formats)) this.formats = formats;
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,24 +23,22 @@ class FormatManager {
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
@ -23,24 +23,22 @@ class FormatManager {
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
@ -23,24 +23,22 @@ class FormatManager {
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
@ -23,24 +23,22 @@ class FormatManager {
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
@ -23,24 +23,22 @@ class FormatManager {
|
||||
if(Array.isArray(formats)) this.formats = formats;
|
||||
}
|
||||
|
||||
findByExtension(extension) {
|
||||
return this.formats.find(format => format.name == extension);
|
||||
}
|
||||
|
||||
isAutoConvertible(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isAutoConvertible();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isAutoConvertible();
|
||||
}
|
||||
|
||||
isEditable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isEditable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isEditable();
|
||||
}
|
||||
|
||||
isFillable(extension) {
|
||||
let index = this.formats.findIndex(format => {
|
||||
return format.name == extension && format.isFillable();
|
||||
})
|
||||
return index !== -1;
|
||||
let format = this.findByExtension(extension);
|
||||
return format !== undefined && format.isFillable();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user