"use client";

import {useEffect,useRef} from "react";
import grapesjs from "grapesjs";
import "grapesjs/dist/css/grapes.min.css";
import "grapesjs-preset-webpage";

export default function ProductionVisualBuilder(){

const editorRef=useRef(null);

useEffect(()=>{

if(editorRef.current)return;

editorRef.current=grapesjs.init({

container:"#gjs",

height:"100vh",

storageManager:false,

plugins:["grapesjs-preset-webpage"],

deviceManager:{
devices:[
{name:"Desktop",width:""},
{name:"Tablet",width:"768px"},
{name:"Mobile",width:"375px"}
]
}

});

return()=>{
editorRef.current?.destroy();
};

},[]);

return <div id="gjs" style={{height:"100vh"}}/>;

}
