all files / component/monaco-editor/ monaco-editor.component.ts

86.12% Statements 211/245
38.3% Branches 18/47
59.26% Functions 16/27
85.59% Lines 202/236
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          60×                                                            
/*
 *  @license
 *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.
 *
 *  Use of this source code is governed by an Apache-2.0 license that can be
 *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE
 */
 
import { AfterViewInit, Component, ElementRef, EventEmitter, HostListener, Input, OnChanges, OnDestroy, Optional, Output, Self, ViewChild, ViewEncapsulation } from '@angular/core';
import { ControlValueAccessor, NgControl } from '@angular/forms';
import { MonacoEditorService } from './monaco-editor.service';
import { EditorOptions } from './options/editor-options.model';
import { EditorScrollbarOptions } from './options/editor-scrollbar-options.model';
 
declare const monaco: any;
 
/**
 * Monaco Editor Component for Angular
 *
 * The Monaco Editor is the code editor that powers [VS Code](https://github.com/Microsoft/vscode), a good page describing the code editor's features is [here](https://code.visualstudio.com/docs/editor/editingevolved).
 */
@Component({
    encapsulation: ViewEncapsulation.None,
    selector: 'deja-monaco-editor',
    styles: [
        require('./monaco-editor.component.scss'),
    ],
    template: `<div #editor resize-listener (sizeChanged)="onResize()" class='monaco-editor'></div>`,
})
export class DejaMonacoEditorComponent implements OnDestroy, AfterViewInit, OnChanges, ControlValueAccessor {
    /**
     * Enable experimental screen reader support.
     * Defaults to `true`.
     */
    @Input() public experimentalScreenReader?: boolean;
    /**
     * The aria label for the editor's textarea (when it is focused).
     */
    @Input() public ariaLabel?: string;
    /**
     * Render vertical lines at the specified columns.
     * Defaults to empty array.
     */
    @Input() public rulers?: number[];
    /**
     * A string containing the word separators used when doing word navigation.
     * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
     */
    @Input() public wordSeparators?: string;
    /**
     * Enable Linux primary clipboard.
     * Defaults to `true`.
     */
    @Input() public selectionClipboard?: boolean;
    /**
     * Control the rendering of line numbers.
     * If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
     * Otherwise, if it is a truey, line numbers will be rendered normally (equivalent of using an identity function).
     * Otherwise, line numbers will not be rendered.
     * Defaults to `true`.
     */
    @Input() public lineNumbers?: 'on' | 'off' | 'relative' | ((lineNumber: number) => string);
    /**
     * Should the corresponding line be selected when clicking on the line number?
     * Defaults to `true`.
     */
    @Input() public selectOnLineNumbers?: boolean;
    /**
     * Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits.
     * Defaults to 5.
     */
    @Input() public lineNumbersMinChars?: number;
    /**
     * Enable the rendering of the glyph margin.
     * Defaults to true in vscode and to false in monaco-editor.
     */
    @Input() public glyphMargin?: boolean;
    /**
     * The width reserved for line decorations (in px).
     * Line decorations are placed between line numbers and the editor content.
     * You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch.
     * Defaults to 10.
     */
    @Input() public lineDecorationsWidth?: number;
    /**
     * When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle.
     * This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport.
     * Defaults to 30 (px).
     */
    @Input() public revealHorizontalRightPadding?: number;
    /**
     * Render the editor selection with rounded borders.
     * Defaults to true.
     */
    @Input() public roundedSelection?: boolean;
    /**
     * Theme to be used for rendering.
     * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black'.
     * You can create custom themes via `monaco.editor.defineTheme`.
     */
    @Input() public theme?: string;
    /**
     * Should the editor be read only.
     * Defaults to false.
     */
    @Input() public readOnly?: boolean;
    /**
     * Control the behavior and rendering of the scrollbars.
     */
    @Input() public scrollbar?: EditorScrollbarOptions;
    /**
     * Display overflow widgets as `fixed`.
     * Defaults to `false`.
     */
    @Input() public fixedOverflowWidgets?: boolean;
    /**
     * The number of vertical lanes the overview ruler should render.
     * Defaults to 2.
     */
    @Input() public overviewRulerLanes?: number;
    /**
     * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
     * Defaults to 'blink'.
     */
    @Input() public cursorBlinking?: string;
    /**
     * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
     * Defaults to false.
     */
    @Input() public mouseWheelZoom?: boolean;
    /**
     * Control the cursor style, either 'block' or 'line'.
     * Defaults to 'line'.
     */
    @Input() public cursorStyle?: string;
    /**
     * Enable font ligatures.
     * Defaults to false.
     */
    @Input() public fontLigatures?: boolean;
    /**
     * Disable the use of `translate3d`.
     * Defaults to false.
     */
    @Input() public disableTranslate3d?: boolean;
    /**
     * Disable the optimizations for monospace fonts.
     * Defaults to false.
     */
    @Input() public disableMonospaceOptimizations?: boolean;
    /**
     * Should the cursor be hidden in the overview ruler.
     * Defaults to false.
     */
    @Input() public hideCursorInOverviewRuler?: boolean;
    /**
     * Enable that scrolling can go one screen size after the last line.
     * Defaults to true.
     */
    @Input() public scrollBeyondLastLine?: boolean;
    /**
     * Enable that the editor will install an interval to check if its container dom node size has changed.
     * Enabling this might have a severe performance impact.
     * Defaults to false.
     */
    @Input() public automaticLayout?: boolean;
    /**
     * Control the wrapping strategy of the editor.
     * Using -1 means no wrapping whatsoever.
     * Using 0 means viewport width wrapping (ajusts with the resizing of the editor).
     * Using a positive number means wrapping after a fixed number of characters.
     * Defaults to 300.
     */
    @Input() public wrappingColumn?: number;
    /**
     * Control the alternate style of viewport wrapping.
     * When set to true viewport wrapping is used only when the window width is less than the number of columns specified in the wrappingColumn property. Has no effect if wrappingColumn is not a positive number.
     * Defaults to false.
     */
    @Input() public wordWrap?: boolean;
    /**
     * Control indentation of wrapped lines. Can be: 'none', 'same' or 'indent'.
     * Defaults to 'same' in vscode and to 'none' in monaco-editor.
     */
    @Input() public wrappingIndent?: string;
    /**
     * Configure word wrapping characters. A break will be introduced before these characters.
     * Defaults to '{([+'.
     */
    @Input() public wordWrapBreakBeforeCharacters?: string;
    /**
     * Configure word wrapping characters. A break will be introduced after these characters.
     * Defaults to ' \t})]?|&,;'.
     */
    @Input() public wordWrapBreakAfterCharacters?: string;
    /**
     * Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
     * Defaults to '.'.
     */
    @Input() public wordWrapBreakObtrusiveCharacters?: string;
    /**
     * Performance guard: Stop rendering a line after x characters.
     * Defaults to 10000 if wrappingColumn is -1. Defaults to -1 if wrappingColumn is >= 0.
     * Use -1 to never stop rendering
     */
    @Input() public stopRenderingLineAfter?: number;
    /**
     * Enable hover.
     * Defaults to true.
     */
    @Input() public hover?: boolean;
    /**
     * Enable custom contextmenu.
     * Defaults to true.
     */
    @Input() public contextmenu?: boolean;
    /**
     * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
     * Defaults to 1.
     */
    @Input() public mouseWheelScrollSensitivity?: number;
    /**
     * Enable quick suggestions (shadow suggestions)
     * Defaults to true.
     */
    @Input() public quickSuggestions?: boolean;
    /**
     * Quick suggestions show delay (in ms)
     * Defaults to 500 (ms)
     */
    @Input() public quickSuggestionsDelay?: number;
    /**
     * Enables parameter hints
     */
    @Input() public parameterHints?: boolean;
    /**
     * Render icons in suggestions box.
     * Defaults to true.
     */
    @Input() public iconsInSuggestions?: boolean;
    /**
     * Enable auto closing brackets.
     * Defaults to true.
     */
    @Input() public autoClosingBrackets?: boolean;
    /**
     * Enable format on type.
     * Defaults to false.
     */
    @Input() public formatOnType?: boolean;
    /**
     * Enable format on paste.
     * Defaults to false.
     */
    @Input() public formatOnPaste?: boolean;
    /**
     * Enable the suggestion box to pop-up on trigger characters.
     * Defaults to true.
     */
    @Input() public suggestOnTriggerCharacters?: boolean;
    /**
     * Accept suggestions on ENTER.
     * Defaults to true.
     */
    @Input() public acceptSuggestionOnEnter?: boolean;
    /**
     * Accept suggestions on provider defined characters.
     * Defaults to true.
     */
    @Input() public acceptSuggestionOnCommitCharacter?: boolean;
    /**
     * Enable snippet suggestions. Default to 'true'.
     */
    @Input() public snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none';
    /**
     * Copying without a selection copies the current line.
     */
    @Input() public emptySelectionClipboard?: boolean;
    /**
     * Enable tab completion. Defaults to 'false'
     */
    @Input() public tabCompletion?: boolean;
    /**
     * Enable word based suggestions. Defaults to 'true'
     */
    @Input() public wordBasedSuggestions?: boolean;
    /**
     * The font size for the suggest widget.
     * Defaults to the editor font size.
     */
    @Input() public suggestFontSize?: number;
    /**
     * The line height for the suggest widget.
     * Defaults to the editor line height.
     */
    @Input() public suggestLineHeight?: number;
    /**
     * Enable selection highlight.
     * Defaults to true.
     */
    @Input() public selectionHighlight?: boolean;
    /**
     * Show code lens
     * Defaults to true.
     */
    @Input() public codeLens?: boolean;
    /**
     * Enable code folding
     * Defaults to true in vscode and to false in monaco-editor.
     */
    @Input() public folding?: boolean;
    /**
     * Enable rendering of whitespace.
     * Defaults to none.
     */
    @Input() public renderWhitespace?: 'none' | 'boundary' | 'all';
    /**
     * Enable rendering of control characters.
     * Defaults to false.
     */
    @Input() public renderControlCharacters?: boolean;
    /**
     * Enable rendering of indent guides.
     * Defaults to false.
     */
    @Input() public renderIndentGuides?: boolean;
    /**
     * Enable rendering of current line highlight.
     * Defaults to all.
     */
    @Input() public renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
    /**
     * Inserting and deleting whitespace follows tab stops.
     */
    @Input() public useTabStops?: boolean;
    /**
     * The font family
     */
    @Input() public fontFamily?: string;
    /**
     * The font weight
     */
    @Input() public fontWeight?: 'normal' | 'bold' | 'bolder' | 'lighter' | 'initial' | 'inherit' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
    /**
     * The font size
     */
    @Input() public fontSize?: number;
    /**
     * The line height
     */
    @Input() public lineHeight?: number;
    /**
     * Enable the diff editor mode
     */
    @Input() public isDiffEditor: boolean;
    /**
     * Content language
     */
    @Input()
    public set language(val: 'bat' | 'c' | 'cpp' | 'csharp' | 'css' | 'dockerfile' | 'fsharp' | 'go' | 'handlebars' | 'html' | 'ini' | 'jade' | 'javascript' | 'json' | 'less' | 'lua' | 'markdown' | 'objective-c' | 'php' | 'csharp' | 'plaintext' | 'postiats' | 'powershell' | 'python' | 'r' | 'razor' | 'ruby' | 'scss' | 'sql' | 'swift' | 'typescript' | 'vb' | 'xml' | 'yaml') {
        if (val) {
            this._language = val;
            if (this._editor) {
                this.ngAfterViewInit();
            }
        }
    }
    // @Input() public language: 'bat' | 'c' | 'cpp' | 'csharp' | 'css' | 'dockerfile' | 'fsharp' | 'go' | 'handlebars' | 'html' | 'ini' | 'jade' | 'javascript' | 'json' | 'less' | 'lua' | 'markdown' | 'objective-c' | 'php' | 'csharp' | 'plaintext' | 'postiats' | 'powershell' | 'python' | 'r' | 'razor' | 'ruby' | 'scss' | 'sql' | 'swift' | 'typescript' | 'vb' | 'xml' | 'yaml';
 
