Skip to content

Commit

Permalink
fix: remove disable toolbar on-focus deadcode
Browse files Browse the repository at this point in the history
removed deadcod, inturn notify user with `Range out of Editor` message
  • Loading branch information
sibiraj-s committed Mar 14, 2018
1 parent 1248db7 commit 00adda2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class CommandExecutorService {
*/
execute(command: string): void {

if (!this.savedSelection && command !== 'enableObjectResizing') {
throw new Error('Range out of Editor');
}

if (command === 'enableObjectResizing') {
document.execCommand('enableObjectResizing', true, true);
return;
Expand Down
13 changes: 2 additions & 11 deletions src/app/ngx-editor/ngx-editor.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
Component, OnInit, Input, Output,
ViewChild, HostListener, ElementRef, EventEmitter,
Renderer2, forwardRef
Component, OnInit, Input, Output, ViewChild,
EventEmitter, Renderer2, forwardRef
} from '@angular/core';
import { NG_VALUE_ACCESSOR, ControlValueAccessor } from '@angular/forms';
import * as CodeMirror from 'codemirror';
Expand Down Expand Up @@ -96,14 +95,11 @@ export class NgxEditorComponent implements OnInit, ControlValueAccessor {
private onTouched: () => void;

/**
*
* @param _elementRef api to access dom element
* @param _messageService service to send message to the editor message component
* @param _commandExecutor executes command from the toolbar
* @param _renderer access and manipulate the dom element
*/
constructor(
private _elementRef: ElementRef,
private _messageService: MessageService,
private _commandExecutor: CommandExecutorService,
private _renderer: Renderer2) { }
Expand All @@ -112,7 +108,6 @@ export class NgxEditorComponent implements OnInit, ControlValueAccessor {
* events
*/
onTextAreaFocus(): void {
this.enableToolbar = true;
this.focus.emit('focus');
return;
}
Expand All @@ -122,10 +117,6 @@ export class NgxEditorComponent implements OnInit, ControlValueAccessor {
this.textArea.nativeElement.focus();
}

@HostListener('document:click', ['$event']) onDocumentClick(event: MouseEvent) {
this.enableToolbar = !!this._elementRef.nativeElement.contains(event.target);
}

/**
* Executed from the contenteditable section while the input property changes
* @param html html string from contenteditable
Expand Down

0 comments on commit 00adda2

Please sign in to comment.