@thebigcrunch/sdk
Version:
The big crunch SDK library
45 lines (37 loc) • 885 B
JavaScript
import { crunch } from "./crunch";
const commands = {
SET_VALUE: "setValue",
SET_TITLE: "setTitle"
};
const setValue = function setValue(value, position, contentType = "text/text") {
window.parent.postMessage(
{
command: commands.SET_VALUE,
value,
contentType,
position
},
`*`
);
};
const setEditorTitle = function setEditorTitle(title) {
window.parent.postMessage(
{
command: commands.SET_TITLE,
title
},
`*`
);
};
const edit = function edit(title, cellToEditCallback) {
setEditorTitle(title);
const url = new URLSearchParams(window.location.search);
const editingSpace = url.get("editing");
crunch(editingSpace, cellToEditCallback);
};
const editor = {
setValue,
commands,
edit
};
export default editor;