22/// <reference lib="esnext"/>
33/// <reference lib="dom" />
44
5- import { BaseStore } from "../../deps/scrapbox.ts" ;
5+ import { BaseLine , BaseStore } from "../../deps/scrapbox.ts" ;
66import { Position } from "./position.ts" ;
7+ import { Page } from "./page.d.ts" ;
78
89export interface SetPositionOptions {
910 /** カーソルが画面外に移動したとき、カーソルが見える位置までページをスクロールするかどうか
@@ -16,13 +17,17 @@ export interface SetPositionOptions {
1617 *
1718 * コード内だと、"mouse"が指定されていた場合があった。詳細は不明
1819 */
19- source ?: string ;
20+ source ?: "mouse" ;
2021}
2122
2223/** カーソル操作クラス */
23- export declare class Cursor extends BaseStore {
24+ export declare class Cursor extends BaseStore <
25+ { source : "mouse" | undefined } | "focusTextInput" | "scroll" | undefined
26+ > {
2427 constructor ( ) ;
2528
29+ public startedWithTouch : boolean ;
30+
2631 /** カーソルの位置を初期化し、editorからカーソルを外す */
2732 clear ( ) : void ;
2833
@@ -44,9 +49,18 @@ export declare class Cursor extends BaseStore {
4449 /** popup menuを消す */
4550 hidePopupMenu ( ) : void ;
4651
47- /** #text-inputにカーソルをfocusし、同時にカーソルを表示する */
52+ /** #text-inputにカーソルをfocusし、同時にカーソルを表示する
53+ *
54+ * このとき、`event: "focusTextInput"`が発行される
55+ */
4856 focus ( ) : void ;
4957
58+ /** #text-inputにfocusがあたっているか返す
59+ *
60+ * `this.focusTextarea`と同値
61+ */
62+ get hasFocus ( ) : boolean ;
63+
5064 /** #text-inputからfocusを外す。カーソルの表示状態は変えない */
5165 blur ( ) : void ;
5266
@@ -108,11 +122,11 @@ export declare class Cursor extends BaseStore {
108122 | "go-pageup" ,
109123 ) : void ;
110124
111- /* `scrapbox.Page.lines`とほぼ同じ */
112- get lines ( ) : unknown [ ] ;
125+ /** 現在のページ本文を取得する */
126+ get lines ( ) : BaseLine [ ] ;
113127
114- /* `scrapbox.Project.pages`とほぼ同じ */
115- get pages ( ) : unknown ;
128+ /** 現在のページデータを取得する */
129+ get page ( ) : Page ;
116130
117131 private goUp ( ) : void ;
118132 private goPageUp ( ) : void ;
@@ -143,8 +157,11 @@ export declare class Cursor extends BaseStore {
143157 private sync ( ) : void ;
144158 private syncNow ( ) : void ;
145159 private updateTemporalHorizontalPoint ( ) : number ;
160+ /** scrollされたときに発火される
161+ *
162+ * このとき`event: "source"`が発行される
163+ */
146164 private emitScroll ( ) : void ;
147- emitChange ( event : string ) : void ;
148165
149166 private data : Position ;
150167 private temporalHorizontalPoint : number ;
0 commit comments