    /**
     * Value to compare with the Value input
     * Used only when `isDiffEditor` is set to `true`
     */
    @Input()
    public set valueToCompare(v: string) {
        if (v !== this._valueToCompare) {
            this._valueToCompare = v;
 
            if (this._valueToCompare === undefined || !this._valueToCompare || !this._editor) {
                return;
            }
 
            if (this._editor.getEditorType() !== 'vs.editor.ICodeEditor') {
                this.getModifiedModel().setValue(this._valueToCompare);
            }
        }
    }
    /**
     * Value to show in the editor
     */
    @Input()
    public set value(v: string) {
        Eif (v !== this._value) {
            this._value = v;
 
            Iif (!this._editor) {
                return;
            }
 
            Iif (this._value === undefined || !this._value) {
                this._value = '';
            }
 
            this.getOriginalModel().setValue(this._value);
            this.onChangeCallback(this._value);
        }
    }
    /**
     * Event triggered when value change
     */
    @Output()
    public valueChange = new EventEmitter();
    /**
     * Event triggered when valueToCompare change
     */
    @Output()
    public valueToCompareChange = new EventEmitter();
    /**
     * Event triggered when editor is initialized
     */
    @Output()
    public onInit = new EventEmitter();
 
    @ViewChild('editor')
    private editorContent: ElementRef;
 
