UNPKG

ngx-editor

Version:

WYSIWYG Editor for Angular Applications

95 lines (94 loc) 6.71 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import { Component, HostListener } from '@angular/core'; import { NgxEditorComponent } from '../ngx-editor.component'; export class NgxGrippieComponent { /** * Constructor * * @param {?} _editorComponent Editor component */ constructor(_editorComponent) { this._editorComponent = _editorComponent; /** * previous value befor resizing the editor */ this.oldY = 0; /** * set to true on mousedown event */ this.grabber = false; } /** * * @param {?} event Mouseevent * * Update the height of the editor when the grabber is dragged * @return {?} */ onMouseMove(event) { if (!this.grabber) { return; } this._editorComponent.resizeTextArea(event.clientY - this.oldY); this.oldY = event.clientY; } /** * * @param {?} event Mouseevent * * set the grabber to false on mouse up action * @return {?} */ onMouseUp(event) { this.grabber = false; } /** * @param {?} event * @param {?=} resizer * @return {?} */ onResize(event, resizer) { this.grabber = true; this.oldY = event.clientY; event.preventDefault(); } } NgxGrippieComponent.decorators = [ { type: Component, args: [{ selector: 'app-ngx-grippie', template: "<div class=\"ngx-editor-grippie\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" style=\"isolation:isolate\" viewBox=\"651.6 235 26 5\"\n width=\"26\" height=\"5\">\n <g id=\"sprites\">\n <path d=\" M 651.6 235 L 653.6 235 L 653.6 237 L 651.6 237 M 654.6 238 L 656.6 238 L 656.6 240 L 654.6 240 M 660.6 238 L 662.6 238 L 662.6 240 L 660.6 240 M 666.6 238 L 668.6 238 L 668.6 240 L 666.6 240 M 672.6 238 L 674.6 238 L 674.6 240 L 672.6 240 M 657.6 235 L 659.6 235 L 659.6 237 L 657.6 237 M 663.6 235 L 665.6 235 L 665.6 237 L 663.6 237 M 669.6 235 L 671.6 235 L 671.6 237 L 669.6 237 M 675.6 235 L 677.6 235 L 677.6 237 L 675.6 237\"\n fill=\"rgb(147,153,159)\" />\n </g>\n </svg>\n</div>\n", styles: [".ngx-editor-grippie{height:9px;background-color:#f1f1f1;position:relative;text-align:center;cursor:s-resize;border:1px solid #ddd;border-top:transparent}.ngx-editor-grippie svg{position:absolute;top:1.5px;width:50%;right:25%}"] }] } ]; /** @nocollapse */ NgxGrippieComponent.ctorParameters = () => [ { type: NgxEditorComponent } ]; NgxGrippieComponent.propDecorators = { onMouseMove: [{ type: HostListener, args: ['document:mousemove', ['$event'],] }], onMouseUp: [{ type: HostListener, args: ['document:mouseup', ['$event'],] }], onResize: [{ type: HostListener, args: ['mousedown', ['$event'],] }] }; if (false) { /** * height of the editor * @type {?} */ NgxGrippieComponent.prototype.height; /** * previous value befor resizing the editor * @type {?} */ NgxGrippieComponent.prototype.oldY; /** * set to true on mousedown event * @type {?} */ NgxGrippieComponent.prototype.grabber; /** @type {?} */ NgxGrippieComponent.prototype._editorComponent; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibmd4LWdyaXBwaWUuY29tcG9uZW50LmpzIiwic291cmNlUm9vdCI6Im5nOi8vbmd4LWVkaXRvci8iLCJzb3VyY2VzIjpbImFwcC9uZ3gtZWRpdG9yL25neC1ncmlwcGllL25neC1ncmlwcGllLmNvbXBvbmVudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7O0FBQUEsT0FBTyxFQUFFLFNBQVMsRUFBRSxZQUFZLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDeEQsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFRN0QsTUFBTTs7Ozs7O0lBYUosWUFBb0IsZ0JBQW9DO1FBQXBDLHFCQUFnQixHQUFoQixnQkFBZ0IsQ0FBb0I7Ozs7b0JBVGpELENBQUM7Ozs7dUJBRUUsS0FBSztLQU84Qzs7Ozs7Ozs7SUFRYixXQUFXLENBQUMsS0FBaUI7UUFDM0UsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLEVBQUU7WUFDakIsT0FBTztTQUNSO1FBRU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