import { EditorState } from "prosemirror-state"; import * as React from "react"; import styled from "styled-components"; import { IntegrationType } from "../../types"; import type { IntegrationSettings } from "../../types"; import { urlRegex } from "../../utils/urls"; 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 Gliffy from "./Gliffy"; import GoogleCalendar from "./GoogleCalendar"; import GoogleDataStudio from "./GoogleDataStudio"; import GoogleDocs from "./GoogleDocs"; import GoogleDrawings from "./GoogleDrawings"; import GoogleDrive from "./GoogleDrive"; import GoogleForms from "./GoogleForms"; import GoogleSheets from "./GoogleSheets"; import GoogleSlides from "./GoogleSlides"; import Grist from "./Grist"; import InVision from "./InVision"; import JSFiddle from "./JSFiddle"; 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 Otter from "./Otter"; import Pitch from "./Pitch"; import Prezi from "./Prezi"; import Scribe from "./Scribe"; import Spotify from "./Spotify"; import Tldraw from "./Tldraw"; 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; }; }; const Img = styled(Image)` border-radius: 2px; background: #fff; box-shadow: 0 0 0 1px #fff; margin: 4px; width: 18px; height: 18px; `; export class EmbedDescriptor { icon: React.FC; name?: string; title?: string; shortcut?: string; keywords?: string; tooltip?: string; defaultHidden?: boolean; attrs?: Record; visible?: boolean; active?: (state: EditorState) => boolean; component: typeof React.Component | React.FC; settings?: IntegrationSettings; constructor(options: Omit) { this.icon = options.icon; this.name = options.name; this.title = options.title; this.shortcut = options.shortcut; this.keywords = options.keywords; this.tooltip = options.tooltip; this.defaultHidden = options.defaultHidden; this.attrs = options.attrs; this.visible = options.visible; this.active = options.active; this.component = options.component; this.settings = options.settings; } matcher(url: string): boolean | [] | RegExpMatchArray { const regex = urlRegex(this.settings?.url); // @ts-expect-error not aware of static const regexes = this.component.ENABLED; regex && regexes.unshift( new RegExp( // @ts-expect-error not aware of static `^${regex.source}${this.component.URL_PATH_REGEX.source}$` ) ); for (const regex of regexes) { const result = url.match(regex); if (result) { return result; } } return false; } } const embeds: EmbedDescriptor[] = [ new EmbedDescriptor({ title: "Abstract", keywords: "design", defaultHidden: true, icon: () => Abstract, component: Abstract, }), new EmbedDescriptor({ title: "Airtable", keywords: "spreadsheet", icon: () => Airtable, component: Airtable, }), new EmbedDescriptor({ title: "Berrycast", keywords: "video", defaultHidden: true, icon: () => Berrycast, component: Berrycast, }), new EmbedDescriptor({ title: "Bilibili", keywords: "video", defaultHidden: true, icon: () => Bilibili, component: Bilibili, }), new EmbedDescriptor({ title: "Cawemo", keywords: "bpmn process", defaultHidden: true, icon: () => Cawemo, component: Cawemo, }), new EmbedDescriptor({ title: "ClickUp", keywords: "project", icon: () => ClickUp, component: ClickUp, }), new EmbedDescriptor({ title: "Codepen", keywords: "code editor", icon: () => Codepen, component: Codepen, }), new EmbedDescriptor({ title: "DBDiagram", keywords: "diagrams database", icon: () => DBDiagram, component: DBDiagram, }), new EmbedDescriptor({ title: "Descript", keywords: "audio", icon: () => Descript, component: Descript, }), new EmbedDescriptor({ title: "Figma", keywords: "design svg vector", icon: () => Figma, component: Figma, }), new EmbedDescriptor({ title: "Framer", keywords: "design prototyping", icon: () => Framer, component: Framer, }), new EmbedDescriptor({ title: "GitHub Gist", keywords: "code", icon: () => GitHub, component: Gist, }), new EmbedDescriptor({ title: "Gliffy", keywords: "diagram", icon: () => Gliffy, component: Gliffy, }), new EmbedDescriptor({ title: "Diagrams.net", keywords: "diagrams drawio", icon: () => Diagrams.net, component: Diagrams, }), new EmbedDescriptor({ title: "Google Drawings", keywords: "drawings", icon: () => Google Drawings, component: GoogleDrawings, }), new EmbedDescriptor({ title: "Google Drive", keywords: "drive", icon: () => Google Drive, component: GoogleDrive, }), new EmbedDescriptor({ title: "Google Docs", keywords: "documents word", icon: () => Google Docs, component: GoogleDocs, }), new EmbedDescriptor({ title: "Google Sheets", keywords: "excel spreadsheet", icon: () => Google Sheets, component: GoogleSheets, }), new EmbedDescriptor({ title: "Google Slides", keywords: "presentation slideshow", icon: () => Google Slides, component: GoogleSlides, }), new EmbedDescriptor({ title: "Google Calendar", keywords: "calendar", icon: () => Google Calendar, component: GoogleCalendar, }), new EmbedDescriptor({ title: "Google Data Studio", keywords: "bi business intelligence", icon: () => ( Google Data Studio ), component: GoogleDataStudio, }), new EmbedDescriptor({ title: "Google Forms", keywords: "form survey", icon: () => Google Forms, component: GoogleForms, }), new EmbedDescriptor({ title: "Grist", keywords: "spreadsheet", icon: () => Grist, component: Grist, }), new EmbedDescriptor({ title: "InVision", keywords: "design prototype", defaultHidden: true, icon: () => InVision, component: InVision, }), new EmbedDescriptor({ title: "JSFiddle", keywords: "code", defaultHidden: true, icon: () => JSFiddle, component: JSFiddle, }), new EmbedDescriptor({ title: "Loom", keywords: "video screencast", icon: () => Loom, component: Loom, }), new EmbedDescriptor({ title: "Lucidchart", keywords: "chart", icon: () => Lucidchart, component: Lucidchart, }), new EmbedDescriptor({ title: "Marvel", keywords: "design prototype", icon: () => Marvel, component: Marvel, }), new EmbedDescriptor({ title: "Mindmeister", keywords: "mindmap", icon: () => Mindmeister, component: Mindmeister, }), new EmbedDescriptor({ title: "Miro", keywords: "whiteboard", icon: () => Miro, component: Miro, }), new EmbedDescriptor({ title: "Mode", keywords: "analytics", defaultHidden: true, icon: () => Mode, component: ModeAnalytics, }), new EmbedDescriptor({ title: "Otter.ai", keywords: "audio transcription meeting notes", defaultHidden: true, icon: () => Otter.ai, component: Otter, }), new EmbedDescriptor({ title: "Pitch", keywords: "presentation", defaultHidden: true, icon: () => Pitch, component: Pitch, }), new EmbedDescriptor({ title: "Prezi", keywords: "presentation", icon: () => Prezi, component: Prezi, }), new EmbedDescriptor({ title: "Scribe", keywords: "screencast", icon: () => Scribe, component: Scribe, }), new EmbedDescriptor({ title: "Spotify", keywords: "music", icon: () => Spotify, component: Spotify, }), new EmbedDescriptor({ title: "Tldraw", keywords: "draw schematics diagrams", icon: () => Tldraw, component: Tldraw, }), new EmbedDescriptor({ title: "Trello", keywords: "kanban", icon: () => Trello, component: Trello, }), new EmbedDescriptor({ title: "Typeform", keywords: "form survey", icon: () => Typeform, component: Typeform, }), new EmbedDescriptor({ title: "Vimeo", keywords: "video", icon: () => Vimeo, component: Vimeo, }), new EmbedDescriptor({ title: "Whimsical", keywords: "whiteboard", icon: () => Whimsical, component: Whimsical, }), new EmbedDescriptor({ title: "YouTube", keywords: "google video", icon: () => YouTube, component: YouTube, }), ]; export default embeds;