    private _editor: any;
    private _value = '';
    private _valueToCompare = '';
    private _language: 'bat' | 'c' | 'cpp' | 'csharp' | 'css' | 'dockerfile' | 'fsharp' | 'go' | 'handlebars' | 'html' | 'ini' | 'jade' | 'javascript' | 'json' | 'less' | 'lua' | 'markdown' | 'objective-c' | 'php' | 'csharp' | 'plaintext' | 'postiats' | 'powershell' | 'python' | 'r' | 'razor' | 'ruby' | 'scss' | 'sql' | 'swift' | 'typescript' | 'vb' | 'xml' | 'yaml';
 
    public onTouchedCallback: () => void = () => {};
    public onChangeCallback: (_: string) => void = (_: string) => {};
    /**
     * Constructor
     */
    constructor(
        private monacoEditorService: MonacoEditorService,
        @Self() @Optional() public _control: NgControl,
    ) {
        Iif (this._control) {
            this._control.valueAccessor = this;
        }
    }
 
    /**
     * Load Monaco Editor library
     */
    public ngAfterViewInit() {
        this.monacoEditorService.initMonacoLib().then(() => {
            this.initEditor();
        });
    }
 
    /**
     * Lifecycle hook that is called when a directive, pipe or service is destroyed.
     */
    public ngOnDestroy() {
        this.dispose();
    }
 
