import { Injectable } from '@angular/core';
import { AppHotkeysService } from '@anglr/common/hotkeys';
import { Hotkey } from 'angular2-hotkeys';
import { Subject } from 'rxjs';
import * as i0 from "@angular/core";
import * as i1 from "@anglr/common/hotkeys";
/**
 * Class that handles hotkeys for editors
 */
export class EditorHotkeys {
    //######################### public properties #########################
    /**
     * Occurs on undo shortcut
     */
    get undo() {
        return this.undoSubject.asObservable();
    }
    /**
     * Occurs on redo shortcut
     */
    get redo() {
        return this.redoSubject.asObservable();
    }
    /**
     * Occurs on save shortcut
     */
    get save() {
        return this.saveSubject.asObservable();
    }
    /**
     * Occurs on copy shortcut
     */
    get copy() {
        return this.copySubject.asObservable();
    }
    /**
     * Occurs on cut shortcut
     */
    get cut() {
        return this.cutSubject.asObservable();
    }
    /**
     * Occurs on paste shortcut
     */
    get paste() {
        return this.pasteSubject.asObservable();
    }
    /**
     * Occurs on delete shortcut
     */
    get delete() {
        return this.deleteSubject.asObservable();
    }
    //######################### constructor #########################
    constructor(hotkeys) {
        this.hotkeys = hotkeys;
        //######################### protected properties #########################
        /**
         * Subject used for emitting undo
         */
        this.undoSubject = new Subject();
        /**
         * Subject used for emitting redo
         */
        this.redoSubject = new Subject();
        /**
         * Subject used for emitting save
         */
        this.saveSubject = new Subject();
        /**
         * Subject used for emitting copy
         */
        this.copySubject = new Subject();
        /**
         * Subject used for emitting paste
         */
        this.pasteSubject = new Subject();
        /**
         * Subject used for emitting cut
         */
        this.cutSubject = new Subject();
        /**
         * Subject used for emitting delete
         */
        this.deleteSubject = new Subject();
    }
    //######################### public methods - implementation of OnDestroy #########################
    /**
     * Called when component is destroyed
     */
    destroy() {
        this.hotkeys.destroy();
    }
    //######################### public methods #########################
    /**
     * Initialize hotkeys
     */
    init() {
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+s', () => {
            this.saveSubject.next();
            return false;
        }, ['INPUT', 'TEXTAREA'], 'Emits save event'));
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+z', () => {
            this.undoSubject.next();
            return false;
        }, ['INPUT', 'TEXTAREA'], 'Emits undo event'));
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+y', () => {
            this.redoSubject.next();
            return false;
        }, ['INPUT', 'TEXTAREA'], 'Emits redo event'));
        this.hotkeys.hotkeys.add(new Hotkey('del', () => {
            this.deleteSubject.next();
            return false;
        }, [], 'Emits delete event'));
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+c', () => {
            this.copySubject.next();
            return false;
        }, [], 'Emits copy event'));
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+v', () => {
            this.pasteSubject.next();
            return false;
        }, [], 'Emits paste event'));
        this.hotkeys.hotkeys.add(new Hotkey('ctrl+x', () => {
            this.cutSubject.next();
            return false;
        }, [], 'Emits cut event'));
    }
}
EditorHotkeys.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: EditorHotkeys, deps: [{ token: i1.AppHotkeysService }], target: i0.ɵɵFactoryTarget.Injectable });
EditorHotkeys.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: EditorHotkeys });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: EditorHotkeys, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i1.AppHotkeysService }] });
//# sourceMappingURL=editorHotkeys.service.js.map