@gravitee/ui-particles-angular 13.3.1 → 13.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3335,6 +3335,7 @@ class GioMonacoEditorComponent {
3335
3335
  this.options = {};
3336
3336
  this.disableMiniMap = false;
3337
3337
  this.disableAutoFormat = false;
3338
+ this.singleLineMode = false;
3338
3339
  this.loaded$ = new ReplaySubject(1);
3339
3340
  this.defaultOptions = {
3340
3341
  contextmenu: false,
@@ -3433,18 +3434,88 @@ class GioMonacoEditorComponent {
3433
3434
  this.standaloneCodeEditor?.getAction('editor.action.formatDocument')?.run();
3434
3435
  }, 80);
3435
3436
  }
3437
+ if (this.singleLineMode) {
3438
+ this.standaloneCodeEditor?.addAction({
3439
+ id: 'custom.action',
3440
+ label: 'custom action',
3441
+ keybindings: [monaco.KeyCode.Enter],
3442
+ precondition: '!suggestWidgetVisible && !renameInputVisible && !inSnippetMode && !quickFixWidgetVisible',
3443
+ run: () => {
3444
+ // Ignore Enter key in single line mode when writing
3445
+ return;
3446
+ },
3447
+ });
3448
+ }
3436
3449
  const onDidChangeContent = this.textModel?.onDidChangeContent(() => {
3437
- const newValue = this.textModel?.getValue();
3450
+ const textModelValue = this.textModel?.getValue() ?? '';
3451
+ if (this.singleLineMode) {
3452
+ // If value has \n, \r or \r\n, remove them
3453
+ // Useful to clear line breaks when pasting text
3454
+ const hasLineBreak = new RegExp(/(\r\n|\n|\r)/gm);
3455
+ if (hasLineBreak.test(textModelValue)) {
3456
+ const currentPosition = this.standaloneCodeEditor?.getPosition();
3457
+ setTimeout(() => {
3458
+ this.standaloneCodeEditor?.pushUndoStop();
3459
+ this.textModel?.setValue(textModelValue.replace(/(\r\n|\n|\r)/gm, ''));
3460
+ if (currentPosition) {
3461
+ this.standaloneCodeEditor?.setPosition(currentPosition);
3462
+ }
3463
+ this.standaloneCodeEditor?.popUndoStop();
3464
+ }, 0);
3465
+ return;
3466
+ }
3467
+ }
3438
3468
  this.ngZone.run(() => {
3439
- if (!this.readOnly && !isEqual(this.value, newValue)) {
3469
+ if (!this.readOnly && !isEqual(this.value, textModelValue)) {
3440
3470
  setTimeout(() => {
3441
- this.value = newValue ?? '';
3442
- this._onChange(newValue ?? '');
3471
+ this.value = textModelValue;
3472
+ this._onChange(textModelValue);
3443
3473
  this._onTouched();
3444
3474
  }, 0);
3445
3475
  }
3446
3476
  });
3447
3477
  });
3478
+ if (this.singleLineMode) {
3479
+ // Source : https://farzadyz.com/blog/single-line-monaco-editor
3480
+ this.standaloneCodeEditor?.updateOptions({
3481
+ // quickSuggestions: false,
3482
+ fixedOverflowWidgets: true,
3483
+ acceptSuggestionOnEnter: 'on',
3484
+ hover: {
3485
+ delay: 100,
3486
+ },
3487
+ roundedSelection: false,
3488
+ contextmenu: false,
3489
+ cursorStyle: 'line-thin',
3490
+ links: false,
3491
+ find: {
3492
+ addExtraSpaceOnTop: false,
3493
+ autoFindInSelection: 'never',
3494
+ seedSearchStringFromSelection: 'never',
3495
+ },
3496
+ fontSize: 14,
3497
+ fontWeight: 'normal',
3498
+ overviewRulerLanes: 0,
3499
+ scrollBeyondLastColumn: 0,
3500
+ wordWrap: 'on',
3501
+ minimap: {
3502
+ enabled: false,
3503
+ },
3504
+ lineNumbers: 'off',
3505
+ hideCursorInOverviewRuler: true,
3506
+ overviewRulerBorder: false,
3507
+ glyphMargin: false,
3508
+ folding: false,
3509
+ lineDecorationsWidth: 0,
3510
+ lineNumbersMinChars: 0,
3511
+ renderLineHighlight: 'none',
3512
+ scrollbar: {
3513
+ horizontal: 'hidden',
3514
+ vertical: 'hidden',
3515
+ alwaysConsumeMouseWheel: false,
3516
+ },
3517
+ });
3518
+ }
3448
3519
  const onDidBlurEditorWidget = this.standaloneCodeEditor?.onDidBlurEditorWidget(() => {
3449
3520
  this.ngZone.run(() => {
3450
3521
  if (!this.readOnly)
@@ -3474,11 +3545,11 @@ class GioMonacoEditorComponent {
3474
3545
  }
3475
3546
  }
3476
3547
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioMonacoEditorComponent, deps: [{ token: i0.ElementRef }, { token: GIO_MONACO_EDITOR_CONFIG }, { token: GioMonacoEditorService }, { token: GioLanguageJsonService }, { token: GioLanguageElService }, { token: i0.ChangeDetectorRef }, { token: i0.NgZone }, { token: i1$2.NgControl, optional: true, self: true }], target: i0.ɵɵFactoryTarget.Component }); }
3477
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: { languageConfig: "languageConfig", options: "options", disableMiniMap: "disableMiniMap", disableAutoFormat: "disableAutoFormat" }, ngImport: i0, template: ` <div *ngIf="loaded$ | async">Loading...</div>`, isInline: true, styles: [":host{display:block;height:100%;min-height:150px;pointer-events:auto;transition:opacity .2s ease-out}:host-context(.hidden){opacity:0}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3548
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.0", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: { languageConfig: "languageConfig", options: "options", disableMiniMap: "disableMiniMap", disableAutoFormat: "disableAutoFormat", singleLineMode: "singleLineMode" }, host: { properties: { "class.single-line": "this.singleLineMode" } }, ngImport: i0, template: ` <div *ngIf="loaded$ | async">Loading...</div>`, isInline: true, styles: [":host{display:block;height:100%;min-height:150px;pointer-events:auto;transition:opacity .2s ease-out}:host.single-line{display:flex;height:24px;min-height:24px;align-items:center}:host-context(.hidden){opacity:0}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
3478
3549
  }
3479
3550
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioMonacoEditorComponent, decorators: [{
3480
3551
  type: Component,
3481
- args: [{ selector: 'gio-monaco-editor', template: ` <div *ngIf="loaded$ | async">Loading...</div>`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:block;height:100%;min-height:150px;pointer-events:auto;transition:opacity .2s ease-out}:host-context(.hidden){opacity:0}\n"] }]
3552
+ args: [{ selector: 'gio-monaco-editor', template: ` <div *ngIf="loaded$ | async">Loading...</div>`, changeDetection: ChangeDetectionStrategy.OnPush, styles: [":host{display:block;height:100%;min-height:150px;pointer-events:auto;transition:opacity .2s ease-out}:host.single-line{display:flex;height:24px;min-height:24px;align-items:center}:host-context(.hidden){opacity:0}\n"] }]
3482
3553
  }], ctorParameters: () => [{ type: i0.ElementRef }, { type: undefined, decorators: [{
3483
3554
  type: Inject,
3484
3555
  args: [GIO_MONACO_EDITOR_CONFIG]
@@ -3494,6 +3565,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImpor
3494
3565
  type: Input
3495
3566
  }], disableAutoFormat: [{
3496
3567
  type: Input
3568
+ }], singleLineMode: [{
3569
+ type: Input
3570
+ }, {
3571
+ type: HostBinding,
3572
+ args: ['class.single-line']
3497
3573
  }] } });
3498
3574
  const isJsonString = (str) => {
3499
3575
  try {
@@ -4747,7 +4823,7 @@ class GioFjsCodeEditorTypeComponent extends FieldType$1 {
4747
4823
  [formControl]="formControl"
4748
4824
  [languageConfig]="languageConfig"
4749
4825
  ></gio-monaco-editor>
4750
- `, isInline: true, styles: ["gio-monaco-editor{min-height:38px}\n"], dependencies: [{ kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: ["languageConfig", "options", "disableMiniMap", "disableAutoFormat"] }, { kind: "directive", type: GioMonacoEditorFormFieldDirective, selector: "[gioMonacoEditorFormField]", inputs: ["placeholder", "required", "disabled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4826
+ `, isInline: true, styles: ["gio-monaco-editor{min-height:38px}\n"], dependencies: [{ kind: "directive", type: i1$2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: GioMonacoEditorComponent, selector: "gio-monaco-editor", inputs: ["languageConfig", "options", "disableMiniMap", "disableAutoFormat", "singleLineMode"] }, { kind: "directive", type: GioMonacoEditorFormFieldDirective, selector: "[gioMonacoEditorFormField]", inputs: ["placeholder", "required", "disabled"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
4751
4827
  }
4752
4828
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.0", ngImport: i0, type: GioFjsCodeEditorTypeComponent, decorators: [{
4753
4829
  type: Component,