Skip to content

Commit

Permalink
0.0.115
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Sep 21, 2024
1 parent 08e6186 commit 2ad6f69
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
20 changes: 19 additions & 1 deletion imports/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ export const Editor = React.memo(function Editor({
const [v, setV] = useState(value);
const { colorMode } = useColorMode();
const [lang, setLang] = useState<any>(langs.tsx());
const { data: [ObjectedValue] } = deep.useQuery(linkId ? {
type_id: deep.idLocal('@deep-foundation/core', 'Value'),
to_id: deep.idLocal('@deep-foundation/core', 'Object'),
from: {
typed: { id: linkId },
},
} : {}, { skip: !linkId });
const isObject = !!ObjectedValue;

const _refEditor = useRef();
const eref = refEditor || _refEditor
Expand All @@ -91,7 +99,17 @@ export const Editor = React.memo(function Editor({
const { data: [link] } = useLoad({ id: linkId });

const update = useCallback(async () => {
if (linkId && v?.length > 0) await deep.value(linkId, v);
if (linkId && v?.length > 0) {
let _v = v;
if (isObject) {
try {
_v = JSON.parse(v);
await deep.value(linkId, _v);
} catch(e) {
console.log('go.Editor JSON.parse value', e);
}
} else await deep.value(linkId, _v);
}
onSave && onSave(v)
}, [link, v]);

Expand Down
5 changes: 3 additions & 2 deletions imports/go.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -642,10 +642,10 @@ export const noScrollBar = ((s) => ({

const componentTemplate = ({ children } = { children: null }) => `({ deep, data, require, Go }) => {
const React = require('react');
const c = require('@chakra-ui/react');
const dc = '@deep-foundation/core';
const dpl = '@deep-foundation/perception-links';
const c = require('@chakra-ui/react');
return ({
go,
Expand Down Expand Up @@ -847,7 +847,7 @@ const Input = React.memo(({
...props
}: {
path: [DeepClientStartItem | QueryLink, ...DeepClientPathItem[]],
insert: any;
insert?: any;
title?: any;
type?: 'string' | 'number';

Expand Down Expand Up @@ -890,6 +890,7 @@ const Input = React.memo(({
setSaving(true);
if (!link && !insertedRef.current) {
insertedRef.current = true;
if (!insert) return;
const { data: [inserted] } = await deep.insert({
containerId, name,
[type]: type === 'number' ? +v : v,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/perception-imports",
"version": "0.0.114",
"version": "0.0.115",
"license": "Unlicense",
"type": "module",
"main": "import.js",
Expand Down

0 comments on commit 2ad6f69

Please sign in to comment.