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

[NIFI-13282] improve property editor to handle large amounts of text #8864

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[style.width.px]="width"
cdkDrag
resizable
(resized)="resized()">
(resized)="resized($event)">
<form class="h-full" [formGroup]="nfEditorForm" cdkTrapFocus [cdkTrapFocusAutoCapture]="!readonly">
<div class="flex flex-col gap-y-3 h-full">
<div class="flex justify-end">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,52 +22,11 @@

min-height: 240px;
min-width: 245px;
max-height: 100vh;
max-width: 100vw;
cursor: move;

.property-hint {
cursor: default;
}

.nf-editor {
min-height: 100px;
min-width: 210px;
border-width: 1px;
border-style: solid;
cursor: default;

.CodeMirror {
border-width: 1px;
border-style: solid;
font-family: monospace;
cursor: default;
line-height: normal;
}

.CodeMirror-scroll {
overflow-x: auto;
overflow-y: auto;
}

/*
Override some defaults...
*/

.cm-s-default {
font-size: 13px;
font-family: monospace;
}

.cm-s-default .CodeMirror-matchingbracket {
opacity: 0.5;
filter: alpha(opacity=50);
}

.CodeMirror-vscrollbar {
bottom: 18px !important;
}

.CodeMirror-hscrollbar {
right: 18px !important;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ export class NfEditor implements OnDestroy {

codeMirrorLoaded(codeEditor: any): void {
this.editor = codeEditor.codeMirror;
this.editor.setSize('100%', '100%');
// The `.property-editor` minimum height is set to 240px. This is the height of the `.nf-editor` overlay. The
// height of the codemirror needs to be set in order to handle large amounts of text in the codemirror editor.
// The height of the codemirror should be the height of the `.nf-editor` overlay minus the 132px of spacing
// needed to display the EL and Param tooltips, the 'Set Empty String' checkbox, the action buttons,
// and the resize handle so the initial height of the codemirror when opening should be 108px for a 240px tall
// `.nf-editor` overlay. If the initial height of that overlay changes then this initial height should also be
// updated.
this.editor.setSize('100%', 108);

if (!this.readonly) {
this.editor.execCommand('selectAll');
Expand Down Expand Up @@ -192,8 +199,14 @@ export class NfEditor implements OnDestroy {
};
}

resized(): void {
this.editor.setSize('100%', '100%');
resized(event: any): void {
// Note: We calculate the height of the codemirror to fit into an `.nf-editor` overlay. The
// height of the codemirror needs to be set in order to handle large amounts of text in the codemirror editor.
// The height of the codemirror should be the height of the `.nf-editor` overlay minus the 132px of spacing
// needed to display the EL and Param tooltips, the 'Set Empty String' checkbox, the action buttons,
// and the resize handle. If the amount of spacing needed for additional UX is needed for the `.nf-editor` is
// changed then this value should also be updated.
this.editor.setSize('100%', event.height - 132);
}

preventDrag(event: MouseEvent): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ export class PropertyTable implements AfterViewInit, ControlValueAccessor {
} else {
this.editorWidth = width + 100;
this.editorOffsetX = 8;
this.editorOffsetY = 56;
this.editorOffsetY = 66;
}
this.editorPositions.push(
new ConnectionPositionPair(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@

.cm-s-nifi.CodeMirror {
@extend .surface-contrast;
height: 108px;
cursor: default;
line-height: normal;
background-color: if($is-dark, $nifi-theme-surface-palette-darker, $nifi-theme-surface-palette-lighter);
border: 1px solid var(--mdc-outlined-text-field-label-text-color);
}
Expand Down Expand Up @@ -211,6 +214,8 @@
text-decoration: underline;
color: $nifi-theme-surface-palette-darker-contrast !important;
background-color: $nifi-theme-surface-palette-default;
opacity: 0.5;
filter: alpha(opacity=50);
}

.cm-s-nifi .CodeMirror-nonmatchingbracket {
Expand Down