@babylonjs/gui 5.9.1 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1071 @@
1
+ import { __decorate, __extends } from "tslib";
2
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
3
+ import { Control } from "./control.js";
4
+ import { ValueAndUnit } from "../valueAndUnit.js";
5
+ import { RegisterClass } from "@babylonjs/core/Misc/typeStore.js";
6
+ import { InputText } from "./inputText.js";
7
+ import { serialize } from "@babylonjs/core/Misc/decorators.js";
8
+ /**
9
+ * Class used to create input text control
10
+ */
11
+ var InputTextArea = /** @class */ (function (_super) {
12
+ __extends(InputTextArea, _super);
13
+ /**
14
+ * Creates a new InputTextArea
15
+ * @param name defines the control name
16
+ * @param text defines the text of the control
17
+ */
18
+ function InputTextArea(name, text) {
19
+ if (text === void 0) { text = ""; }
20
+ var _this = _super.call(this, name) || this;
21
+ _this.name = name;
22
+ _this._textHorizontalAlignment = Control.HORIZONTAL_ALIGNMENT_LEFT;
23
+ _this._textVerticalAlignment = Control.VERTICAL_ALIGNMENT_TOP;
24
+ _this._lineSpacing = new ValueAndUnit(0);
25
+ _this._outlineWidth = 0;
26
+ _this._outlineColor = "white";
27
+ _this._maxHeight = new ValueAndUnit(1, ValueAndUnit.UNITMODE_PERCENTAGE, false);
28
+ /**
29
+ * An event triggered after the text was broken up into lines
30
+ */
31
+ _this.onLinesReadyObservable = new Observable();
32
+ _this.text = text;
33
+ _this.isPointerBlocker = true;
34
+ _this.onLinesReadyObservable.add(function () { return _this._updateCursorPosition(); });
35
+ _this._highlightCursorInfo = {
36
+ initialStartIndex: -1,
37
+ initialRelativeStartIndex: -1,
38
+ initialLineIndex: -1,
39
+ };
40
+ _this._cursorInfo = {
41
+ globalStartIndex: 0,
42
+ globalEndIndex: 0,
43
+ relativeEndIndex: 0,
44
+ relativeStartIndex: 0,
45
+ currentLineIndex: 0,
46
+ };
47
+ return _this;
48
+ }
49
+ Object.defineProperty(InputTextArea.prototype, "outlineWidth", {
50
+ /**
51
+ * Gets or sets outlineWidth of the text to display
52
+ */
53
+ get: function () {
54
+ return this._outlineWidth;
55
+ },
56
+ /**
57
+ * Gets or sets outlineWidth of the text to display
58
+ */
59
+ set: function (value) {
60
+ if (this._outlineWidth === value) {
61
+ return;
62
+ }
63
+ this._outlineWidth = value;
64
+ this._markAsDirty();
65
+ },
66
+ enumerable: false,
67
+ configurable: true
68
+ });
69
+ Object.defineProperty(InputTextArea.prototype, "outlineColor", {
70
+ /**
71
+ * Gets or sets outlineColor of the text to display
72
+ */
73
+ get: function () {
74
+ return this._outlineColor;
75
+ },
76
+ /**
77
+ * Gets or sets outlineColor of the text to display
78
+ */
79
+ set: function (value) {
80
+ if (this._outlineColor === value) {
81
+ return;
82
+ }
83
+ this._outlineColor = value;
84
+ this._markAsDirty();
85
+ },
86
+ enumerable: false,
87
+ configurable: true
88
+ });
89
+ Object.defineProperty(InputTextArea.prototype, "autoStretchHeight", {
90
+ /** Gets or sets a boolean indicating if the control can auto stretch its height to adapt to the text */
91
+ get: function () {
92
+ return this._autoStretchHeight;
93
+ },
94
+ set: function (value) {
95
+ if (this._autoStretchHeight === value) {
96
+ return;
97
+ }
98
+ this._autoStretchHeight = value;
99
+ this._markAsDirty();
100
+ },
101
+ enumerable: false,
102
+ configurable: true
103
+ });
104
+ Object.defineProperty(InputTextArea.prototype, "height", {
105
+ set: function (value) {
106
+ this._fixedRatioMasterIsWidth = false;
107
+ if (this._height.toString(this._host) === value) {
108
+ return;
109
+ }
110
+ if (this._height.fromString(value)) {
111
+ this._markAsDirty();
112
+ }
113
+ this._autoStretchHeight = false;
114
+ },
115
+ enumerable: false,
116
+ configurable: true
117
+ });
118
+ Object.defineProperty(InputTextArea.prototype, "maxHeight", {
119
+ get: function () {
120
+ return this._maxHeight.toString(this._host);
121
+ },
122
+ set: function (value) {
123
+ if (this._maxHeight.toString(this._host) === value) {
124
+ return;
125
+ }
126
+ if (this._maxHeight.fromString(value)) {
127
+ this._markAsDirty();
128
+ }
129
+ },
130
+ enumerable: false,
131
+ configurable: true
132
+ });
133
+ Object.defineProperty(InputTextArea.prototype, "maxHeightInPixels", {
134
+ /** Gets the maximum width allowed by the control in pixels */
135
+ get: function () {
136
+ return this._maxHeight.getValueInPixel(this._host, this._cachedParentMeasure.height);
137
+ },
138
+ enumerable: false,
139
+ configurable: true
140
+ });
141
+ InputTextArea.prototype._getTypeName = function () {
142
+ return "InputTextArea";
143
+ };
144
+ /**
145
+ * Handles the keyboard event
146
+ * @param evt Defines the KeyboardEvent
147
+ */
148
+ InputTextArea.prototype.processKeyboard = function (evt) {
149
+ // process pressed key
150
+ this.alternativeProcessKey(evt.code, evt.key, evt);
151
+ this.onKeyboardEventProcessedObservable.notifyObservers(evt);
152
+ };
153
+ /**
154
+ * Process the last keyboard input
155
+ *
156
+ * @param code The ascii input number
157
+ * @param key The key string representation
158
+ * @param evt The keyboard event emits with input
159
+ * @hidden
160
+ */
161
+ InputTextArea.prototype.alternativeProcessKey = function (code, key, evt) {
162
+ //return if clipboard event keys (i.e -ctr/cmd + c,v,x)
163
+ if (evt && (evt.ctrlKey || evt.metaKey) && (code === "KeyC" || code === "KeyV" || code === "KeyX")) {
164
+ return;
165
+ }
166
+ // Specific cases
167
+ switch (code) {
168
+ case "KeyA": // A - select all
169
+ if (evt && (evt.ctrlKey || evt.metaKey)) {
170
+ this._selectAllText();
171
+ evt.preventDefault();
172
+ return;
173
+ }
174
+ break;
175
+ case "Period": //SLASH
176
+ if (evt && evt.shiftKey) {
177
+ evt.preventDefault();
178
+ }
179
+ break;
180
+ case "Backspace": // BACKSPACE
181
+ if (!this._isTextHighlightOn && this._cursorInfo.globalStartIndex > 0) {
182
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
183
+ this._cursorInfo.globalStartIndex--;
184
+ }
185
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
186
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
187
+ if (evt) {
188
+ evt.preventDefault();
189
+ }
190
+ this._blinkIsEven = false;
191
+ this._isTextHighlightOn = false;
192
+ this._textHasChanged();
193
+ break;
194
+ case "Delete": // DELETE
195
+ if (!this._isTextHighlightOn && this._cursorInfo.globalEndIndex < this.text.length) {
196
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex + 1;
197
+ }
198
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
199
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
200
+ if (evt) {
201
+ evt.preventDefault();
202
+ }
203
+ this._blinkIsEven = false;
204
+ this._isTextHighlightOn = false;
205
+ this._textHasChanged();
206
+ break;
207
+ case "Enter": // RETURN
208
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, "\n");
209
+ this._cursorInfo.globalStartIndex++;
210
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
211
+ this._blinkIsEven = false;
212
+ this._isTextHighlightOn = false;
213
+ this._textHasChanged();
214
+ return;
215
+ case "End": // END
216
+ this._cursorInfo.globalStartIndex = this.text.length;
217
+ this._blinkIsEven = false;
218
+ this._isTextHighlightOn = false;
219
+ this._markAsDirty();
220
+ return;
221
+ case "Home": // HOME
222
+ this._cursorInfo.globalStartIndex = 0;
223
+ this._blinkIsEven = false;
224
+ this._isTextHighlightOn = false;
225
+ this._markAsDirty();
226
+ return;
227
+ case "ArrowLeft": // LEFT
228
+ this._markAsDirty();
229
+ if (evt && evt.shiftKey) {
230
+ // shift + ctrl/cmd + <-
231
+ if (evt.ctrlKey || evt.metaKey) {
232
+ // Go to line's start by substract the relativeStartIndex to the globalStartIndex
233
+ this._cursorInfo.globalStartIndex -= this._cursorInfo.relativeStartIndex;
234
+ this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
235
+ }
236
+ // store the starting point
237
+ if (!this._isTextHighlightOn) {
238
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
239
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
240
+ this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
241
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
242
+ this._cursorInfo.globalStartIndex--;
243
+ this._isTextHighlightOn = true;
244
+ }
245
+ else {
246
+ if (this._cursorInfo.globalEndIndex > this._highlightCursorInfo.initialStartIndex) {
247
+ this._cursorInfo.globalEndIndex--;
248
+ }
249
+ else {
250
+ this._cursorInfo.globalStartIndex--;
251
+ }
252
+ }
253
+ this._blinkIsEven = true;
254
+ evt.preventDefault();
255
+ return;
256
+ }
257
+ if (this._isTextHighlightOn) {
258
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
259
+ }
260
+ else if (evt && (evt.ctrlKey || evt.metaKey)) {
261
+ // ctr + <-
262
+ this._cursorInfo.globalStartIndex -= this._cursorInfo.relativeStartIndex;
263
+ evt.preventDefault();
264
+ }
265
+ else if (this._cursorInfo.globalStartIndex > 0) {
266
+ this._cursorInfo.globalStartIndex--;
267
+ }
268
+ // update the cursor
269
+ this._blinkIsEven = false;
270
+ this._isTextHighlightOn = false;
271
+ return;
272
+ case "ArrowRight": // RIGHT
273
+ this._markAsDirty();
274
+ if (evt && evt.shiftKey) {
275
+ // shift + ctrl/cmd + ->
276
+ if (evt.ctrlKey || evt.metaKey) {
277
+ var rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex - 1;
278
+ this._cursorInfo.globalEndIndex += rightDelta;
279
+ this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
280
+ }
281
+ // store the starting point
282
+ if (!this._isTextHighlightOn) {
283
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
284
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
285
+ this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
286
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
287
+ this._cursorInfo.globalEndIndex++;
288
+ this._isTextHighlightOn = true;
289
+ }
290
+ else {
291
+ if (this._cursorInfo.globalStartIndex < this._highlightCursorInfo.initialStartIndex) {
292
+ this._cursorInfo.globalStartIndex++;
293
+ }
294
+ else {
295
+ this._cursorInfo.globalEndIndex++;
296
+ }
297
+ }
298
+ this._blinkIsEven = true;
299
+ evt.preventDefault();
300
+ return;
301
+ }
302
+ if (this._isTextHighlightOn) {
303
+ this._cursorInfo.globalStartIndex = this._cursorInfo.globalEndIndex;
304
+ }
305
+ else if (evt && (evt.ctrlKey || evt.metaKey)) {
306
+ //ctr + ->
307
+ var rightDelta = this._lines[this._cursorInfo.currentLineIndex].text.length - this._cursorInfo.relativeEndIndex;
308
+ this._cursorInfo.globalStartIndex += rightDelta;
309
+ }
310
+ else if (this._cursorInfo.globalStartIndex < this.text.length) {
311
+ this._cursorInfo.globalStartIndex++;
312
+ }
313
+ // update the cursor
314
+ this._blinkIsEven = false;
315
+ this._isTextHighlightOn = false;
316
+ return;
317
+ case "ArrowUp": // UP
318
+ // update the cursor
319
+ this._blinkIsEven = false;
320
+ if (evt) {
321
+ if (evt.shiftKey) {
322
+ if (!this._isTextHighlightOn) {
323
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
324
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
325
+ this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
326
+ }
327
+ this._isTextHighlightOn = true;
328
+ this._blinkIsEven = true;
329
+ }
330
+ else {
331
+ this._isTextHighlightOn = false;
332
+ }
333
+ evt.preventDefault();
334
+ }
335
+ if (this._cursorInfo.currentLineIndex === 0) {
336
+ // First line
337
+ this._cursorInfo.globalStartIndex = 0;
338
+ }
339
+ else {
340
+ var currentLine = this._lines[this._cursorInfo.currentLineIndex];
341
+ var upperLine = this._lines[this._cursorInfo.currentLineIndex - 1];
342
+ var tmpIndex = 0;
343
+ var relativeIndex = 0;
344
+ if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
345
+ tmpIndex = this._cursorInfo.globalStartIndex;
346
+ relativeIndex = this._cursorInfo.relativeStartIndex;
347
+ }
348
+ else {
349
+ tmpIndex = this._cursorInfo.globalEndIndex;
350
+ relativeIndex = this._cursorInfo.relativeEndIndex;
351
+ }
352
+ var currentText = currentLine.text.substr(0, relativeIndex);
353
+ var currentWidth = this._contextForBreakLines.measureText(currentText).width;
354
+ var upperWidth = 0;
355
+ var previousWidth = 0;
356
+ tmpIndex -= relativeIndex; // Start of current line
357
+ tmpIndex -= upperLine.text.length + upperLine.lineEnding.length; // Start of upper line
358
+ var upperLineRelativeIndex = 0;
359
+ while (upperWidth < currentWidth && upperLineRelativeIndex < upperLine.text.length) {
360
+ tmpIndex++;
361
+ upperLineRelativeIndex++;
362
+ previousWidth = Math.abs(currentWidth - upperWidth);
363
+ upperWidth = this._contextForBreakLines.measureText(upperLine.text.substr(0, upperLineRelativeIndex)).width;
364
+ }
365
+ // Find closest move
366
+ if (Math.abs(currentWidth - upperWidth) > previousWidth && upperLineRelativeIndex > 0) {
367
+ tmpIndex--;
368
+ }
369
+ if (!this._isTextHighlightOn) {
370
+ this._cursorInfo.globalStartIndex = tmpIndex;
371
+ }
372
+ else if (this._cursorInfo.currentLineIndex <= this._highlightCursorInfo.initialLineIndex) {
373
+ this._cursorInfo.globalStartIndex = tmpIndex;
374
+ this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
375
+ this._cursorInfo.relativeEndIndex = this._highlightCursorInfo.initialRelativeStartIndex;
376
+ }
377
+ else {
378
+ this._cursorInfo.globalEndIndex = tmpIndex;
379
+ }
380
+ }
381
+ this._markAsDirty();
382
+ return;
383
+ case "ArrowDown": // DOWN
384
+ // update the cursor
385
+ this._blinkIsEven = false;
386
+ if (evt) {
387
+ if (evt.shiftKey) {
388
+ if (!this._isTextHighlightOn) {
389
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
390
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
391
+ this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
392
+ }
393
+ this._isTextHighlightOn = true;
394
+ this._blinkIsEven = true;
395
+ }
396
+ else {
397
+ this._isTextHighlightOn = false;
398
+ }
399
+ evt.preventDefault();
400
+ }
401
+ if (this._cursorInfo.currentLineIndex === this._lines.length - 1) {
402
+ // Last line
403
+ this._cursorInfo.globalStartIndex = this.text.length;
404
+ }
405
+ else {
406
+ var currentLine = this._lines[this._cursorInfo.currentLineIndex];
407
+ var underLine = this._lines[this._cursorInfo.currentLineIndex + 1];
408
+ var tmpIndex = 0;
409
+ var relativeIndex = 0;
410
+ if (!this._isTextHighlightOn || this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
411
+ tmpIndex = this._cursorInfo.globalStartIndex;
412
+ relativeIndex = this._cursorInfo.relativeStartIndex;
413
+ }
414
+ else {
415
+ tmpIndex = this._cursorInfo.globalEndIndex;
416
+ relativeIndex = this._cursorInfo.relativeEndIndex;
417
+ }
418
+ var currentText = currentLine.text.substr(0, relativeIndex);
419
+ var currentWidth = this._contextForBreakLines.measureText(currentText).width;
420
+ var underWidth = 0;
421
+ var previousWidth = 0;
422
+ tmpIndex += currentLine.text.length - relativeIndex + currentLine.lineEnding.length; // Start of current line
423
+ var underLineRelativeIndex = 0;
424
+ while (underWidth < currentWidth && underLineRelativeIndex < underLine.text.length) {
425
+ tmpIndex++;
426
+ underLineRelativeIndex++;
427
+ previousWidth = Math.abs(currentWidth - underWidth);
428
+ underWidth = this._contextForBreakLines.measureText(underLine.text.substr(0, underLineRelativeIndex)).width;
429
+ }
430
+ // Find closest move
431
+ if (Math.abs(currentWidth - underWidth) > previousWidth && underLineRelativeIndex > 0) {
432
+ tmpIndex--;
433
+ }
434
+ if (!this._isTextHighlightOn) {
435
+ this._cursorInfo.globalStartIndex = tmpIndex;
436
+ }
437
+ else if (this._cursorInfo.currentLineIndex < this._highlightCursorInfo.initialLineIndex) {
438
+ this._cursorInfo.globalStartIndex = tmpIndex;
439
+ if (this._cursorInfo.globalStartIndex > this._cursorInfo.globalEndIndex) {
440
+ this._cursorInfo.globalEndIndex += this._cursorInfo.globalStartIndex;
441
+ this._cursorInfo.globalStartIndex = this._cursorInfo.globalEndIndex - this._cursorInfo.globalStartIndex;
442
+ this._cursorInfo.globalEndIndex -= this._cursorInfo.globalStartIndex;
443
+ }
444
+ }
445
+ else {
446
+ this._cursorInfo.globalEndIndex = tmpIndex;
447
+ this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
448
+ }
449
+ }
450
+ this._markAsDirty();
451
+ return;
452
+ }
453
+ // Printable characters
454
+ if ((key === null || key === void 0 ? void 0 : key.length) === 1) {
455
+ evt === null || evt === void 0 ? void 0 : evt.preventDefault();
456
+ this._currentKey = key;
457
+ this.onBeforeKeyAddObservable.notifyObservers(this);
458
+ key = this._currentKey;
459
+ if (this._addKey) {
460
+ this._isTextHighlightOn = false;
461
+ this._blinkIsEven = false;
462
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, key);
463
+ this._cursorInfo.globalStartIndex += key.length;
464
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
465
+ this._textHasChanged();
466
+ }
467
+ }
468
+ };
469
+ InputTextArea.prototype._parseLineWordWrap = function (line, width, context) {
470
+ if (line === void 0) { line = ""; }
471
+ var lines = [];
472
+ var words = line.split(" ");
473
+ var lineWidth = 0;
474
+ var _loop_1 = function (n) {
475
+ var testLine = n > 0 ? line + " " + words[n] : words[0];
476
+ var metrics = context.measureText(testLine);
477
+ var testWidth = metrics.width;
478
+ if (testWidth > width) {
479
+ if (n > 0) {
480
+ // Avoid first word duplication if of too long
481
+ lineWidth = context.measureText(line).width;
482
+ lines.push({ text: line, width: lineWidth, lineEnding: " " });
483
+ }
484
+ line = words[n];
485
+ var flushedLine_1 = "";
486
+ line.split("").map(function (char) {
487
+ if (context.measureText(flushedLine_1 + char).width > width) {
488
+ lines.push({ text: flushedLine_1, width: context.measureText(flushedLine_1).width, lineEnding: "\n" });
489
+ flushedLine_1 = "";
490
+ }
491
+ flushedLine_1 += char;
492
+ });
493
+ line = flushedLine_1;
494
+ // Measure remaining characters
495
+ lineWidth = context.measureText(line).width;
496
+ }
497
+ else {
498
+ lineWidth = testWidth;
499
+ line = testLine;
500
+ }
501
+ };
502
+ for (var n = 0; n < words.length; n++) {
503
+ _loop_1(n);
504
+ }
505
+ lines.push({ text: line, width: lineWidth, lineEnding: " " });
506
+ return lines;
507
+ };
508
+ InputTextArea.prototype._breakLines = function (refWidth, context) {
509
+ var lines = [];
510
+ var _lines = this.text.split("\n");
511
+ if (this.clipContent) {
512
+ for (var _i = 0, _lines_1 = _lines; _i < _lines_1.length; _i++) {
513
+ var _line = _lines_1[_i];
514
+ lines.push.apply(lines, this._parseLineWordWrap(_line, refWidth, context));
515
+ }
516
+ }
517
+ else {
518
+ for (var _a = 0, _lines_2 = _lines; _a < _lines_2.length; _a++) {
519
+ var _line = _lines_2[_a];
520
+ lines.push(this._parseLine(_line, context));
521
+ }
522
+ }
523
+ lines[lines.length - 1].lineEnding = "\n";
524
+ return lines;
525
+ };
526
+ InputTextArea.prototype._parseLine = function (line, context) {
527
+ if (line === void 0) { line = ""; }
528
+ return { text: line, width: context.measureText(line).width, lineEnding: " " };
529
+ };
530
+ /**
531
+ * Processing of child right before the parent measurement update
532
+ *
533
+ * @param parentMeasure The parent measure
534
+ * @param context The rendering canvas
535
+ * @hidden
536
+ */
537
+ InputTextArea.prototype._preMeasure = function (parentMeasure, context) {
538
+ if (!this._fontOffset || this._wasDirty) {
539
+ this._fontOffset = Control._GetFontOffset(context.font);
540
+ }
541
+ var text = this._beforeRenderText(this._textWrapper).text;
542
+ // placeholder conditions and color setting
543
+ if (!this._isFocused && !this.text && this._placeholderText) {
544
+ text = this._placeholderText;
545
+ if (this._placeholderColor) {
546
+ context.fillStyle = this._placeholderColor;
547
+ }
548
+ }
549
+ // measures the textlength -> this.measure.width
550
+ this._textWidth = context.measureText(text).width;
551
+ // we double up the margin width
552
+ var marginWidth = this._margin.getValueInPixel(this._host, parentMeasure.width) * 2;
553
+ if (this._autoStretchWidth) {
554
+ var tmpLines = text.split("\n");
555
+ var longerString = tmpLines.reduce(function (acc, val) {
556
+ var valueLength = context.measureText(val).width;
557
+ var accLength = context.measureText(acc).width;
558
+ return valueLength > accLength ? val : acc;
559
+ }, "");
560
+ var longerStringWidth = context.measureText(longerString).width;
561
+ this.width = Math.min(this._maxWidth.getValueInPixel(this._host, parentMeasure.width), longerStringWidth + marginWidth) + "px";
562
+ this.autoStretchWidth = true;
563
+ }
564
+ this._availableWidth = this._width.getValueInPixel(this._host, parentMeasure.width) - marginWidth;
565
+ // Prepare lines
566
+ this._lines = this._breakLines(this._availableWidth, context);
567
+ // can we find a cleaner implementation here?
568
+ this._contextForBreakLines = context;
569
+ if (this._autoStretchHeight) {
570
+ var textHeight = this._lines.length * this._fontOffset.height;
571
+ var totalHeight = textHeight + this._margin.getValueInPixel(this._host, parentMeasure.height) * 2;
572
+ this.height = Math.min(this._maxHeight.getValueInPixel(this._host, parentMeasure.height), totalHeight) + "px";
573
+ this._autoStretchHeight = true;
574
+ }
575
+ this._availableHeight = this._height.getValueInPixel(this._host, parentMeasure.height) - marginWidth;
576
+ if (this._isFocused) {
577
+ this._cursorInfo.currentLineIndex = 0;
578
+ var lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
579
+ var tmpLength = 0;
580
+ while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
581
+ tmpLength += lineLength;
582
+ if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
583
+ this._cursorInfo.currentLineIndex++;
584
+ lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
585
+ }
586
+ }
587
+ }
588
+ };
589
+ /**
590
+ * Processing of child after the parent measurement update
591
+ *
592
+ * @param parentMeasure The parent measure
593
+ * @param context The rendering canvas
594
+ * @hidden
595
+ */
596
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
597
+ InputTextArea.prototype._additionalProcessing = function (parentMeasure, context) {
598
+ this._clipTextLeft = this._currentMeasure.left + this._margin.getValueInPixel(this._host, parentMeasure.width);
599
+ this._clipTextTop = this._currentMeasure.top + this._margin.getValueInPixel(this._host, parentMeasure.height);
600
+ if (this._isFocused && this._lines[this._cursorInfo.currentLineIndex].width > this._availableWidth) {
601
+ var textLeft = this._clipTextLeft - this._lines[this._cursorInfo.currentLineIndex].width + this._availableWidth;
602
+ if (!this._scrollLeft) {
603
+ this._scrollLeft = textLeft;
604
+ }
605
+ }
606
+ else {
607
+ this._scrollLeft = this._clipTextLeft;
608
+ }
609
+ if (this._isFocused && !this._autoStretchHeight) {
610
+ var selectedHeight = (this._cursorInfo.currentLineIndex + 1) * this._fontOffset.height;
611
+ var textTop = this._clipTextTop - selectedHeight;
612
+ if (!this._scrollTop) {
613
+ this._scrollTop = textTop;
614
+ }
615
+ }
616
+ else {
617
+ this._scrollTop = this._clipTextTop;
618
+ }
619
+ // Flush the highlighted text each frame
620
+ this.highlightedText = "";
621
+ this.onLinesReadyObservable.notifyObservers(this);
622
+ };
623
+ InputTextArea.prototype._drawText = function (text, textWidth, y, context) {
624
+ var width = this._currentMeasure.width;
625
+ var x = this._scrollLeft;
626
+ switch (this._textHorizontalAlignment) {
627
+ case Control.HORIZONTAL_ALIGNMENT_LEFT:
628
+ x += 0;
629
+ break;
630
+ case Control.HORIZONTAL_ALIGNMENT_RIGHT:
631
+ x += width - textWidth;
632
+ break;
633
+ case Control.HORIZONTAL_ALIGNMENT_CENTER:
634
+ x += (width - textWidth) / 2;
635
+ break;
636
+ }
637
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
638
+ context.shadowColor = this.shadowColor;
639
+ context.shadowBlur = this.shadowBlur;
640
+ context.shadowOffsetX = this.shadowOffsetX;
641
+ context.shadowOffsetY = this.shadowOffsetY;
642
+ }
643
+ if (this.outlineWidth) {
644
+ context.strokeText(text, this._currentMeasure.left + x, y);
645
+ }
646
+ context.fillText(text, x, y);
647
+ };
648
+ /**
649
+ * Copy the text in the clipboard
650
+ *
651
+ * @param ev The clipboard event
652
+ * @hidden
653
+ */
654
+ InputTextArea.prototype._onCopyText = function (ev) {
655
+ this._isTextHighlightOn = false;
656
+ //when write permission to clipbaord data is denied
657
+ try {
658
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
659
+ }
660
+ catch (_a) { } //pass
661
+ this._host.clipboardData = this._highlightedText;
662
+ };
663
+ /**
664
+ * Cut the text and copy it in the clipboard
665
+ *
666
+ * @param ev The clipboard event
667
+ * @hidden
668
+ */
669
+ InputTextArea.prototype._onCutText = function (ev) {
670
+ if (!this._highlightedText) {
671
+ return;
672
+ }
673
+ //when write permission to clipbaord data is denied
674
+ try {
675
+ ev.clipboardData && ev.clipboardData.setData("text/plain", this._highlightedText);
676
+ }
677
+ catch (_a) { } //pass
678
+ this._host.clipboardData = this._highlightedText;
679
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
680
+ this._textHasChanged();
681
+ };
682
+ /**
683
+ * Paste the copied text from the clipboard
684
+ *
685
+ * @param ev The clipboard event
686
+ * @hidden
687
+ */
688
+ InputTextArea.prototype._onPasteText = function (ev) {
689
+ var data = "";
690
+ if (ev.clipboardData && ev.clipboardData.types.indexOf("text/plain") !== -1) {
691
+ data = ev.clipboardData.getData("text/plain");
692
+ }
693
+ else {
694
+ //get the cached data; returns blank string by default
695
+ data = this._host.clipboardData;
696
+ }
697
+ this._isTextHighlightOn = false;
698
+ this._textWrapper.removePart(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex, data);
699
+ var deltaIndex = data.length - (this._cursorInfo.globalEndIndex - this._cursorInfo.globalStartIndex);
700
+ this._cursorInfo.globalStartIndex += deltaIndex;
701
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
702
+ this._textHasChanged();
703
+ };
704
+ InputTextArea.prototype._draw = function (context) {
705
+ var _a, _b;
706
+ this._scrollLeft = (_a = this._scrollLeft) !== null && _a !== void 0 ? _a : 0;
707
+ this._scrollTop = (_b = this._scrollTop) !== null && _b !== void 0 ? _b : 0;
708
+ context.save();
709
+ this._applyStates(context);
710
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
711
+ context.shadowColor = this.shadowColor;
712
+ context.shadowBlur = this.shadowBlur;
713
+ context.shadowOffsetX = this.shadowOffsetX;
714
+ context.shadowOffsetY = this.shadowOffsetY;
715
+ }
716
+ // Background
717
+ if (this._isFocused) {
718
+ if (this._focusedBackground) {
719
+ context.fillStyle = this._isEnabled ? this._focusedBackground : this._disabledColor;
720
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
721
+ }
722
+ }
723
+ else if (this._background) {
724
+ context.fillStyle = this._isEnabled ? this._background : this._disabledColor;
725
+ context.fillRect(this._currentMeasure.left, this._currentMeasure.top, this._currentMeasure.width, this._currentMeasure.height);
726
+ }
727
+ if (this.shadowBlur || this.shadowOffsetX || this.shadowOffsetY) {
728
+ context.shadowBlur = 0;
729
+ context.shadowOffsetX = 0;
730
+ context.shadowOffsetY = 0;
731
+ }
732
+ // sets the color of the rectangle (border if background available)
733
+ if (this.color) {
734
+ context.fillStyle = this.color;
735
+ }
736
+ var height = this._currentMeasure.height;
737
+ var width = this._currentMeasure.width;
738
+ var rootY = 0;
739
+ switch (this._textVerticalAlignment) {
740
+ case Control.VERTICAL_ALIGNMENT_TOP:
741
+ rootY = this._fontOffset.ascent;
742
+ break;
743
+ case Control.VERTICAL_ALIGNMENT_BOTTOM:
744
+ rootY = height - this._fontOffset.height * (this._lines.length - 1) - this._fontOffset.descent;
745
+ break;
746
+ case Control.VERTICAL_ALIGNMENT_CENTER:
747
+ rootY = this._fontOffset.ascent + (height - this._fontOffset.height * this._lines.length) / 2;
748
+ break;
749
+ }
750
+ context.save();
751
+ context.beginPath();
752
+ context.fillStyle = this.fontStyle;
753
+ // here we define the visible reactangle to clip it in next line
754
+ context.rect(this._clipTextLeft, this._clipTextTop, this._availableWidth + 2, this._availableHeight + 2);
755
+ context.clip();
756
+ // Text
757
+ rootY += this._scrollTop;
758
+ for (var i = 0; i < this._lines.length; i++) {
759
+ var line = this._lines[i];
760
+ if (i !== 0 && this._lineSpacing.internalValue !== 0) {
761
+ if (this._lineSpacing.isPixel) {
762
+ rootY += this._lineSpacing.getValue(this._host);
763
+ }
764
+ else {
765
+ rootY = rootY + this._lineSpacing.getValue(this._host) * this._height.getValueInPixel(this._host, this._cachedParentMeasure.height);
766
+ }
767
+ }
768
+ this._drawText(line.text, line.width, rootY, context);
769
+ rootY += this._fontOffset.height;
770
+ }
771
+ context.restore();
772
+ // Cursor
773
+ if (this._isFocused) {
774
+ // Render cursor
775
+ if (!this._blinkIsEven || this._isTextHighlightOn) {
776
+ var cursorLeft = this._scrollLeft + context.measureText(this._lines[this._cursorInfo.currentLineIndex].text.substr(0, this._cursorInfo.relativeStartIndex)).width;
777
+ if (cursorLeft < this._clipTextLeft) {
778
+ this._scrollLeft += this._clipTextLeft - cursorLeft;
779
+ cursorLeft = this._clipTextLeft;
780
+ this._markAsDirty();
781
+ }
782
+ else if (cursorLeft > this._clipTextLeft + this._availableWidth) {
783
+ this._scrollLeft += this._clipTextLeft + this._availableWidth - cursorLeft;
784
+ cursorLeft = this._clipTextLeft + this._availableWidth;
785
+ this._markAsDirty();
786
+ }
787
+ var cursorTop = this._scrollTop + this._cursorInfo.currentLineIndex * this._fontOffset.height; //cursorTop distance from top to cursor start
788
+ if (cursorTop < this._clipTextTop) {
789
+ this._scrollTop += this._clipTextTop - cursorTop;
790
+ cursorTop = this._clipTextTop;
791
+ this._markAsDirty();
792
+ }
793
+ else if (cursorTop + this._fontOffset.height > this._clipTextTop + this._availableHeight) {
794
+ this._scrollTop += this._clipTextTop + this._availableHeight - cursorTop - this._fontOffset.height;
795
+ cursorTop = this._clipTextTop + this._availableHeight - this._fontOffset.height;
796
+ this._markAsDirty();
797
+ }
798
+ if (!this._isTextHighlightOn) {
799
+ context.fillRect(cursorLeft, cursorTop, 2, this._fontOffset.height);
800
+ }
801
+ }
802
+ this._resetBlinking();
803
+ //show the highlighted text
804
+ if (this._isTextHighlightOn) {
805
+ clearTimeout(this._blinkTimeout);
806
+ this._highlightedText = this.text.substring(this._cursorInfo.globalStartIndex, this._cursorInfo.globalEndIndex);
807
+ context.globalAlpha = this._highligherOpacity;
808
+ context.fillStyle = this._textHighlightColor;
809
+ var startLineIndex = Math.min(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
810
+ var endLineIndex = Math.max(this._cursorInfo.currentLineIndex, this._highlightCursorInfo.initialLineIndex);
811
+ var highlightRootY = this._scrollTop + startLineIndex * this._fontOffset.height;
812
+ for (var i = startLineIndex; i <= endLineIndex; i++) {
813
+ var line = this._lines[i];
814
+ var highlightRootX = this._scrollLeft;
815
+ switch (this._textHorizontalAlignment) {
816
+ case Control.HORIZONTAL_ALIGNMENT_LEFT:
817
+ highlightRootX += 0;
818
+ break;
819
+ case Control.HORIZONTAL_ALIGNMENT_RIGHT:
820
+ highlightRootX += width - line.width;
821
+ break;
822
+ case Control.HORIZONTAL_ALIGNMENT_CENTER:
823
+ highlightRootX += (width - line.width) / 2;
824
+ break;
825
+ }
826
+ var begin = i === startLineIndex ? this._cursorInfo.relativeStartIndex : 0;
827
+ var end = i === endLineIndex ? this._cursorInfo.relativeEndIndex : line.text.length;
828
+ var leftOffsetWidth = context.measureText(line.text.substr(0, begin)).width;
829
+ var selectedText = line.text.substring(begin, end);
830
+ var hightlightWidth = context.measureText(selectedText).width;
831
+ context.fillRect(highlightRootX + leftOffsetWidth, highlightRootY, hightlightWidth, this._fontOffset.height);
832
+ highlightRootY += this._fontOffset.height;
833
+ }
834
+ if (this._cursorInfo.globalEndIndex === this._cursorInfo.globalStartIndex) {
835
+ this._resetBlinking();
836
+ }
837
+ }
838
+ }
839
+ context.restore();
840
+ // Border
841
+ if (this._thickness) {
842
+ if (this._isFocused) {
843
+ if (this.focusedColor) {
844
+ context.strokeStyle = this.focusedColor;
845
+ }
846
+ }
847
+ else {
848
+ if (this.color) {
849
+ context.strokeStyle = this.color;
850
+ }
851
+ }
852
+ context.lineWidth = this._thickness;
853
+ context.strokeRect(this._currentMeasure.left + this._thickness / 2, this._currentMeasure.top + this._thickness / 2, this._currentMeasure.width - this._thickness, this._currentMeasure.height - this._thickness);
854
+ }
855
+ };
856
+ InputTextArea.prototype._resetBlinking = function () {
857
+ var _this = this;
858
+ clearTimeout(this._blinkTimeout);
859
+ this._blinkTimeout = setTimeout(function () {
860
+ _this._blinkIsEven = !_this._blinkIsEven;
861
+ _this._markAsDirty();
862
+ }, 500);
863
+ };
864
+ InputTextArea.prototype._applyStates = function (context) {
865
+ _super.prototype._applyStates.call(this, context);
866
+ if (this.outlineWidth) {
867
+ context.lineWidth = this.outlineWidth;
868
+ context.strokeStyle = this.outlineColor;
869
+ }
870
+ };
871
+ InputTextArea.prototype._onPointerDown = function (target, coordinates, pointerId, buttonIndex, pi) {
872
+ if (!_super.prototype._onPointerDown.call(this, target, coordinates, pointerId, buttonIndex, pi)) {
873
+ return false;
874
+ }
875
+ this._clickedCoordinateX = coordinates.x;
876
+ this._clickedCoordinateY = coordinates.y;
877
+ this._isTextHighlightOn = false;
878
+ this._highlightedText = "";
879
+ this._isPointerDown = true;
880
+ this._host._capturingControl[pointerId] = this;
881
+ if (this._host.focusedControl === this) {
882
+ // Move cursor
883
+ clearTimeout(this._blinkTimeout);
884
+ this._markAsDirty();
885
+ return true;
886
+ }
887
+ if (!this._isEnabled) {
888
+ return false;
889
+ }
890
+ this._host.focusedControl = this;
891
+ return true;
892
+ };
893
+ // for textselection
894
+ InputTextArea.prototype._onPointerMove = function (target, coordinates, pointerId, pi) {
895
+ // Avoid Chromium-like beahavior when this event is fired right after onPointerDown
896
+ if (pi.event.movementX === 0 && pi.event.movementY === 0) {
897
+ return;
898
+ }
899
+ if (this._host.focusedControl === this && this._isPointerDown) {
900
+ this._clickedCoordinateX = coordinates.x;
901
+ this._clickedCoordinateY = coordinates.y;
902
+ if (!this._isTextHighlightOn) {
903
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
904
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
905
+ this._highlightCursorInfo.initialRelativeStartIndex = this._cursorInfo.relativeStartIndex;
906
+ this._isTextHighlightOn = true;
907
+ }
908
+ this._markAsDirty();
909
+ }
910
+ _super.prototype._onPointerMove.call(this, target, coordinates, pointerId, pi);
911
+ };
912
+ /**
913
+ * Apply the correct position of cursor according to current modification
914
+ */
915
+ InputTextArea.prototype._updateCursorPosition = function () {
916
+ var _a;
917
+ if (!this._isFocused) {
918
+ return;
919
+ }
920
+ if (this._clickedCoordinateX && this._clickedCoordinateY) {
921
+ if (!this._isTextHighlightOn) {
922
+ this._cursorInfo = {
923
+ globalStartIndex: 0,
924
+ globalEndIndex: 0,
925
+ relativeStartIndex: 0,
926
+ relativeEndIndex: 0,
927
+ currentLineIndex: 0,
928
+ };
929
+ }
930
+ var globalIndex = 0;
931
+ var relativeIndex = 0;
932
+ var lastClickedCoordinateY = this._clickedCoordinateY - this._scrollTop;
933
+ var relativeCoordinateY = Math.floor(lastClickedCoordinateY / this._fontOffset.height);
934
+ this._cursorInfo.currentLineIndex = Math.min(Math.max(relativeCoordinateY, 0), this._lines.length - 1);
935
+ var currentSize = 0;
936
+ var relativeXPosition = this._clickedCoordinateX - ((_a = this._scrollLeft) !== null && _a !== void 0 ? _a : 0);
937
+ var previousDist = 0;
938
+ for (var index = 0; index < this._cursorInfo.currentLineIndex; index++) {
939
+ var line = this._lines[index];
940
+ globalIndex += line.text.length + line.lineEnding.length;
941
+ }
942
+ while (currentSize < relativeXPosition && this._lines[this._cursorInfo.currentLineIndex].text.length > relativeIndex) {
943
+ relativeIndex++;
944
+ previousDist = Math.abs(relativeXPosition - currentSize);
945
+ currentSize = this._contextForBreakLines.measureText(this._lines[this._cursorInfo.currentLineIndex].text.substr(0, relativeIndex)).width;
946
+ }
947
+ // Find closest move
948
+ if (Math.abs(relativeXPosition - currentSize) > previousDist && relativeIndex > 0) {
949
+ relativeIndex--;
950
+ }
951
+ globalIndex += relativeIndex;
952
+ if (!this._isTextHighlightOn) {
953
+ this._cursorInfo.globalStartIndex = globalIndex;
954
+ this._cursorInfo.relativeStartIndex = relativeIndex;
955
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
956
+ this._cursorInfo.relativeEndIndex = this._cursorInfo.relativeStartIndex;
957
+ }
958
+ else {
959
+ if (globalIndex < this._highlightCursorInfo.initialStartIndex) {
960
+ this._cursorInfo.globalStartIndex = globalIndex;
961
+ this._cursorInfo.relativeStartIndex = relativeIndex;
962
+ this._cursorInfo.globalEndIndex = this._highlightCursorInfo.initialStartIndex;
963
+ this._cursorInfo.relativeEndIndex = this._highlightCursorInfo.initialRelativeStartIndex;
964
+ }
965
+ else {
966
+ this._cursorInfo.globalStartIndex = this._highlightCursorInfo.initialStartIndex;
967
+ this._cursorInfo.relativeStartIndex = this._highlightCursorInfo.initialRelativeStartIndex;
968
+ this._cursorInfo.globalEndIndex = globalIndex;
969
+ this._cursorInfo.relativeEndIndex = relativeIndex;
970
+ }
971
+ }
972
+ // Avoid the caret during highlighting
973
+ this._blinkIsEven = this._isTextHighlightOn;
974
+ this._clickedCoordinateX = null;
975
+ this._clickedCoordinateY = null;
976
+ }
977
+ else {
978
+ // Standard behavior same as Current line is at least above the initial highlight index
979
+ this._cursorInfo.relativeStartIndex = 0;
980
+ this._cursorInfo.currentLineIndex = 0;
981
+ var lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
982
+ var tmpLength = 0;
983
+ while (tmpLength + lineLength <= this._cursorInfo.globalStartIndex) {
984
+ tmpLength += lineLength;
985
+ if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
986
+ this._cursorInfo.currentLineIndex++;
987
+ lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
988
+ }
989
+ }
990
+ this._cursorInfo.relativeStartIndex = this._cursorInfo.globalStartIndex - tmpLength;
991
+ if (this._highlightCursorInfo.initialStartIndex !== -1 && this._cursorInfo.globalStartIndex >= this._highlightCursorInfo.initialStartIndex) {
992
+ // Current line is at least below the initial highlight index
993
+ while (tmpLength + lineLength <= this._cursorInfo.globalEndIndex) {
994
+ tmpLength += lineLength;
995
+ if (this._cursorInfo.currentLineIndex < this._lines.length - 1) {
996
+ this._cursorInfo.currentLineIndex++;
997
+ lineLength = this._lines[this._cursorInfo.currentLineIndex].text.length + this._lines[this._cursorInfo.currentLineIndex].lineEnding.length;
998
+ }
999
+ }
1000
+ this._cursorInfo.relativeEndIndex = this._cursorInfo.globalEndIndex - tmpLength;
1001
+ }
1002
+ else if (!this._isTextHighlightOn) {
1003
+ this._cursorInfo.relativeEndIndex = this._cursorInfo.relativeStartIndex;
1004
+ this._cursorInfo.globalEndIndex = this._cursorInfo.globalStartIndex;
1005
+ }
1006
+ }
1007
+ };
1008
+ /**
1009
+ * Update all values of cursor information based on cursorIndex value
1010
+ *
1011
+ * @param offset The index to take care of
1012
+ * @hidden
1013
+ */
1014
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1015
+ InputTextArea.prototype._updateValueFromCursorIndex = function (offset) {
1016
+ // Override to avoid parent behavior during _onPointerMove
1017
+ };
1018
+ /**
1019
+ * Select the word immediatly under the cursor on double click
1020
+ *
1021
+ * @param _evt Pointer informations of double click
1022
+ * @hidden
1023
+ */
1024
+ InputTextArea.prototype._processDblClick = function (_evt) {
1025
+ //pre-find the start and end index of the word under cursor, speeds up the rendering
1026
+ var moveLeft, moveRight;
1027
+ do {
1028
+ moveLeft = this._cursorInfo.globalStartIndex > 0 && this._textWrapper.isWord(this._cursorInfo.globalStartIndex - 1) ? --this._cursorInfo.globalStartIndex : 0;
1029
+ moveRight =
1030
+ this._cursorInfo.globalEndIndex < this._textWrapper.length && this._textWrapper.isWord(this._cursorInfo.globalEndIndex) ? ++this._cursorInfo.globalEndIndex : 0;
1031
+ } while (moveLeft || moveRight);
1032
+ this._highlightCursorInfo.initialLineIndex = this._cursorInfo.currentLineIndex;
1033
+ this._highlightCursorInfo.initialStartIndex = this._cursorInfo.globalStartIndex;
1034
+ this.onTextHighlightObservable.notifyObservers(this);
1035
+ this._isTextHighlightOn = true;
1036
+ this._blinkIsEven = true;
1037
+ this._markAsDirty();
1038
+ };
1039
+ /** @hidden */
1040
+ InputTextArea.prototype._selectAllText = function () {
1041
+ this._isTextHighlightOn = true;
1042
+ this._blinkIsEven = true;
1043
+ this._highlightCursorInfo = {
1044
+ initialStartIndex: 0,
1045
+ initialRelativeStartIndex: 0,
1046
+ initialLineIndex: 0,
1047
+ };
1048
+ this._cursorInfo = {
1049
+ globalStartIndex: 0,
1050
+ globalEndIndex: this._textWrapper.length,
1051
+ relativeEndIndex: this._lines[this._lines.length - 1].text.length,
1052
+ relativeStartIndex: 0,
1053
+ currentLineIndex: this._lines.length - 1,
1054
+ };
1055
+ this._markAsDirty();
1056
+ };
1057
+ InputTextArea.prototype.dipose = function () {
1058
+ _super.prototype.dispose.call(this);
1059
+ this.onLinesReadyObservable.clear();
1060
+ };
1061
+ __decorate([
1062
+ serialize()
1063
+ ], InputTextArea.prototype, "autoStretchHeight", null);
1064
+ __decorate([
1065
+ serialize()
1066
+ ], InputTextArea.prototype, "maxHeight", null);
1067
+ return InputTextArea;
1068
+ }(InputText));
1069
+ export { InputTextArea };
1070
+ RegisterClass("BABYLON.GUI.InputTextArea", InputTextArea);
1071
+ //# sourceMappingURL=inputTextArea.js.map