* Get RegExp patterns to substitute by Tool * * @param tool - BlockTool object
(tool: BlockToolAdapter)
| 436 | * @param tool - BlockTool object |
| 437 | */ |
| 438 | private getPatternsConfig(tool: BlockToolAdapter): void { |
| 439 | if ( |
| 440 | tool.pasteConfig === false || |
| 441 | !tool.pasteConfig.patterns || |
| 442 | _.isEmpty(tool.pasteConfig.patterns) |
| 443 | ) { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | Object.entries(tool.pasteConfig.patterns).forEach(([key, pattern]: [string, RegExp]) => { |
| 448 | /** Still need to validate pattern as it provided by user */ |
| 449 | if (!(pattern instanceof RegExp)) { |
| 450 | _.log( |
| 451 | `Pattern ${pattern} for «${tool.name}» Tool is skipped because it should be a Regexp instance.`, |
| 452 | 'warn' |
| 453 | ); |
| 454 | } |
| 455 | |
| 456 | this.toolsPatterns.push({ |
| 457 | key, |
| 458 | pattern, |
| 459 | tool, |
| 460 | }); |
| 461 | }); |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Check if browser behavior suits better |