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

Method getPatternsConfig

src/components/modules/paste.ts:438–462  ·  view source on GitHub ↗

* Get RegExp patterns to substitute by Tool * * @param tool - BlockTool object

(tool: BlockToolAdapter)

Source from the content-addressed store, hash-verified

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

Callers 1

PasteClass · 0.95

Calls 4

forEachMethod · 0.80
entriesMethod · 0.80
isEmptyMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected