@next2d/text 1.18.11 → 2.0.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/package.json +14 -18
- package/src/TextArea/service/TextAreaMovePositionService.d.ts +11 -0
- package/src/TextArea/service/TextAreaMovePositionService.js +42 -0
- package/src/TextArea/usecase/TextAreaCompositionEndUseCase.d.ts +9 -0
- package/src/TextArea/usecase/TextAreaCompositionEndUseCase.js +17 -0
- package/src/TextArea/usecase/TextAreaCompositionStartUseCase.d.ts +9 -0
- package/src/TextArea/usecase/TextAreaCompositionStartUseCase.js +17 -0
- package/src/TextArea/usecase/TextAreaCompositionUpdateUseCase.d.ts +10 -0
- package/src/TextArea/usecase/TextAreaCompositionUpdateUseCase.js +18 -0
- package/src/TextArea/usecase/TextAreaInputUseCase.d.ts +10 -0
- package/src/TextArea/usecase/TextAreaInputUseCase.js +25 -0
- package/src/TextArea/usecase/TextAreaRegisterEventUseCase.d.ts +10 -0
- package/src/TextArea/usecase/TextAreaRegisterEventUseCase.js +21 -0
- package/src/TextData.d.ts +103 -0
- package/src/TextData.js +183 -0
- package/src/TextField/service/TextFieldApplyChangesService.d.ts +11 -0
- package/src/TextField/service/TextFieldApplyChangesService.js +16 -0
- package/src/TextField/service/TextFieldBlinkingClearTimeoutService.d.ts +9 -0
- package/src/TextField/service/TextFieldBlinkingClearTimeoutService.js +16 -0
- package/src/TextField/service/TextFieldCompositionStartService.d.ts +11 -0
- package/src/TextField/service/TextFieldCompositionStartService.js +12 -0
- package/src/TextField/service/TextFieldPasteService.d.ts +11 -0
- package/src/TextField/service/TextFieldPasteService.js +16 -0
- package/src/TextField/usecase/TextFieldArrowDownUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldArrowDownUseCase.js +191 -0
- package/src/TextField/usecase/TextFieldArrowLeftUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldArrowLeftUseCase.js +98 -0
- package/src/TextField/usecase/TextFieldArrowRightUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldArrowRightUseCase.js +92 -0
- package/src/TextField/usecase/TextFieldArrowUpUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldArrowUpUseCase.js +156 -0
- package/src/TextField/usecase/TextFieldBlinkingUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldBlinkingUseCase.js +21 -0
- package/src/TextField/usecase/TextFieldBuildFromCharacterUseCase.d.ts +13 -0
- package/src/TextField/usecase/TextFieldBuildFromCharacterUseCase.js +58 -0
- package/src/TextField/usecase/TextFieldCompositionEndUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldCompositionEndUseCase.js +32 -0
- package/src/TextField/usecase/TextFieldCompositionUpdateUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldCompositionUpdateUseCase.js +109 -0
- package/src/TextField/usecase/TextFieldCopyUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldCopyUseCase.js +38 -0
- package/src/TextField/usecase/TextFieldDeleteTextUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldDeleteTextUseCase.js +108 -0
- package/src/TextField/usecase/TextFieldGetLineTextUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldGetLineTextUseCase.js +32 -0
- package/src/TextField/usecase/TextFieldGetTextDataUseCase.d.ts +15 -0
- package/src/TextField/usecase/TextFieldGetTextDataUseCase.js +26 -0
- package/src/TextField/usecase/TextFieldHtmlTextToRawTextUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldHtmlTextToRawTextUseCase.js +31 -0
- package/src/TextField/usecase/TextFieldInsertTextUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldInsertTextUseCase.js +79 -0
- package/src/TextField/usecase/TextFieldKeyDownEventUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldKeyDownEventUseCase.js +60 -0
- package/src/TextField/usecase/TextFieldReloadUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldReloadUseCase.js +25 -0
- package/src/TextField/usecase/TextFieldReplaceTextUseCase.d.ts +14 -0
- package/src/TextField/usecase/TextFieldReplaceTextUseCase.js +24 -0
- package/src/TextField/usecase/TextFieldResetUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldResetUseCase.js +20 -0
- package/src/TextField/usecase/TextFieldResizeAutoFontSizeUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldResizeAutoFontSizeUseCase.js +37 -0
- package/src/TextField/usecase/TextFieldResizeUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldResizeUseCase.js +49 -0
- package/src/TextField/usecase/TextFieldSelectAllUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldSelectAllUseCase.js +20 -0
- package/src/TextField/usecase/TextFieldSelectedFocusMoveUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldSelectedFocusMoveUseCase.js +90 -0
- package/src/TextField/usecase/TextFieldSetFocusIndexUseCase.d.ts +14 -0
- package/src/TextField/usecase/TextFieldSetFocusIndexUseCase.js +197 -0
- package/src/TextField/usecase/TextFieldSetFocusUseCase.d.ts +11 -0
- package/src/TextField/usecase/TextFieldSetFocusUseCase.js +43 -0
- package/src/TextField/usecase/TextFieldSetScrollXUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldSetScrollXUseCase.js +66 -0
- package/src/TextField/usecase/TextFieldSetScrollYUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldSetScrollYUseCase.js +66 -0
- package/src/TextField/usecase/TextFieldUpdateStopIndexUseCase.d.ts +12 -0
- package/src/TextField/usecase/TextFieldUpdateStopIndexUseCase.js +82 -0
- package/src/TextField.d.ts +602 -0
- package/src/TextField.js +1292 -0
- package/src/TextFormat/service/TextFormatGenerateFontStyleService.d.ts +11 -0
- package/src/TextFormat/service/TextFormatGenerateFontStyleService.js +19 -0
- package/src/TextFormat/service/TextFormatGetWidthMarginService.d.ts +11 -0
- package/src/TextFormat/service/TextFormatGetWidthMarginService.js +19 -0
- package/src/TextFormat/service/TextFormatHtmlTextGenerateStyleService.d.ts +11 -0
- package/src/TextFormat/service/TextFormatHtmlTextGenerateStyleService.js +51 -0
- package/src/TextFormat/service/TextFormatIsSameService.d.ts +12 -0
- package/src/TextFormat/service/TextFormatIsSameService.js +28 -0
- package/src/TextFormat/service/TextFormatSetDefaultService.d.ts +11 -0
- package/src/TextFormat/service/TextFormatSetDefaultService.js +22 -0
- package/{dist → src}/TextFormat.d.ts +42 -128
- package/src/TextFormat.js +233 -0
- package/src/TextParser/service/TextParserAdjustmentHeightService.d.ts +11 -0
- package/src/TextParser/service/TextParserAdjustmentHeightService.js +24 -0
- package/src/TextParser/service/TextParserParseStyleService.d.ts +11 -0
- package/src/TextParser/service/TextParserParseStyleService.js +80 -0
- package/src/TextParser/usecase/TextParserCreateNewLineUseCase.d.ts +13 -0
- package/src/TextParser/usecase/TextParserCreateNewLineUseCase.js +35 -0
- package/src/TextParser/usecase/TextParserParseHtmlTextUseCase.d.ts +15 -0
- package/src/TextParser/usecase/TextParserParseHtmlTextUseCase.js +37 -0
- package/src/TextParser/usecase/TextParserParseTagUseCase.d.ts +17 -0
- package/src/TextParser/usecase/TextParserParseTagUseCase.js +57 -0
- package/src/TextParser/usecase/TextParserParseTextUseCase.d.ts +16 -0
- package/src/TextParser/usecase/TextParserParseTextUseCase.js +140 -0
- package/src/TextParser/usecase/TextParserSetAttributesUseCase.d.ts +14 -0
- package/src/TextParser/usecase/TextParserSetAttributesUseCase.js +63 -0
- package/src/TextUtil.d.ts +114 -0
- package/src/TextUtil.js +186 -0
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
- package/src/interface/IAttributeObject.d.ts +4 -0
- package/src/interface/IBlendMode.d.ts +1 -0
- package/src/interface/IBounds.d.ts +6 -0
- package/src/interface/ICharacter.d.ts +5 -0
- package/src/interface/ICharacter.js +1 -0
- package/src/interface/IDictionaryTag.d.ts +8 -0
- package/src/interface/IDictionaryTag.js +1 -0
- package/src/interface/IElementPosition.d.ts +4 -0
- package/src/interface/IElementPosition.js +1 -0
- package/src/interface/IFilterArray.d.ts +2 -0
- package/src/interface/IFilterArray.js +1 -0
- package/src/interface/IGrid.d.ts +6 -0
- package/src/interface/IGrid.js +1 -0
- package/src/interface/ILoopConfig.d.ts +8 -0
- package/src/interface/ILoopConfig.js +1 -0
- package/src/interface/ILoopType.d.ts +1 -0
- package/src/interface/ILoopType.js +1 -0
- package/src/interface/IMovieClipActionObject.d.ts +5 -0
- package/src/interface/IMovieClipActionObject.js +1 -0
- package/src/interface/IMovieClipCharacter.d.ts +17 -0
- package/src/interface/IMovieClipCharacter.js +1 -0
- package/src/interface/IMovieClipLabelObject.d.ts +4 -0
- package/src/interface/IMovieClipLabelObject.js +1 -0
- package/src/interface/IMovieClipSoundObject.d.ts +5 -0
- package/src/interface/IMovieClipSoundObject.js +1 -0
- package/src/interface/IOptions.d.ts +8 -0
- package/src/interface/IOptions.js +1 -0
- package/src/interface/IPlaceObject.d.ts +14 -0
- package/src/interface/IPlaceObject.js +1 -0
- package/src/interface/IRGBA.d.ts +6 -0
- package/src/interface/IRGBA.js +1 -0
- package/src/interface/IShapeCharacter.d.ts +14 -0
- package/src/interface/IShapeCharacter.js +1 -0
- package/src/interface/ISoundTag.d.ts +6 -0
- package/src/interface/ISoundTag.js +1 -0
- package/src/interface/ISurfaceFilter.d.ts +6 -0
- package/src/interface/ISurfaceFilter.js +1 -0
- package/src/interface/ITextFieldAutoSize.d.ts +1 -0
- package/src/interface/ITextFieldAutoSize.js +1 -0
- package/src/interface/ITextFieldCharacter copy.d.ts +26 -0
- package/src/interface/ITextFieldCharacter copy.js +1 -0
- package/src/interface/ITextFieldCharacter.d.ts +26 -0
- package/src/interface/ITextFieldCharacter.js +1 -0
- package/src/interface/ITextFieldType copy.d.ts +1 -0
- package/src/interface/ITextFieldType copy.js +1 -0
- package/src/interface/ITextFieldType.d.ts +1 -0
- package/src/interface/ITextFieldType.js +1 -0
- package/src/interface/ITextFormatAlign copy.d.ts +1 -0
- package/src/interface/ITextFormatAlign copy.js +1 -0
- package/src/interface/ITextFormatAlign.d.ts +1 -0
- package/src/interface/ITextFormatAlign.js +1 -0
- package/src/interface/ITextFormatObject.d.ts +14 -0
- package/src/interface/ITextFormatObject.js +1 -0
- package/src/interface/ITextObject.d.ts +12 -0
- package/src/interface/ITextObject.js +1 -0
- package/src/interface/ITextObjectMode.d.ts +1 -0
- package/src/interface/ITextObjectMode.js +1 -0
- package/src/interface/IVideoCharacter.d.ts +11 -0
- package/src/interface/IVideoCharacter.js +1 -0
- package/dist/TextData.d.ts +0 -74
- package/dist/TextData.js +0 -132
- package/dist/TextFormat.js +0 -493
- package/dist/TextParser.d.ts +0 -23
- package/dist/TextParser.js +0 -459
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/interface/OptionsImpl.d.ts +0 -8
- package/dist/interface/TextObjectImpl.d.ts +0 -12
- package/dist/interface/TextObjectModeImpl.d.ts +0 -1
- /package/{dist/interface/OptionsImpl.js → src/interface/IAttributeObject.js} +0 -0
- /package/{dist/interface/TextObjectImpl.js → src/interface/IBlendMode.js} +0 -0
- /package/{dist/interface/TextObjectModeImpl.js → src/interface/IBounds.js} +0 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { $toColorInt } from "./TextUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description TextFormat クラスは、文字フォーマット情報を表します。
|
|
4
|
+
* TextFormat クラスを使用して、テキストフィールドに特定のテキストフォーマットを作成します。
|
|
5
|
+
*
|
|
6
|
+
* The TextFormat class represents character formatting information.
|
|
7
|
+
* Use the TextFormat class to create specific text formatting for text fields.
|
|
8
|
+
*
|
|
9
|
+
* @class
|
|
10
|
+
* @memberOf next2d.text
|
|
11
|
+
*/
|
|
12
|
+
export class TextFormat {
|
|
13
|
+
/**
|
|
14
|
+
* @param {string} [font=null]
|
|
15
|
+
* @param {number} [size=null]
|
|
16
|
+
* @param {number} [color=null]
|
|
17
|
+
* @param {boolean} [bold=null]
|
|
18
|
+
* @param {boolean} [italic=null]
|
|
19
|
+
* @param {boolean} [underline=null]
|
|
20
|
+
* @param {string} [align=null]
|
|
21
|
+
* @param {number} [left_margin=null]
|
|
22
|
+
* @param {number} [right_margin=null]
|
|
23
|
+
* @param {number} [leading=null]
|
|
24
|
+
*
|
|
25
|
+
* @constructor
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
constructor(font = null, size = null, color = null, bold = null, italic = null, underline = null, align = null, left_margin = null, right_margin = null, leading = null, letter_Spacing = null) {
|
|
29
|
+
/**
|
|
30
|
+
* @description 段落の行揃えの設定を示します。
|
|
31
|
+
* Indicates the alignment of the paragraph.
|
|
32
|
+
*
|
|
33
|
+
* @member {string}
|
|
34
|
+
* @default null
|
|
35
|
+
* @public
|
|
36
|
+
*/
|
|
37
|
+
Object.defineProperty(this, "align", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* @description テキストをボールドにするかどうかを指定します。
|
|
45
|
+
* Specifies whether the text is boldface.
|
|
46
|
+
*
|
|
47
|
+
* @member {boolean}
|
|
48
|
+
* @default null
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
Object.defineProperty(this, "bold", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* @description テキストの色を示します。
|
|
59
|
+
* Indicates the color of the text.
|
|
60
|
+
*
|
|
61
|
+
* @member {number}
|
|
62
|
+
* @default null
|
|
63
|
+
* @public
|
|
64
|
+
*/
|
|
65
|
+
Object.defineProperty(this, "color", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* @description このテキストフォーマットでのテキストフォント名を示すストリングです。
|
|
73
|
+
* The name of the font for text in this text format, as a string.
|
|
74
|
+
*
|
|
75
|
+
* @member {string}
|
|
76
|
+
* @default null
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
79
|
+
Object.defineProperty(this, "font", {
|
|
80
|
+
enumerable: true,
|
|
81
|
+
configurable: true,
|
|
82
|
+
writable: true,
|
|
83
|
+
value: void 0
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* @description このテキストフォーマットのテキストをイタリックにするかどうかを示します。
|
|
87
|
+
* Indicates whether text in this text format is italicized.
|
|
88
|
+
*
|
|
89
|
+
* @member {boolean}
|
|
90
|
+
* @default null
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
Object.defineProperty(this, "italic", {
|
|
94
|
+
enumerable: true,
|
|
95
|
+
configurable: true,
|
|
96
|
+
writable: true,
|
|
97
|
+
value: void 0
|
|
98
|
+
});
|
|
99
|
+
/**
|
|
100
|
+
* @description 行間の垂直の行送りを示す整数です。
|
|
101
|
+
* An integer representing the amount
|
|
102
|
+
* of vertical space (called leading) between lines.
|
|
103
|
+
*
|
|
104
|
+
* @member {number}
|
|
105
|
+
* @default null
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
Object.defineProperty(this, "leading", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
configurable: true,
|
|
111
|
+
writable: true,
|
|
112
|
+
value: void 0
|
|
113
|
+
});
|
|
114
|
+
/**
|
|
115
|
+
* @description 段落の左インデントをピクセル単位で示します。
|
|
116
|
+
* The left margin of the paragraph, in pixels.
|
|
117
|
+
*
|
|
118
|
+
* @member {number}
|
|
119
|
+
* @default null
|
|
120
|
+
* @public
|
|
121
|
+
*/
|
|
122
|
+
Object.defineProperty(this, "leftMargin", {
|
|
123
|
+
enumerable: true,
|
|
124
|
+
configurable: true,
|
|
125
|
+
writable: true,
|
|
126
|
+
value: void 0
|
|
127
|
+
});
|
|
128
|
+
/**
|
|
129
|
+
* @description すべての文字の間に均等に配分されるスペースの量を表す数値です。
|
|
130
|
+
* A object representing the amount
|
|
131
|
+
* of space that is uniformly distributed between all characters.
|
|
132
|
+
*
|
|
133
|
+
* @member {number}
|
|
134
|
+
* @default null
|
|
135
|
+
* @public
|
|
136
|
+
*/
|
|
137
|
+
Object.defineProperty(this, "letterSpacing", {
|
|
138
|
+
enumerable: true,
|
|
139
|
+
configurable: true,
|
|
140
|
+
writable: true,
|
|
141
|
+
value: void 0
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* @description 段落の右インデントをピクセル単位で示します。
|
|
145
|
+
* The right margin of the paragraph, in pixels.
|
|
146
|
+
*
|
|
147
|
+
* @member {number}
|
|
148
|
+
* @default null
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
Object.defineProperty(this, "rightMargin", {
|
|
152
|
+
enumerable: true,
|
|
153
|
+
configurable: true,
|
|
154
|
+
writable: true,
|
|
155
|
+
value: void 0
|
|
156
|
+
});
|
|
157
|
+
/**
|
|
158
|
+
* @description このテキストフォーマットのテキストのサイズ(ピクセル単位)です。
|
|
159
|
+
* The size in pixels of text in this text format.
|
|
160
|
+
*
|
|
161
|
+
* @member {number}
|
|
162
|
+
* @default null
|
|
163
|
+
* @public
|
|
164
|
+
*/
|
|
165
|
+
Object.defineProperty(this, "size", {
|
|
166
|
+
enumerable: true,
|
|
167
|
+
configurable: true,
|
|
168
|
+
writable: true,
|
|
169
|
+
value: void 0
|
|
170
|
+
});
|
|
171
|
+
/**
|
|
172
|
+
* @description このテキストフォーマットを使用するテキストに
|
|
173
|
+
* アンダーラインを表示する(true)か、表示しない(false)かを示します。
|
|
174
|
+
* Indicates whether the text that uses this text format
|
|
175
|
+
* is underlined (true) or not (false).
|
|
176
|
+
*
|
|
177
|
+
* @member {boolean}
|
|
178
|
+
* @default null
|
|
179
|
+
* @public
|
|
180
|
+
*/
|
|
181
|
+
Object.defineProperty(this, "underline", {
|
|
182
|
+
enumerable: true,
|
|
183
|
+
configurable: true,
|
|
184
|
+
writable: true,
|
|
185
|
+
value: void 0
|
|
186
|
+
});
|
|
187
|
+
this.font = font;
|
|
188
|
+
this.size = size;
|
|
189
|
+
this.color = color;
|
|
190
|
+
this.bold = bold;
|
|
191
|
+
this.italic = italic;
|
|
192
|
+
this.underline = underline;
|
|
193
|
+
this.align = align;
|
|
194
|
+
this.leftMargin = left_margin;
|
|
195
|
+
this.rightMargin = right_margin;
|
|
196
|
+
this.leading = leading;
|
|
197
|
+
this.letterSpacing = letter_Spacing;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* @description この TextFormat オブジェクトのコピーを作成して返します。
|
|
201
|
+
* Creates a copy of the TextFormat object and returns it.
|
|
202
|
+
*
|
|
203
|
+
* @return {next2d.text.TextFormat}
|
|
204
|
+
* @method
|
|
205
|
+
* @public
|
|
206
|
+
*/
|
|
207
|
+
clone() {
|
|
208
|
+
return new TextFormat(this.font, this.size, this.color, this.bold, this.italic, this.underline, this.align, this.leftMargin, this.rightMargin, this.leading, this.letterSpacing);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* @description この TextFormat オブジェクトのプロパティをオブジェクトに変換します。
|
|
212
|
+
* Converts the properties of this TextFormat object to an object.
|
|
213
|
+
*
|
|
214
|
+
* @return {ITextFormatObject}
|
|
215
|
+
* @method
|
|
216
|
+
* @public
|
|
217
|
+
*/
|
|
218
|
+
toObject() {
|
|
219
|
+
return {
|
|
220
|
+
"font": this.font,
|
|
221
|
+
"size": this.size,
|
|
222
|
+
"color": $toColorInt(this.color),
|
|
223
|
+
"bold": this.bold,
|
|
224
|
+
"italic": this.italic,
|
|
225
|
+
"underline": this.underline,
|
|
226
|
+
"align": this.align,
|
|
227
|
+
"leftMargin": this.leftMargin,
|
|
228
|
+
"rightMargin": this.rightMargin,
|
|
229
|
+
"leading": this.leading,
|
|
230
|
+
"letterSpacing": this.letterSpacing
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextData } from "../../TextData";
|
|
2
|
+
/**
|
|
3
|
+
* @description 改行だけの行の高さを調整
|
|
4
|
+
* Adjust the height of a line that contains only line breaks
|
|
5
|
+
*
|
|
6
|
+
* @param {TextData} text_data
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (text_data: TextData) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 改行だけの行の高さを調整
|
|
3
|
+
* Adjust the height of a line that contains only line breaks
|
|
4
|
+
*
|
|
5
|
+
* @param {TextData} text_data
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (text_data) => {
|
|
11
|
+
const length = text_data.heightTable.length - 1;
|
|
12
|
+
for (let idx = 1; idx < length; ++idx) {
|
|
13
|
+
const height = text_data.heightTable[idx];
|
|
14
|
+
if (height > 0) {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
// 改行があって、高さの設定がなければ前の行の高さを設定する
|
|
18
|
+
const object = text_data.lineTable[idx];
|
|
19
|
+
if (!object) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
text_data.heightTable[idx] = object.h = text_data.heightTable[idx - 1];
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IAttributeObject } from "../../interface/IAttributeObject";
|
|
2
|
+
/**
|
|
3
|
+
* @description スタイルを解析して属性オブジェクトの配列を返す
|
|
4
|
+
* Analyze the style and return an array of attribute objects
|
|
5
|
+
*
|
|
6
|
+
* @param {string} value
|
|
7
|
+
* @return {IAttributeObject[]}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (value: string) => IAttributeObject[];
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description スタイルを解析して属性オブジェクトの配列を返す
|
|
3
|
+
* Analyze the style and return an array of attribute objects
|
|
4
|
+
*
|
|
5
|
+
* @param {string} value
|
|
6
|
+
* @return {IAttributeObject[]}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (value) => {
|
|
11
|
+
const values = value
|
|
12
|
+
.trim()
|
|
13
|
+
.split(";");
|
|
14
|
+
const attributes = [];
|
|
15
|
+
for (let idx = 0; idx < values.length; ++idx) {
|
|
16
|
+
const styleValue = values[idx];
|
|
17
|
+
if (!styleValue) {
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const styles = styleValue.split(":");
|
|
21
|
+
const name = styles[0].trim();
|
|
22
|
+
const value = styles[1].trim();
|
|
23
|
+
switch (name) {
|
|
24
|
+
case "font-size":
|
|
25
|
+
attributes.push({
|
|
26
|
+
"name": "size",
|
|
27
|
+
"value": parseInt(value)
|
|
28
|
+
});
|
|
29
|
+
break;
|
|
30
|
+
case "font-family":
|
|
31
|
+
attributes.push({
|
|
32
|
+
"name": "face",
|
|
33
|
+
"value": value.replace(/'|"/g, "")
|
|
34
|
+
});
|
|
35
|
+
break;
|
|
36
|
+
case "letter-spacing":
|
|
37
|
+
attributes.push({
|
|
38
|
+
"name": "letterSpacing",
|
|
39
|
+
"value": parseInt(value)
|
|
40
|
+
});
|
|
41
|
+
break;
|
|
42
|
+
case "margin-bottom":
|
|
43
|
+
attributes.push({
|
|
44
|
+
"name": "leading",
|
|
45
|
+
"value": parseInt(value)
|
|
46
|
+
});
|
|
47
|
+
break;
|
|
48
|
+
case "margin-left":
|
|
49
|
+
attributes.push({
|
|
50
|
+
"name": "leftMargin",
|
|
51
|
+
"value": parseInt(value)
|
|
52
|
+
});
|
|
53
|
+
break;
|
|
54
|
+
case "margin-right":
|
|
55
|
+
attributes.push({
|
|
56
|
+
"name": "rightMargin",
|
|
57
|
+
"value": parseInt(value)
|
|
58
|
+
});
|
|
59
|
+
break;
|
|
60
|
+
case "color":
|
|
61
|
+
case "align":
|
|
62
|
+
attributes.push({
|
|
63
|
+
"name": name,
|
|
64
|
+
"value": value
|
|
65
|
+
});
|
|
66
|
+
break;
|
|
67
|
+
case "text-decoration":
|
|
68
|
+
case "font-weight":
|
|
69
|
+
case "font-style":
|
|
70
|
+
attributes.push({
|
|
71
|
+
"name": value,
|
|
72
|
+
"value": true
|
|
73
|
+
});
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return attributes;
|
|
80
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { TextData } from "../../TextData";
|
|
2
|
+
import type { TextFormat } from "../../TextFormat";
|
|
3
|
+
/**
|
|
4
|
+
* @description 新しい行を作成
|
|
5
|
+
* Create a new line
|
|
6
|
+
*
|
|
7
|
+
* @param {TextData} text_data
|
|
8
|
+
* @param {TextFormat} text_format
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export declare const execute: (text_data: TextData, text_format: TextFormat) => void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { execute as textFormatGenerateFontStyleService } from "../../TextFormat/service/TextFormatGenerateFontStyleService";
|
|
2
|
+
import { $context, $setCurrentWidth } from "../../TextUtil";
|
|
3
|
+
/**
|
|
4
|
+
* @description 新しい行を作成
|
|
5
|
+
* Create a new line
|
|
6
|
+
*
|
|
7
|
+
* @param {TextData} text_data
|
|
8
|
+
* @param {TextFormat} text_format
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export const execute = (text_data, text_format) => {
|
|
14
|
+
$setCurrentWidth(0);
|
|
15
|
+
const line = text_data.lineTable.length;
|
|
16
|
+
$context.font = textFormatGenerateFontStyleService(text_format);
|
|
17
|
+
const mesure = $context.measureText("");
|
|
18
|
+
const object = {
|
|
19
|
+
"mode": "break",
|
|
20
|
+
"text": "",
|
|
21
|
+
"x": 0,
|
|
22
|
+
"y": 0,
|
|
23
|
+
"w": 0,
|
|
24
|
+
"h": mesure.fontBoundingBoxAscent + mesure.fontBoundingBoxDescent,
|
|
25
|
+
"line": line,
|
|
26
|
+
"textFormat": text_format.toObject()
|
|
27
|
+
};
|
|
28
|
+
// initialize
|
|
29
|
+
text_data.heightTable[line] = 0;
|
|
30
|
+
text_data.ascentTable[line] = 0;
|
|
31
|
+
text_data.widthTable[line] = 0;
|
|
32
|
+
// register
|
|
33
|
+
text_data.lineTable.push(object);
|
|
34
|
+
text_data.textTable.push(object);
|
|
35
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TextFormat } from "../../TextFormat";
|
|
2
|
+
import type { IOptions } from "../../interface/IOptions";
|
|
3
|
+
import { TextData } from "../../TextData";
|
|
4
|
+
/**
|
|
5
|
+
* @description HTMLテキストを解析してTextDataを生成
|
|
6
|
+
* Analyze HTML text and generate TextData
|
|
7
|
+
*
|
|
8
|
+
* @param {string} html_text
|
|
9
|
+
* @param {TextFormat} text_format
|
|
10
|
+
* @param {IOptions} options
|
|
11
|
+
* @return {TextData}
|
|
12
|
+
* @method
|
|
13
|
+
* @protected
|
|
14
|
+
*/
|
|
15
|
+
export declare const execute: (html_text: string, text_format: TextFormat, options: IOptions) => TextData;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TextData } from "../../TextData";
|
|
2
|
+
import { parseDocument } from "htmlparser2";
|
|
3
|
+
import { execute as textParserCreateNewLineUseCase } from "./TextParserCreateNewLineUseCase";
|
|
4
|
+
import { execute as textParserAdjustmentHeightService } from "../service/TextParserAdjustmentHeightService";
|
|
5
|
+
import { execute as textParserParseTagUseCase } from "./TextParserParseTagUseCase";
|
|
6
|
+
/**
|
|
7
|
+
* @description HTMLテキストを解析してTextDataを生成
|
|
8
|
+
* Analyze HTML text and generate TextData
|
|
9
|
+
*
|
|
10
|
+
* @param {string} html_text
|
|
11
|
+
* @param {TextFormat} text_format
|
|
12
|
+
* @param {IOptions} options
|
|
13
|
+
* @return {TextData}
|
|
14
|
+
* @method
|
|
15
|
+
* @protected
|
|
16
|
+
*/
|
|
17
|
+
export const execute = (html_text, text_format, options) => {
|
|
18
|
+
const textData = new TextData();
|
|
19
|
+
if (!html_text) {
|
|
20
|
+
return textData;
|
|
21
|
+
}
|
|
22
|
+
const htmlText = html_text
|
|
23
|
+
.trim()
|
|
24
|
+
.replace(/\r?\n/g, "")
|
|
25
|
+
.replace(/\t/g, "");
|
|
26
|
+
const textFormat = text_format.clone();
|
|
27
|
+
if (options.subFontSize && options.subFontSize > 0 && textFormat.size) {
|
|
28
|
+
textFormat.size -= options.subFontSize;
|
|
29
|
+
if (1 > textFormat.size) {
|
|
30
|
+
textFormat.size = 1;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
textParserCreateNewLineUseCase(textData, textFormat);
|
|
34
|
+
textParserParseTagUseCase(parseDocument(htmlText), textFormat, textData, options);
|
|
35
|
+
textParserAdjustmentHeightService(textData);
|
|
36
|
+
return textData;
|
|
37
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { TextFormat } from "../../TextFormat";
|
|
2
|
+
import type { TextData } from "../../TextData";
|
|
3
|
+
import type { IOptions } from "../../interface/IOptions";
|
|
4
|
+
import type { Document } from "domhandler";
|
|
5
|
+
/**
|
|
6
|
+
* @description タグを解析してTextDataとTextFormatを設定
|
|
7
|
+
* Analyze tags and set TextData and TextFormat
|
|
8
|
+
*
|
|
9
|
+
* @param {Document} document
|
|
10
|
+
* @param {TextFormat} text_format
|
|
11
|
+
* @param {TextData} text_data
|
|
12
|
+
* @param {IOptions} options
|
|
13
|
+
* @return {void}
|
|
14
|
+
* @method
|
|
15
|
+
* @protected
|
|
16
|
+
*/
|
|
17
|
+
export declare const execute: (document: Document, text_format: TextFormat, text_data: TextData, options: IOptions) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { execute as textParserParseTextUseCase } from "./TextParserParseTextUseCase";
|
|
2
|
+
import { execute as textParserCreateNewLineUseCase } from "./TextParserCreateNewLineUseCase";
|
|
3
|
+
import { execute as textParserSetAttributesUseCase } from "./TextParserSetAttributesUseCase";
|
|
4
|
+
/**
|
|
5
|
+
* @description タグを解析してTextDataとTextFormatを設定
|
|
6
|
+
* Analyze tags and set TextData and TextFormat
|
|
7
|
+
*
|
|
8
|
+
* @param {Document} document
|
|
9
|
+
* @param {TextFormat} text_format
|
|
10
|
+
* @param {TextData} text_data
|
|
11
|
+
* @param {IOptions} options
|
|
12
|
+
* @return {void}
|
|
13
|
+
* @method
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
export const execute = (document, text_format, text_data, options) => {
|
|
17
|
+
for (let idx = 0; idx < document.children.length; ++idx) {
|
|
18
|
+
const node = document.children[idx];
|
|
19
|
+
if (node.nodeType === 3) {
|
|
20
|
+
textParserParseTextUseCase(node.nodeValue || "", text_format, text_data, options);
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
const textFormat = text_format.clone();
|
|
24
|
+
switch (node.name.toUpperCase()) {
|
|
25
|
+
case "DIV": // div tag
|
|
26
|
+
case "P": // p tag
|
|
27
|
+
textParserSetAttributesUseCase(node.attributes, textFormat, options);
|
|
28
|
+
if (options.multiline) {
|
|
29
|
+
textParserCreateNewLineUseCase(text_data, textFormat);
|
|
30
|
+
}
|
|
31
|
+
execute(node, textFormat, text_data, options);
|
|
32
|
+
continue;
|
|
33
|
+
case "U": // underline
|
|
34
|
+
textFormat.underline = true;
|
|
35
|
+
break;
|
|
36
|
+
case "B": // bold
|
|
37
|
+
textFormat.bold = true;
|
|
38
|
+
break;
|
|
39
|
+
case "I": // italic
|
|
40
|
+
textFormat.italic = true;
|
|
41
|
+
break;
|
|
42
|
+
case "FONT": // FONT tag
|
|
43
|
+
case "SPAN": // SPAN tag
|
|
44
|
+
textParserSetAttributesUseCase(node.attributes, textFormat, options);
|
|
45
|
+
break;
|
|
46
|
+
case "BR":
|
|
47
|
+
if (!options.multiline) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
textParserCreateNewLineUseCase(text_data, textFormat);
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
execute(node, textFormat, text_data, options);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IOptions } from "../../interface/IOptions";
|
|
2
|
+
import type { TextData } from "../../TextData";
|
|
3
|
+
import type { TextFormat } from "../../TextFormat";
|
|
4
|
+
/**
|
|
5
|
+
* @description テキストを解析
|
|
6
|
+
* Analyze text
|
|
7
|
+
*
|
|
8
|
+
* @param {string} texts
|
|
9
|
+
* @param {TextFormat} text_format
|
|
10
|
+
* @param {TextData} text_data
|
|
11
|
+
* @param {IOptions} options
|
|
12
|
+
* @return {void}
|
|
13
|
+
* @method
|
|
14
|
+
* @protected
|
|
15
|
+
*/
|
|
16
|
+
export declare const execute: (texts: string, text_format: TextFormat, text_data: TextData, options: IOptions) => void;
|