You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-16 00:14:34 +02:00
Chore: clean up
This commit is contained in:
@ -27,19 +27,19 @@ export default class InteropService {
|
||||
return this.instance_;
|
||||
}
|
||||
|
||||
constructor() {
|
||||
public constructor() {
|
||||
this.eventEmitter_ = new EventEmitter();
|
||||
}
|
||||
|
||||
on(eventName: string, callback: Function) {
|
||||
public on(eventName: string, callback: Function) {
|
||||
return this.eventEmitter_.on(eventName, callback);
|
||||
}
|
||||
|
||||
off(eventName: string, callback: Function) {
|
||||
public off(eventName: string, callback: Function) {
|
||||
return this.eventEmitter_.removeListener(eventName, callback);
|
||||
}
|
||||
|
||||
modules() {
|
||||
public modules() {
|
||||
if (!this.defaultModules_) {
|
||||
const importModules: Module[] = [
|
||||
{
|
||||
@ -156,7 +156,7 @@ export default class InteropService {
|
||||
// or exporters, such as ENEX. In this case, the one marked as "isDefault"
|
||||
// is returned. This is useful to auto-detect the module based on the format.
|
||||
// For more precise matching, newModuleFromPath_ should be used.
|
||||
findModuleByFormat_(type: ModuleType, format: string, target: FileSystemItem = null, outputFormat: ImportModuleOutputFormat = null) {
|
||||
private findModuleByFormat_(type: ModuleType, format: string, target: FileSystemItem = null, outputFormat: ImportModuleOutputFormat = null) {
|
||||
const modules = this.modules();
|
||||
const matches = [];
|
||||
for (let i = 0; i < modules.length; i++) {
|
||||
@ -203,7 +203,7 @@ export default class InteropService {
|
||||
* https://github.com/laurent22/joplin/pull/1795#discussion_r322379121) but
|
||||
* we can do it if it ever becomes necessary.
|
||||
*/
|
||||
newModuleByFormat_(type: ModuleType, format: string, outputFormat: ImportModuleOutputFormat = ImportModuleOutputFormat.Markdown) {
|
||||
private newModuleByFormat_(type: ModuleType, format: string, outputFormat: ImportModuleOutputFormat = ImportModuleOutputFormat.Markdown) {
|
||||
const moduleMetadata = this.findModuleByFormat_(type, format, null, outputFormat);
|
||||
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and output "%s"', type, format, outputFormat));
|
||||
|
||||
@ -229,7 +229,7 @@ export default class InteropService {
|
||||
*
|
||||
* https://github.com/laurent22/joplin/pull/1795#pullrequestreview-281574417
|
||||
*/
|
||||
newModuleFromPath_(type: ModuleType, options: any) {
|
||||
private newModuleFromPath_(type: ModuleType, options: any) {
|
||||
const moduleMetadata = this.findModuleByFormat_(type, options.format, options.target);
|
||||
if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and target "%s"', type, options.format, options.target));
|
||||
|
||||
@ -246,32 +246,9 @@ export default class InteropService {
|
||||
output.setMetadata({ options, ...moduleMetadata });
|
||||
|
||||
return output;
|
||||
|
||||
// let modulePath = options && options.modulePath ? options.modulePath : '';
|
||||
|
||||
// if (!modulePath) {
|
||||
// const moduleMetadata = this.findModuleByFormat_(type, options.format, options.target);
|
||||
// if (!moduleMetadata) throw new Error(_('Cannot load "%s" module for format "%s" and target "%s"', type, options.format, options.target));
|
||||
// modulePath = this.modulePath(moduleMetadata);
|
||||
// }
|
||||
|
||||
// const moduleMetadata = this.findModuleByFormat_(type, options.format, options.target);
|
||||
|
||||
// let output = null;
|
||||
|
||||
// if (moduleMetadata.isCustom) {
|
||||
// output = this.newModuleFromCustomFactory(moduleMetadata);
|
||||
// } else {
|
||||
// const ModuleClass = shim.requireDynamic(modulePath).default;
|
||||
// output = new ModuleClass();
|
||||
// }
|
||||
|
||||
// output.setMetadata({ options, ...moduleMetadata });
|
||||
|
||||
// return output;
|
||||
}
|
||||
|
||||
moduleByFileExtension_(type: ModuleType, ext: string) {
|
||||
private moduleByFileExtension_(type: ModuleType, ext: string) {
|
||||
ext = ext.toLowerCase();
|
||||
|
||||
const modules = this.modules();
|
||||
|
Reference in New Issue
Block a user