    /**
     * Lifecycle hook that is called when any data-bound property of a directive changes.
     */
    public ngOnChanges() {
        if (this._editor) {
            this._editor.updateOptions(this.getOptions());
        }
    }
 
    /** From ControlValueAccessor interface */
    public writeValue(value: string) {
        this.value = value;
    }
 
    /** From ControlValueAccessor interface */
    public registerOnChange(fn: any) {
        this.onChangeCallback = fn;
    }
 
    /** From ControlValueAccessor interface */
    public registerOnTouched(fn: any) {
        this.onTouchedCallback = fn;
    }
 
    /**
     * Destroy the monaco component
     */
    public dispose() {
        const myDiv: HTMLDivElement = this.editorContent.nativeElement;
        if (this._editor) {
            // this._editor.dispose();
            while (myDiv.hasChildNodes()) {
                myDiv.removeChild(myDiv.firstChild);
            }
            this._editor = null;
        }
    }
 
    /**
     * Triggered when windows is resized
     * Resize the component
     */
    @HostListener('window:resize', ['$event'])
    public onResize() {
        // Manually set monaco size because MonacoEditor doesn't work with Flexbox css
        const myDiv: HTMLDivElement = this.editorContent.nativeElement;
        myDiv.setAttribute('style', `height: 100%; width: 100%;`);
        Eif (this._editor) {
            this._editor.layout();
        }
    }
 
    /**
     * Init the component
     */
    private initEditor() {
        const myDiv: HTMLDivElement = this.editorContent.nativeElement;
        const options = this.getOptions();
        this.dispose();
 
        Eif (!this.isDiffEditor) {
            this._editor = this.initSimpleEditor(myDiv, options);
        } else {
            this._editor = this.initDiffEditor(myDiv, options);
        }
 
        this.onResize();
 
        // Trigger on change event for simple editor
        this.getOriginalModel().onDidChangeContent(() => {
            const newVal: string = this.getOriginalModel().getValue();
            Iif (this._value !== newVal) {
                this.updateValue(newVal);
            }
        });
 
        // Trigger on change event for diff editor
        Iif (this.getModifiedModel()) {
            this.getModifiedModel().onDidChangeContent(() => {
                const newVal: string = this.getModifiedModel().getValue();
                if (this._valueToCompare !== newVal) {
                    this.updateValueToCompare(newVal);
                }
            });
        }
 
        this.onInit.next(this._editor);
    }
 
    /**
     * Create a simple editor text
     * @param div
     * @param options
     * @return instance of monaco
     */
    private initSimpleEditor(div: HTMLDivElement, options: any) {
        return monaco.editor.create(div, options);
    }
 
    /**
     * Create a diff editor to compare two string (_value and _valueToCompare)
     * @param div
     * @return instance of monaco
     */
    private initDiffEditor(div: HTMLDivElement, options: any) {
        const originalModel = monaco.editor.createModel(this._value, this.language);
        const modifiedModel = monaco.editor.createModel(this._valueToCompare, this.language);
 
        const diffEditor = monaco.editor.createDiffEditor(div, options);
        diffEditor.setModel({
            modified: modifiedModel,
            original: originalModel,
        });
 
        return diffEditor;
    }
 
