Docs menu
Edit Post
Open an existing post in the editor.
editPost opens the editor on a post that already exists — one made through the API, or one your user published earlier.
Usage
gnr.on("ready", () => {
gnr.editPost({
post_id: "POST_ID", // from the API's post_ids, or from onPostPublish
onPostPublish: function (err, data) {
if (err) console.error("Could not update:", err);
else console.log("Updated:", data);
},
});
});
gnr.initialize({ appId: "YOUR_APP_ID", embedToken: "SSO_TOKEN" });What it needs
A post_id, and an embedToken in initialize for the user who owns the post. A user can only open their own posts.
What it does not do
editPost opens one post; it does not show the create screen. A common pattern: make posts with the API, then let users fine-tune them with editPost.
Complete example
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>GNR AI SDK</title>
<script type="text/javascript" src="https://gnraisolutions.com/sdk/embed.js" async defer crossorigin="anonymous"></script>
</head>
<body>
<button id="open-editor">Edit post</button>
<script type="text/javascript">
document.getElementById("open-editor").addEventListener("click", function () {
const gnr = new window.GNR();
gnr.on("ready", () => {
gnr.editPost({
post_id: "YOUR_POST_ID",
onPostPublish: function (err, data) {
if (err) return console.error("Could not update:", err);
console.log("Updated:", data);
},
});
});
gnr.on("error", (error) => console.error("SDK error:", error));
gnr.initialize({
appId: "YOUR_APP_ID",
embedToken: "SSO_TOKEN_FROM_YOUR_SERVER",
});
});
</script>
</body>
</html>