@estiva-app/ui 0.82.0 → 0.82.1
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 +2 -1
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/DocumentEditor.d.ts +3 -3
- package/dist/DocumentEditor.d.ts.map +1 -1
- package/dist/editor.js +7 -5
- package/dist/editor.js.map +2 -2
- package/package.json +1 -1
- package/registry.json +5 -5
- package/src/CommentBox.mdx +2 -2
- package/src/CommentBox.test.tsx +7 -6
- package/src/CommentBox.tsx +3 -2
- package/src/DocumentEditor.mdx +2 -2
- package/src/DocumentEditor.test.tsx +27 -11
- package/src/DocumentEditor.tsx +12 -9
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"kind": "package",
|
|
5
5
|
"repo": "estiva-ui",
|
|
6
6
|
"package": "@estiva-app/ui",
|
|
7
|
-
"packageVersion": "0.82.
|
|
7
|
+
"packageVersion": "0.82.1",
|
|
8
8
|
"exports": 206,
|
|
9
9
|
"typeExports": 206,
|
|
10
10
|
"files": null
|
|
@@ -2124,7 +2124,7 @@
|
|
|
2124
2124
|
"kind": "helper",
|
|
2125
2125
|
"importPath": "@estiva-app/ui/editor",
|
|
2126
2126
|
"sourceFile": "src/CommentBox.tsx",
|
|
2127
|
-
"purpose": "The `/` Insert rows the kit offers. Pass the ones an app can perform, in its order, with its own after them; an edit drops
|
|
2127
|
+
"purpose": "The `/` Insert rows the kit offers. Pass the ones an app can perform, in its order, with its own after them; an edit drops Upload and Urgent itself.",
|
|
2128
2128
|
"purposeFrom": "comment",
|
|
2129
2129
|
"props": [],
|
|
2130
2130
|
"variants": [],
|
|
@@ -2812,13 +2812,13 @@
|
|
|
2812
2812
|
"name": "references",
|
|
2813
2813
|
"takes": "DocumentReferences",
|
|
2814
2814
|
"required": false,
|
|
2815
|
-
"note": "`[` and `/` →
|
|
2815
|
+
"note": "`[` and `/` → File."
|
|
2816
2816
|
},
|
|
2817
2817
|
{
|
|
2818
2818
|
"name": "mentions",
|
|
2819
2819
|
"takes": "DocumentMentions",
|
|
2820
2820
|
"required": false,
|
|
2821
|
-
"note": "
|
|
2821
|
+
"note": "`@` and `/` → Mention."
|
|
2822
2822
|
},
|
|
2823
2823
|
{
|
|
2824
2824
|
"name": "linkChips",
|
|
@@ -2830,7 +2830,7 @@
|
|
|
2830
2830
|
"name": "upload",
|
|
2831
2831
|
"takes": "a handler",
|
|
2832
2832
|
"required": false,
|
|
2833
|
-
"note": "`/` →
|
|
2833
|
+
"note": "`/` → Upload, and a pasted picture: upload one file and answer the attachment's attributes (its `imeta` fields)."
|
|
2834
2834
|
},
|
|
2835
2835
|
{
|
|
2836
2836
|
"name": "readMarkdown",
|
package/src/CommentBox.mdx
CHANGED
|
@@ -14,7 +14,7 @@ The one box every app writes a comment, a reply and a line of a conversation in:
|
|
|
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
16
|
- `edit` to change something already sent: the same box with Cancel and Save, and only its keys on the left.
|
|
17
|
-
- `upload` to offer files: the paperclip, `/` →
|
|
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.
|
|
20
20
|
|
|
@@ -56,7 +56,7 @@ const draft = composerDraft(createDraftStore(localStorage), draftKeys.thread(roo
|
|
|
56
56
|
- **It speaks the editor's document.** The text a document sends, and the document an edit or a draft opens with, are `@estiva-app/conversation`'s: `composerText`, `composerDocument`, `composerDraft`. Never write marker text here.
|
|
57
57
|
- **`send` answers.** Resolve `{ accepted: false, reason }` and the words come back with "Not sent: *reason*". A thrown send is a refusal too.
|
|
58
58
|
- **`label` is required**: the editor's accessible name.
|
|
59
|
-
- **`insert` is the app's Insert rows**, after the shared Format section: `commentBoxRows` and the app's own. An edit drops
|
|
59
|
+
- **`insert` is the app's Insert rows**, after the shared Format section: `commentBoxRows` and the app's own. An edit drops Upload and Urgent itself; with no `upload` there is no Upload (`commentBoxRows.file` is that row).
|
|
60
60
|
- **Give the box a `key` per destination.** The editor, the rows and `code` are made once, as the box opens; a new thread is a new box.
|
|
61
61
|
- A send shown at once and refused after its box went away writes the words into its draft instead.
|
|
62
62
|
- **`under.read` is the app's reading of the draft**: `@estiva-app/conversation`'s `boxReadOf(body, context)` says which file gets the card and which parts show; the app adds its own view of each. Call `under.changed`'s listener when what a link names comes back. `send`'s third argument is `{ card }`, the card still shown, which the app writes with `embedsToSend` (or `embedsToEdit` for `onSave`).
|
package/src/CommentBox.test.tsx
CHANGED
|
@@ -177,12 +177,12 @@ describe('editing', () => {
|
|
|
177
177
|
expect(editorOf().getText()).toBe('Said before')
|
|
178
178
|
})
|
|
179
179
|
|
|
180
|
-
it('/ offers no
|
|
180
|
+
it('/ offers no Upload and no Urgent in an edit', async () => {
|
|
181
181
|
render(<Box upload={async () => ({ accepted: true, value: 1 })} edit={{ body, onSave: async () => ({ accepted: true }), onCancel: () => {} }} />)
|
|
182
182
|
await type(' /')
|
|
183
183
|
const rows = within(screen.getByRole('listbox')).getAllByRole('option').map((o) => o.textContent ?? '')
|
|
184
184
|
expect(rows.some((r) => r.startsWith('Mention'))).toBe(true)
|
|
185
|
-
expect(rows.some((r) => r.startsWith('
|
|
185
|
+
expect(rows.some((r) => r.startsWith('Upload') || r.startsWith('Urgent'))).toBe(false)
|
|
186
186
|
// Closed here: the editor is destroyed on a timer, and a list it closes then would hold the next test's Enter.
|
|
187
187
|
await press('Escape')
|
|
188
188
|
})
|
|
@@ -251,21 +251,22 @@ describe('files', () => {
|
|
|
251
251
|
expect(send.mock.calls[0][1]).toEqual([])
|
|
252
252
|
})
|
|
253
253
|
|
|
254
|
-
it('an upload that arrives after the box opened offers
|
|
254
|
+
it('an upload that arrives after the box opened offers Upload in /', async () => {
|
|
255
255
|
const { rerender } = render(<Box />)
|
|
256
256
|
rerender(<Box upload={async () => ({ accepted: true, value: 1 })} />)
|
|
257
257
|
await type('/')
|
|
258
258
|
const rows = within(screen.getByRole('listbox')).getAllByRole('option').map((o) => o.textContent ?? '')
|
|
259
|
-
expect(rows.some((r) => r.startsWith('
|
|
259
|
+
expect(rows.some((r) => r.startsWith('Upload'))).toBe(true)
|
|
260
|
+
expect(rows.some((r) => r.startsWith('File'))).toBe(false)
|
|
260
261
|
await press('Escape')
|
|
261
262
|
})
|
|
262
263
|
|
|
263
|
-
it('no upload: no paperclip and no
|
|
264
|
+
it('no upload: no paperclip and no Upload row', async () => {
|
|
264
265
|
render(<Box />)
|
|
265
266
|
expect(screen.queryByRole('button', { name: 'Attach a file' })).toBeNull()
|
|
266
267
|
await type('/')
|
|
267
268
|
const rows = within(screen.getByRole('listbox')).getAllByRole('option').map((o) => o.textContent ?? '')
|
|
268
|
-
expect(rows.some((r) => r.startsWith('
|
|
269
|
+
expect(rows.some((r) => r.startsWith('Upload'))).toBe(false)
|
|
269
270
|
await press('Escape')
|
|
270
271
|
})
|
|
271
272
|
})
|
package/src/CommentBox.tsx
CHANGED
|
@@ -173,10 +173,11 @@ const askForFile = (editor: Editor) => editor.view.dom.dispatchEvent(new CustomE
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* The `/` Insert rows the kit offers. Pass the ones an app can perform, in
|
|
176
|
-
* its order, with its own after them; an edit drops
|
|
176
|
+
* its order, with its own after them; an edit drops Upload and Urgent itself.
|
|
177
|
+
* `file` is the Upload row, named as in a document's `/`.
|
|
177
178
|
*/
|
|
178
179
|
export const commentBoxRows: Readonly<Record<'file' | 'mention' | 'urgent' | 'reference', SlashCommand>> = {
|
|
179
|
-
file: { key: 'insert-file', row: { label: '
|
|
180
|
+
file: { key: 'insert-file', row: { label: 'Upload' }, keywords: ['attach', 'file', 'picture'], run: askForFile },
|
|
180
181
|
mention: { key: 'insert-mention', row: { label: 'Mention', shortcut: '@' }, keywords: ['@', 'Mention a person'], run: typeTrigger('@') },
|
|
181
182
|
urgent: { key: 'insert-urgent', row: { label: 'Urgent', shortcut: '!@' }, keywords: ['!@', 'Urgent mention'], run: typeTrigger('!@') },
|
|
182
183
|
reference: { key: 'insert-reference', row: { label: 'Reference', shortcut: '[' }, keywords: ['[', 'Reference'], run: typeTrigger('[') },
|
package/src/DocumentEditor.mdx
CHANGED
|
@@ -13,7 +13,7 @@ One document's text as one surface that is always an editor, the same in every a
|
|
|
13
13
|
|
|
14
14
|
- **Any document's text**, written where it is read: a page, a description, a panel. The same editor in every app.
|
|
15
15
|
- `references` and `mentions` for `[` and `@`, from the app's own lists. Without them, `[` and `@` are text.
|
|
16
|
-
- `upload` for `/` →
|
|
16
|
+
- `upload` for `/` → Upload and a pasted picture, uploaded before the file is placed.
|
|
17
17
|
- `onCommentOnSelection` to offer Comment on what is selected, and draw where comments are. Without it, neither.
|
|
18
18
|
- `blockRows` for the app's rows in a block's menu: Copy link, Comment on the block.
|
|
19
19
|
- `readOnly` for reading: the same drawing, nothing typed or saved. Chips open, and Comment on a selection stays where it is on.
|
|
@@ -86,7 +86,7 @@ It does these by itself. Write none of them around it.
|
|
|
86
86
|
| 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 |
|
|
87
87
|
| Your own save coming back is not someone else's | an echo filter |
|
|
88
88
|
| The text held when the sign-in ends, back unsaved after the tap, and nothing saved on the way out | a draft |
|
|
89
|
-
| `/` Format (with checklist, note and warning) and Insert: Table, File
|
|
89
|
+
| `/` Format (with checklist, note and warning) and Insert: Table, File (opens `[`), Upload, Mention (opens `@`) | the `/` rows |
|
|
90
90
|
| A URL pasted over plain words links them; typing after linked words is not linked; a link keeps the keys this version does not know | a paste handler, a link schema |
|
|
91
91
|
| A bare address drawn as a link, opened by a click, and saved as the text it is | a link decoration |
|
|
92
92
|
| Each block's id through editing, so what is anchored to it stays on it | an id plugin |
|
|
@@ -260,29 +260,45 @@ describe('[ and /', () => {
|
|
|
260
260
|
expect(screen.queryByRole('listbox')).toBeNull()
|
|
261
261
|
})
|
|
262
262
|
|
|
263
|
-
it('/ offers Format and Insert
|
|
264
|
-
render(<Doc references={references} upload={async () => ({})} />)
|
|
263
|
+
it('/ offers Format and Insert: Table, File, Upload and Mention, each when the app can do it', async () => {
|
|
264
|
+
render(<Doc references={references} mentions={mentions} upload={async () => ({})} />)
|
|
265
265
|
await type(' /')
|
|
266
|
-
// A row reads as its label and the key it is typed with.
|
|
267
|
-
|
|
266
|
+
// A row reads as its label and the key it is typed with; Insert in this order.
|
|
267
|
+
const rows = options()
|
|
268
|
+
expect(rows).toEqual(expect.arrayContaining(['Text', 'Checklist[]', 'Note']))
|
|
269
|
+
expect(rows.slice(-4)).toEqual(['Table', 'File[', 'Upload', 'Mention@'])
|
|
268
270
|
await press('Escape')
|
|
269
271
|
cleanup()
|
|
270
272
|
render(<Doc />)
|
|
271
273
|
await type(' /')
|
|
272
|
-
expect(options()).
|
|
273
|
-
expect(options()).not.toContain('Link to a file[')
|
|
274
|
-
expect(options()).toContain('Table')
|
|
274
|
+
expect(options().slice(-1)).toEqual(['Table'])
|
|
275
275
|
})
|
|
276
276
|
|
|
277
|
-
it('/ →
|
|
277
|
+
it('/ → Upload opens the file dialog, and that dialog taking focus does not save', async () => {
|
|
278
|
+
const click = vi.spyOn(HTMLInputElement.prototype, 'click').mockImplementation(() => {})
|
|
279
|
+
const onCommit = vi.fn(async () => true)
|
|
280
|
+
render(<Doc upload={async () => ({})} onCommit={onCommit} />)
|
|
281
|
+
await type(' /upload')
|
|
282
|
+
await press('Enter')
|
|
283
|
+
expect(click).toHaveBeenCalledTimes(1)
|
|
284
|
+
await leave()
|
|
285
|
+
expect(onCommit).not.toHaveBeenCalled()
|
|
286
|
+
})
|
|
287
|
+
|
|
288
|
+
it.each([
|
|
289
|
+
['File', '/file', 'Items'],
|
|
290
|
+
['Mention', '/mention', 'People'],
|
|
291
|
+
])('/ → %s opens its list', async (_row, typed, list) => {
|
|
278
292
|
vi.useFakeTimers({ toFake: ['requestAnimationFrame'] })
|
|
279
|
-
render(<Doc references={references} />)
|
|
280
|
-
await type(
|
|
293
|
+
render(<Doc references={references} mentions={mentions} />)
|
|
294
|
+
await type(` ${typed}`)
|
|
295
|
+
// The row Enter picks is the one named so, not another the word also finds.
|
|
296
|
+
expect(within(screen.getByRole('listbox', { name: 'Commands' })).getAllByRole('option')[0].textContent).toMatch(new RegExp(`^${_row}`))
|
|
281
297
|
await press('Enter')
|
|
282
298
|
await act(async () => {
|
|
283
299
|
vi.advanceTimersToNextFrame()
|
|
284
300
|
})
|
|
285
|
-
expect(screen.getByRole('listbox', { name:
|
|
301
|
+
expect(screen.getByRole('listbox', { name: list })).toBeTruthy()
|
|
286
302
|
})
|
|
287
303
|
})
|
|
288
304
|
|
package/src/DocumentEditor.tsx
CHANGED
|
@@ -102,13 +102,13 @@ export interface DocumentEditorProps {
|
|
|
102
102
|
/** Where text typed when the sign-in ends is held, under `holdKey`. */
|
|
103
103
|
hold?: HeldTyping
|
|
104
104
|
holdKey?: string
|
|
105
|
-
/** `[` and `/` →
|
|
105
|
+
/** `[` and `/` → File. */
|
|
106
106
|
references?: DocumentReferences
|
|
107
|
-
/**
|
|
107
|
+
/** `@` and `/` → Mention. */
|
|
108
108
|
mentions?: DocumentMentions
|
|
109
109
|
/** A pasted app URL drawn as the chip of what it names (`LinkChips`). */
|
|
110
110
|
linkChips?: LinkChipsOptions
|
|
111
|
-
/** `/` →
|
|
111
|
+
/** `/` → Upload, and a pasted picture: upload one file and answer the attachment's attributes (its `imeta` fields). */
|
|
112
112
|
upload?: (file: File) => Promise<Record<string, unknown>>
|
|
113
113
|
/** Plain text pasted as the blocks it spells: the app's reader of markdown, as the editor's document. */
|
|
114
114
|
readMarkdown?: (text: string) => JSONContent | undefined
|
|
@@ -369,7 +369,7 @@ export function DocumentEditor({
|
|
|
369
369
|
ReferenceMenu,
|
|
370
370
|
UnknownBlock,
|
|
371
371
|
AttachmentNode.configure({ view: attachmentView ?? null }),
|
|
372
|
-
SlashCommands.configure({ sections: slashSections({ table,
|
|
372
|
+
SlashCommands.configure({ sections: slashSections({ table, upload: !!upload, pickFile }) }),
|
|
373
373
|
...(references
|
|
374
374
|
? [
|
|
375
375
|
ReferenceTrigger.configure({
|
|
@@ -554,15 +554,18 @@ export function DocumentEditor({
|
|
|
554
554
|
|
|
555
555
|
/**
|
|
556
556
|
* `/`: the shared Format section with a document's checklist and callouts,
|
|
557
|
-
* then Insert with what this editor can do.
|
|
558
|
-
*
|
|
557
|
+
* then Insert with what this editor can do. File and Mention type `[` and `@`,
|
|
558
|
+
* so their lists open; Upload picks a file from the computer (Miky, 15 October
|
|
559
|
+
* QA and 20 October at the Storybook: "File" for `[`, a Mention row, "Upload").
|
|
559
560
|
*/
|
|
560
|
-
function slashSections({ table,
|
|
561
|
+
function slashSections({ table, upload, pickFile }: { table: boolean; upload: boolean; pickFile: { current: () => void } }): SlashSection[] {
|
|
561
562
|
const insert: SlashCommand[] = [
|
|
562
563
|
// Three by three with a header row, as every app's Insert → Table makes it.
|
|
563
564
|
...(table ? [{ key: 'insert-table', row: { label: 'Table' }, run: (editor: Editor) => void editor.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run() }] : []),
|
|
564
|
-
|
|
565
|
-
|
|
565
|
+
// Offered only where the editor has the list the row opens.
|
|
566
|
+
{ key: 'insert-link', row: { label: 'File', shortcut: '[' }, keywords: ['[', 'link', 'reference'], needs: ['referenceTrigger'], run: typeTrigger('[') },
|
|
567
|
+
...(upload ? [{ key: 'insert-upload', row: { label: 'Upload' }, keywords: ['attach', 'file', 'picture'], run: () => pickFile.current() }] : []),
|
|
568
|
+
{ key: 'insert-mention', row: { label: 'Mention', shortcut: '@' }, keywords: ['@', 'person', 'people'], needs: ['personReference'], run: typeTrigger('@') },
|
|
566
569
|
]
|
|
567
570
|
return [formatSection('block'), ...(insert.length > 0 ? [{ label: 'Insert', commands: insert }] : [])]
|
|
568
571
|
}
|