@next2d/text 1.18.12 → 2.0.1
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
package/package.json
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/text",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Next2D Text
|
|
5
|
-
"author": "Toshiyuki Ienaga<ienaga@
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "Next2D Text Package",
|
|
5
|
+
"author": "Toshiyuki Ienaga<ienaga@next2d.app> (https://github.com/ienaga/)",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://next2d.app",
|
|
8
8
|
"bugs": "https://github.com/Next2D/Player/issues",
|
|
9
|
-
"main": "
|
|
10
|
-
"types": "
|
|
11
|
-
"
|
|
12
|
-
"dist"
|
|
13
|
-
],
|
|
9
|
+
"main": "src/index.js",
|
|
10
|
+
"types": "src/index.d.ts",
|
|
11
|
+
"type": "module",
|
|
14
12
|
"exports": {
|
|
15
13
|
".": {
|
|
16
|
-
"import":
|
|
17
|
-
|
|
18
|
-
"default": "./dist/index.js"
|
|
19
|
-
},
|
|
20
|
-
"require": {
|
|
21
|
-
"types": "./dist/index.d.ts",
|
|
22
|
-
"default": "./dist/index.js"
|
|
23
|
-
}
|
|
14
|
+
"import": "./src/index.js",
|
|
15
|
+
"require": "./src/index.js"
|
|
24
16
|
}
|
|
25
17
|
},
|
|
26
18
|
"keywords": [
|
|
@@ -31,7 +23,11 @@
|
|
|
31
23
|
"type": "git",
|
|
32
24
|
"url": "git+https://github.com/Next2D/Player.git"
|
|
33
25
|
},
|
|
34
|
-
"
|
|
35
|
-
"@next2d/
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@next2d/display": "2.0.1",
|
|
28
|
+
"@next2d/geom": "2.0.1",
|
|
29
|
+
"@next2d/events": "2.0.1",
|
|
30
|
+
"@next2d/ui": "2.0.1",
|
|
31
|
+
"@next2d/cache": "2.0.1"
|
|
36
32
|
}
|
|
37
33
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextField } from "../../TextField";
|
|
2
|
+
/**
|
|
3
|
+
* @description フォーカスしているテキストの位置にテキストエリアを移動します。
|
|
4
|
+
* Move the text area to the position of the text that is focusing.
|
|
5
|
+
*
|
|
6
|
+
* @param {TextField} text_field
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (text_field: TextField) => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Point } from "@next2d/geom";
|
|
2
|
+
import { stage } from "@next2d/display";
|
|
3
|
+
import { $textArea, $mainCanvasPosition } from "../../TextUtil";
|
|
4
|
+
/**
|
|
5
|
+
* @type {number}
|
|
6
|
+
* @private
|
|
7
|
+
*/
|
|
8
|
+
const $devicePixelRatio = window.devicePixelRatio;
|
|
9
|
+
/**
|
|
10
|
+
* @description フォーカスしているテキストの位置にテキストエリアを移動します。
|
|
11
|
+
* Move the text area to the position of the text that is focusing.
|
|
12
|
+
*
|
|
13
|
+
* @param {TextField} text_field
|
|
14
|
+
* @return {void}
|
|
15
|
+
* @method
|
|
16
|
+
* @protected
|
|
17
|
+
*/
|
|
18
|
+
export const execute = (text_field) => {
|
|
19
|
+
const point = text_field.localToGlobal(new Point());
|
|
20
|
+
const textData = text_field.$textData;
|
|
21
|
+
if (textData) {
|
|
22
|
+
const focusTextObject = textData.textTable[text_field.focusIndex];
|
|
23
|
+
if (focusTextObject) {
|
|
24
|
+
for (let idx = text_field.focusIndex - 1; idx > -1; --idx) {
|
|
25
|
+
const textObject = textData.textTable[idx];
|
|
26
|
+
if (!textObject || textObject.line !== focusTextObject.line) {
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
point.x += textObject.w;
|
|
30
|
+
}
|
|
31
|
+
const line = focusTextObject.mode === "break"
|
|
32
|
+
? focusTextObject.line - 1
|
|
33
|
+
: focusTextObject.line;
|
|
34
|
+
for (let idx = 0; idx < line; ++idx) {
|
|
35
|
+
point.y += textData.heightTable[idx];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const scale = stage.rendererScale / $devicePixelRatio;
|
|
40
|
+
$textArea.style.left = `${$mainCanvasPosition.x + point.x * scale}px`;
|
|
41
|
+
$textArea.style.top = `${$mainCanvasPosition.y + point.y * scale}px`;
|
|
42
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $getSelectedTextField } from "../../TextUtil";
|
|
2
|
+
import { execute as textFieldCompositionEndUseCase } from "../../TextField/usecase/TextFieldCompositionEndUseCase";
|
|
3
|
+
/**
|
|
4
|
+
* @description テキストフィールドのコンポジションエンドイベントを処理します。
|
|
5
|
+
* Processes the composition end event of the text field.
|
|
6
|
+
*
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export const execute = () => {
|
|
12
|
+
const textField = $getSelectedTextField();
|
|
13
|
+
if (!textField) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
textFieldCompositionEndUseCase(textField);
|
|
17
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { $getSelectedTextField } from "../../TextUtil";
|
|
2
|
+
import { execute as textFieldCompositionStartService } from "../../TextField/service/TextFieldCompositionStartService";
|
|
3
|
+
/**
|
|
4
|
+
* @description IME などのテキスト変換システムが新しい変換セッションを開始した時に発生します。
|
|
5
|
+
* Occurs when a text conversion system, such as an IME, starts a new conversion session.
|
|
6
|
+
*
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export const execute = () => {
|
|
12
|
+
const textField = $getSelectedTextField();
|
|
13
|
+
if (!textField) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
textFieldCompositionStartService(textField);
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description IME などのテキスト変換システムによって制御されているテキスト変換セッションに新しい文字が入力されたときに発生します。
|
|
3
|
+
* Occurs when a new character is entered into a text conversion session controlled by a text conversion system such as an IME.
|
|
4
|
+
*
|
|
5
|
+
* @param {CompositionEvent} event
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export declare const execute: (event: CompositionEvent) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { $getSelectedTextField } from "../../TextUtil";
|
|
2
|
+
import { execute as textFieldCompositionUpdateUseCase } from "../../TextField/usecase/TextFieldCompositionUpdateUseCase";
|
|
3
|
+
/**
|
|
4
|
+
* @description IME などのテキスト変換システムによって制御されているテキスト変換セッションに新しい文字が入力されたときに発生します。
|
|
5
|
+
* Occurs when a new character is entered into a text conversion session controlled by a text conversion system such as an IME.
|
|
6
|
+
*
|
|
7
|
+
* @param {CompositionEvent} event
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
export const execute = (event) => {
|
|
13
|
+
const textField = $getSelectedTextField();
|
|
14
|
+
if (!textField) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
textFieldCompositionUpdateUseCase(textField, event.data);
|
|
18
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { $getSelectedTextField } from "../../TextUtil";
|
|
2
|
+
import { Event } from "@next2d/events";
|
|
3
|
+
import { execute as textFieldInsertTextUseCase } from "../../TextField/usecase/TextFieldInsertTextUseCase";
|
|
4
|
+
/**
|
|
5
|
+
* @description テキストエリアに入力された文字を挿入します。
|
|
6
|
+
* Inserts the characters entered in the text area.
|
|
7
|
+
*
|
|
8
|
+
* @param {InputEvent} event
|
|
9
|
+
* @return {void}
|
|
10
|
+
* @method
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
13
|
+
export const execute = (event) => {
|
|
14
|
+
if (!event.data) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const textField = $getSelectedTextField();
|
|
18
|
+
if (!textField) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
textFieldInsertTextUseCase(textField, event.data);
|
|
22
|
+
if (textField.hasEventListener(Event.INPUT)) {
|
|
23
|
+
textField.dispatchEvent(new Event(Event.INPUT));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { execute as textAreaCompositionStartUseCase } from "./TextAreaCompositionStartUseCase";
|
|
2
|
+
import { execute as textAreaCompositionUpdateUseCase } from "./TextAreaCompositionUpdateUseCase";
|
|
3
|
+
import { execute as textAreaCompositionEndUseCase } from "./TextAreaCompositionEndUseCase";
|
|
4
|
+
import { execute as textAreaInputUseCase } from "./TextAreaInputUseCase";
|
|
5
|
+
/**
|
|
6
|
+
* @description テキストエリアにイベントを登録します。
|
|
7
|
+
* Registers events in the text area.
|
|
8
|
+
*
|
|
9
|
+
* @param {HTMLTextAreaElement} text_area
|
|
10
|
+
* @return {void}
|
|
11
|
+
* @method
|
|
12
|
+
* @protected
|
|
13
|
+
*/
|
|
14
|
+
export const execute = (text_area) => {
|
|
15
|
+
// omposition evnet
|
|
16
|
+
text_area.addEventListener("compositionstart", textAreaCompositionStartUseCase);
|
|
17
|
+
text_area.addEventListener("compositionupdate", textAreaCompositionUpdateUseCase);
|
|
18
|
+
text_area.addEventListener("compositionend", textAreaCompositionEndUseCase);
|
|
19
|
+
// input event
|
|
20
|
+
text_area.addEventListener("input", textAreaInputUseCase);
|
|
21
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ITextObject } from "./interface/ITextObject";
|
|
2
|
+
/**
|
|
3
|
+
* @description テキストの文字毎のデータ
|
|
4
|
+
* Data for each character of text
|
|
5
|
+
* @class
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export declare class TextData {
|
|
9
|
+
private _$textWidth;
|
|
10
|
+
private _$textHeight;
|
|
11
|
+
/**
|
|
12
|
+
* @description テキストの行ごとの高さ
|
|
13
|
+
* Height of each line of text
|
|
14
|
+
*
|
|
15
|
+
* @type {array}
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
readonly heightTable: number[];
|
|
19
|
+
/**
|
|
20
|
+
* @description テキストの行ごとのベースラインから上方線までの距離
|
|
21
|
+
* Distance from the baseline to the top line of each line of text
|
|
22
|
+
*
|
|
23
|
+
* @type {array}
|
|
24
|
+
* @public
|
|
25
|
+
*/
|
|
26
|
+
readonly ascentTable: number[];
|
|
27
|
+
/**
|
|
28
|
+
* @description テキストの行ごとの幅
|
|
29
|
+
* Width of each line of text
|
|
30
|
+
*
|
|
31
|
+
* @type {array}
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
readonly widthTable: number[];
|
|
35
|
+
/**
|
|
36
|
+
* @description テキストの行ごとのテキストオブジェクト
|
|
37
|
+
* Text object for each line of text
|
|
38
|
+
*
|
|
39
|
+
* @type {array}
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
readonly textTable: ITextObject[];
|
|
43
|
+
/**
|
|
44
|
+
* @description テキストの行ごとのテキストオブジェクト
|
|
45
|
+
* Text object for each line of text
|
|
46
|
+
*
|
|
47
|
+
* @type {array}
|
|
48
|
+
* @public
|
|
49
|
+
*/
|
|
50
|
+
readonly lineTable: ITextObject[];
|
|
51
|
+
/**
|
|
52
|
+
* @class
|
|
53
|
+
* @public
|
|
54
|
+
*/
|
|
55
|
+
constructor();
|
|
56
|
+
/**
|
|
57
|
+
* @description テキストエリアの幅
|
|
58
|
+
* Width of text area
|
|
59
|
+
*
|
|
60
|
+
* @member {number}
|
|
61
|
+
* @readonly
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
get textWidth(): number;
|
|
65
|
+
/**
|
|
66
|
+
* @description テキストエリアの高さ
|
|
67
|
+
* Height of text area
|
|
68
|
+
*
|
|
69
|
+
* @member {number}
|
|
70
|
+
* @readonly
|
|
71
|
+
* @public
|
|
72
|
+
*/
|
|
73
|
+
get textHeight(): number;
|
|
74
|
+
/**
|
|
75
|
+
* @description 指定した行のテキストの幅
|
|
76
|
+
* Width of text for the specified line
|
|
77
|
+
*
|
|
78
|
+
* @param {number} line_index
|
|
79
|
+
* @return {number}
|
|
80
|
+
* @method
|
|
81
|
+
* @public
|
|
82
|
+
*/
|
|
83
|
+
getLineWidth(line_index: number): number;
|
|
84
|
+
/**
|
|
85
|
+
* @description 指定した行のテキストの高さ
|
|
86
|
+
* Height of text for the specified line
|
|
87
|
+
*
|
|
88
|
+
* @param {number} line_index
|
|
89
|
+
* @return {number}
|
|
90
|
+
* @method
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
getLineHeight(line_index: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* @description 設定を初期化
|
|
96
|
+
* Initialize settings
|
|
97
|
+
*
|
|
98
|
+
* @return {void}
|
|
99
|
+
* @method
|
|
100
|
+
* @public
|
|
101
|
+
*/
|
|
102
|
+
clear(): void;
|
|
103
|
+
}
|
package/src/TextData.js
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description テキストの文字毎のデータ
|
|
3
|
+
* Data for each character of text
|
|
4
|
+
* @class
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
7
|
+
export class TextData {
|
|
8
|
+
/**
|
|
9
|
+
* @class
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
constructor() {
|
|
13
|
+
Object.defineProperty(this, "_$textWidth", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
configurable: true,
|
|
16
|
+
writable: true,
|
|
17
|
+
value: void 0
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(this, "_$textHeight", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
configurable: true,
|
|
22
|
+
writable: true,
|
|
23
|
+
value: void 0
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* @description テキストの行ごとの高さ
|
|
27
|
+
* Height of each line of text
|
|
28
|
+
*
|
|
29
|
+
* @type {array}
|
|
30
|
+
* @public
|
|
31
|
+
*/
|
|
32
|
+
Object.defineProperty(this, "heightTable", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* @description テキストの行ごとのベースラインから上方線までの距離
|
|
40
|
+
* Distance from the baseline to the top line of each line of text
|
|
41
|
+
*
|
|
42
|
+
* @type {array}
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
Object.defineProperty(this, "ascentTable", {
|
|
46
|
+
enumerable: true,
|
|
47
|
+
configurable: true,
|
|
48
|
+
writable: true,
|
|
49
|
+
value: void 0
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* @description テキストの行ごとの幅
|
|
53
|
+
* Width of each line of text
|
|
54
|
+
*
|
|
55
|
+
* @type {array}
|
|
56
|
+
* @public
|
|
57
|
+
*/
|
|
58
|
+
Object.defineProperty(this, "widthTable", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
/**
|
|
65
|
+
* @description テキストの行ごとのテキストオブジェクト
|
|
66
|
+
* Text object for each line of text
|
|
67
|
+
*
|
|
68
|
+
* @type {array}
|
|
69
|
+
* @public
|
|
70
|
+
*/
|
|
71
|
+
Object.defineProperty(this, "textTable", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
/**
|
|
78
|
+
* @description テキストの行ごとのテキストオブジェクト
|
|
79
|
+
* Text object for each line of text
|
|
80
|
+
*
|
|
81
|
+
* @type {array}
|
|
82
|
+
* @public
|
|
83
|
+
*/
|
|
84
|
+
Object.defineProperty(this, "lineTable", {
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true,
|
|
87
|
+
writable: true,
|
|
88
|
+
value: void 0
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* @type {number}
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
this._$textWidth = -1;
|
|
95
|
+
/**
|
|
96
|
+
* @type {number}
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
this._$textHeight = -1;
|
|
100
|
+
this.widthTable = [];
|
|
101
|
+
this.heightTable = [];
|
|
102
|
+
this.ascentTable = [];
|
|
103
|
+
this.textTable = [];
|
|
104
|
+
this.lineTable = [];
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* @description テキストエリアの幅
|
|
108
|
+
* Width of text area
|
|
109
|
+
*
|
|
110
|
+
* @member {number}
|
|
111
|
+
* @readonly
|
|
112
|
+
* @public
|
|
113
|
+
*/
|
|
114
|
+
get textWidth() {
|
|
115
|
+
if (this._$textWidth !== -1) {
|
|
116
|
+
return this._$textWidth;
|
|
117
|
+
}
|
|
118
|
+
this._$textWidth = 0;
|
|
119
|
+
for (let idx = 0; idx < this.widthTable.length; ++idx) {
|
|
120
|
+
this._$textWidth = Math.max(this._$textWidth, this.widthTable[idx]);
|
|
121
|
+
}
|
|
122
|
+
return this._$textWidth;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* @description テキストエリアの高さ
|
|
126
|
+
* Height of text area
|
|
127
|
+
*
|
|
128
|
+
* @member {number}
|
|
129
|
+
* @readonly
|
|
130
|
+
* @public
|
|
131
|
+
*/
|
|
132
|
+
get textHeight() {
|
|
133
|
+
if (this._$textHeight !== -1) {
|
|
134
|
+
return this._$textHeight;
|
|
135
|
+
}
|
|
136
|
+
this._$textHeight = 0;
|
|
137
|
+
for (let idx = 0; idx < this.heightTable.length; ++idx) {
|
|
138
|
+
this._$textHeight += this.heightTable[idx];
|
|
139
|
+
}
|
|
140
|
+
return this._$textHeight;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* @description 指定した行のテキストの幅
|
|
144
|
+
* Width of text for the specified line
|
|
145
|
+
*
|
|
146
|
+
* @param {number} line_index
|
|
147
|
+
* @return {number}
|
|
148
|
+
* @method
|
|
149
|
+
* @public
|
|
150
|
+
*/
|
|
151
|
+
getLineWidth(line_index) {
|
|
152
|
+
return line_index in this.widthTable ? this.widthTable[line_index] : 0;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* @description 指定した行のテキストの高さ
|
|
156
|
+
* Height of text for the specified line
|
|
157
|
+
*
|
|
158
|
+
* @param {number} line_index
|
|
159
|
+
* @return {number}
|
|
160
|
+
* @method
|
|
161
|
+
* @public
|
|
162
|
+
*/
|
|
163
|
+
getLineHeight(line_index) {
|
|
164
|
+
return line_index in this.heightTable ? this.heightTable[line_index] : 0;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* @description 設定を初期化
|
|
168
|
+
* Initialize settings
|
|
169
|
+
*
|
|
170
|
+
* @return {void}
|
|
171
|
+
* @method
|
|
172
|
+
* @public
|
|
173
|
+
*/
|
|
174
|
+
clear() {
|
|
175
|
+
this._$textWidth = -1;
|
|
176
|
+
this._$textHeight = -1;
|
|
177
|
+
this.widthTable.length = 0;
|
|
178
|
+
this.heightTable.length = 0;
|
|
179
|
+
this.ascentTable.length = 0;
|
|
180
|
+
this.textTable.length = 0;
|
|
181
|
+
this.lineTable.length = 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DisplayObject } from "@next2d/display";
|
|
2
|
+
/**
|
|
3
|
+
* @description DisplayObjectの更新フラグを立てる
|
|
4
|
+
* Set the update flag of DisplayObject
|
|
5
|
+
*
|
|
6
|
+
* @param {DisplayObject} display_object
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: <D extends DisplayObject>(display_object: D) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description DisplayObjectの更新フラグを立てる
|
|
3
|
+
* Set the update flag of DisplayObject
|
|
4
|
+
*
|
|
5
|
+
* @param {DisplayObject} display_object
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (display_object) => {
|
|
11
|
+
display_object.changed = true;
|
|
12
|
+
const parent = display_object.parent;
|
|
13
|
+
if (parent && !parent.changed) {
|
|
14
|
+
execute(parent);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { $getBlinkingTimerId, $setBlinkingTimerId } from "../../TextUtil";
|
|
2
|
+
/**
|
|
3
|
+
* @description テキストの点滅のタイマーをクリアします。
|
|
4
|
+
* Clear the text blinking timer.
|
|
5
|
+
*
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = () => {
|
|
11
|
+
const timerId = $getBlinkingTimerId();
|
|
12
|
+
if (timerId !== undefined) {
|
|
13
|
+
clearTimeout(timerId);
|
|
14
|
+
}
|
|
15
|
+
$setBlinkingTimerId(void 0);
|
|
16
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextField } from "../../TextField";
|
|
2
|
+
/**
|
|
3
|
+
* @description 選択中のインデックスを記録します。
|
|
4
|
+
* Records the currently selected index.
|
|
5
|
+
*
|
|
6
|
+
* @param {TextField} text_field
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (text_field: TextField) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 選択中のインデックスを記録します。
|
|
3
|
+
* Records the currently selected index.
|
|
4
|
+
*
|
|
5
|
+
* @param {TextField} text_field
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = (text_field) => {
|
|
11
|
+
text_field.compositionStartIndex = text_field.focusIndex;
|
|
12
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextField } from "../../TextField";
|
|
2
|
+
/**
|
|
3
|
+
* @description コピーしたテキストをペーストします。
|
|
4
|
+
* Pastes the copied text.
|
|
5
|
+
*
|
|
6
|
+
* @param {TextField} text_field
|
|
7
|
+
* @return {void}
|
|
8
|
+
* @method
|
|
9
|
+
* @protected
|
|
10
|
+
*/
|
|
11
|
+
export declare const execute: (text_field: TextField) => Promise<void>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description コピーしたテキストをペーストします。
|
|
3
|
+
* Pastes the copied text.
|
|
4
|
+
*
|
|
5
|
+
* @param {TextField} text_field
|
|
6
|
+
* @return {void}
|
|
7
|
+
* @method
|
|
8
|
+
* @protected
|
|
9
|
+
*/
|
|
10
|
+
export const execute = async (text_field) => {
|
|
11
|
+
const text = await navigator.clipboard.readText();
|
|
12
|
+
if (text === "" || text_field.focusIndex === -1) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
text_field.insertText(text);
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TextField } from "../../TextField";
|
|
2
|
+
/**
|
|
3
|
+
* @description テキストフィールドのフォーカスインデックスを下に移動します。
|
|
4
|
+
* Moves the focus index of the text field down.
|
|
5
|
+
*
|
|
6
|
+
* @param {TextField} text_field
|
|
7
|
+
* @param {boolean} shift_key
|
|
8
|
+
* @return {void}
|
|
9
|
+
* @method
|
|
10
|
+
* @protected
|
|
11
|
+
*/
|
|
12
|
+
export declare const execute: (text_field: TextField, shift_key: boolean) => void;
|