Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow language context to be externally provided #396

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/entries/FEEL/Feel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import FeelIcon from './FeelIcon';

import { FEEL_POPUP_WIDTH } from './FeelPopup';

import { FeelPopupContext } from './context';
import { FeelLanguageContext, FeelPopupContext } from './context';

import { ToggleSwitch } from '../ToggleSwitch';

Expand Down Expand Up @@ -67,6 +67,8 @@ function FeelTextfieldComponent(props) {

const [ focus, _setFocus ] = useState(undefined);

const languageContext = useContext(FeelLanguageContext);

const {
open: openPopup,
source: popupSource
Expand Down Expand Up @@ -249,6 +251,7 @@ function FeelTextfieldComponent(props) {
placeholder={ placeholder }
value={ feelOnlyValue }
variables={ variables }
languageContext={ languageContext }
ref={ editorRef }
tooltipContainer={ tooltipContainer }
/> :
Expand Down
12 changes: 10 additions & 2 deletions src/components/entries/FEEL/FeelEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ const CodeEditor = forwardRef((props, ref) => {
popupOpen,
disabled,
tooltipContainer,
variables
variables,
languageContext : {
builtins,
dialect,
parserDialect
} = { }
} = props;

const inputRef = useRef();
Expand Down Expand Up @@ -99,7 +104,10 @@ const CodeEditor = forwardRef((props, ref) => {
placeholder: placeholder,
tooltipContainer: tooltipContainer,
value: localValue,
variables: variables,
variables,
builtins,
dialect,
parserDialect,
extensions: [
...enableGutters ? [ lineNumbers() ] : [],
EditorView.lineWrapping
Expand Down
9 changes: 9 additions & 0 deletions src/components/entries/FEEL/context/FeelLanguageContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
createContext
} from 'preact';

const FeelLanguageContext = createContext({
dialect: 'expression'
});

export default FeelLanguageContext;
4 changes: 3 additions & 1 deletion src/components/entries/FEEL/context/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { default as FeelPopupContext } from './FeelPopupContext';
export { default as FeelPopupContext } from './FeelPopupContext';

export { default as FeelLanguageContext } from './FeelLanguageContext';
Loading