@firestitch/text-editor 12.4.1 → 12.4.3
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.
- package/app/components/text-editor/text-editor.component.d.ts +8 -12
- package/app/interfaces/config.interface.d.ts +2 -0
- package/app/modules/ngx-monaco-editor/base-editor.d.ts +3 -2
- package/bundles/firestitch-text-editor.umd.js +41 -55
- package/bundles/firestitch-text-editor.umd.js.map +1 -1
- package/esm2015/app/components/text-editor/text-editor.component.js +30 -45
- package/esm2015/app/interfaces/config.interface.js +1 -1
- package/esm2015/app/modules/ngx-monaco-editor/base-editor.js +5 -5
- package/esm2015/app/modules/ngx-monaco-editor/diff-editor.component.js +6 -6
- package/esm2015/app/modules/ngx-monaco-editor/editor.component.js +7 -10
- package/fesm2015/firestitch-text-editor.js +43 -60
- package/fesm2015/firestitch-text-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
import {
|
|
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
|
-
|
|
10
|
+
ready: EventEmitter<any>;
|
|
12
11
|
blur: EventEmitter<any>;
|
|
13
|
-
_editorContainer: EditorComponent;
|
|
14
|
-
defaultConfig: FsTextEditorConfig;
|
|
15
12
|
onChange: (_: any) => void;
|
|
16
13
|
onTouched: () => void;
|
|
17
|
-
private _window;
|
|
18
|
-
get monaco(): any;
|
|
19
|
-
constructor(_element: ElementRef, _document: Document);
|
|
20
|
-
readonly LINE_HEIGHT = 18;
|
|
21
14
|
private _editorRef;
|
|
22
15
|
private _value;
|
|
16
|
+
private _window;
|
|
17
|
+
constructor(_document: Document);
|
|
18
|
+
get monaco(): any;
|
|
23
19
|
ngOnInit(): void;
|
|
24
20
|
ngOnDestroy(): void;
|
|
25
21
|
get value(): string;
|
|
26
22
|
onEditorInit(event: any): void;
|
|
27
23
|
writeValue(value: any): void;
|
|
28
24
|
changed(e: any): void;
|
|
25
|
+
updateLayout(): void;
|
|
29
26
|
registerOnChange(fn: any): void;
|
|
30
27
|
registerOnTouched(fn: any): void;
|
|
31
28
|
private _initEditor;
|
|
32
29
|
private _updateEditorHeight;
|
|
33
|
-
updateLayout(): void;
|
|
34
30
|
private _disableScroll;
|
|
35
31
|
static ɵfac: i0.ɵɵFactoryDeclaration<FsTextEditorComponent, never>;
|
|
36
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<FsTextEditorComponent, "fs-text-editor", never, { "config": "config"; "scrollable": "scrollable"; }, { "
|
|
32
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<FsTextEditorComponent, "fs-text-editor", never, { "config": "config"; "scrollable": "scrollable"; }, { "ready": "ready"; "blur": "blur"; }, never, never>;
|
|
37
33
|
}
|
|
@@ -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:
|
|
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') +
|
|
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: {
|
|
520
|
-
window.require([
|
|
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,19 +662,19 @@
|
|
|
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
|
|
666
|
-
}], usesInheritance: true, ngImport: i0__namespace, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: ["\n
|
|
665
|
+
multi: true,
|
|
666
|
+
}], usesInheritance: true, ngImport: i0__namespace, template: '<div class="editor-container" #editorContainer></div>', isInline: true, styles: ["\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,
|
|
669
669
|
args: [{
|
|
670
670
|
selector: 'ngx-monaco-editor',
|
|
671
671
|
template: '<div class="editor-container" #editorContainer></div>',
|
|
672
|
-
styles: ["\n
|
|
672
|
+
styles: ["\n\n\n .editor-container {\n width: 100%;\n height: 98%;\n }\n "],
|
|
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,15 @@
|
|
|
690
690
|
}] } });
|
|
691
691
|
|
|
692
692
|
var FsTextEditorComponent = /** @class */ (function () {
|
|
693
|
-
function FsTextEditorComponent(
|
|
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.
|
|
698
|
+
this.ready = new i0.EventEmitter();
|
|
699
699
|
this.blur = new i0.EventEmitter();
|
|
700
|
-
this.defaultConfig = {
|
|
701
|
-
minimap: {
|
|
702
|
-
enabled: false
|
|
703
|
-
},
|
|
704
|
-
theme: 'vs-dark',
|
|
705
|
-
automaticLayout: false,
|
|
706
|
-
scrollBeyondLastLine: false,
|
|
707
|
-
autoHeight: true,
|
|
708
|
-
scrollbar: {
|
|
709
|
-
vertical: 'hidden'
|
|
710
|
-
},
|
|
711
|
-
hideCursorInOverviewRuler: true
|
|
712
|
-
};
|
|
713
|
-
this.onChange = function (_) { };
|
|
714
|
-
this.onTouched = function () { };
|
|
715
|
-
this._window = this._document.defaultView;
|
|
716
|
-
this.LINE_HEIGHT = 18;
|
|
717
700
|
this._value = '';
|
|
701
|
+
this._window = this._document.defaultView;
|
|
718
702
|
}
|
|
719
703
|
Object.defineProperty(FsTextEditorComponent.prototype, "monaco", {
|
|
720
704
|
get: function () {
|
|
@@ -723,11 +707,13 @@
|
|
|
723
707
|
enumerable: false,
|
|
724
708
|
configurable: true
|
|
725
709
|
});
|
|
726
|
-
;
|
|
727
|
-
;
|
|
728
710
|
FsTextEditorComponent.prototype.ngOnInit = function () {
|
|
729
711
|
if (this.config) {
|
|
730
|
-
this.config = Object.assign({
|
|
712
|
+
this.config = Object.assign({ minimap: {
|
|
713
|
+
enabled: false,
|
|
714
|
+
}, theme: 'vs-dark', automaticLayout: !!this.config.height, scrollBeyondLastLine: false, autoHeight: !this.config.height, scrollbar: {
|
|
715
|
+
vertical: this.config.height ? 'auto' : 'hidden',
|
|
716
|
+
}, hideCursorInOverviewRuler: true }, this.config);
|
|
731
717
|
}
|
|
732
718
|
};
|
|
733
719
|
FsTextEditorComponent.prototype.ngOnDestroy = function () {
|
|
@@ -747,10 +733,13 @@
|
|
|
747
733
|
setTimeout(function () {
|
|
748
734
|
_this._editorRef = event;
|
|
749
735
|
_this._initEditor();
|
|
750
|
-
_this.
|
|
751
|
-
if (!_this.scrollable) {
|
|
736
|
+
_this.ready.next(event);
|
|
737
|
+
if (!_this.scrollable && !_this.config.height) {
|
|
752
738
|
_this._disableScroll();
|
|
753
739
|
}
|
|
740
|
+
if (_this.config.ready) {
|
|
741
|
+
_this.config.ready(_this._editorRef);
|
|
742
|
+
}
|
|
754
743
|
});
|
|
755
744
|
};
|
|
756
745
|
FsTextEditorComponent.prototype.writeValue = function (value) {
|
|
@@ -762,6 +751,9 @@
|
|
|
762
751
|
this.onChange(e);
|
|
763
752
|
}
|
|
764
753
|
};
|
|
754
|
+
FsTextEditorComponent.prototype.updateLayout = function () {
|
|
755
|
+
this._editorRef.layout();
|
|
756
|
+
};
|
|
765
757
|
FsTextEditorComponent.prototype.registerOnChange = function (fn) {
|
|
766
758
|
this.onChange = fn;
|
|
767
759
|
};
|
|
@@ -795,12 +787,9 @@
|
|
|
795
787
|
}
|
|
796
788
|
var nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;
|
|
797
789
|
// set the height and redo layout
|
|
798
|
-
editorDomNode.style.height = nextHeight +
|
|
790
|
+
editorDomNode.style.height = nextHeight + "px";
|
|
799
791
|
this.updateLayout();
|
|
800
792
|
};
|
|
801
|
-
FsTextEditorComponent.prototype.updateLayout = function () {
|
|
802
|
-
this._editorRef.layout();
|
|
803
|
-
};
|
|
804
793
|
FsTextEditorComponent.prototype._disableScroll = function () {
|
|
805
794
|
var node = this._editorRef.getDomNode();
|
|
806
795
|
node.addEventListener('wheel', function (e) {
|
|
@@ -809,26 +798,26 @@
|
|
|
809
798
|
};
|
|
810
799
|
return FsTextEditorComponent;
|
|
811
800
|
}());
|
|
812
|
-
FsTextEditorComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FsTextEditorComponent, deps: [{ token:
|
|
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: {
|
|
801
|
+
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 });
|
|
802
|
+
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
803
|
provide: i2.NG_VALUE_ACCESSOR,
|
|
815
804
|
useExisting: i0.forwardRef(function () { return FsTextEditorComponent; }),
|
|
816
|
-
multi: true
|
|
817
|
-
}],
|
|
805
|
+
multi: true,
|
|
806
|
+
}], ngImport: i0__namespace, template: "<ngx-monaco-editor\n [style.height]=\"config.height\"\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n", styles: ["ngx-monaco-editor{display:block}\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
807
|
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.17", ngImport: i0__namespace, type: FsTextEditorComponent, decorators: [{
|
|
819
808
|
type: i0.Component,
|
|
820
809
|
args: [{
|
|
821
810
|
selector: 'fs-text-editor',
|
|
822
|
-
templateUrl: 'text-editor.component.html',
|
|
823
|
-
styleUrls: ['text-editor.component.scss'],
|
|
811
|
+
templateUrl: './text-editor.component.html',
|
|
812
|
+
styleUrls: ['./text-editor.component.scss'],
|
|
824
813
|
providers: [{
|
|
825
814
|
provide: i2.NG_VALUE_ACCESSOR,
|
|
826
815
|
useExisting: i0.forwardRef(function () { return FsTextEditorComponent; }),
|
|
827
|
-
multi: true
|
|
828
|
-
}]
|
|
816
|
+
multi: true,
|
|
817
|
+
}],
|
|
829
818
|
}]
|
|
830
819
|
}], ctorParameters: function () {
|
|
831
|
-
return [{ type:
|
|
820
|
+
return [{ type: Document, decorators: [{
|
|
832
821
|
type: i0.Inject,
|
|
833
822
|
args: [common.DOCUMENT]
|
|
834
823
|
}] }];
|
|
@@ -836,13 +825,10 @@
|
|
|
836
825
|
type: i0.Input
|
|
837
826
|
}], scrollable: [{
|
|
838
827
|
type: i0.Input
|
|
839
|
-
}],
|
|
828
|
+
}], ready: [{
|
|
840
829
|
type: i0.Output
|
|
841
830
|
}], blur: [{
|
|
842
831
|
type: i0.Output
|
|
843
|
-
}], _editorContainer: [{
|
|
844
|
-
type: i0.ViewChild,
|
|
845
|
-
args: [EditorComponent, { static: true }]
|
|
846
832
|
}] } });
|
|
847
833
|
|
|
848
834
|
var DiffEditorComponent = /** @class */ (function (_super) {
|
|
@@ -857,7 +843,7 @@
|
|
|
857
843
|
return this._options;
|
|
858
844
|
},
|
|
859
845
|
set: function (options) {
|
|
860
|
-
this._options = Object.assign({}, this.config.defaultOptions, options);
|
|
846
|
+
this._options = Object.assign(Object.assign({}, this.config.defaultOptions), options);
|
|
861
847
|
if (this._editor) {
|
|
862
848
|
this._editor.dispose();
|
|
863
849
|
this.initMonaco(options);
|
|
@@ -903,7 +889,7 @@
|
|
|
903
889
|
options.theme = theme;
|
|
904
890
|
this._editor.setModel({
|
|
905
891
|
original: originalModel,
|
|
906
|
-
modified: modifiedModel
|
|
892
|
+
modified: modifiedModel,
|
|
907
893
|
});
|
|
908
894
|
// refresh layout on resize event.
|
|
909
895
|
if (this._windowResizeSubscription) {
|
|
@@ -921,7 +907,7 @@
|
|
|
921
907
|
args: [{
|
|
922
908
|
selector: 'ngx-monaco-diff-editor',
|
|
923
909
|
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 "]
|
|
910
|
+
styles: ["\n :host {\n display: block;\n height: 200px;\n }\n\n .editor-container {\n width: 100%;\n height: 98%;\n }\n "],
|
|
925
911
|
}]
|
|
926
912
|
}], ctorParameters: function () {
|
|
927
913
|
return [{ type: undefined, decorators: [{
|