@estiva-app/ui 0.101.0 → 0.102.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.
Files changed (52) hide show
  1. package/dist/AskedBlocks.d.ts +30 -0
  2. package/dist/AskedBlocks.d.ts.map +1 -0
  3. package/dist/DeletedNotice.d.ts +17 -0
  4. package/dist/DeletedNotice.d.ts.map +1 -0
  5. package/dist/DocumentEditor.d.ts +39 -6
  6. package/dist/DocumentEditor.d.ts.map +1 -1
  7. package/dist/LinkRow.d.ts +7 -10
  8. package/dist/LinkRow.d.ts.map +1 -1
  9. package/dist/NoAccessNotice.d.ts +13 -0
  10. package/dist/NoAccessNotice.d.ts.map +1 -0
  11. package/dist/PartCard.d.ts +3 -3
  12. package/dist/PartCard.d.ts.map +1 -1
  13. package/dist/editor.d.ts +1 -1
  14. package/dist/editor.d.ts.map +1 -1
  15. package/dist/editor.js +311 -8
  16. package/dist/editor.js.map +4 -4
  17. package/dist/index.d.ts +2 -0
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +113 -81
  20. package/dist/index.js.map +4 -4
  21. package/dist/linked.d.ts +2 -2
  22. package/dist/linked.d.ts.map +1 -1
  23. package/dist/linkedFrom.d.ts.map +1 -1
  24. package/package.json +1 -1
  25. package/registry.json +77 -7
  26. package/src/AskedBlocks.ts +158 -0
  27. package/src/DeletedNotice.mdx +43 -0
  28. package/src/DeletedNotice.stories.tsx +29 -0
  29. package/src/DeletedNotice.test.tsx +46 -0
  30. package/src/DeletedNotice.tsx +47 -0
  31. package/src/DocumentEditor.mdx +5 -1
  32. package/src/DocumentEditor.stories.tsx +84 -0
  33. package/src/DocumentEditor.test.tsx +188 -0
  34. package/src/DocumentEditor.tsx +294 -14
  35. package/src/LinkCard.test.tsx +4 -6
  36. package/src/LinkCard.tsx +1 -1
  37. package/src/LinkRow.mdx +1 -1
  38. package/src/LinkRow.stories.tsx +3 -3
  39. package/src/LinkRow.test.tsx +2 -2
  40. package/src/LinkRow.tsx +11 -20
  41. package/src/NoAccessNotice.mdx +40 -0
  42. package/src/NoAccessNotice.stories.tsx +17 -0
  43. package/src/NoAccessNotice.tsx +18 -0
  44. package/src/PartCard.test.tsx +2 -2
  45. package/src/PartCard.tsx +5 -4
  46. package/src/editor.ts +1 -0
  47. package/src/index.ts +2 -0
  48. package/src/linked.ts +2 -2
  49. package/src/linkedFrom.test.tsx +4 -7
  50. package/src/linkedFrom.ts +0 -2
  51. package/src/registry/registry.test.ts +4 -4
  52. package/stories/Choosing.mdx +2 -0
