import { type Editor } from '@tiptap/react';

/** TipTap node name shared by all inline media (img / video / iframe). */
export const RESIZABLE_MEDIA_NODE = 'resizable-media';

/** Media variants the `resizable-media` node renders, keyed by its `tag` attr. */
export type MediaTag = 'img' | 'video' | 'iframe';

/** Whether the current selection is a `resizable-media` node of the given tag. */
export const isMediaActive = (
  editor: Editor | null | undefined,
  tag: MediaTag,
): boolean => !!editor?.isActive(RESIZABLE_MEDIA_NODE, { tag });
