All files / src/parsers embed.ts

75% Statements 6/8
75% Branches 3/4
100% Functions 1/1
75% Lines 6/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19    1x 2x   2x 1x     1x 1x                
import { OutputBlockData } from "@editorjs/editorjs";
 
export const embed = ({ data }: OutputBlockData): string => {
  const provider = data.service;
 
  if (provider === "vimeo") {
    return `<iframe src="${data.embed}" height="${data.height}" frameborder="0" allow="autoplay; fullscreen; picture-in-picture" allowfullscreen></iframe>`;
  }
 
  Eif (provider === "youtube") {
    return `<iframe width="${data.width}" height="${data.height}" src="${data.embed}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>`;
  }
 
  console.error(
    "[editorjs-html]: Only Youtube & Vimeo embeds are available by default. Write your own embed parser for other options."
  );
  return "";
};