* Get information about file and find Tool to handle it * * @param {File} file - file to process
(file: File)
| 537 | * @param {File} file - file to process |
| 538 | */ |
| 539 | private async processFile(file: File): Promise<{ event: PasteEvent; type: string }> { |
| 540 | const extension = _.getFileExtension(file); |
| 541 | |
| 542 | const foundConfig = Object |
| 543 | .entries(this.toolsFiles) |
| 544 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars |
| 545 | .find(([toolName, { mimeTypes, extensions } ]) => { |
| 546 | const [fileType, fileSubtype] = file.type.split('/'); |
| 547 | |
| 548 | const foundExt = extensions.find((ext) => ext.toLowerCase() === extension.toLowerCase()); |
| 549 | const foundMimeType = mimeTypes.find((mime) => { |
| 550 | const [type, subtype] = mime.split('/'); |
| 551 | |
| 552 | return type === fileType && (subtype === fileSubtype || subtype === '*'); |
| 553 | }); |
| 554 | |
| 555 | return !!foundExt || !!foundMimeType; |
| 556 | }); |
| 557 | |
| 558 | if (!foundConfig) { |
| 559 | return; |
| 560 | } |
| 561 | |
| 562 | const [ tool ] = foundConfig; |
| 563 | const pasteEvent = this.composePasteEvent('file', { |
| 564 | file, |
| 565 | }); |
| 566 | |
| 567 | return { |
| 568 | event: pasteEvent, |
| 569 | type: tool, |
| 570 | }; |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * Split HTML string to blocks and return it as array of Block data |
no test coverage detected