Skip to content

♻️ SelectionCursorの型定義をより厳密にした #114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions browser/dom/cursor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
/// <reference lib="esnext"/>
/// <reference lib="dom" />

import { BaseStore } from "../../deps/scrapbox.ts";
import { BaseLine, BaseStore } from "../../deps/scrapbox.ts";
import { Position } from "./position.ts";
import { Page } from "./page.d.ts";

export interface SetPositionOptions {
/** カーソルが画面外に移動したとき、カーソルが見える位置までページをスクロールするかどうか
Expand All @@ -16,13 +17,17 @@ export interface SetPositionOptions {
*
* コード内だと、"mouse"が指定されていた場合があった。詳細は不明
*/
source?: string;
source?: "mouse";
}

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

public startedWithTouch: boolean;

/** カーソルの位置を初期化し、editorからカーソルを外す */
clear(): void;

Expand All @@ -44,9 +49,18 @@ export declare class Cursor extends BaseStore {
/** popup menuを消す */
hidePopupMenu(): void;

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

/** #text-inputにfocusがあたっているか返す
*
* `this.focusTextarea`と同値
*/
get hasFocus(): boolean;

/** #text-inputからfocusを外す。カーソルの表示状態は変えない */
blur(): void;

Expand Down Expand Up @@ -108,11 +122,11 @@ export declare class Cursor extends BaseStore {
| "go-pageup",
): void;

/* `scrapbox.Page.lines`とほぼ同じ */
get lines(): unknown[];
/** 現在のページ本文を取得する */
get lines(): BaseLine[];

/* `scrapbox.Project.pages`とほぼ同じ */
get pages(): unknown;
/** 現在のページデータを取得する */
get page(): Page;

private goUp(): void;
private goPageUp(): void;
Expand Down Expand Up @@ -143,8 +157,11 @@ export declare class Cursor extends BaseStore {
private sync(): void;
private syncNow(): void;
private updateTemporalHorizontalPoint(): number;
/** scrollされたときに発火される
*
* このとき`event: "source"`が発行される
*/
private emitScroll(): void;
emitChange(event: string): void;

private data: Position;
private temporalHorizontalPoint: number;
Expand Down
Loading