@tiptap/extension-twitch 3.30.2 → 3.30.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/twitch.ts","../src/utils.ts"],"sourcesContent":["import { Twitch } from './twitch.js'\n\nexport * from './twitch.js'\nexport * from './utils.js'\n\nexport default Twitch\n","import { createAtomBlockMarkdownSpec, mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport {\n getAttributesFromTwitchEmbedUrl,\n getEmbedUrlFromTwitchUrl,\n isValidTwitchUrl,\n TWITCH_REGEX_GLOBAL,\n} from './utils.js'\n\nconst getParsedDimension = (value: string | null) => {\n if (!value) {\n return null\n }\n\n const parsedValue = Number.parseInt(value, 10)\n\n return Number.isNaN(parsedValue) ? null : parsedValue\n}\n\nconst getParsedTwitchAttributes = (element: HTMLElement) => {\n const src = element.getAttribute('src')\n\n if (!src) {\n return null\n }\n\n const embedAttributes = getAttributesFromTwitchEmbedUrl(src)\n\n if (embedAttributes) {\n return embedAttributes\n }\n\n if (isValidTwitchUrl(src)) {\n return {\n src,\n }\n }\n\n return {\n src,\n }\n}\n\nexport interface TwitchOptions {\n /**\n * Controls if the paste handler for Twitch videos should be added.\n * @default true\n * @example false\n */\n addPasteHandler: boolean\n\n /**\n * Controls if the Twitch video should be allowed to go fullscreen.\n * @default true\n * @example false\n */\n allowFullscreen: boolean\n\n /**\n * Controls if the Twitch video should autoplay.\n * @default false\n * @example true\n */\n autoplay: boolean\n\n /**\n * Controls if the Twitch video should start muted.\n * @default false\n * @example true\n */\n muted: boolean\n\n /**\n * The time in the video where playback starts (format: 1h2m3s).\n * Only works for video embeds, not for clips or channels.\n * @default undefined\n * @example '1h2m3s'\n */\n time?: string\n\n /**\n * The parent domain for the Twitch embed. Required for embed functionality.\n * @default 'localhost'\n * @example 'example.com'\n */\n parent: string\n\n /**\n * The height of the Twitch video.\n * @default 480\n * @example 720\n */\n height: number\n\n /**\n * The width of the Twitch video.\n * @default 640\n * @example 1280\n */\n width: number\n\n /**\n * The HTML attributes for a Twitch video node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Controls if the Twitch node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean\n}\n\n/**\n * The options for setting a Twitch video.\n */\ntype SetTwitchVideoOptions = {\n src: string\n width?: number\n height?: number\n autoplay?: boolean\n muted?: boolean\n time?: string\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n twitch: {\n /**\n * Insert a Twitch video\n * @param options The Twitch video attributes\n * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })\n */\n setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType\n }\n }\n}\n\n/**\n * This extension adds support for Twitch videos.\n * @see https://www.tiptap.dev/api/nodes/twitch\n *\n * @example\n * ```ts\n * import { useEditor, EditorContent } from '@tiptap/react'\n * import { StarterKit } from '@tiptap/starter-kit'\n * import { Twitch } from '@tiptap/extension-twitch'\n *\n * const editor = useEditor({\n * extensions: [\n * StarterKit,\n * Twitch.configure({\n * parent: 'example.com',\n * allowFullscreen: true,\n * }),\n * ],\n * content: '<p>Hello World!</p>',\n * })\n * ```\n */\nexport const Twitch = Node.create<TwitchOptions>({\n name: 'twitch',\n\n addOptions() {\n return {\n addPasteHandler: true,\n allowFullscreen: true,\n autoplay: false,\n muted: false,\n time: undefined,\n parent: 'localhost',\n height: 480,\n width: 640,\n HTMLAttributes: {},\n inline: false,\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n parseHTML: element => getParsedTwitchAttributes(element)?.src,\n },\n width: {\n default: this.options.width,\n parseHTML: element => getParsedDimension(element.getAttribute('width')),\n },\n height: {\n default: this.options.height,\n parseHTML: element => getParsedDimension(element.getAttribute('height')),\n },\n autoplay: {\n default: this.options.autoplay,\n parseHTML: element => getParsedTwitchAttributes(element)?.autoplay,\n },\n muted: {\n default: this.options.muted,\n parseHTML: element => getParsedTwitchAttributes(element)?.muted,\n },\n time: {\n default: this.options.time,\n parseHTML: element => getParsedTwitchAttributes(element)?.time,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-twitch-video] iframe',\n },\n ]\n },\n\n addCommands() {\n return {\n setTwitchVideo:\n (options: SetTwitchVideoOptions) =>\n ({ commands }) => {\n if (!isValidTwitchUrl(options.src)) {\n return false\n }\n\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addPasteRules() {\n if (!this.options.addPasteHandler) {\n return []\n }\n\n return [\n nodePasteRule({\n find: TWITCH_REGEX_GLOBAL,\n type: this.type,\n getAttributes: match => {\n return { src: match.input }\n },\n }),\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const embedUrl = getEmbedUrlFromTwitchUrl({\n url: HTMLAttributes.src,\n allowFullscreen: this.options.allowFullscreen,\n autoplay: HTMLAttributes.autoplay ?? this.options.autoplay,\n muted: HTMLAttributes.muted ?? this.options.muted,\n time: HTMLAttributes.time ?? this.options.time,\n parent: this.options.parent,\n })\n\n if (!embedUrl) {\n return ['div', 'Invalid Twitch URL']\n }\n\n HTMLAttributes.src = embedUrl\n\n return [\n 'div',\n { 'data-twitch-video': '' },\n [\n 'iframe',\n mergeAttributes(\n this.options.HTMLAttributes,\n {\n width: this.options.width,\n height: this.options.height,\n allowfullscreen: this.options.allowFullscreen,\n scrolling: 'no',\n frameborder: '0',\n },\n HTMLAttributes,\n ),\n ],\n ]\n },\n\n ...createAtomBlockMarkdownSpec({\n nodeName: 'twitch',\n allowedAttributes: ['src', 'width', 'height', 'autoplay', 'muted', 'time'],\n }),\n})\n","/**\n * Regex patterns for matching Twitch URLs\n * Matches:\n * - https://twitch.tv/videos/1234567890\n * - https://www.twitch.tv/videos/1234567890\n * - https://twitch.tv/examplechannel/clip/ClipName-123\n * - https://www.twitch.tv/examplechannel/clip/ClipName-123\n * - https://clips.twitch.tv/ClipName\n * - https://www.clips.twitch.tv/ClipName\n * - https://twitch.tv/examplechannel (channel)\n * - https://www.twitch.tv/examplechannel\n */\nexport const TWITCH_REGEX =\n /^(https?:\\/\\/)?(www\\.)?(twitch\\.tv|clips\\.twitch\\.tv)\\/(?:videos\\/(\\d+)|(\\w+)\\/clip\\/([\\w-]+)|([\\w-]+)(?:\\/)?)?(\\?.*)?$/\n\nexport const TWITCH_REGEX_GLOBAL =\n /^(https?:\\/\\/)?(www\\.)?(twitch\\.tv|clips\\.twitch\\.tv)\\/(?:videos\\/(\\d+)|(\\w+)\\/clip\\/([\\w-]+)|([\\w-]+)(?:\\/)?)?(\\?.*)?$/g\n\n/**\n * Validates if a URL is a valid Twitch video, clip or channel URL\n *\n * @param url - The URL to validate\n * @returns true if the URL is a valid Twitch URL\n *\n * @example\n * ```ts\n * isValidTwitchUrl('https://www.twitch.tv/videos/1234567890') // true\n * isValidTwitchUrl('https://www.twitch.tv/examplechannel/clip/ExampleClipName') // true\n * isValidTwitchUrl('https://www.twitch.tv/examplechannel') // true\n * isValidTwitchUrl('https://clips.twitch.tv/ExampleClipName') // true\n * isValidTwitchUrl('invalid') // false\n * ```\n */\nexport const isValidTwitchUrl = (url: string) => {\n return url.match(TWITCH_REGEX)\n}\n\nexport interface GetEmbedUrlOptions {\n url: string\n allowFullscreen?: boolean\n autoplay?: boolean\n muted?: boolean\n time?: string\n parent?: string\n}\n\nexport interface TwitchEmbedAttributes {\n src: string\n autoplay?: boolean\n muted?: boolean\n time?: string\n}\n\n/**\n * Extracts the video, clip or channel identifier from a Twitch URL\n *\n * @param url - The Twitch URL\n * @returns Object containing type ('video', 'clip' or 'channel') and ID, or null if invalid\n *\n * @example\n * ```ts\n * getTwitchIdentifier('https://www.twitch.tv/videos/1234567890')\n * // { type: 'video', id: '1234567890' }\n *\n * getTwitchIdentifier('https://www.twitch.tv/examplechannel/clip/ExampleClipName-ABC123')\n * // { type: 'clip', id: 'ExampleClipName-ABC123' }\n *\n * getTwitchIdentifier('https://www.twitch.tv/examplechannel')\n * // { type: 'channel', id: 'examplechannel' }\n * ```\n */\nexport const getTwitchIdentifier = (\n url: string,\n): { type: 'video' | 'clip' | 'channel'; id: string } | null => {\n if (!isValidTwitchUrl(url)) {\n return null\n }\n\n // Remove query parameters\n const cleanUrl = url.split('?')[0]\n\n // Handle clip URLs from clips.twitch.tv\n if (cleanUrl.includes('clips.twitch.tv/')) {\n const clipRegex = /clips\\.twitch\\.tv\\/([\\w-]+)/\n const match = cleanUrl.match(clipRegex)\n return match ? { type: 'clip', id: match[1] } : null\n }\n\n // Handle twitch.tv URLs\n if (cleanUrl.includes('twitch.tv/')) {\n // Check if it's a video URL (videos/ID)\n const videoRegex = /twitch\\.tv\\/videos\\/(\\d+)/\n const videoMatch = cleanUrl.match(videoRegex)\n if (videoMatch) {\n return { type: 'video', id: videoMatch[1] }\n }\n\n // Check if it's a clip URL (channel/clip/clipname)\n const channelClipRegex = /twitch\\.tv\\/([\\w-]+)\\/clip\\/([\\w-]+)/\n const clipMatch = cleanUrl.match(channelClipRegex)\n if (clipMatch) {\n return { type: 'clip', id: clipMatch[2] }\n }\n\n // Otherwise it's a channel URL\n const channelRegex = /twitch\\.tv\\/([\\w-]+)(?:\\/)?$/\n const channelMatch = cleanUrl.match(channelRegex)\n if (channelMatch) {\n return { type: 'channel', id: channelMatch[1] }\n }\n }\n\n return null\n}\n\n/**\n * Generates an embed URL from a Twitch video, clip or channel URL with optional parameters\n *\n * @param options - The embed URL options\n * @returns The embed URL or null if invalid\n *\n * @example\n * ```ts\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/videos/1234567890',\n * parent: 'example.com',\n * muted: true,\n * time: '1h2m3s'\n * })\n * // Returns: https://player.twitch.tv/?video=1234567890&parent=example.com&muted=true&time=1h2m3s\n *\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/examplechannel/clip/ExampleClipName-ABC123',\n * parent: 'example.com',\n * autoplay: true,\n * muted: true\n * })\n * // Returns: https://clips.twitch.tv/embed?clip=ExampleClipName-ABC123&parent=example.com&autoplay=true&muted=true\n *\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/examplechannel',\n * parent: 'example.com'\n * })\n * // Returns: https://player.twitch.tv/?channel=examplechannel&parent=example.com\n * ```\n */\nexport const getEmbedUrlFromTwitchUrl = (options: GetEmbedUrlOptions): string | null => {\n const { url, allowFullscreen = true, autoplay = false, muted = false, time, parent } = options\n\n const identifier = getTwitchIdentifier(url)\n\n if (!identifier) {\n return null\n }\n\n const parentDomain = parent || 'localhost'\n\n // Handle clip URLs\n if (identifier.type === 'clip') {\n const clipUrl = new URL('https://clips.twitch.tv/embed')\n clipUrl.searchParams.set('clip', identifier.id)\n clipUrl.searchParams.set('parent', parentDomain)\n\n if (autoplay) {\n clipUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n clipUrl.searchParams.set('muted', 'true')\n }\n\n return clipUrl.toString()\n }\n\n // Handle video URLs\n if (identifier.type === 'video') {\n const videoUrl = new URL('https://player.twitch.tv/')\n videoUrl.searchParams.set('video', identifier.id)\n videoUrl.searchParams.set('parent', parentDomain)\n\n if (allowFullscreen) {\n videoUrl.searchParams.set('allowfullscreen', 'true')\n }\n\n if (autoplay) {\n videoUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n videoUrl.searchParams.set('muted', 'true')\n }\n\n if (time) {\n videoUrl.searchParams.set('time', time)\n }\n\n return videoUrl.toString()\n }\n\n // Handle channel URLs\n if (identifier.type === 'channel') {\n const channelUrl = new URL('https://player.twitch.tv/')\n channelUrl.searchParams.set('channel', identifier.id)\n channelUrl.searchParams.set('parent', parentDomain)\n\n if (allowFullscreen) {\n channelUrl.searchParams.set('allowfullscreen', 'true')\n }\n\n if (autoplay) {\n channelUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n channelUrl.searchParams.set('muted', 'true')\n }\n\n return channelUrl.toString()\n }\n\n return null\n}\n\n/**\n * Parses a Twitch embed URL into canonical Twitch node attributes.\n *\n * @param url - The Twitch embed URL\n * @returns Canonical node attributes or null if the URL is not a supported Twitch embed URL\n *\n * @example\n * ```ts\n * getAttributesFromTwitchEmbedUrl('https://player.twitch.tv/?video=1234567890&parent=example.com&muted=true')\n * // Returns: { src: 'https://www.twitch.tv/videos/1234567890', muted: true }\n *\n * getAttributesFromTwitchEmbedUrl('https://clips.twitch.tv/embed?clip=ExampleClipName-ABC123&parent=example.com')\n * // Returns: { src: 'https://clips.twitch.tv/ExampleClipName-ABC123' }\n * ```\n */\nexport const getAttributesFromTwitchEmbedUrl = (url: string): TwitchEmbedAttributes | null => {\n let parsedUrl: URL\n\n try {\n parsedUrl = new URL(url)\n } catch {\n return null\n }\n\n const hostname = parsedUrl.hostname.replace(/^www\\./, '')\n const result: TwitchEmbedAttributes = {\n src: '',\n }\n\n if (hostname === 'player.twitch.tv') {\n const videoId = parsedUrl.searchParams.get('video')\n const channelName = parsedUrl.searchParams.get('channel')\n\n if (videoId) {\n result.src = `https://www.twitch.tv/videos/${videoId}`\n } else if (channelName) {\n result.src = `https://www.twitch.tv/${channelName}`\n } else {\n return null\n }\n } else if (hostname === 'clips.twitch.tv' && parsedUrl.pathname === '/embed') {\n const clipId = parsedUrl.searchParams.get('clip')\n\n if (!clipId) {\n return null\n }\n\n result.src = `https://clips.twitch.tv/${clipId}`\n } else {\n return null\n }\n\n if (parsedUrl.searchParams.get('autoplay') === 'true') {\n result.autoplay = true\n }\n\n if (parsedUrl.searchParams.get('muted') === 'true') {\n result.muted = true\n }\n\n const time = parsedUrl.searchParams.get('time')\n\n if (time) {\n result.time = time\n }\n\n if (!isValidTwitchUrl(result.src)) {\n return null\n }\n\n return result\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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O,oBAAoB;AAAA,IACrC;AAEA,mBAAe,MAAM;AAErB,WAAO;AAAA,MACL;AAAA,MACA,EAAE,qBAAqB,GAAG;AAAA,MAC1B;AAAA,QACE;AAAA,YACA;AAAA,UACE,KAAK,QAAQ;AAAA,UACb;AAAA,YACE,OAAO,KAAK,QAAQ;AAAA,YACpB,QAAQ,KAAK,QAAQ;AAAA,YACrB,iBAAiB,KAAK,QAAQ;AAAA,YAC9B,WAAW;AAAA,YACX,aAAa;AAAA,UACf;AAAA,UACA;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,OAAG,yCAA4B;AAAA,IAC7B,UAAU;AAAA,IACV,mBAAmB,CAAC,OAAO,SAAS,UAAU,YAAY,SAAS,MAAM;AAAA,EAC3E,CAAC;AACH,CAAC;;;ADxSD,IAAO,gBAAQ;","names":[]}
1
+ {"version":3,"file":"index.cjs","names":["Node"],"sources":["../src/utils.ts","../src/twitch.ts","../src/index.ts"],"sourcesContent":["/**\n * Regex patterns for matching Twitch URLs\n * Matches:\n * - https://twitch.tv/videos/1234567890\n * - https://www.twitch.tv/videos/1234567890\n * - https://twitch.tv/examplechannel/clip/ClipName-123\n * - https://www.twitch.tv/examplechannel/clip/ClipName-123\n * - https://clips.twitch.tv/ClipName\n * - https://www.clips.twitch.tv/ClipName\n * - https://twitch.tv/examplechannel (channel)\n * - https://www.twitch.tv/examplechannel\n */\nexport const TWITCH_REGEX =\n /^(https?:\\/\\/)?(www\\.)?(twitch\\.tv|clips\\.twitch\\.tv)\\/(?:videos\\/(\\d+)|(\\w+)\\/clip\\/([\\w-]+)|([\\w-]+)(?:\\/)?)?(\\?.*)?$/\n\nexport const TWITCH_REGEX_GLOBAL =\n /^(https?:\\/\\/)?(www\\.)?(twitch\\.tv|clips\\.twitch\\.tv)\\/(?:videos\\/(\\d+)|(\\w+)\\/clip\\/([\\w-]+)|([\\w-]+)(?:\\/)?)?(\\?.*)?$/g\n\n/**\n * Validates if a URL is a valid Twitch video, clip or channel URL\n *\n * @param url - The URL to validate\n * @returns true if the URL is a valid Twitch URL\n *\n * @example\n * ```ts\n * isValidTwitchUrl('https://www.twitch.tv/videos/1234567890') // true\n * isValidTwitchUrl('https://www.twitch.tv/examplechannel/clip/ExampleClipName') // true\n * isValidTwitchUrl('https://www.twitch.tv/examplechannel') // true\n * isValidTwitchUrl('https://clips.twitch.tv/ExampleClipName') // true\n * isValidTwitchUrl('invalid') // false\n * ```\n */\nexport const isValidTwitchUrl = (url: string) => {\n return url.match(TWITCH_REGEX)\n}\n\nexport interface GetEmbedUrlOptions {\n url: string\n allowFullscreen?: boolean\n autoplay?: boolean\n muted?: boolean\n time?: string\n parent?: string\n}\n\nexport interface TwitchEmbedAttributes {\n src: string\n autoplay?: boolean\n muted?: boolean\n time?: string\n}\n\n/**\n * Extracts the video, clip or channel identifier from a Twitch URL\n *\n * @param url - The Twitch URL\n * @returns Object containing type ('video', 'clip' or 'channel') and ID, or null if invalid\n *\n * @example\n * ```ts\n * getTwitchIdentifier('https://www.twitch.tv/videos/1234567890')\n * // { type: 'video', id: '1234567890' }\n *\n * getTwitchIdentifier('https://www.twitch.tv/examplechannel/clip/ExampleClipName-ABC123')\n * // { type: 'clip', id: 'ExampleClipName-ABC123' }\n *\n * getTwitchIdentifier('https://www.twitch.tv/examplechannel')\n * // { type: 'channel', id: 'examplechannel' }\n * ```\n */\nexport const getTwitchIdentifier = (\n url: string,\n): { type: 'video' | 'clip' | 'channel'; id: string } | null => {\n if (!isValidTwitchUrl(url)) {\n return null\n }\n\n // Remove query parameters\n const cleanUrl = url.split('?')[0]\n\n // Handle clip URLs from clips.twitch.tv\n if (cleanUrl.includes('clips.twitch.tv/')) {\n const clipRegex = /clips\\.twitch\\.tv\\/([\\w-]+)/\n const match = cleanUrl.match(clipRegex)\n return match ? { type: 'clip', id: match[1] } : null\n }\n\n // Handle twitch.tv URLs\n if (cleanUrl.includes('twitch.tv/')) {\n // Check if it's a video URL (videos/ID)\n const videoRegex = /twitch\\.tv\\/videos\\/(\\d+)/\n const videoMatch = cleanUrl.match(videoRegex)\n if (videoMatch) {\n return { type: 'video', id: videoMatch[1] }\n }\n\n // Check if it's a clip URL (channel/clip/clipname)\n const channelClipRegex = /twitch\\.tv\\/([\\w-]+)\\/clip\\/([\\w-]+)/\n const clipMatch = cleanUrl.match(channelClipRegex)\n if (clipMatch) {\n return { type: 'clip', id: clipMatch[2] }\n }\n\n // Otherwise it's a channel URL\n const channelRegex = /twitch\\.tv\\/([\\w-]+)(?:\\/)?$/\n const channelMatch = cleanUrl.match(channelRegex)\n if (channelMatch) {\n return { type: 'channel', id: channelMatch[1] }\n }\n }\n\n return null\n}\n\n/**\n * Generates an embed URL from a Twitch video, clip or channel URL with optional parameters\n *\n * @param options - The embed URL options\n * @returns The embed URL or null if invalid\n *\n * @example\n * ```ts\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/videos/1234567890',\n * parent: 'example.com',\n * muted: true,\n * time: '1h2m3s'\n * })\n * // Returns: https://player.twitch.tv/?video=1234567890&parent=example.com&muted=true&time=1h2m3s\n *\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/examplechannel/clip/ExampleClipName-ABC123',\n * parent: 'example.com',\n * autoplay: true,\n * muted: true\n * })\n * // Returns: https://clips.twitch.tv/embed?clip=ExampleClipName-ABC123&parent=example.com&autoplay=true&muted=true\n *\n * getEmbedUrlFromTwitchUrl({\n * url: 'https://www.twitch.tv/examplechannel',\n * parent: 'example.com'\n * })\n * // Returns: https://player.twitch.tv/?channel=examplechannel&parent=example.com\n * ```\n */\nexport const getEmbedUrlFromTwitchUrl = (options: GetEmbedUrlOptions): string | null => {\n const { url, allowFullscreen = true, autoplay = false, muted = false, time, parent } = options\n\n const identifier = getTwitchIdentifier(url)\n\n if (!identifier) {\n return null\n }\n\n const parentDomain = parent || 'localhost'\n\n // Handle clip URLs\n if (identifier.type === 'clip') {\n const clipUrl = new URL('https://clips.twitch.tv/embed')\n clipUrl.searchParams.set('clip', identifier.id)\n clipUrl.searchParams.set('parent', parentDomain)\n\n if (autoplay) {\n clipUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n clipUrl.searchParams.set('muted', 'true')\n }\n\n return clipUrl.toString()\n }\n\n // Handle video URLs\n if (identifier.type === 'video') {\n const videoUrl = new URL('https://player.twitch.tv/')\n videoUrl.searchParams.set('video', identifier.id)\n videoUrl.searchParams.set('parent', parentDomain)\n\n if (allowFullscreen) {\n videoUrl.searchParams.set('allowfullscreen', 'true')\n }\n\n if (autoplay) {\n videoUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n videoUrl.searchParams.set('muted', 'true')\n }\n\n if (time) {\n videoUrl.searchParams.set('time', time)\n }\n\n return videoUrl.toString()\n }\n\n // Handle channel URLs\n if (identifier.type === 'channel') {\n const channelUrl = new URL('https://player.twitch.tv/')\n channelUrl.searchParams.set('channel', identifier.id)\n channelUrl.searchParams.set('parent', parentDomain)\n\n if (allowFullscreen) {\n channelUrl.searchParams.set('allowfullscreen', 'true')\n }\n\n if (autoplay) {\n channelUrl.searchParams.set('autoplay', 'true')\n }\n\n if (muted) {\n channelUrl.searchParams.set('muted', 'true')\n }\n\n return channelUrl.toString()\n }\n\n return null\n}\n\n/**\n * Parses a Twitch embed URL into canonical Twitch node attributes.\n *\n * @param url - The Twitch embed URL\n * @returns Canonical node attributes or null if the URL is not a supported Twitch embed URL\n *\n * @example\n * ```ts\n * getAttributesFromTwitchEmbedUrl('https://player.twitch.tv/?video=1234567890&parent=example.com&muted=true')\n * // Returns: { src: 'https://www.twitch.tv/videos/1234567890', muted: true }\n *\n * getAttributesFromTwitchEmbedUrl('https://clips.twitch.tv/embed?clip=ExampleClipName-ABC123&parent=example.com')\n * // Returns: { src: 'https://clips.twitch.tv/ExampleClipName-ABC123' }\n * ```\n */\nexport const getAttributesFromTwitchEmbedUrl = (url: string): TwitchEmbedAttributes | null => {\n let parsedUrl: URL\n\n try {\n parsedUrl = new URL(url)\n } catch {\n return null\n }\n\n const hostname = parsedUrl.hostname.replace(/^www\\./, '')\n const result: TwitchEmbedAttributes = {\n src: '',\n }\n\n if (hostname === 'player.twitch.tv') {\n const videoId = parsedUrl.searchParams.get('video')\n const channelName = parsedUrl.searchParams.get('channel')\n\n if (videoId) {\n result.src = `https://www.twitch.tv/videos/${videoId}`\n } else if (channelName) {\n result.src = `https://www.twitch.tv/${channelName}`\n } else {\n return null\n }\n } else if (hostname === 'clips.twitch.tv' && parsedUrl.pathname === '/embed') {\n const clipId = parsedUrl.searchParams.get('clip')\n\n if (!clipId) {\n return null\n }\n\n result.src = `https://clips.twitch.tv/${clipId}`\n } else {\n return null\n }\n\n if (parsedUrl.searchParams.get('autoplay') === 'true') {\n result.autoplay = true\n }\n\n if (parsedUrl.searchParams.get('muted') === 'true') {\n result.muted = true\n }\n\n const time = parsedUrl.searchParams.get('time')\n\n if (time) {\n result.time = time\n }\n\n if (!isValidTwitchUrl(result.src)) {\n return null\n }\n\n return result\n}\n","import { createAtomBlockMarkdownSpec, mergeAttributes, Node, nodePasteRule } from '@tiptap/core'\n\nimport {\n getAttributesFromTwitchEmbedUrl,\n getEmbedUrlFromTwitchUrl,\n isValidTwitchUrl,\n TWITCH_REGEX_GLOBAL,\n} from './utils.js'\n\nconst getParsedDimension = (value: string | null) => {\n if (!value) {\n return null\n }\n\n const parsedValue = Number.parseInt(value, 10)\n\n return Number.isNaN(parsedValue) ? null : parsedValue\n}\n\nconst getParsedTwitchAttributes = (element: HTMLElement) => {\n const src = element.getAttribute('src')\n\n if (!src) {\n return null\n }\n\n const embedAttributes = getAttributesFromTwitchEmbedUrl(src)\n\n if (embedAttributes) {\n return embedAttributes\n }\n\n if (isValidTwitchUrl(src)) {\n return {\n src,\n }\n }\n\n return {\n src,\n }\n}\n\nexport interface TwitchOptions {\n /**\n * Controls if the paste handler for Twitch videos should be added.\n * @default true\n * @example false\n */\n addPasteHandler: boolean\n\n /**\n * Controls if the Twitch video should be allowed to go fullscreen.\n * @default true\n * @example false\n */\n allowFullscreen: boolean\n\n /**\n * Controls if the Twitch video should autoplay.\n * @default false\n * @example true\n */\n autoplay: boolean\n\n /**\n * Controls if the Twitch video should start muted.\n * @default false\n * @example true\n */\n muted: boolean\n\n /**\n * The time in the video where playback starts (format: 1h2m3s).\n * Only works for video embeds, not for clips or channels.\n * @default undefined\n * @example '1h2m3s'\n */\n time?: string\n\n /**\n * The parent domain for the Twitch embed. Required for embed functionality.\n * @default 'localhost'\n * @example 'example.com'\n */\n parent: string\n\n /**\n * The height of the Twitch video.\n * @default 480\n * @example 720\n */\n height: number\n\n /**\n * The width of the Twitch video.\n * @default 640\n * @example 1280\n */\n width: number\n\n /**\n * The HTML attributes for a Twitch video node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * Controls if the Twitch node should be inline or not.\n * @default false\n * @example true\n */\n inline: boolean\n}\n\n/**\n * The options for setting a Twitch video.\n */\ntype SetTwitchVideoOptions = {\n src: string\n width?: number\n height?: number\n autoplay?: boolean\n muted?: boolean\n time?: string\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n twitch: {\n /**\n * Insert a Twitch video\n * @param options The Twitch video attributes\n * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })\n */\n setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType\n }\n }\n}\n\n/**\n * This extension adds support for Twitch videos.\n * @see https://www.tiptap.dev/api/nodes/twitch\n *\n * @example\n * ```ts\n * import { useEditor, EditorContent } from '@tiptap/react'\n * import { StarterKit } from '@tiptap/starter-kit'\n * import { Twitch } from '@tiptap/extension-twitch'\n *\n * const editor = useEditor({\n * extensions: [\n * StarterKit,\n * Twitch.configure({\n * parent: 'example.com',\n * allowFullscreen: true,\n * }),\n * ],\n * content: '<p>Hello World!</p>',\n * })\n * ```\n */\nexport const Twitch = Node.create<TwitchOptions>({\n name: 'twitch',\n\n addOptions() {\n return {\n addPasteHandler: true,\n allowFullscreen: true,\n autoplay: false,\n muted: false,\n time: undefined,\n parent: 'localhost',\n height: 480,\n width: 640,\n HTMLAttributes: {},\n inline: false,\n }\n },\n\n inline() {\n return this.options.inline\n },\n\n group() {\n return this.options.inline ? 'inline' : 'block'\n },\n\n draggable: true,\n\n addAttributes() {\n return {\n src: {\n default: null,\n parseHTML: element => getParsedTwitchAttributes(element)?.src,\n },\n width: {\n default: this.options.width,\n parseHTML: element => getParsedDimension(element.getAttribute('width')),\n },\n height: {\n default: this.options.height,\n parseHTML: element => getParsedDimension(element.getAttribute('height')),\n },\n autoplay: {\n default: this.options.autoplay,\n parseHTML: element => getParsedTwitchAttributes(element)?.autoplay,\n },\n muted: {\n default: this.options.muted,\n parseHTML: element => getParsedTwitchAttributes(element)?.muted,\n },\n time: {\n default: this.options.time,\n parseHTML: element => getParsedTwitchAttributes(element)?.time,\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'div[data-twitch-video] iframe',\n },\n ]\n },\n\n addCommands() {\n return {\n setTwitchVideo:\n (options: SetTwitchVideoOptions) =>\n ({ commands }) => {\n if (!isValidTwitchUrl(options.src)) {\n return false\n }\n\n return commands.insertContent({\n type: this.name,\n attrs: options,\n })\n },\n }\n },\n\n addPasteRules() {\n if (!this.options.addPasteHandler) {\n return []\n }\n\n return [\n nodePasteRule({\n find: TWITCH_REGEX_GLOBAL,\n type: this.type,\n getAttributes: match => {\n return { src: match.input }\n },\n }),\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n const embedUrl = getEmbedUrlFromTwitchUrl({\n url: HTMLAttributes.src,\n allowFullscreen: this.options.allowFullscreen,\n autoplay: HTMLAttributes.autoplay ?? this.options.autoplay,\n muted: HTMLAttributes.muted ?? this.options.muted,\n time: HTMLAttributes.time ?? this.options.time,\n parent: this.options.parent,\n })\n\n if (!embedUrl) {\n return ['div', 'Invalid Twitch URL']\n }\n\n HTMLAttributes.src = embedUrl\n\n return [\n 'div',\n { 'data-twitch-video': '' },\n [\n 'iframe',\n mergeAttributes(\n this.options.HTMLAttributes,\n {\n width: this.options.width,\n height: this.options.height,\n allowfullscreen: this.options.allowFullscreen,\n scrolling: 'no',\n frameborder: '0',\n },\n HTMLAttributes,\n ),\n ],\n ]\n },\n\n ...createAtomBlockMarkdownSpec({\n nodeName: 'twitch',\n allowedAttributes: ['src', 'width', 'height', 'autoplay', 'muted', 'time'],\n }),\n})\n","import { Twitch } from './twitch.js'\n\nexport * from './twitch.js'\nexport * from './utils.js'\n\nexport default Twitch\n"],"mappings":";;;;;;;;;;;;;;;;;;AAYA,MAAa,eACX;AAEF,MAAa,sBACX;;;;;;;;;;;;;;;;AAiBF,MAAa,oBAAoB,QAAgB;CAC/C,OAAO,IAAI,MAAM,YAAY;AAC/B;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,uBACX,QAC8D;CAC9D,IAAI,CAAC,iBAAiB,GAAG,GACvB,OAAO;CAIT,MAAM,WAAW,IAAI,MAAM,GAAG,CAAC,CAAC;CAGhC,IAAI,SAAS,SAAS,kBAAkB,GAAG;EAEzC,MAAM,QAAQ,SAAS,MAAM,6BAAS;EACtC,OAAO,QAAQ;GAAE,MAAM;GAAQ,IAAI,MAAM;EAAG,IAAI;CAClD;CAGA,IAAI,SAAS,SAAS,YAAY,GAAG;EAGnC,MAAM,aAAa,SAAS,MAAM,2BAAU;EAC5C,IAAI,YACF,OAAO;GAAE,MAAM;GAAS,IAAI,WAAW;EAAG;EAK5C,MAAM,YAAY,SAAS,MAAM,sCAAgB;EACjD,IAAI,WACF,OAAO;GAAE,MAAM;GAAQ,IAAI,UAAU;EAAG;EAK1C,MAAM,eAAe,SAAS,MAAM,8BAAY;EAChD,IAAI,cACF,OAAO;GAAE,MAAM;GAAW,IAAI,aAAa;EAAG;CAElD;CAEA,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAa,4BAA4B,YAA+C;CACtF,MAAM,EAAE,KAAK,kBAAkB,MAAM,WA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twitch.d.ts
3
3
  interface TwitchOptions {
4
- /**
5
- * Controls if the paste handler for Twitch videos should be added.
6
- * @default true
7
- * @example false
8
- */
9
- addPasteHandler: boolean;
10
- /**
11
- * Controls if the Twitch video should be allowed to go fullscreen.
12
- * @default true
13
- * @example false
14
- */
15
- allowFullscreen: boolean;
16
- /**
17
- * Controls if the Twitch video should autoplay.
18
- * @default false
19
- * @example true
20
- */
21
- autoplay: boolean;
22
- /**
23
- * Controls if the Twitch video should start muted.
24
- * @default false
25
- * @example true
26
- */
27
- muted: boolean;
28
- /**
29
- * The time in the video where playback starts (format: 1h2m3s).
30
- * Only works for video embeds, not for clips or channels.
31
- * @default undefined
32
- * @example '1h2m3s'
33
- */
34
- time?: string;
35
- /**
36
- * The parent domain for the Twitch embed. Required for embed functionality.
37
- * @default 'localhost'
38
- * @example 'example.com'
39
- */
40
- parent: string;
41
- /**
42
- * The height of the Twitch video.
43
- * @default 480
44
- * @example 720
45
- */
46
- height: number;
47
- /**
48
- * The width of the Twitch video.
49
- * @default 640
50
- * @example 1280
51
- */
52
- width: number;
53
- /**
54
- * The HTML attributes for a Twitch video node.
55
- * @default {}
56
- * @example { class: 'foo' }
57
- */
58
- HTMLAttributes: Record<string, any>;
59
- /**
60
- * Controls if the Twitch node should be inline or not.
61
- * @default false
62
- * @example true
63
- */
64
- inline: boolean;
4
+ /**
5
+ * Controls if the paste handler for Twitch videos should be added.
6
+ * @default true
7
+ * @example false
8
+ */
9
+ addPasteHandler: boolean;
10
+ /**
11
+ * Controls if the Twitch video should be allowed to go fullscreen.
12
+ * @default true
13
+ * @example false
14
+ */
15
+ allowFullscreen: boolean;
16
+ /**
17
+ * Controls if the Twitch video should autoplay.
18
+ * @default false
19
+ * @example true
20
+ */
21
+ autoplay: boolean;
22
+ /**
23
+ * Controls if the Twitch video should start muted.
24
+ * @default false
25
+ * @example true
26
+ */
27
+ muted: boolean;
28
+ /**
29
+ * The time in the video where playback starts (format: 1h2m3s).
30
+ * Only works for video embeds, not for clips or channels.
31
+ * @default undefined
32
+ * @example '1h2m3s'
33
+ */
34
+ time?: string;
35
+ /**
36
+ * The parent domain for the Twitch embed. Required for embed functionality.
37
+ * @default 'localhost'
38
+ * @example 'example.com'
39
+ */
40
+ parent: string;
41
+ /**
42
+ * The height of the Twitch video.
43
+ * @default 480
44
+ * @example 720
45
+ */
46
+ height: number;
47
+ /**
48
+ * The width of the Twitch video.
49
+ * @default 640
50
+ * @example 1280
51
+ */
52
+ width: number;
53
+ /**
54
+ * The HTML attributes for a Twitch video node.
55
+ * @default {}
56
+ * @example { class: 'foo' }
57
+ */
58
+ HTMLAttributes: Record<string, any>;
59
+ /**
60
+ * Controls if the Twitch node should be inline or not.
61
+ * @default false
62
+ * @example true
63
+ */
64
+ inline: boolean;
65
65
  }
66
66
  /**
67
67
  * The options for setting a Twitch video.
68
68
  */
69
69
  type SetTwitchVideoOptions = {
70
- src: string;
71
- width?: number;
72
- height?: number;
73
- autoplay?: boolean;
74
- muted?: boolean;
75
- time?: string;
70
+ src: string;
71
+ width?: number;
72
+ height?: number;
73
+ autoplay?: boolean;
74
+ muted?: boolean;
75
+ time?: string;
76
76
  };
77
77
  declare module '@tiptap/core' {
78
- interface Commands<ReturnType> {
79
- twitch: {
80
- /**
81
- * Insert a Twitch video
82
- * @param options The Twitch video attributes
83
- * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })
84
- */
85
- setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType;
86
- };
87
- }
78
+ interface Commands<ReturnType> {
79
+ twitch: {
80
+ /**
81
+ * Insert a Twitch video
82
+ * @param options The Twitch video attributes
83
+ * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })
84
+ */
85
+ setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType;
86
+ };
87
+ }
88
88
  }
89
89
  /**
90
90
  * This extension adds support for Twitch videos.
@@ -109,7 +109,8 @@ declare module '@tiptap/core' {
109
109
  * ```
110
110
  */
111
111
  declare const Twitch: Node<TwitchOptions, any>;
112
-
112
+ //#endregion
113
+ //#region src/utils.d.ts
113
114
  /**
114
115
  * Regex patterns for matching Twitch URLs
115
116
  * Matches:
@@ -141,18 +142,18 @@ declare const TWITCH_REGEX_GLOBAL: RegExp;
141
142
  */
142
143
  declare const isValidTwitchUrl: (url: string) => RegExpMatchArray | null;
143
144
  interface GetEmbedUrlOptions {
144
- url: string;
145
- allowFullscreen?: boolean;
146
- autoplay?: boolean;
147
- muted?: boolean;
148
- time?: string;
149
- parent?: string;
145
+ url: string;
146
+ allowFullscreen?: boolean;
147
+ autoplay?: boolean;
148
+ muted?: boolean;
149
+ time?: string;
150
+ parent?: string;
150
151
  }
151
152
  interface TwitchEmbedAttributes {
152
- src: string;
153
- autoplay?: boolean;
154
- muted?: boolean;
155
- time?: string;
153
+ src: string;
154
+ autoplay?: boolean;
155
+ muted?: boolean;
156
+ time?: string;
156
157
  }
157
158
  /**
158
159
  * Extracts the video, clip or channel identifier from a Twitch URL
@@ -173,8 +174,8 @@ interface TwitchEmbedAttributes {
173
174
  * ```
174
175
  */
175
176
  declare const getTwitchIdentifier: (url: string) => {
176
- type: "video" | "clip" | "channel";
177
- id: string;
177
+ type: "video" | "clip" | "channel";
178
+ id: string;
178
179
  } | null;
179
180
  /**
180
181
  * Generates an embed URL from a Twitch video, clip or channel URL with optional parameters
@@ -224,5 +225,6 @@ declare const getEmbedUrlFromTwitchUrl: (options: GetEmbedUrlOptions) => string
224
225
  * ```
225
226
  */
226
227
  declare const getAttributesFromTwitchEmbedUrl: (url: string) => TwitchEmbedAttributes | null;
227
-
228
- export { type GetEmbedUrlOptions, TWITCH_REGEX, TWITCH_REGEX_GLOBAL, Twitch, type TwitchEmbedAttributes, type TwitchOptions, Twitch as default, getAttributesFromTwitchEmbedUrl, getEmbedUrlFromTwitchUrl, getTwitchIdentifier, isValidTwitchUrl };
228
+ //#endregion
229
+ export { GetEmbedUrlOptions, TWITCH_REGEX, TWITCH_REGEX_GLOBAL, Twitch, Twitch as default, TwitchEmbedAttributes, TwitchOptions, getAttributesFromTwitchEmbedUrl, getEmbedUrlFromTwitchUrl, getTwitchIdentifier, isValidTwitchUrl };
230
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/twitch.ts","../src/utils.ts"],"mappings":";;UA2CiB;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;;;EAQA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA,gBAAgB;;;;;;EAOhB;;;;;KAMG;EACH;EACA;EACA;EACA;EACA;EACA;;;YAIU,SAAS;IACjB;;;;;;MAME,iBAAiB,SAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;cA2B7C,QAAM,KAAA;;;;;;;;;;;;;;;cCvJN,cAAY;cAGZ,qBAAmB;;;;;;;;;;;;;;;;cAkBnB,mBAAoB,gBAAW;UAI3B;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;cAqBW,sBACX;EACG;EAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyE5B,2BAA4B,SAAS;;;;;;;;;;;;;;;;cA4FrC,kCAAmC,gBAAc"}
package/dist/index.d.ts CHANGED
@@ -1,90 +1,90 @@
1
- import { Node } from '@tiptap/core';
2
-
1
+ import { Node } from "@tiptap/core";
2
+ //#region src/twitch.d.ts
3
3
  interface TwitchOptions {
4
- /**
5
- * Controls if the paste handler for Twitch videos should be added.
6
- * @default true
7
- * @example false
8
- */
9
- addPasteHandler: boolean;
10
- /**
11
- * Controls if the Twitch video should be allowed to go fullscreen.
12
- * @default true
13
- * @example false
14
- */
15
- allowFullscreen: boolean;
16
- /**
17
- * Controls if the Twitch video should autoplay.
18
- * @default false
19
- * @example true
20
- */
21
- autoplay: boolean;
22
- /**
23
- * Controls if the Twitch video should start muted.
24
- * @default false
25
- * @example true
26
- */
27
- muted: boolean;
28
- /**
29
- * The time in the video where playback starts (format: 1h2m3s).
30
- * Only works for video embeds, not for clips or channels.
31
- * @default undefined
32
- * @example '1h2m3s'
33
- */
34
- time?: string;
35
- /**
36
- * The parent domain for the Twitch embed. Required for embed functionality.
37
- * @default 'localhost'
38
- * @example 'example.com'
39
- */
40
- parent: string;
41
- /**
42
- * The height of the Twitch video.
43
- * @default 480
44
- * @example 720
45
- */
46
- height: number;
47
- /**
48
- * The width of the Twitch video.
49
- * @default 640
50
- * @example 1280
51
- */
52
- width: number;
53
- /**
54
- * The HTML attributes for a Twitch video node.
55
- * @default {}
56
- * @example { class: 'foo' }
57
- */
58
- HTMLAttributes: Record<string, any>;
59
- /**
60
- * Controls if the Twitch node should be inline or not.
61
- * @default false
62
- * @example true
63
- */
64
- inline: boolean;
4
+ /**
5
+ * Controls if the paste handler for Twitch videos should be added.
6
+ * @default true
7
+ * @example false
8
+ */
9
+ addPasteHandler: boolean;
10
+ /**
11
+ * Controls if the Twitch video should be allowed to go fullscreen.
12
+ * @default true
13
+ * @example false
14
+ */
15
+ allowFullscreen: boolean;
16
+ /**
17
+ * Controls if the Twitch video should autoplay.
18
+ * @default false
19
+ * @example true
20
+ */
21
+ autoplay: boolean;
22
+ /**
23
+ * Controls if the Twitch video should start muted.
24
+ * @default false
25
+ * @example true
26
+ */
27
+ muted: boolean;
28
+ /**
29
+ * The time in the video where playback starts (format: 1h2m3s).
30
+ * Only works for video embeds, not for clips or channels.
31
+ * @default undefined
32
+ * @example '1h2m3s'
33
+ */
34
+ time?: string;
35
+ /**
36
+ * The parent domain for the Twitch embed. Required for embed functionality.
37
+ * @default 'localhost'
38
+ * @example 'example.com'
39
+ */
40
+ parent: string;
41
+ /**
42
+ * The height of the Twitch video.
43
+ * @default 480
44
+ * @example 720
45
+ */
46
+ height: number;
47
+ /**
48
+ * The width of the Twitch video.
49
+ * @default 640
50
+ * @example 1280
51
+ */
52
+ width: number;
53
+ /**
54
+ * The HTML attributes for a Twitch video node.
55
+ * @default {}
56
+ * @example { class: 'foo' }
57
+ */
58
+ HTMLAttributes: Record<string, any>;
59
+ /**
60
+ * Controls if the Twitch node should be inline or not.
61
+ * @default false
62
+ * @example true
63
+ */
64
+ inline: boolean;
65
65
  }
66
66
  /**
67
67
  * The options for setting a Twitch video.
68
68
  */
69
69
  type SetTwitchVideoOptions = {
70
- src: string;
71
- width?: number;
72
- height?: number;
73
- autoplay?: boolean;
74
- muted?: boolean;
75
- time?: string;
70
+ src: string;
71
+ width?: number;
72
+ height?: number;
73
+ autoplay?: boolean;
74
+ muted?: boolean;
75
+ time?: string;
76
76
  };
77
77
  declare module '@tiptap/core' {
78
- interface Commands<ReturnType> {
79
- twitch: {
80
- /**
81
- * Insert a Twitch video
82
- * @param options The Twitch video attributes
83
- * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })
84
- */
85
- setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType;
86
- };
87
- }
78
+ interface Commands<ReturnType> {
79
+ twitch: {
80
+ /**
81
+ * Insert a Twitch video
82
+ * @param options The Twitch video attributes
83
+ * @example editor.commands.setTwitchVideo({ src: 'https://www.twitch.tv/videos/1234567890' })
84
+ */
85
+ setTwitchVideo: (options: SetTwitchVideoOptions) => ReturnType;
86
+ };
87
+ }
88
88
  }
89
89
  /**
90
90
  * This extension adds support for Twitch videos.
@@ -109,7 +109,8 @@ declare module '@tiptap/core' {
109
109
  * ```
110
110
  */
111
111
  declare const Twitch: Node<TwitchOptions, any>;
112
-
112
+ //#endregion
113
+ //#region src/utils.d.ts
113
114
  /**
114
115
  * Regex patterns for matching Twitch URLs
115
116
  * Matches:
@@ -141,18 +142,18 @@ declare const TWITCH_REGEX_GLOBAL: RegExp;
141
142
  */
142
143
  declare const isValidTwitchUrl: (url: string) => RegExpMatchArray | null;
143
144
  interface GetEmbedUrlOptions {
144
- url: string;
145
- allowFullscreen?: boolean;
146
- autoplay?: boolean;
147
- muted?: boolean;
148
- time?: string;
149
- parent?: string;
145
+ url: string;
146
+ allowFullscreen?: boolean;
147
+ autoplay?: boolean;
148
+ muted?: boolean;
149
+ time?: string;
150
+ parent?: string;
150
151
  }
151
152
  interface TwitchEmbedAttributes {
152
- src: string;
153
- autoplay?: boolean;
154
- muted?: boolean;
155
- time?: string;
153
+ src: string;
154
+ autoplay?: boolean;
155
+ muted?: boolean;
156
+ time?: string;
156
157
  }
157
158
  /**
158
159
  * Extracts the video, clip or channel identifier from a Twitch URL
@@ -173,8 +174,8 @@ interface TwitchEmbedAttributes {
173
174
  * ```
174
175
  */
175
176
  declare const getTwitchIdentifier: (url: string) => {
176
- type: "video" | "clip" | "channel";
177
- id: string;
177
+ type: "video" | "clip" | "channel";
178
+ id: string;
178
179
  } | null;
179
180
  /**
180
181
  * Generates an embed URL from a Twitch video, clip or channel URL with optional parameters
@@ -224,5 +225,6 @@ declare const getEmbedUrlFromTwitchUrl: (options: GetEmbedUrlOptions) => string
224
225
  * ```
225
226
  */
226
227
  declare const getAttributesFromTwitchEmbedUrl: (url: string) => TwitchEmbedAttributes | null;
227
-
228
- export { type GetEmbedUrlOptions, TWITCH_REGEX, TWITCH_REGEX_GLOBAL, Twitch, type TwitchEmbedAttributes, type TwitchOptions, Twitch as default, getAttributesFromTwitchEmbedUrl, getEmbedUrlFromTwitchUrl, getTwitchIdentifier, isValidTwitchUrl };
228
+ //#endregion
229
+ export { GetEmbedUrlOptions, TWITCH_REGEX, TWITCH_REGEX_GLOBAL, Twitch, Twitch as default, TwitchEmbedAttributes, TwitchOptions, getAttributesFromTwitchEmbedUrl, getEmbedUrlFromTwitchUrl, getTwitchIdentifier, isValidTwitchUrl };
230
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/twitch.ts","../src/utils.ts"],"mappings":";;UA2CiB;;;;;;EAMf;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;;;EAQA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA;;;;;;EAOA,gBAAgB;;;;;;EAOhB;;;;;KAMG;EACH;EACA;EACA;EACA;EACA;EACA;;;YAIU,SAAS;IACjB;;;;;;MAME,iBAAiB,SAAS,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;cA2B7C,QAAM,KAAA;;;;;;;;;;;;;;;cCvJN,cAAY;cAGZ,qBAAmB;;;;;;;;;;;;;;;;cAkBnB,mBAAoB,gBAAW;UAI3B;EACf;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf;EACA;EACA;EACA;;;;;;;;;;;;;;;;;;;;cAqBW,sBACX;EACG;EAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAyE5B,2BAA4B,SAAS;;;;;;;;;;;;;;;;cA4FrC,kCAAmC,gBAAc"}