@estiva-app/ui 0.84.0 → 0.86.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/CommentBox.d.ts +1 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/{ComposeBox.d.ts → commentBoxFrame.d.ts} +32 -13
- package/dist/commentBoxFrame.d.ts.map +1 -0
- package/dist/editor.d.ts +0 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +316 -292
- package/dist/editor.js.map +4 -4
- package/dist/eslint/index.js +594 -559
- package/dist/eslint/index.js.map +4 -4
- package/dist/eslint/no-hand-rolled-behaviour.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +150 -0
- package/dist/index.js.map +4 -4
- package/dist/linkedFrom.d.ts +83 -0
- package/dist/linkedFrom.d.ts.map +1 -0
- package/dist/looks.d.ts +1 -1
- package/package.json +1 -1
- package/registry.json +42 -128
- package/src/CommentBox.mdx +4 -3
- package/src/CommentBox.stories.tsx +3 -0
- package/src/CommentBox.test.tsx +15 -0
- package/src/CommentBox.tsx +39 -32
- package/src/LinkCard.mdx +1 -0
- package/src/{ComposeBox.tsx → commentBoxFrame.tsx} +61 -27
- package/src/editor.ts +1 -1
- package/src/eslint/no-hand-rolled-behaviour.test.ts +27 -0
- package/src/eslint/no-hand-rolled-behaviour.ts +44 -0
- package/src/index.ts +9 -0
- package/src/linkedFrom.test.tsx +193 -0
- package/src/linkedFrom.ts +286 -0
- package/src/looks.ts +1 -1
- package/src/registry/app.test.ts +3 -4
- package/src/registry/registry.test.ts +5 -5
- package/stories/Choosing.mdx +0 -1
- package/dist/ComposeBox.d.ts.map +0 -1
- package/src/ComposeBox.mdx +0 -58
- package/src/ComposeBox.stories.tsx +0 -81
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { LinkState, Linked, LinkedConversation, LinkedKind } from './linked';
|
|
2
|
+
/** A person as interop names them: a profile, possibly empty. */
|
|
3
|
+
export interface LinkedProfile {
|
|
4
|
+
displayName?: string;
|
|
5
|
+
picture?: string;
|
|
6
|
+
}
|
|
7
|
+
/** One of interop's resolved slots. */
|
|
8
|
+
export interface LinkedSlot {
|
|
9
|
+
value: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
colour?: string;
|
|
12
|
+
isPubkey?: boolean;
|
|
13
|
+
field?: string;
|
|
14
|
+
}
|
|
15
|
+
/** One of interop's resolved actions: what the file's own app lets a reader change. */
|
|
16
|
+
export interface LinkedAction {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
control: string;
|
|
20
|
+
field?: string;
|
|
21
|
+
current?: string;
|
|
22
|
+
options?: {
|
|
23
|
+
value: string;
|
|
24
|
+
label: string;
|
|
25
|
+
colour?: string;
|
|
26
|
+
}[];
|
|
27
|
+
}
|
|
28
|
+
/** The part of interop's `ForeignObject` a link is built from. */
|
|
29
|
+
export interface LinkedSource {
|
|
30
|
+
ref: string;
|
|
31
|
+
address?: string;
|
|
32
|
+
eventId?: string;
|
|
33
|
+
kind: number;
|
|
34
|
+
widget: string | string[];
|
|
35
|
+
noun?: string;
|
|
36
|
+
appName?: string;
|
|
37
|
+
slots: Record<string, LinkedSlot | undefined>;
|
|
38
|
+
meta: LinkedSlot[];
|
|
39
|
+
children?: LinkedSource[];
|
|
40
|
+
people?: Record<string, LinkedProfile>;
|
|
41
|
+
actions: LinkedAction[];
|
|
42
|
+
parentField?: string;
|
|
43
|
+
openUrl?: string;
|
|
44
|
+
unreachable?: boolean;
|
|
45
|
+
archived?: unknown;
|
|
46
|
+
/** When it last changed, in seconds (interop 0.64). */
|
|
47
|
+
changedAt?: number;
|
|
48
|
+
}
|
|
49
|
+
/** `T` is the app's own object type (interop's `ForeignObject`), so `hrefOf` takes it as it is. */
|
|
50
|
+
export interface LinkedFromOptions<T extends LinkedSource = LinkedSource> {
|
|
51
|
+
/**
|
|
52
|
+
* Where a file opens in this app: the linked file itself (`top`), or one of
|
|
53
|
+
* the rows on its card. Another app's address comes from a manifest anyone
|
|
54
|
+
* may publish, so the app keeps it to https.
|
|
55
|
+
*/
|
|
56
|
+
hrefOf: (object: T, top: boolean) => string;
|
|
57
|
+
/** A message's words for a one-line preview: marks stripped, references read as words. */
|
|
58
|
+
previewText: (body: string, people: Record<string, LinkedProfile> | undefined) => string;
|
|
59
|
+
/** The workspace's people, for the owner picker's options. */
|
|
60
|
+
directory?: Record<string, LinkedProfile>;
|
|
61
|
+
/**
|
|
62
|
+
* Changes the file from its card. Without it the values read as words
|
|
63
|
+
* (Decided 16 Oct: any reader may change a file from its card; words only in
|
|
64
|
+
* a preview and for a file that cannot be read). An archived file's read as
|
|
65
|
+
* words whatever is passed: its page is read-only.
|
|
66
|
+
*/
|
|
67
|
+
onAct?: (actionId: string, value: string) => void;
|
|
68
|
+
/** What was said about it, when the app has read that. */
|
|
69
|
+
conversation?: LinkedConversation;
|
|
70
|
+
}
|
|
71
|
+
/** The file a reference names, as the kit's chip, row and card draw it. */
|
|
72
|
+
export declare function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFromOptions<T>): Linked;
|
|
73
|
+
/**
|
|
74
|
+
* Where a reference's read stands, for the kit: `undefined` is still read,
|
|
75
|
+
* `null` an answer of nothing. `unread` is what the app knows from the address
|
|
76
|
+
* alone, for those two. Nothing, and a file the reader may not read, draw
|
|
77
|
+
* alike: "not available." (Miky, 15 Oct).
|
|
78
|
+
*/
|
|
79
|
+
export declare function linkStateFrom<T extends LinkedSource>(object: T | null | undefined, unread: {
|
|
80
|
+
kind: LinkedKind;
|
|
81
|
+
noun: string;
|
|
82
|
+
}, options: LinkedFromOptions<T>): LinkState;
|
|
83
|
+
//# sourceMappingURL=linkedFrom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linkedFrom.d.ts","sourceRoot":"","sources":["../src/linkedFrom.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS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
package/dist/looks.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export declare const MENU_TRIGGER_CLASSES = "cursor-pointer rounded-md transitio
|
|
|
53
53
|
export declare const COLLAPSIBLE_PANEL_CLASSES = "h-[var(--collapsible-panel-height)] overflow-hidden transition-[height] duration-150 ease-out motion-reduce:transition-none data-[starting-style]:h-0 data-[ending-style]:h-0";
|
|
54
54
|
/**
|
|
55
55
|
* The box a message or a comment is written in: Peek's writing box (its
|
|
56
|
-
* `looks.ts`, Katerina 24 September), moved with
|
|
56
|
+
* `looks.ts`, Katerina 24 September), moved with the comment box. Inset, a hairline,
|
|
57
57
|
* 12px in, 16px between the text and the row under it; the focus ring in Signal.
|
|
58
58
|
*/
|
|
59
59
|
export declare const WRITING_BOX_CLASSES = "relative bg-bg-inset border border-border-default rounded-lg p-3 flex flex-col gap-4 signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring";
|
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
"kind": "package",
|
|
5
5
|
"repo": "estiva-ui",
|
|
6
6
|
"package": "@estiva-app/ui",
|
|
7
|
-
"packageVersion": "0.
|
|
8
|
-
"exports":
|
|
9
|
-
"typeExports":
|
|
7
|
+
"packageVersion": "0.86.0",
|
|
8
|
+
"exports": 208,
|
|
9
|
+
"typeExports": 211,
|
|
10
10
|
"files": null
|
|
11
11
|
},
|
|
12
12
|
"storybook": {
|
|
@@ -2125,10 +2125,7 @@
|
|
|
2125
2125
|
"storyId": "primitives-commentbox--empty",
|
|
2126
2126
|
"docPage": "src/CommentBox.mdx",
|
|
2127
2127
|
"app": null,
|
|
2128
|
-
"looks": [
|
|
2129
|
-
"bg-bg-inset border border-border-default rounded-lg signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring focus-within:border-border-strong transition-colors",
|
|
2130
|
-
"bg-bg-inset border border-border-default rounded-lg signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring focus-within:border-border-strong transition-colors [&_.ProseMirror]:text-text-muted"
|
|
2131
|
-
]
|
|
2128
|
+
"looks": []
|
|
2132
2129
|
},
|
|
2133
2130
|
{
|
|
2134
2131
|
"name": "commentBoxRows",
|
|
@@ -2244,127 +2241,6 @@
|
|
|
2244
2241
|
"app": null,
|
|
2245
2242
|
"looks": []
|
|
2246
2243
|
},
|
|
2247
|
-
{
|
|
2248
|
-
"name": "COMPOSE_EDITOR_CLASSES",
|
|
2249
|
-
"repo": "estiva-ui",
|
|
2250
|
-
"kind": "helper",
|
|
2251
|
-
"importPath": "@estiva-app/ui/editor",
|
|
2252
|
-
"sourceFile": "src/ComposeBox.tsx",
|
|
2253
|
-
"purpose": "The classes the box's editor wears: rich text with no outline.",
|
|
2254
|
-
"purposeFrom": "comment",
|
|
2255
|
-
"props": [],
|
|
2256
|
-
"variants": [],
|
|
2257
|
-
"ownsBehaviours": [],
|
|
2258
|
-
"status": "stable",
|
|
2259
|
-
"migrationStage": null,
|
|
2260
|
-
"docsId": "primitives-composebox--docs",
|
|
2261
|
-
"storyId": "primitives-composebox--default",
|
|
2262
|
-
"docPage": null,
|
|
2263
|
-
"app": null,
|
|
2264
|
-
"looks": []
|
|
2265
|
-
},
|
|
2266
|
-
{
|
|
2267
|
-
"name": "ComposeBox",
|
|
2268
|
-
"repo": "estiva-ui",
|
|
2269
|
-
"kind": "component",
|
|
2270
|
-
"importPath": "@estiva-app/ui/editor",
|
|
2271
|
-
"sourceFile": "src/ComposeBox.tsx",
|
|
2272
|
-
"purpose": "The box a message, a reply or a comment is written in: the text, the selection strip over it, what is attached, the tools and Send.",
|
|
2273
|
-
"purposeFrom": "page",
|
|
2274
|
-
"props": [
|
|
2275
|
-
{
|
|
2276
|
-
"name": "editor",
|
|
2277
|
-
"takes": "Editor | null",
|
|
2278
|
-
"required": true,
|
|
2279
|
-
"note": "The app's editor, with `ComposeKeys` in its extensions and `COMPOSE_EDITOR_CLASSES` on it."
|
|
2280
|
-
},
|
|
2281
|
-
{
|
|
2282
|
-
"name": "onSend",
|
|
2283
|
-
"takes": "a handler",
|
|
2284
|
-
"required": true,
|
|
2285
|
-
"note": "Send what is written. The box empties afterwards — unless this returns `false`: nothing was sent, and the words stay."
|
|
2286
|
-
},
|
|
2287
|
-
{
|
|
2288
|
-
"name": "placeholder",
|
|
2289
|
-
"takes": "anything",
|
|
2290
|
-
"required": true,
|
|
2291
|
-
"note": "Said in the empty box: words, and a `Kbd` where a key helps (\"type / for commands\")."
|
|
2292
|
-
},
|
|
2293
|
-
{
|
|
2294
|
-
"name": "tools",
|
|
2295
|
-
"takes": "anything",
|
|
2296
|
-
"required": false,
|
|
2297
|
-
"note": "The tools under the text, left: `ToolbarButton`s (attach, highlight)."
|
|
2298
|
-
},
|
|
2299
|
-
{
|
|
2300
|
-
"name": "attachments",
|
|
2301
|
-
"takes": "anything",
|
|
2302
|
-
"required": false,
|
|
2303
|
-
"note": "What is attached, under the text: `AttachmentCard pending`s."
|
|
2304
|
-
},
|
|
2305
|
-
{
|
|
2306
|
-
"name": "ready",
|
|
2307
|
-
"takes": "true/false",
|
|
2308
|
-
"required": false,
|
|
2309
|
-
"note": "Something to send even with no words — a file ready."
|
|
2310
|
-
},
|
|
2311
|
-
{
|
|
2312
|
-
"name": "holding",
|
|
2313
|
-
"takes": "true/false",
|
|
2314
|
-
"required": false,
|
|
2315
|
-
"note": "Sending waits — a file still uploading."
|
|
2316
|
-
},
|
|
2317
|
-
{
|
|
2318
|
-
"name": "marked",
|
|
2319
|
-
"takes": "true/false",
|
|
2320
|
-
"required": false,
|
|
2321
|
-
"note": "The bar down the text's left: an urgent mention or a highlight, as Peek draws it."
|
|
2322
|
-
},
|
|
2323
|
-
{
|
|
2324
|
-
"name": "selection",
|
|
2325
|
-
"takes": "Pick<SelectionToolbarProps, 'marks' | 'link' | 'actions'>",
|
|
2326
|
-
"required": false,
|
|
2327
|
-
"note": "The selection strip's buttons: its marks, Link, and the app's own (`actions`)."
|
|
2328
|
-
},
|
|
2329
|
-
{
|
|
2330
|
-
"name": "className",
|
|
2331
|
-
"takes": "text",
|
|
2332
|
-
"required": false,
|
|
2333
|
-
"note": null
|
|
2334
|
-
}
|
|
2335
|
-
],
|
|
2336
|
-
"variants": [],
|
|
2337
|
-
"ownsBehaviours": [],
|
|
2338
|
-
"status": "stable",
|
|
2339
|
-
"migrationStage": null,
|
|
2340
|
-
"docsId": "primitives-composebox--docs",
|
|
2341
|
-
"storyId": "primitives-composebox--default",
|
|
2342
|
-
"docPage": "src/ComposeBox.mdx",
|
|
2343
|
-
"app": null,
|
|
2344
|
-
"looks": [
|
|
2345
|
-
"bg-bg-inset border border-border-default rounded-lg signal:transition-shadow signal:focus-within:border-border-focus signal:focus-within:shadow-focus-ring focus-within:border-border-strong transition-colors",
|
|
2346
|
-
"select-none font-mono text-menu font-normal tracking-wider text-text-muted"
|
|
2347
|
-
]
|
|
2348
|
-
},
|
|
2349
|
-
{
|
|
2350
|
-
"name": "ComposeKeys",
|
|
2351
|
-
"repo": "estiva-ui",
|
|
2352
|
-
"kind": "component",
|
|
2353
|
-
"importPath": "@estiva-app/ui/editor",
|
|
2354
|
-
"sourceFile": "src/ComposeBox.tsx",
|
|
2355
|
-
"purpose": "Enter sends; Shift+Enter is a new line — in a list a new item (or out of the list, on an empty one), in a quote a new line (or out of it, on an empty one).",
|
|
2356
|
-
"purposeFrom": "comment",
|
|
2357
|
-
"props": [],
|
|
2358
|
-
"variants": [],
|
|
2359
|
-
"ownsBehaviours": [],
|
|
2360
|
-
"status": "stable",
|
|
2361
|
-
"migrationStage": null,
|
|
2362
|
-
"docsId": "primitives-composebox--docs",
|
|
2363
|
-
"storyId": "primitives-composebox--default",
|
|
2364
|
-
"docPage": null,
|
|
2365
|
-
"app": null,
|
|
2366
|
-
"looks": []
|
|
2367
|
-
},
|
|
2368
2244
|
{
|
|
2369
2245
|
"name": "ConfirmDialog",
|
|
2370
2246
|
"repo": "estiva-ui",
|
|
@@ -4695,6 +4571,25 @@
|
|
|
4695
4571
|
"app": null,
|
|
4696
4572
|
"looks": []
|
|
4697
4573
|
},
|
|
4574
|
+
{
|
|
4575
|
+
"name": "linkedFrom",
|
|
4576
|
+
"repo": "estiva-ui",
|
|
4577
|
+
"kind": "helper",
|
|
4578
|
+
"importPath": "@estiva-app/ui",
|
|
4579
|
+
"sourceFile": "src/linkedFrom.ts",
|
|
4580
|
+
"purpose": "The file a reference names, as the kit's chip, row and card draw it.",
|
|
4581
|
+
"purposeFrom": "comment",
|
|
4582
|
+
"props": [],
|
|
4583
|
+
"variants": [],
|
|
4584
|
+
"ownsBehaviours": [],
|
|
4585
|
+
"status": "stable",
|
|
4586
|
+
"migrationStage": null,
|
|
4587
|
+
"docsId": null,
|
|
4588
|
+
"storyId": null,
|
|
4589
|
+
"docPage": null,
|
|
4590
|
+
"app": null,
|
|
4591
|
+
"looks": []
|
|
4592
|
+
},
|
|
4698
4593
|
{
|
|
4699
4594
|
"name": "LinkedIcon",
|
|
4700
4595
|
"repo": "estiva-ui",
|
|
@@ -4945,6 +4840,25 @@
|
|
|
4945
4840
|
"app": null,
|
|
4946
4841
|
"looks": []
|
|
4947
4842
|
},
|
|
4843
|
+
{
|
|
4844
|
+
"name": "linkStateFrom",
|
|
4845
|
+
"repo": "estiva-ui",
|
|
4846
|
+
"kind": "helper",
|
|
4847
|
+
"importPath": "@estiva-app/ui",
|
|
4848
|
+
"sourceFile": "src/linkedFrom.ts",
|
|
4849
|
+
"purpose": "Where a reference's read stands, for the kit: `undefined` is still read, `null` an answer of nothing.",
|
|
4850
|
+
"purposeFrom": "comment",
|
|
4851
|
+
"props": [],
|
|
4852
|
+
"variants": [],
|
|
4853
|
+
"ownsBehaviours": [],
|
|
4854
|
+
"status": "stable",
|
|
4855
|
+
"migrationStage": null,
|
|
4856
|
+
"docsId": null,
|
|
4857
|
+
"storyId": null,
|
|
4858
|
+
"docPage": null,
|
|
4859
|
+
"app": null,
|
|
4860
|
+
"looks": []
|
|
4861
|
+
},
|
|
4948
4862
|
{
|
|
4949
4863
|
"name": "LinkUnavailable",
|
|
4950
4864
|
"repo": "estiva-ui",
|
package/src/CommentBox.mdx
CHANGED
|
@@ -13,7 +13,7 @@ The one box every app writes a comment, a reply and a line of a conversation in:
|
|
|
13
13
|
|
|
14
14
|
- **Writing anything that is sent**, in every app: a comment, a reply, a line in a conversation. The same box writes all of them.
|
|
15
15
|
- `showsAtOnce` when the app shows a send before the relay answers: the box empties at once, and a refusal puts the words back. Without it the box holds the words, shut, until the answer.
|
|
16
|
-
- `edit` to change something already sent: the same box with Cancel and Save,
|
|
16
|
+
- `edit` to change something already sent: the same box with Cancel and Save, its keys on the left, and the same selection strip over selected words.
|
|
17
17
|
- `upload` to offer files: the paperclip, `/` → Upload, a pasted picture and a dropped file.
|
|
18
18
|
- `under` to show, while something is written, the one card it will be sent with (✕ takes it off) and the live part of each block link, drawn as the app draws them under a sent message. An edit box shows the card and no part.
|
|
19
19
|
- `closed` where nothing can be written (archived, signed out): a line saying why, in the box's place. No greyed box.
|
|
@@ -22,6 +22,8 @@ The one box every app writes a comment, a reply and a line of a conversation in:
|
|
|
22
22
|
|
|
23
23
|
<Canvas of={CommentBoxStories.Refused} />
|
|
24
24
|
|
|
25
|
+
<Canvas of={CommentBoxStories.WithAFile} />
|
|
26
|
+
|
|
25
27
|
<Canvas of={CommentBoxStories.WithAnAppsOwnRows} />
|
|
26
28
|
|
|
27
29
|
<Canvas of={CommentBoxStories.LongDraft} />
|
|
@@ -31,7 +33,6 @@ The one box every app writes a comment, a reply and a line of a conversation in:
|
|
|
31
33
|
## When not
|
|
32
34
|
|
|
33
35
|
- Writing a document in place → the editor itself, with **EditorBlockHandle** and **SelectionToolbar**. Nothing is sent.
|
|
34
|
-
- A box with nothing of this — no lists, no drafts, no files → **ComposeBox**, with the app's own editor. CommentBox is built on it.
|
|
35
36
|
- One line of plain text in a form → **TextInput** or **Textarea**.
|
|
36
37
|
|
|
37
38
|
## How
|
|
@@ -96,6 +97,6 @@ It does these by itself. Write none of them around it.
|
|
|
96
97
|
| Enter | Sends; saves an edit. With a list open, picks the row. Holds while a file is uploading or did not upload. |
|
|
97
98
|
| Ctrl/Cmd+Enter | Sends, as Enter does. |
|
|
98
99
|
| Shift+Enter | A new line; in a list, a new item. |
|
|
99
|
-
| Escape | Cancels an edit. With a list open,
|
|
100
|
+
| Escape | Cancels an edit. With a list open, or words selected under the strip, closes that first. |
|
|
100
101
|
|
|
101
102
|
<Controls />
|
|
@@ -198,6 +198,9 @@ export const EditingRefused: Story = {
|
|
|
198
198
|
play: typeInto('{Enter}'),
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
/** A file attached and ready: its card under the text, and Send can send it with no words. */
|
|
202
|
+
export const WithAFile: Story = { render: () => <Live />, play: pickAFile }
|
|
203
|
+
|
|
201
204
|
/** A file uploading: Send waits for it. */
|
|
202
205
|
export const FileUploading: Story = { render: () => <Live upload={uploads('never')} />, play: pickAFile }
|
|
203
206
|
|
package/src/CommentBox.test.tsx
CHANGED
|
@@ -169,6 +169,21 @@ describe('editing', () => {
|
|
|
169
169
|
expect(onCancel).toHaveBeenCalledTimes(1)
|
|
170
170
|
})
|
|
171
171
|
|
|
172
|
+
it('with words selected, the first Escape closes the selection strip and keeps the edit; the next cancels', async () => {
|
|
173
|
+
const onCancel = vi.fn()
|
|
174
|
+
render(<Box edit={{ body, onSave: async () => ({ accepted: true }), onCancel }} />)
|
|
175
|
+
// Selected and pressed in one act, so the box's opening focus (a frame later) cannot collapse the selection in between.
|
|
176
|
+
await act(async () => {
|
|
177
|
+
const editor = editorOf()
|
|
178
|
+
editor.commands.setTextSelection({ from: 1, to: 5 })
|
|
179
|
+
editor.view.someProp('handleKeyDown', (handle) => handle(editor.view, new KeyboardEvent('keydown', { key: 'Escape' })))
|
|
180
|
+
})
|
|
181
|
+
expect(onCancel).not.toHaveBeenCalled()
|
|
182
|
+
expect(editorOf().state.selection.empty).toBe(true)
|
|
183
|
+
await press('Escape')
|
|
184
|
+
expect(onCancel).toHaveBeenCalledTimes(1)
|
|
185
|
+
})
|
|
186
|
+
|
|
172
187
|
it('a refused save keeps the words and says it was not saved', async () => {
|
|
173
188
|
render(<Box edit={{ body, onSave: async () => ({ accepted: false, reason: 'gone' }), onCancel: () => {} }} />)
|
|
174
189
|
await press('Enter')
|
package/src/CommentBox.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fragment, useCallback, useEffect, useLayoutEffect, useRef, useState, type ComponentType, type DragEvent, type ReactNode } from 'react'
|
|
2
2
|
import { Extension, type AnyExtension, type EditorOptions } from '@tiptap/core'
|
|
3
|
-
import { Editor,
|
|
3
|
+
import { Editor, type JSONContent } from '@tiptap/react'
|
|
4
4
|
import { IconLock, IconPaperclip, IconSquareRounded } from '@tabler/icons-react'
|
|
5
5
|
import { AttachmentCard } from './AttachmentCard'
|
|
6
6
|
import { ReferenceNode, type ReferenceViewProps } from './BlockNodes'
|
|
@@ -8,7 +8,7 @@ import { Button } from './Button'
|
|
|
8
8
|
import { Card } from './Card'
|
|
9
9
|
import { CardUnder } from './CardUnder'
|
|
10
10
|
import { cn } from './cn'
|
|
11
|
-
import {
|
|
11
|
+
import { BoxFrame, ComposeKeys, COMPOSE_EDITOR_CLASSES, isEmptyDoc as isEmpty, SendBox } from './commentBoxFrame'
|
|
12
12
|
import {
|
|
13
13
|
CaptionedReference,
|
|
14
14
|
PersonMention,
|
|
@@ -27,9 +27,7 @@ import { FieldLine } from './Field'
|
|
|
27
27
|
import { FilePicker } from './FilePicker'
|
|
28
28
|
import { Kbd } from './Kbd'
|
|
29
29
|
import { BoxKit, PasteOverWords } from './links'
|
|
30
|
-
import { WRITING_BOX_CLASSES } from './looks'
|
|
31
30
|
import { PastedImages } from './PastedImages'
|
|
32
|
-
import { ScrollArea } from './ScrollArea'
|
|
33
31
|
import { KeptSelection } from './SelectionToolbar'
|
|
34
32
|
import { isSuggestionOpen } from './suggestionPopup'
|
|
35
33
|
import { ToolbarButton } from './Toolbar'
|
|
@@ -37,7 +35,7 @@ import { ToolbarButton } from './Toolbar'
|
|
|
37
35
|
/**
|
|
38
36
|
* The one box every app writes a comment, a reply and a chat line in, from the
|
|
39
37
|
* approved prototype (`concept/comments-everywhere`, Miky 17 October): the
|
|
40
|
-
*
|
|
38
|
+
* box's one frame (`commentBoxFrame`) with everything each app built around it — `@`,
|
|
41
39
|
* `!@`, `[` and `/`, the keys, drafts, files, the edit mode, sending and a
|
|
42
40
|
* refused send. An app hands over only its people, its `[` sections, its `/`
|
|
43
41
|
* Insert rows and a send that says whether the relay accepted it.
|
|
@@ -188,8 +186,8 @@ export const commentBoxRows: Readonly<Record<'file' | 'mention' | 'urgent' | 're
|
|
|
188
186
|
reference: { key: 'insert-reference', row: { label: 'Reference', shortcut: '[' }, keywords: ['[', 'Reference'], run: typeTrigger('[') },
|
|
189
187
|
}
|
|
190
188
|
|
|
191
|
-
/** Ctrl/Cmd+Enter sends as Enter does; Escape cancels an edit (an open list takes Escape first). */
|
|
192
|
-
const BoxKeys = Extension.create<{ onEscape: () => boolean }>({
|
|
189
|
+
/** Ctrl/Cmd+Enter sends as Enter does; Escape cancels an edit (an open list, or the selection strip, takes Escape first). */
|
|
190
|
+
const BoxKeys = Extension.create<{ onEscape: (editor: Editor) => boolean }>({
|
|
193
191
|
name: 'commentBoxKeys',
|
|
194
192
|
addOptions() {
|
|
195
193
|
return { onEscape: () => false }
|
|
@@ -198,7 +196,7 @@ const BoxKeys = Extension.create<{ onEscape: () => boolean }>({
|
|
|
198
196
|
return {
|
|
199
197
|
'Mod-Enter': ({ editor }) => (editor.storage as unknown as { composeKeys?: { send: (() => boolean) | null } }).composeKeys?.send?.() ?? false,
|
|
200
198
|
// Open now, with no grace: the first Escape closes a list, the next is a deliberate cancel (suggestionPopup).
|
|
201
|
-
Escape: () => (isSuggestionOpen() ? false : this.options.onEscape()),
|
|
199
|
+
Escape: ({ editor }) => (isSuggestionOpen() ? false : this.options.onEscape(editor as unknown as Editor)),
|
|
202
200
|
}
|
|
203
201
|
},
|
|
204
202
|
})
|
|
@@ -245,9 +243,16 @@ function boxExtensions(hold: BoxHold, app: BoxApp): AnyExtension[] {
|
|
|
245
243
|
KeptSelection,
|
|
246
244
|
ComposeKeys,
|
|
247
245
|
BoxKeys.configure({
|
|
248
|
-
onEscape: () => {
|
|
246
|
+
onEscape: (ed) => {
|
|
249
247
|
const editing = hold.current.edit
|
|
250
248
|
if (!editing) return false
|
|
249
|
+
// Words selected: the strip is over them, and the first Escape closes it, leaving the caret at their end.
|
|
250
|
+
// The next is the deliberate cancel, as with an open list (Katerina, 21 Oct: the edit box gets the strip).
|
|
251
|
+
const { selection } = ed.state
|
|
252
|
+
if (!selection.empty) {
|
|
253
|
+
ed.commands.setTextSelection(selection.to)
|
|
254
|
+
return true
|
|
255
|
+
}
|
|
251
256
|
editing.onCancel()
|
|
252
257
|
return true
|
|
253
258
|
},
|
|
@@ -543,7 +548,7 @@ export function CommentBox({
|
|
|
543
548
|
setRefused(null)
|
|
544
549
|
const answered = (answer: Promise<SendAnswer>) => answer.catch((): SendAnswer => ({ accepted: false, reason: 'try again in a moment' }))
|
|
545
550
|
if (showsAtOnce) {
|
|
546
|
-
// Shown at once: the box empties now (
|
|
551
|
+
// Shown at once: the box empties now (the send box clears it); a refusal puts the words back above anything written since,
|
|
547
552
|
// and what ✕ took off with them.
|
|
548
553
|
const took = removed
|
|
549
554
|
setFiles((all) => all.filter((f) => f.state !== 'ready'))
|
|
@@ -600,7 +605,7 @@ export function CommentBox({
|
|
|
600
605
|
return true
|
|
601
606
|
}
|
|
602
607
|
|
|
603
|
-
// Enter and Ctrl/Cmd+Enter save an edit; the send box wires them
|
|
608
|
+
// Enter and Ctrl/Cmd+Enter save an edit; the send box wires them itself.
|
|
604
609
|
useEffect(() => {
|
|
605
610
|
if (!editor || !edit) return
|
|
606
611
|
const storage = (editor.storage as unknown as { composeKeys?: { send: (() => boolean) | null } }).composeKeys
|
|
@@ -660,27 +665,29 @@ export function CommentBox({
|
|
|
660
665
|
if (edit) {
|
|
661
666
|
return (
|
|
662
667
|
<div className={cn('flex flex-col gap-1', className)}>
|
|
663
|
-
<
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
{
|
|
670
|
-
|
|
671
|
-
<
|
|
672
|
-
<
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
<
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
668
|
+
<BoxFrame
|
|
669
|
+
editor={editor}
|
|
670
|
+
marked={marking}
|
|
671
|
+
// The same strip as the send box: writing and editing work the same way (Katerina, 21 Oct).
|
|
672
|
+
selection={{ link: true }}
|
|
673
|
+
attachments={fileCards}
|
|
674
|
+
className={cn(sending && '[&_.ProseMirror]:text-text-muted')}
|
|
675
|
+
footer={
|
|
676
|
+
<div className="flex items-center justify-between gap-2">
|
|
677
|
+
<span className="flex items-center gap-1 text-caption text-text-muted">
|
|
678
|
+
<Kbd>Esc</Kbd> to cancel · <Kbd>Enter</Kbd> to save
|
|
679
|
+
</span>
|
|
680
|
+
<div className="flex items-center gap-2">
|
|
681
|
+
<Button variant="outlined" size="small" onClick={edit.onCancel}>
|
|
682
|
+
Cancel
|
|
683
|
+
</Button>
|
|
684
|
+
<Button variant="primary" size="small" disabled={uploading || sending} onClick={() => save.current()}>
|
|
685
|
+
Save
|
|
686
|
+
</Button>
|
|
687
|
+
</div>
|
|
681
688
|
</div>
|
|
682
|
-
|
|
683
|
-
|
|
689
|
+
}
|
|
690
|
+
/>
|
|
684
691
|
{underBox}
|
|
685
692
|
{sending && <FieldLine>Saving…</FieldLine>}
|
|
686
693
|
{refusedLine}
|
|
@@ -697,7 +704,7 @@ export function CommentBox({
|
|
|
697
704
|
|
|
698
705
|
return (
|
|
699
706
|
<div ref={root} className={cn('flex flex-col gap-1', className)} onDragOver={upload ? (e) => e.preventDefault() : undefined} onDrop={onDrop}>
|
|
700
|
-
<
|
|
707
|
+
<SendBox
|
|
701
708
|
editor={editor}
|
|
702
709
|
onSend={go}
|
|
703
710
|
placeholder={placeholder}
|
package/src/LinkCard.mdx
CHANGED
|
@@ -44,6 +44,7 @@ const linked = {
|
|
|
44
44
|
- The picker offers only the options it is given: to let the reader set nobody as the owner, include an option for it.
|
|
45
45
|
- `linked.latest` is drawn whenever it is given: pass it only to a reader who may read it.
|
|
46
46
|
- `linked.conversation.unread` only for a member of it.
|
|
47
|
+
- **From interop's projection, build it with `linkStateFrom(object, unread, options)`** (or `linkedFrom` for a read object), so every app draws one thing as one card: its key, its 7 most recently changed items, a ring over all of them, and pickers through its own actions when `options.onAct` is passed (words once it is archived). The app passes `hrefOf(object, top)`, `previewText(body, people)` and, for a link not yet read, its kind and noun.
|
|
47
48
|
|
|
48
49
|
## What it owns
|
|
49
50
|
|