Closed chuteany closed 8 months ago
You can create a new GraphTemplate
using the fromGraph
function:
import { useBaklava, GraphTemplate } from "baklavajs";
const baklava = useBaklava();
const template = GraphTemplate.fromGraph(baklava.editor.graph, baklava.editor);
JSON.stringify(template.save()) // => string that you can save in the database
To load a graph template into other editors:
import { useBaklava, GraphTemplate } from "baklavajs";
const baklava = useBaklava();
const state = JSON.parse("<string from the database>");
const template = new GraphTemplate(state, baklava.editor);
baklava.editor.addGraphTemplate(template);
I have a requirement to convert a graph into a node, save it to the database, and allow others to download this node to add it to the NodePalette for general usage. How can I implement it