import * as React from "react"; import styled from "styled-components"; import { EmbedDescriptor } from "@shared/editor/types"; import Image from "../components/Image"; import Abstract from "./Abstract"; import Airtable from "./Airtable"; import Berrycast from "./Berrycast"; import Bilibili from "./Bilibili"; import Cawemo from "./Cawemo"; import ClickUp from "./ClickUp"; import Codepen from "./Codepen"; import DBDiagram from "./DBDiagram"; import Descript from "./Descript"; import Diagrams from "./Diagrams"; import Figma from "./Figma"; import Framer from "./Framer"; import Gist from "./Gist"; import GoogleCalendar from "./GoogleCalendar"; import GoogleDataStudio from "./GoogleDataStudio"; import GoogleDocs from "./GoogleDocs"; import GoogleDrawings from "./GoogleDrawings"; import GoogleDrive from "./GoogleDrive"; import GoogleSheets from "./GoogleSheets"; import GoogleSlides from "./GoogleSlides"; import InVision from "./InVision"; import Loom from "./Loom"; import Lucidchart from "./Lucidchart"; import Marvel from "./Marvel"; import Mindmeister from "./Mindmeister"; import Miro from "./Miro"; import ModeAnalytics from "./ModeAnalytics"; import Pitch from "./Pitch"; import Prezi from "./Prezi"; import Spotify from "./Spotify"; import Trello from "./Trello"; import Typeform from "./Typeform"; import Vimeo from "./Vimeo"; import Whimsical from "./Whimsical"; import YouTube from "./YouTube"; export type EmbedProps = { isSelected: boolean; isEditable: boolean; embed: EmbedDescriptor; attrs: { href: string; matches: RegExpMatchArray; }; }; function matcher(Component: React.ComponentType) { return (url: string): boolean | [] | RegExpMatchArray => { // @ts-expect-error not aware of static const regexes = Component.ENABLED; for (const regex of regexes) { const result = url.match(regex); if (result) { return result; } } return false; }; } const Img = styled(Image)` margin: 4px; width: 18px; height: 18px; `; const embeds: EmbedDescriptor[] = [ { title: "Abstract", keywords: "design", defaultHidden: true, icon: () => Abstract, component: Abstract, matcher: matcher(Abstract), }, { title: "Airtable", keywords: "spreadsheet", icon: () => Airtable, component: Airtable, matcher: matcher(Airtable), }, { title: "Berrycast", keywords: "video", defaultHidden: true, icon: () => Berrycast, component: Berrycast, matcher: matcher(Berrycast), }, { title: "Bilibili", keywords: "video", defaultHidden: true, icon: () => Bilibili, component: Bilibili, matcher: matcher(Bilibili), }, { title: "Cawemo", keywords: "bpmn process", defaultHidden: true, icon: () => Cawemo, component: Cawemo, matcher: matcher(Cawemo), }, { title: "ClickUp", keywords: "project", icon: () => ClickUp, component: ClickUp, matcher: matcher(ClickUp), }, { title: "Codepen", keywords: "code editor", icon: () => Codepen, component: Codepen, matcher: matcher(Codepen), }, { title: "DBDiagram", keywords: "diagrams database", icon: () => DBDiagram, component: DBDiagram, matcher: matcher(DBDiagram), }, { title: "Descript", keywords: "audio", icon: () => Descript, component: Descript, matcher: matcher(Descript), }, { title: "Figma", keywords: "design svg vector", icon: () => Figma, component: Figma, matcher: matcher(Figma), }, { title: "Framer", keywords: "design prototyping", icon: () => Framer, component: Framer, matcher: matcher(Framer), }, { title: "GitHub Gist", keywords: "code", icon: () => GitHub, component: Gist, matcher: matcher(Gist), }, { title: "Diagrams.net", keywords: "diagrams drawio", icon: () => Diagrams.net, component: Diagrams, matcher: matcher(Diagrams), }, { title: "Google Drawings", keywords: "drawings", icon: () => Google Drawings, component: GoogleDrawings, matcher: matcher(GoogleDrawings), }, { title: "Google Drive", keywords: "drive", icon: () => Google Drive, component: GoogleDrive, matcher: matcher(GoogleDrive), }, { title: "Google Docs", keywords: "documents word", icon: () => Google Docs, component: GoogleDocs, matcher: matcher(GoogleDocs), }, { title: "Google Sheets", keywords: "excel spreadsheet", icon: () => Google Sheets, component: GoogleSheets, matcher: matcher(GoogleSheets), }, { title: "Google Slides", keywords: "presentation slideshow", icon: () => Google Slides, component: GoogleSlides, matcher: matcher(GoogleSlides), }, { title: "Google Calendar", keywords: "calendar", icon: () => Google Calendar, component: GoogleCalendar, matcher: matcher(GoogleCalendar), }, { title: "Google Data Studio", keywords: "bi business intelligence", icon: () => ( Google Data Studio ), component: GoogleDataStudio, matcher: matcher(GoogleDataStudio), }, { title: "InVision", keywords: "design prototype", defaultHidden: true, icon: () => InVision, component: InVision, matcher: matcher(InVision), }, { title: "Loom", keywords: "video screencast", icon: () => Loom, component: Loom, matcher: matcher(Loom), }, { title: "Lucidchart", keywords: "chart", icon: () => Lucidchart, component: Lucidchart, matcher: matcher(Lucidchart), }, { title: "Marvel", keywords: "design prototype", icon: () => Marvel, component: Marvel, matcher: matcher(Marvel), }, { title: "Mindmeister", keywords: "mindmap", icon: () => Mindmeister, component: Mindmeister, matcher: matcher(Mindmeister), }, { title: "Miro", keywords: "whiteboard", icon: () => Miro, component: Miro, matcher: matcher(Miro), }, { title: "Mode", keywords: "analytics", defaultHidden: true, icon: () => Mode, component: ModeAnalytics, matcher: matcher(ModeAnalytics), }, { title: "Pitch", keywords: "presentation", defaultHidden: true, icon: () => Pitch, component: Pitch, matcher: matcher(Pitch), }, { title: "Prezi", keywords: "presentation", icon: () => Prezi, component: Prezi, matcher: matcher(Prezi), }, { title: "Spotify", keywords: "music", icon: () => Spotify, component: Spotify, matcher: matcher(Spotify), }, { title: "Trello", keywords: "kanban", icon: () => Trello, component: Trello, matcher: matcher(Trello), }, { title: "Typeform", keywords: "form survey", icon: () => Typeform, component: Typeform, matcher: matcher(Typeform), }, { title: "Vimeo", keywords: "video", icon: () => Vimeo, component: Vimeo, matcher: matcher(Vimeo), }, { title: "Whimsical", keywords: "whiteboard", icon: () => Whimsical, component: Whimsical, matcher: matcher(Whimsical), }, { title: "YouTube", keywords: "google video", icon: () => YouTube, component: YouTube, matcher: matcher(YouTube), }, ]; export default embeds;