2024-10-22 08:01:21 +00:00
|
|
|
/* eslint-disable import/no-unresolved */
|
|
|
|
|
import React, { useContext, useEffect, useMemo, useRef } from 'react';
|
|
|
|
|
import CodeMirror from '@uiw/react-codemirror';
|
|
|
|
|
import { javascript, javascriptLanguage } from '@codemirror/lang-javascript';
|
|
|
|
|
import { defaultKeymap, indentWithTab } from '@codemirror/commands';
|
|
|
|
|
import { keymap } from '@codemirror/view';
|
|
|
|
|
import { completionKeymap, acceptCompletion, autocompletion, completionStatus } from '@codemirror/autocomplete';
|
|
|
|
|
import { python } from '@codemirror/lang-python';
|
|
|
|
|
import { sql } from '@codemirror/lang-sql';
|
2025-03-25 23:11:00 +00:00
|
|
|
import _ from 'lodash';
|
2024-10-22 08:01:21 +00:00
|
|
|
import { sass, sassCompletionSource } from '@codemirror/lang-sass';
|
|
|
|
|
import { okaidia } from '@uiw/codemirror-theme-okaidia';
|
|
|
|
|
import { githubLight } from '@uiw/codemirror-theme-github';
|
2025-07-01 11:19:04 +00:00
|
|
|
import { getSuggestionsForMultiLine } from './autocompleteExtensionConfig';
|
2024-10-22 08:01:21 +00:00
|
|
|
import ErrorBoundary from '@/_ui/ErrorBoundary';
|
|
|
|
|
import CodeHinter from './CodeHinter';
|
|
|
|
|
import { CodeHinterContext } from '../CodeBuilder/CodeHinterContext';
|
|
|
|
|
import { createReferencesLookup } from '@/_stores/utils';
|
|
|
|
|
import { PreviewBox } from './PreviewBox';
|
|
|
|
|
import useStore from '@/AppBuilder/_stores/store';
|
|
|
|
|
import { shallow } from 'zustand/shallow';
|
2025-02-25 06:52:50 +00:00
|
|
|
import { search, searchKeymap, searchPanelOpen } from '@codemirror/search';
|
2025-04-23 15:20:40 +00:00
|
|
|
import { handleSearchPanel } from './SearchBox';
|
2025-03-07 10:04:31 +00:00
|
|
|
import { useQueryPanelKeyHooks } from './useQueryPanelKeyHooks';
|
2025-03-25 23:11:00 +00:00
|
|
|
import { isInsideParent } from './utils';
|
2025-04-23 15:20:40 +00:00
|
|
|
import { CodeHinterBtns } from './CodehinterOverlayTriggers';
|
2025-09-16 18:12:53 +00:00
|
|
|
import useWorkflowStore from '@/_stores/workflowStore';
|
2024-10-22 08:01:21 +00:00
|
|
|
|
|
|
|
|
const langSupport = Object.freeze({
|
|
|
|
|
javascript: javascript(),
|
|
|
|
|
python: python(),
|
|
|
|
|
sql: sql(),
|
|
|
|
|
jsx: javascript({ jsx: true }),
|
|
|
|
|
css: sass(),
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const MultiLineCodeEditor = (props) => {
|
|
|
|
|
const {
|
2025-10-15 12:44:05 +00:00
|
|
|
darkMode,
|
|
|
|
|
height,
|
2024-10-22 08:01:21 +00:00
|
|
|
initialValue,
|
|
|
|
|
lang,
|
|
|
|
|
className,
|
|
|
|
|
onChange,
|
|
|
|
|
componentName,
|
|
|
|
|
lineNumbers,
|
|
|
|
|
placeholder,
|
|
|
|
|
hideSuggestion,
|
|
|
|
|
portalProps,
|
|
|
|
|
showPreview,
|
|
|
|
|
paramLabel = '',
|
|
|
|
|
delayOnChange = true, // Added this prop to immediately update the onBlurUpdate callback
|
|
|
|
|
readOnly = false,
|
|
|
|
|
editable = true,
|
2025-02-25 06:52:50 +00:00
|
|
|
renderCopilot,
|
2025-06-27 14:38:15 +00:00
|
|
|
setCodeEditorView,
|
2025-09-19 06:00:41 +00:00
|
|
|
onInputChange, // Added this prop to immediately handle value changes
|
2024-10-22 08:01:21 +00:00
|
|
|
} = props;
|
2025-07-07 09:41:58 +00:00
|
|
|
const editorRef = useRef(null);
|
2025-10-15 12:44:05 +00:00
|
|
|
|
2024-10-22 08:01:21 +00:00
|
|
|
const replaceIdsWithName = useStore((state) => state.replaceIdsWithName, shallow);
|
2025-03-25 23:11:00 +00:00
|
|
|
const wrapperRef = useRef(null);
|
2024-10-22 08:01:21 +00:00
|
|
|
const getSuggestions = useStore((state) => state.getSuggestions, shallow);
|
2025-06-27 14:38:15 +00:00
|
|
|
const getServerSideGlobalResolveSuggestions = useStore(
|
2025-10-15 12:44:05 +00:00
|
|
|
(state) => state.getServerSideGlobalResolveSuggestions,
|
|
|
|
|
shallow
|
2025-06-27 14:38:15 +00:00
|
|
|
);
|
2025-04-01 20:41:13 +00:00
|
|
|
|
2025-02-25 06:52:50 +00:00
|
|
|
const isInsideQueryPane = !!document.querySelector('.code-hinter-wrapper')?.closest('.query-details');
|
2025-03-25 23:11:00 +00:00
|
|
|
const isInsideQueryManager = useMemo(
|
2025-10-15 12:44:05 +00:00
|
|
|
() => isInsideParent(wrapperRef?.current, 'query-manager'),
|
|
|
|
|
[wrapperRef.current]
|
2025-03-25 23:11:00 +00:00
|
|
|
);
|
2024-10-22 08:01:21 +00:00
|
|
|
|
|
|
|
|
const context = useContext(CodeHinterContext);
|
|
|
|
|
|
2025-09-16 18:12:53 +00:00
|
|
|
const { workflowSuggestions } = useWorkflowStore((state) => ({ workflowSuggestions: state.suggestions }), shallow);
|
2025-06-27 00:09:07 +00:00
|
|
|
|
2025-01-20 10:53:37 +00:00
|
|
|
const { suggestionList: paramList } = createReferencesLookup(context, true);
|
2024-10-22 08:01:21 +00:00
|
|
|
|
|
|
|
|
const currentValueRef = useRef(initialValue);
|
|
|
|
|
|
2025-02-25 06:52:50 +00:00
|
|
|
const [editorView, setEditorView] = React.useState(null);
|
|
|
|
|
|
2025-04-23 15:20:40 +00:00
|
|
|
const [isSearchPanelOpen, setIsSearchPanelOpen] = React.useState(false);
|
2025-03-07 10:04:31 +00:00
|
|
|
const { queryPanelKeybindings } = useQueryPanelKeyHooks(onChange, currentValueRef, 'multiline');
|
2025-04-23 15:20:40 +00:00
|
|
|
|
Custom themes (#13064)
* feat: Add CSA and functionalities for managing loading, visibility, and disable states for full tab component. (#11267)
* feat: tab draggble option and popover menu (#11267)
* feat: tab scrollable arrows and tabItem logic(#11267)
* feat: remove logs(#11267)
* feat: Tabslayout name change(#11267)
* fix: component update on Tabs
* fix: tab text color update
* feat: setTabDisable CSA added(#11267)
* feat: added CSA for tab specific changes(#11267)
* feat: added handle function for tab specific changes(#11267)
* feat: shimmer for tab nav and icon chooser (#11267)
* feat: icon for each tab in TabNav items (#11267)
* feat: equal split width fix for each tab in TabNav items (#11267)
* feat: styles for Tab Nav (#11267)
* feat: slide options(#11267)
* feat: fix radius (#11267)
* feat: slider (#11267)
* feat: fix slide direction (#11267)
* feat: fix slide direction 2 (#11267)
* feat: fix styles right side inspector view (#11267)
* feat: nav ellipsis ... (#11267)
* feat: children different for dynamic and non-dynamic (#11267)
* feat:[tabsLayout] change default values in config (#11267)
* feat:[tabsLayout] split and auto fix (#11267)
* feat: fix styles accent and text (#11267)
* feat: fix styles divider and more 2(#11267)
* feat: fix styles divider and more 3(#11267)
* feat: fix styles 4(#11267)
* feat: fix styles 5(#11267)
* feat: fix tab icon visibility 6 (#11267)
* feat: modify name of property from id to Tab 7(#11267)
* fixes and changes
* fix: csa for tabs
* new changes and fixes
* fix: dynamic options sytling
* v2 changes
* add: new properties and styles to inspector for range slider
* fixes of range slider
* fix: styling
* fix: styling of icons
* fixed endvalue and startvalue problem
* ColorSwatches for table
* fix: styling
* transition effect fix
* fix: properties and migration
* fix: slider functionality
* fixed transition
* new changes
* visible,disable,loading,width
* feat: merge appbuilder/sprint-11 with main
* fix: styling
* style: extend tabpane background to whole pane
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable' -m 'Changes done for: Currency, Email, Phone Number & ModalV2 component
* review changes
* fix: tinycolor import
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Date, Time, DateTime & Date Range Picker components
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Form, Textarea & Horizontal Divider component
* Fix: Add default selected value config for Header & Footer Background Color input field for Form component so that its shows correct color demo & its value
* Fix: Resolved custom theming issues in different components
* feat: Revamps file uploader widget
* Fixes added
* Custom theme extra code for extra components
* Submodule commit change
* Submodule commit change
* Textinput theming added
* Number input theming added
* Email & Password Theming added
* Textarea theming added
* Error system status added along with rating theming
* ToggleV2 theming added
* Toggle, RadioButton & Error related theming added
* Checkbox Theming added
* Dropdown V2 and legacy theming added
* Multiselect V2 theming added
* Adding ux friendly error messages
* Misc1 and Misc 2 theming added
* Multiselect legacy theming added
* Form components theming added
* Subcontainer related issues
* Subcontainers theming added
* Tabs theming added
* Filepicker theming added
* Range slider theming added
* Steps theming added
* Submodule update
* Package update
* Added Header text, background and container background color
* Submodule Update
* Submodule update
* Submodule update
* Submodule update
* Hover effect added
* feat: Revamps file uploader widget
* Adding ux friendly error messages
* Adds style tab
* Adds min file validation
* Reset vs code
* Adds support for theme
* Base theme added
* Base theme added
* Base theme added
* initial commit
* fix
* Fixes
* Submodule update
* Added auto color assign feature for multiselect/select in table
* Table column popover going out of bounds fix
* Changed layout of component manager
* DropdownV2 added to selectInputs
* HTML column data type added
* Table column icons added
* Fix dropping widget width while dragging
* Changed datepicker icon and added icons to table dropdown
* Style: Update Accordion Component UI
* Temp changes
* Fix group selection in form
* fix when dropping a component, shadow is coming on top of component manager.
* improve performace on useGroupedTargetsScrollHandler
* Fix
* Review fixes
* Minor changes
* chore: update submodule references
* Color swatches added icon/default and added disabled/loading state
* Submodule update
* Bugs solved
* Fixes for Component sidebar
* Custom theme related bug fixes
* App Background Switch added
* Submodule update
* Submodule update
* HTML fixes
* Submodule update
* Query breaking on Symbol fix
* Import export property migration for Rangepicker & Textarea
* Auto color pills not working for table select fix
* Custom themes minor bugs
* Submodule update
* Minor fixes
* Revamp pages in editor and viewer
* bug fixes
* merge base
* fix conflicts
* fix conflicts
* bug fixes
* Added swatches to page menu
* Submodule update
* Submodule update
* Submodule update
* Styling fixes
* Changed few page styles
* bug fixes
* fix: pages icon and layout for right sidebar
* fix: styling for pages menu
* fix base styling
* merge base
* bug fixes
* Bug fixes
* Submodule update
* Submodules updated
* bug fixes
* fix top styling of nav bar
* Sass loader error fix
* styles: correct styles to match the dsigns
* Accordion design added with some minor styling fixes
* fix: update default supported file of filepicker to any
* fix: update styles mismatches
* fix: hide min and max file count if multi file select is disabled
* TJ Default changed to Tooljet Migration
* Multiline code editor suggestions now close when out of view
* add border to canvas
* Dark theme link color fix for html column type
* Spinner color fix
* bug fixes
* bug fixes
* Submodules updated
* update reference
* Submodule update
---------
Co-authored-by: Raman Kumar <k.raman1998@yahoo.in>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: TaruunMalik <taruunrmalik09@gmail.com>
Co-authored-by: johnsoncherian <johnsonc.dev@gmail.com>
Co-authored-by: NishidhJain11 <nishidh@tooljet.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Nakul Nagargade <nakul@tooljet.com>
2025-06-27 12:42:34 +00:00
|
|
|
// Add state for tracking autocomplete visibility
|
|
|
|
|
const [showSuggestions, setShowSuggestions] = React.useState(true);
|
|
|
|
|
const currentLineObserverRef = useRef(null);
|
|
|
|
|
const isObserverTriggeredRef = useRef(false);
|
|
|
|
|
|
|
|
|
|
// Intersection observer to detect when current line goes out of view
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const observer = new IntersectionObserver(
|
2025-10-15 12:44:05 +00:00
|
|
|
([entry]) => {
|
|
|
|
|
if (entry.intersectionRatio < 1) {
|
|
|
|
|
setShowSuggestions(false);
|
|
|
|
|
isObserverTriggeredRef.current = true;
|
|
|
|
|
// Close autocomplete dropdown by dispatching a selection change
|
|
|
|
|
if (editorView) {
|
|
|
|
|
editorView.dispatch({
|
|
|
|
|
selection: editorView.state.selection,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setShowSuggestions(true);
|
|
|
|
|
isObserverTriggeredRef.current = false;
|
Custom themes (#13064)
* feat: Add CSA and functionalities for managing loading, visibility, and disable states for full tab component. (#11267)
* feat: tab draggble option and popover menu (#11267)
* feat: tab scrollable arrows and tabItem logic(#11267)
* feat: remove logs(#11267)
* feat: Tabslayout name change(#11267)
* fix: component update on Tabs
* fix: tab text color update
* feat: setTabDisable CSA added(#11267)
* feat: added CSA for tab specific changes(#11267)
* feat: added handle function for tab specific changes(#11267)
* feat: shimmer for tab nav and icon chooser (#11267)
* feat: icon for each tab in TabNav items (#11267)
* feat: equal split width fix for each tab in TabNav items (#11267)
* feat: styles for Tab Nav (#11267)
* feat: slide options(#11267)
* feat: fix radius (#11267)
* feat: slider (#11267)
* feat: fix slide direction (#11267)
* feat: fix slide direction 2 (#11267)
* feat: fix styles right side inspector view (#11267)
* feat: nav ellipsis ... (#11267)
* feat: children different for dynamic and non-dynamic (#11267)
* feat:[tabsLayout] change default values in config (#11267)
* feat:[tabsLayout] split and auto fix (#11267)
* feat: fix styles accent and text (#11267)
* feat: fix styles divider and more 2(#11267)
* feat: fix styles divider and more 3(#11267)
* feat: fix styles 4(#11267)
* feat: fix styles 5(#11267)
* feat: fix tab icon visibility 6 (#11267)
* feat: modify name of property from id to Tab 7(#11267)
* fixes and changes
* fix: csa for tabs
* new changes and fixes
* fix: dynamic options sytling
* v2 changes
* add: new properties and styles to inspector for range slider
* fixes of range slider
* fix: styling
* fix: styling of icons
* fixed endvalue and startvalue problem
* ColorSwatches for table
* fix: styling
* transition effect fix
* fix: properties and migration
* fix: slider functionality
* fixed transition
* new changes
* visible,disable,loading,width
* feat: merge appbuilder/sprint-11 with main
* fix: styling
* style: extend tabpane background to whole pane
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable' -m 'Changes done for: Currency, Email, Phone Number & ModalV2 component
* review changes
* fix: tinycolor import
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Date, Time, DateTime & Date Range Picker components
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Form, Textarea & Horizontal Divider component
* Fix: Add default selected value config for Header & Footer Background Color input field for Form component so that its shows correct color demo & its value
* Fix: Resolved custom theming issues in different components
* feat: Revamps file uploader widget
* Fixes added
* Custom theme extra code for extra components
* Submodule commit change
* Submodule commit change
* Textinput theming added
* Number input theming added
* Email & Password Theming added
* Textarea theming added
* Error system status added along with rating theming
* ToggleV2 theming added
* Toggle, RadioButton & Error related theming added
* Checkbox Theming added
* Dropdown V2 and legacy theming added
* Multiselect V2 theming added
* Adding ux friendly error messages
* Misc1 and Misc 2 theming added
* Multiselect legacy theming added
* Form components theming added
* Subcontainer related issues
* Subcontainers theming added
* Tabs theming added
* Filepicker theming added
* Range slider theming added
* Steps theming added
* Submodule update
* Package update
* Added Header text, background and container background color
* Submodule Update
* Submodule update
* Submodule update
* Submodule update
* Hover effect added
* feat: Revamps file uploader widget
* Adding ux friendly error messages
* Adds style tab
* Adds min file validation
* Reset vs code
* Adds support for theme
* Base theme added
* Base theme added
* Base theme added
* initial commit
* fix
* Fixes
* Submodule update
* Added auto color assign feature for multiselect/select in table
* Table column popover going out of bounds fix
* Changed layout of component manager
* DropdownV2 added to selectInputs
* HTML column data type added
* Table column icons added
* Fix dropping widget width while dragging
* Changed datepicker icon and added icons to table dropdown
* Style: Update Accordion Component UI
* Temp changes
* Fix group selection in form
* fix when dropping a component, shadow is coming on top of component manager.
* improve performace on useGroupedTargetsScrollHandler
* Fix
* Review fixes
* Minor changes
* chore: update submodule references
* Color swatches added icon/default and added disabled/loading state
* Submodule update
* Bugs solved
* Fixes for Component sidebar
* Custom theme related bug fixes
* App Background Switch added
* Submodule update
* Submodule update
* HTML fixes
* Submodule update
* Query breaking on Symbol fix
* Import export property migration for Rangepicker & Textarea
* Auto color pills not working for table select fix
* Custom themes minor bugs
* Submodule update
* Minor fixes
* Revamp pages in editor and viewer
* bug fixes
* merge base
* fix conflicts
* fix conflicts
* bug fixes
* Added swatches to page menu
* Submodule update
* Submodule update
* Submodule update
* Styling fixes
* Changed few page styles
* bug fixes
* fix: pages icon and layout for right sidebar
* fix: styling for pages menu
* fix base styling
* merge base
* bug fixes
* Bug fixes
* Submodule update
* Submodules updated
* bug fixes
* fix top styling of nav bar
* Sass loader error fix
* styles: correct styles to match the dsigns
* Accordion design added with some minor styling fixes
* fix: update default supported file of filepicker to any
* fix: update styles mismatches
* fix: hide min and max file count if multi file select is disabled
* TJ Default changed to Tooljet Migration
* Multiline code editor suggestions now close when out of view
* add border to canvas
* Dark theme link color fix for html column type
* Spinner color fix
* bug fixes
* bug fixes
* Submodules updated
* update reference
* Submodule update
---------
Co-authored-by: Raman Kumar <k.raman1998@yahoo.in>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: TaruunMalik <taruunrmalik09@gmail.com>
Co-authored-by: johnsoncherian <johnsonc.dev@gmail.com>
Co-authored-by: NishidhJain11 <nishidh@tooljet.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Nakul Nagargade <nakul@tooljet.com>
2025-06-27 12:42:34 +00:00
|
|
|
}
|
2025-10-15 12:44:05 +00:00
|
|
|
},
|
|
|
|
|
{ root: null, threshold: [1] }
|
Custom themes (#13064)
* feat: Add CSA and functionalities for managing loading, visibility, and disable states for full tab component. (#11267)
* feat: tab draggble option and popover menu (#11267)
* feat: tab scrollable arrows and tabItem logic(#11267)
* feat: remove logs(#11267)
* feat: Tabslayout name change(#11267)
* fix: component update on Tabs
* fix: tab text color update
* feat: setTabDisable CSA added(#11267)
* feat: added CSA for tab specific changes(#11267)
* feat: added handle function for tab specific changes(#11267)
* feat: shimmer for tab nav and icon chooser (#11267)
* feat: icon for each tab in TabNav items (#11267)
* feat: equal split width fix for each tab in TabNav items (#11267)
* feat: styles for Tab Nav (#11267)
* feat: slide options(#11267)
* feat: fix radius (#11267)
* feat: slider (#11267)
* feat: fix slide direction (#11267)
* feat: fix slide direction 2 (#11267)
* feat: fix styles right side inspector view (#11267)
* feat: nav ellipsis ... (#11267)
* feat: children different for dynamic and non-dynamic (#11267)
* feat:[tabsLayout] change default values in config (#11267)
* feat:[tabsLayout] split and auto fix (#11267)
* feat: fix styles accent and text (#11267)
* feat: fix styles divider and more 2(#11267)
* feat: fix styles divider and more 3(#11267)
* feat: fix styles 4(#11267)
* feat: fix styles 5(#11267)
* feat: fix tab icon visibility 6 (#11267)
* feat: modify name of property from id to Tab 7(#11267)
* fixes and changes
* fix: csa for tabs
* new changes and fixes
* fix: dynamic options sytling
* v2 changes
* add: new properties and styles to inspector for range slider
* fixes of range slider
* fix: styling
* fix: styling of icons
* fixed endvalue and startvalue problem
* ColorSwatches for table
* fix: styling
* transition effect fix
* fix: properties and migration
* fix: slider functionality
* fixed transition
* new changes
* visible,disable,loading,width
* feat: merge appbuilder/sprint-11 with main
* fix: styling
* style: extend tabpane background to whole pane
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable' -m 'Changes done for: Currency, Email, Phone Number & ModalV2 component
* review changes
* fix: tinycolor import
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Date, Time, DateTime & Date Range Picker components
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Form, Textarea & Horizontal Divider component
* Fix: Add default selected value config for Header & Footer Background Color input field for Form component so that its shows correct color demo & its value
* Fix: Resolved custom theming issues in different components
* feat: Revamps file uploader widget
* Fixes added
* Custom theme extra code for extra components
* Submodule commit change
* Submodule commit change
* Textinput theming added
* Number input theming added
* Email & Password Theming added
* Textarea theming added
* Error system status added along with rating theming
* ToggleV2 theming added
* Toggle, RadioButton & Error related theming added
* Checkbox Theming added
* Dropdown V2 and legacy theming added
* Multiselect V2 theming added
* Adding ux friendly error messages
* Misc1 and Misc 2 theming added
* Multiselect legacy theming added
* Form components theming added
* Subcontainer related issues
* Subcontainers theming added
* Tabs theming added
* Filepicker theming added
* Range slider theming added
* Steps theming added
* Submodule update
* Package update
* Added Header text, background and container background color
* Submodule Update
* Submodule update
* Submodule update
* Submodule update
* Hover effect added
* feat: Revamps file uploader widget
* Adding ux friendly error messages
* Adds style tab
* Adds min file validation
* Reset vs code
* Adds support for theme
* Base theme added
* Base theme added
* Base theme added
* initial commit
* fix
* Fixes
* Submodule update
* Added auto color assign feature for multiselect/select in table
* Table column popover going out of bounds fix
* Changed layout of component manager
* DropdownV2 added to selectInputs
* HTML column data type added
* Table column icons added
* Fix dropping widget width while dragging
* Changed datepicker icon and added icons to table dropdown
* Style: Update Accordion Component UI
* Temp changes
* Fix group selection in form
* fix when dropping a component, shadow is coming on top of component manager.
* improve performace on useGroupedTargetsScrollHandler
* Fix
* Review fixes
* Minor changes
* chore: update submodule references
* Color swatches added icon/default and added disabled/loading state
* Submodule update
* Bugs solved
* Fixes for Component sidebar
* Custom theme related bug fixes
* App Background Switch added
* Submodule update
* Submodule update
* HTML fixes
* Submodule update
* Query breaking on Symbol fix
* Import export property migration for Rangepicker & Textarea
* Auto color pills not working for table select fix
* Custom themes minor bugs
* Submodule update
* Minor fixes
* Revamp pages in editor and viewer
* bug fixes
* merge base
* fix conflicts
* fix conflicts
* bug fixes
* Added swatches to page menu
* Submodule update
* Submodule update
* Submodule update
* Styling fixes
* Changed few page styles
* bug fixes
* fix: pages icon and layout for right sidebar
* fix: styling for pages menu
* fix base styling
* merge base
* bug fixes
* Bug fixes
* Submodule update
* Submodules updated
* bug fixes
* fix top styling of nav bar
* Sass loader error fix
* styles: correct styles to match the dsigns
* Accordion design added with some minor styling fixes
* fix: update default supported file of filepicker to any
* fix: update styles mismatches
* fix: hide min and max file count if multi file select is disabled
* TJ Default changed to Tooljet Migration
* Multiline code editor suggestions now close when out of view
* add border to canvas
* Dark theme link color fix for html column type
* Spinner color fix
* bug fixes
* bug fixes
* Submodules updated
* update reference
* Submodule update
---------
Co-authored-by: Raman Kumar <k.raman1998@yahoo.in>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: TaruunMalik <taruunrmalik09@gmail.com>
Co-authored-by: johnsoncherian <johnsonc.dev@gmail.com>
Co-authored-by: NishidhJain11 <nishidh@tooljet.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Nakul Nagargade <nakul@tooljet.com>
2025-06-27 12:42:34 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
currentLineObserverRef.current = observer;
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
if (currentLineObserverRef.current) {
|
|
|
|
|
currentLineObserverRef.current.disconnect();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}, [editorView]);
|
|
|
|
|
|
2025-09-19 06:00:41 +00:00
|
|
|
const handleChange = (val) => {
|
|
|
|
|
currentValueRef.current = val;
|
|
|
|
|
onInputChange && onInputChange(val);
|
|
|
|
|
};
|
Custom themes (#13064)
* feat: Add CSA and functionalities for managing loading, visibility, and disable states for full tab component. (#11267)
* feat: tab draggble option and popover menu (#11267)
* feat: tab scrollable arrows and tabItem logic(#11267)
* feat: remove logs(#11267)
* feat: Tabslayout name change(#11267)
* fix: component update on Tabs
* fix: tab text color update
* feat: setTabDisable CSA added(#11267)
* feat: added CSA for tab specific changes(#11267)
* feat: added handle function for tab specific changes(#11267)
* feat: shimmer for tab nav and icon chooser (#11267)
* feat: icon for each tab in TabNav items (#11267)
* feat: equal split width fix for each tab in TabNav items (#11267)
* feat: styles for Tab Nav (#11267)
* feat: slide options(#11267)
* feat: fix radius (#11267)
* feat: slider (#11267)
* feat: fix slide direction (#11267)
* feat: fix slide direction 2 (#11267)
* feat: fix styles right side inspector view (#11267)
* feat: nav ellipsis ... (#11267)
* feat: children different for dynamic and non-dynamic (#11267)
* feat:[tabsLayout] change default values in config (#11267)
* feat:[tabsLayout] split and auto fix (#11267)
* feat: fix styles accent and text (#11267)
* feat: fix styles divider and more 2(#11267)
* feat: fix styles divider and more 3(#11267)
* feat: fix styles 4(#11267)
* feat: fix styles 5(#11267)
* feat: fix tab icon visibility 6 (#11267)
* feat: modify name of property from id to Tab 7(#11267)
* fixes and changes
* fix: csa for tabs
* new changes and fixes
* fix: dynamic options sytling
* v2 changes
* add: new properties and styles to inspector for range slider
* fixes of range slider
* fix: styling
* fix: styling of icons
* fixed endvalue and startvalue problem
* ColorSwatches for table
* fix: styling
* transition effect fix
* fix: properties and migration
* fix: slider functionality
* fixed transition
* new changes
* visible,disable,loading,width
* feat: merge appbuilder/sprint-11 with main
* fix: styling
* style: extend tabpane background to whole pane
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable' -m 'Changes done for: Currency, Email, Phone Number & ModalV2 component
* review changes
* fix: tinycolor import
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Date, Time, DateTime & Date Range Picker components
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Form, Textarea & Horizontal Divider component
* Fix: Add default selected value config for Header & Footer Background Color input field for Form component so that its shows correct color demo & its value
* Fix: Resolved custom theming issues in different components
* feat: Revamps file uploader widget
* Fixes added
* Custom theme extra code for extra components
* Submodule commit change
* Submodule commit change
* Textinput theming added
* Number input theming added
* Email & Password Theming added
* Textarea theming added
* Error system status added along with rating theming
* ToggleV2 theming added
* Toggle, RadioButton & Error related theming added
* Checkbox Theming added
* Dropdown V2 and legacy theming added
* Multiselect V2 theming added
* Adding ux friendly error messages
* Misc1 and Misc 2 theming added
* Multiselect legacy theming added
* Form components theming added
* Subcontainer related issues
* Subcontainers theming added
* Tabs theming added
* Filepicker theming added
* Range slider theming added
* Steps theming added
* Submodule update
* Package update
* Added Header text, background and container background color
* Submodule Update
* Submodule update
* Submodule update
* Submodule update
* Hover effect added
* feat: Revamps file uploader widget
* Adding ux friendly error messages
* Adds style tab
* Adds min file validation
* Reset vs code
* Adds support for theme
* Base theme added
* Base theme added
* Base theme added
* initial commit
* fix
* Fixes
* Submodule update
* Added auto color assign feature for multiselect/select in table
* Table column popover going out of bounds fix
* Changed layout of component manager
* DropdownV2 added to selectInputs
* HTML column data type added
* Table column icons added
* Fix dropping widget width while dragging
* Changed datepicker icon and added icons to table dropdown
* Style: Update Accordion Component UI
* Temp changes
* Fix group selection in form
* fix when dropping a component, shadow is coming on top of component manager.
* improve performace on useGroupedTargetsScrollHandler
* Fix
* Review fixes
* Minor changes
* chore: update submodule references
* Color swatches added icon/default and added disabled/loading state
* Submodule update
* Bugs solved
* Fixes for Component sidebar
* Custom theme related bug fixes
* App Background Switch added
* Submodule update
* Submodule update
* HTML fixes
* Submodule update
* Query breaking on Symbol fix
* Import export property migration for Rangepicker & Textarea
* Auto color pills not working for table select fix
* Custom themes minor bugs
* Submodule update
* Minor fixes
* Revamp pages in editor and viewer
* bug fixes
* merge base
* fix conflicts
* fix conflicts
* bug fixes
* Added swatches to page menu
* Submodule update
* Submodule update
* Submodule update
* Styling fixes
* Changed few page styles
* bug fixes
* fix: pages icon and layout for right sidebar
* fix: styling for pages menu
* fix base styling
* merge base
* bug fixes
* Bug fixes
* Submodule update
* Submodules updated
* bug fixes
* fix top styling of nav bar
* Sass loader error fix
* styles: correct styles to match the dsigns
* Accordion design added with some minor styling fixes
* fix: update default supported file of filepicker to any
* fix: update styles mismatches
* fix: hide min and max file count if multi file select is disabled
* TJ Default changed to Tooljet Migration
* Multiline code editor suggestions now close when out of view
* add border to canvas
* Dark theme link color fix for html column type
* Spinner color fix
* bug fixes
* bug fixes
* Submodules updated
* update reference
* Submodule update
---------
Co-authored-by: Raman Kumar <k.raman1998@yahoo.in>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: TaruunMalik <taruunrmalik09@gmail.com>
Co-authored-by: johnsoncherian <johnsonc.dev@gmail.com>
Co-authored-by: NishidhJain11 <nishidh@tooljet.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Nakul Nagargade <nakul@tooljet.com>
2025-06-27 12:42:34 +00:00
|
|
|
|
2024-10-22 08:01:21 +00:00
|
|
|
const handleOnBlur = () => {
|
|
|
|
|
if (!delayOnChange) return onChange(currentValueRef.current);
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
onChange(currentValueRef.current);
|
|
|
|
|
}, 100);
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-15 12:44:05 +00:00
|
|
|
const heightInPx = typeof height === 'string' && height?.includes('px') ? height : `${height}px`;
|
2024-10-22 08:01:21 +00:00
|
|
|
|
|
|
|
|
const theme = darkMode ? okaidia : githubLight;
|
|
|
|
|
const langExtention = langSupport[lang] ?? null;
|
|
|
|
|
|
|
|
|
|
const setupConfig = {
|
|
|
|
|
lineNumbers: lineNumbers ?? true,
|
|
|
|
|
syntaxHighlighting: true,
|
|
|
|
|
bracketMatching: true,
|
|
|
|
|
foldGutter: true,
|
|
|
|
|
highlightActiveLine: false,
|
|
|
|
|
autocompletion: hideSuggestion ?? true,
|
|
|
|
|
highlightActiveLineGutter: false,
|
2025-03-07 10:04:31 +00:00
|
|
|
defaultKeymap: false,
|
2024-10-22 08:01:21 +00:00
|
|
|
completionKeymap: true,
|
|
|
|
|
searchKeymap: false,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function autoCompleteExtensionConfig(context) {
|
2025-09-18 19:54:57 +00:00
|
|
|
const hasWorkflowSuggestions =
|
2025-10-15 12:44:05 +00:00
|
|
|
workflowSuggestions?.appHints?.length > 0 || workflowSuggestions?.jsHints?.length > 0;
|
2025-09-18 19:54:57 +00:00
|
|
|
const hints = hasWorkflowSuggestions ? workflowSuggestions : getSuggestions();
|
2025-05-22 20:08:04 +00:00
|
|
|
const serverHints = getServerSideGlobalResolveSuggestions(isInsideQueryManager);
|
2025-04-01 20:41:13 +00:00
|
|
|
|
2025-03-25 23:11:00 +00:00
|
|
|
const allHints = {
|
|
|
|
|
...hints,
|
|
|
|
|
appHints: [...hints.appHints, ...serverHints],
|
|
|
|
|
};
|
|
|
|
|
|
2025-07-01 11:19:04 +00:00
|
|
|
return getSuggestionsForMultiLine(context, allHints, hints, lang, paramList);
|
2024-10-22 08:01:21 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-07 10:04:31 +00:00
|
|
|
const customKeyMaps = [
|
|
|
|
|
...defaultKeymap.filter((keyBinding) => keyBinding.key !== 'Mod-Enter'), // Remove default keybinding for Mod-Enter
|
|
|
|
|
...completionKeymap,
|
|
|
|
|
...searchKeymap,
|
|
|
|
|
];
|
|
|
|
|
|
2024-10-22 08:01:21 +00:00
|
|
|
const customTabKeymap = keymap.of([
|
|
|
|
|
{
|
|
|
|
|
key: 'Tab',
|
|
|
|
|
run: (view) => {
|
|
|
|
|
if (completionStatus(view.state)) {
|
|
|
|
|
return acceptCompletion(view);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const { state } = view;
|
|
|
|
|
const { selection } = state;
|
|
|
|
|
const { anchor } = selection.main;
|
|
|
|
|
const tabSize = 2;
|
|
|
|
|
|
|
|
|
|
view.dispatch({
|
|
|
|
|
changes: { from: anchor, insert: ' '.repeat(tabSize) },
|
|
|
|
|
selection: { anchor: anchor + tabSize },
|
|
|
|
|
});
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-03-07 10:04:31 +00:00
|
|
|
...queryPanelKeybindings,
|
2024-10-22 08:01:21 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
2025-01-20 10:53:37 +00:00
|
|
|
const overRideFunction = React.useCallback((context) => autoCompleteExtensionConfig(context), [paramList]);
|
2024-10-22 08:01:21 +00:00
|
|
|
const { handleTogglePopupExapand, isOpen, setIsOpen, forceUpdate } = portalProps;
|
|
|
|
|
let cyLabel = paramLabel ? paramLabel.toLowerCase().trim().replace(/\s+/g, '-') : props.cyLabel;
|
|
|
|
|
|
|
|
|
|
const initialValueWithReplacedIds = useMemo(() => {
|
|
|
|
|
if (
|
2025-10-15 12:44:05 +00:00
|
|
|
typeof initialValue === 'string' &&
|
|
|
|
|
(initialValue?.includes('components') || initialValue?.includes('queries'))
|
2024-10-22 08:01:21 +00:00
|
|
|
) {
|
|
|
|
|
return replaceIdsWithName(initialValue);
|
|
|
|
|
}
|
|
|
|
|
return initialValue;
|
|
|
|
|
}, [initialValue, replaceIdsWithName]);
|
|
|
|
|
|
Custom themes (#13064)
* feat: Add CSA and functionalities for managing loading, visibility, and disable states for full tab component. (#11267)
* feat: tab draggble option and popover menu (#11267)
* feat: tab scrollable arrows and tabItem logic(#11267)
* feat: remove logs(#11267)
* feat: Tabslayout name change(#11267)
* fix: component update on Tabs
* fix: tab text color update
* feat: setTabDisable CSA added(#11267)
* feat: added CSA for tab specific changes(#11267)
* feat: added handle function for tab specific changes(#11267)
* feat: shimmer for tab nav and icon chooser (#11267)
* feat: icon for each tab in TabNav items (#11267)
* feat: equal split width fix for each tab in TabNav items (#11267)
* feat: styles for Tab Nav (#11267)
* feat: slide options(#11267)
* feat: fix radius (#11267)
* feat: slider (#11267)
* feat: fix slide direction (#11267)
* feat: fix slide direction 2 (#11267)
* feat: fix styles right side inspector view (#11267)
* feat: nav ellipsis ... (#11267)
* feat: children different for dynamic and non-dynamic (#11267)
* feat:[tabsLayout] change default values in config (#11267)
* feat:[tabsLayout] split and auto fix (#11267)
* feat: fix styles accent and text (#11267)
* feat: fix styles divider and more 2(#11267)
* feat: fix styles divider and more 3(#11267)
* feat: fix styles 4(#11267)
* feat: fix styles 5(#11267)
* feat: fix tab icon visibility 6 (#11267)
* feat: modify name of property from id to Tab 7(#11267)
* fixes and changes
* fix: csa for tabs
* new changes and fixes
* fix: dynamic options sytling
* v2 changes
* add: new properties and styles to inspector for range slider
* fixes of range slider
* fix: styling
* fix: styling of icons
* fixed endvalue and startvalue problem
* ColorSwatches for table
* fix: styling
* transition effect fix
* fix: properties and migration
* fix: slider functionality
* fixed transition
* new changes
* visible,disable,loading,width
* feat: merge appbuilder/sprint-11 with main
* fix: styling
* style: extend tabpane background to whole pane
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable' -m 'Changes done for: Currency, Email, Phone Number & ModalV2 component
* review changes
* fix: tinycolor import
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Date, Time, DateTime & Date Range Picker components
* [Issue 12503] Update input's with type as color to colorSwatches and also change accent color value to primary brand css variable
Changes done for: Form, Textarea & Horizontal Divider component
* Fix: Add default selected value config for Header & Footer Background Color input field for Form component so that its shows correct color demo & its value
* Fix: Resolved custom theming issues in different components
* feat: Revamps file uploader widget
* Fixes added
* Custom theme extra code for extra components
* Submodule commit change
* Submodule commit change
* Textinput theming added
* Number input theming added
* Email & Password Theming added
* Textarea theming added
* Error system status added along with rating theming
* ToggleV2 theming added
* Toggle, RadioButton & Error related theming added
* Checkbox Theming added
* Dropdown V2 and legacy theming added
* Multiselect V2 theming added
* Adding ux friendly error messages
* Misc1 and Misc 2 theming added
* Multiselect legacy theming added
* Form components theming added
* Subcontainer related issues
* Subcontainers theming added
* Tabs theming added
* Filepicker theming added
* Range slider theming added
* Steps theming added
* Submodule update
* Package update
* Added Header text, background and container background color
* Submodule Update
* Submodule update
* Submodule update
* Submodule update
* Hover effect added
* feat: Revamps file uploader widget
* Adding ux friendly error messages
* Adds style tab
* Adds min file validation
* Reset vs code
* Adds support for theme
* Base theme added
* Base theme added
* Base theme added
* initial commit
* fix
* Fixes
* Submodule update
* Added auto color assign feature for multiselect/select in table
* Table column popover going out of bounds fix
* Changed layout of component manager
* DropdownV2 added to selectInputs
* HTML column data type added
* Table column icons added
* Fix dropping widget width while dragging
* Changed datepicker icon and added icons to table dropdown
* Style: Update Accordion Component UI
* Temp changes
* Fix group selection in form
* fix when dropping a component, shadow is coming on top of component manager.
* improve performace on useGroupedTargetsScrollHandler
* Fix
* Review fixes
* Minor changes
* chore: update submodule references
* Color swatches added icon/default and added disabled/loading state
* Submodule update
* Bugs solved
* Fixes for Component sidebar
* Custom theme related bug fixes
* App Background Switch added
* Submodule update
* Submodule update
* HTML fixes
* Submodule update
* Query breaking on Symbol fix
* Import export property migration for Rangepicker & Textarea
* Auto color pills not working for table select fix
* Custom themes minor bugs
* Submodule update
* Minor fixes
* Revamp pages in editor and viewer
* bug fixes
* merge base
* fix conflicts
* fix conflicts
* bug fixes
* Added swatches to page menu
* Submodule update
* Submodule update
* Submodule update
* Styling fixes
* Changed few page styles
* bug fixes
* fix: pages icon and layout for right sidebar
* fix: styling for pages menu
* fix base styling
* merge base
* bug fixes
* Bug fixes
* Submodule update
* Submodules updated
* bug fixes
* fix top styling of nav bar
* Sass loader error fix
* styles: correct styles to match the dsigns
* Accordion design added with some minor styling fixes
* fix: update default supported file of filepicker to any
* fix: update styles mismatches
* fix: hide min and max file count if multi file select is disabled
* TJ Default changed to Tooljet Migration
* Multiline code editor suggestions now close when out of view
* add border to canvas
* Dark theme link color fix for html column type
* Spinner color fix
* bug fixes
* bug fixes
* Submodules updated
* update reference
* Submodule update
---------
Co-authored-by: Raman Kumar <k.raman1998@yahoo.in>
Co-authored-by: Vijaykant Yadav <vjy239@gmail.com>
Co-authored-by: TaruunMalik <taruunrmalik09@gmail.com>
Co-authored-by: johnsoncherian <johnsonc.dev@gmail.com>
Co-authored-by: NishidhJain11 <nishidh@tooljet.com>
Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com>
Co-authored-by: Nakul Nagargade <nakul@tooljet.com>
2025-06-27 12:42:34 +00:00
|
|
|
function updateCurrentLineObserver(editorView) {
|
|
|
|
|
if (!editorView || !editorView?.view?.dom) return;
|
|
|
|
|
const cursorPos = editorView.state.selection.main.head;
|
|
|
|
|
const line = editorView.state.doc.lineAt(cursorPos);
|
|
|
|
|
const lineNumber = line.number;
|
|
|
|
|
const cmLines = editorView.view.dom.querySelectorAll('.cm-line');
|
|
|
|
|
const currentLineDiv = cmLines[lineNumber - 1] || null;
|
|
|
|
|
|
|
|
|
|
// Update intersection observer to watch the current line
|
|
|
|
|
if (currentLineObserverRef.current && currentLineDiv && !isObserverTriggeredRef.current) {
|
|
|
|
|
currentLineObserverRef.current.disconnect();
|
|
|
|
|
currentLineObserverRef.current.observe(currentLineDiv);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-07 09:41:58 +00:00
|
|
|
const onAiSuggestionAccept = (newValue) => {
|
|
|
|
|
currentValueRef.current = newValue;
|
|
|
|
|
onChange(newValue);
|
|
|
|
|
};
|
|
|
|
|
|
2024-10-22 08:01:21 +00:00
|
|
|
return (
|
2025-10-15 12:44:05 +00:00
|
|
|
<div
|
|
|
|
|
className={`code-hinter-wrapper position-relative ${isInsideQueryPane ? 'code-editor-query-panel' : ''}`}
|
|
|
|
|
style={{ width: '100%' }}
|
|
|
|
|
ref={wrapperRef}
|
|
|
|
|
>
|
|
|
|
|
<div className={`${className} ${darkMode && 'cm-codehinter-dark-themed'}`}>
|
|
|
|
|
<CodeHinterBtns
|
|
|
|
|
view={editorView}
|
|
|
|
|
isPanelOpen={isSearchPanelOpen}
|
|
|
|
|
renderCopilot={() =>
|
|
|
|
|
renderCopilot?.({
|
|
|
|
|
darkMode,
|
|
|
|
|
language: lang,
|
|
|
|
|
editorRef,
|
|
|
|
|
onAiSuggestionAccept,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<CodeHinter.PopupIcon
|
|
|
|
|
callback={handleTogglePopupExapand}
|
|
|
|
|
icon="portal-open"
|
|
|
|
|
tip="Pop out code editor into a new window"
|
|
|
|
|
isMultiEditor={true}
|
|
|
|
|
isQueryManager={isInsideQueryPane}
|
|
|
|
|
position={{height: height}}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<CodeHinter.Portal
|
|
|
|
|
isCopilotEnabled={false}
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
callback={setIsOpen}
|
|
|
|
|
componentName={componentName}
|
|
|
|
|
key={componentName}
|
|
|
|
|
forceUpdate={forceUpdate}
|
|
|
|
|
optionalProps={{ styles: { height: 300 }, cls: '' }}
|
|
|
|
|
darkMode={darkMode}
|
|
|
|
|
selectors={{ className: 'preview-block-portal' }}
|
|
|
|
|
dragResizePortal={true}
|
|
|
|
|
callgpt={null}
|
|
|
|
|
>
|
|
|
|
|
<ErrorBoundary>
|
|
|
|
|
<div className="codehinter-container w-100 " data-cy={`${cyLabel}-input-field`} style={{ height: '100%' }}>
|
|
|
|
|
<CodeMirror
|
|
|
|
|
ref={editorRef}
|
|
|
|
|
value={initialValueWithReplacedIds}
|
|
|
|
|
placeholder={placeholder}
|
|
|
|
|
height={heightInPx}
|
|
|
|
|
minHeight={heightInPx}
|
|
|
|
|
{...(isInsideQueryPane ? { maxHeight: '100%' } : {})}
|
|
|
|
|
width="100%"
|
|
|
|
|
theme={theme}
|
|
|
|
|
extensions={[
|
|
|
|
|
langExtention,
|
|
|
|
|
search({
|
|
|
|
|
createPanel: handleSearchPanel,
|
|
|
|
|
}),
|
|
|
|
|
javascriptLanguage.data.of({
|
|
|
|
|
autocomplete: overRideFunction,
|
|
|
|
|
}),
|
|
|
|
|
python().language.data.of({
|
|
|
|
|
autocomplete: overRideFunction,
|
|
|
|
|
}),
|
|
|
|
|
sql().language.data.of({
|
|
|
|
|
autocomplete: overRideFunction,
|
|
|
|
|
}),
|
|
|
|
|
sass().language.data.of({
|
|
|
|
|
autocomplete: sassCompletionSource,
|
|
|
|
|
}),
|
|
|
|
|
autocompletion({
|
|
|
|
|
override: [overRideFunction],
|
|
|
|
|
activateOnTyping: true,
|
|
|
|
|
compareCompletions: (a, b) => {
|
|
|
|
|
return a.section.rank - b.section.rank && a.label.localeCompare(b.label);
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
customTabKeymap,
|
|
|
|
|
keymap.of([...customKeyMaps]),
|
|
|
|
|
]}
|
|
|
|
|
onChange={handleChange}
|
|
|
|
|
onBlur={handleOnBlur}
|
|
|
|
|
basicSetup={setupConfig}
|
|
|
|
|
style={{
|
|
|
|
|
overflowY: 'auto',
|
|
|
|
|
}}
|
|
|
|
|
className={`codehinter-multi-line-input ${isInsideQueryPane ? 'code-editor-query-panel' : ''}`}
|
|
|
|
|
indentWithTab={false}
|
|
|
|
|
readOnly={readOnly}
|
|
|
|
|
editable={editable} //for transformations in query manager
|
|
|
|
|
onCreateEditor={(view) => {
|
|
|
|
|
setEditorView(view);
|
|
|
|
|
if (setCodeEditorView) {
|
|
|
|
|
setCodeEditorView(view);
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
onUpdate={(view) => {
|
|
|
|
|
setIsSearchPanelOpen(searchPanelOpen(view.state));
|
|
|
|
|
updateCurrentLineObserver(view);
|
|
|
|
|
}}
|
2024-10-22 08:01:21 +00:00
|
|
|
/>
|
|
|
|
|
</div>
|
2025-10-15 12:44:05 +00:00
|
|
|
{showPreview && (
|
|
|
|
|
<div className="multiline-previewbox-wrapper">
|
|
|
|
|
<PreviewBox
|
|
|
|
|
currentValue={currentValueRef.current}
|
|
|
|
|
validationSchema={null}
|
|
|
|
|
setErrorStateActive={() => null}
|
|
|
|
|
componentId={null}
|
|
|
|
|
setErrorMessage={() => null}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</ErrorBoundary>
|
|
|
|
|
</CodeHinter.Portal>
|
|
|
|
|
</div>
|
2024-10-22 08:01:21 +00:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2025-10-15 12:44:05 +00:00
|
|
|
export default MultiLineCodeEditor;
|