diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor.tsx index a3c2552b45..2ae7fec78d 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/code-editor.tsx @@ -28,6 +28,7 @@ const CodeEditor: FC = ({ const { theme } = useTheme() const monacoRef = useRef(null) const editorRef = useRef(null) + const containerRef = useRef(null) useEffect(() => { if (monacoRef.current) { @@ -74,6 +75,19 @@ const CodeEditor: FC = ({ onUpdate?.(value) }, [onUpdate]) + useEffect(() => { + const resizeObserver = new ResizeObserver(() => { + editorRef.current?.layout() + }) + + if (containerRef.current) + resizeObserver.observe(containerRef.current) + + return () => { + resizeObserver.disconnect() + } + }, []) + return (
@@ -102,9 +116,11 @@ const CodeEditor: FC = ({
-
+
= ({ scrollBeyondLastLine: false, wordWrap: 'on', wrappingIndent: 'same', - // Add these options overviewRulerBorder: false, hideCursorInOverviewRuler: true, renderLineHighlightOnlyWhenFocus: false, diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx index 344d02c011..2b8574b285 100644 --- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx +++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/json-schema-config.tsx @@ -21,7 +21,7 @@ import { MittProvider, VisualEditorContextProvider, useMittContext } from './vis import ErrorMessage from './error-message' import { useVisualEditorStore } from './visual-editor/store' import Toast from '@/app/components/base/toast' -import { useGetLanguage } from '@/context/i18n' +import { useGetDocLanguage } from '@/context/i18n' import { JSON_SCHEMA_MAX_DEPTH } from '@/config' type JsonSchemaConfigProps = { @@ -47,21 +47,13 @@ const DEFAULT_SCHEMA: SchemaRoot = { additionalProperties: false, } -const HELP_DOC_URL = { - zh_Hans: 'https://docs.dify.ai/zh-hans/guides/workflow/structured-outputs', - en_US: 'https://docs.dify.ai/en/guides/workflow/structured-outputs', - ja_JP: 'https://docs.dify.ai/ja-jp/guides/workflow/structured-outputs', -} - -type LocaleKey = keyof typeof HELP_DOC_URL - const JsonSchemaConfig: FC = ({ defaultSchema, onSave, onClose, }) => { const { t } = useTranslation() - const locale = useGetLanguage() as LocaleKey + const docLanguage = useGetDocLanguage() const [currentTab, setCurrentTab] = useState(SchemaView.VisualEditor) const [jsonSchema, setJsonSchema] = useState(defaultSchema || DEFAULT_SCHEMA) const [json, setJson] = useState(JSON.stringify(jsonSchema, null, 2)) @@ -260,7 +252,7 @@ const JsonSchemaConfig: FC = ({