@estiva-app/ui 0.91.1 → 0.92.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/AppProvider.d.ts +7 -3
- package/dist/AppProvider.d.ts.map +1 -1
- package/dist/AttachedCard.d.ts +5 -1
- package/dist/AttachedCard.d.ts.map +1 -1
- package/dist/BlockNodes.d.ts +14 -1
- package/dist/BlockNodes.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +9 -2
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ComposerTriggers.d.ts +11 -2
- package/dist/ComposerTriggers.d.ts.map +1 -1
- package/dist/DocumentEditor.d.ts.map +1 -1
- package/dist/LinkCard.d.ts.map +1 -1
- package/dist/LinkChip.d.ts.map +1 -1
- package/dist/LinkChips.d.ts +2 -1
- package/dist/LinkChips.d.ts.map +1 -1
- package/dist/LinkParts.d.ts +6 -1
- package/dist/LinkParts.d.ts.map +1 -1
- package/dist/LinkPlaces.d.ts +7 -0
- package/dist/LinkPlaces.d.ts.map +1 -1
- package/dist/LinkRow.d.ts +29 -6
- package/dist/LinkRow.d.ts.map +1 -1
- package/dist/PartCard.d.ts +9 -2
- package/dist/PartCard.d.ts.map +1 -1
- package/dist/ReferenceCards.d.ts +9 -39
- package/dist/ReferenceCards.d.ts.map +1 -1
- package/dist/ReferenceMenu.d.ts.map +1 -1
- package/dist/Select.d.ts +7 -1
- package/dist/Select.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +204 -183
- package/dist/editor.js.map +3 -3
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/index.js.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +172 -52
- package/dist/index.js.map +3 -3
- package/dist/linked.d.ts +48 -3
- package/dist/linked.d.ts.map +1 -1
- package/dist/linked.examples.d.ts +6 -0
- package/dist/linked.examples.d.ts.map +1 -1
- package/dist/linkedFrom.d.ts +7 -3
- package/dist/linkedFrom.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +78 -65
- package/src/AppProvider.mdx +7 -5
- package/src/AppProvider.test.tsx +15 -1
- package/src/AppProvider.tsx +13 -4
- package/src/AttachedCard.mdx +2 -1
- package/src/AttachedCard.test.tsx +28 -0
- package/src/AttachedCard.tsx +12 -2
- package/src/BlockNodes.mdx +8 -1
- package/src/BlockNodes.tsx +98 -11
- package/src/CommentBox.mdx +8 -2
- package/src/CommentBox.stories.tsx +28 -1
- package/src/CommentBox.test.tsx +64 -1
- package/src/CommentBox.tsx +44 -5
- package/src/ComposerTriggers.mdx +1 -0
- package/src/ComposerTriggers.tsx +34 -15
- package/src/DocumentEditor.mdx +1 -1
- package/src/DocumentEditor.stories.tsx +2 -2
- package/src/DocumentEditor.test.tsx +37 -7
- package/src/DocumentEditor.tsx +2 -1
- package/src/LinkCard.mdx +9 -5
- package/src/LinkCard.stories.tsx +17 -2
- package/src/LinkCard.test.tsx +21 -0
- package/src/LinkCard.tsx +35 -16
- package/src/LinkChip.mdx +6 -1
- package/src/LinkChip.stories.tsx +7 -1
- package/src/LinkChip.test.tsx +12 -0
- package/src/LinkChip.tsx +6 -2
- package/src/LinkChips.mdx +4 -3
- package/src/LinkChips.stories.tsx +2 -2
- package/src/LinkChips.test.tsx +1 -2
- package/src/LinkChips.ts +2 -1
- package/src/LinkParts.mdx +3 -2
- package/src/LinkParts.stories.tsx +8 -0
- package/src/LinkParts.tsx +43 -6
- package/src/LinkPlaces.mdx +3 -0
- package/src/LinkPlaces.ts +19 -0
- package/src/LinkRow.mdx +8 -2
- package/src/LinkRow.stories.tsx +14 -2
- package/src/LinkRow.test.tsx +31 -1
- package/src/LinkRow.tsx +69 -25
- package/src/PartCard.mdx +9 -1
- package/src/PartCard.stories.tsx +9 -0
- package/src/PartCard.test.tsx +13 -0
- package/src/PartCard.tsx +19 -5
- package/src/ReferenceCards.test.tsx +4 -35
- package/src/ReferenceCards.ts +10 -119
- package/src/ReferenceMenu.mdx +6 -4
- package/src/ReferenceMenu.test.tsx +67 -5
- package/src/ReferenceMenu.tsx +18 -7
- package/src/Select.mdx +4 -0
- package/src/Select.stories.tsx +11 -1
- package/src/Select.tsx +10 -2
- package/src/editor.ts +0 -3
- package/src/eslint/no-restyled-part.ts +1 -1
- package/src/index.ts +4 -1
- package/src/linked.examples.ts +6 -0
- package/src/linked.test.ts +35 -1
- package/src/linked.ts +108 -3
- package/src/linkedFrom.test.tsx +42 -2
- package/src/linkedFrom.ts +15 -7
- package/src/registry/registry.test.ts +25 -6
- package/src/ReferenceCards.mdx +0 -86
- package/src/ReferenceCards.stories.tsx +0 -66
|
@@ -26,7 +26,7 @@ import { SCHEMA_VERSION, validateRegistry, type Registry, type RegistryEntry } f
|
|
|
26
26
|
const root = process.cwd()
|
|
27
27
|
const registry = buildRegistry({ root })
|
|
28
28
|
/** Editor extensions: named like components by the catalogue, and not React components. */
|
|
29
|
-
const EDITOR_EXTENSIONS = ['KeptSelection', 'BlockId', 'UnknownBlock', 'ReferenceNode', 'AttachmentNode', 'PersonMention', 'UrgentPersonMention', 'PersonReference', 'CaptionedReference', 'ReferenceTrigger', 'SlashCommands', 'PastedImages', 'PastedMarkdown', 'CodeBlockColours', 'Checklist', 'Callout', '
|
|
29
|
+
const EDITOR_EXTENSIONS = ['KeptSelection', 'BlockId', 'UnknownBlock', 'ReferenceNode', 'AttachmentNode', 'PersonMention', 'UrgentPersonMention', 'PersonReference', 'CaptionedReference', 'ReferenceTrigger', 'SlashCommands', 'PastedImages', 'PastedMarkdown', 'CodeBlockColours', 'Checklist', 'Callout', 'LinkChips', 'LinkPlaces', 'ReferenceMenu', 'CommentHighlights', 'ComposeKeys']
|
|
30
30
|
const entry = (name: string): RegistryEntry => {
|
|
31
31
|
const found = registry.entries.find((candidate) => candidate.name === name)
|
|
32
32
|
if (!found) throw new Error(`no entry for ${name}`)
|
|
@@ -48,19 +48,19 @@ describe('the registry builds', () => {
|
|
|
48
48
|
expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('counts
|
|
51
|
+
it('counts 210 names over 98 files: 138 components, 70 helpers and 2 hooks (cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
|
|
52
52
|
// The reconciliation GATES.md §24 explains. If this changes, that changes.
|
|
53
53
|
// The `EDITOR_EXTENSIONS` count as components by their names; they are
|
|
54
54
|
// editor extensions, documented on SelectionToolbar's, BlockNodes' and
|
|
55
55
|
// ComposerTriggers' pages.
|
|
56
56
|
const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
|
|
57
|
-
expect(kinds).toEqual({ component:
|
|
57
|
+
expect(kinds).toEqual({ component: 138, helper: 70, hook: 2 })
|
|
58
58
|
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(98)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('gives every entry a purpose, from its own page or from the comment above it', () => {
|
|
62
62
|
expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
|
|
63
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(
|
|
63
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(89)
|
|
64
64
|
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(121)
|
|
65
65
|
})
|
|
66
66
|
|
|
@@ -262,8 +262,27 @@ describe('the ids point at something', () => {
|
|
|
262
262
|
|
|
263
263
|
it('gives every component a page and a story, and only a helper none', () => {
|
|
264
264
|
const without = registry.entries.filter((one) => one.docsId === null || one.storyId === null)
|
|
265
|
-
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page),
|
|
266
|
-
expect(without.map((one) => one.name).sort()).toEqual([
|
|
265
|
+
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's and cardShapeMemory's on LinkCard's), and a chip's card choice (ReferenceMenu writes it).
|
|
266
|
+
expect(without.map((one) => one.name).sort()).toEqual([
|
|
267
|
+
'archivedLine',
|
|
268
|
+
'cardShapeMemory',
|
|
269
|
+
'chosenOf',
|
|
270
|
+
'cn',
|
|
271
|
+
'inTheBox',
|
|
272
|
+
'isApplePlatform',
|
|
273
|
+
'isSuggestionActive',
|
|
274
|
+
'isSuggestionOpen',
|
|
275
|
+
'linkStateFrom',
|
|
276
|
+
'linkedFrom',
|
|
277
|
+
'loadingShapeOf',
|
|
278
|
+
'referenceAtSelection',
|
|
279
|
+
'referenceCardPlacements',
|
|
280
|
+
'setReferenceCard',
|
|
281
|
+
'setReferenceCardAt',
|
|
282
|
+
'shortcutLabel',
|
|
283
|
+
'suggestionPopup',
|
|
284
|
+
'unavailableMemory',
|
|
285
|
+
])
|
|
267
286
|
expect(without.every((one) => one.kind !== 'component')).toBe(true)
|
|
268
287
|
})
|
|
269
288
|
|
package/src/ReferenceCards.mdx
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas } from '@storybook/addon-docs/blocks'
|
|
2
|
-
import * as ReferenceCardsStories from './ReferenceCards.stories'
|
|
3
|
-
|
|
4
|
-
<Meta of={ReferenceCardsStories} />
|
|
5
|
-
|
|
6
|
-
# ReferenceCards
|
|
7
|
-
|
|
8
|
-
**Deprecated.** A new editor uses **LinkPlaces**. This stays only for an editor
|
|
9
|
-
that has not moved yet.
|
|
10
|
-
|
|
11
|
-
A chip in a document can ask for a card after its line: compact, detailed or
|
|
12
|
-
none. The choice is the chip's own `embed`, so the card moves and goes with it.
|
|
13
|
-
This draws no card itself. It places a slot after each line that asks for
|
|
14
|
-
one, and the app draws its own card into it.
|
|
15
|
-
|
|
16
|
-
<Canvas of={ReferenceCardsStories.InAnEditor} />
|
|
17
|
-
|
|
18
|
-
## When
|
|
19
|
-
|
|
20
|
-
- **An editor of a document whose chips can carry a card**: pair it with
|
|
21
|
-
**ReferenceNode**, which holds the choice, and **SelectionToolbar**, where
|
|
22
|
-
the app offers it for the selected chip.
|
|
23
|
-
|
|
24
|
-
## When not
|
|
25
|
-
|
|
26
|
-
- A new editor of a document → **LinkPlaces**: since §13.3's line rule, a
|
|
27
|
-
card draws in a lone link's row's place, and a card on a link in a sentence
|
|
28
|
-
draws nothing. **DocumentEditor** uses it; this stays for an editor that has
|
|
29
|
-
not moved yet.
|
|
30
|
-
- A document that is only read → **RichText**, with each block's cards drawn
|
|
31
|
-
after it from the text's own description of them.
|
|
32
|
-
- A text whose cards travel beside it rather than on its chips → the app keeps
|
|
33
|
-
that choice itself, and this has nothing to read.
|
|
34
|
-
|
|
35
|
-
## How
|
|
36
|
-
|
|
37
|
-
```tsx
|
|
38
|
-
import { createPortal } from 'react-dom'
|
|
39
|
-
import { EditorContent, useEditor } from '@tiptap/react'
|
|
40
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
41
|
-
import { ToolbarButton } from '@estiva-app/ui'
|
|
42
|
-
import {
|
|
43
|
-
BlockId,
|
|
44
|
-
ReferenceCards,
|
|
45
|
-
ReferenceNode,
|
|
46
|
-
SelectionToolbar,
|
|
47
|
-
referenceAtSelection,
|
|
48
|
-
setReferenceCard,
|
|
49
|
-
useReferenceCards,
|
|
50
|
-
type ReferenceCard,
|
|
51
|
-
type ReferenceViewProps,
|
|
52
|
-
} from '@estiva-app/ui/editor'
|
|
53
|
-
|
|
54
|
-
const Reference = ({ uri }: ReferenceViewProps) => <span>{uri}</span>
|
|
55
|
-
const Cards = ({ cards }: { cards: ReferenceCard[] }) => <div>{cards.map((card) => card.layout).join(', ')}</div>
|
|
56
|
-
|
|
57
|
-
const editor = useEditor({ extensions: [StarterKit, BlockId, ReferenceNode.configure({ view: Reference }), ReferenceCards] })
|
|
58
|
-
const slots = useReferenceCards(editor)
|
|
59
|
-
const chip = editor ? referenceAtSelection(editor.state) : null
|
|
60
|
-
|
|
61
|
-
;<>
|
|
62
|
-
<EditorContent editor={editor} />
|
|
63
|
-
{slots.map((slot) => createPortal(<Cards cards={slot.cards} />, slot.element, slot.key))}
|
|
64
|
-
<SelectionToolbar editor={editor}>
|
|
65
|
-
{chip && editor && (
|
|
66
|
-
<ToolbarButton aria-label="Detailed" pressed={chip.layout === 'detailed'} onMouseDown={(e) => e.preventDefault()} onClick={() => setReferenceCard(editor, chip.layout === 'detailed' ? 'none' : 'detailed')}>
|
|
67
|
-
D
|
|
68
|
-
</ToolbarButton>
|
|
69
|
-
)}
|
|
70
|
-
</SelectionToolbar>
|
|
71
|
-
</>
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
- **A slot keeps its element while its line lives.** It is keyed by the
|
|
75
|
-
line's block id, so typing above a card does not make it load again.
|
|
76
|
-
- **The slot is not text.** It cannot be typed into or selected, and a click
|
|
77
|
-
on a card stays the card's.
|
|
78
|
-
- **A layout this version does not know draws as compact.** The writer asked
|
|
79
|
-
for a card, and the smallest is the safe reading.
|
|
80
|
-
- **Press without taking the focus.** A button in the toolbar prevents its
|
|
81
|
-
press's default, or the editor loses the chip's selection and the toolbar
|
|
82
|
-
goes.
|
|
83
|
-
|
|
84
|
-
## What it owns
|
|
85
|
-
|
|
86
|
-
Nothing. It only draws. Clicks and keys are yours.
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
|
-
// @estiva-escape(no-hand-rolled-behaviour): the slots ReferenceCards places inside the document are drawn into by a portal, which keeps the app's providers around its card
|
|
3
|
-
import { createPortal } from 'react-dom'
|
|
4
|
-
import { EditorContent, useEditor } from '@tiptap/react'
|
|
5
|
-
import StarterKit from '@tiptap/starter-kit'
|
|
6
|
-
import { BlockId, ReferenceNode } from './BlockNodes'
|
|
7
|
-
import { Card } from './Card'
|
|
8
|
-
import { ReferenceCards, useReferenceCards } from './ReferenceCards'
|
|
9
|
-
import { richTextClassName } from './RichText'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* A chip that asks for a card gets a slot after its line, and the app draws
|
|
13
|
-
* its card there. Here the "card" is a stand-in box naming the layout: the real
|
|
14
|
-
* one is the app's, which knows how to resolve what the chip points at.
|
|
15
|
-
*/
|
|
16
|
-
const meta = {
|
|
17
|
-
title: 'Writing/ReferenceCards',
|
|
18
|
-
// On its way out: the sidebar says "deprecated" beside its name (.storybook/manager.ts).
|
|
19
|
-
tags: ['deprecated'],
|
|
20
|
-
parameters: { layout: 'padded' },
|
|
21
|
-
} satisfies Meta
|
|
22
|
-
|
|
23
|
-
export default meta
|
|
24
|
-
type Story = StoryObj
|
|
25
|
-
|
|
26
|
-
const ref = (uri: string, embed?: string) => ({ type: 'reference', attrs: { uri, ...(embed ? { embed } : {}) } })
|
|
27
|
-
|
|
28
|
-
function Box() {
|
|
29
|
-
const editor = useEditor({
|
|
30
|
-
extensions: [StarterKit, BlockId, ReferenceNode, ReferenceCards],
|
|
31
|
-
content: {
|
|
32
|
-
type: 'doc',
|
|
33
|
-
content: [
|
|
34
|
-
{ type: 'paragraph', attrs: { blockId: 'p1' }, content: [{ type: 'text', text: 'Blocked by ' }, ref('nostr:naddr1first', 'detailed'), { type: 'text', text: ' until it ships.' }] },
|
|
35
|
-
{ type: 'paragraph', attrs: { blockId: 'p2' }, content: [{ type: 'text', text: 'See also ' }, ref('nostr:naddr1second')] },
|
|
36
|
-
{ type: 'paragraph', attrs: { blockId: 'p3' }, content: [ref('nostr:naddr1third', 'compact')] },
|
|
37
|
-
],
|
|
38
|
-
},
|
|
39
|
-
editorProps: { attributes: { class: richTextClassName('default', 'outline-none'), 'aria-label': 'Text' } },
|
|
40
|
-
})
|
|
41
|
-
const slots = useReferenceCards(editor)
|
|
42
|
-
// @estiva-escape(no-hand-rolled-behaviour): the app's card goes into the slot ReferenceCards placed after its line, inside the document; no Base UI part owns a place in an editor's text
|
|
43
|
-
return (
|
|
44
|
-
<Card fill="surface" className="flex w-[520px] flex-col gap-2 p-3">
|
|
45
|
-
<EditorContent editor={editor} />
|
|
46
|
-
{slots.map((slot) =>
|
|
47
|
-
createPortal(
|
|
48
|
-
<div className="mt-2 flex flex-col gap-2">
|
|
49
|
-
{slot.cards.map((card, i) => (
|
|
50
|
-
<Card key={`${card.uri}-${i}`} fill="surface" className="p-3">
|
|
51
|
-
<span className="text-body-2 text-text-secondary">
|
|
52
|
-
{card.layout} card for {card.uri}
|
|
53
|
-
</span>
|
|
54
|
-
</Card>
|
|
55
|
-
))}
|
|
56
|
-
</div>,
|
|
57
|
-
slot.element,
|
|
58
|
-
slot.key,
|
|
59
|
-
),
|
|
60
|
-
)}
|
|
61
|
-
</Card>
|
|
62
|
-
)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Three chips: a detailed card after the first line, none for the second, a compact one after the third. */
|
|
66
|
-
export const InAnEditor: Story = { render: () => <Box /> }
|