From daaba6325d8d810a6258b80679949a7ebcc7f4f0 Mon Sep 17 00:00:00 2001 From: Kartik Gupta Date: Thu, 7 Nov 2024 21:40:41 +0530 Subject: [PATCH] pass custom resolvables as custom variables in codeeditor --- .../AppBuilder/CodeEditor/SingleLineCodeEditor.jsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx index 09b7d84a43..76dcae3c7a 100644 --- a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx @@ -30,6 +30,12 @@ const SingleLineCodeEditor = ({ componentName, fieldMeta = {}, componentId, ...r const [currentValue, setCurrentValue] = useState(''); const [errorStateActive, setErrorStateActive] = useState(false); const [cursorInsidePreview, setCursorInsidePreview] = useState(false); + const componentDefinition = useStore((state) => state.getComponentDefinition(componentId), shallow); + const parentId = componentDefinition?.component?.parent; + const customResolvables = useStore((state) => state.resolvedStore.modules.canvas?.customResolvables, shallow); + + const customVariables = customResolvables?.[parentId]?.[0] || {}; + const isPreviewFocused = useRef(false); const wrapperRef = useRef(null); @@ -52,8 +58,10 @@ const SingleLineCodeEditor = ({ componentName, fieldMeta = {}, componentId, ...r // ? resolveReferences(newInitialValue, validation, customVariables) // : [true, null]; - // Need to add customVariables while resolving the value like above - const [valid, _error] = !isEmpty(validation) ? resolveReferences(newInitialValue, validation) : [true, null]; + //!TODO use the updated new resolver + const [valid, _error] = !isEmpty(validation) + ? resolveReferences(newInitialValue, validation, customVariables) + : [true, null]; if (!valid) { setErrorStateActive(true); @@ -90,6 +98,7 @@ const SingleLineCodeEditor = ({ componentName, fieldMeta = {}, componentId, ...r style={{ width: '100%', height: restProps?.lang === 'jsx' && '320px' }} >