@@ -4,7 +4,7 @@ import { EditorState } from "@codemirror/state";
44import { EditorView , lineNumbers , Rect } from "@codemirror/view" ;
55
66import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
7- import { CodeEditor } from "../../extensions/codemirror/CodeMirror" ;
7+ import { CodeEditor , CodeEditorProps } from "../../extensions/codemirror/CodeMirror" ;
88//hooks
99import { SupportedCodeEditorModes } from "../../extensions/codemirror/hooks/useCodemirrorModeExtension.hooks" ;
1010
@@ -15,23 +15,23 @@ export interface IRange {
1515
1616export interface ExtendedCodeEditorProps {
1717 // Is called with the editor instance that allows access via the CodeMirror API
18- setCM : ( editor : EditorView | undefined ) => any ;
18+ setCM : ( editor : EditorView | undefined ) => void ;
1919 // Called whenever the editor content changes
20- onChange : ( value : string ) => any ;
20+ onChange : ( value : string ) => void ;
2121 // Called when the cursor position changes
22- onCursorChange : ( pos : number , coords : Rect , scrollinfo : HTMLElement , cm : EditorView ) => any ;
22+ onCursorChange : ( pos : number , coords : Rect , scrollinfo : HTMLElement , cm : EditorView ) => void ;
2323 // The editor theme, e.g. "sparql"
2424 mode ?: SupportedCodeEditorModes ;
2525 // The initial value of the editor
2626 initialValue : string ;
2727 // Called when the focus status changes
28- onFocusChange : ( focused : boolean ) => any ;
28+ onFocusChange : ( focused : boolean ) => void ;
2929 // Called when the user presses a key
3030 onKeyDown : ( event : KeyboardEvent ) => boolean ;
3131 // function invoked when any click occurs
3232 onMouseDown ?: ( view : EditorView ) => void ;
3333 // Called when the user selects text
34- onSelection : ( ranges : IRange [ ] ) => any ;
34+ onSelection : ( ranges : IRange [ ] ) => void ;
3535 // If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app.
3636 enableTab ?: boolean ;
3737 /** Placeholder to be shown when no text has been entered, yet. */
@@ -40,6 +40,27 @@ export interface ExtendedCodeEditorProps {
4040 showScrollBar ?: boolean ;
4141 /** allow multiline entries when new line characters are entered */
4242 multiline ?: boolean ;
43+ /**
44+ * Code editor props
45+ */
46+ codeEditorProps ?: Omit <
47+ CodeEditorProps ,
48+ | "defaultValue"
49+ | "setEditorView"
50+ | "onChange"
51+ | "onCursorChange"
52+ | "onFocusChange"
53+ | "onKeyDown"
54+ | "onSelection"
55+ | "onMouseDown"
56+ | "shouldHaveMinimalSetup"
57+ | "preventLineNumbers"
58+ | "mode"
59+ | "name"
60+ | "enableTab"
61+ | "additionalExtensions"
62+ | "outerDivAttributes"
63+ > ;
4364}
4465
4566export type IEditorProps = ExtendedCodeEditorProps ;
@@ -58,6 +79,7 @@ export const ExtendedCodeEditor = ({
5879 placeholder,
5980 onCursorChange,
6081 onSelection,
82+ codeEditorProps,
6183} : ExtendedCodeEditorProps ) => {
6284 const initialContent = React . useRef ( multiline ? initialValue : initialValue . replace ( / [ \r \n ] / g, " " ) ) ;
6385 const multilineExtensions = multiline
@@ -88,6 +110,7 @@ export const ExtendedCodeEditor = ({
88110 multiline ? "codeeditor" : `singlelinecodeeditor ${ BlueprintClassNames . INPUT } `
89111 } `,
90112 } }
113+ { ...codeEditorProps }
91114 />
92115 ) ;
93116} ;
0 commit comments