@firestitch/text-editor 9.0.3 → 12.0.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.
@@ -1,191 +0,0 @@
1
- import { __decorate, __metadata } from 'tslib';
2
- import { EventEmitter, ElementRef, Input, Output, ViewChild, Component, forwardRef, NgModule } from '@angular/core';
3
- import { CommonModule } from '@angular/common';
4
- import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
5
- import { EditorComponent, MonacoEditorModule } from 'ngx-monaco-editor';
6
-
7
- var FsTextEditorComponent = /** @class */ (function () {
8
- function FsTextEditorComponent(_element) {
9
- this._element = _element;
10
- this.config = {};
11
- this.scrollable = false;
12
- this.init = new EventEmitter();
13
- this.blur = new EventEmitter();
14
- this.defaultConfig = {
15
- minimap: {
16
- enabled: false
17
- },
18
- theme: 'vs-dark',
19
- automaticLayout: false,
20
- scrollBeyondLastLine: false,
21
- autoHeight: true,
22
- scrollbar: {
23
- vertical: 'hidden'
24
- },
25
- hideCursorInOverviewRuler: true
26
- };
27
- this.onChange = function (_) { };
28
- this.onTouched = function () { };
29
- this.LINE_HEIGHT = 18;
30
- this._value = '';
31
- }
32
- FsTextEditorComponent_1 = FsTextEditorComponent;
33
- Object.defineProperty(FsTextEditorComponent.prototype, "monaco", {
34
- get: function () {
35
- return window.monaco;
36
- },
37
- enumerable: true,
38
- configurable: true
39
- });
40
- ;
41
- ;
42
- FsTextEditorComponent.prototype.ngOnInit = function () {
43
- if (this.config) {
44
- this.config = Object.assign({}, this.defaultConfig, this.config);
45
- }
46
- };
47
- Object.defineProperty(FsTextEditorComponent.prototype, "value", {
48
- get: function () {
49
- return this._value;
50
- },
51
- enumerable: true,
52
- configurable: true
53
- });
54
- FsTextEditorComponent.prototype.onEditorInit = function (event) {
55
- var _this = this;
56
- // Timeout allows the content to fully load to and calculate height
57
- setTimeout(function () {
58
- _this._editorRef = event;
59
- _this._initEditor();
60
- _this.init.next(event);
61
- if (!_this.scrollable) {
62
- _this._disableScroll();
63
- }
64
- });
65
- };
66
- FsTextEditorComponent.prototype.writeValue = function (value) {
67
- this._value = value || '';
68
- };
69
- FsTextEditorComponent.prototype.changed = function (e) {
70
- if (this._value !== e) {
71
- this._value = e;
72
- this.onChange(e);
73
- }
74
- };
75
- FsTextEditorComponent.prototype.registerOnChange = function (fn) {
76
- this.onChange = fn;
77
- };
78
- FsTextEditorComponent.prototype.registerOnTouched = function (fn) {
79
- this.onTouched = fn;
80
- };
81
- FsTextEditorComponent.prototype._initEditor = function () {
82
- var _this = this;
83
- if (this._editorRef && this.config.autoHeight) {
84
- this._updateEditorHeight();
85
- this._editorRef.onDidChangeModelContent(function (e) {
86
- _this._updateEditorHeight();
87
- });
88
- this._editorRef.onDidBlurEditorText(function () {
89
- _this.blur.next();
90
- });
91
- }
92
- };
93
- FsTextEditorComponent.prototype._updateEditorHeight = function () {
94
- var editorDomNode = this._editorRef.getDomNode();
95
- if (!editorDomNode) {
96
- return;
97
- }
98
- var container = editorDomNode.getElementsByClassName('view-lines')[0];
99
- var lineHeight = container.firstChild
100
- ? container.firstChild.offsetHeight
101
- : this.LINE_HEIGHT;
102
- var editorModel = this._editorRef.getModel();
103
- if (!editorModel) {
104
- return;
105
- }
106
- var nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;
107
- // set the height and redo layout
108
- editorDomNode.style.height = nextHeight + 'px';
109
- this.updateLayout();
110
- };
111
- FsTextEditorComponent.prototype.updateLayout = function () {
112
- this._editorRef.layout();
113
- };
114
- FsTextEditorComponent.prototype._disableScroll = function () {
115
- var node = this._editorRef.getDomNode();
116
- node.addEventListener('wheel', function (e) {
117
- e.stopPropagation();
118
- }, true);
119
- };
120
- var FsTextEditorComponent_1;
121
- FsTextEditorComponent.ctorParameters = function () { return [
122
- { type: ElementRef }
123
- ]; };
124
- __decorate([
125
- Input(),
126
- __metadata("design:type", Object)
127
- ], FsTextEditorComponent.prototype, "config", void 0);
128
- __decorate([
129
- Input(),
130
- __metadata("design:type", Object)
131
- ], FsTextEditorComponent.prototype, "scrollable", void 0);
132
- __decorate([
133
- Output(),
134
- __metadata("design:type", Object)
135
- ], FsTextEditorComponent.prototype, "init", void 0);
136
- __decorate([
137
- Output(),
138
- __metadata("design:type", Object)
139
- ], FsTextEditorComponent.prototype, "blur", void 0);
140
- __decorate([
141
- ViewChild(EditorComponent, { static: true }),
142
- __metadata("design:type", EditorComponent)
143
- ], FsTextEditorComponent.prototype, "_editorContainer", void 0);
144
- FsTextEditorComponent = FsTextEditorComponent_1 = __decorate([
145
- Component({
146
- selector: 'fs-text-editor',
147
- template: "<ngx-monaco-editor\n [ngModel]=\"value\"\n (ngModelChange)=\"changed($event)\"\n [options]=\"config\"\n (onInit)=\"onEditorInit($event)\">\n</ngx-monaco-editor>\n",
148
- providers: [{
149
- provide: NG_VALUE_ACCESSOR,
150
- useExisting: forwardRef(function () { return FsTextEditorComponent_1; }),
151
- multi: true
152
- }],
153
- 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:0!important}"]
154
- }),
155
- __metadata("design:paramtypes", [ElementRef])
156
- ], FsTextEditorComponent);
157
- return FsTextEditorComponent;
158
- }());
159
-
160
- var FsTextEditorModule = /** @class */ (function () {
161
- function FsTextEditorModule() {
162
- }
163
- FsTextEditorModule = __decorate([
164
- NgModule({
165
- imports: [
166
- CommonModule,
167
- MonacoEditorModule,
168
- FormsModule,
169
- ],
170
- exports: [
171
- FsTextEditorComponent,
172
- ],
173
- entryComponents: [],
174
- declarations: [
175
- FsTextEditorComponent,
176
- ]
177
- })
178
- ], FsTextEditorModule);
179
- return FsTextEditorModule;
180
- }());
181
-
182
- /*
183
- * Public API Surface of fs-menu
184
- */
185
-
186
- /**
187
- * Generated bundle index. Do not edit.
188
- */
189
-
190
- export { FsTextEditorComponent, FsTextEditorModule };
191
- //# sourceMappingURL=firestitch-text-editor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"firestitch-text-editor.js","sources":["ng://@firestitch/text-editor/app/components/text-editor/text-editor.component.ts","ng://@firestitch/text-editor/app/fs-text-editor.module.ts","ng://@firestitch/text-editor/public_api.ts","ng://@firestitch/text-editor/firestitch-text-editor.ts"],"sourcesContent":["import { Component, EventEmitter, forwardRef, Input, OnInit, Output, ViewChild, ElementRef } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { EditorComponent } from 'ngx-monaco-editor';\n\nimport ICodeEditor = monaco.editor.ICodeEditor;\n\nimport { FsTextEditorConfig } from '../../interfaces/config.interface';\n\n\n@Component({\n selector: 'fs-text-editor',\n templateUrl: 'text-editor.component.html',\n styleUrls: [ 'text-editor.component.scss' ],\n providers: [{\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => FsTextEditorComponent),\n multi: true\n }]\n})\nexport class FsTextEditorComponent implements OnInit, ControlValueAccessor {\n\n @Input() public config: FsTextEditorConfig = {};\n @Input() public scrollable = false;\n\n @Output() public init = new EventEmitter();\n @Output() public blur = new EventEmitter();\n @ViewChild(EditorComponent, { static: true }) _editorContainer: EditorComponent;\n\n public defaultConfig: FsTextEditorConfig = {\n minimap: {\n enabled: false\n },\n theme: 'vs-dark',\n automaticLayout: false,\n scrollBeyondLastLine: false,\n autoHeight: true,\n scrollbar: {\n vertical: 'hidden'\n },\n hideCursorInOverviewRuler: true\n };\n\n public onChange = (_: any) => {};\n public onTouched = () => {};\n\n public get monaco() {\n return (<any>window).monaco;\n };\n\n constructor(private _element: ElementRef) {};\n\n public readonly LINE_HEIGHT = 18;\n\n private _editorRef: ICodeEditor;\n private _value = '';\n\n public ngOnInit() {\n\n if (this.config) {\n this.config = Object.assign({}, this.defaultConfig, this.config);\n }\n }\n\n get value() {\n return this._value;\n }\n\n public onEditorInit(event) {\n // Timeout allows the content to fully load to and calculate height\n setTimeout(() => {\n this._editorRef = event;\n this._initEditor();\n this.init.next(event);\n\n if (!this.scrollable) {\n this._disableScroll();\n }\n });\n }\n\n public writeValue(value: any): void {\n this._value = value || '';\n }\n\n public changed(e) {\n if (this._value !== e) {\n this._value = e;\n this.onChange(e);\n }\n }\n\n public registerOnChange(fn: any): void {\n this.onChange = fn;\n }\n\n public registerOnTouched(fn: any): void {\n this.onTouched = fn;\n }\n\n private _initEditor() {\n if (this._editorRef && this.config.autoHeight) {\n this._updateEditorHeight();\n\n this._editorRef.onDidChangeModelContent((e) => {\n this._updateEditorHeight();\n });\n\n this._editorRef.onDidBlurEditorText(() => {\n this.blur.next();\n });\n }\n }\n\n private _updateEditorHeight() {\n\n const editorDomNode = this._editorRef.getDomNode();\n\n if (!editorDomNode) {\n return;\n }\n\n const container = editorDomNode.getElementsByClassName('view-lines')[0] as HTMLElement;\n const lineHeight = container.firstChild\n ? (container.firstChild as HTMLElement).offsetHeight\n : this.LINE_HEIGHT;\n\n const editorModel = this._editorRef.getModel();\n\n if (!editorModel) {\n return;\n }\n\n const nextHeight = this._editorRef.getModel().getLineCount() * lineHeight;\n\n // set the height and redo layout\n editorDomNode.style.height = nextHeight + 'px';\n this.updateLayout();\n }\n\n public updateLayout(): void {\n this._editorRef.layout();\n }\n\n private _disableScroll() {\n const node = this._editorRef.getDomNode();\n\n node.addEventListener('wheel', (e) => {\n e.stopPropagation();\n }, true);\n }\n}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { FormsModule } from '@angular/forms';\n\nimport { MonacoEditorModule } from 'ngx-monaco-editor';\nimport { FsTextEditorComponent } from './components/text-editor/text-editor.component';\n\n@NgModule({\n imports: [\n CommonModule,\n MonacoEditorModule,\n FormsModule,\n ],\n exports: [\n FsTextEditorComponent,\n ],\n entryComponents: [\n ],\n declarations: [\n FsTextEditorComponent,\n ]\n})\nexport class FsTextEditorModule {\n\n}\n","/*\n * Public API Surface of fs-menu\n */\n\nimport { from } from 'rxjs';\n\nexport { FsTextEditorModule } from './app/fs-text-editor.module';\n\nexport { FsTextEditorConfig } from './app/interfaces/config.interface';\n\n\nexport { FsTextEditorComponent } from './app/components/text-editor/text-editor.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;IAiDE,+BAAoB,QAAoB;QAApB,aAAQ,GAAR,QAAQ,CAAY;QA5BxB,WAAM,GAAuB,EAAE,CAAC;QAChC,eAAU,GAAG,KAAK,CAAC;QAElB,SAAI,GAAG,IAAI,YAAY,EAAE,CAAC;QAC1B,SAAI,GAAG,IAAI,YAAY,EAAE,CAAC;QAGpC,kBAAa,GAAuB;YACzC,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;aACf;YACD,KAAK,EAAE,SAAS;YAChB,eAAe,EAAE,KAAK;YACtB,oBAAoB,EAAE,KAAK;YAC3B,UAAU,EAAE,IAAI;YAChB,SAAS,EAAE;gBACT,QAAQ,EAAE,QAAQ;aACnB;YACD,yBAAyB,EAAE,IAAI;SAChC,CAAC;QAEK,aAAQ,GAAG,UAAC,CAAM,KAAO,CAAC;QAC1B,cAAS,GAAG,eAAQ,CAAC;QAQZ,gBAAW,GAAG,EAAE,CAAC;QAGzB,WAAM,GAAG,EAAE,CAAC;KALwB;8BA9BjC,qBAAqB;IA0BhC,sBAAW,yCAAM;aAAjB;YACE,OAAa,MAAO,CAAC,MAAM,CAAC;SAC7B;;;OAAA;IAAA,CAAC;IAE0C,CAAC;IAOtC,wCAAQ,GAAf;QAEE,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;SAClE;KACF;IAED,sBAAI,wCAAK;aAAT;YACE,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;;;OAAA;IAEM,4CAAY,GAAnB,UAAoB,KAAK;QAAzB,iBAWC;;QATC,UAAU,CAAC;YACT,KAAI,CAAC,UAAU,GAAG,KA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