@mlightcad/cad-simple-viewer 1.2.4 → 1.3.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/index.js +13000 -10094
- package/dist/index.umd.cjs +327 -24
- package/dist/libredwg-parser-worker.js +7267 -7238
- package/dist/mtext-renderer-worker.js +81 -41
- package/lib/app/AcApContext.js +1 -1
- package/lib/app/AcApContext.js.map +1 -1
- package/lib/app/AcApDocManager.d.ts +20 -3
- package/lib/app/AcApDocManager.d.ts.map +1 -1
- package/lib/app/AcApDocManager.js +67 -12
- package/lib/app/AcApDocManager.js.map +1 -1
- package/lib/app/AcApProgress.d.ts +133 -0
- package/lib/app/AcApProgress.d.ts.map +1 -0
- package/lib/app/AcApProgress.js +148 -0
- package/lib/app/AcApProgress.js.map +1 -0
- package/lib/app/AcApSettingManager.d.ts +42 -0
- package/lib/app/AcApSettingManager.d.ts.map +1 -1
- package/lib/app/AcApSettingManager.js +63 -0
- package/lib/app/AcApSettingManager.js.map +1 -1
- package/lib/app/index.d.ts +0 -1
- package/lib/app/index.d.ts.map +1 -1
- package/lib/app/index.js +0 -1
- package/lib/app/index.js.map +1 -1
- package/lib/command/AcApCircleCmd.d.ts +21 -0
- package/lib/command/AcApCircleCmd.d.ts.map +1 -0
- package/lib/command/AcApCircleCmd.js +115 -0
- package/lib/command/AcApCircleCmd.js.map +1 -0
- package/lib/command/AcApDimCmd.d.ts +57 -0
- package/lib/command/AcApDimCmd.d.ts.map +1 -0
- package/lib/command/AcApDimCmd.js +228 -0
- package/lib/command/AcApDimCmd.js.map +1 -0
- package/lib/command/AcApLogCmd.d.ts +13 -0
- package/lib/command/AcApLogCmd.d.ts.map +1 -0
- package/lib/command/AcApLogCmd.js +97 -0
- package/lib/command/AcApLogCmd.js.map +1 -0
- package/lib/command/AcApSysVarCmd.d.ts +15 -0
- package/lib/command/AcApSysVarCmd.d.ts.map +1 -0
- package/lib/command/AcApSysVarCmd.js +94 -0
- package/lib/command/AcApSysVarCmd.js.map +1 -0
- package/lib/command/AcApZoomCmd.js +1 -1
- package/lib/command/AcApZoomCmd.js.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.d.ts +0 -36
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -1
- package/lib/command/AcApZoomToBoxCmd.js +4 -61
- package/lib/command/AcApZoomToBoxCmd.js.map +1 -1
- package/lib/command/index.d.ts +4 -0
- package/lib/command/index.d.ts.map +1 -1
- package/lib/command/index.js +4 -0
- package/lib/command/index.js.map +1 -1
- package/lib/editor/command/AcEdCommandStack.d.ts +19 -1
- package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
- package/lib/editor/command/AcEdCommandStack.js +40 -0
- package/lib/editor/command/AcEdCommandStack.js.map +1 -1
- package/lib/editor/input/AcEdCursorManager.d.ts +14 -30
- package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -1
- package/lib/editor/input/AcEdCursorManager.js +32 -31
- package/lib/editor/input/AcEdCursorManager.js.map +1 -1
- package/lib/editor/input/AcEdPreviewJig.d.ts +103 -0
- package/lib/editor/input/AcEdPreviewJig.d.ts.map +1 -0
- package/lib/editor/input/AcEdPreviewJig.js +82 -0
- package/lib/editor/input/AcEdPreviewJig.js.map +1 -0
- package/lib/editor/input/AcEditor.d.ts +58 -11
- package/lib/editor/input/AcEditor.d.ts.map +1 -1
- package/lib/editor/input/AcEditor.js +86 -22
- package/lib/editor/input/AcEditor.js.map +1 -1
- package/lib/editor/input/handler/AcEdAngleHandler.d.ts +12 -0
- package/lib/editor/input/handler/AcEdAngleHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdAngleHandler.js +25 -0
- package/lib/editor/input/handler/AcEdAngleHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdDistanceHandler.d.ts +8 -0
- package/lib/editor/input/handler/AcEdDistanceHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdDistanceHandler.js +29 -0
- package/lib/editor/input/handler/AcEdDistanceHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdDoubleHandler.d.ts +7 -0
- package/lib/editor/input/handler/AcEdDoubleHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdDoubleHandler.js +28 -0
- package/lib/editor/input/handler/AcEdDoubleHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdInputHandler.d.ts +14 -0
- package/lib/editor/input/handler/AcEdInputHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdInputHandler.js +2 -0
- package/lib/editor/input/handler/AcEdInputHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdIntegerHandler.d.ts +11 -0
- package/lib/editor/input/handler/AcEdIntegerHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdIntegerHandler.js +44 -0
- package/lib/editor/input/handler/AcEdIntegerHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdNumericalHandler.d.ts +11 -0
- package/lib/editor/input/handler/AcEdNumericalHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdNumericalHandler.js +24 -0
- package/lib/editor/input/handler/AcEdNumericalHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdPointHandler.d.ts +16 -0
- package/lib/editor/input/handler/AcEdPointHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdPointHandler.js +19 -0
- package/lib/editor/input/handler/AcEdPointHandler.js.map +1 -0
- package/lib/editor/input/handler/AcEdStringHandler.d.ts +12 -0
- package/lib/editor/input/handler/AcEdStringHandler.d.ts.map +1 -0
- package/lib/editor/input/handler/AcEdStringHandler.js +24 -0
- package/lib/editor/input/handler/AcEdStringHandler.js.map +1 -0
- package/lib/editor/input/handler/index.d.ts +9 -0
- package/lib/editor/input/handler/index.d.ts.map +1 -0
- package/lib/editor/input/handler/index.js +9 -0
- package/lib/editor/input/handler/index.js.map +1 -0
- package/lib/editor/input/index.d.ts +4 -1
- package/lib/editor/input/index.d.ts.map +1 -1
- package/lib/editor/input/index.js +4 -1
- package/lib/editor/input/index.js.map +1 -1
- package/lib/editor/input/marker/AcEdMarker.d.ts +72 -0
- package/lib/editor/input/marker/AcEdMarker.d.ts.map +1 -0
- package/lib/editor/input/marker/AcEdMarker.js +124 -0
- package/lib/editor/input/marker/AcEdMarker.js.map +1 -0
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts +52 -0
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts.map +1 -0
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.js +91 -0
- package/lib/editor/input/marker/AcEdOSnapMarkerManager.js.map +1 -0
- package/lib/editor/input/marker/index.d.ts +3 -0
- package/lib/editor/input/marker/index.d.ts.map +1 -0
- package/lib/editor/input/marker/index.js +3 -0
- package/lib/editor/input/marker/index.js.map +1 -0
- package/lib/editor/input/prompt/AcEdKeyword.d.ts +63 -0
- package/lib/editor/input/prompt/AcEdKeyword.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdKeyword.js +120 -0
- package/lib/editor/input/prompt/AcEdKeyword.js.map +1 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts +52 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.js +103 -0
- package/lib/editor/input/prompt/AcEdKeywordCollection.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +75 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +182 -0
- package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDistanceOptions.d.ts +46 -0
- package/lib/editor/input/prompt/AcEdPromptDistanceOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDistanceOptions.js +114 -0
- package/lib/editor/input/prompt/AcEdPromptDistanceOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleOptions.d.ts +10 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleOptions.js +31 -0
- package/lib/editor/input/prompt/AcEdPromptDoubleOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerOptions.d.ts +39 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerOptions.js +84 -0
- package/lib/editor/input/prompt/AcEdPromptIntegerOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.d.ts +59 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.js +140 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalResult.d.ts +19 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalResult.js +36 -0
- package/lib/editor/input/prompt/AcEdPromptNumericalResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts +61 -0
- package/lib/editor/input/prompt/AcEdPromptOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptOptions.js +179 -0
- package/lib/editor/input/prompt/AcEdPromptOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptPointOptions.d.ts +46 -0
- package/lib/editor/input/prompt/AcEdPromptPointOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptPointOptions.js +113 -0
- package/lib/editor/input/prompt/AcEdPromptPointOptions.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptPointResult.d.ts +25 -0
- package/lib/editor/input/prompt/AcEdPromptPointResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptPointResult.js +38 -0
- package/lib/editor/input/prompt/AcEdPromptPointResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptResult.d.ts +27 -0
- package/lib/editor/input/prompt/AcEdPromptResult.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptResult.js +19 -0
- package/lib/editor/input/prompt/AcEdPromptResult.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptStatus.d.ts +22 -0
- package/lib/editor/input/prompt/AcEdPromptStatus.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptStatus.js +23 -0
- package/lib/editor/input/prompt/AcEdPromptStatus.js.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptStringOptions.d.ts +54 -0
- package/lib/editor/input/prompt/AcEdPromptStringOptions.d.ts.map +1 -0
- package/lib/editor/input/prompt/AcEdPromptStringOptions.js +124 -0
- package/lib/editor/input/prompt/AcEdPromptStringOptions.js.map +1 -0
- package/lib/editor/input/prompt/index.d.ts +11 -0
- package/lib/editor/input/prompt/index.d.ts.map +1 -0
- package/lib/editor/input/prompt/index.js +11 -0
- package/lib/editor/input/prompt/index.js.map +1 -0
- package/lib/editor/input/ui/AcEdCommandLine.d.ts +116 -0
- package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdCommandLine.js +481 -0
- package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts +151 -0
- package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInput.js +239 -0
- package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts +60 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.js +113 -0
- package/lib/editor/input/ui/AcEdFloatingInputBox.js.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts +104 -0
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +154 -0
- package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +113 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.js +2 -0
- package/lib/editor/input/ui/AcEdFloatingInputTypes.js.map +1 -0
- package/lib/editor/input/ui/AcEdInputManager.d.ts +132 -0
- package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdInputManager.js +477 -0
- package/lib/editor/input/ui/AcEdInputManager.js.map +1 -0
- package/lib/editor/input/ui/AcEdRubberBand.d.ts +66 -0
- package/lib/editor/input/ui/AcEdRubberBand.d.ts.map +1 -0
- package/lib/editor/input/ui/AcEdRubberBand.js +276 -0
- package/lib/editor/input/ui/AcEdRubberBand.js.map +1 -0
- package/lib/editor/input/ui/index.d.ts +3 -0
- package/lib/editor/input/ui/index.d.ts.map +1 -0
- package/lib/editor/input/ui/index.js +3 -0
- package/lib/editor/input/ui/index.js.map +1 -0
- package/lib/editor/view/AcEdBaseView.d.ts +54 -16
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
- package/lib/editor/view/AcEdBaseView.js +14 -11
- package/lib/editor/view/AcEdBaseView.js.map +1 -1
- package/lib/editor/view/AcEdLayerInfo.d.ts +5 -0
- package/lib/editor/view/AcEdLayerInfo.d.ts.map +1 -1
- package/lib/i18n/AcApI18n.d.ts +135 -0
- package/lib/i18n/AcApI18n.d.ts.map +1 -0
- package/lib/i18n/AcApI18n.js +208 -0
- package/lib/i18n/AcApI18n.js.map +1 -0
- package/lib/i18n/en/command.d.ts +18 -0
- package/lib/i18n/en/command.d.ts.map +1 -0
- package/lib/i18n/en/command.js +17 -0
- package/lib/i18n/en/command.js.map +1 -0
- package/lib/i18n/en/jig.d.ts +11 -0
- package/lib/i18n/en/jig.d.ts.map +1 -0
- package/lib/i18n/en/jig.js +10 -0
- package/lib/i18n/en/jig.js.map +1 -0
- package/lib/i18n/en/main.d.ts +37 -0
- package/lib/i18n/en/main.d.ts.map +1 -0
- package/lib/i18n/en/main.js +36 -0
- package/lib/i18n/en/main.js.map +1 -0
- package/lib/i18n/index.d.ts +6 -0
- package/lib/i18n/index.d.ts.map +1 -0
- package/lib/i18n/index.js +31 -0
- package/lib/i18n/index.js.map +1 -0
- package/lib/i18n/zh/command.d.ts +18 -0
- package/lib/i18n/zh/command.d.ts.map +1 -0
- package/lib/i18n/zh/command.js +17 -0
- package/lib/i18n/zh/command.js.map +1 -0
- package/lib/i18n/zh/jig.d.ts +11 -0
- package/lib/i18n/zh/jig.d.ts.map +1 -0
- package/lib/i18n/zh/jig.js +10 -0
- package/lib/i18n/zh/jig.js.map +1 -0
- package/lib/i18n/zh/main.d.ts +37 -0
- package/lib/i18n/zh/main.d.ts.map +1 -0
- package/lib/i18n/zh/main.js +36 -0
- package/lib/i18n/zh/main.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/view/AcTrLayer.d.ts +29 -5
- package/lib/view/AcTrLayer.d.ts.map +1 -1
- package/lib/view/AcTrLayer.js +44 -6
- package/lib/view/AcTrLayer.js.map +1 -1
- package/lib/view/AcTrLayout.d.ts +13 -7
- package/lib/view/AcTrLayout.d.ts.map +1 -1
- package/lib/view/AcTrLayout.js +29 -21
- package/lib/view/AcTrLayout.js.map +1 -1
- package/lib/view/AcTrScene.d.ts +22 -8
- package/lib/view/AcTrScene.d.ts.map +1 -1
- package/lib/view/AcTrScene.js +36 -9
- package/lib/view/AcTrScene.js.map +1 -1
- package/lib/view/AcTrView2d.d.ts +19 -4
- package/lib/view/AcTrView2d.d.ts.map +1 -1
- package/lib/view/AcTrView2d.js +135 -43
- package/lib/view/AcTrView2d.js.map +1 -1
- package/package.json +7 -7
- package/lib/editor/input/AcEdBaseInput.d.ts +0 -89
- package/lib/editor/input/AcEdBaseInput.d.ts.map +0 -1
- package/lib/editor/input/AcEdBaseInput.js +0 -166
- package/lib/editor/input/AcEdBaseInput.js.map +0 -1
- package/lib/editor/input/AcEdBoxSelector.d.ts +0 -108
- package/lib/editor/input/AcEdBoxSelector.d.ts.map +0 -1
- package/lib/editor/input/AcEdBoxSelector.js +0 -220
- package/lib/editor/input/AcEdBoxSelector.js.map +0 -1
- package/lib/editor/input/AcEdInputPoint.d.ts +0 -51
- package/lib/editor/input/AcEdInputPoint.d.ts.map +0 -1
- package/lib/editor/input/AcEdInputPoint.js +0 -78
- package/lib/editor/input/AcEdInputPoint.js.map +0 -1
- package/lib/editor/input/AcEdJig.d.ts +0 -180
- package/lib/editor/input/AcEdJig.d.ts.map +0 -1
- package/lib/editor/input/AcEdJig.js +0 -256
- package/lib/editor/input/AcEdJig.js.map +0 -1
- package/lib/editor/input/AcEdJigLoop.d.ts +0 -63
- package/lib/editor/input/AcEdJigLoop.d.ts.map +0 -1
- package/lib/editor/input/AcEdJigLoop.js +0 -91
- package/lib/editor/input/AcEdJigLoop.js.map +0 -1
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AcEdFloatingInputBox } from './AcEdFloatingInputBox';
|
|
2
|
+
import { AcEdFloatingInputCancelCallback, AcEdFloatingInputChangeCallback, AcEdFloatingInputCommitCallback, AcEdFloatingInputRawData, AcEdFloatingInputValidationCallback } from './AcEdFloatingInputTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Construction options for {@link AcEdFloatingInputBoxes}.
|
|
5
|
+
*/
|
|
6
|
+
export interface AcEdFloatingInputBoxesOptions<T> {
|
|
7
|
+
/**
|
|
8
|
+
* The parent element to constrain the floating input within.
|
|
9
|
+
*/
|
|
10
|
+
parent: HTMLElement;
|
|
11
|
+
/**
|
|
12
|
+
* If true, display both X and Y inputs.
|
|
13
|
+
* If false, display only X input (useful for distance, angle, etc.).
|
|
14
|
+
*
|
|
15
|
+
* Default: `true`
|
|
16
|
+
*/
|
|
17
|
+
twoInputs?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Custom validation function.
|
|
20
|
+
*/
|
|
21
|
+
validate: AcEdFloatingInputValidationCallback<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Callback invoked when user confirms valid input by pressing Enter.
|
|
24
|
+
*/
|
|
25
|
+
onCommit?: AcEdFloatingInputCommitCallback<T>;
|
|
26
|
+
/**
|
|
27
|
+
* Callback invoked on each input event after validation completes.
|
|
28
|
+
*/
|
|
29
|
+
onChange?: AcEdFloatingInputChangeCallback<T>;
|
|
30
|
+
/**
|
|
31
|
+
* Callback invoked on cancellation (Escape or hide()).
|
|
32
|
+
*/
|
|
33
|
+
onCancel?: AcEdFloatingInputCancelCallback;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Container holding one or two floating input boxes.
|
|
37
|
+
*
|
|
38
|
+
* Always contains:
|
|
39
|
+
* - X input box
|
|
40
|
+
*
|
|
41
|
+
* Contains Y input box only if `twoInputs` is true.
|
|
42
|
+
*/
|
|
43
|
+
export declare class AcEdFloatingInputBoxes<T> {
|
|
44
|
+
/** Root DOM node that contains X and optional Y input boxes */
|
|
45
|
+
readonly parent: HTMLElement;
|
|
46
|
+
/** Whether this input uses X+Y fields or X-only. @private */
|
|
47
|
+
readonly twoInputs: boolean;
|
|
48
|
+
/** Always present */
|
|
49
|
+
readonly xInput: AcEdFloatingInputBox;
|
|
50
|
+
/** Only present when twoInputs = true */
|
|
51
|
+
readonly yInput?: AcEdFloatingInputBox;
|
|
52
|
+
/**
|
|
53
|
+
* Cached bound handler for keyboard events—ensures removal works.
|
|
54
|
+
*/
|
|
55
|
+
private boundOnKeyDown;
|
|
56
|
+
/**
|
|
57
|
+
* Cached bound handler for input events—ensures removal works.
|
|
58
|
+
*/
|
|
59
|
+
private boundOnInput;
|
|
60
|
+
private onCommit?;
|
|
61
|
+
private onChange?;
|
|
62
|
+
private onCancel?;
|
|
63
|
+
private validateFn;
|
|
64
|
+
/**
|
|
65
|
+
* Constructs one instance of this class
|
|
66
|
+
* @param parent - The container element of X and Y inputs
|
|
67
|
+
* @param twoInputs - The flag whether to show Y input
|
|
68
|
+
*/
|
|
69
|
+
constructor(options: AcEdFloatingInputBoxesOptions<T>);
|
|
70
|
+
/** Returns true if user typed in ANY input box */
|
|
71
|
+
get userTyped(): boolean;
|
|
72
|
+
/** Return one flag to indicate whether one of inputs is focused. */
|
|
73
|
+
get focused(): boolean | undefined;
|
|
74
|
+
/** Focus on X input */
|
|
75
|
+
focus(): void;
|
|
76
|
+
/** Sets text value of X and Y inputs if user doesn't type value */
|
|
77
|
+
setValue(value: AcEdFloatingInputRawData): void;
|
|
78
|
+
/**
|
|
79
|
+
* Disposes the floating input widget permanently.
|
|
80
|
+
*
|
|
81
|
+
* - Removes all event listeners (keyboard, input, mouse move).
|
|
82
|
+
* - Removes the widget's DOM container from the parent.
|
|
83
|
+
* - Marks the widget as disposed; after this, it cannot be shown again.
|
|
84
|
+
*
|
|
85
|
+
* Safe to call multiple times; subsequent calls have no effect.
|
|
86
|
+
*/
|
|
87
|
+
dispose(): void;
|
|
88
|
+
/**
|
|
89
|
+
* Handles input events from X or Y fields.
|
|
90
|
+
* Triggers validation and notifies listeners through `onChange`.
|
|
91
|
+
*/
|
|
92
|
+
private handleInput;
|
|
93
|
+
/**
|
|
94
|
+
* Handles keyboard events (Enter for commit, Escape for cancel).
|
|
95
|
+
*/
|
|
96
|
+
private handleKeyDown;
|
|
97
|
+
/**
|
|
98
|
+
* Validates the input values using either:
|
|
99
|
+
* - the user-provided custom validation function, OR
|
|
100
|
+
* - the built-in numeric parser.
|
|
101
|
+
*/
|
|
102
|
+
private validate;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=AcEdFloatingInputBoxes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcEdFloatingInputBoxes.d.ts","sourceRoot":"","sources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IA8BrD,kDAAkD;IAClD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,oEAAoE;IACpE,IAAI,OAAO,wBAEV;IAED,uBAAuB;IACvB,KAAK;IAIL,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAOxC;;;;;;;;OAQG;IACH,OAAO;IAYP;;;OAGG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,aAAa;IAgCrB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;CAMjB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { AcEdFloatingInputBox } from './AcEdFloatingInputBox';
|
|
2
|
+
/**
|
|
3
|
+
* Container holding one or two floating input boxes.
|
|
4
|
+
*
|
|
5
|
+
* Always contains:
|
|
6
|
+
* - X input box
|
|
7
|
+
*
|
|
8
|
+
* Contains Y input box only if `twoInputs` is true.
|
|
9
|
+
*/
|
|
10
|
+
var AcEdFloatingInputBoxes = /** @class */ (function () {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs one instance of this class
|
|
13
|
+
* @param parent - The container element of X and Y inputs
|
|
14
|
+
* @param twoInputs - The flag whether to show Y input
|
|
15
|
+
*/
|
|
16
|
+
function AcEdFloatingInputBoxes(options) {
|
|
17
|
+
var _this = this;
|
|
18
|
+
var _a;
|
|
19
|
+
this.parent = options.parent;
|
|
20
|
+
this.twoInputs = (_a = options.twoInputs) !== null && _a !== void 0 ? _a : true;
|
|
21
|
+
// Bind events
|
|
22
|
+
this.boundOnInput = function () { return _this.handleInput(); };
|
|
23
|
+
this.boundOnKeyDown = function (e) { return _this.handleKeyDown(e); };
|
|
24
|
+
this.xInput = new AcEdFloatingInputBox(this.parent);
|
|
25
|
+
this.xInput.addEventListener('input', this.boundOnInput);
|
|
26
|
+
this.xInput.addEventListener('keydown', this.boundOnKeyDown);
|
|
27
|
+
if (this.twoInputs) {
|
|
28
|
+
this.yInput = new AcEdFloatingInputBox(this.parent);
|
|
29
|
+
this.yInput.addEventListener('input', this.boundOnInput);
|
|
30
|
+
this.yInput.addEventListener('keydown', this.boundOnKeyDown);
|
|
31
|
+
}
|
|
32
|
+
this.validateFn = options.validate;
|
|
33
|
+
this.onCommit = options.onCommit;
|
|
34
|
+
this.onChange = options.onChange;
|
|
35
|
+
this.onCancel = options.onCancel;
|
|
36
|
+
// Focus/select after mount
|
|
37
|
+
setTimeout(function () {
|
|
38
|
+
if (_this.yInput)
|
|
39
|
+
_this.yInput.select();
|
|
40
|
+
_this.xInput.focus();
|
|
41
|
+
_this.xInput.select();
|
|
42
|
+
}, 0);
|
|
43
|
+
}
|
|
44
|
+
Object.defineProperty(AcEdFloatingInputBoxes.prototype, "userTyped", {
|
|
45
|
+
/** Returns true if user typed in ANY input box */
|
|
46
|
+
get: function () {
|
|
47
|
+
var _a;
|
|
48
|
+
return this.xInput.userTyped || !!((_a = this.xInput) === null || _a === void 0 ? void 0 : _a.userTyped);
|
|
49
|
+
},
|
|
50
|
+
enumerable: false,
|
|
51
|
+
configurable: true
|
|
52
|
+
});
|
|
53
|
+
Object.defineProperty(AcEdFloatingInputBoxes.prototype, "focused", {
|
|
54
|
+
/** Return one flag to indicate whether one of inputs is focused. */
|
|
55
|
+
get: function () {
|
|
56
|
+
var _a;
|
|
57
|
+
return this.xInput.focused || ((_a = this.yInput) === null || _a === void 0 ? void 0 : _a.focused);
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
/** Focus on X input */
|
|
63
|
+
AcEdFloatingInputBoxes.prototype.focus = function () {
|
|
64
|
+
this.xInput.focus();
|
|
65
|
+
};
|
|
66
|
+
/** Sets text value of X and Y inputs if user doesn't type value */
|
|
67
|
+
AcEdFloatingInputBoxes.prototype.setValue = function (value) {
|
|
68
|
+
var _a;
|
|
69
|
+
if (!this.xInput.userTyped)
|
|
70
|
+
this.xInput.value = value.x;
|
|
71
|
+
if (this.twoInputs && this.yInput && !this.yInput.userTyped) {
|
|
72
|
+
this.yInput.value = (_a = value.y) !== null && _a !== void 0 ? _a : '';
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Disposes the floating input widget permanently.
|
|
77
|
+
*
|
|
78
|
+
* - Removes all event listeners (keyboard, input, mouse move).
|
|
79
|
+
* - Removes the widget's DOM container from the parent.
|
|
80
|
+
* - Marks the widget as disposed; after this, it cannot be shown again.
|
|
81
|
+
*
|
|
82
|
+
* Safe to call multiple times; subsequent calls have no effect.
|
|
83
|
+
*/
|
|
84
|
+
AcEdFloatingInputBoxes.prototype.dispose = function () {
|
|
85
|
+
var _a;
|
|
86
|
+
this.xInput.removeEventListener('input', this.boundOnInput);
|
|
87
|
+
this.xInput.removeEventListener('keydown', this.boundOnKeyDown);
|
|
88
|
+
this.xInput.dispose();
|
|
89
|
+
if (this.yInput) {
|
|
90
|
+
this.yInput.removeEventListener('input', this.boundOnInput);
|
|
91
|
+
this.yInput.removeEventListener('keydown', this.boundOnKeyDown);
|
|
92
|
+
(_a = this.yInput) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Handles input events from X or Y fields.
|
|
97
|
+
* Triggers validation and notifies listeners through `onChange`.
|
|
98
|
+
*/
|
|
99
|
+
AcEdFloatingInputBoxes.prototype.handleInput = function () {
|
|
100
|
+
var _a;
|
|
101
|
+
var state = this.validate();
|
|
102
|
+
(_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this, state);
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Handles keyboard events (Enter for commit, Escape for cancel).
|
|
106
|
+
*/
|
|
107
|
+
AcEdFloatingInputBoxes.prototype.handleKeyDown = function (e) {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
// Find out which input element triggers this event
|
|
110
|
+
var currentInput = this.xInput;
|
|
111
|
+
var nextInput = this.yInput;
|
|
112
|
+
if (this.yInput && this.yInput.isEventTarget(e)) {
|
|
113
|
+
currentInput = this.yInput;
|
|
114
|
+
nextInput = this.xInput;
|
|
115
|
+
}
|
|
116
|
+
if (e.key === 'Enter') {
|
|
117
|
+
var state = this.validate();
|
|
118
|
+
if (state.isValid && state.value != null) {
|
|
119
|
+
(_a = this.onCommit) === null || _a === void 0 ? void 0 : _a.call(this, state.value);
|
|
120
|
+
currentInput.markValid();
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
currentInput.markInvalid();
|
|
124
|
+
}
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
e.stopPropagation();
|
|
127
|
+
}
|
|
128
|
+
else if (e.key === 'Escape') {
|
|
129
|
+
(_b = this.onCancel) === null || _b === void 0 ? void 0 : _b.call(this);
|
|
130
|
+
e.preventDefault();
|
|
131
|
+
e.stopPropagation();
|
|
132
|
+
}
|
|
133
|
+
else if (e.key === 'Tab') {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
if (nextInput) {
|
|
136
|
+
nextInput === null || nextInput === void 0 ? void 0 : nextInput.focus();
|
|
137
|
+
nextInput === null || nextInput === void 0 ? void 0 : nextInput.select();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Validates the input values using either:
|
|
143
|
+
* - the user-provided custom validation function, OR
|
|
144
|
+
* - the built-in numeric parser.
|
|
145
|
+
*/
|
|
146
|
+
AcEdFloatingInputBoxes.prototype.validate = function () {
|
|
147
|
+
var rawX = this.xInput.value.trim();
|
|
148
|
+
var rawY = this.twoInputs && this.yInput ? this.yInput.value.trim() : undefined;
|
|
149
|
+
return this.validateFn({ x: rawX, y: rawY });
|
|
150
|
+
};
|
|
151
|
+
return AcEdFloatingInputBoxes;
|
|
152
|
+
}());
|
|
153
|
+
export { AcEdFloatingInputBoxes };
|
|
154
|
+
//# sourceMappingURL=AcEdFloatingInputBoxes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcE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
*/
|
|
4
|
+
export interface AcEdFloatingInputRawData {
|
|
5
|
+
/** Raw text value in the X input box */
|
|
6
|
+
x: string;
|
|
7
|
+
/** Raw text value in the Y input box */
|
|
8
|
+
y?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface AcEdFloatingInputDynamicValue<T> {
|
|
11
|
+
/** Parsed data value */
|
|
12
|
+
value: T;
|
|
13
|
+
/** Raw text values set to the X and Y fields in {@link AcEdFloatingInput}. */
|
|
14
|
+
raw: AcEdFloatingInputRawData;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Describes the output of a validation operation performed on the user-typed
|
|
18
|
+
* raw text values from the X and Y fields in {@link AcEdFloatingInput}.
|
|
19
|
+
*/
|
|
20
|
+
export interface AcEdFloatingInputValidationResult<T> {
|
|
21
|
+
/** Parsed data value */
|
|
22
|
+
value?: T;
|
|
23
|
+
/** Whether the validation succeeded. */
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A callback capable of validating the raw textual contents of the X and Y
|
|
28
|
+
* input fields.
|
|
29
|
+
*
|
|
30
|
+
* The caller receives two raw strings:
|
|
31
|
+
* - `x`: raw string in the X textbox
|
|
32
|
+
* - `y`: raw string in the Y textbox, or `null` if Y input is disabled
|
|
33
|
+
*
|
|
34
|
+
* The callback should parse these strings and determine whether the input set
|
|
35
|
+
* is valid. It then returns an {@link AcEdFloatingInputValidationResult}.
|
|
36
|
+
*/
|
|
37
|
+
export type AcEdFloatingInputValidationCallback<T> = (raw: AcEdFloatingInputRawData) => AcEdFloatingInputValidationResult<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Callback invoked when the user confirms input via the Enter key.
|
|
40
|
+
* Receives the parsed (and validated) X and Y values.
|
|
41
|
+
*
|
|
42
|
+
* When `twoInputs` is `false`, Y will always be `null`.
|
|
43
|
+
*/
|
|
44
|
+
export type AcEdFloatingInputCommitCallback<T> = (point: T) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Callback invoked whenever the user edits either input field.
|
|
47
|
+
*
|
|
48
|
+
* Called only after validation (custom or built-in). Useful for dynamic
|
|
49
|
+
* real-time preview, updating temporary graphics, or displaying error states.
|
|
50
|
+
*/
|
|
51
|
+
export type AcEdFloatingInputChangeCallback<T> = (state: AcEdFloatingInputValidationResult<T>) => void;
|
|
52
|
+
/**
|
|
53
|
+
* Callback invoked when input box closes due to user cancelling,
|
|
54
|
+
* typically by pressing Escape or programmatically via `hide()`.
|
|
55
|
+
*/
|
|
56
|
+
export type AcEdFloatingInputCancelCallback = () => void;
|
|
57
|
+
/**
|
|
58
|
+
* Callback invoked on mousemove to update the preview geometry.
|
|
59
|
+
*/
|
|
60
|
+
export type AcEdFloatingInputDrawPreviewCallback = (x: number, y: number) => void;
|
|
61
|
+
/**
|
|
62
|
+
* Callback used to dynamically compute input values for the floating input fields.
|
|
63
|
+
*/
|
|
64
|
+
export type AcEdFloatingInputDynamicValueCallback<T> = (x: number, y: number) => AcEdFloatingInputDynamicValue<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Construction options for {@link AcEdFloatingInput}.
|
|
67
|
+
*/
|
|
68
|
+
export interface AcEdFloatingInputOptions<T> {
|
|
69
|
+
/**
|
|
70
|
+
* Optional parent element to constrain the floating input within.
|
|
71
|
+
* If not provided, the container is added to document.body.
|
|
72
|
+
*/
|
|
73
|
+
parent?: HTMLElement;
|
|
74
|
+
/**
|
|
75
|
+
* If true, display both X and Y inputs.
|
|
76
|
+
* If false, display only X input (useful for distance, angle, etc.).
|
|
77
|
+
*
|
|
78
|
+
* Default: `true`
|
|
79
|
+
*/
|
|
80
|
+
twoInputs?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* A message or hint displayed above the input fields.
|
|
83
|
+
* Useful for describing expected input (e.g., "Specify next point").
|
|
84
|
+
*/
|
|
85
|
+
message?: string;
|
|
86
|
+
/**
|
|
87
|
+
* Custom validation function.
|
|
88
|
+
*/
|
|
89
|
+
validate: AcEdFloatingInputValidationCallback<T>;
|
|
90
|
+
/**
|
|
91
|
+
* Optional callback to dynamically compute values for X/Y inputs.
|
|
92
|
+
* Called whenever the input is empty and the mouse moves, providing
|
|
93
|
+
* context-dependent defaults for the user.
|
|
94
|
+
*/
|
|
95
|
+
getDynamicValue: AcEdFloatingInputDynamicValueCallback<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Callback invoked on mousemove to update the preview geometry.
|
|
98
|
+
*/
|
|
99
|
+
drawPreview?: AcEdFloatingInputDrawPreviewCallback;
|
|
100
|
+
/**
|
|
101
|
+
* Callback invoked when user confirms valid input by pressing Enter.
|
|
102
|
+
*/
|
|
103
|
+
onCommit?: AcEdFloatingInputCommitCallback<T>;
|
|
104
|
+
/**
|
|
105
|
+
* Callback invoked on each input event after validation completes.
|
|
106
|
+
*/
|
|
107
|
+
onChange?: AcEdFloatingInputChangeCallback<T>;
|
|
108
|
+
/**
|
|
109
|
+
* Callback invoked on cancellation (Escape or hide()).
|
|
110
|
+
*/
|
|
111
|
+
onCancel?: AcEdFloatingInputCancelCallback;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=AcEdFloatingInputTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcEdFloatingInputTypes.d.ts","sourceRoot":"","sources":["../../../../src/editor/input/ui/AcEdFloatingInputTypes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,wCAAwC;IACxC,CAAC,EAAE,MAAM,CAAA;IACT,wCAAwC;IACxC,CAAC,CAAC,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,6BAA6B,CAAC,CAAC;IAC9C,wBAAwB;IACxB,KAAK,EAAE,CAAC,CAAA;IACR,8EAA8E;IAC9E,GAAG,EAAE,wBAAwB,CAAA;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,iCAAiC,CAAC,CAAC;IAClD,wBAAwB;IACxB,KAAK,CAAC,EAAE,CAAC,CAAA;I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,CAAC,CAAA;IAE7C;;OAEG;IACH,QAAQ,CAAC,EAAE,+BAA+B,CAAA;CAC3C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcEdFloatingInputTypes.js","sourceRoot":"","sources":["../../../../src/editor/input/ui/AcEdFloatingInputTypes.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { AcGeBox2d, AcGePoint3dLike } from '@mlightcad/data-model';
|
|
2
|
+
import { AcEdBaseView } from '../../view';
|
|
3
|
+
import { AcEdPromptAngleOptions, AcEdPromptDistanceOptions, AcEdPromptIntegerOptions, AcEdPromptPointOptions, AcEdPromptStringOptions } from '../prompt';
|
|
4
|
+
/**
|
|
5
|
+
* A fully type-safe TypeScript class providing CAD-style interactive user input
|
|
6
|
+
* using floating HTML input boxes and mouse events. Supports collecting points,
|
|
7
|
+
* distances, angles, numbers, strings, and selecting a 2-point rectangular box
|
|
8
|
+
* using an HTML overlay rectangle (suitable when the main canvas is a THREE.js
|
|
9
|
+
* WebGL canvas).
|
|
10
|
+
*/
|
|
11
|
+
export declare class AcEdInputManager {
|
|
12
|
+
/** Inject styles only once */
|
|
13
|
+
private static stylesInjected;
|
|
14
|
+
/** The view associated with this input operation */
|
|
15
|
+
protected view: AcEdBaseView;
|
|
16
|
+
/** Stores last confirmed point from getPoint() or getBox() */
|
|
17
|
+
private lastPoint;
|
|
18
|
+
/** Stores last confirmed osnap point */
|
|
19
|
+
private lastOSnapPoint?;
|
|
20
|
+
/**
|
|
21
|
+
* The flag to indicate whether it is currently in an “input acquisition” mode (e.g., point
|
|
22
|
+
* selection, distance/angle prompt, string prompt, etc.),
|
|
23
|
+
*/
|
|
24
|
+
private active;
|
|
25
|
+
/**
|
|
26
|
+
* Construct the manager and attach mousemove listener used for floating input
|
|
27
|
+
* positioning and live preview updates.
|
|
28
|
+
*
|
|
29
|
+
* @param view - The view associated with the input manager
|
|
30
|
+
*/
|
|
31
|
+
constructor(view: AcEdBaseView);
|
|
32
|
+
/**
|
|
33
|
+
* The flag to indicate whether it is currently in an “input acquisition” mode (e.g., point
|
|
34
|
+
* selection, distance/angle prompt, string prompt, etc.),
|
|
35
|
+
*/
|
|
36
|
+
get isActive(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Injects minimal CSS required for the floating input and preview rectangle.
|
|
39
|
+
* Useful when you do not have a separate CSS file.
|
|
40
|
+
*/
|
|
41
|
+
private injectCSS;
|
|
42
|
+
/**
|
|
43
|
+
* Format a number for display in input box.
|
|
44
|
+
* Default: 3 decimal places for points/distance, 2 decimal places for angles.
|
|
45
|
+
* @param value The numeric value
|
|
46
|
+
* @param type Optional type: 'point' | 'distance' | 'angle'
|
|
47
|
+
*/
|
|
48
|
+
private formatNumber;
|
|
49
|
+
/**
|
|
50
|
+
* Public point input API.
|
|
51
|
+
*/
|
|
52
|
+
getPoint(options: AcEdPromptPointOptions): Promise<AcGePoint3dLike>;
|
|
53
|
+
/**
|
|
54
|
+
* Prompt the user to type a numeric value. If integerOnly is true, integers
|
|
55
|
+
* are enforced. The input is validated and the box will be marked invalid if
|
|
56
|
+
* the typed value does not conform, allowing the user to retype.
|
|
57
|
+
*/
|
|
58
|
+
private getNumberTyped;
|
|
59
|
+
/** Request a distance (number) from the user. */
|
|
60
|
+
getDistance(options: AcEdPromptDistanceOptions): Promise<number>;
|
|
61
|
+
/** Request an angle in degrees from the user. */
|
|
62
|
+
getAngle(options: AcEdPromptAngleOptions): Promise<number>;
|
|
63
|
+
/** Request a double/float from the user. */
|
|
64
|
+
getDouble(options: AcEdPromptDistanceOptions): Promise<number>;
|
|
65
|
+
/** Request an integer from the user. */
|
|
66
|
+
getInteger(options: AcEdPromptIntegerOptions): Promise<number>;
|
|
67
|
+
/**
|
|
68
|
+
* Prompt the user to type an arbitrary string. Resolved when Enter is pressed.
|
|
69
|
+
*/
|
|
70
|
+
getString(options: AcEdPromptStringOptions): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Prompt the user to specify a rectangular box by selecting two corners.
|
|
73
|
+
* Each corner may be specified by clicking on the canvas or typing "x,y".
|
|
74
|
+
* A live HTML overlay rectangle previews the box as the user moves the mouse.
|
|
75
|
+
*/
|
|
76
|
+
getBox(): Promise<AcGeBox2d>;
|
|
77
|
+
/**
|
|
78
|
+
* Shared point input logic used by getPoint() and getBox(). Accepts "x,y"
|
|
79
|
+
* typed input OR mouse click.
|
|
80
|
+
*/
|
|
81
|
+
private getPointInternal;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a Promise that will be resolved or rejected by user input.
|
|
84
|
+
*
|
|
85
|
+
* This method centralizes the lifecycle of an interactive input operation,
|
|
86
|
+
* including handling the Escape key to cancel, resolving with user-provided
|
|
87
|
+
* values, and guaranteeing cleanup of UI elements and event handlers.
|
|
88
|
+
*/
|
|
89
|
+
private makePromise;
|
|
90
|
+
/**
|
|
91
|
+
* Picks entities that intersect a hit-region centered at the specified point
|
|
92
|
+
* in world coordinates.
|
|
93
|
+
*
|
|
94
|
+
* The hit-region is defined as a square (or bounding box) centered at the
|
|
95
|
+
* input point, whose half-size is determined by the `hitRadius` parameter.
|
|
96
|
+
* Only entities whose geometry intersects this region are returned.
|
|
97
|
+
*
|
|
98
|
+
* @param point The center point of the hit-region in world coordinates.
|
|
99
|
+
* If omitted, the current cursor position is used.
|
|
100
|
+
*
|
|
101
|
+
* @param hitRadius The half-width (in world coordinate system) of the
|
|
102
|
+
* hit-region around the point. This creates a square bounding box:
|
|
103
|
+
* [point.x ± hitRadius, point.y ± hitRadius].
|
|
104
|
+
* A larger value increases the pick sensitivity. If omitted, a reasonable
|
|
105
|
+
* default is used.
|
|
106
|
+
* @returns - Returns The OSNAP point in the specified position in world coordinate system
|
|
107
|
+
* if found. Return undefined if no OSNAP point found.
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
* Gets OSNAP point of entities that intersect a hit-region centered at the
|
|
111
|
+
* specified point in world coordinates.
|
|
112
|
+
*
|
|
113
|
+
* The hit-region is defined as a square (or bounding box) centered at the
|
|
114
|
+
* input point, whose half-size is determined by the `hitRadius` parameter.
|
|
115
|
+
* Only entities whose geometry intersects this region are returned.
|
|
116
|
+
*
|
|
117
|
+
* @param point The center point of the hit-region in world coordinates.
|
|
118
|
+
* If omitted, the current cursor position is used.
|
|
119
|
+
*
|
|
120
|
+
* @param hitRadius The half-width (in pixel size) of the hit-region around
|
|
121
|
+
* the point. It will be converted on one value in the world
|
|
122
|
+
* coordinate 'wcsHitRadius' and creates a square bounding box:
|
|
123
|
+
* [point.x ± wcsHitRadius, point.y ± wcsHitRadius].
|
|
124
|
+
* A larger value increases the pick sensitivity. If omitted, a reasonable
|
|
125
|
+
* default is used.
|
|
126
|
+
*
|
|
127
|
+
* @returns An array of object IDs representing the entities that intersect
|
|
128
|
+
* the hit-region.
|
|
129
|
+
*/
|
|
130
|
+
private getOSnapPoint;
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=AcEdInputManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcEdInputManager.d.ts","sourceRoot":"","sources":["../../../../src/editor/input/ui/AcEdInputManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,EAGT,eAAe,EAChB,MAAM,uBAAuB,CAAA;AAG9B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAazC,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EAExB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,WAAW,CAAA;AASlB;;;;;;GAMG;AACH,qBAAa,gBAAgB;IAC3B,8BAA8B;IAC9B,OAAO,CAAC,MAAM,CAAC,cAAc,CAAQ;IAErC,oDAAoD;IACpD,SAAS,CAAC,IAAI,EAAE,YAAY,CAAA;IAE5B,8DAA8D;IAC9D,OAAO,CAAC,SAAS,CAA+B;IAEhD,wCAAwC;IACxC,OAAO,CAAC,cAAc,CAAC,CAAiB;IAExC;;;OAGG;IACH,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