@next2d/text 1.14.20

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Next2D
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ @next2d/text
2
+ =============
3
+
4
+ ## Installation
5
+
6
+ ```
7
+ npm install @next2d/text
8
+ ```
9
+
10
+ ## License
11
+ This project is licensed under the [MIT License](https://opensource.org/licenses/MIT) - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,635 @@
1
+ import { TextFormat } from "./TextFormat";
2
+ import { InteractiveObject } from "@next2d/display";
3
+ import { BoundsImpl, TextFieldTypeImpl, TextFormatVerticalAlignImpl, TextFieldAutoSizeImpl, ParentImpl, TextDataImpl, DictionaryTagImpl, TextCharacterImpl, PlayerHitObjectImpl, Character } from "@next2d/interface";
4
+ import { CanvasToWebGLContext } from "@next2d/webgl";
5
+ /**
6
+ * TextField クラスは、テキストの表示と入力用の表示オブジェクトを作成するために使用されます。
7
+ * プロパティインスペクターを使用して、テキストフィールドにインスタンス名を付けることができます。
8
+ * また、TextField クラスのメソッドとプロパティを使用して、JavaScript でテキストフィールドを操作できます。
9
+ *
10
+ * The TextField class is used to create display objects for text display and input.
11
+ * You can give a text field an instance name in the Property inspector
12
+ * and use the methods and properties of the TextField class to manipulate it with JavaScript.
13
+ *
14
+ * @class
15
+ * @memberOf next2d.text
16
+ * @extends InteractiveObject
17
+ */
18
+ export declare class TextField extends InteractiveObject {
19
+ private readonly _$bounds;
20
+ private readonly _$originBounds;
21
+ private readonly _$textData;
22
+ private readonly _$widthTable;
23
+ private readonly _$heightTable;
24
+ private readonly _$textFormatTable;
25
+ private readonly _$objectTable;
26
+ private readonly _$imageData;
27
+ private readonly _$textHeightTable;
28
+ private readonly _$heightCache;
29
+ private _$background;
30
+ private _$backgroundColor;
31
+ private _$border;
32
+ private _$borderColor;
33
+ private _$htmlText;
34
+ private _$multiline;
35
+ private _$text;
36
+ private _$wordWrap;
37
+ private _$scrollH;
38
+ private _$scrollV;
39
+ private _$maxScrollV;
40
+ private _$maxScrollH;
41
+ private _$maxChars;
42
+ private _$defaultTextFormat;
43
+ private _$rawHtmlText;
44
+ private _$restrict;
45
+ private _$isHTML;
46
+ private _$textHeight;
47
+ private _$textWidth;
48
+ private _$textarea;
49
+ private _$autoSize;
50
+ private _$autoFontSize;
51
+ private _$textAreaActive;
52
+ private _$totalWidth;
53
+ private _$scrollEnabled;
54
+ private _$scrollSprite;
55
+ private _$type;
56
+ private _$focus;
57
+ private _$isComposing;
58
+ private _$thickness;
59
+ private _$thicknessColor;
60
+ private _$verticalAlign;
61
+ private _$createdTextData;
62
+ /**
63
+ * @constructor
64
+ * @public
65
+ */
66
+ constructor();
67
+ /**
68
+ * @description 指定されたクラスのストリングを返します。
69
+ * Returns the string representation of the specified class.
70
+ *
71
+ * @return {string}
72
+ * @default [class TextField]
73
+ * @method
74
+ * @static
75
+ */
76
+ static toString(): string;
77
+ /**
78
+ * @description 指定されたクラスの空間名を返します。
79
+ * Returns the space name of the specified class.
80
+ *
81
+ * @return {string}
82
+ * @default next2d.text.TextField
83
+ * @const
84
+ * @static
85
+ */
86
+ static get namespace(): string;
87
+ /**
88
+ * @description 指定されたオブジェクトのストリングを返します。
89
+ * Returns the string representation of the specified object.
90
+ *
91
+ * @return {string}
92
+ * @default [object TextField]
93
+ * @method
94
+ * @public
95
+ */
96
+ toString(): string;
97
+ /**
98
+ * @description 指定されたオブジェクトの空間名を返します。
99
+ * Returns the space name of the specified object.
100
+ *
101
+ * @return {string}
102
+ * @default next2d.text.TextField
103
+ * @const
104
+ * @public
105
+ */
106
+ get namespace(): string;
107
+ /**
108
+ * @description テキストサイズの自動的な拡大 / 縮小および整列を制御します。
109
+ * Controls automatic sizing and alignment of text size.
110
+ *
111
+ * @member {boolean}
112
+ * @default false
113
+ * @public
114
+ */
115
+ get autoFontSize(): boolean;
116
+ set autoFontSize(auto_font_size: boolean);
117
+ /**
118
+ * @description テキストフィールドの自動的な拡大 / 縮小および整列を制御します。
119
+ * Controls automatic sizing and alignment of text fields.
120
+ *
121
+ * @member {string}
122
+ * @default TextFieldAutoSize.NONE
123
+ * @public
124
+ */
125
+ get autoSize(): TextFieldAutoSizeImpl;
126
+ set autoSize(auto_size: TextFieldAutoSizeImpl);
127
+ /**
128
+ * @description テキストフィールドに背景の塗りつぶしがあるかどうかを指定します。
129
+ * Specifies whether the text field has a background fill.
130
+ *
131
+ * @member {boolean}
132
+ * @default false
133
+ * @public
134
+ */
135
+ get background(): boolean;
136
+ set background(background: boolean);
137
+ /**
138
+ * @description テキストフィールドの背景の色です。
139
+ * The color of the text field background.
140
+ *
141
+ * @member {number}
142
+ * @default 0xffffff
143
+ * @public
144
+ */
145
+ get backgroundColor(): number;
146
+ set backgroundColor(background_color: string | number);
147
+ /**
148
+ * @description テキストフィールドに境界線があるかどうかを指定します。
149
+ * Specifies whether the text field has a border.
150
+ *
151
+ * @member {boolean}
152
+ * @default false
153
+ * @public
154
+ */
155
+ get border(): boolean;
156
+ set border(border: boolean);
157
+ /**
158
+ * @description テキストフィールドの境界線の色です。
159
+ * The color of the text field border.
160
+ *
161
+ * @member {number}
162
+ * @default 0x000000
163
+ * @public
164
+ */
165
+ get borderColor(): number;
166
+ set borderColor(border_color: string | number);
167
+ /**
168
+ * @description テキストに適用するフォーマットを指定します。
169
+ * Specifies the formatting to be applied to the text.
170
+ *
171
+ * @member {TextFormat}
172
+ * @public
173
+ */
174
+ get defaultTextFormat(): TextFormat;
175
+ set defaultTextFormat(text_format: TextFormat);
176
+ /**
177
+ * @description このオブジェクトでマウスまたはその他のユーザー入力メッセージを
178
+ *
179
+ * @member {boolean}
180
+ * @default false
181
+ * @public
182
+ */
183
+ get focus(): boolean;
184
+ set focus(focus: boolean);
185
+ /**
186
+ * @description テキストフィールドの内容を HTML で表します。
187
+ * Contains the HTML representation of the text field contents.
188
+ *
189
+ * @member {string}
190
+ * @default ""
191
+ * @public
192
+ */
193
+ get htmlText(): string;
194
+ set htmlText(html_text: string);
195
+ /**
196
+ * @description テキストフィールド内の文字数です。
197
+ * The int of characters in a text field.
198
+ *
199
+ * @member {number}
200
+ * @readonly
201
+ * @public
202
+ */
203
+ get length(): number;
204
+ /**
205
+ * @description ユーザーが入力するときに、テキストフィールドに入力できる最大の文字数です。
206
+ * The maximum number of characters that the text field can contain,
207
+ * as entered by a user.
208
+ *
209
+ * @member {number}
210
+ * @default 0
211
+ * @public
212
+ */
213
+ get maxChars(): number;
214
+ set maxChars(max_chars: number);
215
+ /**
216
+ * TODO
217
+ * @description scrollH の最大値です。
218
+ * The maximum value of scrollH.
219
+ *
220
+ * @member {number}
221
+ * @readonly
222
+ * @public
223
+ */
224
+ get maxScrollH(): number;
225
+ /**
226
+ * @description scrollV の最大値です。
227
+ * The maximum value of scrollV.
228
+ *
229
+ * @member {number}
230
+ * @readonly
231
+ * @public
232
+ */
233
+ get maxScrollV(): number;
234
+ /**
235
+ * @description フィールドが複数行テキストフィールドであるかどうかを示します。
236
+ * Indicates whether field is a multiline text field.
237
+ *
238
+ * @member {boolean}
239
+ * @default false
240
+ * @public
241
+ */
242
+ get multiline(): boolean;
243
+ set multiline(multiline: boolean);
244
+ /**
245
+ * @description フィールドが複数行テキストフィールドであるかどうかを示します。
246
+ * Indicates whether field is a multiline text field.
247
+ *
248
+ * @member {number}
249
+ * @readonly
250
+ * @public
251
+ */
252
+ get numLines(): number;
253
+ /**
254
+ * @description ユーザーがテキストフィールドに入力できる文字のセットを指定します。
255
+ * Indicates the set of characters that a user can enter into the text field.
256
+ *
257
+ * @member {string}
258
+ * @default null
259
+ * @public
260
+ */
261
+ get restrict(): string;
262
+ set restrict(restrict: string);
263
+ /**
264
+ * @description スクロール機能のON/OFFの制御。
265
+ * Control ON/OFF of the scroll function.
266
+ *
267
+ * @member {boolean}
268
+ * @default true
269
+ * @public
270
+ */
271
+ get scrollEnabled(): boolean;
272
+ set scrollEnabled(scroll_enabled: boolean);
273
+ /**
274
+ * TODO
275
+ * @description 現在の水平スクロール位置です。
276
+ * The current horizontal scrolling position.
277
+ *
278
+ * @member {number}
279
+ * @public
280
+ */
281
+ get scrollH(): number;
282
+ set scrollH(scroll_h: number);
283
+ /**
284
+ * @description テキストフィールドのテキストの垂直位置です。
285
+ * The vertical position of text in a text field.
286
+ *
287
+ * @member {number}
288
+ * @public
289
+ */
290
+ get scrollV(): number;
291
+ set scrollV(scroll_v: number);
292
+ /**
293
+ * @description テキストフィールド内の現在のテキストであるストリングです。
294
+ * A string that is the current text in the text field.
295
+ *
296
+ * @member {string}
297
+ * @default ""
298
+ * @public
299
+ */
300
+ get text(): string;
301
+ set text(text: string | null);
302
+ /**
303
+ * @description テキストフィールドのテキストの色です(16 進数形式)。
304
+ * The color of the text in a text field, in hexadecimal format.
305
+ *
306
+ * @member {number}
307
+ * @public
308
+ */
309
+ get textColor(): number;
310
+ set textColor(text_color: number);
311
+ /**
312
+ * @description テキストの高さです(ピクセル単位)。
313
+ * The height of the text in pixels.
314
+ *
315
+ * @member {number}
316
+ * @readonly
317
+ * @public
318
+ */
319
+ get textHeight(): number;
320
+ /**
321
+ * @description テキストの幅です(ピクセル単位)。
322
+ * The width of the text in pixels.
323
+ *
324
+ * @member {number}
325
+ * @readonly
326
+ * @public
327
+ */
328
+ get textWidth(): number;
329
+ /**
330
+ * @description 輪郭のテキスト幅です。0(デフォルト値)で無効にできます。
331
+ * The text width of the outline, which can be disabled with 0 (the default value).
332
+ *
333
+ * @member {number}
334
+ * @default 0
335
+ * @public
336
+ */
337
+ get thickness(): number;
338
+ set thickness(thickness: number);
339
+ /**
340
+ * @description 輪郭のテキストの色です(16 進数形式)。
341
+ * The color of the outline text. (Hexadecimal format)
342
+ *
343
+ * @member {number}
344
+ * @default 0
345
+ * @public
346
+ */
347
+ get thicknessColor(): number;
348
+ set thicknessColor(thickness_color: number);
349
+ /**
350
+ * @description テキストフィールドのタイプです。
351
+ * The type of the text field.
352
+ *
353
+ * @member {string}
354
+ * @default TextFieldType.STATIC
355
+ * @public
356
+ */
357
+ get type(): TextFieldTypeImpl;
358
+ set type(type: TextFieldTypeImpl);
359
+ /**
360
+ * @description 縦方向の揃え位置を指定するプロパティです。
361
+ * This property specifies the vertical alignment position.
362
+ *
363
+ * @member {string}
364
+ * @default TextFormatVerticalAlign.TOP
365
+ * @public
366
+ */
367
+ get verticalAlign(): TextFormatVerticalAlignImpl;
368
+ set verticalAlign(vertical_align: TextFormatVerticalAlignImpl);
369
+ /**
370
+ * @description テキストフィールドのテキストを折り返すかどうかを示すブール値です。
371
+ * A Boolean value that indicates whether the text field has word wrap.
372
+ *
373
+ * @member {boolean}
374
+ * @default false
375
+ * @public
376
+ */
377
+ get wordWrap(): boolean;
378
+ set wordWrap(word_wrap: boolean);
379
+ /**
380
+ * @description 表示オブジェクトの幅を示します(ピクセル単位)。
381
+ * Indicates the width of the display object, in pixels.
382
+ *
383
+ * @member {number}
384
+ * @public
385
+ */
386
+ get width(): number;
387
+ set width(width: number);
388
+ /**
389
+ * @description 表示オブジェクトの高さを示します(ピクセル単位)。
390
+ * Indicates the height of the display object, in pixels.
391
+ *
392
+ * @member {number}
393
+ * @public
394
+ */
395
+ get height(): number;
396
+ set height(height: number);
397
+ /**
398
+ * @description 親 DisplayObjectContainer のローカル座標を基準にした
399
+ * DisplayObject インスタンスの x 座標を示します。
400
+ * Indicates the x coordinate
401
+ * of the DisplayObject instance relative to the local coordinates
402
+ * of the parent DisplayObjectContainer.
403
+ *
404
+ * @member {number}
405
+ * @public
406
+ */
407
+ get x(): number;
408
+ set x(x: number);
409
+ /**
410
+ * @description 親 DisplayObjectContainer のローカル座標を基準にした
411
+ * DisplayObject インスタンスの y 座標を示します。
412
+ * Indicates the y coordinate
413
+ * of the DisplayObject instance relative to the local coordinates
414
+ * of the parent DisplayObjectContainer.
415
+ *
416
+ * @member {number}
417
+ * @public
418
+ */
419
+ get y(): number;
420
+ set y(y: number);
421
+ /**
422
+ * @description newText パラメーターで指定されたストリングを、
423
+ * テキストフィールドのテキストの最後に付加します。
424
+ * Appends the string specified by the newText parameter
425
+ * to the end of the text of the text field.
426
+ *
427
+ * @param {string} new_text
428
+ * @return void
429
+ * @method
430
+ * @public
431
+ */
432
+ appendText(new_text: string): void;
433
+ /**
434
+ * @description beginIndex パラメーターと endIndex パラメーターで指定された範囲の
435
+ * テキストのフォーマット情報を含む TextFormat オブジェクトを返します。
436
+ * Returns a TextFormat object that contains formatting information
437
+ * for the range of text that the beginIndex and endIndex parameters specify.
438
+ *
439
+ * @param {int} [begin_index=-1]
440
+ * @param {int} [end_index=-1]
441
+ * @return {TextFormat}
442
+ * @method
443
+ * @public
444
+ */
445
+ getTextFormat(begin_index?: number, end_index?: number): TextFormat;
446
+ /**
447
+ * @description lineIndex パラメーターで指定された行のテキストを返します。
448
+ * Returns the text of the line specified by the lineIndex parameter.
449
+ *
450
+ * @param {number} line_index
451
+ * @return {string}
452
+ * @public
453
+ */
454
+ getLineText(line_index: number): string;
455
+ /**
456
+ * @description beginIndex パラメーターと endIndex パラメーターで指定された文字範囲を、
457
+ * newText パラメーターの内容に置き換えます。
458
+ * Replaces the range of characters that the beginIndex
459
+ * and endIndex parameters specify with the contents of the newText parameter.
460
+ *
461
+ * @param {number} begin_index
462
+ * @param {number} end_index
463
+ * @param {string} new_text
464
+ * @return {void}
465
+ * @method
466
+ * @public
467
+ */
468
+ replaceText(begin_index: number, end_index: number, new_text: string): void;
469
+ /**
470
+ * @description format パラメーターで指定したテキストフォーマットを、
471
+ * テキストフィールド内の指定されたテキストに適用します。
472
+ * Applies the text formatting that the format parameter specifies
473
+ * to the specified text in a text field.
474
+ *
475
+ * @param {TextFormat} text_format
476
+ * @param {number} [begin_index=-1]
477
+ * @param {number} [end_index=-1]
478
+ * @return {void}
479
+ * @method
480
+ * @public
481
+ */
482
+ setTextFormat(text_format: TextFormat, begin_index?: number, end_index?: number): void;
483
+ /**
484
+ * @return {array}
485
+ * @method
486
+ * @private
487
+ */
488
+ _$getTextData(): TextDataImpl<any>[];
489
+ /**
490
+ * @param {Element} tag
491
+ * @param {TextFormat} text_format
492
+ * @param {number} tf_copy_offset
493
+ * @return {void}
494
+ * @private
495
+ */
496
+ _$parseTag(tag: HTMLElement, text_format: TextFormat, tf_copy_offset: number): void;
497
+ /**
498
+ * @param {string} text
499
+ * @param {TextFormat} text_format
500
+ * @param {number} tf_copy_offset
501
+ * @returns {number}
502
+ * @method
503
+ * @private
504
+ */
505
+ _$parseText(text: string, text_format: TextFormat, tf_copy_offset: number): number;
506
+ /**
507
+ * @param {TextFormat} text_format
508
+ * @return {number}
509
+ * @private
510
+ */
511
+ _$getTextHeight(text_format: TextFormat): number;
512
+ /**
513
+ * @return {number}
514
+ * @private
515
+ */
516
+ _$getImageOffsetX(): number;
517
+ /**
518
+ * @return {void}
519
+ * @method
520
+ * @private
521
+ */
522
+ _$reset(): void;
523
+ /**
524
+ * @return {void}
525
+ * @method
526
+ * @private
527
+ */
528
+ _$reload(): void;
529
+ /**
530
+ * @return {void}
531
+ * @method
532
+ * @private
533
+ */
534
+ _$resize(): void;
535
+ /**
536
+ * @param {object} obj
537
+ * @param {number} width
538
+ * @return {number}
539
+ * @private
540
+ */
541
+ _$getAlignOffset(obj: TextDataImpl<any>, width: number): number;
542
+ /**
543
+ * @param {Float32Array} [matrix=null]
544
+ * @returns {object}
545
+ * @method
546
+ * @private
547
+ */
548
+ _$getBounds(matrix?: Float32Array | null): BoundsImpl;
549
+ /**
550
+ * @param {object} character
551
+ * @return {void}
552
+ * @method
553
+ * @private
554
+ */
555
+ _$buildCharacter(character: Character<TextCharacterImpl>): void;
556
+ /**
557
+ * @param {object} character
558
+ * @return {void}
559
+ * @method
560
+ * @private
561
+ */
562
+ _$sync(character: TextCharacterImpl): void;
563
+ /**
564
+ * @param {object} tag
565
+ * @param {DisplayObjectContainer} parent
566
+ * @return {object}
567
+ * @method
568
+ * @private
569
+ */
570
+ _$build(tag: DictionaryTagImpl, parent: ParentImpl<any>): TextCharacterImpl;
571
+ /**
572
+ * @param {CanvasToWebGLContext} context
573
+ * @param {Float32Array} matrix
574
+ * @returns {void}
575
+ * @method
576
+ * @private
577
+ */
578
+ _$clip(context: CanvasToWebGLContext, matrix: Float32Array): void;
579
+ /**
580
+ * @param {CanvasToWebGLContext} context
581
+ * @param {Float32Array} matrix
582
+ * @param {Float32Array} color_transform
583
+ * @return {void}
584
+ * @method
585
+ * @private
586
+ */
587
+ _$draw(context: CanvasToWebGLContext, matrix: Float32Array, color_transform: Float32Array): void;
588
+ /**
589
+ * @param {CanvasRenderingContext2D} context
590
+ * @param {Float32Array} matrix
591
+ * @param {Float32Array} color_transform
592
+ * @param {number} width
593
+ * @return {void}
594
+ * @method
595
+ * @private
596
+ */
597
+ _$doDraw(context: CanvasRenderingContext2D, matrix: Float32Array, color_transform: Float32Array, width: number): void;
598
+ /**
599
+ * @param {CanvasRenderingContext2D} context
600
+ * @param {Float32Array} matrix
601
+ * @param {object} options
602
+ * @return {boolean}
603
+ * @method
604
+ * @private
605
+ */
606
+ _$mouseHit(context: CanvasRenderingContext2D, matrix: Float32Array, options: PlayerHitObjectImpl): boolean;
607
+ /**
608
+ * @param {CanvasRenderingContext2D} context
609
+ * @param {Float32Array} matrix
610
+ * @param {object} options
611
+ * @return {boolean}
612
+ * @method
613
+ * @private
614
+ */
615
+ _$hit(context: CanvasRenderingContext2D, matrix: Float32Array, options: PlayerHitObjectImpl): boolean;
616
+ /**
617
+ * @param {number} scale
618
+ * @return {void}
619
+ * @method
620
+ * @private
621
+ */
622
+ _$createTextAreaElement(scale: number): void;
623
+ /**
624
+ * @return {void}
625
+ * @method
626
+ * @private
627
+ */
628
+ _$createWorkerInstance(): void;
629
+ /**
630
+ * @return {void}
631
+ * @method
632
+ * @private
633
+ */
634
+ _$postProperty(): void;
635
+ }