@firestitch/text-editor 12.4.0 → 12.4.2

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.
@@ -1,37 +1,34 @@
1
- import { EventEmitter, OnInit, ElementRef, OnDestroy } from '@angular/core';
1
+ import { EventEmitter, OnDestroy, OnInit } from '@angular/core';
2
2
  import { ControlValueAccessor } from '@angular/forms';
3
3
  import { FsTextEditorConfig } from '../../interfaces/config.interface';
4
- import { EditorComponent } from '../../modules/ngx-monaco-editor/editor.component';
5
4
  import * as i0 from "@angular/core";
6
5
  export declare class FsTextEditorComponent implements OnInit, OnDestroy, ControlValueAccessor {
7
- private _element;
8
6
  private _document;
7
+ readonly LINE_HEIGHT = 18;
9
8
  config: FsTextEditorConfig;
10
9
  scrollable: boolean;
11
- init: EventEmitter<any>;
10
+ ready: EventEmitter<any>;
12
11
  blur: EventEmitter<any>;
13
- _editorContainer: EditorComponent;
14
12
  defaultConfig: FsTextEditorConfig;
15
13
  onChange: (_: any) => void;
16
14
  onTouched: () => void;
17
- private _window;
18
- get monaco(): any;
19
- constructor(_element: ElementRef, _document: Document);
20
- readonly LINE_HEIGHT = 18;
21
15
  private _editorRef;
22
16
  private _value;
17
+ private _window;
18
+ constructor(_document: Document);
19
+ get monaco(): any;
23
20
  ngOnInit(): void;
24
21
  ngOnDestroy(): void;
25
22
  get value(): string;
26
23
  onEditorInit(event: any): void;
27
24
  writeValue(value: any): void;
28
25
  changed(e: any): void;
26
+ updateLayout(): void;
29
27
  registerOnChange(fn: any): void;
30
28
  registerOnTouched(fn: any): void;
31
29
  private _initEditor;
32
30
  private _updateEditorHeight;
33
- updateLayout(): void;
34
31
  private _disableScroll;
35
32
  static ɵfac: i0.ɵɵFactoryDeclaration<FsTextEditorComponent, never>;
36
- static ɵcmp: i0.ɵɵComponentDeclaration<FsTextEditorComponent, "fs-text-editor", never, { "config": "config"; "scrollable": "scrollable"; }, { "init": "init"; "blur": "blur"; }, never, never>;
33
+ static ɵcmp: i0.ɵɵComponentDeclaration<FsTextEditorComponent, "fs-text-editor", never, { "config": "config"; "scrollable": "scrollable"; }, { "ready": "ready"; "blur": "blur"; }, never, never>;
37
34
  }
@@ -1,4 +1,5 @@
1
1
  import { editor } from 'monaco-editor';
2
2
  export interface FsTextEditorConfig extends editor.IStandaloneEditorConstructionOptions {
3
3
  autoHeight?: boolean;
4
+ ready?: (editor: editor.ICodeEditor) => void;
4
5
  }
@@ -1,18 +1,19 @@
1
1
  import { AfterViewInit, ElementRef, EventEmitter, OnDestroy } from '@angular/core';
2
2
  import { Subscription } from 'rxjs';
3
+ import { editor } from 'monaco-editor';
3
4
  import { NgxMonacoEditorConfig } from './config';
4
5
  import * as i0 from "@angular/core";
5
6
  export declare abstract class BaseEditor implements AfterViewInit, OnDestroy {
6
7
  protected config: NgxMonacoEditorConfig;
7
8
  _editorContainer: ElementRef;
8
9
  onInit: EventEmitter<any>;
9
- protected _editor: any;
10
+ protected _editor: editor.ICodeEditor;
10
11
  protected _options: any;
11
12
  protected _windowResizeSubscription: Subscription;
12
13
  constructor(config: NgxMonacoEditorConfig);
13
14
  ngAfterViewInit(): void;
14
- protected abstract initMonaco(options: any): void;
15
15
  ngOnDestroy(): void;
16
+ protected abstract initMonaco(options: any): void;
16
17
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseEditor, never>;
17
18
  static ɵcmp: i0.ɵɵComponentDeclaration<BaseEditor, "ng-component", never, {}, { "onInit": "onInit"; }, never, never>;
18
19
  }
