UNPKG

2.93 kBJavaScriptView Raw
1/**
2 * ag-grid - Advanced Data Grid / Data Table supporting Javascript / React / AngularJS / Web Components
3 * @version v18.1.2
4 * @link http://www.ag-grid.com/
5 * @license MIT
6 */
7"use strict";
8var __extends = (this && this.__extends) || (function () {
9 var extendStatics = Object.setPrototypeOf ||
10 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
11 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
12 return function (d, b) {
13 extendStatics(d, b);
14 function __() { this.constructor = d; }
15 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
16 };
17})();
18Object.defineProperty(exports, "__esModule", { value: true });
19var component_1 = require("../../widgets/component");
20var constants_1 = require("../../constants");
21var utils_1 = require("../../utils");
22var LargeTextCellEditor = (function (_super) {
23 __extends(LargeTextCellEditor, _super);
24 function LargeTextCellEditor() {
25 return _super.call(this, LargeTextCellEditor.TEMPLATE) || this;
26 }
27 LargeTextCellEditor.prototype.init = function (params) {
28 this.params = params;
29 this.focusAfterAttached = params.cellStartedEdit;
30 this.textarea = document.createElement("textarea");
31 this.textarea.maxLength = params.maxLength ? params.maxLength : "200";
32 this.textarea.cols = params.cols ? params.cols : "60";
33 this.textarea.rows = params.rows ? params.rows : "10";
34 if (utils_1.Utils.exists(params.value)) {
35 this.textarea.value = params.value.toString();
36 }
37 this.getGui().querySelector('.ag-large-textarea').appendChild(this.textarea);
38 this.addGuiEventListener('keydown', this.onKeyDown.bind(this));
39 };
40 LargeTextCellEditor.prototype.onKeyDown = function (event) {
41 var key = event.which || event.keyCode;
42 if (key == constants_1.Constants.KEY_LEFT ||
43 key == constants_1.Constants.KEY_UP ||
44 key == constants_1.Constants.KEY_RIGHT ||
45 key == constants_1.Constants.KEY_DOWN ||
46 (event.shiftKey && key == constants_1.Constants.KEY_ENTER)) {
47 event.stopPropagation();
48 }
49 };
50 LargeTextCellEditor.prototype.afterGuiAttached = function () {
51 if (this.focusAfterAttached) {
52 this.textarea.focus();
53 }
54 };
55 LargeTextCellEditor.prototype.getValue = function () {
56 return this.textarea.value;
57 };
58 LargeTextCellEditor.prototype.isPopup = function () {
59 return true;
60 };
61 LargeTextCellEditor.TEMPLATE =
62 // tab index is needed so we can focus, which is needed for keyboard events
63 '<div class="ag-large-text" tabindex="0">' +
64 '<div class="ag-large-textarea"></div>' +
65 '</div>';
66 return LargeTextCellEditor;
67}(component_1.Component));
68exports.LargeTextCellEditor = LargeTextCellEditor;