'use client' import type { RawContentMatch } from '@admin/utils/editor/raw-content-match' import { rawHtmlBlockTags } from '@admin/utils/editor/raw-html-block-tags' import { selfClosingHtmlBlockTags } from '@admin/utils/editor/self-closing-html-block-tags' export function matchHtmlBlock(src: string): RawContentMatch | null { const pairedTagMatch = new RegExp( `^<(${rawHtmlBlockTags})\\b[\\s\\S]*?<\\/\\1>[ \\t]*(?:\\n|$)`, 'i' ).exec(src) if (pairedTagMatch) { return { kind: 'html', raw: pairedTagMatch[0].trimEnd() } } const selfClosingMatch = new RegExp( `^<(${selfClosingHtmlBlockTags})\\b[^>]*(?:\\/?>)[ \\t]*(?:\\n|$)`, 'i' ).exec(src) if (!selfClosingMatch) return null return { kind: 'html', raw: selfClosingMatch[0].trimEnd() } }