scottyaslan commented on code in PR #10144:
URL: https://github.com/apache/nifi/pull/10144#discussion_r2246082626


##########
nifi-frontend/src/main/frontend/apps/nifi/src/app/ui/common/property-table/editors/nf-editor/nf-editor.component.ts:
##########
@@ -88,40 +129,126 @@ export class NfEditor implements OnDestroy {
     @Output() exit: EventEmitter<void> = new EventEmitter<void>();
 
     itemSet = false;
-    getParametersSet = false;
-
+    parameterConfigSet = false;
+    nfLanguageDefinition: NfLanguageDefinition | null = null;
     nfEditorForm: FormGroup;
     showSensitiveHelperText = false;
     supportsEl = false;
     supportsParameters = false;
     blank = false;
 
-    mode!: string;
     parameters: Parameter[] | null = null;
-
-    editor!: Editor;
+    private _codemirrorConfig: CodeMirrorConfig = {
+        plugins: [],
+        focusOnInit: true
+    };
+
+    // Styling configuration
+    editorStyling = {
+        width: '100%',
+        height: '108px'
+    };
+
+    // Language configuration
+    languageConfig = {
+        language: this.nifiLanguagePackage.getLanguageId(),
+        languages: [] as LanguageDescription[]
+    };
+
+    // Dynamic config getter that includes disabled state
+    get codemirrorConfig(): CodeMirrorConfig {
+        return {
+            ...this._codemirrorConfig,
+            disabled: this.readonly || this.blank,
+            readOnly: this.readonly || this.blank
+        };
+    }
 
     constructor(
         private formBuilder: FormBuilder,
         private viewContainerRef: ViewContainerRef,
-        private renderer: Renderer2,
-        private nfel: NfEl,
-        private nfpr: NfPr
+        private nifiLanguagePackage: CodemirrorNifiLanguagePackage
     ) {
         this.nfEditorForm = this.formBuilder.group({
             value: new FormControl(''),
             setEmptyString: new FormControl(false)
         });
     }
 
-    codeMirrorLoaded(codeEditor: any): void {
-        this.editor = codeEditor.codeMirror;
+    initializeCodeMirror(): void {
+        if (this.itemSet && this.parameterConfigSet) {
+            const setup: Extension[] = [
+                lineNumbers(),
+                history(),
+                indentUnit.of('    '),
+                parameterHighlightPlugin,
+                elFunctionHighlightPlugin,
+                EditorView.lineWrapping,
+                rectangularSelection(),
+                crosshairCursor(),
+                EditorState.allowMultipleSelections.of(true),
+                indentOnInput(),
+                highlightSpecialChars(),
+                syntaxHighlighting(highlightStyle),
+                syntaxHighlighting(defaultHighlightStyle, { fallback: true }),
+                bracketMatching(),
+                closeBrackets(),
+                highlightActiveLine(),
+                highlightSelectionMatches(),
+                [highlightActiveLineGutter(), Prec.highest(lineNumbers())],
+                autocompletion(),
+                EditorView.contentAttributes.of({ 'aria-label': 'Code Editor' 
}),
+                keymap.of([
+                    { key: 'Mod-Enter', run: () => true }, // ignore Mod-Enter 
in `defaultKeymap` which is handled by `QueryShortcuts.ts`
+                    { key: 'Mod-y', run: redoSelection },
+                    { key: 'Shift-Mod-k', run: deleteLine },
+                    {
+                        key: 'Enter',
+                        run: () => {
+                            if (this.nfEditorForm.dirty && 
this.nfEditorForm.valid) {
+                                this.okClicked();
+                                return true;
+                            }
+                            return false;
+                        }
+                    },
+                    ...closeBracketsKeymap,
+                    ...defaultKeymap,
+                    ...historyKeymap,
+                    ...foldKeymap,
+                    ...searchKeymap,

Review Comment:
   I have removed all search.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to