import { NodeViewWrapper, NodeViewContent } from "@tiptap/react"; import { useCallback } from "react"; import type { NodeViewProps } from "@tiptap/react"; const GAP_MAP: Record = { small: "8px", medium: "16px", large: "24px", }; const LAYOUT_OPTIONS = ["2-column", "3-column", "4-column"]; const GAP_OPTIONS = ["small", "medium", "large"]; export function StackView({ node, updateAttributes, editor, getPos }: NodeViewProps) { const layout = (node.attrs.layout as string) || "2-column"; const gap = (node.attrs.gap as string) || "medium"; const colCount = parseInt(layout) || 2; const handleLayoutChange = useCallback( (e: React.ChangeEvent) => { const newLayout = e.target.value; const newColCount = parseInt(newLayout) || 2; const pos = getPos(); if (typeof pos === "number") { editor.commands.setStackColumns(pos, newColCount); } }, [editor, getPos], ); const handleGapChange = useCallback( (e: React.ChangeEvent) => updateAttributes({ gap: e.target.value }), [updateAttributes], ); return (
Stack
); }