diff --git a/packages/frame/src/runtime/executor/lib/autoForm/FormField.tsx b/packages/frame/src/runtime/executor/lib/autoForm/FormField.tsx index 29b97a53..dbf5591c 100644 --- a/packages/frame/src/runtime/executor/lib/autoForm/FormField.tsx +++ b/packages/frame/src/runtime/executor/lib/autoForm/FormField.tsx @@ -8,8 +8,8 @@ import DropdownMenu, { DropdownItemRadio, DropdownItemRadioGroup, } from "@atlaskit/dropdown-menu"; -import { Field } from "@atlaskit/form"; -import { VscEllipsis } from "react-icons/vsc"; +import { Field, HelperMessage } from "@atlaskit/form"; +import { VscArrowCircleUp, VscEllipsis } from "react-icons/vsc"; import MonacoEdit from "./MonacoEdit"; export const FormField = observer( @@ -28,6 +28,14 @@ export const FormField = observer( const { inputObject, fieldKey } = props; const currentValue = inputObject[fieldKey]; + let currentStringified = ""; + + try { + currentStringified = JSON.stringify(currentValue); + } catch (e) { + // noop + } + let currentParsedBinding: string | number | undefined; if (props.value !== undefined) { @@ -65,6 +73,10 @@ export const FormField = observer( onChange={(e) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any const newVal = (e.target as any).value; + if (newVal === "") { + props.setValue(undefined); + return; + } props.setValue(`export default ${JSON.stringify(newVal)};`); }} /> @@ -79,8 +91,16 @@ export const FormField = observer( value={currentParsedBinding || ""} onChange={(e) => { // eslint-disable-next-line @typescript-eslint/no-explicit-any - const newVal = parseFloat((e.target as any).value); - props.setValue(`export default ${JSON.stringify(newVal)};`); + const newVal = (e.target as any).value; + + if (newVal === "") { + props.setValue(undefined); + return; + } + + props.setValue( + `export default ${JSON.stringify(parseFloat(newVal))};`, + ); }} /> ); @@ -144,6 +164,16 @@ export const FormField = observer( + + + Current: {currentStringified} + )} diff --git a/packages/frame/src/runtime/executor/lib/exports.tsx b/packages/frame/src/runtime/executor/lib/exports.tsx index d42c6c55..d8e1eb89 100644 --- a/packages/frame/src/runtime/executor/lib/exports.tsx +++ b/packages/frame/src/runtime/executor/lib/exports.tsx @@ -140,6 +140,10 @@ export default function getExposeGlobalVariables( settings={editor.currentBlock.storage.settings || {}} setSetting={(key: string, value: any) => { runInAction(() => { + if (!editor.currentBlock.storage.settings) { + // TODO: might not be compatible with Yjs + editor.currentBlock.storage.settings = {}; + } editor.currentBlock.storage.settings[key] = value; }); }}