@next2d/text 1.16.0 → 1.17.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.
- package/dist/TextData.d.ts +74 -0
- package/dist/TextData.js +135 -0
- package/dist/TextFormat.d.ts +1 -26
- package/dist/TextFormat.js +3 -57
- package/dist/TextParser.d.ts +23 -0
- package/dist/TextParser.js +300 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/interface/OptionsImpl.d.ts +6 -0
- package/dist/interface/OptionsImpl.js +1 -0
- package/dist/interface/TextObjectImpl.d.ts +12 -0
- package/dist/interface/TextObjectImpl.js +1 -0
- package/dist/interface/TextObjectModeImpl.d.ts +1 -0
- package/dist/interface/TextObjectModeImpl.js +1 -0
- package/package.json +2 -8
- package/dist/TextField.d.ts +0 -637
- package/dist/TextField.js +0 -2683
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { TextObjectImpl } from "./interface/TextObjectImpl";
|
|
2
|
+
/**
|
|
3
|
+
* @class
|
|
4
|
+
*/
|
|
5
|
+
export declare class TextData {
|
|
6
|
+
private _$textWidth;
|
|
7
|
+
private _$textHeight;
|
|
8
|
+
private readonly _$heightTable;
|
|
9
|
+
private readonly _$ascentTable;
|
|
10
|
+
private readonly _$widthTable;
|
|
11
|
+
private readonly _$textTable;
|
|
12
|
+
private readonly _$lineTable;
|
|
13
|
+
/**
|
|
14
|
+
* @class
|
|
15
|
+
* @public
|
|
16
|
+
*/
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* @member {number}
|
|
20
|
+
* @readonly
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
get textWidth(): number;
|
|
24
|
+
/**
|
|
25
|
+
* @member {number}
|
|
26
|
+
* @readonly
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
get textHeight(): number;
|
|
30
|
+
/**
|
|
31
|
+
* @param {number} line_index
|
|
32
|
+
* @return {number}
|
|
33
|
+
* @method
|
|
34
|
+
* @public
|
|
35
|
+
*/
|
|
36
|
+
getLineWidth(line_index: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* @param {number} line_index
|
|
39
|
+
* @return {number}
|
|
40
|
+
* @method
|
|
41
|
+
* @public
|
|
42
|
+
*/
|
|
43
|
+
getLineHeight(line_index: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* @member {array}
|
|
46
|
+
* @readonly
|
|
47
|
+
* @public
|
|
48
|
+
*/
|
|
49
|
+
get widthTable(): number[];
|
|
50
|
+
/**
|
|
51
|
+
* @member {array}
|
|
52
|
+
* @readonly
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
get heightTable(): number[];
|
|
56
|
+
/**
|
|
57
|
+
* @member {array}
|
|
58
|
+
* @readonly
|
|
59
|
+
* @public
|
|
60
|
+
*/
|
|
61
|
+
get ascentTable(): number[];
|
|
62
|
+
/**
|
|
63
|
+
* @member {array}
|
|
64
|
+
* @readonly
|
|
65
|
+
* @public
|
|
66
|
+
*/
|
|
67
|
+
get textTable(): TextObjectImpl[];
|
|
68
|
+
/**
|
|
69
|
+
* @member {array}
|
|
70
|
+
* @readonly
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
get lineTable(): TextObjectImpl[];
|
|
74
|
+
}
|
package/dist/TextData.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class
|
|
3
|
+
*/
|
|
4
|
+
export class TextData {
|
|
5
|
+
/**
|
|
6
|
+
* @class
|
|
7
|
+
* @public
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* @type {number}
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
this._$textWidth = -1;
|
|
15
|
+
/**
|
|
16
|
+
* @type {number}
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
this._$textHeight = -1;
|
|
20
|
+
/**
|
|
21
|
+
* @type {array}
|
|
22
|
+
* @private
|
|
23
|
+
*/
|
|
24
|
+
this._$widthTable = [];
|
|
25
|
+
/**
|
|
26
|
+
* @type {array}
|
|
27
|
+
* @private
|
|
28
|
+
*/
|
|
29
|
+
this._$heightTable = [];
|
|
30
|
+
/**
|
|
31
|
+
* @type {array}
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
this._$ascentTable = [];
|
|
35
|
+
/**
|
|
36
|
+
* @type {array}
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
this._$textTable = [];
|
|
40
|
+
/**
|
|
41
|
+
* @type {array}
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
this._$lineTable = [];
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @member {number}
|
|
48
|
+
* @readonly
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
get textWidth() {
|
|
52
|
+
if (this._$textWidth === -1) {
|
|
53
|
+
this._$textWidth = 0;
|
|
54
|
+
for (let idx = 0; idx < this._$widthTable.length; ++idx) {
|
|
55
|
+
this._$textWidth = Math.max(this._$textWidth, this._$widthTable[idx]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return this._$textWidth;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @member {number}
|
|
62
|
+
* @readonly
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
get textHeight() {
|
|
66
|
+
if (this._$textHeight === -1) {
|
|
67
|
+
this._$textHeight = 0;
|
|
68
|
+
for (let idx = 0; idx < this._$heightTable.length; ++idx) {
|
|
69
|
+
this._$textHeight += this._$heightTable[idx];
|
|
70
|
+
if (idx) {
|
|
71
|
+
this._$textHeight += 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return this._$textHeight;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @param {number} line_index
|
|
79
|
+
* @return {number}
|
|
80
|
+
* @method
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
getLineWidth(line_index) {
|
|
84
|
+
return line_index in this._$widthTable ? this._$widthTable[line_index] : 0;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* @param {number} line_index
|
|
88
|
+
* @return {number}
|
|
89
|
+
* @method
|
|
90
|
+
* @public
|
|
91
|
+
*/
|
|
92
|
+
getLineHeight(line_index) {
|
|
93
|
+
return line_index in this._$heightTable ? this._$heightTable[line_index] : 0;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* @member {array}
|
|
97
|
+
* @readonly
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
get widthTable() {
|
|
101
|
+
return this._$widthTable;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* @member {array}
|
|
105
|
+
* @readonly
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
get heightTable() {
|
|
109
|
+
return this._$heightTable;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @member {array}
|
|
113
|
+
* @readonly
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
get ascentTable() {
|
|
117
|
+
return this._$ascentTable;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* @member {array}
|
|
121
|
+
* @readonly
|
|
122
|
+
* @public
|
|
123
|
+
*/
|
|
124
|
+
get textTable() {
|
|
125
|
+
return this._$textTable;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* @member {array}
|
|
129
|
+
* @readonly
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
get lineTable() {
|
|
133
|
+
return this._$lineTable;
|
|
134
|
+
}
|
|
135
|
+
}
|
package/dist/TextFormat.d.ts
CHANGED
|
@@ -19,9 +19,7 @@ export declare class TextFormat {
|
|
|
19
19
|
private _$align;
|
|
20
20
|
private _$leftMargin;
|
|
21
21
|
private _$rightMargin;
|
|
22
|
-
private _$indent;
|
|
23
22
|
private _$leading;
|
|
24
|
-
private _$blockIndent;
|
|
25
23
|
private _$letterSpacing;
|
|
26
24
|
/**
|
|
27
25
|
* @param {string} [font=null]
|
|
@@ -33,14 +31,12 @@ export declare class TextFormat {
|
|
|
33
31
|
* @param {string} [align=null]
|
|
34
32
|
* @param {number} [left_margin=null]
|
|
35
33
|
* @param {number} [right_margin=null]
|
|
36
|
-
* @param {number} [indent=null]
|
|
37
34
|
* @param {number} [leading=null]
|
|
38
|
-
* @param {number} [block_indent=null]
|
|
39
35
|
*
|
|
40
36
|
* @constructor
|
|
41
37
|
* @public
|
|
42
38
|
*/
|
|
43
|
-
constructor(font?: string | null, size?: number | null, color?: number | null, bold?: boolean | null, italic?: boolean | null, underline?: boolean | null, align?: TextFormatAlignImpl | null, left_margin?: number | null, right_margin?: number | null,
|
|
39
|
+
constructor(font?: string | null, size?: number | null, color?: number | null, bold?: boolean | null, italic?: boolean | null, underline?: boolean | null, align?: TextFormatAlignImpl | null, left_margin?: number | null, right_margin?: number | null, leading?: number | null);
|
|
44
40
|
/**
|
|
45
41
|
* @description 指定されたクラスのストリングを返します。
|
|
46
42
|
* Returns the string representation of the specified class.
|
|
@@ -91,16 +87,6 @@ export declare class TextFormat {
|
|
|
91
87
|
*/
|
|
92
88
|
get align(): TextFormatAlignImpl | null;
|
|
93
89
|
set align(align: TextFormatAlignImpl | null);
|
|
94
|
-
/**
|
|
95
|
-
* @description ブロックのインデントをピクセル単位で示します。
|
|
96
|
-
* Indicates the block indentation in pixels.
|
|
97
|
-
*
|
|
98
|
-
* @member {number}
|
|
99
|
-
* @default null
|
|
100
|
-
* @public
|
|
101
|
-
*/
|
|
102
|
-
get blockIndent(): number | null;
|
|
103
|
-
set blockIndent(block_indent: number | null);
|
|
104
90
|
/**
|
|
105
91
|
* @description テキストをボールドにするかどうかを指定します。
|
|
106
92
|
* Specifies whether the text is boldface.
|
|
@@ -131,17 +117,6 @@ export declare class TextFormat {
|
|
|
131
117
|
*/
|
|
132
118
|
get font(): string | null;
|
|
133
119
|
set font(font: string | null);
|
|
134
|
-
/**
|
|
135
|
-
* @description 左インデントから段落の先頭文字までのインデントを示します。
|
|
136
|
-
* Indicates the indentation from the left margin
|
|
137
|
-
* to the first character in the paragraph.
|
|
138
|
-
*
|
|
139
|
-
* @member {number}
|
|
140
|
-
* @default null
|
|
141
|
-
* @public
|
|
142
|
-
*/
|
|
143
|
-
get indent(): number | null;
|
|
144
|
-
set indent(indent: number | null);
|
|
145
120
|
/**
|
|
146
121
|
* @description このテキストフォーマットのテキストをイタリックにするかどうかを示します。
|
|
147
122
|
* Indicates whether text in this text format is italicized.
|
package/dist/TextFormat.js
CHANGED
|
@@ -20,14 +20,12 @@ export class TextFormat {
|
|
|
20
20
|
* @param {string} [align=null]
|
|
21
21
|
* @param {number} [left_margin=null]
|
|
22
22
|
* @param {number} [right_margin=null]
|
|
23
|
-
* @param {number} [indent=null]
|
|
24
23
|
* @param {number} [leading=null]
|
|
25
|
-
* @param {number} [block_indent=null]
|
|
26
24
|
*
|
|
27
25
|
* @constructor
|
|
28
26
|
* @public
|
|
29
27
|
*/
|
|
30
|
-
constructor(font = null, size = null, color = null, bold = null, italic = null, underline = null, align = null, left_margin = null, right_margin = null,
|
|
28
|
+
constructor(font = null, size = null, color = null, bold = null, italic = null, underline = null, align = null, left_margin = null, right_margin = null, leading = null) {
|
|
31
29
|
/**
|
|
32
30
|
* @type {string}
|
|
33
31
|
* @default null
|
|
@@ -84,24 +82,12 @@ export class TextFormat {
|
|
|
84
82
|
* @private
|
|
85
83
|
*/
|
|
86
84
|
this._$rightMargin = right_margin;
|
|
87
|
-
/**
|
|
88
|
-
* @type {number}
|
|
89
|
-
* @default null
|
|
90
|
-
* @private
|
|
91
|
-
*/
|
|
92
|
-
this._$indent = indent;
|
|
93
85
|
/**
|
|
94
86
|
* @type {number}
|
|
95
87
|
* @default null
|
|
96
88
|
* @private
|
|
97
89
|
*/
|
|
98
90
|
this._$leading = leading;
|
|
99
|
-
/**
|
|
100
|
-
* @type {number}
|
|
101
|
-
* @default null
|
|
102
|
-
* @private
|
|
103
|
-
*/
|
|
104
|
-
this._$blockIndent = block_indent;
|
|
105
91
|
/**
|
|
106
92
|
* @type {number}
|
|
107
93
|
* @default 0
|
|
@@ -171,20 +157,6 @@ export class TextFormat {
|
|
|
171
157
|
set align(align) {
|
|
172
158
|
this._$align = align;
|
|
173
159
|
}
|
|
174
|
-
/**
|
|
175
|
-
* @description ブロックのインデントをピクセル単位で示します。
|
|
176
|
-
* Indicates the block indentation in pixels.
|
|
177
|
-
*
|
|
178
|
-
* @member {number}
|
|
179
|
-
* @default null
|
|
180
|
-
* @public
|
|
181
|
-
*/
|
|
182
|
-
get blockIndent() {
|
|
183
|
-
return this._$blockIndent;
|
|
184
|
-
}
|
|
185
|
-
set blockIndent(block_indent) {
|
|
186
|
-
this._$blockIndent = block_indent;
|
|
187
|
-
}
|
|
188
160
|
/**
|
|
189
161
|
* @description テキストをボールドにするかどうかを指定します。
|
|
190
162
|
* Specifies whether the text is boldface.
|
|
@@ -230,21 +202,6 @@ export class TextFormat {
|
|
|
230
202
|
set font(font) {
|
|
231
203
|
this._$font = font !== null ? `${font}` : null;
|
|
232
204
|
}
|
|
233
|
-
/**
|
|
234
|
-
* @description 左インデントから段落の先頭文字までのインデントを示します。
|
|
235
|
-
* Indicates the indentation from the left margin
|
|
236
|
-
* to the first character in the paragraph.
|
|
237
|
-
*
|
|
238
|
-
* @member {number}
|
|
239
|
-
* @default null
|
|
240
|
-
* @public
|
|
241
|
-
*/
|
|
242
|
-
get indent() {
|
|
243
|
-
return this._$indent;
|
|
244
|
-
}
|
|
245
|
-
set indent(indent) {
|
|
246
|
-
this._$indent = indent;
|
|
247
|
-
}
|
|
248
205
|
/**
|
|
249
206
|
* @description このテキストフォーマットのテキストをイタリックにするかどうかを示します。
|
|
250
207
|
* Indicates whether text in this text format is italicized.
|
|
@@ -353,7 +310,7 @@ export class TextFormat {
|
|
|
353
310
|
* @private
|
|
354
311
|
*/
|
|
355
312
|
_$clone() {
|
|
356
|
-
const textFormat = new TextFormat(this._$font, this._$size, this._$color, this._$bold, this._$italic, this._$underline, this._$align, this._$leftMargin, this._$rightMargin, this._$
|
|
313
|
+
const textFormat = new TextFormat(this._$font, this._$size, this._$color, this._$bold, this._$italic, this._$underline, this._$align, this._$leftMargin, this._$rightMargin, this._$leading);
|
|
357
314
|
textFormat._$letterSpacing = this._$letterSpacing;
|
|
358
315
|
return textFormat;
|
|
359
316
|
}
|
|
@@ -364,11 +321,9 @@ export class TextFormat {
|
|
|
364
321
|
*/
|
|
365
322
|
_$setDefault() {
|
|
366
323
|
this._$align = "left";
|
|
367
|
-
this._$blockIndent = 0;
|
|
368
324
|
this._$bold = false;
|
|
369
325
|
this._$color = 0;
|
|
370
326
|
this._$font = "Times New Roman";
|
|
371
|
-
this._$indent = 0;
|
|
372
327
|
this._$italic = false;
|
|
373
328
|
this._$leading = 0;
|
|
374
329
|
this._$leftMargin = 0;
|
|
@@ -387,9 +342,6 @@ export class TextFormat {
|
|
|
387
342
|
if (this._$align === null) {
|
|
388
343
|
this._$align = text_format._$align;
|
|
389
344
|
}
|
|
390
|
-
if (this._$blockIndent === null) {
|
|
391
|
-
this._$blockIndent = text_format._$blockIndent;
|
|
392
|
-
}
|
|
393
345
|
if (this._$bold === null) {
|
|
394
346
|
this._$bold = text_format._$bold;
|
|
395
347
|
}
|
|
@@ -399,9 +351,6 @@ export class TextFormat {
|
|
|
399
351
|
if (this._$font === null) {
|
|
400
352
|
this._$font = text_format._$font;
|
|
401
353
|
}
|
|
402
|
-
if (this._$indent === null) {
|
|
403
|
-
this._$indent = text_format._$indent;
|
|
404
|
-
}
|
|
405
354
|
if (this._$italic === null) {
|
|
406
355
|
this._$italic = text_format._$italic;
|
|
407
356
|
}
|
|
@@ -431,9 +380,6 @@ export class TextFormat {
|
|
|
431
380
|
*/
|
|
432
381
|
_$widthMargin() {
|
|
433
382
|
let width = 0;
|
|
434
|
-
if (this._$indent) {
|
|
435
|
-
width += this._$indent;
|
|
436
|
-
}
|
|
437
383
|
if (this._$leftMargin) {
|
|
438
384
|
width += this._$leftMargin;
|
|
439
385
|
}
|
|
@@ -455,6 +401,6 @@ export class TextFormat {
|
|
|
455
401
|
if (this._$bold) {
|
|
456
402
|
fontStyle += "bold ";
|
|
457
403
|
}
|
|
458
|
-
return `${fontStyle}${this._$size}px '${this._$font}',
|
|
404
|
+
return `${fontStyle}${this._$size}px '${this._$font}',sans-serif`;
|
|
459
405
|
}
|
|
460
406
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TextData } from "./TextData";
|
|
2
|
+
import { TextFormat } from "./TextFormat";
|
|
3
|
+
import type { OptionsImpl } from "./interface/OptionsImpl";
|
|
4
|
+
/**
|
|
5
|
+
* @description 文字列のテキストを分解・解析して配列戻す
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text
|
|
8
|
+
* @param {object} [options = null]
|
|
9
|
+
* @return {TextData}
|
|
10
|
+
* @method
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export declare const parsePlainText: (text: string, text_format: TextFormat, options: OptionsImpl) => TextData;
|
|
14
|
+
/**
|
|
15
|
+
* @description HTMLを分解・解析して配列戻す
|
|
16
|
+
*
|
|
17
|
+
* @param {string} html_text
|
|
18
|
+
* @param {object} [options = null]
|
|
19
|
+
* @return {array}
|
|
20
|
+
* @method
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare const parseHtmlText: (html_text: string, text_format: TextFormat, options: OptionsImpl) => TextData;
|