Skip to content

Commit 6c8bf79

Browse files
committed
♻️ eventの型を厳密にした
1 parent 7bc02f6 commit 6c8bf79

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

browser/dom/cursor.d.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ export interface SetPositionOptions {
1616
*
1717
* コード内だと、"mouse"が指定されていた場合があった。詳細は不明
1818
*/
19-
source?: string;
19+
source?: "mouse";
2020
}
2121

2222
/** カーソル操作クラス */
23-
export declare class Cursor extends BaseStore {
23+
export declare class Cursor extends BaseStore<
24+
{ source: "mouse" | undefined } | "focusTextInput" | "scroll" | undefined
25+
> {
2426
constructor();
2527

2628
/** カーソルの位置を初期化し、editorからカーソルを外す */
@@ -44,7 +46,10 @@ export declare class Cursor extends BaseStore {
4446
/** popup menuを消す */
4547
hidePopupMenu(): void;
4648

47-
/** #text-inputにカーソルをfocusし、同時にカーソルを表示する */
49+
/** #text-inputにカーソルをfocusし、同時にカーソルを表示する
50+
*
51+
* このとき、`event: "focusTextInput"`が発行される
52+
*/
4853
focus(): void;
4954

5055
/** #text-inputからfocusを外す。カーソルの表示状態は変えない */
@@ -143,8 +148,11 @@ export declare class Cursor extends BaseStore {
143148
private sync(): void;
144149
private syncNow(): void;
145150
private updateTemporalHorizontalPoint(): number;
151+
/** scrollされたときに発火される
152+
*
153+
* このとき`event: "source"`が発行される
154+
*/
146155
private emitScroll(): void;
147-
emitChange(event: string): void;
148156

149157
private data: Position;
150158
private temporalHorizontalPoint: number;

browser/dom/selection.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface Range {
1010
end: Position;
1111
}
1212

13-
export declare class Selection extends BaseStore {
13+
export declare class Selection extends BaseStore<undefined> {
1414
constructor();
1515

1616
/** 現在のページ本文を取得する */

deps/scrapbox.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export type {
22
BaseLine,
33
Line,
44
Scrapbox,
5-
} from "https://raw.githubusercontent.com/scrapbox-jp/types/0.3.8/userscript.ts";
5+
} from "https://raw.githubusercontent.com/scrapbox-jp/types/0.4.2/userscript.ts";
66
export type {
77
BaseStore,
8-
} from "https://raw.githubusercontent.com/scrapbox-jp/types/0.3.8/baseStore.ts";
8+
} from "https://raw.githubusercontent.com/scrapbox-jp/types/0.4.2/baseStore.ts";
99
export * from "https://esm.sh/@progfay/[email protected]";

0 commit comments

Comments
 (0)