-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(websocket): Add
/websocket
submodule, which provides types abo…
…ut Websocket events used in Cosense
- Loading branch information
Showing
6 changed files
with
362 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./websocket/change.ts"; | ||
export * from "./websocket/event.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
import type { BasePage, LineId } from "../base.ts"; | ||
|
||
/** Changes to push to the cosense server */ | ||
export type ChangeToPush = | ||
| InsertChange | ||
| UpdateChange | ||
| DeleteChange | ||
| LinksChange | ||
| ProjectLinksChange | ||
| IconsChange | ||
| DescriptionsChange | ||
| ImageChange | ||
| FilesChange | ||
| HelpFeelsChange | ||
| InfoboxDefinitionChange | ||
| TitleChange | ||
| LinesCountChange | ||
| CharsCountChange | ||
| PinChange; | ||
|
||
/** 行を新規作成する変更 */ | ||
export interface InsertChange { | ||
/** このIDが示す行の上に挿入する | ||
* | ||
* 末尾に挿入するときは`"_end"`を指定する | ||
*/ | ||
_insert: LineId; | ||
|
||
/** 挿入する行のデータ */ | ||
lines: NewLine; | ||
} | ||
export interface NewLine { | ||
/** 新しく挿入する行のID */ | ||
id: LineId; | ||
|
||
/** 行のテキスト */ | ||
text: string; | ||
} | ||
|
||
export interface UpdateChange { | ||
_update: string; | ||
lines: Pick<ChangeLine, "text">; | ||
noTimestampUpdate?: unknown; | ||
} | ||
|
||
export interface ChangeLine { | ||
/**変更前の文字列*/ | ||
origText: string; | ||
|
||
/**変更後の文字列*/ | ||
text: string; | ||
} | ||
|
||
/** 既存の行を削除する変更 */ | ||
export interface DeleteChange { | ||
/** 削除する行のID */ | ||
_delete: LineId; | ||
|
||
/** 常に `-1` */ | ||
lines: -1; | ||
} | ||
|
||
export interface LinksChange { | ||
links: string[]; | ||
} | ||
|
||
export interface ProjectLinksChange { | ||
projectLinks: string[]; | ||
} | ||
|
||
export interface IconsChange { | ||
icons: string[]; | ||
} | ||
|
||
/** ページのサムネイル本文が変更されると発生する */ | ||
export interface DescriptionsChange { | ||
/** 新しいサムネイル本文 */ | ||
descriptions: string[]; | ||
} | ||
|
||
/** ページのサムネイルが変更されると発生する */ | ||
export interface ImageChange { | ||
/** 新しいサムネイルのURL | ||
* | ||
* サムネイルがなくなったときは`null`になる | ||
*/ | ||
image: string | null; | ||
} | ||
|
||
export interface TitleChange { | ||
title: string; | ||
} | ||
|
||
export interface FilesChange { | ||
/** Array of file IDs | ||
* | ||
* These IDs reference files that have been uploaded to the page. | ||
* Files can include images, documents, or other attachments. | ||
*/ | ||
files: string[]; | ||
} | ||
export interface HelpFeelsChange { | ||
/** Array of Helpfeel entries without the leading "? " prefix | ||
* | ||
* Helpfeel is a Scrapbox notation for creating help/documentation entries. | ||
* Example: "? How to use" becomes "How to use" in this array. | ||
* These entries are used to build the page's help documentation. | ||
*/ | ||
helpfeels: string[]; | ||
} | ||
|
||
export interface InfoboxDefinitionChange { | ||
/** Array of trimmed lines from infobox tables | ||
* | ||
* Contains lines from tables marked with either `table:infobox` or `table:cosense` | ||
*/ | ||
infoboxDefinition: string[]; | ||
} | ||
|
||
export interface LinesCountChange { | ||
linesCount: number; | ||
} | ||
|
||
export interface CharsCountChange { | ||
charsCount: number; | ||
} | ||
|
||
/** ページのピンの状態が変更されると発生する */ | ||
export interface PinChange { | ||
pin: BasePage["pin"]; | ||
} | ||
|
||
export interface DeletePageChange { | ||
deleted: true; | ||
merged?: true; | ||
} |
Oops, something went wrong.