    private getOptions(): EditorOptions {
        const options: EditorOptions = new EditorOptions();
        options.experimentalScreenReader = this.experimentalScreenReader;
        options.ariaLabel = this.ariaLabel;
        options.rulers = this.rulers;
        options.wordSeparators = this.wordSeparators;
        options.selectionClipboard = this.selectionClipboard;
        options.lineNumbers = this.lineNumbers;
        options.selectOnLineNumbers = this.selectOnLineNumbers;
        options.lineNumbersMinChars = this.lineNumbersMinChars;
        options.glyphMargin = this.glyphMargin;
        options.lineDecorationsWidth = this.lineDecorationsWidth;
        options.revealHorizontalRightPadding = this.revealHorizontalRightPadding;
        options.roundedSelection = this.roundedSelection;
        options.theme = this.theme;
        options.readOnly = this.readOnly;
        options.scrollbar = this.scrollbar;
        options.overviewRulerLanes = this.overviewRulerLanes;
        options.cursorBlinking = this.cursorBlinking;
        options.mouseWheelZoom = this.mouseWheelZoom;
        options.cursorStyle = this.cursorStyle;
        options.mouseWheelZoom = this.mouseWheelZoom;
        options.fontLigatures = this.fontLigatures;
        options.disableTranslate3d = this.disableTranslate3d;
        options.hideCursorInOverviewRuler = this.hideCursorInOverviewRuler;
        options.scrollBeyondLastLine = this.scrollBeyondLastLine;
        options.automaticLayout = this.automaticLayout;
        options.wrappingColumn = this.wrappingColumn;
        options.wordWrap = this.wordWrap;
        options.wrappingIndent = this.wrappingIndent;
        options.wordWrapBreakBeforeCharacters = this.wordWrapBreakBeforeCharacters;
        options.wordWrapBreakAfterCharacters = this.wordWrapBreakAfterCharacters;
        options.wordWrapBreakObtrusiveCharacters = this.wordWrapBreakObtrusiveCharacters;
        options.stopRenderingLineAfter = this.stopRenderingLineAfter;
        options.hover = this.hover;
        options.contextmenu = this.contextmenu;
        options.mouseWheelScrollSensitivity = this.mouseWheelScrollSensitivity;
        options.quickSuggestions = this.quickSuggestions;
        options.quickSuggestionsDelay = this.quickSuggestionsDelay;
        options.parameterHints = this.parameterHints;
        options.iconsInSuggestions = this.iconsInSuggestions;
        options.autoClosingBrackets = this.autoClosingBrackets;
        options.formatOnType = this.formatOnType;
        options.suggestOnTriggerCharacters = this.suggestOnTriggerCharacters;
        options.acceptSuggestionOnEnter = this.acceptSuggestionOnEnter;
        options.snippetSuggestions = this.snippetSuggestions;
        options.tabCompletion = this.tabCompletion;
        options.wordBasedSuggestions = this.wordBasedSuggestions;
        options.selectionHighlight = this.selectionHighlight;
        options.codeLens = this.codeLens;
        options.folding = this.folding;
        options.renderWhitespace = this.renderWhitespace;
        options.renderControlCharacters = this.renderControlCharacters;
        options.renderIndentGuides = this.renderIndentGuides;
        options.renderLineHighlight = this.renderLineHighlight;
        options.useTabStops = this.useTabStops;
        options.fontFamily = this.fontFamily;
        options.fontWeight = this.fontWeight;
        options.fontSize = this.fontSize;
        options.lineHeight = this.lineHeight;
        options.formatOnPaste = this.formatOnPaste;
        options.value = this._value;
        options.language = this._language;
 
        Object.keys(options).forEach((key) => (<any>options)[key] === undefined && delete (<any>options)[key]); // Remove all undefined properties
        return options;
    }
 
    /**
     * UpdateValue
     *
     * @param value
     */
    private updateValue(value: string) {
        // this.value = value;
        this._value = value;
        this.valueChange.emit(value);
        this.onChangeCallback(value);
    }
 
    /**
     * UpdateValue
     *
     * @param value
     */
    private updateValueToCompare(value: string) {
        // this.valueToCompare = value;
        this._valueToCompare = value;
        this.valueToCompareChange.emit(value);
    }
 
    private getOriginalModel() {
        Eif (this._editor) {
            const model = this._editor.getModel();
            return model.original ? model.original : model;
        }
    }
 
    private getModifiedModel() {
        Eif (this._editor) {
            const model = this._editor.getModel();
            return model.modified ? model.modified : null;
        }
    }
}