package/dist/linked.d.ts CHANGED
@@ -132,7 +132,7 @@ export interface LoadingShape {
132
132
  /**
133
133
  * Where a link's lookup stands. `loading` knows the kind from the address, and
134
134
  * a shape when the app remembers one; `unavailable` is not the reader's to see
135
- * ("Issue not available"), or `deleted` ("Issue deleted"), which a reader tells
135
+ * ("You can't open this issue"), or `deleted` ("Issue deleted"), which a reader tells
136
136
  * apart by a deletion naming the address (SPEC §13.6.1: deleted is not
137
137
  * not-permitted). Written as a URL, it is that URL either way (`url`).
138
138
  */
@@ -145,7 +145,7 @@ export type LinkState = {
145
145
  kind: LinkedKind;
146
146
  /** What it is, in a word: "Item". */
147
147
  noun: string;
148
- /** Where it may still open for someone who can: the app that owns it, and its address. */
148
+ /** @deprecated Not drawn since 0.102.0: someone who can't open it has nowhere to go (Miky, ALO-4's review). */
149
149
  openIn?: {
150
150
  app: string;
151
151
  href: string;
@@ -1 +1 @@
1
- {"version":3,"file":"linked.d.ts","sourceRoot":"","sources":["../src/linked.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C;;;;GAIG;AACH,eAAO,MAAM,QAAQ,kCAAuB,CAAA;AAE5C,wEAAwE;AACxE,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,CAAA;AAE3C,sEAAsE;AACtE,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG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,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EAC3E,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC5B,SAAS,CAaX"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.101.0",
3
+ "version": "0.102.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
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.101.0",
8
- "exports": 243,
9
- "typeExports": 249,
7
+ "packageVersion": "0.102.0",
8
+ "exports": 245,
9
+ "typeExports": 252,
10
10
  "files": null
11
11
  },
12
12
  "storybook": {
@@ -3316,6 +3316,44 @@
3316
3316
  "app": null,
3317
3317
  "looks": []
3318
3318
  },
3319
+ {
3320
+ "name": "DeletedNotice",
3321
+ "repo": "estiva-ui",
3322
+ "kind": "component",
3323
+ "importPath": "@estiva-app/ui",
3324
+ "sourceFile": "src/DeletedNotice.tsx",
3325
+ "purpose": "The card a link to a deleted file opens on: who deleted it and when, and Restore.",
3326
+ "purposeFrom": "page",
3327
+ "props": [
3328
+ {
3329
+ "name": "by",
3330
+ "takes": "text",
3331
+ "required": true,
3332
+ "note": "Who deleted it, in the app's words: \"You\", a name."
3333
+ },
3334
+ {
3335
+ "name": "when",
3336
+ "takes": "text",
3337
+ "required": true,
3338
+ "note": "When, in the app's words, with its day: \"Today\", \"Mon, Nov 2\"."
3339
+ },
3340
+ {
3341
+ "name": "onRestore",
3342
+ "takes": "a handler",
3343
+ "required": false,
3344
+ "note": "Bring it back; the button waits for it. Absent for someone who may not edit it: the card offers nothing."
3345
+ }
3346
+ ],
3347
+ "variants": [],
3348
+ "ownsBehaviours": [],
3349
+ "status": "stable",
3350
+ "migrationStage": null,
3351
+ "docsId": "status-feedback-deletednotice--docs",
3352
+ "storyId": "status-feedback-deletednotice--deleted",
3353
+ "docPage": "src/DeletedNotice.mdx",
3354
+ "app": null,
3355
+ "looks": []
3356
+ },
3319
3357
  {
3320
3358
  "name": "deleteTableColumn",
3321
3359
  "repo": "estiva-ui",
@@ -3579,6 +3617,12 @@
3579
3617
  "required": true,
3580
3618
  "note": "Save. Called when you leave, never while typing, with the text, its format, and the saved text this edit started from — so the app can tell whom the save names anew."
3581
3619
  },
3620
+ {
3621
+ "name": "merges",
3622
+ "takes": "true/false",
3623
+ "required": false,
3624
+ "note": "Your saves are merged with someone else's (the app merges them by blocks): a newer save arriving while you are in the editor waits with no line, and leaving saves yours merged onto it."
3625
+ },
3582
3626
  {
3583
3627
  "name": "label",
3584
3628
  "takes": "text",
@@ -6181,13 +6225,13 @@
6181
6225
  "name": "noun",
6182
6226
  "takes": "text",
6183
6227
  "required": true,
6184
- "note": "What it is, in a word: \"Issue\". Drawn as \"Issue not available\"."
6228
+ "note": "What it is, in a word: \"Issue\". Drawn as \"You can't open this issue\", or \"Issue deleted\"."
6185
6229
  },
6186
6230
  {
6187
6231
  "name": "openIn",
6188
6232
  "takes": "{ app: string; href: string }",
6189
6233
  "required": false,
6190
- "note": "Where it may still open, for someone who can: its app and address."
6234
+ "note": null
6191
6235
  },
6192
6236
  {
6193
6237
  "name": "card",
@@ -7567,6 +7611,32 @@
7567
7611
  "app": null,
7568
7612
  "looks": []
7569
7613
  },
7614
+ {
7615
+ "name": "NoAccessNotice",
7616
+ "repo": "estiva-ui",
7617
+ "kind": "component",
7618
+ "importPath": "@estiva-app/ui",
7619
+ "sourceFile": "src/NoAccessNotice.tsx",
7620
+ "purpose": "Where a link to a file you can't read opens: \"You can't open this …\", and no title.",
7621
+ "purposeFrom": "page",
7622
+ "props": [
7623
+ {
7624
+ "name": "what",
7625
+ "takes": "text",
7626
+ "required": true,
7627
+ "note": "What the link names, in the app's words: \"project\", \"page\"."
7628
+ }
7629
+ ],
7630
+ "variants": [],
7631
+ "ownsBehaviours": [],
7632
+ "status": "stable",
7633
+ "migrationStage": null,
7634
+ "docsId": "status-feedback-noaccessnotice--docs",
7635
+ "storyId": "status-feedback-noaccessnotice--page",
7636
+ "docPage": "src/NoAccessNotice.mdx",
7637
+ "app": null,
7638
+ "looks": []
7639
+ },
7570
7640
  {
7571
7641
  "name": "normalizeHref",
7572
7642
  "repo": "estiva-ui",
@@ -7785,13 +7855,13 @@
7785
7855
  "name": "noun",
7786
7856
  "takes": "text",
7787
7857
  "required": false,
7788
- "note": "What it is part of, in a word, for \"A part of this issue not available\"."
7858
+ "note": "What it is part of, in a word, for \"You can't open this issue\"."
7789
7859
  },
7790
7860
  {
7791
7861
  "name": "openIn",
7792
7862
  "takes": "{ app: string; href: string }",
7793
7863
  "required": false,
7794
- "note": "Where it may still open, for someone who can, when it is not available."
7864
+ "note": null
7795
7865
  },
7796
7866
  {
7797
7867
  "name": "children",
@@ -0,0 +1,158 @@
1
+ import { Extension, type Editor } from '@tiptap/core'
2
+ import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
3
+ import { Plugin, PluginKey } from '@tiptap/pm/state'
4
+ import { Decoration, DecorationSet } from '@tiptap/pm/view'
5
+
6
+ /** Where an asked block's card is drawn: beside its words, or under them at phone width. */
7
+ export type AskedSlot = 'beside' | 'under'
8
+
9
+ /** The blocks that ask, and where each one's card is drawn. */
10
+ interface AskedState {
11
+ ids: readonly string[]
12
+ /** The element one asked block's card is drawn into, there: the editor's, kept for as long as it asks. */
13
+ slot: ((id: string, where: AskedSlot) => HTMLElement) | null
14
+ }
15
+
16
+ const askedBlocksKey = new PluginKey<AskedState>('askedBlocks')
17
+
18
+ /**
19
+ * A block both people changed: marked by a bar in the accent colour at its edge, as long as its words and no longer,
20
+ * with the card that holds your version beside them; its words wrap beside the card, and the next block starts below
21
+ * both. At phone width the card sits under the block, outside the bar (the story `Project changes`, approved 2 November).
22
+ * The block holds the card (the editor's blocks are a flex column's), so the bar is an element of its own, as tall as
23
+ * the block's words as the plugin measures them: a widget, whose changes the editor leaves alone.
24
+ */
25
+ export const ASKED_BLOCK_CLASSES = {
26
+ block: 'relative -ml-3 pl-3',
27
+ bar: 'absolute left-0 top-0 h-full w-0.5 bg-accent-primary',
28
+ beside: 'hidden md:float-right md:ml-3 md:block md:w-64',
29
+ under: 'mt-2 block md:hidden',
30
+ } as const
31
+
32
+ const newBar = () => {
33
+ const bar = document.createElement('span')
34
+ bar.className = ASKED_BLOCK_CLASSES.bar
35
+ bar.dataset.askedBar = ''
36
+ bar.contentEditable = 'false'
37
+ return bar
38
+ }
39
+
40
+ /**
41
+ * How far down a block its words reach, to the foot of their last line, leaving out the card drawn in it; `null` when
42
+ * it has none to measure.
43
+ */
44
+ function wordsHeight(block: HTMLElement): number | null {
45
+ const top = block.getBoundingClientRect().top
46
+ let bottom: number | null = null
47
+ let glyphs = 0
48
+ const range = document.createRange()
49
+ const walker = document.createTreeWalker(block, NodeFilter.SHOW_TEXT)
50
+ for (let text = walker.nextNode(); text; text = walker.nextNode()) {
51
+ if (text.parentElement?.closest('.ProseMirror-widget')) continue
52
+ range.selectNodeContents(text)
53
+ for (const box of range.getClientRects()) {
54
+ if (box.height > 0 && (bottom === null || box.bottom > bottom)) [bottom, glyphs] = [box.bottom, box.height]
55
+ }
56
+ }
57
+ if (bottom === null) return null
58
+ // A line is taller than its letters: half the difference is below them, as half is above the first.
59
+ const line = parseFloat(getComputedStyle(block).lineHeight)
60
+ return bottom - top + (line > glyphs ? (line - glyphs) / 2 : 0)
61
+ }
62
+
63
+ /** Each asked block's bar as tall as its words; where nothing can be measured, as tall as the block. */
64
+ function measureWords(root: HTMLElement) {
65
+ for (const block of root.querySelectorAll<HTMLElement>('[data-asked-block]')) {
66
+ const bar = block.querySelector<HTMLElement>('[data-asked-bar]')
67
+ if (!bar) continue
68
+ const height = typeof document.createRange().getClientRects === 'function' ? wordsHeight(block) : null
69
+ const next = height === null ? '' : `${height}px`
70
+ if (bar.style.height !== next) bar.style.height = next
71
+ }
72
+ }
73
+
74
+ /** Each block with a `blockId` the editor holds, and where it is. */
75
+ export function blockAt(doc: ProseMirrorNode, id: string): { node: ProseMirrorNode; pos: number } | null {
76
+ let found: { node: ProseMirrorNode; pos: number } | null = null
77
+ doc.descendants((node, pos) => {
78
+ if (found) return false
79
+ if (node.attrs.blockId === id) {
80
+ found = { node, pos }
81
+ return false
82
+ }
83
+ return true
84
+ })
85
+ return found
86
+ }
87
+
88
+ /**
89
+ * The blocks a refused save asks about (`DocumentEditor`'s `DocumentAsks`), drawn as decorations so a save never
90
+ * carries them: the bar at the block's edge, and a slot at its end that the editor draws "Your version" into.
91
+ */
92
+ export const AskedBlocks = Extension.create({
93
+ name: 'askedBlocks',
94
+
95
+ addProseMirrorPlugins() {
96
+ return [
97
+ new Plugin<AskedState>({
98
+ key: askedBlocksKey,
99
+ state: {
100
+ init: () => ({ ids: [], slot: null }),
101
+ apply(tr, previous) {
102
+ return (tr.getMeta(askedBlocksKey) as AskedState | undefined) ?? previous
103
+ },
104
+ },
105
+ props: {
106
+ decorations(state) {
107
+ const { ids, slot } = askedBlocksKey.getState(state) ?? { ids: [], slot: null }
108
+ if (!slot || ids.length === 0) return null
109
+ const drawn: Decoration[] = []
110
+ for (const id of ids) {
111
+ const at = blockAt(state.doc, id)
112
+ if (!at) continue
113
+ const end = at.pos + at.node.nodeSize
114
+ drawn.push(Decoration.node(at.pos, end, { class: ASKED_BLOCK_CLASSES.block, 'data-asked-block': id }))
115
+ // The same element each time, so the card drawn into it stays as the text around it changes. Beside: first in
116
+ // the block, so its words wrap from its top; under: after the block, outside the bar.
117
+ const widget = { ignoreSelection: true, stopEvent: () => true }
118
+ const widgetAt = (pos: number, where: AskedSlot, side: number) =>
119
+ Decoration.widget(pos, () => slot(id, where), { ...widget, key: `asked-${id}-${where}`, side })
120
+ drawn.push(
121
+ Decoration.widget(at.pos + 1, newBar, { ...widget, key: `asked-${id}-bar`, side: -2 }),
122
+ widgetAt(at.pos + 1, 'beside', -1),
123
+ widgetAt(end, 'under', 1),
124
+ )
125
+ }
126
+ return drawn.length ? DecorationSet.create(state.doc, drawn) : null
127
+ },
128
+ },
129
+ // The bar's height, again whenever the text, the editor's width or a card (drawn after the block) changes it.
130
+ // Nothing is watched or measured while no block asks: typing costs what it did.
131
+ view(view) {
132
+ const measure = () => measureWords(view.dom)
133
+ const resized = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(measure)
134
+ let watched: readonly Element[] = []
135
+ return {
136
+ update() {
137
+ const asking = (askedBlocksKey.getState(view.state)?.ids.length ?? 0) > 0
138
+ const blocks = asking ? [...view.dom.querySelectorAll('[data-asked-block]')] : []
139
+ if (resized && (blocks.length !== watched.length || blocks.some((block, i) => block !== watched[i]))) {
140
+ resized.disconnect()
141
+ if (blocks.length) for (const element of [view.dom, ...blocks]) resized.observe(element)
142
+ watched = blocks
143
+ }
144
+ if (asking) measure()
145
+ },
146
+ destroy: () => resized?.disconnect(),
147
+ }
148
+ },
149
+ }),
150
+ ]
151
+ },
152
+ })
153
+
154
+ /** Draw these blocks as asking, with their cards in `slot`; none, to draw nothing. */
155
+ export function setAskedBlocks(editor: Editor, ids: readonly string[], slot: (id: string, where: AskedSlot) => HTMLElement) {
156
+ if (editor.isDestroyed) return
157
+ editor.view.dispatch(editor.state.tr.setMeta(askedBlocksKey, { ids, slot }))
158
+ }
@@ -0,0 +1,43 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './DeletedNotice.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # DeletedNotice
7
+
8
+ The card a link to a deleted file opens on: who deleted it and when, and Restore.
9
+
10
+ <Canvas of={Stories.Deleted} />
11
+
12
+ ## When
13
+
14
+ - At the top of a deleted file's page, under its title, where a link to it opens. A deleted file is gone from lists and search; a link still opens it.
15
+ - For someone who may only read it: the line alone.
16
+
17
+ <Canvas of={Stories.ReadOnly} />
18
+
19
+ ## When not
20
+
21
+ - An archived file → **ArchivedNotice**, the same card in the same words.
22
+ - A file the person cannot read at all → **NoAccessNotice**: no title, nothing about it.
23
+
24
+ ## How
25
+
26
+ ```tsx
27
+ import { DeletedNotice } from '@estiva-app/ui'
28
+
29
+ <DeletedNotice by={name} when={day} onRestore={canEdit ? restore : undefined} />
30
+ ```
31
+
32
+ - Give `when` its day, in the app's words: "Today", "Mon, Nov 2".
33
+ - Leave out `onRestore` for someone who may not edit it: the card offers nothing.
34
+
35
+ ## What it owns
36
+
37
+ | It does | So you never write | Refused when written by hand |
38
+ |---|---|---|
39
+ | Waits for Restore's answer, and ignores a second press meanwhile | a busy state | |
40
+
41
+ ## Props
42
+
43
+ <Controls />
@@ -0,0 +1,29 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { fn, userEvent, within } from 'storybook/test'
3
+ import { DeletedNotice } from './DeletedNotice'
4
+
5
+ /** What a link to a deleted file opens on. */
6
+ const meta = {
7
+ title: 'Status & feedback/DeletedNotice',
8
+ component: DeletedNotice,
9
+ parameters: { layout: 'padded' },
10
+ args: { by: 'Person two', when: 'Mon, Nov 2', onRestore: fn() },
11
+ decorators: [(Story) => <div className="max-w-xl">{Story()}</div>],
12
+ } satisfies Meta<typeof DeletedNotice>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** For someone who may edit it: who deleted it, when, and Restore. */
18
+ export const Deleted: Story = {}
19
+
20
+ /** For someone who may only read it: the line alone. */
21
+ export const ReadOnly: Story = { name: 'Read-only', args: { onRestore: undefined } }
22
+
23
+ /** Restore pressed: it waits for the answer, and a second press does nothing. */
24
+ export const Restoring: Story = {
25
+ args: { onRestore: fn(() => new Promise<void>(() => {})) },
26
+ play: async ({ canvasElement }) => {
27
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Restore' }))
28
+ },
29
+ }
@@ -0,0 +1,46 @@
1
+ // @vitest-environment jsdom
2
+ import { act } from 'react'
3
+ import { afterEach, describe, expect, it, vi } from 'vitest'
4
+ import { cleanup, fireEvent, render, screen } from '@testing-library/react'
5
+ import { DeletedNotice } from './DeletedNotice'
6
+ import { NoAccessNotice } from './NoAccessNotice'
7
+
8
+ afterEach(cleanup)
9
+
10
+ describe('DeletedNotice', () => {
11
+ it('says who deleted it and when, with Restore for someone who may edit it', async () => {
12
+ const onRestore = vi.fn()
13
+ render(<DeletedNotice by="Person two" when="Mon, Nov 2" onRestore={onRestore} />)
14
+ expect(screen.getByText('Deleted by Person two · Mon, Nov 2')).toBeTruthy()
15
+ await act(async () => {
16
+ fireEvent.click(screen.getByRole('button', { name: 'Restore' }))
17
+ })
18
+ expect(onRestore).toHaveBeenCalledTimes(1)
19
+ })
20
+
21
+ it('offers nothing to someone who may only read it', () => {
22
+ render(<DeletedNotice by="Person two" when="Mon, Nov 2" />)
23
+ expect(screen.queryByRole('button')).toBeNull()
24
+ })
25
+
26
+ it('a second press while the restore is written does nothing, and the button opens again after its answer', async () => {
27
+ let answer: () => void = () => {}
28
+ const onRestore = vi.fn(() => new Promise<void>((resolve) => (answer = resolve)))
29
+ render(<DeletedNotice by="Person two" when="Mon, Nov 2" onRestore={onRestore} />)
30
+ const button = screen.getByRole('button', { name: 'Restore' }) as HTMLButtonElement
31
+ await act(async () => {
32
+ fireEvent.click(button)
33
+ })
34
+ fireEvent.click(button)
35
+ expect(onRestore).toHaveBeenCalledTimes(1)
36
+ await act(async () => answer())
37
+ expect(button.disabled).toBe(false)
38
+ })
39
+ })
40
+
41
+ describe('NoAccessNotice', () => {
42
+ it('says the file cannot be opened, and never which one', () => {
43
+ const { container } = render(<NoAccessNotice what="item" />)
44
+ expect(container.textContent).toBe("You can't open this item")
45
+ })
46
+ })
@@ -0,0 +1,47 @@
1
+ import { useState } from 'react'
2
+ import { IconTrash } from '@tabler/icons-react'
3
+ import { Button } from './Button'
4
+ import { Card } from './Card'
5
+
6
+ export interface DeletedNoticeProps {
7
+ /** Who deleted it, in the app's words: "You", a name. */
8
+ by: string
9
+ /** When, in the app's words, with its day: "Today", "Mon, Nov 2". */
10
+ when: string
11
+ /** Bring it back; the button waits for it. Absent for someone who may not edit it: the card offers nothing. */
12
+ onRestore?: () => void | Promise<unknown>
13
+ }
14
+
15
+ /**
16
+ * What a link to a deleted file opens on: who deleted it and when, and Restore for anyone who may edit it. A deleted
17
+ * file is gone from lists and search; a link to it still opens, and this is what stops it reading as live work.
18
+ * `ArchivedNotice`'s card and words, so the two states read alike (the story `Project changes`, approved 2 November).
19
+ *
20
+ * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/every-file-is-an-artifact-the-relay-keeps-in-order.md
21
+ */
22
+ export function DeletedNotice({ by, when, onRestore }: DeletedNoticeProps) {
23
+ const [restoring, setRestoring] = useState(false)
24
+ return (
25
+ <Card fill="inset" className="flex items-start gap-3 px-4 py-3">
26
+ <IconTrash size={16} stroke={1.5} className="mt-0.5 shrink-0 text-text-muted" />
27
+ <span className="min-w-0 flex-1 text-body-2-strong text-text-primary">{`Deleted by ${by} · ${when}`}</span>
28
+ {onRestore && (
29
+ <Button
30
+ variant="outlined"
31
+ size="small"
32
+ className="shrink-0"
33
+ disabled={restoring}
34
+ onClick={() => {
35
+ // One restore at a time: a second press while the first is written would write it twice.
36
+ setRestoring(true)
37
+ void Promise.resolve()
38
+ .then(onRestore)
39
+ .finally(() => setRestoring(false))
40
+ }}
41
+ >
42
+ Restore
43
+ </Button>
44
+ )}
45
+ </Card>
46
+ )
47
+ }
@@ -72,6 +72,9 @@ const codec: DocumentCodec = {
72
72
 
73
73
  - **It speaks the editor's document.** The package does not depend on `@estiva-app/protocol`: the app hands it `codec`, which reads its saved text and writes the editor's document back. Pass `{ links: true }`, or a link on words is lost at the next save.
74
74
  - **`onCommit` answers whether it was saved**, and gets the saved text the edit started from: whom a save names anew is the difference between the two (`mentionAddsFor`). A refused or thrown save keeps the text and says so.
75
+ - **Or it answers what asks.** Where the app merges a refused save by blocks (`writeChange` in `@estiva-app/interop`), a block both people changed comes back as `asks`; answer `{ value, theirs, mine, blocks }`: `value` is theirs with every change of yours that did not clash in it and their words in each block that asks, `theirs` their saved text (the next save's `editedFrom`), `mine` what you sent. Pass `merges` too, so a newer save waits without the Load it line. Leaving before every block is chosen saves nothing and calls `onLeftUnsaved`: keep the text there if it should outlive the page. Text typed while that save was out is kept: in `value` where they did not change that block, and as your version where it asks, which a block they changed too then does.
76
+
77
+ <Canvas of={DocumentEditorStories.BlockBothChanged} />
75
78
  - **`@` writes a reference to the person**, a chip whose `uri` is their `nostr:npub…`, not a message's mention. `uriOf` answers it; someone without one is not offered. The chip carries no name: `referenceView` resolves it.
76
79
  - **`label` is required**: the editor's accessible name.
77
80
  - **Give the editor a `key` per document.** The editor and which of `[`, `@`, File, comments and markdown it has are made once, as it opens; the lists, the upload and the people are read as they are each time.
@@ -87,7 +90,8 @@ It does these by itself. Write none of them around it.
87
90
  |---|---|
88
91
  | Saving on blur, on unmount and on a checklist tick; never while typing; Escape leaves | a save button, a timer, a key handler |
89
92
  | A refused save: the text kept, and "Could not save. Your text is still here." | a toast, or putting text back |
90
- | Someone else's save: loaded while you are not in it; while you are, "*Name* saved a newer version. Load it (replaces your changes)", and leaving saves yours over theirs — the later save wins | a merge, a conflict dialog |
93
+ | Someone else's save: loaded while you are not in it; while you are, "*Name* saved a newer version. Load it (replaces your changes)", and leaving saves yours over theirs — the later save wins. With `merges`, no line: leaving saves yours to be merged | a merge, a conflict dialog |
94
+ | A block you both changed (`onCommit` answers `DocumentAsks`): their words in the text, marked at its edge, and "Your version" beside it — under it at phone width — with Use mine, Copy and Dismiss; nothing saved until each is chosen, and the last choice saves after their text. A page opened before the text changed says so above it | a conflict dialog, a diff, a draft store |
91
95
  | Your own save coming back is not someone else's | an echo filter |
92
96
  | The text held when the sign-in ends, back unsaved after the tap, and nothing saved on the way out | a draft |
93
97
  | `/` Format (with checklist, note and warning) and Insert: Table, File (opens `[`), Upload, Mention (opens `@`) | the `/` rows |
@@ -389,3 +389,87 @@ export const ReadOnly: Story = {
389
389
  export const ReadOnlyWithoutComments: Story = {
390
390
  render: () => <Workbench readOnly />,
391
391
  }
392
+
393
+ // ─── A block both people changed ───
394
+
395
+ const block = (id: string, text: string) => ({ type: 'paragraph', id, content: [{ type: 'text', text }] })
396
+ const blocks = (...content: object[]) => JSON.stringify({ type: 'doc', content })
397
+ const ASK_START = blocks(
398
+ block('k1', 'The first block. Nobody changed it, so it reads as it did.'),
399
+ block('k2', 'The second block, as it was when you both started.'),
400
+ block('k3', 'The third block, as it was when you both started.'),
401
+ )
402
+ const ASK_THEIRS = blocks(
403
+ block('k1', 'The first block. Nobody changed it, so it reads as it did.'),
404
+ block('k2', 'The second block, as the other person saved it a moment before you: their words stand in the text.'),
405
+ block('k3', 'The third block. They changed it too, but you did not, so their words simply appear.'),
406
+ )
407
+ const ASK_MINE = blocks(
408
+ block('k1', 'The first block. Nobody changed it, so it reads as it did.'),
409
+ block('k2', 'The second block, as you had it: your words, kept beside theirs until you choose.'),
410
+ block('k3', 'The third block, as it was when you both started.'),
411
+ )
412
+
413
+ /**
414
+ * The app's side: the first save is refused because the other person saved
415
+ * the second block first, and the merge asks about it; the next save goes
416
+ * through. The story saves your text as it opens, as leaving the editor would.
417
+ */
418
+ function Asking({ sinceOpened = false }: { sinceOpened?: boolean }) {
419
+ const answered = useRef(false)
420
+ const started = useRef(false)
421
+ const [said, setSaid] = useState<string | null>(null)
422
+ const onEditor = (editor: Editor | null) => {
423
+ if (!editor || started.current) return
424
+ started.current = true
425
+ setTimeout(() => {
426
+ editor.commands.setContent(codec.read(ASK_MINE, 'blocks'))
427
+ editor.view.focus()
428
+ editor.view.dom.blur()
429
+ })
430
+ }
431
+ return (
432
+ <div className="flex max-w-3xl flex-col gap-4 px-6 py-5">
433
+ <DocumentEditor
434
+ value={ASK_START}
435
+ format="blocks"
436
+ codec={codec}
437
+ label="Document"
438
+ merges
439
+ onEditor={onEditor}
440
+ onCommit={async (value) => {
441
+ if (!answered.current) {
442
+ answered.current = true
443
+ return { value: ASK_THEIRS, theirs: ASK_THEIRS, mine: ASK_MINE, blocks: ['k2'], sinceOpened }
444
+ }
445
+ setSaid(`Saved: ${savedLines(value)[1]}`)
446
+ return true
447
+ }}
448
+ />
449
+ {said && <p className="text-caption text-text-secondary">{said}</p>}
450
+ </div>
451
+ )
452
+ }
453
+
454
+ /**
455
+ * A block you both changed: their words in the text, marked at its edge;
456
+ * yours beside it with Use mine, Copy and Dismiss. Nothing is saved until you
457
+ * choose. A block only one of you changed shows nothing: their words appear.
458
+ */
459
+ export const BlockBothChanged: Story = {
460
+ name: 'A block both changed',
461
+ render: () => <Asking />,
462
+ }
463
+
464
+ /** A page opened before the text changed, and refused: the same shape, under one line. */
465
+ export const OpenedBefore: Story = {
466
+ name: 'Opened before it changed',
467
+ render: () => <Asking sinceOpened />,
468
+ }
469
+
470
+ /** At phone width your version sits under the block instead of beside it. */
471
+ export const BlockBothChangedNarrow: Story = {
472
+ name: 'A block both changed, phone width',
473
+ globals: { viewport: { value: 'mobile1', isRotated: false } },
474
+ render: () => <Asking />,
475
+ }