@@ -509,15 +509,15 @@
509
509
  else {
510
510
  loadedMonaco = true;
511
511
  loadPromise = new Promise(function (resolve) {
512
- var baseUrl = (_this.config.baseUrl || './assets') + '/monaco-editor/min/vs';
512
+ var baseUrl = (_this.config.baseUrl || './assets') + "/monaco-editor/min/vs";
513
513
  if (typeof (window.monaco) === 'object') {
514
514
  resolve();
515
515
  return;
516
516
  }
517
517
  var onGotAmdLoader = function () {
518
518
  // Load monaco
519
- window.require.config({ paths: { 'vs': "" + baseUrl } });
520
- window.require(["vs/editor/editor.main"], function () {
519
+ window.require.config({ paths: { vs: "" + baseUrl } });
520
+ window.require(['vs/editor/editor.main'], function () {
521
521
  if (typeof _this.config.onMonacoLoad === 'function') {
522
522
  _this.config.onMonacoLoad();
523
523
  }
@@ -555,7 +555,7 @@
555
555
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: BaseEditor, decorators: [{
556
556
  type: i0.Component,
557
557
  args: [{
558
- template: ''
558
+ template: '',
559
559
  }]
560
560
  }], ctorParameters: function () {
561
561
  return [{ type: undefined, decorators: [{
@@ -585,7 +585,7 @@
585
585
  return this._options;
586
586
  },
587
587
  set: function (options) {
588
- this._options = Object.assign({}, this.config.defaultOptions, options);
588
+ this._options = Object.assign(Object.assign({}, this.config.defaultOptions), options);
589
589
  if (this._editor) {
590
590
  this._editor.dispose();
591
591
  this.initMonaco(options);
@@ -662,7 +662,7 @@
662
662
  EditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: EditorComponent, selector: "ngx-monaco-editor", inputs: { options: "options", model: "model" }, providers: [{
663
663
  provide: i2.NG_VALUE_ACCESSOR,
664
664
  useExisting: i0.forwardRef(function () { return EditorComponent; }),
665
- multi: true
665
+ multi: true,
666
666
  }], usesInheritance: true, ngImport: i0__namespace, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: ["\n :host {\n display: block;\n height: 200px;\n }\n\n .editor-container {\n width: 100%;\n height: 98%;\n }\n "] });
667
667
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: EditorComponent, decorators: [{
668
668
  type: i0.Component,
@@ -673,8 +673,8 @@
673
673
  providers: [{
674
674
  provide: i2.NG_VALUE_ACCESSOR,
675
675
  useExisting: i0.forwardRef(function () { return EditorComponent; }),
676
- multi: true
677
- }]
676
+ multi: true,
677
+ }],
678
678
  }]
679
679
  }], ctorParameters: function () {
680
680
  return [{ type: i0__namespace.NgZone }, { type: undefined, decorators: [{
@@ -690,31 +690,28 @@
690
690
  }] } });
691
691
 
692
692
  var FsTextEditorComponent = /** @class */ (function () {
693
- function FsTextEditorComponent(_element, _document) {
694
- this._element = _element;
693
+ function FsTextEditorComponent(_document) {
695
694
  this._document = _document;
695
+ this.LINE_HEIGHT = 18;
696
696
  this.config = {};
697
697
  this.scrollable = false;
698
- this.init = new i0.EventEmitter();
698
+ this.ready = new i0.EventEmitter();
699
699
  this.blur = new i0.EventEmitter();
700
700
  this.defaultConfig = {
701
701
  minimap: {
702
- enabled: false
702
+ enabled: false,
703
703
  },
704
704
  theme: 'vs-dark',
705
705
  automaticLayout: false,
706
706
  scrollBeyondLastLine: false,
707
707
  autoHeight: true,
708
708
  scrollbar: {
709
- vertical: 'hidden'
709
+ vertical: 'hidden',
710
710
  },
711
- hideCursorInOverviewRuler: true
711
+ hideCursorInOverviewRuler: true,
712
712
  };
713
- this.onChange = function (_) { };
714
- this.onTouched = function () { };
715
- this._window = this._document.defaultView;
716
- this.LINE_HEIGHT = 18;
717
713
  this._value = '';
714
+ this._window = this._document.defaultView;
718
715
  }
719
716
  Object.defineProperty(FsTextEditorComponent.prototype, "monaco", {
720
717
  get: function () {
@@ -723,11 +720,9 @@
723
720
  enumerable: false,
724
721
  configurable: true
725
722
  });
726
- ;
727
- ;
728
723
  FsTextEditorComponent.prototype.ngOnInit = function () {
729
724
  if (this.config) {
730
- this.config = Object.assign({}, this.defaultConfig, this.config);
725
+ this.config = Object.assign(Object.assign({}, this.defaultConfig), this.config);
731
726
  }
732
727
  };
733
728
  FsTextEditorComponent.prototype.ngOnDestroy = function () {
@@ -747,10 +742,13 @@
747
742
  setTimeout(function () {
748
743
  _this._editorRef = event;
749
744
  _this._initEditor();
750
- _this.init.next(event);
745
+ _this.ready.next(event);
751
746
  if (!_this.scrollable) {
752
747
  _this._disableScroll();
753
748
  }
749
+ if (_this.config.ready) {
750
+ _this.config.ready(_this._editorRef);
751
+ }
754
752
  });
755
753
  };
756
754
  FsTextEditorComponent.prototype.writeValue = function (value) {
@@ -762,6 +760,9 @@
762
760
  this.onChange(e);
763
761
  }
764
762
  };
763
+ FsTextEditorComponent.prototype.updateLayout = function () {
764
+ this._editorRef.layout();
765
+ };
765
766
  FsTextEditorComponent.prototype.registerOnChange = function (fn) {
766
767
  this.onChange = fn;
767
768
  };
@@ -795,12 +796,9 @@
795
796
  }
796
797
  var nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;
797
798
  // set the height and redo layout
798
- editorDomNode.style.height = nextHeight + 'px';
799
+ editorDomNode.style.height = nextHeight + "px";
799
800
  this.updateLayout();
800
801
  };
801
- FsTextEditorComponent.prototype.updateLayout = function () {
802
- this._editorRef.layout();
803
- };
804
802
  FsTextEditorComponent.prototype._disableScroll = function () {
805
803
  var node = this._editorRef.getDomNode();
806
804
  node.addEventListener('wheel', function (e) {
@@ -809,26 +807,26 @@
809
807
  };
810
808
  return FsTextEditorComponent;
811
809
  }());
812
- FsTextEditorComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FsTextEditorComponent, deps: [{ token: i0__namespace.ElementRef }, { token: common.DOCUMENT }], target: i0__namespace.ɵɵFactoryTarget.Component });
813
- FsTextEditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FsTextEditorComponent, selector: "fs-text-editor", inputs: { config: "config", scrollable: "scrollable" }, outputs: { init: "init", blur: "blur" }, providers: [{
810
+ FsTextEditorComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FsTextEditorComponent, deps: [{ token: common.DOCUMENT }], target: i0__namespace.ɵɵFactoryTarget.Component });
811
+ FsTextEditorComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.17", type: FsTextEditorComponent, selector: "fs-text-editor", inputs: { config: "config", scrollable: "scrollable" }, outputs: { ready: "ready", blur: "blur" }, providers: [{
814
812
  provide: i2.NG_VALUE_ACCESSOR,
815
813
  useExisting: i0.forwardRef(function () { return FsTextEditorComponent; }),
816
- multi: true
817
- }], viewQueries: [{ propertyName: "_editorContainer", first: true, predicate: EditorComponent, descendants: true, static: true }], ngImport: i0__namespace, template: "<ngx-monaco-editor\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: [":host ngx-monaco-editor{height:100%!important}:host ::ng-deep .decorationsOverviewRuler{display:none}:host ::ng-deep .margin,:host ::ng-deep .monaco-editor-background{top:0px!important}\n"], components: [{ type: EditorComponent, selector: "ngx-monaco-editor", inputs: ["options", "model"] }], directives: [{ type: i2__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
814
+ multi: true,
815
+ }], ngImport: i0__namespace, template: "<ngx-monaco-editor\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: [":host ngx-monaco-editor{height:100%!important}:host ::ng-deep .decorationsOverviewRuler{display:none}:host ::ng-deep .margin,:host ::ng-deep .monaco-editor-background{top:0px!important}\n"], components: [{ type: EditorComponent, selector: "ngx-monaco-editor", inputs: ["options", "model"] }], directives: [{ type: i2__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
818
816
  i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FsTextEditorComponent, decorators: [{
819
817
  type: i0.Component,
820
818
  args: [{
821
819
  selector: 'fs-text-editor',
822
- templateUrl: 'text-editor.component.html',
823
- styleUrls: ['text-editor.component.scss'],
820
+ templateUrl: './text-editor.component.html',
821
+ styleUrls: ['./text-editor.component.scss'],
824
822
  providers: [{
825
823
  provide: i2.NG_VALUE_ACCESSOR,
826
824
  useExisting: i0.forwardRef(function () { return FsTextEditorComponent; }),
827
- multi: true
828
- }]
825
+ multi: true,
826
+ }],
829
827
  }]
830
828
  }], ctorParameters: function () {
831
- return [{ type: i0__namespace.ElementRef }, { type: Document, decorators: [{
829
+ return [{ type: Document, decorators: [{
832
830
  type: i0.Inject,
833
831
  args: [common.DOCUMENT]
834
832
  }] }];
@@ -836,13 +834,10 @@
836
834
  type: i0.Input
837
835
  }], scrollable: [{
838
836
  type: i0.Input
839
- }], init: [{
837
+ }], ready: [{
840
838
  type: i0.Output
841
839
  }], blur: [{
842
840
  type: i0.Output
843
- }], _editorContainer: [{
844
- type: i0.ViewChild,
845
- args: [EditorComponent, { static: true }]
846
841
  }] } });
847
842
 
848
843
  var DiffEditorComponent = /** @class */ (function (_super) {
@@ -857,7 +852,7 @@
857
852
  return this._options;
858
853
  },
859
854
  set: function (options) {
860
- this._options = Object.assign({}, this.config.defaultOptions, options);
855
+ this._options = Object.assign(Object.assign({}, this.config.defaultOptions), options);
861
856
  if (this._editor) {
862
857
  this._editor.dispose();
863
858
  this.initMonaco(options);
@@ -903,7 +898,7 @@
903
898
  options.theme = theme;
904
899
  this._editor.setModel({
905
900
  original: originalModel,
906
- modified: modifiedModel
901
+ modified: modifiedModel,
907
902
  });
908
903
  // refresh layout on resize event.
909
904
  if (this._windowResizeSubscription) {
@@ -921,7 +916,7 @@
921
916
  args: [{
922
917
  selector: 'ngx-monaco-diff-editor',
923
918
  template: '<div class="editor-container" #editorContainer></div>',
924
- styles: ["\n :host {\n display: block;\n height: 200px;\n }\n\n .editor-container {\n width: 100%;\n height: 98%;\n }\n "]
919
+ styles: ["\n :host {\n display: block;\n height: 200px;\n }\n\n .editor-container {\n width: 100%;\n height: 98%;\n }\n "],
925
920
  }]
926
921
  }], ctorParameters: function () {
927
922
  return [{ type: undefined, decorators: [{