MCPcopy
hub / github.com/codex-team/editor.js / getFilesConfig

Method getFilesConfig

src/components/modules/paste.ts:393–431  ·  view source on GitHub ↗

* Get files` types and extensions to substitute by Tool * * @param tool - BlockTool object

(tool: BlockToolAdapter)

Source from the content-addressed store, hash-verified

391 * @param tool - BlockTool object
392 */
393 private getFilesConfig(tool: BlockToolAdapter): void {
394 if (tool.pasteConfig === false) {
395 return;
396 }
397
398 const { files = {} } = tool.pasteConfig;
399 let { extensions, mimeTypes } = files;
400
401 if (!extensions && !mimeTypes) {
402 return;
403 }
404
405 if (extensions && !Array.isArray(extensions)) {
406 _.log(`«extensions» property of the onDrop config for «${tool.name}» Tool should be an array`);
407 extensions = [];
408 }
409
410 if (mimeTypes && !Array.isArray(mimeTypes)) {
411 _.log(`«mimeTypes» property of the onDrop config for «${tool.name}» Tool should be an array`);
412 mimeTypes = [];
413 }
414
415 if (mimeTypes) {
416 mimeTypes = mimeTypes.filter((type) => {
417 if (!_.isValidMimeType(type)) {
418 _.log(`MIME type value «${typefor the «${tool.name}» Tool is not a valid MIME type`, 'warn');
419
420 return false;
421 }
422
423 return true;
424 });
425 }
426
427 this.toolsFiles[tool.name] = {
428 extensions: extensions || [],
429 mimeTypes: mimeTypes || [],
430 };
431 }
432
433 /**
434 * Get RegExp patterns to substitute by Tool

Callers 1

PasteClass · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected